Forráskód Böngészése

采购列表-批量入库

damon227 11 hónapja
szülő
commit
d3a8b601aa

+ 55 - 3
src/views/modules/sale/purchase.vue

@@ -47,8 +47,8 @@
           <el-button v-if="isAuth('purchase:detail:save')" type="primary" @click="addOrUpdateHandle(0)">新建采购申请</el-button>
           <el-button v-if="isAuth('purchase:detail:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">工作提示通知设置</el-button>
           <el-button v-if="isAuth('purchase:detail:priceConfig')" type="primary" @click="setAmountMaskHandel()">采购金额屏蔽设置</el-button>
-          <el-button v-if="isAuth('purchase:detail:updatePurchaseDetail')" type="primary" @click="batchBuyHandel()">批量采购</el-button>
-          <el-button v-if="isAuth('purchase:detail:infoPutIn')" type="primary" @click="batchIncomeHandel()">批量入库</el-button>
+          <el-button v-if="isAuth('purchase:detail:updatePurchaseDetail')" type="primary" @click="batchBuyHandel()" :disabled="batchBuyBtnDisabled">批量采购</el-button>
+          <el-button v-if="isAuth('purchase:detail:infoPutIn')" type="primary" @click="batchIncomeHandel()" :disabled="batchIncomeBtnDisabled">批量入库</el-button>
         </el-form-item>
       </el-form>
       <el-table
@@ -291,6 +291,8 @@
           {code: '4', value: '入库中'},
           {code: '5', value: '入库异常'}
         ],
+        batchIncomeBtnDisabled:false,
+        batchBuyBtnDisabled:false,
         selectedRows:[]
       }
     },
@@ -308,6 +310,9 @@
         this.inboundVisible = false
         this.noticeChangeAttachVisible = false
         this.amountMaskSettingVisible = false
+        this.batchIncomeBtnDisabled = false
+        this.batchBuyBtnDisabled = false
+        this.selectedRows = []
       },
       // 获取采购类别字典
       getTypeList () {
@@ -324,6 +329,8 @@
       },
       // 获取数据列表
       getDataList () {
+        this.selectedRows = []
+
         this.dataListLoading = true
         this.addOrUpdateVisible = false
         let params = {
@@ -466,9 +473,32 @@
       //监听批量选择的行
       handleSelectionChange(rows){
         this.selectedRows = rows
+
+        //控制批量操作按钮
+        this.batchIncomeBtnDisabled = false
+        this.batchBuyBtnDisabled = false
+        for(let index=0;index<this.selectedRows.length;index++){
+          let item = this.selectedRows[index]
+          if(Number(item.approvalState) === 3  && (Number(item.purchaseState) === 2 || Number(item.purchaseState) === 5)){
+          
+          } else {
+            this.batchIncomeBtnDisabled = true
+          }
+
+          if(Number(item.approvalState) === 3  && Number(item.purchaseState) === 1){
+          
+          } else {
+            this.batchBuyBtnDisabled = true
+          }
+        }
       },
       //批量采购
       batchBuyHandel(){
+        console.log(this.selectedRows)
+        if(this.selectedRows.length == 0){
+           this.$message.error("请先勾选数据")
+           return
+        }
         this.operateVisible = true
         this.$nextTick(() => {
           this.$refs.operate.init(this.selectedRows)
@@ -476,7 +506,29 @@
       },
       //批量入库
       batchIncomeHandel(){
-        console.log(this.selectedRows)
+        if(this.selectedRows.length == 0){
+           this.$message.error("请先勾选数据")
+           return
+        }
+
+        let list = []
+        for(let index=0;index<this.selectedRows.length;index++){
+          let item = this.selectedRows[index]
+          let dataForm = {
+            ...item,
+            buttonType: '1',
+            sourceCategory: '1', // 入库依据类别
+            source: item.supplierName, // 来源对应供应商
+            tableId: item.purchaseDetailId,
+            specifications: item.specification
+          }
+          list.push(dataForm)
+        }
+
+        this.inboundVisible = true
+        this.$nextTick(() => {
+          this.$refs.inbound.init(0, false, list)
+        })
       }
     }
   }

+ 9 - 2
src/views/modules/warehouse/stock-order-inbound.vue

@@ -230,8 +230,15 @@
             }
           })
         } else if (item) {
-          item.applicant = this.$store.state.user.id
-          this.addOne(item)
+          if(item instanceof Array){
+            item.forEach(obj => {
+               obj.applicant = this.$store.state.user.id
+               this.addOne(obj)
+            })
+          }else{
+            item.applicant = this.$store.state.user.id
+            this.addOne(item)
+          }
         } else if (!display) {
           this.addOne()
         }