提交问题修改

master
zhangdi 1 week ago
parent 0e4bdc44ff
commit 1f68203d4f
  1. 180
      src/views/firstOrder/components/outDialog.vue

@ -580,7 +580,7 @@ export default {
item.materialCode === stat.materialCode &&
item.materialName === stat.materialName
);
console.log(898989,detailList)
console.log(898989, detailList);
detail.theOutboundQuantity = detailList.reduce(
(acc, cur) => acc + cur.num,
0
@ -772,19 +772,20 @@ export default {
// 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
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0,
};
});
this.sizeForm.inTableData = processedData;
@ -881,8 +882,7 @@ export default {
},
//
async submit(index) {
// 1.
if (!this.sizeForm.reason) {
if (!this.sizeForm.reason) {
this.$message.error("事由不能为空");
return;
}
@ -890,112 +890,146 @@ export default {
this.$message.error("请选择物资类型");
return;
}
//
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) {
this.$message.error("请添加出库物资数据");
return;
}
// 2.
let finalDetailList = [];
// status == 1 2
this.sizeForm.status = index;
//
let submitList = [];
if (this.sizeForm.options === 1) {
// === ===
if (!this.sizeForm.demandEndInfo) {
this.$message.error("请选择需求单名称");
return;
}
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) {
this.$message.error("请添加批量选择数据");
return;
// (options == 1)
if (this.sizeForm.options == 1) {
// 1.
// inBatchForm.department
// batchSubmit sizeForm
let deptId = null;
let deptName = "";
// inBatchForm
if (this.inBatchForm.department) {
const selectedDept = this.list.find(item => item.departmentId === this.inBatchForm.department);
if (selectedDept) {
deptId = selectedDept.departmentId;
deptName = selectedDept.department;
}
}
//
// inBatchForm.department ID
const selectedDeptObj = this.departmentList.find(
(item) => item.departmentId === this.inBatchForm.department
);
if (!selectedDeptObj) {
this.$message.error("部门信息丢失,请重新选择需求单和部门");
return;
// inBatchForm batchSubmit department
if (!deptId && this.sizeForm.inTableData.length > 0) {
// batchSubmit departmentId department
// batchSubmit: department: deptName (ID)
// : department: deptName (ID)
// ID Name
// batchSubmit :
// department: deptName ()
// list
const firstRow = this.sizeForm.inTableData[0];
// departmentId
// batchSubmit ID Name
// batchSubmit:
// const deptName = selectedDept ? selectedDept.department : "";
// department: deptName
// BugID
// list ID
if(firstRow.department) {
const deptObj = this.list.find(d => d.department === firstRow.department);
if(deptObj) {
deptId = deptObj.departmentId;
deptName = deptObj.department;
}
}
}
//
finalDetailList = this.sizeForm.inTableData.map((row) => {
// inBatchForm
this.sizeForm.optionType = this.inBatchForm.optionType;
submitList = this.sizeForm.inTableData.map((row) => {
// materialId, code, name
// department oneFormId ()
// row departmentId ( batchSubmit ID)
// 使 deptId
return {
...row,
department: selectedDeptObj.departmentId, // ID
departmentName: selectedDeptObj.department, //
// oneFormId row id materialId
// : oneFormId: select.id ( select )
// batchList ID
oneFormId: row.oneFormId || row.id
// ID
department: deptId || row.departmentId || row.department,
departmentName: deptName || row.departmentName || row.department,
// oneFormId materials id
// : oneFormId: select.id select
// item id ( detailId)
oneFormId: row.id || row.materialId,
theOutboundQuantity: row.theOutboundQuantity || row.num //
};
});
} 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;
}
}
// ID
finalDetailList = this.sizeForm.inTableData.map((row) => {
} else {
// (options == 2)
//
submitList = this.sizeForm.inTableData.map((row) => {
const deptId = row.department;
// this.list ()
const deptObj = this.list.find((item) => item.departmentId === deptId);
const dept = this.list.find((item) => item.departmentId === deptId);
// materials
let select = this.materials.find(
(item) => item.materialId === row.materialId
);
//
if (!select) {
console.warn('未找到对应的物资信息', row.materialId);
select = {};
}
return {
...row,
department: deptId,
departmentName: deptObj ? deptObj.department : "",
oneFormId: row.oneFormId || row.id
departmentName: dept ? dept.department : row.departmentName,
oneFormId: select.id || row.oneFormId, //
materialCode: select.materialCode || row.materialCode,
materialName: select.materialName || row.materialName,
model: select.model || row.model,
type: select.type || row.type,
unit: select.unit || row.unit
};
});
}
// 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.ldOneOutStorageDetailVOList = submitList;
if (this.outDialogTiltle == "编辑") {
this.sizeForm.id = this.id;
}
// 4.
try {
this.saveLoading = true;
console.log('提交数据:', this.sizeForm); //
// 便
console.log('提交数据:', this.sizeForm);
const res = await submitData(this.sizeForm);
if (res.data.success) {
this.$message({
type: "success",
message: index === 1 ? "暂存成功" : "提交成功",
message: "提交成功",
});
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 || "服务器错误");
} finally {
this.saveLoading = false;
}
},

Loading…
Cancel
Save