Browse Source

运算处理

lucky 2 years ago
parent
commit
93f74f9f1a
1 changed files with 25 additions and 1 deletions
  1. 25 1
      src/views/mobile/order/index.vue

+ 25 - 1
src/views/mobile/order/index.vue

@@ -379,7 +379,10 @@ export default {
         this.tableData.forEach((v1) => {
           v1.order_goods_num =
             v1.order_num + v1.unit + "/" + v1.unit_weight + "kg";
-          v1.order_goods_num_t = v1.order_num * 1 * (v1.unit_weight * 1) + "kg";
+          // v1.order_goods_num_t = v1.order_num * 1 * (v1.unit_weight * 1) + "kg";
+          v1.order_goods_num_t = this.accMul(this.accMul(v1.order_num,1),this.accMul(v1.unit_weight,1)) + "kg";
+
+          
         });
         console.log(this.tableData);
         this.pageInfo.total = Number(res.data.count);
@@ -390,6 +393,27 @@ export default {
         this.pageInfo.total = 0;
       }
       this.loading = false;
+
+      
+
+      
+      
+    },
+    //乘法精度问题
+    accMul(arg1, arg2) {
+      var m = 0,
+        s1 = arg1.toString(),
+        s2 = arg2.toString();
+      try {
+        m += s1.split(".")[1].length;
+      } catch (e) {}
+      try {
+        m += s2.split(".")[1].length;
+      } catch (e) {}
+      return (
+        (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
+        Math.pow(10, m)
+      );
     },
     /**
      * 导出