Merge origin/main:并入 0.3.318 账面口径,保留未盘库位占位行

线上 f4c40e4 与本地的 stock_id 入口/workDataDetail 改造重叠且为超集,
冲突文件(countModel.js、inventoryCountDetail.vue、inventoryCountGoods.vue)
取线上版本为基准,仅补回本地独有逻辑:

- countModel.normalizeGoodsDetailInfo:库位明细保留未盘占位行(checked 标记、
  实盘置空),记账条数/最近上报仍只统计已盘库位;allLocations 明细ID映射沿用线上
- inventoryCountGoods:resolveHasChecked 改为「有记录 或 存在已盘库位」,
  「共 N 条」按已盘库位数统计
- apis.js 注释同步(detail_id 可选、商品钻取 summary+rows)
- 版本升级至 1.0.135

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-10-28 16:25:31 +08:00
commit 9c3ee18cdd
10 changed files with 392 additions and 113 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "wms-pda", "name": "wms-pda",
"version": "1.0.134", "version": "1.0.135",
"private": true, "private": true,
"description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)", "description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)",
"scripts": { "scripts": {

View File

@ -21,11 +21,12 @@
<text v-if="row.subtitle" class="goods-card__subtitle">{{ row.subtitle }}</text> <text v-if="row.subtitle" class="goods-card__subtitle">{{ row.subtitle }}</text>
<view class="goods-card__metrics"> <view class="goods-card__metrics">
<template v-if="row.amount"> <template v-if="row.amount">
<text class="goods-card__metric">账面 {{ row.amount.systemText }}</text> <text class="goods-card__metric">{{ row.amount.systemLabel || '账面' }} {{ row.amount.systemText }}</text>
<text class="goods-card__metric">已盘 {{ row.amount.checkedText }}</text> <text class="goods-card__metric">已盘 {{ row.amount.checkedText }}</text>
<text v-if="row.amount.diffText" class="goods-card__diff" :class="diffClass(row)"> <text v-if="row.amount.diffText" class="goods-card__diff" :class="diffClass(row)">
{{ row.amount.diffText }} {{ row.amount.diffText }}
</text> </text>
<text v-if="row.amount.bookHint" class="goods-card__metric goods-card__metric--hint">{{ row.amount.bookHint }}</text>
</template> </template>
<text v-else class="goods-card__metric">已盘记录 {{ row.recordCount || 0 }} 条</text> <text v-else class="goods-card__metric">已盘记录 {{ row.recordCount || 0 }} 条</text>
<text v-if="locationText" class="goods-card__metric">{{ locationText }}</text> <text v-if="locationText" class="goods-card__metric">{{ locationText }}</text>
@ -171,6 +172,12 @@ export default {
color: #303133; color: #303133;
} }
/* 另一种账面口径提示(静态看当前库存 / 普通看基准快照) */
.goods-card__metric--hint {
color: #b8811a;
font-size: 28rpx;
}
.goods-card__diff { .goods-card__diff {
margin-right: 20rpx; margin-right: 20rpx;
font-size: 34rpx; font-size: 34rpx;

View File

@ -71,11 +71,12 @@
<text <text
class="loc-detail__row-amount" class="loc-detail__row-amount"
:class="{ 'loc-detail__row-amount--stock': child.amounts.hasSystemStock }" :class="{ 'loc-detail__row-amount--stock': child.amounts.hasSystemStock }"
>账面 {{ child.amounts.systemText }}</text> >{{ child.amounts.systemLabel || '账面' }} {{ child.amounts.systemText }}</text>
<text class="loc-detail__row-amount loc-detail__row-amount--checked">实盘 {{ child.amounts.checkedText }}</text> <text class="loc-detail__row-amount loc-detail__row-amount--checked">实盘 {{ child.amounts.checkedText }}</text>
<text v-if="child.amounts.diffText" class="loc-detail__row-diff" :class="diffClass(child.amounts)"> <text v-if="child.amounts.diffText" class="loc-detail__row-diff" :class="diffClass(child.amounts)">
{{ child.amounts.diffText }} {{ child.amounts.diffText }}
</text> </text>
<text v-if="child.amounts.bookHint" class="loc-detail__row-hint">{{ child.amounts.bookHint }}</text>
</view> </view>
</view> </view>
<view class="loc-detail__row-side"> <view class="loc-detail__row-side">
@ -428,6 +429,13 @@ export default {
font-weight: 600; font-weight: 600;
} }
/* 另一种账面口径提示(静态看当前库存 / 普通看基准快照) */
.loc-detail__row-hint {
margin-right: 20rpx;
font-size: 26rpx;
color: #b8811a;
}
.loc-detail__row-diff--gain { .loc-detail__row-diff--gain {
color: #18a058; color: #18a058;
} }

View File

@ -15,6 +15,7 @@
class="record-card__type" class="record-card__type"
:class="item.typeClass" :class="item.typeClass"
>{{ item.typeLabel }}</text> >{{ item.typeLabel }}</text>
<text v-if="item.isStatic" class="record-card__type record-card__type--static">静态</text>
</view> </view>
<!-- 第三行:左(创建人 / 创建时间)· 右(进度 / 状态) --> <!-- 第三行:左(创建人 / 创建时间)· 右(进度 / 状态) -->
<view class="record-card__body"> <view class="record-card__body">
@ -111,6 +112,11 @@ export default {
background: #e8f7ee; background: #e8f7ee;
} }
.record-card__type--static {
color: #d46b08;
background: #fff4e6;
}
/* 第三行:左右结构 */ /* 第三行:左右结构 */
.record-card__body { .record-card__body {
margin-top: 20rpx; margin-top: 20rpx;

View File

@ -22,6 +22,10 @@
<text class="summary-panel__label">盘点方式</text> <text class="summary-panel__label">盘点方式</text>
<text class="summary-panel__value">{{ info.modeText || '--' }}</text> <text class="summary-panel__value">{{ info.modeText || '--' }}</text>
</view> </view>
<view v-if="info.isStaticText" class="summary-panel__row">
<text class="summary-panel__label">盘点性质</text>
<text class="summary-panel__value">{{ info.isStaticText }}</text>
</view>
<view class="summary-panel__row"> <view class="summary-panel__row">
<text class="summary-panel__label">状态</text> <text class="summary-panel__label">状态</text>
<text class="summary-panel__value" :class="info.statusClass">{{ info.statusText || '--' }}</text> <text class="summary-panel__value" :class="info.statusClass">{{ info.statusText || '--' }}</text>

View File

@ -15,7 +15,7 @@
<!-- 行级数量(明盘) --> <!-- 行级数量(明盘) -->
<view v-if="row.amount" class="work-card__amount"> <view v-if="row.amount" class="work-card__amount">
<view class="work-card__metric"> <view class="work-card__metric">
<text class="work-card__label">账面数量</text> <text class="work-card__label">{{ row.amount.systemLabel || '账面数量' }}</text>
<text class="work-card__value">{{ row.amount.systemText }}</text> <text class="work-card__value">{{ row.amount.systemText }}</text>
</view> </view>
<view class="work-card__metric"> <view class="work-card__metric">
@ -23,6 +23,7 @@
<text class="work-card__value">{{ row.amount.checkedText }}</text> <text class="work-card__value">{{ row.amount.checkedText }}</text>
</view> </view>
<text v-if="row.amount.diffText" class="work-card__diff" :class="row.amount.diffClass">{{ row.amount.diffText }}</text> <text v-if="row.amount.diffText" class="work-card__diff" :class="row.amount.diffClass">{{ row.amount.diffText }}</text>
<text v-if="row.amount.bookHint" class="work-card__book-hint">{{ row.amount.bookHint }}</text>
</view> </view>
<!-- 行级录入(库位任务的库位行 / 商品任务的商品行) --> <!-- 行级录入(库位任务的库位行 / 商品任务的商品行) -->
@ -66,9 +67,10 @@
<view class="work-child__side"> <view class="work-child__side">
<text v-if="child.statusText" class="work-card__tag" :class="child.statusClass">{{ child.statusText }}</text> <text v-if="child.statusText" class="work-card__tag" :class="child.statusClass">{{ child.statusText }}</text>
<text v-if="child.amount" class="work-child__amount"> <text v-if="child.amount" class="work-child__amount">
账面 {{ child.amount.systemText }} · 已盘 {{ child.amount.checkedText }} {{ child.amount.systemLabel || '账面' }} {{ child.amount.systemText }} · 已盘 {{ child.amount.checkedText }}
</text> </text>
<text v-else-if="child.quantityText !== ''" class="work-child__amount">实盘 {{ child.quantityText }}</text> <text v-else-if="child.quantityText !== ''" class="work-child__amount">实盘 {{ child.quantityText }}</text>
<text v-if="child.amount && child.amount.bookHint" class="work-child__hint">{{ child.amount.bookHint }}</text>
</view> </view>
<view v-if="child.unit" class="work-child__input"> <view v-if="child.unit" class="work-child__input">
<view class="work-input" :class="{ 'work-input--reported': child.unit.reported }"> <view class="work-input" :class="{ 'work-input--reported': child.unit.reported }">
@ -275,6 +277,14 @@ export default {
background: #f5f7fa; background: #f5f7fa;
} }
/* 另一种账面口径提示(静态看当前库存 / 普通看基准快照) */
.work-card__book-hint {
width: 100%;
margin-top: 6rpx;
font-size: 26rpx;
color: #b8811a;
}
.work-card__input-row { .work-card__input-row {
margin-top: 20rpx; margin-top: 20rpx;
display: flex; display: flex;
@ -389,6 +399,13 @@ export default {
color: #606266; color: #606266;
} }
.work-child__hint {
margin-top: 4rpx;
margin-left: 16rpx;
font-size: 26rpx;
color: #b8811a;
}
.work-child__side .work-card__amount { .work-child__side .work-card__amount {
margin-left: 16rpx; margin-left: 16rpx;
} }

View File

@ -284,6 +284,10 @@ export function normalizeCheckRecords(list, fallbackPage = 1) {
const id = firstValue(source, ['id', 'check_id', 'checkId', 'task_id', 'taskId']) const id = firstValue(source, ['id', 'check_id', 'checkId', 'task_id', 'taskId'])
|| `${fallbackPage}-${index + 1}`; || `${fallbackPage}-${index + 1}`;
const tone = statusTone(status); const tone = statusTone(status);
// 静态盘点标记(0.3.310):仅商品盘点任务有效,库位盘点恒为 0
const staticRaw = source.is_static !== undefined ? source.is_static : source.isStatic;
const hasStaticFlag = staticRaw !== undefined && staticRaw !== null && String(staticRaw).trim() !== '';
const isStatic = hasStaticFlag && toBool(staticRaw);
return { return {
id, id,
checkNo, checkNo,
@ -293,6 +297,9 @@ export function normalizeCheckRecords(list, fallbackPage = 1) {
typeText: composeType(typeValue, modeValue), typeText: composeType(typeValue, modeValue),
typeLabel: typeText(typeValue), typeLabel: typeText(typeValue),
typeClass: typeTone(typeValue) ? `record-card__type--${typeTone(typeValue)}` : '', typeClass: typeTone(typeValue) ? `record-card__type--${typeTone(typeValue)}` : '',
isStatic,
hasStaticFlag,
isStaticText: hasStaticFlag ? (isStatic ? '静态' : '') : '',
operator, operator,
progressText, progressText,
status, status,
@ -326,6 +333,10 @@ export function normalizeCheckTaskInfo(check, storeNameFallback = '') {
const creatorName = firstValue(source, ['creator_name', 'creatorName', 'creator']); const creatorName = firstValue(source, ['creator_name', 'creatorName', 'creator']);
const remark = firstValue(source, ['remark']); const remark = firstValue(source, ['remark']);
const tone = statusTone(status); const tone = statusTone(status);
// 静态盘点标记(0.3.310):detail/workData 的 check 均返回;库位盘点恒为 0
const staticRaw = source.is_static !== undefined ? source.is_static : source.isStatic;
const hasStaticFlag = staticRaw !== undefined && staticRaw !== null && String(staticRaw).trim() !== '';
const isStatic = hasStaticFlag && toBool(staticRaw);
return { return {
id, id,
checkNo, checkNo,
@ -348,6 +359,9 @@ export function normalizeCheckTaskInfo(check, storeNameFallback = '') {
creatorId, creatorId,
creatorName, creatorName,
remark, remark,
isStatic,
hasStaticFlag,
isStaticText: hasStaticFlag ? (isStatic ? '静态盘点' : '普通盘点') : '',
startTimeText: formatDateTime(firstValue(source, ['start_time', 'startTime'])), startTimeText: formatDateTime(firstValue(source, ['start_time', 'startTime'])),
endTimeText: formatDateTime(firstValue(source, ['end_time', 'endTime'])), endTimeText: formatDateTime(firstValue(source, ['end_time', 'endTime'])),
createTimeText: formatDateTime(firstValue(source, ['created_at', 'createdAt', 'create_time', 'createTime'])), createTimeText: formatDateTime(firstValue(source, ['created_at', 'createdAt', 'create_time', 'createTime'])),
@ -492,6 +506,74 @@ export function isOpenCheckMode(mode) {
return String(mode || '').trim().toLowerCase() === 'open'; return String(mode || '').trim().toLowerCase() === 'open';
} }
/** 静态盘点标记归一化(兼容 1/'1'/true) */
export function isStaticCheck(value) {
return toBool(value);
}
/**
* 账面来源归一化(0.3.318):
* snapshot = 明细快照(静态盘点冻结基准);storage = 当前库存 wms_storage(普通盘点实时账面)
*/
export function normalizeBookSource(bookSource, isStatic) {
const key = String(bookSource || '').trim().toLowerCase();
if (key === 'snapshot' || key === 'storage') return key;
return toBool(isStatic) ? 'snapshot' : 'storage';
}
/**
* 从作业行读取 0.3.318 账面字段(兼容驼峰)
* storage_quantity=当前 storage 账面;snapshot_quantity=明细快照;is_static/book_source=口径来源
*/
function pickBookMeta(source, fallbackIsStatic) {
const obj = source && typeof source === 'object' ? source : {};
const storageRaw = obj.storage_quantity !== undefined ? obj.storage_quantity : obj.storageQuantity;
const snapshotRaw = obj.snapshot_quantity !== undefined ? obj.snapshot_quantity : obj.snapshotQuantity;
const staticRaw = obj.is_static !== undefined ? obj.is_static : obj.isStatic;
const bookRaw = obj.book_source !== undefined ? obj.book_source : obj.bookSource;
const hasStaticFlag = staticRaw !== undefined && staticRaw !== null && String(staticRaw).trim() !== '';
// 行级未带 is_static 时(如 space 视图 goods)用任务级标记兜底,避免静态任务误显「当前库存」
const hasFallback = typeof fallbackIsStatic === 'boolean';
const resolvedStatic = hasStaticFlag ? staticRaw : (hasFallback ? fallbackIsStatic : undefined);
return {
storageQuantity: toNumberOrNull(storageRaw),
snapshotQuantity: toNumberOrNull(snapshotRaw),
isStatic: hasStaticFlag || hasFallback ? toBool(resolvedStatic) : false,
hasStaticFlag: hasStaticFlag || hasFallback,
bookSource: normalizeBookSource(bookRaw, resolvedStatic)
};
}
/**
* 账面口径元信息:system_quantity 为本次参与差异计算的账面(静态=快照、普通=当前库存),
* storage_quantity / snapshot_quantity 为另一口径参考值,两者不一致时给出提示文案。
*/
export function resolveBookMeta(systemQuantity, options = {}) {
const sys = toNumberOrNull(systemQuantity);
const storage = toNumberOrNull(options.storageQuantity);
const snapshot = toNumberOrNull(options.snapshotQuantity);
const source = normalizeBookSource(options.bookSource, options.isStatic);
const sourceText = source === 'snapshot' ? '快照' : '当前库存';
let hint = '';
if (sys !== null) {
if (source === 'snapshot') {
// 静态盘点:账面取快照,若当前库存已偏离(理论上盘点期间禁止出入库)则提示
if (storage !== null && storage !== sys) hint = `当前库存 ${storage}`;
} else if (snapshot !== null && snapshot !== sys) {
// 普通盘点:账面取当前库存,补充展示审核时的基准快照
hint = `基准快照 ${snapshot}`;
}
}
return {
bookSource: source,
bookSourceText: sourceText,
systemLabel: `账面(${sourceText})`,
bookHint: hint,
storageQuantity: storage,
snapshotQuantity: snapshot
};
}
/** /**
* 作业解析视图: * 作业解析视图:
* 库位任务(location)一律 location;商品任务(goods/store)默认 space,isGoods=true 时为 goods * 库位任务(location)一律 location;商品任务(goods/store)默认 space,isGoods=true 时为 goods
@ -514,13 +596,15 @@ function toBool(value) {
return key === '1' || key === 'true'; return key === '1' || key === 'true';
} }
/** 库位明细是否已盘:有记录ID(record_ids)、盘点人或上报时间之一即视为已盘 */ /** 库位明细是否已盘:有记录ID(record_ids)、盘点人、上报时间或状态为 checked 之一即视为已盘 */
function isCheckedLocation(loc) { function isCheckedLocation(loc) {
if (!loc || typeof loc !== 'object') return false; if (!loc || typeof loc !== 'object') return false;
const ids = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : []; const ids = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : [];
return ids.length > 0 return ids.length > 0
|| !!firstValue(loc, ['checked_at', 'checkedAt']) || !!firstValue(loc, ['checked_at', 'checkedAt'])
|| !!firstValue(loc, ['checker_name', 'checkerName']); || !!firstValue(loc, ['checker_name', 'checkerName'])
|| String(loc.status || '').trim().toLowerCase() === 'checked'
|| toBool(loc.is_checked);
} }
/** 宫格格子里显示的短库位号(取末两段,如 E07-01-02-01 → 02-01) */ /** 宫格格子里显示的短库位号(取末两段,如 E07-01-02-01 → 02-01) */
@ -537,11 +621,14 @@ function toNumberString(value) {
return num === null ? '' : String(num); return num === null ? '' : String(num);
} }
/** 明盘数量块(盲盘返回 null,不展示任何数量) */ /** 明盘数量块(盲盘返回 null,不展示任何数量)
function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open) { * meta(0.3.318):storageQuantity / snapshotQuantity / isStatic / bookSource ——
* 账面 systemText 始终取接口 system_quantity(静态=快照、普通=当前库存),另一种口径仅作提示 */
function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open, meta = {}) {
if (!open) return null; if (!open) return null;
const sys = toNumberOrNull(systemQuantity); const sys = toNumberOrNull(systemQuantity);
const chk = toNumberOrNull(checkedQuantity); const chk = toNumberOrNull(checkedQuantity);
const book = resolveBookMeta(sys, meta);
// 差异统一以「实盘 - 账面」为准,避免后端 diff_quantity 与账面/实盘不一致(如未盘项返回 0) // 差异统一以「实盘 - 账面」为准,避免后端 diff_quantity 与账面/实盘不一致(如未盘项返回 0)
let diff = null; let diff = null;
if (sys !== null && chk !== null) { if (sys !== null && chk !== null) {
@ -558,7 +645,14 @@ function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open) {
diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')), diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')),
diff, diff,
diffTone, diffTone,
diffClass: diff === null ? '' : (diff > 0 ? 'work-card__diff--gain' : (diff < 0 ? 'work-card__diff--loss' : 'work-card__diff--match')) diffClass: diff === null ? '' : (diff > 0 ? 'work-card__diff--gain' : (diff < 0 ? 'work-card__diff--loss' : 'work-card__diff--match')),
// 账面口径(0.3.318):标签 + 另一口径提示
systemLabel: book.systemLabel,
bookSource: book.bookSource,
bookSourceText: book.bookSourceText,
bookHint: book.bookHint,
storageQuantity: book.storageQuantity,
snapshotQuantity: book.snapshotQuantity
}; };
} }
@ -583,7 +677,6 @@ function buildWorkUnit(detailId, location, currentQuantity, reported, stockId, s
* 构造 check.report 入参(按 https 文档口径) * 构造 check.report 入参(按 https 文档口径)
* - space_id 必传(wms_location_space.id,兼容 spaceId/location_id/locationId 写法):库位一律按库位ID落库 * - space_id 必传(wms_location_space.id,兼容 spaceId/location_id/locationId 写法):库位一律按库位ID落库
* - location 降级为可选一致性校验(与 space_id 对应编码不一致返回 400) * - location 降级为可选一致性校验(与 space_id 对应编码不一致返回 400)
* - detail_id 可选:库位明细行必传;商品模式(goods 视图行不返回明细ID)只传 id + stock_id + space_id,服务端反查明细
* - 商品明细行:stock_id 固定为明细商品(与 space_id 一起定位「库位+商品」) * - 商品明细行:stock_id 固定为明细商品(与 space_id 一起定位「库位+商品」)
* - 库位明细行:必须带商品(stock_id 或 barcode 至少一项),space_id 对应编码须等于明细库位编码 * - 库位明细行:必须带商品(stock_id 或 barcode 至少一项),space_id 对应编码须等于明细库位编码
* - 未知商品:只传 barcode(item_name 可选,缺省为条码) * - 未知商品:只传 barcode(item_name 可选,缺省为条码)
@ -591,16 +684,13 @@ function buildWorkUnit(detailId, location, currentQuantity, reported, stockId, s
*/ */
export function buildReportParams(taskId, payload = {}) { export function buildReportParams(taskId, payload = {}) {
const isEmpty = !!payload.isEmpty; const isEmpty = !!payload.isEmpty;
const detailId = Number(payload.detailId);
const params = { const params = {
id: Number(taskId), id: Number(taskId),
quantity: isEmpty ? 0 : Number(payload.quantity) quantity: isEmpty ? 0 : Number(payload.quantity)
}; };
const detailIdRaw = payload.detailId !== undefined && payload.detailId !== null && String(payload.detailId).trim() !== '' // detail_id 可选(0.3.309):商品钻取上报可改传 stock_id + space_id 由服务端反查明细
? payload.detailId if (Number.isFinite(detailId) && detailId > 0) params.detail_id = detailId;
: payload.detail_id;
if (detailIdRaw !== undefined && detailIdRaw !== null && String(detailIdRaw).trim() !== '') {
params.detail_id = Number(detailIdRaw);
}
// space_id 必传:兼容 spaceId/location_id/locationId 写法(取回接口 rows[].space_id、rows[].id、locations[].space_id 可直接回传) // space_id 必传:兼容 spaceId/location_id/locationId 写法(取回接口 rows[].space_id、rows[].id、locations[].space_id 可直接回传)
const spaceId = payload.spaceId !== undefined && payload.spaceId !== null && String(payload.spaceId).trim() !== '' const spaceId = payload.spaceId !== undefined && payload.spaceId !== null && String(payload.spaceId).trim() !== ''
? payload.spaceId ? payload.spaceId
@ -635,7 +725,7 @@ function joinText(parts, sep = ' · ') {
} }
/** space 视图:行=库位,goods 为该库位下的任务商品(商品任务默认视图;作业列表按库位宫格展示,仅统计不可点击) */ /** space 视图:行=库位,goods 为该库位下的任务商品(商品任务默认视图;作业列表按库位宫格展示,仅统计不可点击) */
function normalizeSpaceWorkRow(item, index, open) { function normalizeSpaceWorkRow(item, index, open, options = {}) {
const source = item && typeof item === 'object' ? item : {}; const source = item && typeof item === 'object' ? item : {};
const spaceCode = firstValue(source, ['space_code', 'spaceCode']) || `#${index + 1}`; const spaceCode = firstValue(source, ['space_code', 'spaceCode']) || `#${index + 1}`;
// space 视图行:space_id 与 location_id 均等于既有 id(wms_location_space.id) // space 视图行:space_id 与 location_id 均等于既有 id(wms_location_space.id)
@ -646,13 +736,20 @@ function normalizeSpaceWorkRow(item, index, open) {
const detailId = firstValue(good, ['detail_id', 'detailId']); const detailId = firstValue(good, ['detail_id', 'detailId']);
const checkedRaw = good.checked_quantity !== undefined ? good.checked_quantity : good.checkedQuantity; const checkedRaw = good.checked_quantity !== undefined ? good.checked_quantity : good.checkedQuantity;
const done = String(good.status || '').trim().toLowerCase() === 'checked'; const done = String(good.status || '').trim().toLowerCase() === 'checked';
const bookMeta = pickBookMeta(good, options.isStatic);
return { return {
key: `${spaceCode}-${detailId || goodIndex + 1}`, key: `${spaceCode}-${detailId || goodIndex + 1}`,
title: firstValue(good, ['item_name', 'itemName']) || '--', title: firstValue(good, ['item_name', 'itemName']) || '--',
subtitle: joinText([firstValue(good, ['barcode']), firstValue(good, ['spec']), storeNameValue(good)]), subtitle: joinText([firstValue(good, ['barcode']), firstValue(good, ['spec']), storeNameValue(good)]),
statusText: done ? '已盘' : '未盘', statusText: done ? '已盘' : '未盘',
statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo', statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
amount: buildWorkAmount(good.system_quantity !== undefined ? good.system_quantity : good.systemQuantity, checkedRaw, null, open), amount: buildWorkAmount(
good.system_quantity !== undefined ? good.system_quantity : good.systemQuantity,
checkedRaw,
null,
open,
bookMeta
),
quantityText: '', quantityText: '',
unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId']), rowSpaceId) unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId']), rowSpaceId)
}; };
@ -699,12 +796,10 @@ function normalizeSpaceWorkRow(item, index, open) {
}; };
} }
/** goods 视图:行=商品(后端不再返回行级 detail_id,跳转/上报改用 stock_id),locations 为按库位聚合的作业记录(商品任务的 is_goods=true) */ /** goods 视图:行=商品,locations 为按库位聚合的作业记录(商品任务的 is_goods=true) */
function normalizeGoodsWorkRow(item, index, open) { function normalizeGoodsWorkRow(item, index, open, options = {}) {
const source = item && typeof item === 'object' ? item : {}; const source = item && typeof item === 'object' ? item : {};
const detailId = firstValue(source, ['detail_id', 'detailId']); const detailId = firstValue(source, ['detail_id', 'detailId']);
// 行级明细ID 已不再返回,商品模式以 stock_id 定位(workDataDetail / report 均传 id + stock_id)
const stockId = firstValue(source, ['stock_id', 'stockId']);
const checkedRaw = source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity; const checkedRaw = source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity;
const rawLocations = Array.isArray(source.locations) ? source.locations : []; const rawLocations = Array.isArray(source.locations) ? source.locations : [];
const children = rawLocations.map((row, locIndex) => { const children = rawLocations.map((row, locIndex) => {
@ -727,6 +822,11 @@ function normalizeGoodsWorkRow(item, index, open) {
}; };
}); });
const checkedNumber = toNumberOrNull(checkedRaw); const checkedNumber = toNumberOrNull(checkedRaw);
// 账面口径(0.3.318):is_static/book_source/storage_quantity/snapshot_quantity
const bookMeta = pickBookMeta(source, options.isStatic);
const stockIdValue = firstValue(source, ['stock_id', 'stockId']);
// 行唯一键:0.3.309 起 goods 视图行不再返回 detail_id,优先用 stock_id
const rowKey = stockIdValue || detailId || `${index + 1}`;
// 行级商品主图(goods 视图行级 images 仍为商品主图) // 行级商品主图(goods 视图行级 images 仍为商品主图)
const imageList = Array.isArray(source.images) ? source.images.filter(Boolean) : []; const imageList = Array.isArray(source.images) ? source.images.filter(Boolean) : [];
// 作业记录条数(locations[].record_ids 汇总)——已盘判断与概况展示用 // 作业记录条数(locations[].record_ids 汇总)——已盘判断与概况展示用
@ -739,10 +839,10 @@ function normalizeGoodsWorkRow(item, index, open) {
const done = status === 'checked' || recordCount > 0 || (checkedNumber !== null && checkedNumber > 0); const done = status === 'checked' || recordCount > 0 || (checkedNumber !== null && checkedNumber > 0);
const reported = done; const reported = done;
return { return {
key: `goods-${stockId || index + 1}`, key: `goods-${rowKey}`,
view: 'goods', view: 'goods',
detailId: detailId ? String(detailId) : '', detailId: detailId ? String(detailId) : '',
stockId: stockId || '', stockId: stockIdValue === '' || stockIdValue === undefined || stockIdValue === null ? '' : String(stockIdValue),
title: firstValue(source, ['item_name', 'itemName']) || '--', title: firstValue(source, ['item_name', 'itemName']) || '--',
subtitle: joinText([firstValue(source, ['barcode']), firstValue(source, ['spec']), storeNameValue(source)]), subtitle: joinText([firstValue(source, ['barcode']), firstValue(source, ['spec']), storeNameValue(source)]),
statusText: done ? '已盘' : '未盘', statusText: done ? '已盘' : '未盘',
@ -752,11 +852,18 @@ function normalizeGoodsWorkRow(item, index, open) {
source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity, source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity,
done ? checkedRaw : null, done ? checkedRaw : null,
done ? (source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity) : null, done ? (source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity) : null,
open open,
bookMeta
), ),
quantityText: '', quantityText: '',
children, children,
unit: buildWorkUnit(detailId, '', checkedRaw, reported, stockId), unit: buildWorkUnit(detailId, '', checkedRaw, reported, firstValue(source, ['stock_id', 'stockId'])),
// 账面口径字段(商品作业页 / 商品卡片展示用)
isStatic: bookMeta.isStatic,
hasStaticFlag: bookMeta.hasStaticFlag,
bookSource: bookMeta.bookSource,
storageQuantity: bookMeta.storageQuantity,
snapshotQuantity: bookMeta.snapshotQuantity,
// 列表行(CountGoodsCard)与商品作业页(概况带入路由)用的字段:一行一个商品,操作剥离到操作页 // 列表行(CountGoodsCard)与商品作业页(概况带入路由)用的字段:一行一个商品,操作剥离到操作页
images: imageList, images: imageList,
image: imageList[0] || '', image: imageList[0] || '',
@ -865,14 +972,14 @@ function normalizeLocationWorkRow(item, index, open) {
}; };
} }
/** 作业数据行归一化(view: space / goods / location) */ /** 作业数据行归一化(view: space / goods / location;options.isStatic 为任务级静态标记兜底) */
export function normalizeWorkRows(rows, view, mode) { export function normalizeWorkRows(rows, view, mode, options = {}) {
if (!Array.isArray(rows)) return []; if (!Array.isArray(rows)) return [];
const open = isOpenCheckMode(mode); const open = isOpenCheckMode(mode);
return rows.map((item, index) => { return rows.map((item, index) => {
if (view === 'goods') return normalizeGoodsWorkRow(item, index, open); if (view === 'goods') return normalizeGoodsWorkRow(item, index, open, options);
if (view === 'location') return normalizeLocationWorkRow(item, index, open); if (view === 'location') return normalizeLocationWorkRow(item, index, open);
return normalizeSpaceWorkRow(item, index, open); return normalizeSpaceWorkRow(item, index, open, options);
}); });
} }
@ -890,9 +997,9 @@ export function normalizeLocationWorkDetail(payload, mode) {
* 单库位作业数据归一化(stock.check.workDataSpaceDetails,rows 只有该库位一行) * 单库位作业数据归一化(stock.check.workDataSpaceDetails,rows 只有该库位一行)
* 返回结构与 workData space 视图单行一致;rows 为空时返回 null。 * 返回结构与 workData space 视图单行一致;rows 为空时返回 null。
*/ */
export function normalizeSpaceWorkDetail(rows, mode) { export function normalizeSpaceWorkDetail(rows, mode, options = {}) {
if (!Array.isArray(rows) || !rows.length) return null; if (!Array.isArray(rows) || !rows.length) return null;
return normalizeWorkRows(rows.slice(0, 1), 'space', mode)[0] || null; return normalizeWorkRows(rows.slice(0, 1), 'space', mode, options)[0] || null;
} }
/** /**
@ -951,25 +1058,40 @@ export function normalizeGoodsRecords(rows) {
/** /**
* 单条明细的作业数据(stock.check.workDataDetail)→ 商品明细概况 * 单条明细的作业数据(stock.check.workDataDetail)→ 商品明细概况
* 用于商品作业页:传 id + stock_id(商品钻取),明细由接口反查得出 * 兼容两种结构:
* 商品钻取返回:check_id/stock_id/item_code/item_name/spec/store_id/store_name/barcode/images(商品主图) * - 商品钻取(0.3.309+):{ check_id, stock_id, ..., summary{ system_quantity/checked_quantity/diff_quantity }, rows[] }
* + summary(仅明盘:system_quantity 账面快照合计/checked_quantity 实盘合计/diff_quantity/is_diff) * rows[] 每个库位一行:detail_id/space_id/location_code/system_quantity/checked_quantity/diff_quantity/record_ids/...
* + rows[](每库位:detail_id/location_code/checked_at/checker_name/record_ids/images, * 0.3.318 起顶层增加 is_static/book_source,rows[] 增加 storage_quantity(另有 snapshot_quantity)
* 明盘另含 system_quantity 当前账面/snapshot_quantity 账面快照/checked_quantity 实盘/diff_quantity) * - 旧单行结构:顶层 system_quantity/checked_quantity/diff_quantity + locations[](每库位 quantity)
* 兼容旧口径(扁平 system_quantity/checked_quantity + locations[]);库位行(商品信息在 goods 子列表里)取 goods 首项兜底 * 库位行(商品信息在 goods 子列表里)也兼容:信息取 goods 首项兜底
*/ */
export function normalizeGoodsDetailInfo(row, mode) { export function normalizeGoodsDetailInfo(row, mode, options = {}) {
const source = row && typeof row === 'object' && !Array.isArray(row) ? row : {}; const source = row && typeof row === 'object' && !Array.isArray(row) ? row : {};
if (!Object.keys(source).length) return null; if (!Object.keys(source).length) return null;
const summary = source.summary && typeof source.summary === 'object' && !Array.isArray(source.summary) ? source.summary : {}; const summarySource = source.summary && typeof source.summary === 'object' && !Array.isArray(source.summary)
? source.summary : null;
const drillRows = Array.isArray(source.rows) ? source.rows : null;
const isDrillLayout = !!summarySource || !!drillRows;
// 商品级合计:钻取结构取 summary,旧结构取顶层
const systemRaw = isDrillLayout
? (summarySource ? summarySource.system_quantity : undefined)
: (source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity);
const checkedRaw = isDrillLayout
? (summarySource ? summarySource.checked_quantity : undefined)
: (source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity);
const diffRaw = isDrillLayout
? (summarySource ? summarySource.diff_quantity : undefined)
: (source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity);
// 行内只要带了任一数量字段就按明盘口径构建(任务 mode 可能没取到/缺失,别把盈亏丢掉) // 行内只要带了任一数量字段就按明盘口径构建(任务 mode 可能没取到/缺失,别把盈亏丢掉)
const quantityFields = [ const quantityFields = [
systemRaw, checkedRaw, diffRaw,
source.system_quantity, source.checked_quantity, source.diff_quantity, source.system_quantity, source.checked_quantity, source.diff_quantity,
source.systemQuantity, source.checkedQuantity, source.diffQuantity, source.systemQuantity, source.checkedQuantity, source.diffQuantity
summary.system_quantity, summary.checked_quantity, summary.diff_quantity
]; ];
const hasQuantity = quantityFields.some(value => value !== undefined && value !== null && value !== ''); const hasQuantity = quantityFields.some(value => value !== undefined && value !== null && value !== '');
const open = isOpenCheckMode(mode) || hasQuantity; const open = isOpenCheckMode(mode) || hasQuantity;
// 账面口径(0.3.318):顶层 is_static/book_source
const bookMeta = pickBookMeta(source, options.isStatic);
// 库位行形态:商品信息/图片取 goods 首项兜底 // 库位行形态:商品信息/图片取 goods 首项兜底
const firstGoods = Array.isArray(source.goods) && source.goods.length ? (source.goods[0] || {}) : {}; const firstGoods = Array.isArray(source.goods) && source.goods.length ? (source.goods[0] || {}) : {};
const pickText = keys => firstValue(source, keys) || firstValue(firstGoods, keys) || ''; const pickText = keys => firstValue(source, keys) || firstValue(firstGoods, keys) || '';
@ -983,10 +1105,27 @@ export function normalizeGoodsDetailInfo(row, mode) {
// 库位明细(每库位一行:账面 / 实盘 / 盈亏),顺便汇总记录条数与最近上报时间 // 库位明细(每库位一行:账面 / 实盘 / 盈亏),顺便汇总记录条数与最近上报时间
// 未盘点库位是任务范围占位:保留展示以便看到待盘库位,但实盘按 -- 处理、不参与盈亏、不计入记录条数 // 未盘点库位是任务范围占位:保留展示以便看到待盘库位,但实盘按 -- 处理、不参与盈亏、不计入记录条数
// 商品钻取用 rows,旧口径用 locations const rawLocations = isDrillLayout
const rawLocations = Array.isArray(source.rows) ? (drillRows || [])
? source.rows
: (Array.isArray(source.locations) ? source.locations : []); : (Array.isArray(source.locations) ? source.locations : []);
// 商品级另一种口径合计(含未盘库位,避免账面/当前库存合计只统计已盘行)
const rowBookTotals = rawLocations.reduce((acc, item) => {
const book = pickBookMeta(item);
if (book.storageQuantity !== null) acc.storage = (acc.storage === null ? 0 : acc.storage) + book.storageQuantity;
if (book.snapshotQuantity !== null) acc.snapshot = (acc.snapshot === null ? 0 : acc.snapshot) + book.snapshotQuantity;
return acc;
}, { storage: null, snapshot: null });
const pageDetailId = pickText(['detail_id', 'detailId']);
// 全部库位(含未盘占位行)的明细ID映射:商品作业页按库位上报时定位 detail_id
const allLocations = rawLocations.map((item, index) => {
const loc = item && typeof item === 'object' ? item : {};
return {
key: `all-loc-${index + 1}`,
detailId: firstValue(loc, ['detail_id', 'detailId']) || pageDetailId,
spaceId: firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']) || '',
locationCode: firstValue(loc, ['location_code', 'locationCode']) || ''
};
});
let recordCount = 0; let recordCount = 0;
let lastCheckedAt = ''; let lastCheckedAt = '';
const locations = rawLocations.map((item, index) => { const locations = rawLocations.map((item, index) => {
@ -995,26 +1134,31 @@ export function normalizeGoodsDetailInfo(row, mode) {
const locationCode = firstValue(loc, ['location_code', 'locationCode']) || ''; const locationCode = firstValue(loc, ['location_code', 'locationCode']) || '';
const locationName = firstValue(loc, ['location_name', 'locationName']) || ''; const locationName = firstValue(loc, ['location_name', 'locationName']) || '';
const spaceId = firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']); const spaceId = firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']);
// 钻取结构每个库位有自己的明细ID(report 按 detail_id + stock_id + space_id 定位)
const rowDetailId = firstValue(loc, ['detail_id', 'detailId']) || pageDetailId;
const recordIds = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : []; const recordIds = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : [];
// 账面:优先 snapshot_quantity(盘点开始时的账面快照,与 summary 口径一致),旧口径用 system_quantity const rowBook = pickBookMeta(loc);
const systemRaw = loc.snapshot_quantity !== undefined && loc.snapshot_quantity !== null const systemQuantity = toNumberOrNull(loc.system_quantity !== undefined ? loc.system_quantity : loc.systemQuantity);
? loc.snapshot_quantity // 实盘:旧结构为 quantity,钻取结构为 checked_quantity;未盘库位后端可能回 0,直接展示会算出「账实相符」,因此按未盘置空
: (loc.system_quantity !== undefined ? loc.system_quantity : loc.systemQuantity); const quantity = checked ? toNumberOrNull(
const systemQuantity = toNumberOrNull(systemRaw); loc.quantity !== undefined
// 实盘:商品钻取用 checked_quantity,旧口径用 quantity;未盘库位后端可能回 0,直接展示会算出「账实相符」,因此按未盘置空 ? loc.quantity
const quantityRaw = loc.checked_quantity !== undefined && loc.checked_quantity !== null : (loc.checked_quantity !== undefined ? loc.checked_quantity : loc.checkedQuantity)
? loc.checked_quantity ) : null;
: (loc.quantity !== undefined && loc.quantity !== null ? loc.quantity : loc.checkedQuantity);
const quantity = checked ? toNumberOrNull(quantityRaw) : null;
const checkedAt = firstValue(loc, ['checked_at', 'checkedAt']); const checkedAt = firstValue(loc, ['checked_at', 'checkedAt']);
const checkerName = firstValue(loc, ['checker_name', 'checkerName']); const checkerName = firstValue(loc, ['checker_name', 'checkerName']);
recordCount += recordIds.length; const rowBookInfo = resolveBookMeta(systemQuantity, rowBook);
if (checkedAt && checkedAt > lastCheckedAt) lastCheckedAt = checkedAt; if (checked) {
const diff = checked && systemQuantity !== null && quantity !== null ? quantity - systemQuantity : null; recordCount += recordIds.length;
if (checkedAt && checkedAt > lastCheckedAt) lastCheckedAt = checkedAt;
}
const diff = systemQuantity === null || quantity === null ? null : quantity - systemQuantity;
return { return {
key: `loc-${locationCode || index + 1}`, key: `loc-${locationCode || index + 1}`,
// 该库位是否已盘(占位行 checked=false:实盘 --、不可删除) // 该库位是否已盘(未盘占位行 checked=false:实盘 --、不可删除)
checked, checked,
// 该库位对应的盘点明细ID(多库位商品上报时按行回传)
detailId: rowDetailId,
// 左滑删除用:整库位的记录 ID 列表(recordDelete 支持数组) // 左滑删除用:整库位的记录 ID 列表(recordDelete 支持数组)
recordIds, recordIds,
recordId: recordIds.length === 1 ? recordIds[0] : '', recordId: recordIds.length === 1 ? recordIds[0] : '',
@ -1024,6 +1168,9 @@ export function normalizeGoodsDetailInfo(row, mode) {
locationId: spaceId || '', locationId: spaceId || '',
systemQuantity, systemQuantity,
quantity, quantity,
// 账面口径(0.3.318):当前 storage 账面 / 明细快照
storageQuantity: rowBook.storageQuantity,
snapshotQuantity: rowBook.snapshotQuantity,
title: locationName || locationCode || '未指定库位', title: locationName || locationCode || '未指定库位',
subtitle: joinText([ subtitle: joinText([
checkerName ? `盘点人 ${checkerName}` : '', checkerName ? `盘点人 ${checkerName}` : '',
@ -1039,6 +1186,8 @@ export function normalizeGoodsDetailInfo(row, mode) {
// 明细面板展示:账面 / 实盘 / 盈亏(账面>0 时高亮,方便找账面库位) // 明细面板展示:账面 / 实盘 / 盈亏(账面>0 时高亮,方便找账面库位)
amounts: systemQuantity === null && quantity === null ? null : { amounts: systemQuantity === null && quantity === null ? null : {
systemText: systemQuantity === null ? '--' : String(systemQuantity), systemText: systemQuantity === null ? '--' : String(systemQuantity),
systemLabel: rowBookInfo.systemLabel,
bookHint: rowBookInfo.bookHint,
checkedText: quantity === null ? '--' : String(quantity), checkedText: quantity === null ? '--' : String(quantity),
diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')), diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')),
diffTone: diff === null ? '' : (diff > 0 ? 'gain' : (diff < 0 ? 'loss' : 'match')), diffTone: diff === null ? '' : (diff > 0 ? 'gain' : (diff < 0 ? 'loss' : 'match')),
@ -1048,18 +1197,15 @@ export function normalizeGoodsDetailInfo(row, mode) {
}; };
}); });
const systemQuantityRaw = summary.system_quantity !== undefined && summary.system_quantity !== null const summaryBook = resolveBookMeta(toNumberOrNull(systemRaw), {
? summary.system_quantity isStatic: bookMeta.isStatic,
: (source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity); bookSource: bookMeta.bookSource,
const checkedQuantityRaw = summary.checked_quantity !== undefined && summary.checked_quantity !== null storageQuantity: bookMeta.storageQuantity !== null ? bookMeta.storageQuantity : rowBookTotals.storage,
? summary.checked_quantity snapshotQuantity: bookMeta.snapshotQuantity !== null ? bookMeta.snapshotQuantity : rowBookTotals.snapshot
: (source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity); });
const diffQuantityRaw = summary.diff_quantity !== undefined && summary.diff_quantity !== null
? summary.diff_quantity
: (source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity);
return { return {
detailId: pickText(['detail_id', 'detailId']), detailId: pageDetailId || (locations[0] && locations[0].detailId) || '',
stockId: stockIdRaw === undefined || stockIdRaw === null ? '' : String(stockIdRaw), stockId: stockIdRaw === undefined || stockIdRaw === null ? '' : String(stockIdRaw),
itemName: pickText(['item_name', 'itemName']), itemName: pickText(['item_name', 'itemName']),
itemCode: pickText(['item_code', 'itemCode']), itemCode: pickText(['item_code', 'itemCode']),
@ -1069,10 +1215,24 @@ export function normalizeGoodsDetailInfo(row, mode) {
images, images,
image: images[0] || '', image: images[0] || '',
status: String(source.status || '').trim().toLowerCase(), status: String(source.status || '').trim().toLowerCase(),
systemQuantity: toNumberOrNull(systemQuantityRaw), // 账面口径(0.3.318):静态盘点取快照、普通盘点取当前库存;另一口径仅作提示
checkedQuantity: toNumberOrNull(checkedQuantityRaw), isStatic: bookMeta.isStatic,
amount: buildWorkAmount(systemQuantityRaw, checkedQuantityRaw, diffQuantityRaw, open), hasStaticFlag: bookMeta.hasStaticFlag,
bookSource: bookMeta.bookSource,
bookSourceText: summaryBook.bookSourceText,
storageQuantity: summaryBook.storageQuantity,
snapshotQuantity: summaryBook.snapshotQuantity,
systemQuantity: toNumberOrNull(systemRaw),
checkedQuantity: toNumberOrNull(checkedRaw),
amount: buildWorkAmount(systemRaw, checkedRaw, diffRaw, open, {
isStatic: bookMeta.isStatic,
bookSource: bookMeta.bookSource,
storageQuantity: summaryBook.storageQuantity,
snapshotQuantity: summaryBook.snapshotQuantity
}),
locations, locations,
// 全部库位(含未盘)——仅用于按库位定位明细ID,不用于列表展示
allLocations,
recordCount, recordCount,
locationCodes: locations.map(item => item.locationCode).filter(Boolean), locationCodes: locations.map(item => item.locationCode).filter(Boolean),
checkers, checkers,

View File

@ -635,20 +635,21 @@ export default {
this._pendingWorkRefresh = true; this._pendingWorkRefresh = true;
uni.navigateTo({ url }); uni.navigateTo({ url });
}, },
// ===== 商品视图(goods):点击进入商品作业页(只传 task_id + stock_id,明细由服务端反查) ===== // ===== 商品视图(goods):点击进入商品作业页(0.3.309 起行内不再有 detail_id,优先按 stock_id 进入) =====
handleGoodsOpen(row) { handleGoodsOpen(row) {
if (!row || !this.taskId) return; if (!row || !this.taskId) return;
if (!row.stockId) { const params = [`task_id=${encodeURIComponent(this.taskId)}`];
uni.showToast({ title: '缺少商品库存ID', icon: 'none' }); if (row.detailId) {
params.push(`detail_id=${encodeURIComponent(row.detailId)}`);
} else if (row.stockId) {
params.push(`stock_id=${encodeURIComponent(row.stockId)}`);
} else {
uni.showToast({ title: '缺少盘点明细ID', icon: 'none' });
return; return;
} }
const params = [
`task_id=${encodeURIComponent(this.taskId)}`,
`stock_id=${encodeURIComponent(row.stockId)}`
].join('&');
// 从商品作业页返回后刷新列表(已盘状态/记录数已变化) // 从商品作业页返回后刷新列表(已盘状态/记录数已变化)
this._pendingWorkRefresh = true; this._pendingWorkRefresh = true;
uni.navigateTo({ url: `/pages/warehouse/inventoryCountGoods?${params}` }); uni.navigateTo({ url: `/pages/warehouse/inventoryCountGoods?${params.join('&')}` });
}, },
// 刷新/分页后保证存在有效选中项(无选中时不高亮任何格子) // 刷新/分页后保证存在有效选中项(无选中时不高亮任何格子)
ensureLocationSelection() { ensureLocationSelection() {
@ -692,7 +693,9 @@ export default {
this.taskInfo = normalizeCheckTaskInfo(payload.check, this.routeStoreName); this.taskInfo = normalizeCheckTaskInfo(payload.check, this.routeStoreName);
} }
const rows = extractListPayload(payload, response); const rows = extractListPayload(payload, response);
this.workList = normalizeWorkRows(rows, this.workView, this.taskInfo.mode); this.workList = normalizeWorkRows(rows, this.workView, this.taskInfo.mode, {
isStatic: this.taskInfo.hasStaticFlag ? this.taskInfo.isStatic : undefined
});
this.workTotal = resolveListTotal(payload, response, rows); this.workTotal = resolveListTotal(payload, response, rows);
const pageNo = Number(payload?.page); const pageNo = Number(payload?.page);
this.workPage = Number.isFinite(pageNo) && pageNo > 0 ? pageNo : targetPage; this.workPage = Number.isFinite(pageNo) && pageNo > 0 ? pageNo : targetPage;

View File

@ -54,9 +54,10 @@
</view> </view>
<text class="inv-goods-card__line">{{ goodsMetaText }}</text> <text class="inv-goods-card__line">{{ goodsMetaText }}</text>
<view class="inv-goods-card__metrics"> <view class="inv-goods-card__metrics">
<text v-if="systemQuantityValue !== null" class="inv-goods-card__metric">账面 {{ systemQuantityValue }}</text> <text v-if="systemQuantityValue !== null" class="inv-goods-card__metric">{{ systemLabel }} {{ systemQuantityValue }}</text>
<text class="inv-goods-card__metric">已盘 {{ checkedTotalText }}</text> <text class="inv-goods-card__metric">已盘 {{ checkedTotalText }}</text>
<text v-if="diffText" class="inv-goods-card__diff" :class="diffValueClass">{{ diffText }}</text> <text v-if="diffText" class="inv-goods-card__diff" :class="diffValueClass">{{ diffText }}</text>
<text v-if="bookHintText" class="inv-goods-card__hint">{{ bookHintText }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -124,6 +125,7 @@ import {
normalizeScanResult, normalizeScanResult,
extractObjectPayload, extractObjectPayload,
normalizeGoodsDetailInfo, normalizeGoodsDetailInfo,
isStaticCheck,
buildReportParams buildReportParams
} from './inventoryCount-comps/countModel.js'; } from './inventoryCount-comps/countModel.js';
@ -139,7 +141,14 @@ function EMPTY_GOODS_INFO() {
systemQuantity: null, systemQuantity: null,
checkedQuantity: null, checkedQuantity: null,
amount: null, amount: null,
// 账面口径(0.3.318):静态盘点取快照、普通盘点取当前库存
isStatic: false,
bookSource: '',
storageQuantity: null,
snapshotQuantity: null,
locations: [], locations: [],
// 全部库位(含未盘)的明细ID映射:按库位上报时定位 detail_id
allLocations: [],
recordCount: 0, recordCount: 0,
locationCodes: [], locationCodes: [],
lastCheckedAtText: '' lastCheckedAtText: ''
@ -155,7 +164,20 @@ function resolveSystemQuantity(goodsInfo) {
return sys === null || sys === undefined ? null : Number(sys); return sys === null || sys === undefined ? null : Number(sys);
} }
/** 是否已盘(有已盘库位明细/作业记录;未盘占位行不算) */ /** 账面口径标签:静态盘点=账面(快照)、普通盘点=账面(当前库存) */
function resolveSystemLabel(goodsInfo) {
const amount = (goodsInfo || {}).amount;
if (amount && amount.systemLabel) return amount.systemLabel;
return (goodsInfo || {}).isStatic ? '账面(快照)' : '账面(当前库存)';
}
/** 另一种口径提示(静态看当前库存 / 普通看基准快照,不一致时才提示) */
function resolveBookHint(goodsInfo) {
const amount = (goodsInfo || {}).amount;
return amount && amount.bookHint ? amount.bookHint : '';
}
/** 是否已盘(有作业记录或已盘库位;未盘占位行不算) */
function resolveHasChecked(goodsInfo) { function resolveHasChecked(goodsInfo) {
const info = goodsInfo || {}; const info = goodsInfo || {};
if (Number(info.recordCount) > 0) return true; if (Number(info.recordCount) > 0) return true;
@ -187,11 +209,11 @@ function resolveDiffText(goodsInfo) {
/** /**
* 商品作业页(goods 视图;从盘点作业商品列表点击/扫码进入) * 商品作业页(goods 视图;从盘点作业商品列表点击/扫码进入)
* 入参:**只传 id** —— task_id(盘点任务ID)+ stock_id(商品库存ID);明细由服务端反查 * 入参:**只传 id** —— task_id(盘点任务ID)+ detail_id(盘点明细ID)或 stock_id(商品库存ID)
* 数据: * 数据:
* - stock.check.workDataDetail(id + stock_id)→ 商品钻取数据,含商品信息/主图/账面/已盘/差异 + rows(每库位:账面/实盘/盘点人/时间/记录ID/照片) * - stock.check.workDataDetail(id + stock_id / detail_id)→ 商品钻取数据:summary(商品级账面/已盘/差异)+ rows(按库位分行)
* - stock.check.detail(仅主表 check)→ 任务状态 / 盘点模式 * - stock.check.detail(仅主表 check)→ 任务状态 / 盘点模式 / 是否静态盘点
* 能力:扫码/输入库位 → 底部抽屉选库位 + 录数量(check.report:id + stock_id + space_id,不传 detail_id);库位记录可左滑删除(recordDelete) * 能力:扫码/输入库位 → 底部抽屉选库位 + 录数量(check.report);库位记录可左滑删除(recordDelete)
*/ */
export default { export default {
components: { components: {
@ -202,8 +224,10 @@ export default {
data() { data() {
return { return {
taskId: '', taskId: '',
detailId: '',
// 商品库存ID(0.3.309 起 goods 行不再返回 detail_id,改用 stock_id 进入)
stockId: '', stockId: '',
taskInfo: { status: '', mode: '', type: '' }, taskInfo: { status: '', mode: '', type: '', isStatic: false, hasStaticFlag: false },
goodsInfo: EMPTY_GOODS_INFO(), goodsInfo: EMPTY_GOODS_INFO(),
loading: false, loading: false,
refreshing: false, refreshing: false,
@ -234,6 +258,13 @@ export default {
systemQuantityValue() { systemQuantityValue() {
return resolveSystemQuantity(this.goodsInfo); return resolveSystemQuantity(this.goodsInfo);
}, },
// 账面口径标签(快照 / 当前库存)与另一种口径提示
systemLabel() {
return resolveSystemLabel(this.goodsInfo);
},
bookHintText() {
return resolveBookHint(this.goodsInfo);
},
// 已盘合计(接口 checked_quantity,缺失时用库位明细合计;未盘显示 --) // 已盘合计(接口 checked_quantity,缺失时用库位明细合计;未盘显示 --)
checkedTotalText() { checkedTotalText() {
if (!this.hasChecked) return '--'; if (!this.hasChecked) return '--';
@ -265,15 +296,15 @@ export default {
}, },
// CountLocationDetail 只需要 row 结构(概况在卡片,children = 库位明细:账面/实盘/盈亏) // CountLocationDetail 只需要 row 结构(概况在卡片,children = 库位明细:账面/实盘/盈亏)
detailRow() { detailRow() {
if (!this.stockId) return null; if (!this.detailId && !this.stockId && !this.goodsInfo.stockId) return null;
const locations = this.goodsInfo.locations || []; const locations = this.goodsInfo.locations || [];
const meta = []; const meta = [];
const codes = this.goodsInfo.locationCodes || []; const codes = this.goodsInfo.locationCodes || [];
if (codes.length) meta.push({ label: '库位', value: codes.length === 1 ? codes[0] : `${codes.length} 个` }); if (codes.length) meta.push({ label: '库位', value: codes.length === 1 ? codes[0] : `${codes.length} 个` });
if (this.goodsInfo.lastCheckedAtText) meta.push({ label: '最近上报', value: this.goodsInfo.lastCheckedAtText }); if (this.goodsInfo.lastCheckedAtText) meta.push({ label: '最近上报', value: this.goodsInfo.lastCheckedAtText });
return { return {
key: `goods-${this.stockId}`, key: `goods-${this.detailId || this.stockId || this.goodsInfo.stockId}`,
detailId: '', detailId: this.detailId,
title: '', title: '',
subtitle: '', subtitle: '',
statusText: '', statusText: '',
@ -287,8 +318,9 @@ export default {
} }
}, },
onLoad(options = {}) { onLoad(options = {}) {
// 页面只需两个 id:task_id(任务ID)+ stock_id(商品库存ID) // 页面需 task_id +(detail_id 或 stock_id):商品明细由接口反查
this.taskId = String(options.task_id || options.taskId || options.id || '').trim(); this.taskId = String(options.task_id || options.taskId || options.id || '').trim();
this.detailId = String(options.detail_id || options.detailId || '').trim();
this.stockId = String(options.stock_id || options.stockId || '').trim(); this.stockId = String(options.stock_id || options.stockId || '').trim();
this.loadAll(); this.loadAll();
@ -390,14 +422,15 @@ export default {
this.showEntryPopup = false; this.showEntryPopup = false;
this.pendingLocation = ''; this.pendingLocation = '';
}, },
/** 抽屉确认:库位 + 数量 → check.report(商品模式只传任务ID + stock_id,不传 detail_id) */ /** 抽屉确认:库位 + 数量 → check.report(多库位商品按所选库位取对应明细ID) */
async handleEntryConfirm(payload) { async handleEntryConfirm(payload) {
if (!payload || !payload.location) return; if (!payload || !payload.location) return;
const ok = await this.submitReport({ const ok = await this.submitReport({
detailId: this.resolveLocationDetailId(payload),
location: payload.location, location: payload.location,
spaceId: payload.locationId, spaceId: payload.locationId,
quantity: payload.quantity, quantity: payload.quantity,
stockId: this.goodsInfo.stockId || this.stockId stockId: this.goodsInfo.stockId
}); });
// 成功才收起抽屉并清空顶部关键字,失败保留输入便于重试 // 成功才收起抽屉并清空顶部关键字,失败保留输入便于重试
if (ok) { if (ok) {
@ -405,12 +438,26 @@ export default {
this.closeEntryPopup(); this.closeEntryPopup();
} }
}, },
/** 上报(check.report:id=盘点任务,stock_id=商品,space_id=库位;明细由服务端反查) */ /** 按库位定位盘点明细ID(同一商品多库位时每个库位一条明细) */
resolveLocationDetailId(payload) {
const target = payload || {};
const spaceId = target.locationId !== undefined && target.locationId !== null ? String(target.locationId).trim() : '';
const code = String(target.location || '').trim();
const candidates = []
.concat(Array.isArray(this.goodsInfo.allLocations) ? this.goodsInfo.allLocations : [])
.concat(Array.isArray(this.goodsInfo.locations) ? this.goodsInfo.locations : []);
const matched = candidates.find(loc => {
const locSpaceId = String(loc.spaceId || loc.locationId || '').trim();
if (spaceId && locSpaceId && locSpaceId === spaceId) return true;
return !!code && String(loc.locationCode || '').trim() === code;
});
return (matched && matched.detailId) || this.detailId;
},
/** 上报(check.report:detail_id=该库位明细,location=库位) */
async submitReport(payload) { async submitReport(payload) {
if (!this.editable || this.submitting) return false; if (!this.editable || this.submitting) return false;
const stockId = String((payload && payload.stockId) || '').trim(); if (!payload || (!payload.detailId && !payload.stockId)) {
if (!stockId) { uni.showToast({ title: '缺少盘点明细ID', icon: 'none' });
uni.showToast({ title: '缺少商品库存ID(stock_id)', icon: 'none' });
return false; return false;
} }
const location = String(payload.location || '').trim(); const location = String(payload.location || '').trim();
@ -431,10 +478,11 @@ export default {
this.submitting = true; this.submitting = true;
try { try {
const response = await this.$http('check.report', buildReportParams(this.taskId, { const response = await this.$http('check.report', buildReportParams(this.taskId, {
detailId: payload.detailId,
location, location,
spaceId, spaceId,
quantity, quantity,
stockId, stockId: payload.stockId,
barcode: this.goodsInfo.barcode, barcode: this.goodsInfo.barcode,
itemName: this.goodsInfo.itemName itemName: this.goodsInfo.itemName
})); }));
@ -567,7 +615,10 @@ export default {
this.taskInfo = { this.taskInfo = {
status: String(check.status || '').trim().toLowerCase(), status: String(check.status || '').trim().toLowerCase(),
mode: String(check.mode || '').trim().toLowerCase(), mode: String(check.mode || '').trim().toLowerCase(),
type: check.type || '' type: check.type || '',
// 静态盘点:账面取明细快照;普通盘点取当前库存(0.3.318)
isStatic: isStaticCheck(check.is_static !== undefined ? check.is_static : check.isStatic),
hasStaticFlag: (check.is_static !== undefined ? check.is_static : check.isStatic) !== undefined
}; };
return this.taskInfo; return this.taskInfo;
} catch (error) { } catch (error) {
@ -575,30 +626,40 @@ export default {
return null; return null;
} }
}, },
/** 商品钻取数据(stock.check.workDataDetail:id + stock_id,明细由服务端反查)——含商品信息/主图/账面/已盘/差异 + rows 库位明细 */ /** 商品明细(stock.check.workDataDetail:id + stock_id / detail_id,兼容 summary+rows 钻取结构)——含商品信息/主图/账面/已盘/差异 + 各库位明细 */
async loadInfo() { async loadInfo() {
const stockId = Number(this.stockId);
if (!Number.isFinite(stockId) || stockId <= 0) {
this.loadError = '缺少商品库存ID';
uni.showToast({ title: this.loadError, icon: 'none' });
return null;
}
const taskId = Number(this.taskId); const taskId = Number(this.taskId);
if (!Number.isFinite(taskId) || taskId <= 0) { if (!Number.isFinite(taskId) || taskId <= 0) {
this.loadError = '缺少盘点任务ID'; this.loadError = '缺少盘点任务ID';
uni.showToast({ title: this.loadError, icon: 'none' }); uni.showToast({ title: this.loadError, icon: 'none' });
return null; return null;
} }
const detailId = Number(this.detailId);
const routeStockId = Number(this.stockId);
const knownStockId = Number(this.goodsInfo.stockId);
const stockId = Number.isFinite(knownStockId) && knownStockId > 0
? knownStockId
: (Number.isFinite(routeStockId) && routeStockId > 0 ? routeStockId : 0);
const params = { id: taskId };
if (Number.isFinite(detailId) && detailId > 0) params.detail_id = detailId;
if (stockId > 0) params.stock_id = stockId;
if (!params.detail_id && !params.stock_id) {
this.loadError = '缺少盘点明细ID/商品库存ID';
uni.showToast({ title: this.loadError, icon: 'none' });
return null;
}
this.loading = true; this.loading = true;
try { try {
const response = await this.$http('check.workDataDetail', { id: taskId, stock_id: stockId }); const response = await this.$http('check.workDataDetail', params);
if (response?.flag === 'failure') { if (response?.flag === 'failure') {
this.goodsInfo = EMPTY_GOODS_INFO(); this.goodsInfo = EMPTY_GOODS_INFO();
this.loadError = response.message || '盘点明细加载失败'; this.loadError = response.message || '盘点明细加载失败';
uni.showToast({ title: this.loadError, icon: 'none' }); uni.showToast({ title: this.loadError, icon: 'none' });
return null; return null;
} }
const info = normalizeGoodsDetailInfo(extractObjectPayload(response), this.taskInfo.mode); const info = normalizeGoodsDetailInfo(extractObjectPayload(response), this.taskInfo.mode, {
isStatic: this.taskInfo.hasStaticFlag ? this.taskInfo.isStatic : undefined
});
if (info) this.goodsInfo = Object.assign({}, this.goodsInfo, info); if (info) this.goodsInfo = Object.assign({}, this.goodsInfo, info);
this.loadError = ''; this.loadError = '';
return this.goodsInfo; return this.goodsInfo;
@ -745,6 +806,13 @@ export default {
color: #e64340; color: #e64340;
} }
/* 另一种账面口径提示(静态看当前库存 / 普通看基准快照) */
.inv-goods-card__hint {
margin-right: 20rpx;
font-size: 28rpx;
color: #b8811a;
}
.inv-goods-tip { .inv-goods-tip {
margin: 0 12rpx 16rpx; margin: 0 12rpx 16rpx;
padding: 24rpx; padding: 24rpx;

View File

@ -61,6 +61,7 @@ import {
extractObjectPayload, extractObjectPayload,
extractListPayload, extractListPayload,
normalizeSpaceWorkDetail, normalizeSpaceWorkDetail,
isStaticCheck,
buildReportParams buildReportParams
} from './inventoryCount-comps/countModel.js'; } from './inventoryCount-comps/countModel.js';
@ -81,7 +82,7 @@ export default {
return { return {
taskId: '', taskId: '',
locationId: '', locationId: '',
taskInfo: { status: '', mode: '' }, taskInfo: { status: '', mode: '', isStatic: false, hasStaticFlag: false },
row: null, row: null,
loading: false, loading: false,
refreshing: false, refreshing: false,
@ -327,7 +328,10 @@ export default {
const check = extractObjectPayload(response).check || {}; const check = extractObjectPayload(response).check || {};
this.taskInfo = { this.taskInfo = {
status: String(check.status || '').trim().toLowerCase(), status: String(check.status || '').trim().toLowerCase(),
mode: String(check.mode || '').trim().toLowerCase() mode: String(check.mode || '').trim().toLowerCase(),
// 静态盘点:账面取明细快照;普通盘点取当前库存(0.3.318)
isStatic: isStaticCheck(check.is_static !== undefined ? check.is_static : check.isStatic),
hasStaticFlag: (check.is_static !== undefined ? check.is_static : check.isStatic) !== undefined
}; };
return this.taskInfo; return this.taskInfo;
} catch (error) { } catch (error) {
@ -382,7 +386,9 @@ export default {
} }
const payload = extractObjectPayload(response); const payload = extractObjectPayload(response);
const rows = extractListPayload(payload, response); const rows = extractListPayload(payload, response);
this.row = normalizeSpaceWorkDetail(rows, this.taskInfo.mode); this.row = normalizeSpaceWorkDetail(rows, this.taskInfo.mode, {
isStatic: this.taskInfo.hasStaticFlag ? this.taskInfo.isStatic : undefined
});
this.applyLocalQuantities(); this.applyLocalQuantities();
this.loadError = this.row ? '' : '该库位暂无任务商品'; this.loadError = this.row ? '' : '该库位暂无任务商品';
return this.row; return this.row;