二级库出库逻辑调整

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

@ -140,6 +140,7 @@
style="width: 100%" style="width: 100%"
border border
ref="groupTable" ref="groupTable"
@expand-change="handleExpandChange"
> >
<!-- 展开行详情 --> <!-- 展开行详情 -->
<el-table-column type="expand"> <el-table-column type="expand">
@ -153,12 +154,26 @@
(val) => handleSelectionChange(val, props.row) (val) => handleSelectionChange(val, props.row)
" "
border border
:row-key="getRowKeyId"
ref="nestedTable"
> >
<el-table-column <!-- <el-table-column
type="selection" type="selection"
width="55" width="55"
:selectable="isRowSelectable" :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 type="index" label="#" width="55" />
<el-table-column label="物料名称" prop="materialName" /> <el-table-column label="物料名称" prop="materialName" />
<el-table-column label="物料编码" prop="materialCode" /> <el-table-column label="物料编码" prop="materialCode" />
@ -513,6 +528,56 @@ export default {
this.getOutGroupName(); this.getOutGroupName();
}, },
methods: { 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) { isRowSelectable(row) {
// materialName materialId // materialName materialId
return ( return (
@ -560,16 +625,25 @@ export default {
getGroupMaterial(this.sizeForm.ldTwoOutStorage).then((res) => { getGroupMaterial(this.sizeForm.ldTwoOutStorage).then((res) => {
this.groupTableData = res.data.result; this.groupTableData = res.data.result;
this.groupTableData.forEach((group) => { this.groupTableData.forEach((group) => {
// if (
if (group.twoInventoryVOList.length > 0) { group.twoInventoryVOList &&
group.twoInventoryVOList.forEach((element) => { group.twoInventoryVOList.length > 0
element.applyNum = group.applyNum; ) {
element.goodsCode = group.applyNum; group.twoInventoryVOList.forEach((item) => {
if (element.type === "NY") { item.applyNum = group.applyNum;
element.num = 1; item.goodsCode = group.applyNum;
if (item.type === "NY") {
item.num = 1;
} else { } 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) { if (selectedItems.length === 0) {
this.$message.error(`分组【${group.materialName || group.materialCode}】未选择任何物资`); this.$message.error(
`分组【${
group.materialName || group.materialCode
}未选择任何物资`
);
hasError = true; hasError = true;
break; break;
} }
@ -805,7 +883,9 @@ export default {
if (totalSelectedNum !== applyNum) { if (totalSelectedNum !== applyNum) {
this.$message.error( this.$message.error(
`分组【${group.materialName || group.materialCode}】:已选物资出库数量总和(${totalSelectedNum})与申请数量(${applyNum})不一致` `分组【${
group.materialName || group.materialCode
}已选物资出库数量总和${totalSelectedNum}与申请数量${applyNum}不一致`
); );
hasError = true; hasError = true;
break; break;
@ -828,8 +908,6 @@ export default {
} }
} }
submit(this.sizeForm).then((res) => { submit(this.sizeForm).then((res) => {
this.$message({ this.$message({
type: "success", type: "success",

Loading…
Cancel
Save