wxy 4 years ago
parent
commit
db626c703a
2 changed files with 44 additions and 27 deletions
  1. 9 4
      src/views/order/inDetail.vue
  2. 35 23
      src/views/order/out.vue

+ 9 - 4
src/views/order/inDetail.vue

@@ -404,12 +404,15 @@ export default {
       this.name = arr.name;
     },
     //合同改变
-    async treayChange(data) {
+    async treayChange(data, mm) {
       this.treatyValue = data;
       await this.searchProject();
+      if (mm) return;
+      this.detailForm.item = '';
+      this.detailForm.route = '';
     },
     //项目改变  项目改变就有税率
-    async projectChange(data) {
+    async projectChange(data, mm) {
       this.$set(this, `routeValue`, data);
       await this.searchRoute();
       const res = this.projectList.find(f => f.id == data);
@@ -422,6 +425,8 @@ export default {
         });
         this.$set(this.detailForm, `goods`, duplicate);
       }
+      if (mm) return;
+      this.detailForm.route = '';
     },
     //线路改变
     routeChange(data, type) {
@@ -434,8 +439,8 @@ export default {
     },
     //是否有合同
     async isTreaty() {
-      if (this.detailForm.treaty) this.treayChange(this.detailForm.treaty);
-      if (this.detailForm.item) this.projectChange(this.detailForm.item);
+      if (this.detailForm.treaty) this.treayChange(this.detailForm.treaty, true);
+      if (this.detailForm.item) this.projectChange(this.detailForm.item, true);
       //判断是不是第一次进入,如果是第一次那么不清空,如果是自己手动触发则要清空
       if (this.detailForm.route) await this.routeChange(this.detailForm.route, true);
     },

+ 35 - 23
src/views/order/out.vue

@@ -92,7 +92,7 @@
                         </el-form-item>
 
                         <el-form-item label="供应商方式">
-                          <el-radio-group v-model="item.supply_type" @change="changeSupply" :disabled="item.is_js">
+                          <el-radio-group v-model="item.supply_type" :disabled="item.is_js">
                             <el-radio label="0">自运</el-radio>
                             <el-radio label="1">供应商</el-radio>
                             <el-radio label="2">第三方单位</el-radio>
@@ -109,13 +109,31 @@
 
                         <span v-else-if="item.supply_type == '1'">
                           <el-form-item label="供应商">
-                            <el-select v-model="item.client" placeholder="供应商" @change="changeClient" :disabled="item.is_js">
+                            <el-select
+                              v-model="item.client"
+                              placeholder="供应商"
+                              @change="
+                                val => {
+                                  changeClient(val, index);
+                                }
+                              "
+                              :disabled="item.is_js"
+                            >
                               <el-option v-for="item in supClientList" :key="item.label" :label="item.name" :value="item.id"> </el-option>
                             </el-select>
                           </el-form-item>
 
                           <el-form-item label="合同">
-                            <el-select v-model="item.treaty" placeholder="合同" @change="changeTreaty" :disabled="item.is_js">
+                            <el-select
+                              v-model="item.treaty"
+                              placeholder="合同"
+                              @change="
+                                val => {
+                                  changeTreaty(val, index);
+                                }
+                              "
+                              :disabled="item.is_js"
+                            >
                               <el-option v-for="item in treatyList" :key="item.label" :label="item.number" :value="item.id"> </el-option>
                             </el-select>
                           </el-form-item>
@@ -429,48 +447,42 @@ export default {
       const obj = this.userList.find(i => i.id === data);
       if (obj) return obj.name;
     },
-    // 选择运输类型
-    // 选择自运&第三方时,路线赋值
-    changeSupply(value) {
-      // if (value == 0 || value == 2) {
-      //   this.$set(this.form, `route`, this.depositRoute);
-      // }
-      console.log(value);
-    },
     // 选择供应商,查询合同
-    async changeClient(value) {
+    async changeClient(value, index) {
       let res = await this.treatyQuery({ client: value });
       if (this.$checkRes(res)) {
         this.$set(this, `treatyList`, res.data);
       }
+      if (index === true) return;
+      this.detailForm.out_bill[index].treaty = '';
+      this.detailForm.out_bill[index].item = '';
+      this.detailForm.out_bill[index].taxes = '';
     },
     // 选择合同,查询项目
-    async changeTreaty(value) {
+    async changeTreaty(value, index) {
       let res = await this.projectQuery({ treaty: value });
       if (this.$checkRes(res)) {
         this.$set(this, `itemList`, res.data);
       }
+      if (index === true) return;
+      this.detailForm.out_bill[index].item = '';
+      this.detailForm.out_bill[index].taxes = '';
     },
     // 选择项目,赋值税率
     async changeItem(value, index) {
-      if (index) {
+      if (typeof index === 'number') {
         const projects = this.itemList.find(item => item.id === value);
         let outBill = this.detailForm.out_bill[index];
         this.$set(outBill, `taxes`, projects.taxes);
-      }
-      return;
-    },
-    //选择供应商方式
-    getSupStyle(value) {
-      console.log(value);
+      } else return;
     },
     //是否有供应商
     async isTreaty() {
       let outList = this.detailForm.out_bill;
       for (let item of outList) {
-        if (item.client) this.changeClient(item.client);
-        if (item.treaty) this.changeTreaty(item.treaty);
-        if (item.item) this.changeItem(item.item);
+        if (item.client) this.changeClient(item.client, true);
+        if (item.treaty) this.changeTreaty(item.treaty, true);
+        if (item.item) this.changeItem(item.item, true);
       }
     },
   },