huangbin 4 years ago
parent
commit
d8fcef3a19
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/common/setup/table/clolumn.ts

+ 5 - 1
src/common/setup/table/clolumn.ts

@@ -87,6 +87,7 @@ function getFromatterFn(val: string) {
     const arr = val.split(',');
     const first = arr[0]
     let result: Function | null = null
+
     switch (first) {
         case 'FormatterUnit':   // 处理单位
             result = (obj: any) => arr[1] ? obj.text + obj.record[arr[1]] : obj.text
@@ -95,7 +96,10 @@ function getFromatterFn(val: string) {
             result = (obj: any) => (Number(obj.text) * 100).toFixed(2) + '%'
             break
         case 'FromatterDecimal':  // 数值小数位
-            result = (obj: any) => arr[1] ? (obj.text ? obj.text.toFixed(obj.record[arr[1]]) : obj.text) : obj.text
+            result = (obj: any) => {
+                const value = obj.text;
+                return (value && arr[1]) ? value.toFixed(obj.record[arr[1]]) : value
+            }
             break
     }
     return result