出库问题修改

master
zhangdi 23 hours ago
parent 1f68203d4f
commit 87ba7cdad5
  1. 165
      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
@ -767,25 +767,24 @@ export default {
);
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,
IdDemandEndld: this.inBatchForm.batchType,
department: deptName, // IDsubmit
// 0
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0,
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0
};
});
this.sizeForm.inTableData = processedData;
@ -882,7 +881,7 @@ export default {
},
//
async submit(index) {
if (!this.sizeForm.reason) {
if (!this.sizeForm.reason) {
this.$message.error("事由不能为空");
return;
}
@ -890,130 +889,62 @@ export default {
this.$message.error("请选择物资类型");
return;
}
//
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) {
this.$message.error("请添加出库物资数据");
return;
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;
}
if (this.sizeForm.options === 2) {
for (const row of this.sizeForm.inTableData) {
if (!row.departmentName) {
this.$message.error("请选择部门");
return;
}
}
}
}
// status == 1 2
this.sizeForm.status = index;
this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData;
let arr = this.list.find(
(item) => item.departmentId === this.inBatchForm.department || {}
);
//
let submitList = [];
// (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 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;
}
}
}
this.sizeForm.optionType = this.inBatchForm.optionType;
submitList = this.sizeForm.inTableData.map((row) => {
// materialId, code, name
// department oneFormId ()
// row departmentId ( batchSubmit ID)
// 使 deptId
return {
...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) => {
this.sizeForm.ldOneOutStorageDetailVOList = this.sizeForm.inTableData.map(
(row) => {
const deptId = row.department;
const dept = this.list.find((item) => item.departmentId === deptId);
// materials
const oneFormId = row.id;
let select = this.materials.find(
(item) => item.materialId === row.materialId
);
//
if (!select) {
console.warn('未找到对应的物资信息', row.materialId);
select = {};
}
return {
...row,
department: deptId,
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
department:
this.sizeForm.options == "1" ? arr.departmentId : deptId,
departmentName:
this.sizeForm.options == "1" ? arr.department : dept.department,
oneFormId: row.oneFormId,
};
});
}
this.sizeForm.ldOneOutStorageDetailVOList = submitList;
}
);
if (this.outDialogTiltle == "编辑") {
this.sizeForm.id = this.id;
}
if (this.sizeForm.options === 1) {
this.sizeForm.optionType = this.inBatchForm.optionType;
}
try {
this.saveLoading = true;
// 便
console.log('提交数据:', this.sizeForm);
const res = await submitData(this.sizeForm);
if (res.data.success) {
this.$message({
@ -1021,15 +952,15 @@ export default {
message: "提交成功",
});
this.$emit("submitSuccess");
this.saveLoading = false;
this.handleCloseDetail();
} else {
this.saveLoading = false;
this.$message.error(res.data.message || "提交失败");
}
} catch (error) {
console.error(error);
this.$message.error(error.message || "服务器错误");
} finally {
this.saveLoading = false;
this.$message.error(error.message || "服务器错误");
}
},
@ -1069,10 +1000,12 @@ export default {
this.batchSelectionVisible = false;
this.sizeForm.optionType = "";
this.batchTableData = [];
this.inBatchForm.batchType = ""
this.inBatchForm.department = ""
if (this.sizeForm.options === 1) {
this.getQuarterList();
this.inBatchDialogVisible = true;
(this.inBatchForm.batchType = ""), (this.inBatchForm.department = "");
this.inBatchForm.optionType = "";
}
},

Loading…
Cancel
Save