Pārlūkot izejas kodu

选了计划单,商品信息的采购数量和单价自动带出不能修改(非计划单不变)

FengChaoYu 1 mēnesi atpakaļ
vecāks
revīzija
baa5ad11c1

+ 26 - 2
src/views/salesPurchasing/goodsPurchasedStored/index.vue

@@ -110,6 +110,7 @@ import common from '../mixins/common_code'
 import jihuamingxi from '../mixins/jihuamingxi'
 import { delayPerform, firstPerform, intervalPerform, passivePerform, queuePerform } from 'js-perform-lock'
 import { required, diyRequired } from '@/components/template/rules_verify.js'
+import Collapse from '@/components/Common/collapse.vue'
 export default {
   components: { TemplatePage },
   mixins: [import_mixin, operation_mixin, form_ty, storage_table, storage_goods, storage_codes, common, jihuamingxi],
@@ -165,7 +166,7 @@ export default {
         items: [],
         planItems: [],
         codeInfoList: [],
-        isPlan: ''
+        isPlan: false
       },
       activeName: 'goodsInfo',
       goods_material_id: '',
@@ -302,6 +303,13 @@ export default {
       this.$nextTick(() => {
         this.pageShow = true
       })
+    },
+    'formData.isPlan'(newVal, oldVal) {
+      // 当isPlan值变化时执行相应操作
+      if (newVal) {
+        // 仅当isPlan为true时执行
+        this.isPlanHandleItem(newVal);
+      }
     }
   },
   methods: {
@@ -367,7 +375,7 @@ export default {
             qty: item.qty,
             outQty: '', //
             partsQty: '', //
-            price: '', //
+            price: item.price, //
             recQty: '', //
             retQty: '', //
             seriesName: item.seriesName,
@@ -612,6 +620,22 @@ export default {
         this.handleClose()
         this.$refs.pageRef.refreshList()
       })
+    },
+    // 计划单遍历商品信息注入数量和采购单价
+    isPlanHandleItem(val) {
+      if (val && this.formData.planItems && this.formData.planItems.length > 0) {
+        // planItems非空时遍历
+        this.formData.items.forEach(item => {
+          item.qty = 0;
+          item.price = 0;
+          this.formData.planItems.forEach(planItem => {
+            if (item.goodsMaterialId === planItem.goodsMaterialId) {
+              item.qty = (item.qty || 0) + (planItem.recQty || 0);
+              item.price = planItem.price || 0;
+            }
+          });
+        });
+      }
     }
   }
 }

+ 3 - 0
src/views/salesPurchasing/mixins/jihuamingxi.js

@@ -100,6 +100,9 @@ export default {
                     onInput={val => {
                       row[column.columnAttributes.prop] = val <= 0 ? 0 : Number(val)
                     }}
+                    onBlur={val => {
+                      this.isPlanHandleItem(this.formData.isPlan)
+                    }}
                     type="number"
                     placeholder="请输入"
                   ></el-input>

+ 10 - 6
src/views/salesPurchasing/mixins/storage_goods.js

@@ -346,6 +346,7 @@ export default {
                     }}
                     type="number"
                     placeholder="请输入"
+                    disabled={this.formData.isPlan}
                   ></el-input>
                 </el-form-item>
               </div>
@@ -423,6 +424,7 @@ export default {
                     }}
                     type="number"
                     placeholder="请输入"
+                    disabled={this.formData.isPlan}
                   ></el-input>
                 </el-form-item>
               </div>
@@ -585,6 +587,7 @@ export default {
       }
     },
     getVfyKey(index, bool = true) {
+      this.isPlanHandleItem(this.formData.isPlan);
       return [
         ...(() => {
           if (bool) {
@@ -628,6 +631,7 @@ export default {
     },
     // 添加商品信息
     addGoodsInfo() {
+      this.isPlanHandleItem(this.formData.isPlan);
       if (this.isEditIndex > -1) {
         this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
           if (valid && this.eidtItems()) {
@@ -642,15 +646,15 @@ export default {
               goodsMaterialName: '',
               specsName: '',
               unit: '',
-              qty: '',
+              qty: 0,
               insideQty: '',
               outQty: '',
               partsQty: '',
               insideCodeQty: '',
               outCodeQty: '',
               partsCodeQty: '',
-              price: '',
-              amount: '',
+              price: 0,
+              amount: 0,
               stockQty: '',
               factoryNo: ''
             })
@@ -669,15 +673,15 @@ export default {
           goodsMaterialName: '',
           specsName: '',
           unit: '',
-          qty: '',
+          qty: 0,
           insideQty: '',
           outQty: '',
           partsQty: '',
           insideCodeQty: '',
           outCodeQty: '',
           partsCodeQty: '',
-          price: '',
-          amount: '',
+          price: 0,
+          amount: 0,
           stockQty: '',
           factoryNo: ''
         })