暂存问题不生效修改

master
zhangdi 2 days ago
parent 6ee1c080e5
commit 0e4bdc44ff
  1. 134
      src/views/firstOrder/components/outDialog.vue

@ -767,11 +767,27 @@ export default {
);
const deptName = selectedDept ? selectedDept.department : "";
this.sizeForm.inTableData = res.data.result.map((item) => ({
...item,
IdDemandEndld: this.inBatchForm.batchType,
department: deptName,
}));
// this.sizeForm.inTableData = res.data.result.map((item) => ({
// ...item,
// IdDemandEndld: this.inBatchForm.batchType,
// department: deptName,
// }));
const processedData = res.data.result.map((item) => {
// -
// 0
const appQty = Number(item.applicationQuantity || 0);
const outQty = Number(item.outboundQuantity || 0);
const defaultQty = appQty - outQty;
return {
...item,
IdDemandEndld: this.inBatchForm.batchType,
department: deptName, // IDsubmit
// 0
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0
};
});
this.sizeForm.inTableData = processedData;
//
this.inBatchDialogVisible = false;
@ -865,6 +881,7 @@ export default {
},
//
async submit(index) {
// 1.
if (!this.sizeForm.reason) {
this.$message.error("事由不能为空");
return;
@ -873,73 +890,110 @@ export default {
this.$message.error("请选择物资类型");
return;
}
// 2.
let finalDetailList = [];
if (this.sizeForm.options === 1) {
// === ===
if (!this.sizeForm.demandEndInfo) {
this.$message.error("请选择需求单名称");
return;
}
if (
!this.sizeForm.inTableData ||
this.sizeForm.inTableData.length === 0
) {
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) {
this.$message.error("请添加批量选择数据");
return;
}
if (this.sizeForm.options === 2) {
for (const row of this.sizeForm.inTableData) {
if (!row.departmentName) {
this.$message.error("请选择部门");
return;
}
//
// inBatchForm.department ID
const selectedDeptObj = this.departmentList.find(
(item) => item.departmentId === this.inBatchForm.department
);
if (!selectedDeptObj) {
this.$message.error("部门信息丢失,请重新选择需求单和部门");
return;
}
//
finalDetailList = this.sizeForm.inTableData.map((row) => {
// inBatchForm
return {
...row,
department: selectedDeptObj.departmentId, // ID
departmentName: selectedDeptObj.department, //
// oneFormId row id materialId
// : oneFormId: select.id ( select )
// batchList ID
oneFormId: row.oneFormId || row.id
};
});
} else if (this.sizeForm.options === 2) {
// === ===
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) {
this.$message.error("请至少添加一条物资数据");
return;
}
for (const row of this.sizeForm.inTableData) {
if (!row.department) { // v-model scope.row.department (ID)
this.$message.error("请选择部门");
return;
}
}
}
// status == 1 2
this.sizeForm.status = index;
this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData;
let arr = this.departmentList.find(
(item) => item.departmentId === this.inBatchForm.department || {}
);
this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData.map(
(row) => {
// ID
finalDetailList = this.sizeForm.inTableData.map((row) => {
const deptId = row.department;
const dept = this.list.find((item) => item.departmentId === deptId);
const oneFormId = row.id;
let select = this.materials.find(
(item) => item.materialId === row.materialId
);
// this.list ()
const deptObj = this.list.find((item) => item.departmentId === deptId);
return {
...row,
department:
this.sizeForm.options == "1" ? arr.departmentId : deptId,
departmentName:
this.sizeForm.options == "1" ? arr.department : dept.department,
oneFormId: select.id,
department: deptId,
departmentName: deptObj ? deptObj.department : "",
oneFormId: row.oneFormId || row.id
};
}
);
if (this.outDialogTiltle == "编辑") {
this.sizeForm.id = this.id;
});
}
// 3.
this.sizeForm.status = index;
this.sizeForm.ldOneOutStorageDetailVOList = finalDetailList;
// optionType
if (this.sizeForm.options === 1) {
this.sizeForm.optionType = this.inBatchForm.optionType;
}
// ID
if (this.outDialogTiltle == "编辑" || this.outDialogType == "edit") {
this.sizeForm.id = this.id;
}
// 4.
try {
this.saveLoading = true;
console.log('提交数据:', this.sizeForm); //
const res = await submitData(this.sizeForm);
if (res.data.success) {
this.$message({
type: "success",
message: "提交成功",
message: index === 1 ? "暂存成功" : "提交成功",
});
this.$emit("submitSuccess");
this.saveLoading = false;
this.handleCloseDetail();
} else {
this.saveLoading = false;
this.$message.error(res.data.message || "提交失败");
this.$message.error(res.data.message || "操作失败");
}
} catch (error) {
console.error(error);
this.saveLoading = false;
this.$message.error(error.message || "服务器错误");
}

Loading…
Cancel
Save