fix(tsoorder): 修复产线选择和表单验证逻辑问题

This commit is contained in:
zxy 2026-04-20 14:35:12 +08:00
parent 9592f36871
commit dcd1833e0e
3 changed files with 52 additions and 56 deletions

View File

@ -134,8 +134,8 @@ export default {
const selectedData = this.selectedLines.map(line => ({ const selectedData = this.selectedLines.map(line => ({
lineId: line.id || line.lineId || '', lineId: line.id || line.lineId || '',
lineCode: line.proLineCd, lineCode: line.lineCode || line.proLineCd || '',
lineName: line.proLineName, lineName: line.lineName || line.proLineName || '',
remark: line.remark || "" remark: line.remark || ""
})); }));

View File

@ -116,7 +116,7 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item> <el-form-item>
<el-checkbox v-model="baseForm.isAllLine" @change="handleisAllLineChange" /> <el-checkbox v-model="baseForm.isAllLine" true-label="0" false-label="1" />
<span style="margin-left: 5px;">所有产线</span> <span style="margin-left: 5px;">所有产线</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -269,7 +269,7 @@ export default {
planBgDate: "", planBgDate: "",
processFlow: "", processFlow: "",
remark: "", remark: "",
isAllLine: false isAllLine: "1"
}, },
orderList: [], orderList: [],
lineList: [], lineList: [],
@ -451,44 +451,13 @@ export default {
}, },
addLine() { addLine() {
this.baseForm.isAllLine = "0"; this.baseForm.isAllLine = "1";
this.lineModalVisible = true; this.lineModalVisible = true;
}, },
handleisAllLineChange(val) { handleisAllLineChange(val) {
this.baseForm.isAllLine = val ? "1" : "0"; this.baseForm.isAllLine = val ? "0" : "1";
if (val) { this.lineList = [];
this.lineList = [];
request({
url: "/api/example/proLine/getSelectList",
method: "get"
}).then(res => {
if (res.code === 200) {
const lines = res.data || [];
if (lines.length > 10) {
this.$message.warning("产线数量超过10条请手动选择部分产线");
this.baseForm.isAllLine = "0";
return;
}
lines.forEach(line => {
this.lineList.push({
id: line.id,
lineCode: line.lineCode,
lineName: line.lineName,
allocateQty: null,
completedQty: null,
planStartDate: "",
planEndDate: "",
remark: ""
});
});
this.selectedLineCodes = this.lineList.map(item => item.lineCode);
}
});
} else {
this.lineList = [];
this.selectedLineCodes = [];
}
}, },
handleProLineConfirm(selectedLines) { handleProLineConfirm(selectedLines) {
@ -524,7 +493,11 @@ export default {
this.$refs.formRef.validate((valid) => { this.$refs.formRef.validate((valid) => {
if (valid) { if (valid) {
if (!this.validateOrderPlanQty()) return; if (!this.validateOrderPlanQty()) return;
if (this.lineList.length > 0 && !this.validateAllocateQty()) return; if (this.baseForm.isAllLine !== "0" && (!this.lineList || this.lineList.length === 0)) {
this.$message.warning("请选择产线信息!");
return;
}
if (this.baseForm.isAllLine !== "0" && this.lineList.length > 0 && !this.validateAllocateQty()) return;
const submitData = this.prepareSubmitData(); const submitData = this.prepareSubmitData();
submitData.orderStatus = "0"; submitData.orderStatus = "0";
this.generateCheck(submitData).then(() => { this.generateCheck(submitData).then(() => {
@ -537,7 +510,7 @@ export default {
}, },
submit() { submit() {
if (!this.lineList || this.lineList.length === 0) { if (this.baseForm.isAllLine !== "0" && (!this.lineList || this.lineList.length === 0)) {
this.$message.warning("生产订单下发必须指定产线,请确认!"); this.$message.warning("生产订单下发必须指定产线,请确认!");
return; return;
} }
@ -553,11 +526,17 @@ export default {
if (res.code === 200) { if (res.code === 200) {
resolve(); resolve();
} else { } else {
this.$message.error(res.msg || "检查失败"); this.$message({
type: "warning",
message: res.msg || "检查失败!",
});
reject(res.msg); reject(res.msg);
} }
}).catch(err => { }).catch(err => {
this.$message.error("检查接口调用失败"); this.$message({
type: "error",
message: "检查接口调用失败!",
});
reject(err); reject(err);
}); });
}); });
@ -570,8 +549,11 @@ export default {
data: submitData data: submitData
}).then(res => { }).then(res => {
if (res.code === 200) { if (res.code === 200) {
const message = submitData.orderStatus === "0" ? "保存成功" : "下发成功"; const message = submitData.orderStatus === "0" ? "保存成功!" : "下发成功!";
this.$message.success(message); this.$message({
type: "success",
message: message,
});
this.goBack(); this.goBack();
} }
}); });
@ -734,6 +716,12 @@ export default {
width: 100%; width: 100%;
} }
.base-form ::v-deep .el-input,
.base-form ::v-deep .el-select,
.base-form ::v-deep .el-date-picker {
width: 100%;
}
.checkbox-label { .checkbox-label {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -310,22 +310,30 @@ export default {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { })
request({ .then(() => {
url: "/api/example/proOrder/close", return request({
method: "post", url: "/api/example/proOrder/close",
data: { id: row.itemId } method: "post",
}).then(res => { data: { id: row.itemId }
});
})
.then(res => {
if (res.code === 200) { if (res.code === 200) {
this.$message.success("关闭成功"); this.$message({
type: "success",
message: res.msg || "关闭成功!",
});
this.initData(); this.initData();
} else {
this.$message({
type: "warning",
message: res.msg || "操作失败!",
});
} }
}).catch(() => { })
this.$message.error("关闭失败"); .catch(() => {
}); });
}).catch(() => {
this.$message.info('已取消关闭');
});
}, },
}, },
}; };