Ver código fonte

附件信息修改

lizhenhao 2 anos atrás
pai
commit
9df0cc0f9d
1 arquivos alterados com 15 adições e 7 exclusões
  1. 15 7
      src/views/common/UpLoadComponent.vue

+ 15 - 7
src/views/common/UpLoadComponent.vue

@@ -205,14 +205,22 @@
       getSize (value) {
         if (this.commonJS.isEmpty(value)) {
           return '0 B'
+        } else {
+          let val = parseInt(value)
+          if (this.commonJS.isEmpty(val)) {
+            return '0 B'
+          }
+          if (isNaN(val)) {
+            return '0 B'
+          }
+          if (val === 0) {
+            return '0 B'
+          }
+          let k = 1024
+          let sizes = ['B', 'KB', 'MB', 'GB', 'PB', 'TB', 'EB', 'ZB', 'YB']
+          let i = Math.floor(Math.log(val) / Math.log(k))
+          return (val / Math.pow(k, i)).toPrecision(3) + '' + sizes[i]
         }
-        if (value === 0) {
-          return '0 B'
-        }
-        let k = 1024
-        let sizes = ['B', 'KB', 'MB', 'GB', 'PB', 'TB', 'EB', 'ZB', 'YB']
-        let i = Math.floor(Math.log(value) / Math.log(k))
-        return (value / Math.pow(k, i)).toPrecision(3) + '' + sizes[i]
       },
       async changes (file, fileList) {
         // if (file.status !== 'ready') {