|
|
@@ -25,8 +25,9 @@
|
|
|
ref="tableRef"
|
|
|
:data="tableData"
|
|
|
style="width: 100%"
|
|
|
- max-height="300"
|
|
|
+ max-height="580"
|
|
|
border
|
|
|
+ v-loading="tableLoading"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
<el-table-column
|
|
|
@@ -38,6 +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 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" />
|
|
|
@@ -61,6 +63,16 @@
|
|
|
<el-table-column prop="purchaseDate" label="采购日期" width="110" align="center" />
|
|
|
<el-table-column prop="expiryDate" label="失效日期" width="110" align="center" />
|
|
|
</el-table>
|
|
|
+ <el-pagination
|
|
|
+ v-if="dimension === 3"
|
|
|
+ style="margin-top: 8px; text-align: right;"
|
|
|
+ :current-page="packingPages.pageNum"
|
|
|
+ :page-size="packingPages.size"
|
|
|
+ :total="packingTotal"
|
|
|
+ layout="total, prev, pager, next"
|
|
|
+ @current-change="handlePackingPageChange"
|
|
|
+ @size-change="handlePackingSizeChange"
|
|
|
+ />
|
|
|
</el-col>
|
|
|
|
|
|
<!-- 右侧:上架信息 -->
|
|
|
@@ -96,7 +108,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="选择货架">
|
|
|
- <el-select filterable v-model="formData.shelves" @change="changeshelvesList">
|
|
|
+ <el-select filterable v-model="shelves" @change="changeshelvesList">
|
|
|
<el-option
|
|
|
v-for="(item, index) in shelvesList"
|
|
|
:key="index"
|
|
|
@@ -124,11 +136,11 @@
|
|
|
@click="handlCur(p)"
|
|
|
:class="{ selected: isLocationSelected(p.id) }"
|
|
|
:style="{
|
|
|
- 'background-color': getStatus(p.allocationStatus).color,
|
|
|
- cursor: [1, 2].includes(p.allocationStatus) ? 'pointer' : 'not-allowed'
|
|
|
+ 'background-color': locationType === 'allocation' ? getStatus(p.allocationStatus).color : getShelfStatus(p).color,
|
|
|
+ cursor: locationType === 'allocation' ? ([1, 2].includes(p.allocationStatus) ? 'pointer' : 'not-allowed') : getShelfStatus(p).cursor
|
|
|
}"
|
|
|
>
|
|
|
- {{ p.goodsAllocationCode }}
|
|
|
+ {{ p.goodsAllocationCode || p.goodsshelvesCode }}
|
|
|
</div>
|
|
|
<div v-for="n in placeholderCount" :key="'ph-' + n" class="placeholder-box"></div>
|
|
|
</div>
|
|
|
@@ -137,7 +149,7 @@
|
|
|
<div style="margin-top: 12px;">
|
|
|
<el-button type="primary" size="small" @click="addRow">添加行</el-button>
|
|
|
</div>
|
|
|
- <el-table :data="shelvingList" style="width: 100%; margin-top: 8px;" border>
|
|
|
+ <el-table :data="shelvingList" max-height="400" style="width: 100%; margin-top: 8px;" border>
|
|
|
<el-table-column label="序号" type="index" width="50" align="center" />
|
|
|
<el-table-column label="货位位置" min-width="320" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
@@ -146,7 +158,7 @@
|
|
|
filterable
|
|
|
placeholder="选择货位"
|
|
|
size="small"
|
|
|
- style="width: 300px;"
|
|
|
+ style="width: 100%;"
|
|
|
@change="(val) => onLocationChange(val, scope.row)"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -158,14 +170,17 @@
|
|
|
</el-select>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="物品批次" min-width="280" align="center">
|
|
|
+
|
|
|
+ <el-table-column v-if="dimension === 3" prop="packageNo" label="包装编码" width="140" align="center" />
|
|
|
+ <el-table-column v-if="dimension == 1" label="物品批次" min-width="180" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-select
|
|
|
v-model="scope.row.itemKey"
|
|
|
filterable
|
|
|
placeholder="选择物品批次"
|
|
|
size="small"
|
|
|
- style="width: 260px;"
|
|
|
+ style="width: 100%;"
|
|
|
+ :disabled="dimension === 3"
|
|
|
@change="(val) => onItemChange(val, scope.row)"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -185,7 +200,8 @@
|
|
|
:max="scope.row.maxQuantity"
|
|
|
size="small"
|
|
|
controls-position="right"
|
|
|
- style="width: 130px;"
|
|
|
+ :disabled="dimension === 3"
|
|
|
+ style="width: 100%;"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -225,13 +241,19 @@
|
|
|
visible: false,
|
|
|
rowData: null,
|
|
|
dimension: 1, // 1-批次维度 2-物品维度 3-包装维度
|
|
|
-
|
|
|
+ type: '', // 'package' | 'product' 区分当前操作的是包装还是产品
|
|
|
// 物品表格
|
|
|
tableLoading: false,
|
|
|
tableData: [],
|
|
|
allTableData: [],
|
|
|
selection: [],
|
|
|
+ allSelectedItems: [], // 包装维度跨页面保持选中数据
|
|
|
+ _packingRestoring: false, // 包装维度切换页面恢复选中中,跳过中间态
|
|
|
+ _packingWarehouseInited: false, // 包装维度仓库是否已初始化(仅首次加载时初始化)
|
|
|
shelvedItemKeys: [],
|
|
|
+ // 包装维度分页
|
|
|
+ packingPages: { pageNum: 1, size: 20 },
|
|
|
+ packingTotal: 0,
|
|
|
|
|
|
// 仓库选择
|
|
|
warehouseList: [],
|
|
|
@@ -246,6 +268,7 @@
|
|
|
},
|
|
|
shelvesList: [],
|
|
|
locationList: [],
|
|
|
+ locationType: 'shelf', // 'shelf' | 'allocation' 区分当前显示的是货架还是货位
|
|
|
selectedLocations: [],
|
|
|
|
|
|
// 上架清单
|
|
|
@@ -256,23 +279,40 @@
|
|
|
|
|
|
computed: {
|
|
|
locationOptions() {
|
|
|
- return this.selectedLocations.map((l) => ({
|
|
|
- label: `${l.warehouseName} - ${l.areaName} - ${l.shelfCode} - ${l.goodsAllocationCode}`,
|
|
|
- value: l.id,
|
|
|
- ...l
|
|
|
- }));
|
|
|
+ const seen = new Set();
|
|
|
+ return this.selectedLocations
|
|
|
+ .filter((l) => {
|
|
|
+ if (seen.has(l.id)) return false;
|
|
|
+ seen.add(l.id);
|
|
|
+ return true;
|
|
|
+ })
|
|
|
+ .map((l) => ({
|
|
|
+ label:
|
|
|
+ this.locationType === 'allocation'
|
|
|
+ ? `${l.areaName} - ${l.shelfCode} - ${l.goodsAllocationCode}`
|
|
|
+ : `${l.areaName} - ${l.shelfCode}`,
|
|
|
+ value: l.id,
|
|
|
+ ...l
|
|
|
+ }));
|
|
|
},
|
|
|
itemOptions() {
|
|
|
+ const seen = new Set();
|
|
|
return this.selection
|
|
|
.filter((it) => !it._shelved)
|
|
|
+ .filter((it) => {
|
|
|
+ const key = this._getRowKey(it);
|
|
|
+ if (seen.has(key)) return false;
|
|
|
+ seen.add(key);
|
|
|
+ return true;
|
|
|
+ })
|
|
|
.map((it) => ({
|
|
|
- label: `${it.categoryName || ''}${it.batchNo ? '/' + it.batchNo : ''}`,
|
|
|
+ label: it.batchNo || '',
|
|
|
value: this._getRowKey(it),
|
|
|
...it
|
|
|
}));
|
|
|
},
|
|
|
placeholderCount() {
|
|
|
- const perRow = 5;
|
|
|
+ const perRow = 12;
|
|
|
const remainder = this.locationList.length % perRow;
|
|
|
return remainder === 0 ? 0 : perRow - remainder;
|
|
|
}
|
|
|
@@ -280,10 +320,11 @@
|
|
|
|
|
|
methods: {
|
|
|
// ==================== 打开/关闭 ====================
|
|
|
- async open(row) {
|
|
|
- console.log('open', row);
|
|
|
+ async open(row, type) {
|
|
|
+ console.log('open', row, type);
|
|
|
this.rowData = row;
|
|
|
- this.dimension = 1;
|
|
|
+ this.dimension = type === 'package' ? 3 : 1;
|
|
|
+ this.type = type;
|
|
|
this.selection = [];
|
|
|
this.shelvingList = [];
|
|
|
this.selectedLocations = [];
|
|
|
@@ -292,20 +333,20 @@
|
|
|
this.shelves = '';
|
|
|
this.formData = { warehouse: {}, area: {}, shelves: {} };
|
|
|
this.locationList = [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
this.shelvesList = [];
|
|
|
this.shelvedItemKeys = [];
|
|
|
+ this.allSelectedItems = [];
|
|
|
+ this._packingRestoring = false;
|
|
|
+ this._packingWarehouseInited = false;
|
|
|
+ this._packingWarehouseInited = false;
|
|
|
+ this.packingPages = { pageNum: 1, size: 20 };
|
|
|
+ this.packingTotal = 0;
|
|
|
this.visible = true;
|
|
|
await this._getWarehouseList();
|
|
|
await this._loadTableData();
|
|
|
|
|
|
- if (row?.warehouseId) {
|
|
|
- this.warehouse = row.warehouseId;
|
|
|
- const w = this.warehouseList.find((item) => item.id == row.warehouseId);
|
|
|
- if (w) {
|
|
|
- this.formData.warehouse = w;
|
|
|
- await this.changeWarehouse(w);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
cancel() {
|
|
|
@@ -317,32 +358,106 @@
|
|
|
this.tableData = [];
|
|
|
this.allTableData = [];
|
|
|
this.selection = [];
|
|
|
+ this.allSelectedItems = [];
|
|
|
+ this._packingRestoring = false;
|
|
|
+ this._packingWarehouseInited = false;
|
|
|
this.shelvingList = [];
|
|
|
this.selectedLocations = [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
this.visible = false;
|
|
|
},
|
|
|
|
|
|
// ==================== 维度切换 ====================
|
|
|
dimensionChange() {
|
|
|
this.selection = [];
|
|
|
+ this.allSelectedItems = [];
|
|
|
+ this._packingRestoring = false;
|
|
|
+ this._packingWarehouseInited = false;
|
|
|
+ this._packingWarehouseInited = false;
|
|
|
if (this.$refs.tableRef) {
|
|
|
this.$refs.tableRef.clearSelection();
|
|
|
}
|
|
|
this.shelvingList = [];
|
|
|
+ this.packingPages.pageNum = 1;
|
|
|
+ this.packingTotal = 0;
|
|
|
+ this.locationList = [];
|
|
|
+ this.shelvesList = [];
|
|
|
+ this._loadTableData();
|
|
|
+ },
|
|
|
+
|
|
|
+ // ==================== 包装维度分页 ====================
|
|
|
+ handlePackingPageChange(page) {
|
|
|
+ this.packingPages.pageNum = page;
|
|
|
+ this._loadTableData();
|
|
|
+ },
|
|
|
+
|
|
|
+ handlePackingSizeChange(size) {
|
|
|
+ this.packingPages.size = size;
|
|
|
+ this.packingPages.pageNum = 1;
|
|
|
this._loadTableData();
|
|
|
},
|
|
|
|
|
|
// ==================== 物品表格数据 ====================
|
|
|
async _loadTableData() {
|
|
|
+ console.log('this.rowData', this.rowData.outInId);
|
|
|
if (!this.rowData?.id) return;
|
|
|
this.tableLoading = true;
|
|
|
try {
|
|
|
- const res = await storageApi.getInboundDetailsById(this.rowData.id);
|
|
|
- if (res) {
|
|
|
- const items = this._parseRecords(res);
|
|
|
- this.allTableData = items;
|
|
|
- this.shelvedItemKeys = this._extractShelvedKeys(items);
|
|
|
- this.tableData = items;
|
|
|
+ if (this.dimension === 3) {
|
|
|
+ // 包装维度:调用 getOutInRecordsPage(分页)
|
|
|
+ const data = await storageApi.getOutInRecordsPage({
|
|
|
+ pageNum: this.packingPages.pageNum,
|
|
|
+ size: this.packingPages.size,
|
|
|
+ outInId: this.rowData.outInId || this.rowData.id
|
|
|
+ });
|
|
|
+ if (data?.list) {
|
|
|
+ const items = this._parsePackingRecords(data.list);
|
|
|
+ this.packingTotal = data.count || 0;
|
|
|
+ if (items.length > 0 && !this._packingWarehouseInited) {
|
|
|
+ this._packingWarehouseInited = true;
|
|
|
+ this.warehouse = items[0].warehouseId || '';
|
|
|
+ const w = this.warehouseList.find((item) => item.id == items[0].warehouseId);
|
|
|
+ if (w) {
|
|
|
+ this.formData.warehouse = w;
|
|
|
+ await this.changeWarehouse(w);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.allTableData = items;
|
|
|
+ this.shelvedItemKeys = this._extractShelvedKeys(items);
|
|
|
+ // 标记正在恢复,防止 tableData 变化触发的 selection-change 清空 allSelectedItems
|
|
|
+ this._packingRestoring = true;
|
|
|
+ this.tableData = items;
|
|
|
+ this.selection = this.allSelectedItems;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.tableRef) {
|
|
|
+ const selectedKeys = new Set(this.allSelectedItems.map((it) => this._getRowKey(it)));
|
|
|
+ this.tableData.forEach((row) => {
|
|
|
+ if (selectedKeys.has(this._getRowKey(row))) {
|
|
|
+ this.$refs.tableRef.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this._packingRestoring = false;
|
|
|
+ // 切页不重建右侧清单,保留用户已有的编辑数据
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 批次维度 / 物品维度:原有接口
|
|
|
+ const res = await storageApi.getInboundDetailsById(this.rowData.outInId ||this.rowData.id);
|
|
|
+ if (res) {
|
|
|
+ const items = this._parseRecords(res);
|
|
|
+ console.log('items', items);
|
|
|
+ this.warehouse = items[0].warehouseId;
|
|
|
+ const w = this.warehouseList.find((item) => item.id == items[0].warehouseId);
|
|
|
+ if (w) {
|
|
|
+ this.formData.warehouse = w;
|
|
|
+ await this.changeWarehouse(w);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.allTableData = items;
|
|
|
+ this.shelvedItemKeys = this._extractShelvedKeys(items);
|
|
|
+ this.tableData = items;
|
|
|
+ }
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error('加载物品清单失败:', e);
|
|
|
@@ -392,11 +507,50 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ _parsePackingRecords(list) {
|
|
|
+ return list.map((item, index) => {
|
|
|
+ const isUpper = !!(item.areaId && item.goodsShelfId && item.goodsAllocationId);
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ _index: index,
|
|
|
+ _shelved: isUpper,
|
|
|
+ categoryId: item.categoryId || '',
|
|
|
+ categoryCode: item.categoryCode || '',
|
|
|
+ categoryName: item.categoryName || '',
|
|
|
+ batchNo: item.batchNo || '',
|
|
|
+ measureQuantity: item.measureQuantity || item.quantity || 0,
|
|
|
+ measureUnit: item.measureUnit || '',
|
|
|
+ packingQuantity: item.packingQuantity || item.quantity || 0,
|
|
|
+ packingUnit: item.packingUnit || '',
|
|
|
+ singleWeight: item.singleWeight || '',
|
|
|
+ totalWeight: item.totalWeight || '',
|
|
|
+ weightUnit: item.weightUnit || '',
|
|
|
+ colorKey: item.colorKey || '',
|
|
|
+ categoryModel: item.categoryModel || '',
|
|
|
+ specification: item.specification || '',
|
|
|
+ gradeName: item.gradeName || '',
|
|
|
+ voltage: item.voltage || '',
|
|
|
+ approvalNumber: item.approvalNumber || '',
|
|
|
+ packingSpec: item.packingSpec || '',
|
|
|
+ allowUnpack:
|
|
|
+ item.allowUnpack != null ? (item.allowUnpack ? '是' : '否') : '',
|
|
|
+ supplierName: item.supplierName || '',
|
|
|
+ warehouseName: item.warehouseName || '',
|
|
|
+ warehouseId: item.warehouseId || '',
|
|
|
+ productionDate: item.productionDate || '',
|
|
|
+ purchaseDate: item.purchaseDate || '',
|
|
|
+ expiryDate: item.expiryDate || ''
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
_extractShelvedKeys(items) {
|
|
|
return items.filter((it) => it._shelved).map((it) => this._getRowKey(it));
|
|
|
},
|
|
|
|
|
|
_getRowKey(row) {
|
|
|
+ // 包装维度:用 packageNo 作为唯一标识(同一批次下 packageNo 唯一)
|
|
|
+ if (row.packageNo) return row.packageNo;
|
|
|
return `${row.categoryId || ''}_${row.batchNo || ''}`;
|
|
|
},
|
|
|
|
|
|
@@ -405,7 +559,30 @@
|
|
|
},
|
|
|
|
|
|
handleSelectionChange(selection) {
|
|
|
- this.selection = selection;
|
|
|
+ if (this.dimension === 3) {
|
|
|
+ if (this._packingRestoring) {
|
|
|
+ // 正在恢复跨页面选中状态,跳过中间态,避免 allSelectedItems 被错误清空
|
|
|
+ this.selection = selection;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 包装维度:维护跨页面的选中状态
|
|
|
+ const currentTableKeys = new Set(this.tableData.map((row) => this._getRowKey(row)));
|
|
|
+ const newSelectionKeys = new Set(selection.map((row) => this._getRowKey(row)));
|
|
|
+ // 移除当前页面中取消选中的项,保留其他页面的选中项
|
|
|
+ this.allSelectedItems = this.allSelectedItems.filter(
|
|
|
+ (item) => !currentTableKeys.has(this._getRowKey(item)) || newSelectionKeys.has(this._getRowKey(item))
|
|
|
+ );
|
|
|
+ // 添加当前页面新选中的项
|
|
|
+ selection.forEach((item) => {
|
|
|
+ const key = this._getRowKey(item);
|
|
|
+ if (!this.allSelectedItems.find((it) => this._getRowKey(it) === key)) {
|
|
|
+ this.allSelectedItems.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.selection = this.allSelectedItems;
|
|
|
+ } else {
|
|
|
+ this.selection = selection;
|
|
|
+ }
|
|
|
this.buildDefaultShelvingList();
|
|
|
},
|
|
|
|
|
|
@@ -414,51 +591,46 @@
|
|
|
const items = this.selection.filter((it) => !it._shelved);
|
|
|
const locs = this.selectedLocations;
|
|
|
|
|
|
- if (items.length === 0 || locs.length === 0) {
|
|
|
+ if (items.length === 0) {
|
|
|
this.shelvingList = [];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let newList = null;
|
|
|
-
|
|
|
- // ① 单个物品 + 单个货位
|
|
|
- if (items.length === 1 && locs.length === 1) {
|
|
|
- const item = items[0];
|
|
|
- newList = [
|
|
|
- {
|
|
|
- cargoSpaceId: locs[0].id,
|
|
|
- cargoSpaceCode: locs[0].goodsAllocationCode,
|
|
|
- itemKey: this._getRowKey(item),
|
|
|
- quantity: item.measureQuantity,
|
|
|
- maxQuantity: item.measureQuantity
|
|
|
- }
|
|
|
- ];
|
|
|
- }
|
|
|
- // ② 多个物品 + 单个货位
|
|
|
- else if (items.length > 1 && locs.length === 1) {
|
|
|
- newList = items.map((item) => ({
|
|
|
- cargoSpaceId: locs[0].id,
|
|
|
- cargoSpaceCode: locs[0].goodsAllocationCode,
|
|
|
- itemKey: this._getRowKey(item),
|
|
|
- quantity: item.measureQuantity,
|
|
|
- maxQuantity: item.measureQuantity
|
|
|
- }));
|
|
|
- }
|
|
|
- // ③ 多个物品 + 多个货位,且数量相等
|
|
|
- else if (items.length > 1 && locs.length > 1 && items.length === locs.length) {
|
|
|
- newList = items.map((item, idx) => ({
|
|
|
- cargoSpaceId: locs[idx].id,
|
|
|
- cargoSpaceCode: locs[idx].goodsAllocationCode,
|
|
|
- itemKey: this._getRowKey(item),
|
|
|
- quantity: item.measureQuantity,
|
|
|
- maxQuantity: item.measureQuantity
|
|
|
- }));
|
|
|
- }
|
|
|
+ // 保留已有行中用户手动编辑的数据(按 itemKey 匹配)
|
|
|
+ const existingMap = {};
|
|
|
+ this.shelvingList.forEach((row) => {
|
|
|
+ if (row.itemKey) {
|
|
|
+ existingMap[row.itemKey] = row;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- if (newList) {
|
|
|
- this.shelvingList = newList;
|
|
|
- }
|
|
|
- // ④ 其他情况:无法默认,保持现有内容(如果有)
|
|
|
+ // 选中几个就生成几行,优先继承已有行的用户编辑数据
|
|
|
+ const newList = items.map((item, idx) => {
|
|
|
+ const key = this._getRowKey(item);
|
|
|
+ const old = existingMap[key];
|
|
|
+
|
|
|
+ // 尝试匹配货位:1:1 / N:1 / N:N
|
|
|
+ let cargoId = '';
|
|
|
+ let cargoCode = '';
|
|
|
+ if (locs.length === 1) {
|
|
|
+ cargoId = locs[0].id;
|
|
|
+ cargoCode = locs[0].goodsAllocationCode;
|
|
|
+ } else if (locs.length > 1 && items.length === locs.length) {
|
|
|
+ cargoId = locs[idx].id;
|
|
|
+ cargoCode = locs[idx].goodsAllocationCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ packageNo: item.packageNo || '',
|
|
|
+ cargoSpaceId: old?.cargoSpaceId || cargoId,
|
|
|
+ cargoSpaceCode: old?.cargoSpaceCode || cargoCode,
|
|
|
+ itemKey: key,
|
|
|
+ quantity: old?.quantity != null ? old.quantity : (parseFloat(item.measureQuantity) || 0),
|
|
|
+ maxQuantity: parseFloat(item.measureQuantity) || 0
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ this.shelvingList = newList;
|
|
|
},
|
|
|
|
|
|
// ==================== 仓库/库区/货架/货位 ====================
|
|
|
@@ -473,6 +645,7 @@
|
|
|
this.cur = {};
|
|
|
this.shelves = '';
|
|
|
this.locationList = [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
this.area = '';
|
|
|
this.selectedLocations = [];
|
|
|
this.shelvingList = [];
|
|
|
@@ -484,6 +657,7 @@
|
|
|
this.area = '';
|
|
|
this.shelves = '';
|
|
|
this.areaList = res || [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
this.selectedLocations = [];
|
|
|
this.shelvingList = [];
|
|
|
},
|
|
|
@@ -491,11 +665,13 @@
|
|
|
async getshelvesList(e) {
|
|
|
this.cur = {};
|
|
|
this.shelves = '';
|
|
|
- this.locationList = [];
|
|
|
this.selectedLocations = [];
|
|
|
this.shelvingList = [];
|
|
|
const rep = await warehouseDefinition.getListByAreaId(e);
|
|
|
this.shelvesList = rep || [];
|
|
|
+ // 直接将货架信息赋值给 locationList,在网格区域展示
|
|
|
+ this.locationList = rep || [];
|
|
|
+ this.locationType = 'shelf';
|
|
|
},
|
|
|
|
|
|
async changeshelvesList(id) {
|
|
|
@@ -504,28 +680,65 @@
|
|
|
this.shelvingList = [];
|
|
|
if (!this.shelvesList.length) {
|
|
|
this.locationList = [];
|
|
|
+ this.locationType = 'allocation';
|
|
|
return;
|
|
|
}
|
|
|
const matched = this.shelvesList.find((item) => item.goodsshelvesCode == id);
|
|
|
if (!matched) {
|
|
|
this.locationList = [];
|
|
|
+ this.locationType = 'allocation';
|
|
|
return;
|
|
|
}
|
|
|
const res = await warehouseDefinition.getListByGoodId(matched.id);
|
|
|
this.locationList = res || [];
|
|
|
+ this.locationType = 'allocation';
|
|
|
},
|
|
|
|
|
|
getStatus: useDict(locationStatusList),
|
|
|
|
|
|
- // ==================== 货位点击(多选) ====================
|
|
|
- handlCur(row) {
|
|
|
- if (![1, 2].includes(row.allocationStatus)) {
|
|
|
- return;
|
|
|
+ getShelfStatus(row) {
|
|
|
+ // 根据货架的 allocation 信息判断状态
|
|
|
+ const empty = row.emptyAllocationNumber ?? 0;
|
|
|
+ const inUse = row.inUseAllocationNumber ?? 0;
|
|
|
+ const full = row.fullAllocationNumber ?? 0;
|
|
|
+ const total = row.allocationNumber ?? 0;
|
|
|
+
|
|
|
+ // 已满:full > 0 且没有空位
|
|
|
+ if (full > 0 && empty === 0 && inUse === 0) {
|
|
|
+ return { code: 3, color: 'rgba(255, 14, 14, 1)', cursor: 'not-allowed' };
|
|
|
}
|
|
|
- const { area, shelves, warehouse } = this.formData;
|
|
|
- if (!warehouse?.id || !area?.id || !shelves?.id) {
|
|
|
- this.$message.warning('请先选择仓库、库区和货架');
|
|
|
- return;
|
|
|
+ // 在用:inUse > 0
|
|
|
+ if (inUse > 0) {
|
|
|
+ return { code: 2, color: 'rgba(129, 211, 248, 1)', cursor: 'pointer' };
|
|
|
+ }
|
|
|
+ // 空置:empty > 0 或者没有分配信息(默认可上架)
|
|
|
+ if (empty > 0 || total === 0) {
|
|
|
+ return { code: 1, color: 'rgba(202, 249, 130, 1)', cursor: 'pointer' };
|
|
|
+ }
|
|
|
+ // 默认空置
|
|
|
+ return { code: 1, color: 'rgba(202, 249, 130, 1)', cursor: 'pointer' };
|
|
|
+ },
|
|
|
+
|
|
|
+ // ==================== 货架/货位点击(多选) ====================
|
|
|
+ handlCur(row) {
|
|
|
+ const { area, warehouse } = this.formData;
|
|
|
+ const isAllocation = this.locationType === 'allocation';
|
|
|
+
|
|
|
+ // 货位模式:检查 allocationStatus
|
|
|
+ if (isAllocation) {
|
|
|
+ if (![1, 2].includes(row.allocationStatus)) return;
|
|
|
+ if (!warehouse?.id || !area?.id || !this.formData.shelves?.id) {
|
|
|
+ this.$message.warning('请先选择仓库、库区和货架');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 货架模式:检查 shelfStatus
|
|
|
+ const status = this.getShelfStatus(row);
|
|
|
+ if (status.code !== 1 && status.code !== 2) return;
|
|
|
+ if (!warehouse?.id || !area?.id) {
|
|
|
+ this.$message.warning('请先选择仓库和库区');
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const idx = this.selectedLocations.findIndex((l) => l.id === row.id);
|
|
|
@@ -534,13 +747,13 @@
|
|
|
} else {
|
|
|
this.selectedLocations.push({
|
|
|
id: row.id,
|
|
|
- goodsAllocationCode: row.goodsAllocationCode,
|
|
|
+ goodsAllocationCode: isAllocation ? row.goodsAllocationCode : row.goodsshelvesCode,
|
|
|
warehouseId: warehouse.id,
|
|
|
warehouseName: warehouse.name,
|
|
|
areaId: area.id,
|
|
|
areaName: area.name,
|
|
|
- shelfId: shelves.id,
|
|
|
- shelfCode: shelves.goodsshelvesCode
|
|
|
+ shelfId: isAllocation ? this.formData.shelves.id : row.id,
|
|
|
+ shelfCode: isAllocation ? this.formData.shelves.goodsshelvesCode : row.goodsshelvesCode
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -563,7 +776,25 @@
|
|
|
},
|
|
|
|
|
|
delItem(index) {
|
|
|
+ const row = this.shelvingList[index];
|
|
|
+ const removedKey = row?.itemKey;
|
|
|
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
|
|
|
+ );
|
|
|
+ if (matchedRow) {
|
|
|
+ this.$refs.tableRef.toggleRowSelection(matchedRow, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
onLocationChange(val, row) {
|
|
|
@@ -574,7 +805,8 @@
|
|
|
},
|
|
|
|
|
|
onItemChange(val, row) {
|
|
|
- const item = this.allTableData.find((it) => this._getRowKey(it) === val);
|
|
|
+ const source = this.dimension === 3 ? this.selection : this.allTableData;
|
|
|
+ const item = source.find((it) => this._getRowKey(it) === val);
|
|
|
if (item) {
|
|
|
row.maxQuantity = parseFloat(item.measureQuantity) || 0;
|
|
|
if (row.quantity > row.maxQuantity) {
|
|
|
@@ -635,8 +867,9 @@
|
|
|
// 组装提交数据
|
|
|
this.confirmLoading = true;
|
|
|
const outInDetailList = [];
|
|
|
+ const lookupSource = this.dimension === 3 ? this.selection : this.allTableData;
|
|
|
this.shelvingList.forEach((row) => {
|
|
|
- const matchedItem = this.allTableData.find(
|
|
|
+ const matchedItem = lookupSource.find(
|
|
|
(it) => this._getRowKey(it) === row.itemKey
|
|
|
);
|
|
|
const loc = this.selectedLocations.find((l) => l.id === row.cargoSpaceId);
|
|
|
@@ -659,7 +892,7 @@
|
|
|
});
|
|
|
|
|
|
const payload = {
|
|
|
- id: this.rowData.id,
|
|
|
+ id: this.rowData.outInId || this.rowData.id,
|
|
|
outInDetailList
|
|
|
};
|
|
|
|
|
|
@@ -720,15 +953,15 @@
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
flex-wrap: wrap;
|
|
|
- max-height: 40vh;
|
|
|
+ max-height: 300px;
|
|
|
overflow: auto;
|
|
|
.box {
|
|
|
cursor: pointer;
|
|
|
- width: 134px;
|
|
|
- height: 64px;
|
|
|
+ width: 120px;
|
|
|
+ height: 50px;
|
|
|
background-clip: content-box;
|
|
|
margin-bottom: 4px;
|
|
|
- line-height: 64px;
|
|
|
+ line-height: 50px;
|
|
|
text-align: center;
|
|
|
font-size: 13px;
|
|
|
border: 2px solid transparent;
|
|
|
@@ -741,7 +974,7 @@
|
|
|
}
|
|
|
}
|
|
|
.placeholder-box {
|
|
|
- width: 134px;
|
|
|
+ width: 120px;
|
|
|
}
|
|
|
}
|
|
|
|