diff --git a/src/views/activiti/form/ProcessMaterialsAllotForm.vue b/src/views/activiti/form/ProcessMaterialsAllotForm.vue index 6f37142..7076917 100644 --- a/src/views/activiti/form/ProcessMaterialsAllotForm.vue +++ b/src/views/activiti/form/ProcessMaterialsAllotForm.vue @@ -398,6 +398,7 @@ qeihuan: undefined, //切换 kucun: 0, //切换 hiegkucun: [], //切换 + shiyan: [], //实发数 } }, props: { @@ -460,7 +461,7 @@ // console.log("this.disabled",this.disabled); // console.log("this.heid",this.heid); this.heid = this.hieg; - console.log("this.allotNumber====",this.allotShuNumber); + // console.log("this.allotNumber====",this.allotShuNumber); return this.disabled }, showFlowSubmitButton() { @@ -489,32 +490,14 @@ }, methods: { async seeWateNumber(log) { - // console.log(this.allotShuNumber,"asdfasd===") //物料类型 - //this.assigneesText let pas = await log.target.getValuesPromise(log.rowIds); - // console.log(pas,log); if(!!pas[log.index].equipment && !this.allotShuNumber) { - console.log(pas); - let did = ''; - this.form.validateFields((err, values) => { - // 这里做逻辑处理 - console.log(values.beAllotDepartment) // { username: '' } - if(!!values.beAllotDepartmen){ - did = values.beAllotDepartmen; + this.shiyan.forEach(item =>{ + if(item.merchandiseNewsId == pas[log.index].equipment){ + this.kucun =item.materialQuantity; } }); - let param = {merchandiseNewsId : pas[log.index].equipment, - departId : did - } - getAction(this.url.wastematerialsList,param).then(res =>{ - if(res.success){ - // console.log(res.result.records[0].materialQuantity,"edsrtg"); - this.kucun = res.result.records[0].materialQuantity; - } - }).catch(()=>{ - this.kucun = 0; - }); } }, @@ -528,15 +511,8 @@ }, async onSelect(record) { let isDB = true - // if (!!record.row.materialGroup) { - // if (this.issh){ - // return; - // } - // if (!!record.row.id && this.materialGroupId !== record.row.materialGroup && record.column.key !== "allotNumber" ) { if (!record.row.equipment && !!record.row.materialGroup && !!record.row.materialName || !record.row.materialName && !!record.row.materialGroup && !!record.row.equipment ) { - // console.log("record.row.materialGroup") - // await this.fetchMerchandiseNews(record.row.materialGroup, 1) let value = [ { rowKey: record.row.id, @@ -560,7 +536,6 @@ isDB = false } - // } if (!!record.row.equipment && !record.row.allotNumber && isDB && this.materialGroupId !== record.row.materialGroup) { // console.log("执行materialNumber") @@ -606,16 +581,11 @@ } } }) - // console.log("materialName",materialName); if(Object.keys(materialName).length > 0){ - - this.processMaterialsAllotListTable.columns[0].options.push({ title: materialName.materialGroup, value: materialName.descriptionId }) - - let values = [ { rowKey: record.row.id, @@ -631,13 +601,22 @@ } } ] - // console.log("",values); this.$refs.processMaterialsAllotList.setValues(values) } } - + //计算实发数 + if(record.column.key == 'allotSendNumber'){ + this.shiyan.forEach( item =>{ + // console.log(item); + // console.log(record); + if(parseInt( record.value) > parseInt(item.materialQuantity )){ + this.$message.warning("实发数大于库存数"); + record.row.allotSendNumber = !record.value ? 0 : item.materialQuantity ; + } + }); + } // 根据请发数量计算 - if (record.row.allotNumber !== '' && record.row.allotNumber !== undefined && isDB) { + if (!!record.row.allotNumber && isDB) { let res = record.row let materialName = {} this.bigIdMerchandiseNewsList.forEach(item => { @@ -647,13 +626,16 @@ } } }) + // console.log("==",this.hiegkucun.length); + // console.log("111",record.row.allotSendNumber); + // console.log("materialName.residueNumber",materialName.residueNumber) // if(parseInt( res.allotNumber) > parseInt( materialName.number )){ // // console.log("大于") // this.$message.warn("输入调拨数量不能大于库存数量") // res.allotNumber = materialName.number; // } - if (res.id != undefined) { + if (!!res.id) { let value = [ { rowKey: res.id, @@ -664,9 +646,9 @@ // 'materialUnit': res.unit, // 'supplier': res.supplierName, // 'materialPrice': res.price, - // 'number': res.number, + 'allotSendNumber': res.allotSendNumber, 'allotNumber': res.allotNumber, - 'materialAmount': parseFloat((res.materialPrice * parseInt(res.allotNumber)).toFixed(1)), + 'materialAmount': parseFloat((res.materialPrice * parseInt( !res.allotSendNumber ? 0 : res.allotSendNumber)).toFixed(1)), } } ] @@ -674,10 +656,6 @@ this.$refs.processMaterialsAllotList.setValues(value) }) } - - - // console.log('****>',value) - } }, @@ -847,6 +825,34 @@ /*通过审批*/ passTask() { // this.handleSubmit() + if(!this.allotShuNumber){ + this.getAllTable().then(tables => { + return validateFormAndTables(this.form, tables) + }).then(allValues => { + console.log('所有数据', allValues) + if(!!allValues.tablesValue[0].values[0] ){ + let all = false; + allValues.tablesValue[0].values.forEach( it => { + if(!it.allotSendNumber){ + this.$message.warning("请填写实发调拨数据!"); + all = true; + } + }); + if(all){ + return + }else{ + let formData = this.classifyIntoFormData(allValues); + // console.log("124234123",formData); + let method = 'put' + httpAction(this.url.edit, formData, method).then((res) => { + if (res.success) { + } + }).finally(() => { + }) + } + } + }) + } this.$emit('passTask') }, /*驳回审批*/ @@ -1089,6 +1095,7 @@ } } this.hiegkucun = []; + this.shiyan = []; // console.log("tab.dataSource",dataSource) dataSource.forEach(item =>{ let par = { id : item.materialGroup,} @@ -1102,17 +1109,36 @@ disabled : true }]; } }) + + let did = ''; + this.form.validateFields((err, values) => { + // 这里做逻辑处理 + // console.log(values.beAllotDepartment) // { username: '' } + if(!!values.beAllotDepartmen){ + did = values.beAllotDepartmen; + } + }); + getAction(this.url.queryByIdMerchandiseNews,param).then( res=>{ - // console.log(res); if(res.success){ this.processMaterialsAllotListTable.columns[1].options= [{ title : res.result.materialsNumber, value : item.equipment, disabled : true }]; + let parer = { + merchandiseNewsId : res.result.id, + departId : did + } + getAction(this.url.wastematerialsList,parer).then(res =>{ + if(res.success){ + this.shiyan.push( res.result.records[0]); + } + }); } this.hiegkucun.push(res.result); }) - + item.allotSendNumber = undefined; + console.log(item,"235234"); }) tab.dataSource = dataSource; typeof success === 'function' ? success(res) : ''