Selaa lähdekoodia

feat:仓库单选

snow 1 vuosi sitten
vanhempi
commit
771208fe3f
1 muutettua tiedostoa jossa 21 lisäystä ja 29 poistoa
  1. 21 29
      src/views/sellOut/combinedRemove/components/baseForm.vue

+ 21 - 29
src/views/sellOut/combinedRemove/components/baseForm.vue

@@ -124,8 +124,12 @@
     </el-form-item>
 
     <el-form-item label="所在仓库" prop="wsm_code" v-if="productinfo">
-      <el-table row-key="id" ref="table" :data="productinfo.wsm_list" border size="mini" @selection-change="handleSelection">
-        <el-table-column type="selection" />
+      <el-table row-key="id" ref="table" :data="productinfo.wsm_list" border size="mini" @select="handleSelection">
+        <el-table-column type="selection">
+          <template slot="header">
+            <span></span>
+          </template>
+        </el-table-column>
         <el-table-column label="仓库名称" prop="name" />
         <el-table-column label="仓库编码" prop="wsm_code" />
         <el-table-column label="可用库存" prop="usable_stock" />
@@ -232,6 +236,7 @@ export default {
         stock_num: 0,
         usable_stock: 0
       },
+      selected: [],
       options6: [
         { id: "1", name: "全国" },
         { id: "2", name: "全国除偏远" }
@@ -263,20 +268,6 @@ export default {
       try {
         await this.$refs.ruleForm.validate();
         const { usable_stock, ...params } = this.ruleForm;
-        // for (let item of this.productinfo.child) {
-        //   const { child_num, stock, child_name } = item;
-        //   if (child_num * params.stock_num > stock) {
-        //     this.$message.warning(
-        //       `子商品   ${child_name}   解除库存数不能超过锁定库存总数`
-        //     );
-        //     return;
-        //   }
-        // }
-        // console.log(usable_stock,params.stock_num)
-        // if(usable_stock > params.stock_num){
-        //   this.$message.warning('')
-        //   return
-        // }
 
         this.loading.full = true;
         const { code, message } = await asyncRequest.add({
@@ -284,8 +275,8 @@ export default {
           wsm_code:this.productinfo.wsm_list[0].wsm_code,
           flag: "0"
         });
-
         this.loading.full = false;
+
         if (Number(code) === 0) {
           this.$router.push("/sellOut/combinedRemove");
           return;
@@ -302,13 +293,19 @@ export default {
         this.$refs.ruleForm && this.$refs.ruleForm.validateField(key);
       });
     },
-    handleSelection(list){
-      this.$nextTick(() => {
-        const { wsm_code = "" , usable_stock = 0} = (list[list.length - 1] || {})
-        this.ruleForm.wsm_code = wsm_code
-       this.ruleForm.usable_stock = usable_stock;
-       this.$refs.ruleForm.validate("wsm_code")
-      })
+    handleSelection(selection, row){
+      // this.selected = list
+      this.$refs.table.clearSelection()
+      
+      if(selection.length === 0){
+        return
+      }
+
+      this.$refs.table.toggleRowSelection(row, true)
+      const { wsm_code = "" , usable_stock = 0} = row
+      this.ruleForm.wsm_code = wsm_code
+      this.ruleForm.usable_stock = usable_stock;
+      this.$refs.ruleForm.validate("wsm_code")
     },
     async getArea(prop = "delivery_place") {
       const chunks = this.productinfo[prop].split(",");
@@ -331,11 +328,6 @@ export default {
       this.loading.product = true;
       const { code, data } = await asyncRequest.productinfo({ spuCode });
 
-      
-      // (data.combind_list || []).forEach(({ stock }) => {
-      //   this.ruleForm.usable_stock = add_sum(stock, this.ruleForm.usable_stock);
-      // });
-      
       if (code !== 0) return;
       this.productinfo = data;
       this.ruleForm.spuCode = data.spuCode;