diff --git a/src/views/plan/plan/index.vue b/src/views/plan/plan/index.vue index 50d2e09..998e938 100644 --- a/src/views/plan/plan/index.vue +++ b/src/views/plan/plan/index.vue @@ -12,12 +12,12 @@ > - - - - - - + + + + + + - - + + @@ -194,12 +194,12 @@ - - - - - - + + + + + + @@ -237,6 +237,17 @@ + + + @@ -429,6 +440,7 @@ export default { dicts: ['sys_yes_no'], data() { return { + // 选中物料 // 新增-物料list materiel: [], materielList: [], @@ -499,19 +511,64 @@ export default { form: { bucketId: null, productId: null, - planTime: null + planTime: null, + productName: null }, // 表单校验 rules: {} } }, created() { - this.timeList = [new Date(),new Date()] + this.timeList = [new Date(), new Date()] this.queryParams.startTime = moment(this.timeList[0]).format('YYYY-MM-DD') this.queryParams.endTime = moment(this.timeList[1]).format('YYYY-MM-DD') this.getList() }, methods: { + // 删除选好的工单 + deleteSelectWork(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.workOrderList.length; i++) { + if (e.workorderCode == this.workOrderList[i].workorderCode) { + // 物料 + let materialNameArray = this.workOrderList[i].materialName1.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.workOrderList[i].bucketName1.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.workOrderList[i].materialName1 = newMaterialName1; + this.workOrderList[i].bucketName1 = newBucketName1; + + } + } + }, // 新增-物料搜索 handleMaterielQuery() { this.materielQueryParams.pageNum = 1; @@ -540,6 +597,9 @@ export default { this.form.productId = this.materiel[0].productId; this.form.prodCode = this.materiel[0].productCode; this.form.prodDesc = this.materiel[0].productDescZh; + + this.form.productName = this.materiel[0].productDescZh; + this.innerVisible = false; }, // 新增-查询物料列表 @@ -650,14 +710,14 @@ export default { }) return } - if (this.form.bucketId == null){ + if (this.form.bucketId == null) { this.$message({ message: '请选择料管!', type: 'warning' }) return } - if (this.form.productId == null){ + if (this.form.productId == null) { this.$message({ message: '请选择物料!', type: 'warning' @@ -690,7 +750,7 @@ export default { } } } - this.bmsList.push(bms) + // 数据保存(仅前端) // 创建料罐对象 var bucket @@ -707,8 +767,76 @@ export default { } } + // 检验工单-物料-料罐 + for (let i = 0; i < this.selectList.length; i++) { + for (let j = 0; j < this.workOrderList.length; j++) { + if (this.selectList[i].workorderCode == this.workOrderList[j].workorderCode) { + // 物料 + if (this.workOrderList[j].materialName1 != null) { + let materialNameArray = this.workOrderList[j].materialName1.split(','); + for (let i = materialNameArray.length - 2; i >= 0; i--) { + if (material.productDesc != materialNameArray[i]) { + this.$message({ + message: '同一工单只能选一个物料!', + type: 'warning' + }) + return + } + } + } + // 料罐 + if (this.workOrderList[j].bucketName1 != null) { + let bucketArray = this.workOrderList[j].bucketName1.split(','); + for (let i = bucketArray.length - 1; i >= 0; i--) { + if (bucket.bucketName == bucketArray[i]) { + this.$message({ + message: '料罐重复!', + type: 'warning' + }) + return + } + } + } + } + } + } + + this.bmsList.push(bms) + + // 创建一个新工单对象 + 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, + }; + // 将选择的信息放入newList for (let i = 0; i < this.selectList.length; i++) { + 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 @@ -716,20 +844,35 @@ export default { 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]) + + this.newWorkOrderList.push(workOrder) } // 将选择的数据在上方的列表中删除 - const selectedCodes = this.selectList.map(item => item.workorderCode) - this.workOrderList = this.workOrderList.filter(item => !selectedCodes.includes(item.workorderCode)) + // const selectedCodes = this.selectList.map(item => item.workorderCode) + for (let i = 0; i < this.selectList.length; i++) { + for (let j = 0; j < this.workOrderList.length; j++) { + if (this.selectList[i].workorderCode == this.workOrderList[j].workorderCode) { + if (this.workOrderList[j].bucketName1 == null) { + this.workOrderList[j].bucketName1 = ""; + } + this.workOrderList[j].bucketName1 += this.selectList[i].bucketName + ","; + if (this.workOrderList[j].materialName1 == null) { + this.workOrderList[j].materialName1 = ""; + } + this.workOrderList[j].materialName1 += this.selectList[i].materialName + ","; + } + } + } + // this.workOrderList = this.workOrderList.filter(item => !selectedCodes.includes(item.workorderCode)) // 重置数据 this.form.bucketId = null this.form.productId = null - + this.form.productName = null }, /** 校验计划日期 */ - checkDate: function(e) { + checkDate: function (e) { if (this.newWorkOrderList.length > 0) { this.$message({ message: '您已生成数据不能更改日期!', @@ -905,9 +1048,9 @@ export default { /** 修改按钮操作 */ handleUpdate(row) { checkChangePlan(row.id).then(response => { - if (response.code == 500){ + if (response.code == 500) { - }else { + } else { // 清除缓存 this.reset() this.selectBucketList = null @@ -951,7 +1094,7 @@ export default { /** 修改-提交按钮 */ updateForm() { // 必须全部修改 - if (this.wetMaterialPlanList.length>0){ + if (this.wetMaterialPlanList.length > 0) { this.$message({ message: '计划要全部重新分配完!', type: 'warning' @@ -1005,7 +1148,7 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const ids = row.id || this.ids - this.$modal.confirm('是否确认删除湿料计划管理编号为"' + ids + '"的数据项?').then(function() { + this.$modal.confirm('是否确认删除湿料计划管理编号为"' + ids + '"的数据项?').then(function () { return delPlan(ids) }).then(() => { this.getList()