|
@@ -237,24 +237,51 @@ export function formatSize (size, pointLength, units) {
|
|
|
return (unit === 'B' ? size : size.toFixed(pointLength === undefined ? 2 : pointLength)) + (unit || '')
|
|
|
}
|
|
|
|
|
|
-// 文件类型转换
|
|
|
-export function docTypeConvert (docType = 'pdf') {
|
|
|
- const typeMap = {
|
|
|
- doc: 'word',
|
|
|
- docx: 'word',
|
|
|
- xls: 'excel',
|
|
|
- xlsx: 'excel',
|
|
|
- ppt: 'ppt',
|
|
|
- pdf: 'pdf',
|
|
|
- 1: 'word', // doc
|
|
|
- 2: 'pdf',
|
|
|
- 3: 'excel', // xls
|
|
|
- 4: 'ppt',
|
|
|
- 5: 'txt',
|
|
|
- 6: '其他'
|
|
|
+// 金额类型转换
|
|
|
+export function moneyUnit (m, type = 'string', lv = 0) {
|
|
|
+ const mUnit = {
|
|
|
+ levelArr: ['元', '万元', '亿元', '万亿元'],
|
|
|
+ test (num, type, lv) {
|
|
|
+ if (num === 0) {
|
|
|
+ if (type === 'string') {
|
|
|
+ return '0元'
|
|
|
+ }
|
|
|
+ if (type === 'lv') {
|
|
|
+ return this.levelArr[lv]
|
|
|
+ }
|
|
|
+ if (type === 'number') {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ if (type === 'index') {
|
|
|
+ return lv
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var result = num / Math.pow(10000, lv);
|
|
|
+
|
|
|
+ if (result > 10000 && lv < 2) {
|
|
|
+ return this.test(num, type, lv + 1)
|
|
|
+ } else {
|
|
|
+ if (type === 'string') {
|
|
|
+ return String(Math.floor(result * 100) / 100).replace('.00', '') + this.levelArr[lv]
|
|
|
+ }
|
|
|
+ if (type === 'lv') {
|
|
|
+ return this.levelArr[lv]
|
|
|
+ }
|
|
|
+ if (type === 'number') {
|
|
|
+ return String(Math.floor(result * 100) / 100).replace('.00', '')
|
|
|
+ }
|
|
|
+ if (type === 'index') {
|
|
|
+ return lv
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (m === undefined || m === null) {
|
|
|
+ return ''
|
|
|
+ } else {
|
|
|
+ return mUnit.test(m, type, lv)
|
|
|
}
|
|
|
- const type = typeMap[docType]
|
|
|
- return type || docType // map中不存在的,则返回原始类型
|
|
|
}
|
|
|
|
|
|
/**
|