From 5ebd4a5c4a1d9d1942017c54a1f3bcc9778bb973 Mon Sep 17 00:00:00 2001 From: wws <18630710203@163.com> Date: Thu, 21 Sep 2023 15:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=BF=E6=96=99=E8=AE=A1=E5=88=92(=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B9=BF=E6=96=99=E8=AE=A1=E5=88=92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/plan/plan/index.vue | 201 ++++++++++++++++++++++++++++++---- 1 file changed, 178 insertions(+), 23 deletions(-) diff --git a/src/views/plan/plan/index.vue b/src/views/plan/plan/index.vue index 870e337..d96a16b 100644 --- a/src/views/plan/plan/index.vue +++ b/src/views/plan/plan/index.vue @@ -311,7 +311,7 @@ - + @@ -354,6 +354,17 @@ + + + @@ -440,7 +451,8 @@ export default { dicts: ['sys_yes_no'], data() { return { - // 选中物料 + // 修改校验 + checkUpdate: true, // 新增-物料list materiel: [], materielList: [], @@ -525,7 +537,7 @@ export default { this.getList() }, methods: { - // 删除选好的工单 + // 新增-删除选好的工单 deleteSelectWork(e) { // 清除下方数据 for (let i =0; i < this.newWorkOrderList.length; i++) { @@ -569,6 +581,50 @@ export default { } } }, + // 修改-删除选好的工单 + deleteSelectWorkUpdate(e) { + // 清除下方数据 + for (let i =0; i < this.newWorkOrderList.length; i++) { + if (e.workorderCode == this.newWorkOrderList[i].workorderCode) { + this.newWorkOrderList.splice(i,1); + } + } + + // 清除上方数据 + let newMaterialName1 = ""; + let newBucketName1 = ""; + for (let i =0; i < this.wetMaterialPlanList.length; i++) { + if (e.workorderCode == this.wetMaterialPlanList[i].workorderCode) { + // 物料 + let materialNameArray = this.wetMaterialPlanList[i].materialName.split(','); + let materialFlag = true; + for (let j = materialNameArray.length - 2; j >= 0; j--) { + if (e.materialName == materialNameArray[j] && materialFlag) { + materialNameArray.splice(j,1); + materialFlag = false; + }else { + newMaterialName1 += materialNameArray[j]+","; + } + } + + // 料罐 + let bucketArray = this.wetMaterialPlanList[i].bucketName.split(','); + let bucketFlag = true; + for (let j = bucketArray.length - 2; j >= 0; j--) { + if (e.bucketName == bucketArray[j] && bucketFlag) { + bucketArray.splice(j,1); + bucketFlag = false; + }else { + newBucketName1 += bucketArray[j]+","; + } + } + + this.wetMaterialPlanList[i].materialName = newMaterialName1; + this.wetMaterialPlanList[i].bucketName = newBucketName1; + + } + } + }, // 新增-物料搜索 handleMaterielQuery() { this.materielQueryParams.pageNum = 1; @@ -663,7 +719,16 @@ export default { } } } - this.bmsList.push(bms) + + // TODO 清空 + if (this.checkUpdate) { + for (let i = 0; i < this.wetMaterialPlanList.length; i++){ + this.wetMaterialPlanList[i].materialName = null; + this.wetMaterialPlanList[i].bucketName = null; + } + this.checkUpdate = false; + } + // 数据保存(仅前端) // 创建料罐对象 var bucket @@ -680,25 +745,111 @@ export default { } } - // 将选择的信息放入newList + // TODO 检验工单-物料-料罐 for (let i = 0; i < this.selectList.length; i++) { - this.selectList[i].bucketName = bucket.bucketName - this.selectList[i].bucketId = bucket.bucketId - this.selectList[i].bucketCode = bucket.bucketCode - this.selectList[i].materialId = material.productId - this.selectList[i].materialCode = material.productCode - this.selectList[i].materialName = material.productDesc - this.selectList[i].planTime = this.form.planTime - this.newWorkOrderList.push(this.selectList[i]) + for (let j = 0; j < this.wetMaterialPlanList.length; j++) { + if (this.selectList[i].workorderCode == this.wetMaterialPlanList[j].workorderCode) { + // 物料 + if (this.wetMaterialPlanList[j].materialName != null) { + let materialNameArray = this.wetMaterialPlanList[j].materialName.split(','); + for (let i = materialNameArray.length - 2; i >= 0; i--) { + if (material.productDesc != materialNameArray[i]) { + this.$message({ + message: '同一工单只能选一个物料!', + type: 'warning' + }) + return + } + } + } + + // 料罐 + if (this.wetMaterialPlanList[j].bucketName != null) { + let bucketArray = this.wetMaterialPlanList[j].bucketName.split(','); + for (let i = bucketArray.length - 1; i >= 0; i--) { + if (bucket.bucketName == bucketArray[i]) { + this.$message({ + message: '料罐重复!', + type: 'warning' + }) + return + } + } + } + } + } } - // 将选择的数据在上方的列表中删除 - const selectedCodes = this.selectList.map(item => item.workorderCode) - this.wetMaterialPlanList = this.wetMaterialPlanList.filter(item => !selectedCodes.includes(item.workorderCode)) + this.bmsList.push(bms) + + + // TODO 将选择的信息放入newList + for (let i = 0; i < this.selectList.length; i++) { + + // 创建一个新工单对象 + var workOrder = { + productName: null, + factoryCode: null, + workorderId: null, + workorderCode: null, + bucketId: null, + bucketCode: null, + bucketName: null, + materialId: null, + materialCode: null, + materialName: null, + shiftId: null, + shiftDesc: null, + planTime: null, + productDate: null, + }; + + workOrder.bucketCode = bucket.bucketCode; + workOrder.bucketId = bucket.bucketId; + workOrder.bucketName = bucket.bucketName; + workOrder.materialId = material.productId; + workOrder.materialCode = material.productCode; + workOrder.materialName = material.productDesc; + workOrder.shiftId = this.selectList[i].shiftId; + workOrder.shiftDesc = this.selectList[i].shiftDesc; + workOrder.planTime = this.form.planTime; + workOrder.productDate = this.selectList[i].productDate; + workOrder.productName = this.selectList[i].productName; + workOrder.workorderId = this.selectList[i].workorderId; + workOrder.workorderCode = this.selectList[i].workorderCode; + + // this.selectList[i].bucketName = bucket.bucketName + // this.selectList[i].bucketId = bucket.bucketId + // this.selectList[i].bucketCode = bucket.bucketCode + // this.selectList[i].materialId = material.productId + // this.selectList[i].materialCode = material.productCode + // this.selectList[i].materialName = material.productDesc + // this.selectList[i].planTime = this.form.planTime + this.newWorkOrderList.push(workOrder) + } + + // // TODO 将选择的数据在上方的列表中删除 + for (let i = 0; i < this.selectList.length; i++) { + for (let j = 0; j < this.wetMaterialPlanList.length; j++) { + if (this.selectList[i].workorderCode == this.wetMaterialPlanList[j].workorderCode) { + if (this.wetMaterialPlanList[j].bucketName == null) { + this.wetMaterialPlanList[j].bucketName = ""; + } + this.wetMaterialPlanList[j].bucketName += bucket.bucketName + ","; + if (this.wetMaterialPlanList[j].materialName == null) { + this.wetMaterialPlanList[j].materialName = ""; + } + this.wetMaterialPlanList[j].materialName += material.productDesc + ","; + } + } + } + // const selectedCodes = this.selectList.map(item => item.workorderCode) + // this.wetMaterialPlanList = this.wetMaterialPlanList.filter(item => !selectedCodes.includes(item.workorderCode)) // 重置数据 this.form.bucketId = null this.form.productId = null + this.form.productName = null }, /** 新增-确定按钮 */ batchBtn() { @@ -936,6 +1087,7 @@ export default { // 取消按钮 cancel() { this.open = false + this.dialogVisible = false this.reset() }, // 表单重置 @@ -1049,6 +1201,7 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.checkUpdate = true; checkChangePlan(row.id).then(response => { if (response.code == 500) { @@ -1095,13 +1248,15 @@ export default { }, /** 修改-提交按钮 */ updateForm() { - // 必须全部修改 - if (this.wetMaterialPlanList.length > 0) { - this.$message({ - message: '计划要全部重新分配完!', - type: 'warning' - }) - return + // TODO 必须全部修改 + for (let i = 0; i < this.wetMaterialPlanList.length; i++) { + if (this.wetMaterialPlanList[i].bucketName == null) { + this.$message({ + message: '计划要全部重新分配完!', + type: 'warning' + }) + return + } } // 校验数据判断newList是否为空 if (this.newWorkOrderList == [] || this.newWorkOrderList.length == 0 || this.newWorkOrderList == null) {