Ver código fonte

【修改】申请退货单

莫绍宝 3 anos atrás
pai
commit
9fe029db44

+ 32 - 9
src/views/supply/apply/components/apply_return_form.vue

@@ -48,6 +48,13 @@
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="8" :lg="8">
+          <el-form-item label="仓库" prop="warehouse">
+            <el-select v-model="mainForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable disabled style="width: 100%">
+              <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="8" :lg="8">
           <el-form-item label="附件" prop="fileUrl">
             <fileUpload :fileList="fileList" />
           </el-form-item>
@@ -83,7 +90,6 @@
             <el-input v-model="scope.row.invoiceNum" size="small" type="number"></el-input>
           </template>
         </el-table-column>
-        <el-table-column align="center" label="仓库" prop="correspondName" min-width="100" show-overflow-tooltip></el-table-column>
         <!-- <el-table-column align="center" label="仓库" prop="correspondId" min-width="140" show-overflow-tooltip>
           <template slot-scope="scope">
             <el-select v-model="scope.row.correspondId" placeholder="请选择仓库" size="small" filterable clearable style="width: 100%">
@@ -227,6 +233,7 @@ export default {
         jxsName: '',
         remark: '',
         createMan: '',
+        warehouse: '',
       },
       mainFormRules: {
         // date: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
@@ -252,6 +259,25 @@ export default {
       categoryList: [],
       
       tableGoodsList: [],
+      isFirst: false,
+    }
+  },
+
+  watch: {
+    goodsList: {
+      handler(newValue, oldValue) {
+        if(this.goodsList && this.goodsList.length) {
+          if(this.isFirst) {
+            this.isFirst = false;
+          }else {
+            this.mainForm.warehouse = this.goodsList[0].correspondId;
+          }
+        }else {
+          this.mainForm.warehouse = '';
+        }
+      },
+      immediate: true,
+      deep: true
     }
   },
 
@@ -261,6 +287,7 @@ export default {
     this.getDealerList();
     this.getCategoryList();
     if(this.listItem) {
+      this.isFirst = true;
       this.getDetail();
     }else {
       this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
@@ -285,7 +312,7 @@ export default {
         this.mainForm.jxsName = data.customerName;
         this.mainForm.createMan = data.createBy;
         this.mainForm.remark = data.remark;
-        this.screenForm.warehouse = data.correspondId;
+        this.mainForm.warehouse = data.correspondId;
         this.fileList = data.fileUrl ? [{
           url: data.fileUrl,
           name: data.fileName
@@ -478,10 +505,6 @@ export default {
               this.$errorMsg('申请数量需为负数');
               return;
             }
-            if(!this.goodsList[i].correspondId) {
-              this.$errorMsg('请选择仓库');
-              return;
-            }
           }
           // if(!this.screenForm.warehouse) {
           //   return this.$errorMsg('请选择仓库');
@@ -498,13 +521,13 @@ export default {
             }
           })
 
-          // let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
+          let warehouseItem = this.warehouseList.find(o => o.id === this.mainForm.warehouse);
           let params = {
             remark: this.mainForm.remark,
             fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
             fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
-            correspondId: this.goodsList[0].correspondId,
-            correspondName: this.goodsList[0].correspondName,
+            correspondId: this.mainForm.warehouse,
+            correspondName: warehouseItem.name,
             salesOrderId: this.goodsList[0].id,
             orders: goodsList,
             examineStatus: status,

+ 32 - 8
src/views/supply/apply/components/engin_return_form.vue

@@ -103,6 +103,13 @@
             <fileUpload :fileList="fileList" />
           </el-form-item>
         </el-col>
+        <el-col :xs="24" :sm="8" :lg="8">
+          <el-form-item label="仓库" prop="warehouse">
+            <el-select v-model="mainForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable disabled style="width: 100%">
+              <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
       </el-row>
       <el-row :gutter="20">
         <el-col :xs="24" :sm="12" :lg="8">
@@ -257,7 +264,6 @@
               <el-input v-model="scope.row.invoiceNum" size="small" type="number"></el-input>
             </template>
           </el-table-column>
-          <el-table-column align="center" label="仓库" prop="correspondName" min-width="100" show-overflow-tooltip></el-table-column>
           <!-- <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
             <template slot-scope="scope">
               {{stockFilter(scope.row, 1)}}
@@ -343,6 +349,7 @@ export default {
         remark: '',
         createMan: '',
         createDate: '',
+        warehouse: '',
       },
       mainFormRules: {
         // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
@@ -371,6 +378,7 @@ export default {
       
       tableGoodsList: [],
       tableSelection: [],
+      isFirst: false,
     }
   },
 
@@ -386,12 +394,31 @@ export default {
     },
   },
 
+  watch: {
+    goodsList: {
+      handler(newValue, oldValue) {
+        if(this.goodsList && this.goodsList.length) {
+          if(this.isFirst) {
+            this.isFirst = false;
+          }else {
+            this.mainForm.warehouse = this.goodsList[0].correspondId;
+          }
+        }else {
+          this.mainForm.warehouse = '';
+        }
+      },
+      immediate: true,
+      deep: true
+    }
+  },
+
   created() {
     this.getDictList();
     this.getWarehouseList();
     this.getDealerList();
     this.getCategoryList();
     if(this.listItem) {
+      this.isFirst = true;
       this.getDetail();
     }else {
       this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
@@ -444,7 +471,7 @@ export default {
         this.mainForm.createMan = data.createBy;
         this.mainForm.createDate = data.createTime;
         this.mainForm.remark = data.remark;
-        this.screenForm.warehouse = data.correspondId;
+        this.mainForm.warehouse = data.correspondId;
         this.fileList = data.fileUrl ? [{
           url: data.fileUrl,
           name: data.fileName,
@@ -703,10 +730,6 @@ export default {
               this.$errorMsg('申请数量需为负数');
               return;
             }
-            if(!this.goodsList[i].correspondId) {
-              this.$errorMsg('请选择仓库');
-              return;
-            }
           }
           // if(!this.screenForm.warehouse) {
           //   return this.$errorMsg('请选择仓库');
@@ -723,6 +746,7 @@ export default {
             }
           })
 
+          let warehouseItem = this.warehouseList.find(o => o.id === this.mainForm.warehouse);
           let params = {
             remark: this.mainForm.remark,
             enginOrderNo: this.mainForm.loginNum,
@@ -737,8 +761,8 @@ export default {
             remark: this.mainForm.remark,
             fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
             fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
-            correspondId: this.goodsList[0].correspondId,
-            correspondName: this.goodsList[0].correspondName,
+            correspondId: this.mainForm.warehouse,
+            correspondName: warehouseItem.name,
             salesOrderId: this.goodsList[0].id,
             orders: goodsList,
             examineStatus: status,