暂存问题不生效修改

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

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

Loading…
Cancel
Save