Jelajahi Sumber

fix: 新建商品维度权重默认值未初始化导致保存失败

- DimensionWeightPicker: mounted() 时调用 emitValue(),确保 form.dimensionWeights 有默认值
Xiaogang Liao 1 bulan lalu
induk
melakukan
40e42ab770
1 mengubah file dengan 11 tambahan dan 11 penghapusan
  1. 11 11
      cfc-web/src/components/DimensionWeightPicker.vue

+ 11 - 11
cfc-web/src/components/DimensionWeightPicker.vue

@@ -75,20 +75,20 @@ export default {
     }
   },
   watch: {
-    value: {
-      immediate: true,
-      handler(val) {
-        if (Array.isArray(val) && val.length > 0) {
-          val.forEach(w => {
-            const dim = this.dimensions.find(d => d.code === w.dimension)
-            if (dim) {
-              dim.currentValue = w.weight || 0
-            }
-          })
-        }
+    value(val) {
+      if (Array.isArray(val) && val.length > 0) {
+        val.forEach(w => {
+          const dim = this.dimensions.find(d => d.code === w.dimension)
+          if (dim) {
+            dim.currentValue = w.weight || 0
+          }
+        })
       }
     }
   },
+  mounted() {
+    this.emitValue()
+  },
   methods: {
     onWeightChange(changedCode) {
       var changed = this.dimensions.find(function(d) { return d.code === changedCode })