Kaynağa Gözat

fix: 直调选项联动

zh 2 yıl önce
ebeveyn
işleme
55e729b6b0

+ 14 - 8
src/views/supply/policy/components/retail_form.vue

@@ -75,7 +75,7 @@
         </el-col>
         <el-col :span="24" :sm="12" :lg="12">
           <el-form-item label="是否直调" prop="isAllDirect">
-            <el-checkbox v-model="mainForm.isAllDirect">{{ mainForm.isAllDirect ? '是' : '否' }}</el-checkbox>
+            <el-checkbox v-model="mainForm.isAllDirect" @change="handleCheckbox">{{ mainForm.isAllDirect ? '是' : '否' }}</el-checkbox>
           </el-form-item>
         </el-col>
         <!--        <el-col :span="24" :sm="12" :lg="12" >-->
@@ -865,8 +865,10 @@ export default {
       handler(newValue, oldValue) {
         if (newValue && newValue.length) {
           newValue.forEach((item, index) => {
-            if (this.mainForm.isAllDirect) {
-              this.$set(this.goodsList[index], 'isDirectTransfer', true)
+            if (newValue.every(k => k.isDirectTransfer === true)) {
+              this.mainForm.isAllDirect = true
+            } else {
+              this.mainForm.isAllDirect = false
             }
             if (this.policyConditionId) {
               this.$set(this.goodsList[index], 'policyConditionId', this.policyConditionId || this.goodsList[index].policyConditionId)
@@ -910,6 +912,11 @@ export default {
   },
 
   methods: {
+    handleCheckbox(e) {
+      this.goodsList.forEach(k => {
+        this.$set(k, 'isDirectTransfer', e)
+      })
+    },
     blurQty(e, row) {
       if (!e) {
         this.$set(row, 'qty', 1)
@@ -1073,13 +1080,12 @@ export default {
           this.screenForm.policyId = this.policyId
           if (this.listItem) {
             this.policyConditionId = data[0].id
-            console.log('edit', this.policyConditionId);
-
+            console.log('edit', this.policyConditionId)
           }
         } else {
           this.screenForm.policyId = data[0].policyId
           this.policyConditionId = data[0].id
-          console.log('xinz', this.policyConditionId);
+          console.log('xinz', this.policyConditionId)
         }
 
         for (let i = 0; i < this.popArr.length; i++) {
@@ -1118,7 +1124,7 @@ export default {
 
       this.screenForm.policyId = data.policyId
       this.policyConditionId = data.id
-      console.log('获取条件相对应的比列', this.policyConditionId );
+      console.log('获取条件相对应的比列', this.policyConditionId)
     },
     async handleGetPolicyList() {
       const { data } = await policyList({
@@ -1931,7 +1937,7 @@ export default {
               this.goBack()
             })
           } else {
-            console.log('添加成功',this.policyConditionId);
+            console.log('添加成功', this.policyConditionId)
             params.retailOrderItemList.forEach(k => {
               k.id = null
               k.policyConditionId = this.policyConditionId

+ 14 - 12
src/views/supply/retail/components/retail_form.vue

@@ -75,7 +75,7 @@
         </el-col>
         <el-col :span="24" :sm="12" :lg="12">
           <el-form-item label="是否直调" prop="isAllDirect">
-            <el-checkbox v-model="mainForm.isAllDirect">{{ mainForm.isAllDirect?'是':'否' }}</el-checkbox>
+            <el-checkbox v-model="mainForm.isAllDirect" @change="handleCheckbox">{{ mainForm.isAllDirect?'是':'否' }}</el-checkbox>
           </el-form-item>
         </el-col>
         <!--        <el-col :span="24" :sm="12" :lg="12">-->
@@ -581,7 +581,7 @@ export default {
   data() {
     return {
       mainForm: {
-        isAllDirect:'',
+        isAllDirect: '',
         orderNum: '',
         date: '',
         // type: '',
@@ -678,11 +678,14 @@ export default {
         }
 
         if (newValue && newValue.length) {
+          if (newValue.every(k => k.isDirectTransfer === true)) {
+            this.mainForm.isAllDirect = true
+          } else {
+            this.mainForm.isAllDirect = false
+          }
           newValue.forEach((item, index) => {
             console.log(this.correspondName)
-            if (this.mainForm.isAllDirect) {
-              this.$set(this.goodsList[index], 'isDirectTransfer', true)
-            }
+
             if (this.correspondId) {
               this.goodsList[index].correspondName = this.correspondName
               this.goodsList[index].correspondId = this.correspondId
@@ -701,11 +704,6 @@ export default {
       },
       immediate: true,
       deep: true
-    },
-    'mainForm.isAllDirect'(e) {
-      this.goodsList.forEach(k => {
-        this.$set(k, 'isDirectTransfer', e)
-      })
     }
   },
 
@@ -732,7 +730,11 @@ export default {
     goBack() {
       this.$emit('backListFormDetail')
     },
-
+    handleCheckbox(e) {
+      this.goodsList.forEach(k => {
+        this.$set(k, 'isDirectTransfer', e)
+      })
+    },
     // 获取详情
     getDetail() {
       getDetail({ id: this.listItem.id }).then(res => {
@@ -1118,7 +1120,7 @@ export default {
             // theTime: this.mainForm.date + ' 00:00:00',
             // mainId: this.mainForm.type,
             // mainName,
-            isAllDirect:this.mainForm.isAllDirect,
+            isAllDirect: this.mainForm.isAllDirect,
             k3ServiceId: this.mainForm.salesMan,
             isPlanOrder: this.mainForm.isPlanOrder,
             correspondName: this.correspondName,