xiaodai2022 hace 2 años
padre
commit
a6b2a5df0e
Se han modificado 1 ficheros con 50 adiciones y 15 borrados
  1. 50 15
      src/views/goodStore/goodsCost/components/baseForm.vue

+ 50 - 15
src/views/goodStore/goodsCost/components/baseForm.vue

@@ -1580,30 +1580,65 @@ export default {
         noble_weight, //贵金属重量
       } = this.ruleForm;
       const {
+        nake_fee, //成本单价
         cost_fee, //工艺费
         delivery_fee, //物流费
-        nake_fee, //成本单价
+
         cert_fee, //证书费
         mark_fee, //加标费
         package_fee, //包装费
         other_fee, //其他费用
       } = e;
-      let total =
-        package_fee * 100 +
-        nake_fee * 100 +
-        mark_fee * 100 +
-        cert_fee * 100 +
-        delivery_fee * 100 +
-        other_fee * 100;
+      let XA = this.add_sum(nake_fee, delivery_fee),
+        XB = this.add_sum(package_fee, cert_fee),
+        XC = this.add_sum(mark_fee, other_fee),
+        XD = 0;
+      let total = this.add_sum(this.add_sum(XA, XB), XC);
+      console.log(total);
       if (this.is_noble && is_gold_price === "1") {
-        let a = noble_price * 100;
-        let b = noble_weight * 1000;
-        let c = cost_fee * 100;
-        let ab = parseInt((a * b) / 1000);
-        let bc = parseInt((b * c) / 1000);
-        total += ab + bc;
+        XD = this.add_sum(
+          this.accMul(noble_price, noble_weight),
+          this.accMul(noble_weight, cost_fee)
+        );
+        total = this.add_sum(total, XD);
+      }
+      return total;
+    },
+    add_sum(arg1, arg2) {
+      var r1, r2, m;
+      try {
+        r1 = arg1.toString().split(".")[1].length;
+      } catch (e) {
+        r1 = 0;
+      }
+
+      try {
+        r2 = arg2.toString().split(".")[1].length;
+      } catch (e) {
+        r2 = 0;
       }
-      return parseFloat(total / 100);
+
+      m = Math.pow(10, Math.max(r1, r2));
+
+      return (this.accMul(arg1, m) + this.accMul(arg2, m)) / m;
+    },
+    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)
+      );
     },
     dataSort(key) {
       return function (a, b) {