Просмотр исходного кода

第一次选择计量单位和包装单位默认添加包装组

huang_an 1 год назад
Родитель
Сommit
3a962f9a79

+ 46 - 5
src/views/material/product/components/WarehouseInfo.vue

@@ -245,6 +245,12 @@
         default() {
           return '';
         }
+      },
+      packingUnit: {
+        type: String,
+        default() {
+          return '';
+        }
       }
     },
     watch: {
@@ -300,7 +306,6 @@
                     break;
                 }
               });
-
               arr.push(obj);
             });
             this.packagingSpecification = arr;
@@ -336,7 +341,8 @@
             label: 'KG',
             value: 'KG'
           }
-        ]
+        ],
+        hasPushed: false
       };
     },
     created() {
@@ -344,11 +350,46 @@
         'this.packageDispositionVOList-',
         this.packageDispositionVOList
       );
+      if (this.packageDispositionVOList.length == 0) {
+        this.hasPushed = false;
+      }
+      console.log(this.hasPushed, 'has');
+    },
+    mounted() {
+      console.log(this.packingRules, 'packingRules');
     },
     methods: {
+      async defaultBuild(val) {
+        if (!this.hasPushed) {
+          let code = await getCode('package_disposition');
+          this.ruleItem = {
+            code: code,
+            name: '默认包装组',
+            status: 1,
+            minPackageCell: '1',
+            packageUnit: this.measuringUnit,
+            minConversionUnit: this.packingUnit,
+            inPackageCell: '',
+            inConversionUnit: '',
+            outPackageCell: '',
+            inConversionUnit: '',
+            outConversionUnit: ''
+          };
+          this.packagingSpecification.push(this.ruleItem);
+          console.log('111111第一次添加');
+          this.packingRules = this.ruleItem.code;
+          this.hasPushed = true;
+        } else {
+          console.log('数组已经进行过push操作,无法再次添加元素。');
+          this.packagingSpecification = this.packagingSpecification.map(
+            (item) => {
+              return { ...item, minConversionUnit: val };
+            }
+          );
+        }
+      },
       statusChange(value, indexs) {
         console.log(value);
-        console.log(this.packagingSpecification);
         if (value == 1) {
           this.packagingSpecification = this.packagingSpecification.map(
             (item, index) => {
@@ -379,9 +420,9 @@
           code: code,
           name: '',
           status: 0,
-          minPackageCell: '',
+          minPackageCell: '1',
           packageUnit: this.measuringUnit,
-          minConversionUnit: '',
+          minConversionUnit: this.packingUnit,
           inPackageCell: '',
           inConversionUnit: '',
           outPackageCell: '',

+ 15 - 1
src/views/material/product/detail.vue

@@ -110,6 +110,7 @@
                 dictName="计量单位"
                 clearable
                 v-model="form.measuringUnit"
+                @change="changeUnit"
               >
               </DictSelection>
             </el-form-item>
@@ -132,6 +133,7 @@
                 dictName="包装单位"
                 clearable
                 v-model="form.packingUnit"
+                @change="changeUnit"
               >
               </DictSelection>
             </el-form-item>
@@ -224,6 +226,7 @@
       ref="warehouseRefs"
       :form="categoryWms"
       :measuringUnit="form.measuringUnit"
+      :packingUnit="form.packingUnit"
       :packageDispositionVOList="packageDispositionVOList"
       @change="changePackagingSpecification"
     />
@@ -322,6 +325,9 @@
           categoryLevelGroupName: '',
           categoryLevelName: '',
           isConsumable: 1,
+          measuringUnit: '',
+          weightUnit: '',
+          packingUnit: '',
 
           extField: {}
         },
@@ -392,7 +398,9 @@
               categoryLevelGroupName: '',
               // categoryLevelName: '',
               isConsumable: 1,
-
+              measuringUnit: '',
+              weightUnit: '',
+              packingUnit: '',
               extField: {}
             };
 
@@ -475,7 +483,13 @@
       this.getDictList('productionType');
     },
     methods: {
+      changeUnit() {
+        if (this.form.measuringUnit && this.form.packingUnit) {
+          this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+        }
+      },
       changePackagingSpecification(val) {
+        console.log('changePackagingSpecification---', val);
         this.packagingSpecificationList = val;
       },
       async _getDetails() {

+ 2 - 1
src/views/material/product/index.vue

@@ -166,13 +166,13 @@
           this.treeLoading = false;
           if (res?.code === '0') {
             this.treeList = res.data;
-
             if (!this.$route.query.categoryLevelId) {
               this.$nextTick(() => {
                 //默认高亮第一级树节点;
                 if (this.treeList[0]) {
                   this.rootTreeId = this.treeList[0].id;
                   this.getDetail(this.treeList[0].id);
+                  this.publicfun(this.treeList[0]);
                 }
               });
             } else {
@@ -229,6 +229,7 @@
 
         this.curNode = node;
         await this.publicfun(data);
+        console.log(data, '点击物品分类');
         await this.getDetail(data.id);
       },
       publicfun(data) {

+ 1 - 0
src/views/material/product/oneProduct.vue

@@ -170,6 +170,7 @@
                   this.rootTreeId = this.treeList[0].id;
                   this.getDetail(this.treeList[0].id);
                   console.log(this.treeList[0].id, 'rootTreeId');
+                  this.publicfun(this.treeList[0]);
                 }
               });
             } else {