二级库出库逻辑调整

master
zhangdi 1 month ago
parent b7797adcff
commit e96de37b21
  1. 104
      src/views/secondOrder/components/outDialog.vue

@ -140,6 +140,7 @@
style="width: 100%"
border
ref="groupTable"
@expand-change="handleExpandChange"
>
<!-- 展开行详情 -->
<el-table-column type="expand">
@ -153,12 +154,26 @@
(val) => handleSelectionChange(val, props.row)
"
border
:row-key="getRowKeyId"
ref="nestedTable"
>
<el-table-column
<!-- <el-table-column
type="selection"
width="55"
:selectable="isRowSelectable"
/> -->
<el-table-column label="选择" width="55">
<template slot-scope="scope">
<el-checkbox
v-model="scope.row._selected"
:disabled="!isRowSelectable(scope.row)"
@change="
(checked) =>
handleRowSelect(checked, scope.row, props.row)
"
/>
</template>
</el-table-column>
<el-table-column type="index" label="#" width="55" />
<el-table-column label="物料名称" prop="materialName" />
<el-table-column label="物料编码" prop="materialCode" />
@ -513,6 +528,56 @@ export default {
this.getOutGroupName();
},
methods: {
handleExpandChange(row, expandedRows) {
//
if (expandedRows.includes(row)) {
this.$nextTick(() => {
// ref
// ref UI selection selectedGroupMap checkbox
// el-table selection UI checked
});
}
},
handleRowSelect(checked, childRow, parentRow) {
const key =
parentRow.materialId || parentRow.materialCode || parentRow.id;
let currentSelection = this.selectedGroupMap[key] || [];
if (checked) {
//
if (
!currentSelection.some(
(item) => item.materialId === childRow.materialId
)
) {
currentSelection = [...currentSelection, { ...childRow }];
}
} else {
//
currentSelection = currentSelection.filter(
(item) => item.materialId !== childRow.materialId
);
}
this.$set(this.selectedGroupMap, key, currentSelection);
//
let allDetails = [];
Object.values(this.selectedGroupMap).forEach((selectedList) => {
allDetails = allDetails.concat(
selectedList.map((item) => ({
...item,
num: item.num || (item.type === "NY" ? 1 : 0),
}))
);
});
this.sizeForm.ldTwoOutStorageDetailList = allDetails;
this.getStatistics();
},
// el-table row-key key
getRowKeyId(row) {
return row.materialId || row.id || row.materialCode;
},
isRowSelectable(row) {
// materialName materialId
return (
@ -560,16 +625,25 @@ export default {
getGroupMaterial(this.sizeForm.ldTwoOutStorage).then((res) => {
this.groupTableData = res.data.result;
this.groupTableData.forEach((group) => {
//
if (group.twoInventoryVOList.length > 0) {
group.twoInventoryVOList.forEach((element) => {
element.applyNum = group.applyNum;
element.goodsCode = group.applyNum;
if (element.type === "NY") {
element.num = 1;
if (
group.twoInventoryVOList &&
group.twoInventoryVOList.length > 0
) {
group.twoInventoryVOList.forEach((item) => {
item.applyNum = group.applyNum;
item.goodsCode = group.applyNum;
if (item.type === "NY") {
item.num = 1;
} else {
element.num = group.applyNum;
item.num = group.applyNum;
}
//
const key = group.materialId || group.materialCode || group.id;
const previouslySelected = this.selectedGroupMap[key] || [];
const isSelected = previouslySelected.some(
(sel) => sel.materialId === item.materialId
);
this.$set(item, "_selected", isSelected);
});
}
});
@ -791,7 +865,11 @@ export default {
//
if (selectedItems.length === 0) {
this.$message.error(`分组【${group.materialName || group.materialCode}】未选择任何物资`);
this.$message.error(
`分组【${
group.materialName || group.materialCode
}未选择任何物资`
);
hasError = true;
break;
}
@ -805,7 +883,9 @@ export default {
if (totalSelectedNum !== applyNum) {
this.$message.error(
`分组【${group.materialName || group.materialCode}】:已选物资出库数量总和(${totalSelectedNum})与申请数量(${applyNum})不一致`
`分组【${
group.materialName || group.materialCode
}已选物资出库数量总和${totalSelectedNum}与申请数量${applyNum}不一致`
);
hasError = true;
break;
@ -828,8 +908,6 @@ export default {
}
}
submit(this.sizeForm).then((res) => {
this.$message({
type: "success",

Loading…
Cancel
Save