Browse Source

no message

linwenxin 4 tháng trước cách đây
mục cha
commit
259b5522fd

+ 16 - 5
src/views/mallManagement/purchaseScheduleManagement/purchaseSchedule/index.vue

@@ -135,15 +135,26 @@ export default {
   watch: {
     'formData.items': {
       handler(newVal, oldVal) {
-        this.formData.totalAmount = newVal
+        this.formData.totalAmount = (
+          newVal
+            .filter(item => item.qty && item.price)
+            .map(item => item.qty * item.price)
+            .reduce((prev, cur, index, arr) => {
+              return prev + cur
+            }, 0) + (Number(this.formData.freightAmount) || 0)
+        ).toFixed(2)
+      },
+      deep: true
+    },
+    'formData.freightAmount'(newVal, oldVal) {
+      this.formData.totalAmount = (
+        this.formData.items
           .filter(item => item.qty && item.price)
           .map(item => item.qty * item.price)
           .reduce((prev, cur, index, arr) => {
             return prev + cur
-          }, 0)
-          .toFixed(2)
-      },
-      deep: true
+          }, 0) + (Number(this.formData.freightAmount) || 0)
+      ).toFixed(2)
     }
   },
   methods: {