From ff51de6c4302288f0756e133c222b3a9078e7d51 Mon Sep 17 00:00:00 2001 From: caoyizhong <1270296080@qq.com> Date: Tue, 1 Nov 2022 17:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BA=E8=B4=A7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/ProcessMaterialsDeliveryForm.vue | 440 +++++++++++++----- 1 file changed, 333 insertions(+), 107 deletions(-) diff --git a/src/views/activiti/form/ProcessMaterialsDeliveryForm.vue b/src/views/activiti/form/ProcessMaterialsDeliveryForm.vue index 736305e..a922014 100644 --- a/src/views/activiti/form/ProcessMaterialsDeliveryForm.vue +++ b/src/views/activiti/form/ProcessMaterialsDeliveryForm.vue @@ -71,6 +71,7 @@ :rowSelection="true" :actionButton="true" @added="addid" + :disabledRows="{id:jiy}" > @@ -121,6 +122,7 @@ }, data() { return { + jiy:[], heid: true, addId : '', bigIdMerchandiseNewsList:[], @@ -204,6 +206,14 @@ placeholder: '请输入${title}', defaultValue:'', }, + // { + // title: '批次', + // key: 'batch', + // type: FormTypes.input, + // width:"200px", + // placeholder: '请输入${title}', + // defaultValue:'', + // }, { title: '请发数', key: 'pleaseSendNumber', @@ -255,14 +265,6 @@ defaultValue:'', }, // { - // title: '删除标志', - // key: 'delFlag', - // type: FormTypes.inputNumber, - // width:"200px", - // placeholder: '请输入${title}', - // defaultValue:'', - // }, - // { // title: '删除时间', // key: 'delTime', // type: FormTypes.date, @@ -289,7 +291,7 @@ materialType: { rules: [{ required: true, message: '请选择物资类型!' }] }, deliveryTime: { rules: [{ required: true, message: '请选择出库时间!' }] }, processPlan: { rules: [{ required: true, message: '请选择流程计划!' }] } - } + }, } }, props: { @@ -357,6 +359,9 @@ this.popupCallback(company,userInfo); }, methods: { + shuliang(){ + this.addId + }, //请数量输入 addid(val){ this.addId = val.row.id; @@ -369,9 +374,7 @@ this.heid = false; this.fetchData(val); } - // console.log("执行l",val); }, - //table 值改变触发 async onSelect(record) { // console.log(record) if(record.row.materialGroup !== '' && record.row.materialGroup !== undefined && record.row.equipment === ''){ @@ -388,9 +391,8 @@ unit: item.materialsUnit, supplierName: item.supplierName, price: item.price, - // residueNumber : item.residueNumber === undefined ? 0 : item.residueNumber, + residueNumber : item.residueNumber === undefined ? 0 : item.residueNumber, } - } }) let values = [ @@ -403,122 +405,68 @@ 'materialUnit': materialName.unit, 'supplier': materialName.supplierName, 'materialPrice': materialName.price, - // 'actualSendNumber': materialName.residueNumber, - // 'materialAmount': materialName.price * materialName.residueNumber, + 'actualSendNumber': materialName.residueNumber, + 'materialAmount': materialName.price * materialName.residueNumber, }, }, ] this.$refs.processMaterialsDeliveryList.setValues(values); } - let a = false; - let numberStar = 0; - let numberEnd = 0; + // 根据请发数量计算 if(record.row.pleaseSendNumber !== '' && record.row.pleaseSendNumber !== undefined){ - // record.row.materialAmount = record.row.materialQuantity * record.row.materialPrice; - let num = 0; - this.bigIdMerchandiseNewsList.forEach( item =>{ - console.log("item",item); - numberStar = item.batch.substring(0,item.batch.indexOf("/")); - numberEnd = item.batch.slice(numberStar.length+1); - num = record.row.pleaseSendNumber - item.residueNumber; - if(num > 0){ - // 限制最大数量 - record.row.pleaseSendNumber = item.residueNumber; - record.row.actualSendNumber = record.row.pleaseSendNumber; - this.$refs.processMaterialsDeliveryList.handleClickAdd(); - a =true; - }else{ - record.row.actualSendNumber = record.row.pleaseSendNumber; - // console.log("执行了222" ,record.row.actualSendNumber); + // console.log("执行了",record.row) + let res = record.row; + let materialName = {} + this.bigIdMerchandiseNewsList.forEach(item => { + if (item.merchandiseNewsId === record.row.equipment) { + materialName = { + residueNumber : item.residueNumber === undefined ? 0 : item.residueNumber, + } } - }); - let drop = record.row.materialGroup; - let values = [ + }) + // console.log("materialName.residueNumber",materialName.residueNumber) + if(parseInt( res.pleaseSendNumber) > parseInt( materialName.residueNumber )){ + // console.log("大于") + res.pleaseSendNumber = materialName.residueNumber; + res.actualSendNumber = materialName.residueNumber; + }else{ + // console.log("小于") + res.actualSendNumber = res.pleaseSendNumber; + } + + let value = [ { - rowKey: record.row.id, + rowKey: res.id, values: { - 'equipment': record.row.equipment, - 'materialGroup': record.row.materialGroup, - 'materialName': record.row.materialName, - 'materialUnit': record.row.materialUnit, - 'supplier': record.row.supplier, - 'materialPrice': record.row.materialPrice, - 'actualSendNumber': record.row.actualSendNumber, - 'materialAmount': record.row.actualSendNumber * record.row.materialPrice, - 'pleaseSendNumber' : record.row.pleaseSendNumber, + // 'equipment': res.equipment, + // 'materialGroup': res.materialGroup, + // 'materialName': res.materialName, + // 'materialUnit': res.materialUnit, + // 'supplier': res.supplier, + // 'materialPrice': res.materialPrice, + 'actualSendNumber': res.actualSendNumber, + 'pleaseSendNumber': res.pleaseSendNumber, + 'materialAmount': res.materialPrice * res.actualSendNumber, }, }, ] - this.$refs.processMaterialsDeliveryList.setValues(values); - //重新赋值 - if(a){ - let merchandiseNewser = {}; - let merchandiseNews = {}; - let is = false; - let onIs= false; - do{ - // console.log("numberStar",parseInt(numberStar)+1) - merchandiseNewser =await this.fetchMerchandiseNews(drop,parseInt(numberStar)+1); - // console.log(merchandiseNewser); - merchandiseNewser.forEach( item => { - merchandiseNews = item; - }); - // console.log(merchandiseNews); - let sum = num - merchandiseNews.residueNumber; - if( sum > 0 ){ - // console.log("大于"); - // console.log("numberEnd",numberEnd); - // console.log("merchandiseNews.batch.substring()",merchandiseNews.batch.substring(0,merchandiseNews.batch.indexOf("/"))); - //第三批 - let isLose = parseInt(numberEnd) - parseInt( merchandiseNews.batch.substring(0,merchandiseNews.batch.indexOf("/")) ); - if(isLose === 0 ){ - onIs = true; - }else { - is = true; - numberStar = numberStar+1; - this.$refs.processMaterialsDeliveryList.handleClickAdd(); - } - }else{ - sum = num; - // console.log("小于"); - is = false; - } - let values = [ - { - rowKey: this.addId, - values: { - 'equipment': record.row.equipment, - 'materialGroup': record.row.materialGroup, - 'materialName': record.row.materialName, - 'materialUnit': record.row.materialUnit, - 'supplier': record.row.supplier, - 'materialPrice': record.row.materialPrice, - 'actualSendNumber': sum, - 'materialAmount': sum * record.row.materialPrice, - 'pleaseSendNumber' : sum, - }, - }, - ] - this.$refs.processMaterialsDeliveryList.setValues(values); - if(onIs){ - this.$message.warn('没有更多批次了'); - is = false; - return; - } - }while (is); - } + this.$nextTick(()=>{ + this.$refs.processMaterialsDeliveryList.setValues(value); + }) + // console.log('****>',value) + } }, - fetchMerchandiseNews(value,batch){ //查询物料清单信息 + fetchMerchandiseNews(value){ //查询物料清单信息 //查询大品类数据 return new Promise((resolve, reject) => { //你的逻辑代码 let par = { delFlag: 0, descriptionId:value, - batchNum: batch, + } this.bigIdMerchandiseNews = []; this.bigIdMerchandiseNewsList = []; @@ -575,6 +523,284 @@ }); }, + //table 值改变触发 + // async onSelect(record) { + // // console.log(record) + // if(record.row.materialGroup !== '' && record.row.materialGroup !== undefined && record.row.equipment === ''){ + // // console.log("执行materialGroup") + // this.fetchMerchandiseNews(record.row.materialGroup,1); + // } + // if(record.row.materialGroup !== '' && record.row.materialGroup !== undefined && record.row.equipment !== '' && record.row.actualSendNumber === '' ){ + // // console.log("执行materialNumber") + // let materialName = {} + // this.bigIdMerchandiseNewsList.forEach(item => { + // if (item.merchandiseNewsId === record.row.equipment) { + // materialName = { + // name: item.merchandiseName, + // unit: item.materialsUnit, + // supplierName: item.supplierName, + // price: item.price, + // batch: item.batch, + // // residueNumber : item.residueNumber === undefined ? 0 : item.residueNumber, + // } + // } + // }) + // let values = [ + // { + // rowKey: record.row.id, + // values: { + // 'equipment': record.row.equipment, + // 'materialGroup': record.row.materialGroup, + // 'materialName': materialName.name, + // 'materialUnit': materialName.unit, + // 'supplier': materialName.supplierName, + // 'materialPrice': materialName.price, + // 'batch' : materialName.batch, + // // 'actualSendNumber': materialName.residueNumber, + // // 'materialAmount': materialName.price * materialName.residueNumber, + // }, + // }, + // ] + // this.$refs.processMaterialsDeliveryList.setValues(values); + // } + // let a = false; + // // 根据请发数量计算 + // if(record.row.pleaseSendNumber !== '' && record.row.pleaseSendNumber !== undefined){ + // let numberStar = 0; + // let numberEnd = 0; + // // record.row.materialAmount = record.row.materialQuantity * record.row.materialPrice; + // // 获取被逻辑删除的字段id + // // let deleteIds = this.$refs.processMaterialsDeliveryList.getDeleteIds(); + // // 获取所有表单的值,并进行验证 + // let batcher = false; + // let rest = false; + // let { error, values } = this.$refs.processMaterialsDeliveryList.getValuesSync({ }) + // // console.log( values); + // values.forEach( item => { + // //判断是不是操作第一个 + // if(item.id === record.row.id){ + // let bat = record.row.batch.substring(0,record.row.batch.indexOf('/')); + // if(parseInt(bat) === 1){ + // // console.log("第一批"); + // batcher = true; + // } + // } + // //判断下面是不是有一样的物资 + // if(item.id !== record.row.id && item.equipment === record.row.equipment ){ + // //有 + // let cf = record.row.pleaseSendNumber - record.row.actualSendNumber; + // if(cf < 0 ){ + // let ba = record.row.batch.substring(0,record.row.batch.indexOf('/')); + // if(parseInt(ba) === 1 ){ + // record.row.actualSendNumber = record.row.pleaseSendNumber; + // //请减小 + // let values = [ + // { + // rowKey: record.row.id, + // values: { + // 'equipment': record.row.equipment, + // 'materialGroup': record.row.materialGroup, + // 'materialName': record.row.materialName, + // 'materialUnit': record.row.materialUnit, + // 'supplier': record.row.supplier, + // 'materialPrice': record.row.price , + // 'actualSendNumber': record.row.actualSendNumber, + // 'materialAmount': record.row.price * record.row.actualSendNumber, + // 'pleaseSendNumber' : record.row.pleaseSendNumber, + // 'batch' : record.row.batch, + // }, + // }, + // ] + // this.$refs.processMaterialsDeliveryList.setValues(values); + // this.$refs.processMaterialsDeliveryList.removeRows(item.id); + // }else { + // + // batcher =true; + // } + // + // }else{ + // //请变大 + // this.$refs.processMaterialsDeliveryList.removeRows(item.id); + // + // } + // } + // + // }) + // //第二行操作 + // if(batcher){ + // // console.log("执行了123") + // let num = 0; + // this.bigIdMerchandiseNewsList.forEach( item =>{ + // // console.log("item",item); + // num = record.row.pleaseSendNumber - item.residueNumber; //第二行显示的数量 + // if(num > 0){ + // // 限制最大数量 + // record.row.pleaseSendNumber = item.residueNumber; + // record.row.actualSendNumber = record.row.pleaseSendNumber; + // //添加一行 + // this.$refs.processMaterialsDeliveryList.handleClickAdd(); + // this.jiy.push(this.addId); + // a =true; + // }else{ + // record.row.actualSendNumber = record.row.pleaseSendNumber; + // // console.log("执行了222" ,record.row.actualSendNumber); + // } + // }); + // let drop = record.row.materialGroup; + // let values = [ + // { + // rowKey: record.row.id, + // values: { + // 'equipment': record.row.equipment, + // 'materialGroup': record.row.materialGroup, + // 'materialName': record.row.materialName, + // 'materialUnit': record.row.materialUnit, + // 'supplier': record.row.supplier, + // 'materialPrice': record.row.materialPrice, + // 'actualSendNumber': record.row.actualSendNumber, + // 'materialAmount': record.row.actualSendNumber * record.row.materialPrice, + // 'pleaseSendNumber' : record.row.pleaseSendNumber, + // 'batch' : record.row.batch, + // }, + // }, + // ] + // this.$refs.processMaterialsDeliveryList.setValues(values); + // //重新赋值 + // if(a){ + // let merchandiseNewser = {}; + // let merchandiseNews = {}; + // let is = false; + // let onIs= false; + // do{ + // if(is){ + // this.$refs.processMaterialsDeliveryList.handleClickAdd(); + // merchandiseNewser =await this.fetchMerchandiseNews(drop,parseInt(numberStar)); + // }else{ + // merchandiseNewser =await this.fetchMerchandiseNews(drop,2); + // } + // merchandiseNewser.forEach( item => { + // merchandiseNews = item; + // }); + // console.log("numberStar",numberStar) + // numberStar = merchandiseNews.batch.substring(0,merchandiseNews.batch.indexOf("/")); + // numberEnd = merchandiseNews.batch.slice(numberStar.length+1); + // // console.log(merchandiseNews); + // let sum = num - merchandiseNews.residueNumber; + // let isLose = parseInt(numberEnd) - parseInt(numberStar); + // console.log("isLose",isLose); + // if(isLose === 0 ){ + // onIs = true; + // } + // if( sum > 0 ){ + // //第三批 + // is = true; + // numberStar = parseInt(numberStar)+1; + // sum = merchandiseNews.residueNumber; + // }else{ + // sum = num; + // // console.log("小于"); + // is = false; + // + // } + // let values = [ + // { + // rowKey: this.addId, + // values: { + // 'equipment': record.row.equipment, + // 'materialGroup': record.row.materialGroup, + // 'materialName': record.row.materialName, + // 'materialUnit': record.row.materialUnit, + // 'supplier': record.row.supplier, + // 'materialPrice': merchandiseNews.price ? merchandiseNews.price : 0 , + // 'actualSendNumber': sum , + // 'materialAmount': sum * merchandiseNews.price ? sum * merchandiseNews.price : 0, + // 'pleaseSendNumber' : sum, + // 'batch' : merchandiseNews.batch, + // }, + // }, + // ] + // this.$refs.processMaterialsDeliveryList.setValues(values); + // //减小num 数量 + // num = sum; + // if(onIs){ + // //还要继续查询 + // + // this.$message.warn('没有更多批次了'); + // is = false; + // return; + // } + // }while (is); + // } + // + // } + // + // } + // + // }, + // fetchMerchandiseNews(value,batch){ //查询物料清单信息 + // //查询大品类数据 + // return new Promise((resolve, reject) => { + // //你的逻辑代码 + // let par = { + // delFlag: 0, + // descriptionId:value, + // batchNum: batch, + // } + // this.bigIdMerchandiseNews = []; + // this.bigIdMerchandiseNewsList = []; + // let qc = []; + // let numberList = []; + // if(this.processMaterialsDeliveryListTable.columns[1].options.length > 0){ + // this.processMaterialsDeliveryListTable.columns[1].options = []; + // } + // this.$refs.processMaterialsDeliveryList.getValues((a,b,c)=>{ + // // console.log(a,b,c) + // b.forEach(item =>{ + // if(item.equipment !== '' && item.equipment !== undefined && item.equipment !== null){ + // numberList.push(item.materialNumber); + // } + // }); + // }); + // getAction(this.url.merchandiseNewsList,par).then((res)=>{ + // if(res.success){ + // console.log(res.result); + // let newList = res.result; + // // console.log("12312312:"+numberList.length); + // if(numberList.length > 0){ + // newList.forEach( item => { + // qc.push({ + // title : item.materialsNumber, + // value : item.merchandiseNewsId, + // disabled : false + // }) + // }) + // numberList.forEach( num => { + // qc.forEach( i => { + // if(num === i.value){ + // // console.log(num,i.value); + // i.disabled = true; + // } + // }); + // }) + // this.processMaterialsDeliveryListTable.columns[1].options = qc; + // }else{ + // newList.forEach( item => { + // this.processMaterialsDeliveryListTable.columns[1].options.push({ + // title : item.materialsNumber, + // value : item.merchandiseNewsId, + // disabled : false + // }) + // }) + // } + // // console.log(this.processUdgetPlanMaterialTable.columns[1].options); + // resolve(this.bigIdMerchandiseNewsList = res.result ); + // // return + // } + // }); + // + // }); + // + // }, fetchData(value){ //查询物料组 //查询大品类数据 let par = {