|
|
|
@ -50,27 +50,32 @@
|
|
|
|
|
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)"
|
|
|
|
|
v-if="(scope.row.children != null && scope.row.children !== undefined)
|
|
|
|
|
&& scope.row.processType!== PROCESS_TYPE.AUTO && scope.row.displayFlag !== DISPLAY_FLAG.NO"
|
|
|
|
|
:disabled="scope.row.addFlag !=='1'
|
|
|
|
|
|| form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED" >
|
|
|
|
|
:disabled="scope.row.addFlag !=='1'
|
|
|
|
|
|| form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED">
|
|
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
@ -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>
|
|
|
|
|
|
|
|
|
@ -206,7 +213,7 @@
|
|
|
|
|
type="danger"
|
|
|
|
|
@click="handleDeleteDispatchUser(scope.row)"
|
|
|
|
|
v-if="(scope.row.children == null || false) "
|
|
|
|
|
:disabled = "(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED"
|
|
|
|
|
:disabled="(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED"
|
|
|
|
|
>删除
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
|
@ -377,6 +384,7 @@ import {
|
|
|
|
|
deleteProductPlansByDispatchCode,
|
|
|
|
|
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
|
|
|
|
|
selectProductPlans,
|
|
|
|
|
checkAddMesProductPlanList,
|
|
|
|
|
orderAddMesProductPlanList,
|
|
|
|
|
getBaseRouteProcesses,
|
|
|
|
|
getProcessUsers,
|
|
|
|
@ -409,7 +417,7 @@ let deepSearch = (arr, target) => {
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "productPlanEdit",
|
|
|
|
|
dicts: ['plan_status','product_status', 'mes_dispatch_flag'],
|
|
|
|
|
dicts: ['plan_status', 'product_status', 'mes_dispatch_flag'],
|
|
|
|
|
components: {
|
|
|
|
|
'apply-raw-outstock': applyRawOutstock,
|
|
|
|
|
},
|
|
|
|
@ -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
|
|
|
|
@ -614,7 +622,7 @@ export default {
|
|
|
|
|
let i = 0;
|
|
|
|
|
let processType;
|
|
|
|
|
productPlansByDispatch.forEach(groupedProductPlan => {
|
|
|
|
|
if(groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED){
|
|
|
|
|
if (groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED) {
|
|
|
|
|
obj.addFlag = "1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -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,56 +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);
|
|
|
|
|
//校验派工数量是否大于生产任务计划数量
|
|
|
|
|
let dispatchedAmount = this.form.dispatchAmount + currentDispatchAmount;//加上此次派工的数量,总共的派工数量
|
|
|
|
|
if (dispatchedAmount > this.form.planAmount) {
|
|
|
|
|
this.$modal.msgError("派工数量之和需小于等于该生产任务计划数量!");
|
|
|
|
|
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;//加上此次派工的数量,总共的派工数量
|
|
|
|
|
if (dispatchedAmount > this.form.planAmount) {
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans) {
|
|
|
|
|
orderAddMesProductPlanList(
|
|
|
|
|
{
|
|
|
|
|
productOrderId: this.form.productOrderId,
|
|
|
|
@ -858,18 +870,18 @@ export default {
|
|
|
|
|
this.$modal.confirm('是否确认删除生产派工单号为"' + dispatchCode + '"的数据项?').then(function () {
|
|
|
|
|
return true;
|
|
|
|
|
}).then(() => {
|
|
|
|
|
if(this.form.orderStatus === this.ORDER_STATUS.RECALLED){
|
|
|
|
|
this.$modal.msgError("此生产任务已经撤回,不能删除") ;
|
|
|
|
|
if (this.form.orderStatus === this.ORDER_STATUS.RECALLED) {
|
|
|
|
|
this.$modal.msgError("此生产任务已经撤回,不能删除");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(this.form.orderStatus === this.ORDER_STATUS.FINISHED){
|
|
|
|
|
this.$modal.msgError("此生产任务已经完成,不能删除") ;
|
|
|
|
|
if (this.form.orderStatus === this.ORDER_STATUS.FINISHED) {
|
|
|
|
|
this.$modal.msgError("此生产任务已经完成,不能删除");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(this.form.orderStatus === this.ORDER_STATUS.DELETED){
|
|
|
|
|
this.$modal.msgError("此生产任务已经删除,不能删除") ;
|
|
|
|
|
if (this.form.orderStatus === this.ORDER_STATUS.DELETED) {
|
|
|
|
|
this.$modal.msgError("此生产任务已经删除,不能删除");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -945,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
|
|
|
|
|