|
@@ -184,13 +184,7 @@
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
reserveSelection: true,
|
|
reserveSelection: true,
|
|
|
selectable: (row) => {
|
|
selectable: (row) => {
|
|
|
- if (this.showStockCount) {
|
|
|
|
|
- return this.getAvailableStockCount(row) != 0;
|
|
|
|
|
- }
|
|
|
|
|
- const measureQuantity = parseFloat(row.measureQuantity) || 0;
|
|
|
|
|
- const lockQuantity = parseFloat(row.lockQuantity) || 0;
|
|
|
|
|
- const available = measureQuantity - lockQuantity;
|
|
|
|
|
- return available != 0;
|
|
|
|
|
|
|
+ return this.getAvailableStockCount(row) != 0;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -303,10 +297,7 @@
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
minWidth: 90,
|
|
minWidth: 90,
|
|
|
- formatter: (row) =>
|
|
|
|
|
- this.showStockCount
|
|
|
|
|
- ? this.getStockCount(row)
|
|
|
|
|
- : row.measureQuantity
|
|
|
|
|
|
|
+ formatter: (row) => this.getStockCount(row)
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
prop: 'lockQuantity',
|
|
prop: 'lockQuantity',
|
|
@@ -322,15 +313,7 @@
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
minWidth: 90,
|
|
minWidth: 90,
|
|
|
formatter: (row) => {
|
|
formatter: (row) => {
|
|
|
- if (this.showStockCount) {
|
|
|
|
|
- return this.getAvailableStockCount(row);
|
|
|
|
|
- }
|
|
|
|
|
- // 使用toFixed处理浮点数精度问题,保留4位小数
|
|
|
|
|
- const measureQuantity = parseFloat(row.measureQuantity) || 0;
|
|
|
|
|
- const lockQuantity = parseFloat(row.lockQuantity) || 0;
|
|
|
|
|
- const available = measureQuantity - lockQuantity;
|
|
|
|
|
- // 使用toFixed避免精度丢失,然后去除末尾多余的0
|
|
|
|
|
- return available.toFixed(4).replace(/\.?0+$/, '');
|
|
|
|
|
|
|
+ return this.getAvailableStockCount(row);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -412,14 +395,33 @@
|
|
|
pageNum: page,
|
|
pageNum: page,
|
|
|
size: limit
|
|
size: limit
|
|
|
});
|
|
});
|
|
|
- // 库存接口在同一物品/批次存在多条台账时可能返回重复 id。
|
|
|
|
|
- // id 仍作为业务主键保留,表格使用仅用于渲染的唯一 key,避免 Vue patch 冲突。
|
|
|
|
|
|
|
+ // 与 WMS 库存台账保持一致:库存取 stockCountBase,旧接口无该字段时回退 measureQuantity;
|
|
|
|
|
+ // 可用数量按库存减锁库数量计算,并统一将负数归零。
|
|
|
if (data && Array.isArray(data.list)) {
|
|
if (data && Array.isArray(data.list)) {
|
|
|
- data.list = data.list.map((item, index) => ({
|
|
|
|
|
- ...item,
|
|
|
|
|
- _tableRowKey: `${item.id || 'row'}_${page}_${index}`
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ data.list = data.list.map((item, index) => {
|
|
|
|
|
+ const stockCountBase = Math.max(
|
|
|
|
|
+ Number(
|
|
|
|
|
+ item.stockCountBase !== undefined && item.stockCountBase !== null
|
|
|
|
|
+ ? item.stockCountBase
|
|
|
|
|
+ : item.measureQuantity
|
|
|
|
|
+ ) || 0,
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
+ const lockQuantity = Number(item.lockQuantity) || 0;
|
|
|
|
|
+ const availableCountBase = Math.max(
|
|
|
|
|
+ stockCountBase - lockQuantity,
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ stockCountBase,
|
|
|
|
|
+ availableCountBase,
|
|
|
|
|
+ _tableRowKey: `${item.id || 'row'}_${page}_${index}`
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
+ // 库存接口在同一物品/批次存在多条台账时可能返回重复 id。
|
|
|
|
|
+ // id 仍作为业务主键保留,表格使用仅用于渲染的唯一 key,避免 Vue patch 冲突。
|
|
|
this.getTabColumns();
|
|
this.getTabColumns();
|
|
|
return data;
|
|
return data;
|
|
|
},
|
|
},
|
|
@@ -476,16 +478,15 @@
|
|
|
return Number(row.measureQuantity || 0);
|
|
return Number(row.measureQuantity || 0);
|
|
|
},
|
|
},
|
|
|
getAvailableStockCount(row) {
|
|
getAvailableStockCount(row) {
|
|
|
- const available =
|
|
|
|
|
- this.getStockCount(row) - Number(row.lockQuantity || 0);
|
|
|
|
|
- return Number(available.toFixed(4));
|
|
|
|
|
|
|
+ if (row.availableCountBase !== undefined && row.availableCountBase !== null) {
|
|
|
|
|
+ return Number(row.availableCountBase);
|
|
|
|
|
+ }
|
|
|
|
|
+ const available = this.getStockCount(row) - Number(row.lockQuantity || 0);
|
|
|
|
|
+ return Math.max(Number(available.toFixed(4)), 0);
|
|
|
},
|
|
},
|
|
|
// 限制订单数量不超过当前可用数量
|
|
// 限制订单数量不超过当前可用数量
|
|
|
handleSaleCountInput(row) {
|
|
handleSaleCountInput(row) {
|
|
|
- const available = this.showStockCount
|
|
|
|
|
- ? this.getAvailableStockCount(row)
|
|
|
|
|
- : (parseFloat(row.measureQuantity) || 0) -
|
|
|
|
|
- (parseFloat(row.lockQuantity) || 0);
|
|
|
|
|
|
|
+ const available = this.getAvailableStockCount(row);
|
|
|
const val = parseFloat(row.saleCount);
|
|
const val = parseFloat(row.saleCount);
|
|
|
if (!isNaN(val) && val > available) {
|
|
if (!isNaN(val) && val > available) {
|
|
|
this.$message.warning(`订单数量不能超过可用数量(${available})`);
|
|
this.$message.warning(`订单数量不能超过可用数量(${available})`);
|