出库问题修改

master
zhangdi 2 days ago
parent 1f68203d4f
commit 87ba7cdad5
  1. 147
      src/views/firstOrder/components/outDialog.vue

@ -580,7 +580,7 @@ export default {
item.materialCode === stat.materialCode && item.materialCode === stat.materialCode &&
item.materialName === stat.materialName item.materialName === stat.materialName
); );
console.log(898989, detailList); console.log(898989,detailList)
detail.theOutboundQuantity = detailList.reduce( detail.theOutboundQuantity = detailList.reduce(
(acc, cur) => acc + cur.num, (acc, cur) => acc + cur.num,
0 0
@ -772,7 +772,6 @@ export default {
// IdDemandEndld: this.inBatchForm.batchType, // IdDemandEndld: this.inBatchForm.batchType,
// department: deptName, // department: deptName,
// })); // }));
const processedData = res.data.result.map((item) => { const processedData = res.data.result.map((item) => {
// - // -
// 0 // 0
@ -785,7 +784,7 @@ export default {
IdDemandEndld: this.inBatchForm.batchType, IdDemandEndld: this.inBatchForm.batchType,
department: deptName, // IDsubmit department: deptName, // IDsubmit
// 0 // 0
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0, theOutboundQuantity: defaultQty > 0 ? defaultQty : 0
}; };
}); });
this.sizeForm.inTableData = processedData; this.sizeForm.inTableData = processedData;
@ -890,130 +889,62 @@ export default {
this.$message.error("请选择物资类型"); this.$message.error("请选择物资类型");
return; return;
} }
if (this.sizeForm.options === 1) {
// if (!this.sizeForm.demandEndInfo) {
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) { this.$message.error("请选择需求单名称");
this.$message.error("请添加出库物资数据");
return; return;
} }
if (
// status == 1 2 !this.sizeForm.inTableData ||
this.sizeForm.status = index; this.sizeForm.inTableData.length === 0
) {
// this.$message.error("请添加批量选择数据");
let submitList = []; 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;
} }
if (this.sizeForm.options === 2) {
for (const row of this.sizeForm.inTableData) {
if (!row.departmentName) {
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;
} }
} }
} }
// status == 1 2
this.sizeForm.status = index;
this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData;
let arr = this.list.find(
(item) => item.departmentId === this.inBatchForm.department || {}
);
this.sizeForm.optionType = this.inBatchForm.optionType;
submitList = this.sizeForm.inTableData.map((row) => {
// materialId, code, name
// department oneFormId ()
// row departmentId ( batchSubmit ID)
// 使 deptId
return { this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData.map(
...row, (row) => {
// 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 {
// (options == 2)
//
submitList = this.sizeForm.inTableData.map((row) => {
const deptId = row.department; const deptId = row.department;
const dept = this.list.find((item) => item.departmentId === deptId); const dept = this.list.find((item) => item.departmentId === deptId);
const oneFormId = row.id;
// materials
let select = this.materials.find( let select = this.materials.find(
(item) => item.materialId === row.materialId (item) => item.materialId === row.materialId
); );
//
if (!select) {
console.warn('未找到对应的物资信息', row.materialId);
select = {};
}
return { return {
...row, ...row,
department: deptId, department:
departmentName: dept ? dept.department : row.departmentName, this.sizeForm.options == "1" ? arr.departmentId : deptId,
oneFormId: select.id || row.oneFormId, // departmentName:
materialCode: select.materialCode || row.materialCode, this.sizeForm.options == "1" ? arr.department : dept.department,
materialName: select.materialName || row.materialName, oneFormId: row.oneFormId,
model: select.model || row.model,
type: select.type || row.type,
unit: select.unit || row.unit
}; };
});
} }
);
this.sizeForm.ldOneOutStorageDetailVOList = submitList;
if (this.outDialogTiltle == "编辑") { if (this.outDialogTiltle == "编辑") {
this.sizeForm.id = this.id; this.sizeForm.id = this.id;
} }
if (this.sizeForm.options === 1) {
this.sizeForm.optionType = this.inBatchForm.optionType;
}
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({
@ -1021,15 +952,15 @@ export default {
message: "提交成功", message: "提交成功",
}); });
this.$emit("submitSuccess"); this.$emit("submitSuccess");
this.saveLoading = false;
this.handleCloseDetail(); this.handleCloseDetail();
} else { } else {
this.saveLoading = false;
this.$message.error(res.data.message || "提交失败"); this.$message.error(res.data.message || "提交失败");
} }
} catch (error) { } catch (error) {
console.error(error);
this.$message.error(error.message || "服务器错误");
} finally {
this.saveLoading = false; this.saveLoading = false;
this.$message.error(error.message || "服务器错误");
} }
}, },
@ -1069,10 +1000,12 @@ export default {
this.batchSelectionVisible = false; this.batchSelectionVisible = false;
this.sizeForm.optionType = ""; this.sizeForm.optionType = "";
this.batchTableData = []; this.batchTableData = [];
this.inBatchForm.batchType = ""
this.inBatchForm.department = ""
if (this.sizeForm.options === 1) { if (this.sizeForm.options === 1) {
this.getQuarterList(); this.getQuarterList();
this.inBatchDialogVisible = true; this.inBatchDialogVisible = true;
(this.inBatchForm.batchType = ""), (this.inBatchForm.department = "");
this.inBatchForm.optionType = ""; this.inBatchForm.optionType = "";
} }
}, },

Loading…
Cancel
Save