|
|
@@ -18,7 +18,7 @@
|
|
|
<el-radio-group v-model="dimension" @change="dimensionChange" size="small">
|
|
|
<el-radio-button :label="1">批次维度</el-radio-button>
|
|
|
<!-- <el-radio-button :label="2">物品维度</el-radio-button> -->
|
|
|
- <el-radio-button :label="3">包装维度</el-radio-button>
|
|
|
+ <el-radio-button :label="2">包装维度</el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
<el-table
|
|
|
@@ -39,7 +39,7 @@
|
|
|
/>
|
|
|
<el-table-column type="index" label="序号" width="50" align="center" />
|
|
|
<el-table-column prop="categoryCode" label="物品编码" min-width="120" align="center" show-overflow-tooltip />
|
|
|
- <el-table-column v-if="dimension === 3" prop="packageNo" label="包装编码" min-width="140" align="center" show-overflow-tooltip />
|
|
|
+ <el-table-column v-if="dimension === 2" prop="packageNo" label="包装编码" min-width="140" align="center" show-overflow-tooltip />
|
|
|
<el-table-column prop="categoryName" label="名称" min-width="120" align="center" show-overflow-tooltip />
|
|
|
<el-table-column prop="batchNo" label="批次号" min-width="140" align="center" show-overflow-tooltip />
|
|
|
<el-table-column prop="measureQuantity" label="数量" width="80" align="center" />
|
|
|
@@ -64,7 +64,7 @@
|
|
|
<el-table-column prop="expiryDate" label="失效日期" width="110" align="center" />
|
|
|
</el-table>
|
|
|
<el-pagination
|
|
|
- v-if="dimension === 3"
|
|
|
+ v-if="dimension === 2"
|
|
|
style="margin-top: 8px; text-align: right;"
|
|
|
:current-page="packingPages.pageNum"
|
|
|
:page-size="packingPages.size"
|
|
|
@@ -95,7 +95,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="选择库区">
|
|
|
- <el-select filterable v-model="area" @change="getshelvesList">
|
|
|
+ <el-select filterable :disabled="isDetail" v-model="area" @change="getshelvesList">
|
|
|
<el-option
|
|
|
v-for="(item, index) in areaList"
|
|
|
:key="index"
|
|
|
@@ -108,7 +108,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="选择货架">
|
|
|
- <el-select filterable v-model="shelves" @change="changeshelvesList">
|
|
|
+ <el-select filterable :disabled="isDetail" clearable v-model="shelves" @change="changeshelvesList">
|
|
|
<el-option
|
|
|
v-for="(item, index) in shelvesList"
|
|
|
:key="index"
|
|
|
@@ -147,7 +147,7 @@
|
|
|
|
|
|
<!-- 添加行 + 上架列表 -->
|
|
|
<div style="margin-top: 12px;">
|
|
|
- <el-button type="primary" size="small" @click="addRow">添加行</el-button>
|
|
|
+ <el-button v-if="!isDetail && dimension != 2" type="primary" size="small" @click="addRow">添加行</el-button>
|
|
|
</div>
|
|
|
<el-table :data="shelvingList" max-height="400" style="width: 100%; margin-top: 8px;" border>
|
|
|
<el-table-column label="序号" type="index" width="50" align="center" />
|
|
|
@@ -159,6 +159,7 @@
|
|
|
placeholder="选择货位"
|
|
|
size="small"
|
|
|
style="width: 100%;"
|
|
|
+ :disabled="isDetail"
|
|
|
@change="(val) => onLocationChange(val, scope.row)"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -171,7 +172,7 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column v-if="dimension === 3" prop="packageNo" label="包装编码" width="140" align="center" />
|
|
|
+ <el-table-column v-if="dimension === 2" prop="packageNo" label="包装编码" width="180" align="center" />
|
|
|
<el-table-column v-if="dimension == 1" label="物品批次" min-width="180" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
|
@@ -180,7 +181,7 @@
|
|
|
placeholder="选择物品批次"
|
|
|
size="small"
|
|
|
style="width: 100%;"
|
|
|
- :disabled="dimension === 3"
|
|
|
+ :disabled="isDetail || dimension === 2"
|
|
|
@change="(val) => onItemChange(val, scope.row)"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -200,12 +201,12 @@
|
|
|
:max="scope.row.maxQuantity"
|
|
|
size="small"
|
|
|
controls-position="right"
|
|
|
- :disabled="dimension === 3"
|
|
|
+ :disabled="isDetail || dimension === 2"
|
|
|
style="width: 100%;"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column width="80" label="操作" fixed="right" align="center">
|
|
|
+ <el-table-column v-if="!isDetail" width="80" label="操作" fixed="right" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="text" @click="delItem(scope.$index)" size="small">删除</el-button>
|
|
|
</template>
|
|
|
@@ -215,7 +216,7 @@
|
|
|
</el-row>
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
- <el-button @click="handleSelect" type="primary" :loading="confirmLoading">确认</el-button>
|
|
|
+ <el-button v-if="!isDetail" @click="handleSelect" type="primary" :loading="confirmLoading">确认</el-button>
|
|
|
<el-button @click="cancel">关闭</el-button>
|
|
|
</div>
|
|
|
</ele-modal>
|
|
|
@@ -240,7 +241,7 @@
|
|
|
locationStatusList,
|
|
|
visible: false,
|
|
|
rowData: null,
|
|
|
- dimension: 1, // 1-批次维度 2-物品维度 3-包装维度
|
|
|
+ dimension: 1, // 1-批次维度 2-包装维度
|
|
|
type: '', // 'package' | 'product' 区分当前操作的是包装还是产品
|
|
|
// 物品表格
|
|
|
tableLoading: false,
|
|
|
@@ -248,7 +249,7 @@
|
|
|
allTableData: [],
|
|
|
selection: [],
|
|
|
allSelectedItems: [], // 包装维度跨页面保持选中数据
|
|
|
- _packingRestoring: false, // 包装维度切换页面恢复选中中,跳过中间态
|
|
|
+ _packingRestoring: 0, // 包装维度切换页面恢复选中中(计数器,支持嵌套),>0 时跳过 handleSelectionChange
|
|
|
_packingWarehouseInited: false, // 包装维度仓库是否已初始化(仅首次加载时初始化)
|
|
|
shelvedItemKeys: [],
|
|
|
// 包装维度分页
|
|
|
@@ -270,14 +271,20 @@
|
|
|
locationList: [],
|
|
|
locationType: 'shelf', // 'shelf' | 'allocation' 区分当前显示的是货架还是货位
|
|
|
selectedLocations: [],
|
|
|
+ storageRecords: [], // 已上架的库存记录(打开弹窗时回显)
|
|
|
|
|
|
// 上架清单
|
|
|
shelvingList: [],
|
|
|
- confirmLoading: false
|
|
|
+ confirmLoading: false,
|
|
|
+ mode: 'edit',
|
|
|
+ // 'edit' | 'detail' 区分当前操作的是编辑还是详情
|
|
|
};
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
+ isDetail() {
|
|
|
+ return this.mode === 'detail';
|
|
|
+ },
|
|
|
locationOptions() {
|
|
|
const seen = new Set();
|
|
|
return this.selectedLocations
|
|
|
@@ -320,10 +327,11 @@
|
|
|
|
|
|
methods: {
|
|
|
// ==================== 打开/关闭 ====================
|
|
|
- async open(row, type) {
|
|
|
- console.log('open', row, type);
|
|
|
+ async open(row, type, mode) {
|
|
|
+ console.log('open', row, type, mode);
|
|
|
+ this.mode = mode;
|
|
|
this.rowData = row;
|
|
|
- this.dimension = type === 'package' ? 3 : 1;
|
|
|
+ this.dimension = type === 'package' ? 2 : 1;
|
|
|
this.type = type;
|
|
|
this.selection = [];
|
|
|
this.shelvingList = [];
|
|
|
@@ -337,16 +345,21 @@
|
|
|
this.shelvesList = [];
|
|
|
this.shelvedItemKeys = [];
|
|
|
this.allSelectedItems = [];
|
|
|
- this._packingRestoring = false;
|
|
|
- this._packingWarehouseInited = false;
|
|
|
+ this._packingRestoring = 0;
|
|
|
this._packingWarehouseInited = false;
|
|
|
+ this.storageRecords = [];
|
|
|
this.packingPages = { pageNum: 1, size: 20 };
|
|
|
this.packingTotal = 0;
|
|
|
+ // 先请求库存记录(可能已上架过),再打开弹窗
|
|
|
+ await this.getDetail();
|
|
|
this.visible = true;
|
|
|
await this._getWarehouseList();
|
|
|
await this._loadTableData();
|
|
|
-
|
|
|
-
|
|
|
+ // 如果有已上架的库存记录,回显到页面
|
|
|
+ if (this.storageRecords.length) {
|
|
|
+ await this._applyStorageRecords();
|
|
|
+ }
|
|
|
+ // await this._loadTableData();
|
|
|
},
|
|
|
|
|
|
cancel() {
|
|
|
@@ -359,21 +372,148 @@
|
|
|
this.allTableData = [];
|
|
|
this.selection = [];
|
|
|
this.allSelectedItems = [];
|
|
|
- this._packingRestoring = false;
|
|
|
+ this._packingRestoring = 0;
|
|
|
this._packingWarehouseInited = false;
|
|
|
+ this.storageRecords = [];
|
|
|
this.shelvingList = [];
|
|
|
this.selectedLocations = [];
|
|
|
this.locationType = 'shelf';
|
|
|
this.visible = false;
|
|
|
},
|
|
|
|
|
|
+ async getDetail() {
|
|
|
+ try {
|
|
|
+ const data = await storageApi.getStorageRecordPage({
|
|
|
+ pageNum: 1,
|
|
|
+ size: -1,
|
|
|
+ outInId: this.rowData.outInId || this.rowData.id
|
|
|
+ });
|
|
|
+ if (data?.list?.length) {
|
|
|
+ this.dimension = +data?.list[0].levelType;
|
|
|
+ this.storageRecords = data.list;
|
|
|
+ } else {
|
|
|
+ this.storageRecords = [];
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('获取库存记录失败:', e);
|
|
|
+ this.storageRecords = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // ==================== 库存记录回显 ====================
|
|
|
+ async _applyStorageRecords() {
|
|
|
+ const records = this.storageRecords;
|
|
|
+ const first = records[0];
|
|
|
+
|
|
|
+ console.log('first~~~', first);
|
|
|
+
|
|
|
+ // 1. 根据库存记录设置仓库、库区、货架(只到货架层级,不展开货位)
|
|
|
+ if (first.warehouseId && first.warehouseId !== this.warehouse) {
|
|
|
+ const w = this.warehouseList.find((item) => item.id == first.warehouseId);
|
|
|
+ if (w) {
|
|
|
+ this.warehouse = first.warehouseId;
|
|
|
+ this.formData.warehouse = w;
|
|
|
+ await this.changeWarehouse(w);
|
|
|
+ this._packingWarehouseInited = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (first.areaId) {
|
|
|
+ this.area = first.areaId;
|
|
|
+ this.formData.area = this.areaList.find((a) => a.id == first.areaId) || {};
|
|
|
+ await this.getshelvesList(first.areaId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 不预选货架,只展库区下所有货架
|
|
|
+ this.locationType = 'shelf';
|
|
|
+
|
|
|
+ // 2. 从 shelvesList 中匹配已选的货架(不匹配货位)
|
|
|
+ const locs = [];
|
|
|
+ records.forEach((rec) => {
|
|
|
+ if (rec.goodsShelfId) {
|
|
|
+ const shelf = this.shelvesList.find((s) => s.id == rec.goodsShelfId);
|
|
|
+ if (shelf && !locs.find((l) => l.id === shelf.id)) {
|
|
|
+ locs.push({
|
|
|
+ id: shelf.id,
|
|
|
+ goodsAllocationCode: shelf.goodsshelvesCode,
|
|
|
+ warehouseId: rec.warehouseId,
|
|
|
+ warehouseName: rec.warehouseName,
|
|
|
+ areaId: rec.areaId,
|
|
|
+ areaName: rec.areaName,
|
|
|
+ shelfId: shelf.id,
|
|
|
+ shelfCode: shelf.goodsshelvesCode
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.selectedLocations = locs;
|
|
|
+
|
|
|
+ // 3. 匹配左侧物品清单(优先 outInDetailId,其次 batchNo,再次 packageNo)
|
|
|
+ const matchedItems = [];
|
|
|
+ const itemSource = this.dimension === 1 ? this.allTableData : this.tableData;
|
|
|
+ records.forEach((rec) => {
|
|
|
+ let item =
|
|
|
+ itemSource.find((t) => t.id === rec.outInDetailId) ||
|
|
|
+ itemSource.find((t) => t.batchNo === rec.batchNo) ||
|
|
|
+ (rec.packageNo
|
|
|
+ ? itemSource.find((t) => t.packageNo === rec.packageNo)
|
|
|
+ : null);
|
|
|
+ if (item && !item._shelved) {
|
|
|
+ const key = this._getRowKey(item);
|
|
|
+ if (!matchedItems.find((m) => this._getRowKey(m) === key)) {
|
|
|
+ matchedItems.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.allSelectedItems = matchedItems;
|
|
|
+ this.selection = matchedItems;
|
|
|
+
|
|
|
+ // 4. 构建右侧上架清单(cargoSpaceId 使用货架 id)
|
|
|
+ const list = records.map((rec) => {
|
|
|
+ let item =
|
|
|
+ itemSource.find((t) => t.id === rec.outInDetailId) ||
|
|
|
+ itemSource.find((t) => t.batchNo === rec.batchNo) ||
|
|
|
+ (rec.packageNo
|
|
|
+ ? itemSource.find((t) => t.packageNo === rec.packageNo)
|
|
|
+ : null);
|
|
|
+
|
|
|
+ const shelfLoc = locs.find((l) => l.shelfId === rec.goodsShelfId);
|
|
|
+ return {
|
|
|
+ id: rec.id,
|
|
|
+ packageNo: rec.packageNo || '',
|
|
|
+ cargoSpaceId: rec.goodsShelfId || '',
|
|
|
+ cargoSpaceCode: (shelfLoc && shelfLoc.shelfCode) || rec.goodsShelfName || '',
|
|
|
+ itemKey: item ? this._getRowKey(item) : (rec.packageNo || rec.outInDetailId || ''),
|
|
|
+ quantity: parseFloat(rec.measureQuantity) || 0,
|
|
|
+ maxQuantity: item ? (parseFloat(item.measureQuantity) || 0) : 0
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ // 5. 恢复左侧表格的勾选状态,最后设置 shelvingList(确保不被中间态覆盖)
|
|
|
+ this._packingRestoring++;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.tableRef) {
|
|
|
+ const selectedKeys = new Set(matchedItems.map((it) => this._getRowKey(it)));
|
|
|
+ this.tableData.forEach((row) => {
|
|
|
+ if (selectedKeys.has(this._getRowKey(row))) {
|
|
|
+ this.$refs.tableRef.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this._packingRestoring--;
|
|
|
+ // 在所有 $nextTick 完成后设置 shelvesList,确保不被覆盖
|
|
|
+ this.shelvingList = list;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// ==================== 维度切换 ====================
|
|
|
dimensionChange() {
|
|
|
this.selection = [];
|
|
|
this.allSelectedItems = [];
|
|
|
- this._packingRestoring = false;
|
|
|
- this._packingWarehouseInited = false;
|
|
|
+ this._packingRestoring = 0;
|
|
|
this._packingWarehouseInited = false;
|
|
|
+ this.storageRecords = [];
|
|
|
if (this.$refs.tableRef) {
|
|
|
this.$refs.tableRef.clearSelection();
|
|
|
}
|
|
|
@@ -403,7 +543,7 @@
|
|
|
if (!this.rowData?.id) return;
|
|
|
this.tableLoading = true;
|
|
|
try {
|
|
|
- if (this.dimension === 3) {
|
|
|
+ if (this.dimension === 2) {
|
|
|
// 包装维度:调用 getOutInRecordsPage(分页)
|
|
|
const data = await storageApi.getOutInRecordsPage({
|
|
|
pageNum: this.packingPages.pageNum,
|
|
|
@@ -425,7 +565,7 @@
|
|
|
this.allTableData = items;
|
|
|
this.shelvedItemKeys = this._extractShelvedKeys(items);
|
|
|
// 标记正在恢复,防止 tableData 变化触发的 selection-change 清空 allSelectedItems
|
|
|
- this._packingRestoring = true;
|
|
|
+ this._packingRestoring++;
|
|
|
this.tableData = items;
|
|
|
this.selection = this.allSelectedItems;
|
|
|
this.$nextTick(() => {
|
|
|
@@ -437,7 +577,7 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- this._packingRestoring = false;
|
|
|
+ this._packingRestoring--;
|
|
|
// 切页不重建右侧清单,保留用户已有的编辑数据
|
|
|
});
|
|
|
}
|
|
|
@@ -555,12 +695,13 @@
|
|
|
},
|
|
|
|
|
|
checkSelectable(row) {
|
|
|
+ if(this.isDetail) return false;
|
|
|
return !this.shelvedItemKeys.includes(this._getRowKey(row));
|
|
|
},
|
|
|
|
|
|
handleSelectionChange(selection) {
|
|
|
- if (this.dimension === 3) {
|
|
|
- if (this._packingRestoring) {
|
|
|
+ if (this.dimension === 2) {
|
|
|
+ if (this._packingRestoring > 0) {
|
|
|
// 正在恢复跨页面选中状态,跳过中间态,避免 allSelectedItems 被错误清空
|
|
|
this.selection = selection;
|
|
|
return;
|
|
|
@@ -621,9 +762,10 @@
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
+ id: old?.id || item.id || '',
|
|
|
packageNo: item.packageNo || '',
|
|
|
- cargoSpaceId: old?.cargoSpaceId || cargoId,
|
|
|
- cargoSpaceCode: old?.cargoSpaceCode || cargoCode,
|
|
|
+ cargoSpaceId: cargoId || old?.cargoSpaceId || '',
|
|
|
+ cargoSpaceCode: cargoCode || old?.cargoSpaceCode || '',
|
|
|
itemKey: key,
|
|
|
quantity: old?.quantity != null ? old.quantity : (parseFloat(item.measureQuantity) || 0),
|
|
|
maxQuantity: parseFloat(item.measureQuantity) || 0
|
|
|
@@ -648,7 +790,7 @@
|
|
|
this.locationType = 'shelf';
|
|
|
this.area = '';
|
|
|
this.selectedLocations = [];
|
|
|
- this.shelvingList = [];
|
|
|
+ this._applyLocationsToRows();
|
|
|
},
|
|
|
|
|
|
async changeWarehouse(val) {
|
|
|
@@ -659,17 +801,16 @@
|
|
|
this.areaList = res || [];
|
|
|
this.locationType = 'shelf';
|
|
|
this.selectedLocations = [];
|
|
|
- this.shelvingList = [];
|
|
|
+ this._applyLocationsToRows();
|
|
|
},
|
|
|
|
|
|
async getshelvesList(e) {
|
|
|
this.cur = {};
|
|
|
this.shelves = '';
|
|
|
this.selectedLocations = [];
|
|
|
- this.shelvingList = [];
|
|
|
+ this._applyLocationsToRows();
|
|
|
const rep = await warehouseDefinition.getListByAreaId(e);
|
|
|
this.shelvesList = rep || [];
|
|
|
- // 直接将货架信息赋值给 locationList,在网格区域展示
|
|
|
this.locationList = rep || [];
|
|
|
this.locationType = 'shelf';
|
|
|
},
|
|
|
@@ -677,7 +818,14 @@
|
|
|
async changeshelvesList(id) {
|
|
|
this.cur = {};
|
|
|
this.selectedLocations = [];
|
|
|
- this.shelvingList = [];
|
|
|
+ this._applyLocationsToRows();
|
|
|
+ if (!id) {
|
|
|
+ // 清空货架选择,回到库区货架展示
|
|
|
+ this.formData.shelves = {};
|
|
|
+ this.locationList = this.shelvesList || [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!this.shelvesList.length) {
|
|
|
this.locationList = [];
|
|
|
this.locationType = 'allocation';
|
|
|
@@ -689,6 +837,7 @@
|
|
|
this.locationType = 'allocation';
|
|
|
return;
|
|
|
}
|
|
|
+ this.formData.shelves = matched;
|
|
|
const res = await warehouseDefinition.getListByGoodId(matched.id);
|
|
|
this.locationList = res || [];
|
|
|
this.locationType = 'allocation';
|
|
|
@@ -721,6 +870,7 @@
|
|
|
|
|
|
// ==================== 货架/货位点击(多选) ====================
|
|
|
handlCur(row) {
|
|
|
+ if (this.isDetail) return;
|
|
|
const { area, warehouse } = this.formData;
|
|
|
const isAllocation = this.locationType === 'allocation';
|
|
|
|
|
|
@@ -757,7 +907,35 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- this.buildDefaultShelvingList();
|
|
|
+ // 只更新已有行的货位信息,不改变行数和物品
|
|
|
+ this._applyLocationsToRows();
|
|
|
+ },
|
|
|
+
|
|
|
+ _applyLocationsToRows() {
|
|
|
+ const locs = this.selectedLocations;
|
|
|
+ if (this.shelvingList.length === 0) return;
|
|
|
+ // 所有货位取消选中 → 清空所有行的货位
|
|
|
+ if (locs.length === 0) {
|
|
|
+ this.shelvingList.forEach((row) => {
|
|
|
+ this.$set(row, 'cargoSpaceId', '');
|
|
|
+ this.$set(row, 'cargoSpaceCode', '');
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 单个货位 → 所有行共用
|
|
|
+ if (locs.length === 1) {
|
|
|
+ this.shelvingList.forEach((row) => {
|
|
|
+ this.$set(row, 'cargoSpaceId', locs[0].id);
|
|
|
+ this.$set(row, 'cargoSpaceCode', locs[0].goodsAllocationCode);
|
|
|
+ });
|
|
|
+ } else if (locs.length === this.shelvingList.length) {
|
|
|
+ // 货位数 = 行数 → 一一对应
|
|
|
+ this.shelvingList.forEach((row, idx) => {
|
|
|
+ this.$set(row, 'cargoSpaceId', locs[idx].id);
|
|
|
+ this.$set(row, 'cargoSpaceCode', locs[idx].goodsAllocationCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 其他情况不自动匹配,保持现有货位
|
|
|
},
|
|
|
|
|
|
isLocationSelected(id) {
|
|
|
@@ -775,23 +953,30 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- delItem(index) {
|
|
|
+ async delItem(index) {
|
|
|
const row = this.shelvingList[index];
|
|
|
const removedKey = row?.itemKey;
|
|
|
+ if (row.id) {
|
|
|
+ const res = await storageApi.deleteStorageRecord([row.id]);
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
this.shelvingList.splice(index, 1);
|
|
|
if (removedKey) {
|
|
|
- // 从跨页选中数据中移除
|
|
|
- this.allSelectedItems = this.allSelectedItems.filter(
|
|
|
- (it) => this._getRowKey(it) !== removedKey
|
|
|
- );
|
|
|
- this.selection = this.allSelectedItems;
|
|
|
- // 如果该行在当前页表格中,取消勾选
|
|
|
- if (this.$refs.tableRef) {
|
|
|
- const matchedRow = this.tableData.find(
|
|
|
- (r) => this._getRowKey(r) === removedKey
|
|
|
+ // 检查上架列表中是否还有其他行引用了相同的 itemKey
|
|
|
+ const stillExists = this.shelvingList.some((r) => r.itemKey === removedKey);
|
|
|
+ if (!stillExists) {
|
|
|
+ // 没有匹配数据了,才从选中中移除并取消勾选
|
|
|
+ this.allSelectedItems = this.allSelectedItems.filter(
|
|
|
+ (it) => this._getRowKey(it) !== removedKey
|
|
|
);
|
|
|
- if (matchedRow) {
|
|
|
- this.$refs.tableRef.toggleRowSelection(matchedRow, false);
|
|
|
+ this.selection = this.allSelectedItems;
|
|
|
+ if (this.$refs.tableRef) {
|
|
|
+ const matchedRow = this.tableData.find(
|
|
|
+ (r) => this._getRowKey(r) === removedKey
|
|
|
+ );
|
|
|
+ if (matchedRow) {
|
|
|
+ this.$refs.tableRef.toggleRowSelection(matchedRow, false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -805,7 +990,7 @@
|
|
|
},
|
|
|
|
|
|
onItemChange(val, row) {
|
|
|
- const source = this.dimension === 3 ? this.selection : this.allTableData;
|
|
|
+ const source = this.dimension === 2 ? this.selection : this.allTableData;
|
|
|
const item = source.find((it) => this._getRowKey(it) === val);
|
|
|
if (item) {
|
|
|
row.maxQuantity = parseFloat(item.measureQuantity) || 0;
|
|
|
@@ -845,7 +1030,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 校验每个物品的总上架数量必须等于物品数量
|
|
|
+ // 校验每个物品的总上架数量不能大于物品数量
|
|
|
const itemTotalMap = {};
|
|
|
this.shelvingList.forEach((row) => {
|
|
|
if (!itemTotalMap[row.itemKey]) itemTotalMap[row.itemKey] = 0;
|
|
|
@@ -856,9 +1041,9 @@
|
|
|
const key = this._getRowKey(item);
|
|
|
const total = itemTotalMap[key] || 0;
|
|
|
const expect = parseFloat(item.measureQuantity) || 0;
|
|
|
- if (total !== expect) {
|
|
|
+ if (total > expect) {
|
|
|
this.$message.error(
|
|
|
- `物品 ${item.categoryName || ''}(${item.batchNo || ''})的上架数量 ${total} 不等于物品数量 ${expect},请确认全部上架`
|
|
|
+ `物品 ${item.categoryName || ''}(${item.batchNo || ''})的上架数量 ${total} 不能大于物品数量 ${expect}`
|
|
|
);
|
|
|
return;
|
|
|
}
|
|
|
@@ -867,26 +1052,41 @@
|
|
|
// 组装提交数据
|
|
|
this.confirmLoading = true;
|
|
|
const outInDetailList = [];
|
|
|
- const lookupSource = this.dimension === 3 ? this.selection : this.allTableData;
|
|
|
+ const lookupSource = this.dimension === 2 ? this.selection : this.allTableData;
|
|
|
+ console.log('this.shelvingList', this.shelvingList);
|
|
|
this.shelvingList.forEach((row) => {
|
|
|
+ console.log(row);
|
|
|
const matchedItem = lookupSource.find(
|
|
|
(it) => this._getRowKey(it) === row.itemKey
|
|
|
);
|
|
|
const loc = this.selectedLocations.find((l) => l.id === row.cargoSpaceId);
|
|
|
if (matchedItem && loc) {
|
|
|
outInDetailList.push({
|
|
|
- id: matchedItem.id,
|
|
|
+ levelType: this.dimension,
|
|
|
+ id: row?.id || '',
|
|
|
warehouseId: loc.warehouseId,
|
|
|
warehouseName: loc.warehouseName,
|
|
|
areaId: loc.areaId,
|
|
|
areaName: loc.areaName,
|
|
|
goodsShelfId: loc.shelfId,
|
|
|
goodsShelfName: loc.shelfCode,
|
|
|
- goodsAllocationId: row.cargoSpaceId,
|
|
|
- goodsAllocationName: row.cargoSpaceCode,
|
|
|
+ goodsAllocationId: this.locationType !== 'shelf' ? row.cargoSpaceId : '',
|
|
|
+ goodsAllocationName: this.locationType !== 'shelf' ? row.cargoSpaceCode : '',
|
|
|
measureQuantity: row.quantity,
|
|
|
categoryId: matchedItem.categoryId,
|
|
|
- batchNo: matchedItem.batchNo
|
|
|
+ batchNo: matchedItem.batchNo,
|
|
|
+ outInDetailId: this.locationType == 'shelf' ? matchedItem.id : '',
|
|
|
+ outInDetailRecordId: this.locationType !== 'shelf' ? matchedItem.id : '',
|
|
|
+ outInId: this.rowData.outInId || this.rowData.id,
|
|
|
+ packageNo: matchedItem.packageNo,
|
|
|
+ packingQuantity: matchedItem.packingQuantity,
|
|
|
+ packingUnit: matchedItem.packingUnit,
|
|
|
+ serialNumber: matchedItem.serialNumber,
|
|
|
+ supplierCode: matchedItem.supplierCode,
|
|
|
+ warehouseId: loc.warehouseId,
|
|
|
+ warehouseName: loc.warehouseName,
|
|
|
+ weight: matchedItem.weight,
|
|
|
+ weightUnit: matchedItem.weightUnit,
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
@@ -896,15 +1096,18 @@
|
|
|
outInDetailList
|
|
|
};
|
|
|
|
|
|
- storageApi
|
|
|
- .upperLowerShelves(payload)
|
|
|
+ console.log('storageRecords', this.storageRecords);
|
|
|
+
|
|
|
+ const requestUrl = storageApi.storageRecordUpdate
|
|
|
+
|
|
|
+ requestUrl(outInDetailList)
|
|
|
.then(() => {
|
|
|
this.$message.success('上架成功');
|
|
|
this.$emit('done');
|
|
|
this.cancel();
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
- this.$message.error(e.message || '上架失败');
|
|
|
+ // this.$message.error(e.message || '上架失败');
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.confirmLoading = false;
|
|
|
@@ -951,7 +1154,7 @@
|
|
|
|
|
|
.content-box {
|
|
|
display: flex;
|
|
|
- justify-content: space-between;
|
|
|
+ justify-content: flex-start;
|
|
|
flex-wrap: wrap;
|
|
|
max-height: 300px;
|
|
|
overflow: auto;
|