fix(盘点): 商品作业页展示未盘库位占位行,恢复待盘库位可见性

- normalizeGoodsDetailInfo 不再过滤未盘库位:每个库位带 checked 标记,
  未盘行实盘按 -- 展示(后端 quantity 回 0,直接用会误算「账实相符」),不参与盈亏
- recordCount / lastCheckedAt 仍只统计真实作业记录,口径不变
- 商品作业页 resolveHasChecked 改为「有记录 或 存在已盘库位」,
  避免占位行导致卡片误显示已盘 0
- 「共 N 条」按已盘库位数统计,未盘占位行不计入

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-10-28 00:08:22 +08:00
parent 630f2a3a3c
commit 3cf709c196
2 changed files with 14 additions and 9 deletions

View File

@ -971,26 +971,29 @@ export function normalizeGoodsDetailInfo(row, mode) {
const checkers = Array.isArray(checkersRaw) ? checkersRaw.filter(Boolean).join('、') : String(checkersRaw || '');
// 库位明细(每库位一行:账面 / 实盘 / 盈亏),顺便汇总记录条数与最近上报时间
// 未盘点库位只是任务范围占位(record_ids 空且无盘点人/上报时间),不作为「盘点记录」展示
// 未盘点库位是任务范围占位:保留展示以便看到待盘库位,但实盘按 -- 处理、不参与盈亏、不计入记录条数
const rawLocations = Array.isArray(source.locations) ? source.locations : [];
const checkedLocations = rawLocations.filter(isCheckedLocation);
let recordCount = 0;
let lastCheckedAt = '';
const locations = checkedLocations.map((item, index) => {
const locations = rawLocations.map((item, index) => {
const loc = item && typeof item === 'object' ? item : {};
const checked = isCheckedLocation(loc);
const locationCode = firstValue(loc, ['location_code', 'locationCode']) || '';
const locationName = firstValue(loc, ['location_name', 'locationName']) || '';
const spaceId = firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']);
const recordIds = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : [];
const systemQuantity = toNumberOrNull(loc.system_quantity !== undefined ? loc.system_quantity : loc.systemQuantity);
const quantity = toNumberOrNull(loc.quantity);
// 未盘库位的 quantity 后端会回 0,直接展示会算出「账实相符」,因此按未盘置空
const quantity = checked ? toNumberOrNull(loc.quantity) : null;
const checkedAt = firstValue(loc, ['checked_at', 'checkedAt']);
const checkerName = firstValue(loc, ['checker_name', 'checkerName']);
recordCount += recordIds.length;
if (checkedAt && checkedAt > lastCheckedAt) lastCheckedAt = checkedAt;
const diff = systemQuantity === null || quantity === null ? null : quantity - systemQuantity;
const diff = checked && systemQuantity !== null && quantity !== null ? quantity - systemQuantity : null;
return {
key: `loc-${locationCode || index + 1}`,
// 该库位是否已盘(占位行 checked=false:实盘 --、不可删除)
checked,
// 左滑删除用:整库位的记录 ID 列表(recordDelete 支持数组)
recordIds,
recordId: recordIds.length === 1 ? recordIds[0] : '',

View File

@ -155,11 +155,12 @@ function resolveSystemQuantity(goodsInfo) {
return sys === null || sys === undefined ? null : Number(sys);
}
/** 是否已盘(有库位明细/作业记录) */
/** 是否已盘(有已盘库位明细/作业记录;未盘占位行不算) */
function resolveHasChecked(goodsInfo) {
const info = goodsInfo || {};
if (Array.isArray(info.locations) && info.locations.length) return true;
return Number(info.recordCount) > 0;
if (Number(info.recordCount) > 0) return true;
const locations = Array.isArray(info.locations) ? info.locations : [];
return locations.some(item => item && item.checked);
}
/** 已盘合计:优先接口 checked_quantity,缺失时用库位明细合计 */
@ -278,7 +279,8 @@ export default {
statusText: '',
statusClass: '',
meta,
goodsCount: locations.length,
// 「共 N 条」按实际已盘库位数统计(未盘占位行不计入)
goodsCount: locations.filter(item => item && item.checked).length,
unknownCount: 0,
children: locations
};