出库问题修改

master
zhangdi 3 days ago
parent 45beafffa0
commit a64e391e8b
  1. 143
      src/views/firstOrder/components/outDialog.vue

@ -423,36 +423,41 @@ export default {
} }
}, },
getStatistics() { getStatistics() {
let arr = JSON.parse(JSON.stringify(this.sizeForm.inTableData)); let arr = this.sizeForm.inTableData;
arr.forEach((row) => { arr.forEach((row) => {
row.id = row.oneFormId; row.id = row.oneFormId;
}); });
getStatistics(arr).then((res) => { getStatistics(arr).then((res) => {
this.statisticsList = res.data.result; // this.statisticsList = res.data.result;
this.statisticsList = this.statisticsList.map((stat) => { let data_ = res.data.result
// this.statisticsList =
console.log('批量易耗品', this.sizeForm.inTableData, data_)
data_.forEach((stat,index) => {
const detail = this.sizeForm.inTableData.find( const detail = this.sizeForm.inTableData.find(
(item) => item.materialCode === stat.materialCode (item) => item.materialCode === stat.materialCode
); );
//
if (detail) {
// console.log(99999,index, detail, stat.materialCode)
if ( if (
(this.sizeForm.options == 1 && (this.sizeForm.options == 1 &&
this.inBatchForm.optionType == "NY") || this.inBatchForm.optionType == "NY") ||
(this.sizeForm.options == 2 && this.sizeForm.optionType == "NY") (this.sizeForm.options == 2 && this.sizeForm.optionType == "NY")
) { ) {
const detailList = this.sizeForm.inTableData.filter( const detailList = this.sizeForm.inTableData.filter(
(item) => (item) =>
item.materialCode === stat.materialCode && item.materialCode === stat.materialCode &&
item.materialName === stat.materialName item.materialName === stat.materialName
); );
console.log(8989898989, detailList)
detail.theOutboundQuantity = detailList.reduce( detail.theOutboundQuantity = detailList.reduce(
(acc, cur) => acc + cur.theOutboundQuantity, (acc, cur) => cur.theOutboundQuantity,
0 0
); );
} }
this.statisticsList.push({
return {
...stat, ...stat,
theOutboundQuantity: detail.theOutboundQuantity, // theOutboundQuantity: detail.theOutboundQuantity, //
unitPrice: detail.unitPrice, unitPrice: detail.unitPrice,
@ -461,17 +466,21 @@ export default {
departmentName: departmentName:
detail.departmentName || detail.departmentName ||
this.getDepartmentName(detail.department), this.getDepartmentName(detail.department),
}; })
}
}); });
console.log('detail', this.statisticsList)
}); });
}, },
changeDepartment() { changeDepartment() {
this.getStatistics(); this.getStatistics();
}, },
batchclose() { batchclose() {
this.batchSelectionVisible = false; this.batchSelectionVisible = false;
}, },
selectionChange(row) { selectionChange(row) {
this.batchSelectionVisible = false; this.batchSelectionVisible = false;
row.forEach((item) => { row.forEach((item) => {
item.outboundQuantity = 1; item.outboundQuantity = 1;
@ -481,8 +490,8 @@ export default {
this.sizeForm.inTableData = row; this.sizeForm.inTableData = row;
this.getStatistics(); this.getStatistics();
}, },
confirm(allSelectedList) { confirm(allSelectedList) {
this.consumableVisible = false; this.consumableVisible = false;
allSelectedList.forEach((item) => { allSelectedList.forEach((item) => {
item.outboundQuantity = 1; item.outboundQuantity = 1;
@ -492,34 +501,34 @@ export default {
this.sizeForm.inTableData = allSelectedList; this.sizeForm.inTableData = allSelectedList;
this.getStatistics(); this.getStatistics();
}, // }, //
async handleSearch() { async handleSearch() {
// //
this.currentPage = 1; this.currentPage = 1;
await this.loadGoodsList(); await this.loadGoodsList();
}, },
// //
handleSizeChange(val) { handleSizeChange(val) {
this.pageSize = val; this.pageSize = val;
this.currentPage = 1; this.currentPage = 1;
this.loadGoodsList(); this.loadGoodsList();
}, },
// //
handleCurrentChange(val) { handleCurrentChange(val) {
this.currentPage = val; this.currentPage = val;
this.loadGoodsList(); this.loadGoodsList();
}, },
depchange(value) { depchange(value) {
this.departmentList = this.departmentList; this.departmentList = this.departmentList;
}, },
// //
handleBatchClose() { handleBatchClose() {
this.inBatchDialogVisible = false; this.inBatchDialogVisible = false;
}, },
// //
inTableAdd() { inTableAdd() {
const requiredFields = [ const requiredFields = [
{ value: this.sizeForm.reason, message: "请填写事由" }, { value: this.sizeForm.reason, message: "请填写事由" },
{ value: this.sizeForm.materialType, message: "请选择物资类型" }, { value: this.sizeForm.materialType, message: "请选择物资类型" },
@ -536,12 +545,12 @@ export default {
} }
} }
this.sizeForm.inTableData.push({}); this.sizeForm.inTableData.push({});
}, },
addInit() { addInit() {
this.sizeForm.outDate = new Date(); // this.sizeForm.outDate = new Date(); //
}, },
// //
syncInboundQuantity(row) { syncInboundQuantity(row) {
row.theOutboundQuantity = Number(row.theOutboundQuantity); row.theOutboundQuantity = Number(row.theOutboundQuantity);
if (this.sizeForm.options === 1) { if (this.sizeForm.options === 1) {
const maxAllowQuantity = const maxAllowQuantity =
@ -556,16 +565,16 @@ export default {
row.outboundQuantity = 1; row.outboundQuantity = 1;
} }
this.getStatistics(); this.getStatistics();
}, },
// //
handleCloseDetail() { handleCloseDetail() {
this.outDialogVisible = false; this.outDialogVisible = false;
this.$emit("handleCloseDetail"); this.$emit("handleCloseDetail");
}, },
closeDialog() { closeDialog() {
this.consumableVisible = false; this.consumableVisible = false;
}, },
// //
async getQuarterList() { async getQuarterList() {
try { try {
@ -583,7 +592,7 @@ export default {
} catch (error) { } catch (error) {
this.$message.error("获取需求单列表失败"); this.$message.error("获取需求单列表失败");
} }
}, },
// //
async onQuarterSelectChange(ids) { async onQuarterSelectChange(ids) {
if (!ids) return; if (!ids) return;
@ -607,7 +616,7 @@ export default {
} else { } else {
this.departmentList = []; this.departmentList = [];
} }
}, },
async batchSubmit() { async batchSubmit() {
if (!this.inBatchForm.batchType) { if (!this.inBatchForm.batchType) {
@ -638,7 +647,7 @@ export default {
} }
if (res.data && res.data.result) { if (res.data && res.data.result) {
this.sizeForm.inTableData = res.data.result; // this.sizeForm.inTableData = res.data.result;
const selectedDept = this.departmentList.find( const selectedDept = this.departmentList.find(
(dept) => dept.departmentId === this.inBatchForm.department (dept) => dept.departmentId === this.inBatchForm.department
); );
@ -648,6 +657,7 @@ export default {
// 0 // 0
const appQty = Number(item.applicationQuantity || 0); const appQty = Number(item.applicationQuantity || 0);
const outQty = Number(item.outboundQuantity || 0); const outQty = Number(item.outboundQuantity || 0);
const defaultQty = appQty - outQty; const defaultQty = appQty - outQty;
if (this.inBatchForm.optionType === "YH") { if (this.inBatchForm.optionType === "YH") {
item.department = selectedDept.departmentId item.department = selectedDept.departmentId
@ -661,8 +671,9 @@ export default {
theOutboundQuantity: defaultQty > 0 ? defaultQty : 0, theOutboundQuantity: defaultQty > 0 ? defaultQty : 0,
}; };
}); });
this.sizeForm.inTableData = processedData;
this.sizeForm.inTableData = processedData;
//
// //
this.inBatchDialogVisible = false; this.inBatchDialogVisible = false;
@ -697,14 +708,14 @@ export default {
}数据失败${error.message}` }数据失败${error.message}`
); );
} }
}, },
// //
async getDetailedItems() { async getDetailedItems() {
this.loading = true; this.loading = true;
try { try {
// const res = await ; // const res = await ;
// this.list = res.data.result; // this.list = res.data.result;
getDetailedItems().then(res=>{ getDetailedItems().then(res => {
this.list = res.data.result; this.list = res.data.result;
}) })
} catch (error) { } catch (error) {
@ -712,13 +723,13 @@ export default {
} finally { } finally {
this.loading = false; this.loading = false;
} }
}, },
getDepartmentName(departmentId) { getDepartmentName(departmentId) {
const department = this.list.find( const department = this.list.find(
(item) => item.departmentId === departmentId (item) => item.departmentId === departmentId
); );
return department ? department.department : ""; return department ? department.department : "";
}, },
// //
async getMaterialList() { async getMaterialList() {
this.loading = true; this.loading = true;
@ -741,9 +752,9 @@ export default {
} finally { } finally {
this.loading = false; this.loading = false;
} }
}, },
// //
handleMaterialChange(row, index) { handleMaterialChange(row, index) {
let select = this.materials.filter( let select = this.materials.filter(
(item) => item.materialId === row.materialId (item) => item.materialId === row.materialId
)[0]; )[0];
@ -756,7 +767,7 @@ export default {
this.sizeForm.inTableData[index].unit = select.unit; this.sizeForm.inTableData[index].unit = select.unit;
this.sizeForm.inTableData[index].num = select.num; this.sizeForm.inTableData[index].num = select.num;
this.getStatistics(); this.getStatistics();
}, },
// //
async submit(index) { async submit(index) {
if (!this.sizeForm.reason) { if (!this.sizeForm.reason) {
@ -852,7 +863,7 @@ export default {
this.saveLoading = false; this.saveLoading = false;
this.$message.error(error.message || "服务器错误"); this.$message.error(error.message || "服务器错误");
} }
}, },
// //
async inInit() { async inInit() {
@ -879,10 +890,10 @@ export default {
this.getStatistics(); this.getStatistics();
}); });
} }
}, },
// //
radioChange() { radioChange() {
this.sizeForm.inTableData = []; this.sizeForm.inTableData = [];
this.statisticsList = []; this.statisticsList = [];
this.sizeForm.optionType = ""; this.sizeForm.optionType = "";
@ -902,15 +913,15 @@ export default {
this.inBatchForm.optionType = ""; this.inBatchForm.optionType = "";
this.inBatchForm.optionType = ""; this.inBatchForm.optionType = "";
} }
}, },
// //
handleDelete(index, row) { handleDelete(index, row) {
this.sizeForm.inTableData.splice(index, 1); this.sizeForm.inTableData.splice(index, 1);
this.$message.success("已成功删除该条记录"); this.$message.success("已成功删除该条记录");
this.getStatistics(); this.getStatistics();
},
}, },
}, watch: {
watch: {
// //
// "inBatchForm.batchType": function (newVal) { // "inBatchForm.batchType": function (newVal) {
// (this.inBatchForm.department = ""), (this.inBatchForm.optionType = 1); // (this.inBatchForm.department = ""), (this.inBatchForm.optionType = 1);
@ -926,7 +937,7 @@ export default {
// this.getMaterialList(); // this.getMaterialList();
// } // }
// }, // },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Loading…
Cancel
Save