|
|
|
@ -50,20 +50,25 @@
|
|
|
|
|
border
|
|
|
|
|
default-expand-all
|
|
|
|
|
>
|
|
|
|
|
<el-table-column label="序号" type="index" align="center">
|
|
|
|
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
width="80"
|
|
|
|
|
label="删除"
|
|
|
|
|
type=""
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button type="danger" icon="el-icon-delete" @click="handleDeleteMesProductPlan(scope)"
|
|
|
|
|
v-if="scope.row.deleteFlag != null && scope.row.deleteFlag === '1'"></el-button>
|
|
|
|
|
v-if="scope.row.firstFlag != null && scope.row.firstFlag === '1'"></el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
width="80"
|
|
|
|
|
type=""
|
|
|
|
|
label="添加"
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope" v-if="">
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus" @click="addProcessUser(scope)"
|
|
|
|
@ -106,7 +111,9 @@
|
|
|
|
|
<el-table-column align="center" label="派工数量" prop="dispatchAmount" width="100">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-input v-model="scope.row.dispatchAmount" :disabled="scope.row.oldRowFlag"
|
|
|
|
|
v-if="scope.row.children != null && scope.row.children !== undefined"/>
|
|
|
|
|
v-if="scope.row.children != null && scope.row.children !== undefined
|
|
|
|
|
&& scope.row.firstFlag != null && scope.row.firstFlag === '1'"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
|
@ -377,6 +384,7 @@ import {
|
|
|
|
|
deleteProductPlansByDispatchCode,
|
|
|
|
|
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
|
|
|
|
|
selectProductPlans,
|
|
|
|
|
checkAddMesProductPlanList,
|
|
|
|
|
orderAddMesProductPlanList,
|
|
|
|
|
getBaseRouteProcesses,
|
|
|
|
|
getProcessUsers,
|
|
|
|
@ -605,7 +613,7 @@ export default {
|
|
|
|
|
let dispatchCode = dispatchCodeProcessId.split("-")[0];
|
|
|
|
|
if (!firstDispatch[dispatchCode]) {
|
|
|
|
|
firstDispatch[dispatchCode] = "1";
|
|
|
|
|
obj.deleteFlag = "1";
|
|
|
|
|
obj.firstFlag = "1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj.id = this.id
|
|
|
|
@ -742,6 +750,7 @@ export default {
|
|
|
|
|
let dataList = this.mesProductPlanList;
|
|
|
|
|
let toUpdatedProductPlans = [];
|
|
|
|
|
let undispathDesc;
|
|
|
|
|
let currentDispatchAmount = 0;
|
|
|
|
|
for (let i = 0; i < dataList.length; i++) {
|
|
|
|
|
let e = dataList[i];
|
|
|
|
|
|
|
|
|
@ -753,13 +762,18 @@ export default {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let j = 0; j < e.children.length; j++) {
|
|
|
|
|
let processUser = e.children[j];
|
|
|
|
|
let toUpdatedProductPlan = deepClone(e);
|
|
|
|
|
|
|
|
|
|
if (processUser.userId && processUser.userId !== '') {
|
|
|
|
|
toUpdatedProductPlan.userId = processUser.userId;
|
|
|
|
|
if(processUser.planBeginTime && processUser.planBeginTime!=='' &&
|
|
|
|
|
processUser.planEndTime && processUser.planEndTime!=='' &&
|
|
|
|
|
processUser.planBeginTime >= processUser.planEndTime){
|
|
|
|
|
this.$modal.msgError("序号"+(parseInt(e.index)+1)+":计划开始时间须小于计划结束时间");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
toUpdatedProductPlan.planBeginTime = processUser.planBeginTime;
|
|
|
|
|
toUpdatedProductPlan.planEndTime = processUser.planEndTime;
|
|
|
|
|
toUpdatedProductPlan.planId = processUser.planId;
|
|
|
|
@ -776,7 +790,7 @@ export default {
|
|
|
|
|
dispatchFlag = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.$modal.msgError(undispathDesc);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -788,67 +802,54 @@ export default {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 校验派工数量(已派工数量 + 派工数量 <= 计划数量)
|
|
|
|
|
// 按照processId分组,所有分组的planAmount之和是否相等,相等后输出planAmount之和的值
|
|
|
|
|
let dispatchAmountErrorMsg = "";
|
|
|
|
|
const sumList = dataList.reduce((result, planData) => {
|
|
|
|
|
let processId = planData.processId;
|
|
|
|
|
let newFlag = planData.newFlag;
|
|
|
|
|
let dispatchAmount = planData.dispatchAmount;
|
|
|
|
|
if (newFlag && newFlag === "1") {
|
|
|
|
|
dispatchAmount = dispatchAmount == null || dispatchAmount === '' ? 0 : dispatchAmount;
|
|
|
|
|
if(e.firstFlag && e.firstFlag==="1"){//第一个标识,校验派工数量
|
|
|
|
|
let dispatchAmount = e.dispatchAmount;
|
|
|
|
|
const numericAmount = parseInt(dispatchAmount, 10);
|
|
|
|
|
if (!this.isPositiveInteger(numericAmount) || numericAmount <= 0) {
|
|
|
|
|
dispatchAmountErrorMsg = "派工数量须为大于等于0的正整数!";
|
|
|
|
|
this.$modal.msgError( "派工数量须为大于等于0的正整数!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!result[processId]) {
|
|
|
|
|
result[processId] = 0;
|
|
|
|
|
|
|
|
|
|
if (e.newFlag && e.newFlag === "1") {
|
|
|
|
|
currentDispatchAmount += numericAmount;
|
|
|
|
|
}
|
|
|
|
|
result[processId] = (result[processId] || 0) + numericAmount;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
if (dispatchAmountErrorMsg !== "") {
|
|
|
|
|
this.$modal.msgError(dispatchAmountErrorMsg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//一种快速去除数组中重复元素的方法,特别适合处理从对象中提取的属性值数组,(例如按工序相加的数量都是一样的,则去重后就剩一个数)
|
|
|
|
|
const uniqueSum = new Set(Object.values(sumList));
|
|
|
|
|
|
|
|
|
|
let currentDispatchAmount = 0;
|
|
|
|
|
if (uniqueSum.size === 1) {
|
|
|
|
|
const finalSum = Array.from(uniqueSum)[0];
|
|
|
|
|
currentDispatchAmount = finalSum;
|
|
|
|
|
let dispatchedAmount = this.form.dispatchAmount + finalSum;//加上此次派工的数量,总共的派工数量
|
|
|
|
|
//校验派工数量是否大于生产任务计划数量
|
|
|
|
|
let dispatchedAmount = this.form.dispatchAmount + currentDispatchAmount;//加上此次派工的数量,总共的派工数量
|
|
|
|
|
if (dispatchedAmount > this.form.planAmount) {
|
|
|
|
|
this.$modal.msgError("每个工序的派工数量之和需小于等于该工单计划数量!");
|
|
|
|
|
this.$modal.msgError("派工数量之和需小于等于该生产任务计划数量!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else if (uniqueSum.size > 1) {
|
|
|
|
|
this.$modal.msgError("每个工序的派工数量之和需相等!");
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkAddMesProductPlanList(
|
|
|
|
|
{
|
|
|
|
|
productOrderId: this.form.productOrderId,
|
|
|
|
|
dispatchAmount: currentDispatchAmount,
|
|
|
|
|
saleOrderId: this.form.saleOrderId,
|
|
|
|
|
mesProductPlanList: toUpdatedProductPlans,
|
|
|
|
|
})
|
|
|
|
|
.then(res => {
|
|
|
|
|
if (res?.msg && res.msg !== '') {
|
|
|
|
|
this.$modal.confirm('有以下用户派工冲突,请确认是否继续派工?' + res.msg).then(function () {
|
|
|
|
|
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans);
|
|
|
|
|
return true;
|
|
|
|
|
}).then(() => {
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// console.log(JSON.stringify(toUpdatedProductPlans));
|
|
|
|
|
// alert(this.toDeletedPlanIds)
|
|
|
|
|
// return;
|
|
|
|
|
// checkProductPlanUserConflictAndRawStock(
|
|
|
|
|
// {
|
|
|
|
|
// productOrderId: this.form.productOrderId,
|
|
|
|
|
// dispatchAmount: currentDispatchAmount,
|
|
|
|
|
// saleOrderId: this.form.saleOrderId
|
|
|
|
|
// })
|
|
|
|
|
// .then(res => {
|
|
|
|
|
// this.$modal.msgSuccess(res.msg);
|
|
|
|
|
// this.close();
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans) {
|
|
|
|
|
orderAddMesProductPlanList(
|
|
|
|
|
{
|
|
|
|
|
productOrderId: this.form.productOrderId,
|
|
|
|
@ -956,7 +957,7 @@ export default {
|
|
|
|
|
res.data.forEach((e, index) => {
|
|
|
|
|
let obj = {};
|
|
|
|
|
if (i === 0) {
|
|
|
|
|
obj.deleteFlag = "1";//设置第一条记录删除标识,代表只能此派工单号只有第一条记录上有删除按钮,删除时同意删除此派工单号的派工
|
|
|
|
|
obj.firstFlag = "1";//设置第一条标识,代表只能此派工单号只有第一条记录上有删除按钮,删除时同意删除此派工单号的派工,第一条有派工数量即可
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
obj.id = this.id
|
|
|
|
|