diff --git a/src/App.vue b/src/App.vue
index 1b14e4d..fddb17f 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -76,4 +76,12 @@ export default {
flex-direction: column;
background-color: #f8f8f8;
}
+
+/* uni 系统图片预览层(uni.previewImage):
+ H5 下框架给 .uni-system-preview-image 的 z-index 只有 999,会被 uView 弹窗
+ (popup 默认 10075、toast 10090)盖住 —— 表现为"在弹窗里点图片预览看不到"。
+ 这里统一抬高到所有业务弹层之上(App 端预览是原生全屏,不受此样式影响)。 */
+.uni-system-preview-image {
+ z-index: 10100 !important;
+}
\ No newline at end of file
diff --git a/src/core/request/apis.js b/src/core/request/apis.js
index 8987e6f..292605f 100644
--- a/src/core/request/apis.js
+++ b/src/core/request/apis.js
@@ -436,7 +436,8 @@ export default {
method: "POST",
isSystemApi: true
},
- // 盘点任务明细:返回主表 check + 全部明细 rows(含账面/实盘/差异数量)
+ // 盘点任务详情(只返回主表 check:check_no/type/mode/store_id/status/detail_status/进度/时间等):
+ // 入参仅 id;不再返回明细范围行(rows),明细结果请调 result,作业记录请调 recordList
detail: {
path: "stock.check.detail",
auth: true,
@@ -461,16 +462,25 @@ export default {
method: "POST",
isSystemApi: true
},
- // 单条盘点明细的作业数据(workData 单行版,仅库位任务明细):
- // 入参仅 detail_id(兼容 detailId),warehouse_id 由服务端注入;
- // 返回 data 为单行 location 结构(detail_id/location_id/location_code/location_name/
- // status/has_unknown/is_empty/checked_at/checkers/goods),仅 approved/checking 可拉取
+ // 单条盘点明细的作业数据(入参仅 detail_id,兼容 detailId)——库位明细返回 location 单行结构
+ // (detail_id/location_code/location_name/status/has_unknown/is_empty/checked_at/checkers/goods);
+ // 商品明细返回商品行结构(item_name/barcode/spec/store_name/images + 明盘 system/checked/diff_quantity);
+ // warehouse_id 由服务端注入;仅 approved/checking 可拉取
workDataDetail: {
path: "stock.check.workDataDetail",
auth: true,
method: "POST",
isSystemApi: true
},
+ // 单库位的 space 作业数据(workData space 视图分页版):
+ // 入参 id(任务ID)+ location_id(库位ID,兼容 locationId,可选)+ pagination;
+ // 传 location_id 时只返回该库位行(total=1),行结构与 workData space 视图一致
+ workDataSpaceDetails: {
+ path: "stock.check.workDataSpaceDetails",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
// 盘点作业上报:单条明细实盘数量(quantity>=0 整数)
report: {
path: "stock.check.report",
@@ -486,6 +496,14 @@ export default {
method: "POST",
isSystemApi: true
},
+ // 盘点作业记录列表(id 与 detail_id 至少传一个,传了 detail_id 只查该明细的记录):
+ // 每条含 location_code/quantity/checker_name/checked_at/is_empty/images + 商品信息列,按记录 id 倒序分页
+ recordList: {
+ path: "stock.check.recordList",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
// 完成盘点作业:主表置 completed
finish: {
path: "stock.check.finish",
@@ -793,6 +811,51 @@ export default {
auth: true,
method: "POST",
isSystemApi: true
+ },
+ list: {
+ path: "returnReceived.list",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ export: {
+ path: "returnReceived.export",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ exportTaskProgress: {
+ path: "returnReceived.exportTaskProgress",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ }
+ },
+ /** 收件任务(退件收件任务列表,warehouse_id 由服务端注入)↓ **/
+ returnReceivedTask: {
+ create: {
+ path: "returnReceivedTask.create",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ list: {
+ path: "returnReceivedTask.list",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ delete: {
+ path: "returnReceivedTask.delete",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ batchDelete: {
+ path: "returnReceivedTask.batchDelete",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
}
}
};
\ No newline at end of file
diff --git a/src/core/request/index.js b/src/core/request/index.js
index d061256..2b66cab 100644
--- a/src/core/request/index.js
+++ b/src/core/request/index.js
@@ -111,5 +111,9 @@ function getApiPath(url) {
apiArray.forEach(v => {
api = api[v];
});
+ // 未登记时报错信息要可读,避免出现 "Cannot read properties of undefined (reading 'auth')"
+ if (!api || typeof api !== 'object' || !api.path) {
+ throw new Error(`接口未注册: ${url}(请在 core/request/apis.js 中登记)`);
+ }
return api;
}
diff --git a/src/core/utils/auth-guard.js b/src/core/utils/auth-guard.js
index f158afd..828567a 100644
--- a/src/core/utils/auth-guard.js
+++ b/src/core/utils/auth-guard.js
@@ -18,6 +18,28 @@ export function isLoginRoute(route = '') {
return route === LOGIN_URL
}
+/**
+ * 整页启动(H5 F5 / 重新打开页面)时页面栈还是空的,getCurrentPages() 取不到路由;
+ * 此时若直接判定为“未知路由”就会把深链页面强制跳回首页,导致该页面的数据永远不会被拉取。
+ * 这里用启动 URL 兵底(只在 H5 history 模式有意义;App 端首屏是入口页,返回空字符串保持原行为)。
+ */
+export function getBootRoute() {
+ // #ifdef H5
+ if (typeof window !== 'undefined' && window.location) {
+ // 兼容 history(pathname)与 hash(#/pages/xxx)两种模式,query 不参与路由判断
+ const hashPath = String(window.location.hash || '').replace(/^#/, '').split('?')[0]
+ const raw = hashPath || String(window.location.pathname || '')
+ let path = raw.replace(/^\/+/, '').replace(/\/+$/, '')
+ if (path && path !== 'index.html') {
+ // 去掉可能存在的 .html 后缀,得到与 getCurrentRoute() 同格式(/pages/xxx)的路由
+ path = path.replace(/\.html$/, '')
+ if (path) return `/${path}`
+ }
+ }
+ // #endif
+ return ''
+}
+
export function clearSession(store) {
removeToken()
if (!store) return
@@ -124,7 +146,8 @@ export function goHome() {
export async function ensureEntry(store, forceValidate = false) {
const token = getToken()
- const currentRoute = getCurrentRoute()
+ // 整页启动时页面栈为空,用启动 URL 兵底,避免把深链当成未知路由而跳首页
+ const currentRoute = getCurrentRoute() || getBootRoute()
// 工作台会话:跳过用户态校验,不调用 user.info;保持当前打包模式页不跳首页
if (isWorkbenchSession()) {
diff --git a/src/pages.json b/src/pages.json
index d4f89f1..2f8f397 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -145,6 +145,20 @@
"titleNView": false
}
},
+ {
+ "path" : "pages/warehouse/inventoryCountSpace",
+ "style" :
+ {
+ "titleNView": false
+ }
+ },
+ {
+ "path" : "pages/warehouse/inventoryCountGoods",
+ "style" :
+ {
+ "titleNView": false
+ }
+ },
{
"path" : "pages/403",
"style" :
@@ -293,6 +307,13 @@
"titleNView": false
}
},
+ {
+ "path" : "pages/work/order/returnRecordScan",
+ "style" :
+ {
+ "titleNView": false
+ }
+ },
{
"path" : "pages/work/order/pickingRecord",
"style" :
diff --git a/src/pages/warehouse/inventoryCount-comps/CountGoodsCard.vue b/src/pages/warehouse/inventoryCount-comps/CountGoodsCard.vue
new file mode 100644
index 0000000..64076d0
--- /dev/null
+++ b/src/pages/warehouse/inventoryCount-comps/CountGoodsCard.vue
@@ -0,0 +1,191 @@
+
+
+
+
+
+
+
+
+ 无图
+
+
+
+
+
+
+ {{ row.title || '--' }}
+
+ {{ row.checked ? '已盘' : '未盘' }}
+
+
+ {{ row.subtitle }}
+
+
+ 账面 {{ row.amount.systemText }}
+ 已盘 {{ row.amount.checkedText }}
+
+ {{ row.amount.diffText }}
+
+
+ 已盘记录 {{ row.recordCount || 0 }} 条
+ {{ locationText }}
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue b/src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue
index f0f16bf..e1c2794 100644
--- a/src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue
+++ b/src/pages/warehouse/inventoryCount-comps/CountLocationDetail.vue
@@ -7,7 +7,7 @@
空库位
- {{ row.statusText }}
+ {{ row.statusText }}
@@ -17,13 +17,13 @@
- 商品记录
+ {{ sectionTitle }}
共 {{ (row.goodsCount || 0) + (row.unknownCount || 0) }} 条
未知 {{ row.unknownCount }}
- 该库位暂无商品记录
+ {{ emptyText }}
@@ -36,13 +36,46 @@
@click="handleSwipeClick(child)"
>
+
+
+
+
+ 无图
+
+
+
+
+ {{ child.images.length }}
+
+
{{ child.title }}
{{ child.subtitle }}
+
+
+ 账面 {{ child.amounts.systemText }}
+ 实盘 {{ child.amounts.checkedText }}
+
+ {{ child.amounts.diffText }}
+
+
{{ child.statusText }}
- 实盘 {{ child.quantityText }}
+ 实盘 {{ child.quantityText }}
@@ -54,9 +87,9 @@
+
+
diff --git a/src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue b/src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue
index c61b0d6..c169a3d 100644
--- a/src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue
+++ b/src/pages/warehouse/inventoryCount-comps/CountWorkCard.vue
@@ -52,7 +52,13 @@
-
+
{{ child.title }}
{{ child.subtitle }}
@@ -126,6 +132,11 @@ export default {
focused: {
type: Boolean,
default: false
+ },
+ // 子项定位高亮(按 child.key,如扫码定位到某个商品行)
+ focusedKey: {
+ type: String,
+ default: ''
}
}
};
@@ -336,6 +347,12 @@ export default {
}
}
+/* 扫码/输入定位到某个商品行时的高亮 */
+.work-child--active {
+ background: #eef4ff;
+ border-radius: 8rpx;
+}
+
.work-child__main {
display: flex;
flex-direction: column;
diff --git a/src/pages/warehouse/inventoryCount-comps/countModel.js b/src/pages/warehouse/inventoryCount-comps/countModel.js
index 3ab6eac..3f396f5 100644
--- a/src/pages/warehouse/inventoryCount-comps/countModel.js
+++ b/src/pages/warehouse/inventoryCount-comps/countModel.js
@@ -513,10 +513,15 @@ function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open) {
const chk = toNumberOrNull(checkedQuantity);
let diff = toNumberOrNull(diffQuantity);
if (diff === null && sys !== null && chk !== null) diff = chk - sys;
+ // diffTone 供各组件映射自己的样式类(gain/loss/match),diffClass 保持旧口径兼容
+ const diffTone = diff === null ? '' : (diff > 0 ? 'gain' : (diff < 0 ? 'loss' : 'match'));
return {
systemText: sys === null ? '--' : String(sys),
checkedText: chk === null ? '--' : String(chk),
- diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${diff}` : '账实相符')),
+ // 盘亏用绝对值(盘亏 49084),避免出现「盘亏 -49084」这种双重负号
+ diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')),
+ diff,
+ diffTone,
diffClass: diff === null ? '' : (diff > 0 ? 'work-card__diff--gain' : (diff < 0 ? 'work-card__diff--loss' : 'work-card__diff--match'))
};
}
@@ -571,7 +576,7 @@ function joinText(parts, sep = ' · ') {
return parts.filter(part => part !== null && part !== undefined && String(part).trim() !== '').map(part => String(part).trim()).join(sep);
}
-/** space 视图:行=库位,goods 为该库位下的任务商品(商品任务默认视图) */
+/** space 视图:行=库位,goods 为该库位下的任务商品(商品任务默认视图;作业列表按库位宫格展示,仅统计不可点击) */
function normalizeSpaceWorkRow(item, index, open) {
const source = item && typeof item === 'object' ? item : {};
const spaceCode = firstValue(source, ['space_code', 'spaceCode']) || `#${index + 1}`;
@@ -592,18 +597,42 @@ function normalizeSpaceWorkRow(item, index, open) {
unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId']))
};
});
+ // 库位统计(口径=商品条数):商品 status=checked 即该明细在该库位已有作业记录
+ const total = children.length;
+ const checkedCount = rawGoods.filter(row => String((row && row.status) || '').trim().toLowerCase() === 'checked').length;
+ const uncheckedCount = Math.max(0, total - checkedCount);
+ const allDone = total > 0 && checkedCount === total;
+ const spaceName = firstValue(source, ['custom_name', 'customName']);
return {
key: `space-${firstValue(source, ['id']) || spaceCode}`,
view: 'space',
title: spaceCode,
- subtitle: joinText([firstValue(source, ['custom_name', 'customName']), firstValue(source, ['custom_barcode', 'customBarcode'])]),
+ subtitle: joinText([spaceName, firstValue(source, ['custom_barcode', 'customBarcode'])]),
statusText: '',
statusClass: '',
meta: children.length ? [] : [{ label: '商品', value: '该库位暂无任务商品' }],
amount: null,
quantityText: '',
children,
- unit: null
+ unit: null,
+ // 宫格展示字段(与 location 视图对齐:行=库位;space 行没有库位明细ID)
+ // 库位ID(wms_location_space.id)——跳「单库位作业页」(workDataSpaceDetails)用
+ spaceId: firstValue(source, ['id']) ? String(firstValue(source, ['id'])) : '',
+ location: spaceCode,
+ locationName: spaceName || spaceCode,
+ empty: false,
+ checked: allDone,
+ partChecked: checkedCount > 0 && checkedCount < total,
+ hasUnknown: false,
+ goodsCount: total,
+ unknownCount: 0,
+ checkedCount,
+ uncheckedCount,
+ gridText: spaceName || spaceCode,
+ gridCode: spaceCode,
+ gridLabel: shortLocationLabel(spaceCode),
+ gridCountText: `商品 ${total} 项`,
+ gridProgressText: `已盘 ${checkedCount} / 未盘 ${uncheckedCount}`
};
}
@@ -629,18 +658,39 @@ function normalizeGoodsWorkRow(item, index, open) {
};
});
const reported = checkedRaw !== undefined && checkedRaw !== null && checkedRaw !== '';
+ // 行级商品主图(goods 视图行级 images 仍为商品主图)
+ const imageList = Array.isArray(source.images) ? source.images.filter(Boolean) : [];
+ // 作业记录条数(locations[].record_ids 汇总)——已盘判断与概况展示用
+ const recordCount = rawLocations.reduce((sum, row) => {
+ const ids = row && Array.isArray(row.record_ids) ? row.record_ids.length : 0;
+ return sum + ids;
+ }, 0);
+ const done = reported || recordCount > 0;
return {
key: `goods-${detailId || index + 1}`,
view: 'goods',
+ detailId: detailId ? String(detailId) : '',
+ stockId: firstValue(source, ['stock_id', 'stockId']) === undefined || firstValue(source, ['stock_id', 'stockId']) === null ? '' : String(firstValue(source, ['stock_id', 'stockId'])),
title: firstValue(source, ['item_name', 'itemName']) || '--',
subtitle: joinText([firstValue(source, ['spec']), firstValue(source, ['barcode']), firstValue(source, ['store_name', 'storeName'])]),
- statusText: '',
- statusClass: '',
+ statusText: done ? '已盘' : '未盘',
+ statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
meta: children.length ? [] : [{ label: '库位', value: '暂无作业记录' }],
amount: buildWorkAmount(source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity, checkedRaw, source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity, open),
quantityText: '',
children,
- unit: buildWorkUnit(detailId, '', checkedRaw, reported, firstValue(source, ['stock_id', 'stockId']))
+ unit: buildWorkUnit(detailId, '', checkedRaw, reported, firstValue(source, ['stock_id', 'stockId'])),
+ // 列表行(CountGoodsCard)与商品作业页(概况带入路由)用的字段:一行一个商品,操作剥离到操作页
+ images: imageList,
+ image: imageList[0] || '',
+ itemCode: firstValue(source, ['item_code', 'itemCode']) || '',
+ barcode: firstValue(source, ['barcode']) || '',
+ spec: firstValue(source, ['spec']) || '',
+ storeName: firstValue(source, ['store_name', 'storeName']) || '',
+ checked: done,
+ recordCount,
+ locationCount: rawLocations.length,
+ locationCodes: rawLocations.map(row => firstValue(row || {}, ['location_code', 'locationCode'])).filter(Boolean)
};
}
@@ -751,6 +801,172 @@ export function normalizeLocationWorkDetail(payload, mode) {
return normalizeLocationWorkRow(payload, 0, isOpenCheckMode(mode));
}
+/**
+ * 单库位作业数据归一化(stock.check.workDataSpaceDetails,rows 只有该库位一行)
+ * 返回结构与 workData space 视图单行一致;rows 为空时返回 null。
+ */
+export function normalizeSpaceWorkDetail(rows, mode) {
+ if (!Array.isArray(rows) || !rows.length) return null;
+ return normalizeWorkRows(rows.slice(0, 1), 'space', mode)[0] || null;
+}
+
+/**
+ * 单条明细的作业记录归一化(stock.check.recordList,按 detail_id 拉该明细的全部记录)
+ * 返回 { children, count, totalQuantity }:children 结构可直接给 CountLocationDetail 用
+ * (title=库位码 / quantityText=实盘数量 / recordId 供左滑删除)。
+ */
+export function normalizeGoodsRecords(rows) {
+ const list = Array.isArray(rows) ? rows : [];
+ const children = list.map((item, index) => {
+ const record = item && typeof item === 'object' ? item : {};
+ const recordId = firstValue(record, ['id', 'record_id', 'recordId']);
+ const locationCode = firstValue(record, ['location_code', 'locationCode']);
+ const quantity = toNumberOrNull(record.quantity);
+ const checkerName = firstValue(record, ['checker_name', 'checkerName']);
+ const checkedAt = firstValue(record, ['checked_at', 'checkedAt']);
+ const isEmpty = toBool(record.is_empty);
+ const stockIdRaw = record.stock_id !== undefined && record.stock_id !== null ? record.stock_id : record.stockId;
+ const unknown = !isEmpty && (stockIdRaw === undefined || stockIdRaw === null || String(stockIdRaw).trim() === '');
+ return {
+ key: `record-${recordId || index + 1}`,
+ recordId,
+ stockId: stockIdRaw === undefined || stockIdRaw === null ? '' : String(stockIdRaw),
+ empty: isEmpty,
+ unknown,
+ locationCode: locationCode || '',
+ quantity,
+ title: isEmpty ? '空库位标记' : (locationCode || '未指定库位'),
+ subtitle: joinText([
+ checkerName ? `盘点人 ${checkerName}` : '',
+ checkedAt ? formatDateTime(checkedAt) : '',
+ unknown ? '未知商品' : ''
+ ]),
+ statusText: '',
+ statusClass: '',
+ amount: null,
+ quantityText: isEmpty || quantity === null ? '' : String(quantity),
+ images: Array.isArray(record.images) ? record.images.filter(Boolean) : [],
+ checkedAt: checkedAt || '',
+ checkedAtText: checkedAt ? formatDateTime(checkedAt) : '',
+ unit: null
+ };
+ });
+ const totalQuantity = children.reduce((sum, child) => sum + (Number(child.quantity) || 0), 0);
+ // 库位码(去重)与最近上报时间(ISO 字符串可按字典序比较)
+ const locationCodes = [];
+ children.forEach(child => {
+ if (child.locationCode && locationCodes.indexOf(child.locationCode) === -1) locationCodes.push(child.locationCode);
+ });
+ let lastCheckedAt = '';
+ children.forEach(child => {
+ if (child.checkedAt && child.checkedAt > lastCheckedAt) lastCheckedAt = child.checkedAt;
+ });
+ return { children, count: children.length, totalQuantity, locationCodes, lastCheckedAt, lastCheckedAtText: lastCheckedAt ? formatDateTime(lastCheckedAt) : '' };
+}
+
+/**
+ * 单条明细的作业数据(stock.check.workDataDetail)→ 商品明细概况
+ * 用于商品作业页:只传 detail_id,概况由接口反查得出
+ * 商品行返回:detail_id/stock_id/item_code/item_name/spec/store_id/store_name/barcode/images(商品主图)
+ * + locations[](每库位:location_code/checked_at/checker_name/record_ids/images/system_quantity/quantity)
+ * + system_quantity/checked_quantity/diff_quantity/is_diff
+ * 库位行(商品信息在 goods 子列表里)也兼容:信息取 goods 首项兜底
+ */
+export function normalizeGoodsDetailInfo(row, mode) {
+ const source = row && typeof row === 'object' && !Array.isArray(row) ? row : {};
+ if (!Object.keys(source).length) return null;
+ // 行内只要带了任一数量字段就按明盘口径构建(任务 mode 可能没取到/缺失,别把盈亏丢掉)
+ const quantityFields = [
+ source.system_quantity, source.checked_quantity, source.diff_quantity,
+ source.systemQuantity, source.checkedQuantity, source.diffQuantity
+ ];
+ const hasQuantity = quantityFields.some(value => value !== undefined && value !== null && value !== '');
+ const open = isOpenCheckMode(mode) || hasQuantity;
+ // 库位行形态:商品信息/图片取 goods 首项兜底
+ const firstGoods = Array.isArray(source.goods) && source.goods.length ? (source.goods[0] || {}) : {};
+ const pickText = keys => firstValue(source, keys) || firstValue(firstGoods, keys) || '';
+ const sourceImages = normalizeImageUrls(source.images);
+ const images = sourceImages.length ? sourceImages : normalizeImageUrls(firstGoods.images);
+ const stockIdRaw = source.stock_id !== undefined && source.stock_id !== null
+ ? source.stock_id
+ : (firstGoods.stock_id !== undefined && firstGoods.stock_id !== null ? firstGoods.stock_id : firstValue(source, ['stock_id', 'stockId']));
+ const checkersRaw = source.checkers;
+ const checkers = Array.isArray(checkersRaw) ? checkersRaw.filter(Boolean).join('、') : String(checkersRaw || '');
+
+ // 库位明细(每库位一行:账面 / 实盘 / 盈亏),顺便汇总记录条数与最近上报时间
+ const rawLocations = Array.isArray(source.locations) ? source.locations : [];
+ let recordCount = 0;
+ let lastCheckedAt = '';
+ const locations = rawLocations.map((item, index) => {
+ const loc = item && typeof item === 'object' ? item : {};
+ const locationCode = firstValue(loc, ['location_code', 'locationCode']) || '';
+ 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);
+ 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;
+ return {
+ key: `loc-${locationCode || index + 1}`,
+ // 左滑删除用:整库位的记录 ID 列表(recordDelete 支持数组)
+ recordIds,
+ recordId: recordIds.length === 1 ? recordIds[0] : '',
+ locationCode,
+ systemQuantity,
+ quantity,
+ title: locationCode || '未指定库位',
+ subtitle: joinText([
+ checkerName ? `盘点人 ${checkerName}` : '',
+ checkedAt ? formatDateTime(checkedAt) : ''
+ ]),
+ statusText: '',
+ statusClass: '',
+ amount: null,
+ quantityText: quantity === null ? '' : String(quantity),
+ images: normalizeImageUrls(loc.images),
+ checkedAt: checkedAt || '',
+ checkedAtText: checkedAt ? formatDateTime(checkedAt) : '',
+ // 明细面板展示:账面 / 实盘 / 盈亏(账面>0 时高亮,方便找账面库位)
+ amounts: systemQuantity === null && quantity === null ? null : {
+ systemText: systemQuantity === null ? '--' : String(systemQuantity),
+ checkedText: quantity === null ? '--' : String(quantity),
+ diffText: diff === null ? '' : (diff > 0 ? `盘盈 +${diff}` : (diff < 0 ? `盘亏 ${-diff}` : '账实相符')),
+ diffTone: diff === null ? '' : (diff > 0 ? 'gain' : (diff < 0 ? 'loss' : 'match')),
+ hasSystemStock: systemQuantity !== null && systemQuantity > 0
+ },
+ unit: null
+ };
+ });
+
+ return {
+ detailId: pickText(['detail_id', 'detailId']),
+ stockId: stockIdRaw === undefined || stockIdRaw === null ? '' : String(stockIdRaw),
+ itemName: pickText(['item_name', 'itemName']),
+ itemCode: pickText(['item_code', 'itemCode']),
+ barcode: pickText(['barcode']),
+ spec: pickText(['spec']),
+ storeName: pickText(['store_name', 'storeName']),
+ images,
+ image: images[0] || '',
+ status: String(source.status || '').trim().toLowerCase(),
+ systemQuantity: toNumberOrNull(source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity),
+ checkedQuantity: toNumberOrNull(source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity),
+ amount: buildWorkAmount(
+ source.system_quantity !== undefined ? source.system_quantity : source.systemQuantity,
+ source.checked_quantity !== undefined ? source.checked_quantity : source.checkedQuantity,
+ source.diff_quantity !== undefined ? source.diff_quantity : source.diffQuantity,
+ open
+ ),
+ locations,
+ recordCount,
+ locationCodes: locations.map(item => item.locationCode).filter(Boolean),
+ checkers,
+ lastCheckedAtText: lastCheckedAt ? formatDateTime(lastCheckedAt) : ''
+ };
+}
+
/** 作业行内可录入单元(行级 + 子项级) */
export function collectWorkUnits(row) {
if (!row) return [];
diff --git a/src/pages/warehouse/inventoryCountDetail.vue b/src/pages/warehouse/inventoryCountDetail.vue
index 602b654..b008d52 100644
--- a/src/pages/warehouse/inventoryCountDetail.vue
+++ b/src/pages/warehouse/inventoryCountDetail.vue
@@ -59,24 +59,28 @@
{{ workLoading ? '加载中...' : (hasWorkKeyword ? '未找到匹配库位' : '暂无作业数据') }}
-
+
-
-
+
+
+
+ 商品列表
+ 点击商品录入实盘数量
+
+
+
+
@@ -142,7 +146,7 @@
+
+
diff --git a/src/pages/warehouse/inventoryCountLocation.vue b/src/pages/warehouse/inventoryCountLocation.vue
index 4504f36..e699304 100644
--- a/src/pages/warehouse/inventoryCountLocation.vue
+++ b/src/pages/warehouse/inventoryCountLocation.vue
@@ -96,22 +96,12 @@ import {
buildReportParams
} from './inventoryCount-comps/countModel.js';
-/** query 参数解码(H5 可能已解码,容错处理非法百分号) */
-function decodeParam(value) {
- const raw = String(value === undefined || value === null ? '' : value);
- if (!raw) return '';
- try {
- return decodeURIComponent(raw);
- } catch (error) {
- return raw;
- }
-}
-
/**
* 库位盘点明细页(从盘点作业宫格列表点击/扫码进入)
- * 入参:detail_id(盘点明细ID,必需,兼容 id/detailId 别名)+ task_id(盘点任务ID,上报用)
- * + check_no / store_id / status(展示与搜索用,可选)
- * 数据:stock.check.workDataDetail(仅传 detail_id 即可拿到该库位的单行作业数据)
+ * 入参:**只传 id** —— task_id(盘点任务ID)+ detail_id(盘点明细ID,scope_type=location)
+ * 数据:
+ * - stock.check.workDataDetail(仅 detail_id)→ 该库位单行作业数据
+ * - stock.check.detail(仅主表 check)→ 盘点单号 / 状态 / 任务货主(商品搜索用)
* 能力:查看该库位状态与商品记录 + 添加商品记录 / 标记空库位(check.report)
*/
export default {
@@ -159,16 +149,11 @@ export default {
}
},
onLoad(options = {}) {
- // 明细ID:std 字段为 detail_id,兼容 id / detailId 别名(页面只需这一个 id 即可拉明细)
+ // 只接 id:明细ID(必需)+ 任务ID(上报与任务概况用)
this.detailId = String(options.detail_id || options.detailId || options.id || '').trim();
- // 任务ID:check.report 需要;兼容 id 与 task_id 两种写法
this.taskId = String(options.task_id || options.taskId || options.id || '').trim();
- this.checkNo = decodeParam(options.check_no || options.checkNo);
- this.taskStatus = decodeParam(options.status).trim().toLowerCase();
- const storeId = options.store_id === undefined || options.store_id === null ? '' : String(options.store_id);
- this.storeId = storeId === '' || storeId === 'null' || storeId === 'undefined' ? null : storeId;
- this.loadRow();
+ this.loadAll();
this.syncBroadcastWithMode();
},
onShow() {
@@ -396,7 +381,7 @@ export default {
if (this.refreshing) return;
this.refreshing = true;
try {
- await this.loadRow();
+ await this.loadAll();
} finally {
this.refreshing = false;
}
@@ -404,6 +389,27 @@ export default {
handleRefresherRestore() {
this.refreshing = false;
},
+ // ===== 数据加载 =====
+ async loadAll() {
+ await Promise.all([this.loadTaskInfo(), this.loadRow()]);
+ },
+ /** 任务概况(stock.check.detail:只返回主表 check)——入参仅任务ID */
+ async loadTaskInfo() {
+ const taskId = Number(this.taskId);
+ if (!Number.isFinite(taskId) || taskId <= 0) return null;
+ try {
+ const response = await this.$http('check.detail', { id: taskId });
+ if (response?.flag === 'failure') return null;
+ const check = extractObjectPayload(response).check || {};
+ this.checkNo = check.check_no || '';
+ this.taskStatus = String(check.status || '').trim().toLowerCase();
+ this.storeId = check.store_id === undefined || check.store_id === null ? null : check.store_id;
+ return check;
+ } catch (error) {
+ console.error('[inventoryCountLocation] 盘点任务信息加载失败:', error);
+ return null;
+ }
+ },
// ===== 数据加载(stock.check.workDataDetail,只需传 detail_id)=====
async loadRow() {
if (!this.detailId) {
@@ -416,8 +422,7 @@ export default {
detail_id: Number(this.detailId)
});
if (response?.flag === 'failure') {
- // 状态不允许(如已完成)时后端返回 400,按只读展示
- this.taskStatus = '';
+ // 状态不允许(如已完成)时后端返回 400:保留任务状态(只读展示),仅清空明细
this.row = null;
uni.showToast({ title: response.message || '明细加载失败', icon: 'none' });
return null;
diff --git a/src/pages/warehouse/inventoryCountSpace.vue b/src/pages/warehouse/inventoryCountSpace.vue
new file mode 100644
index 0000000..20b1500
--- /dev/null
+++ b/src/pages/warehouse/inventoryCountSpace.vue
@@ -0,0 +1,426 @@
+
+
+
+
+
+
+
+
+
+
+
+ 库位
+ {{ locationCode || '--' }}
+
+
+ 商品进度
+ {{ progressText }}
+
+
+
+ 当前盘点任务状态不可作业,仅可查看
+
+ 加载中...
+
+
+
+
+ {{ loadError || '未获取到该库位的作业数据,请返回列表重试' }}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/work/order/returnRecord-comps/ReturnScanPanel.vue b/src/pages/work/order/returnRecord-comps/ReturnScanPanel.vue
new file mode 100644
index 0000000..49b8623
--- /dev/null
+++ b/src/pages/work/order/returnRecord-comps/ReturnScanPanel.vue
@@ -0,0 +1,1714 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 批次号
+ {{ taskBatchNo || '--' }}
+
+
+ 任务名称
+ {{ displayTitle }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 货主备注
+ {{ storeRemark }}
+
+
+ 备注
+ {{ result.remark }}
+
+
+
+
+
+ ⚠ 加急订单,请优先处理
+
+
+
+
+ 30日内已登记,本次沿用首次登记记录
+
+
+
+
+
+
+ 扫描记录
+ 共 {{ recordTotal }} 条
+ 接口未按任务过滤,已前端筛选
+
+ 导出
+
+
+ 刷新
+
+
+
+
+ {{ recordsLoading ? '加载中...' : '暂无扫描记录' }}
+
+
+
+
+
+ {{ item.waybillCode || '--' }}
+ {{ item.tagText }}
+
+
+
+ {{ item.scannerName || '--' }}
+
+
+ {{ item.createdAt || '--' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/work/order/returnRecord-comps/returnTaskModel.js b/src/pages/work/order/returnRecord-comps/returnTaskModel.js
new file mode 100644
index 0000000..8225f83
--- /dev/null
+++ b/src/pages/work/order/returnRecord-comps/returnTaskModel.js
@@ -0,0 +1,269 @@
+/**
+ * 收件任务模块共享逻辑(纯函数 / 无副作用)
+ * 供 pages/work/order/returnRecord.vue(任务列表)与 returnRecord-comps/ReturnScanPanel.vue(扫码登记)复用,
+ * 避免列表页与登记页各维护一份字段映射与响应解析。
+ */
+
+/** 系统预设任务ID:历史收件(warehouse_id=0,不可删除) */
+export const DEFAULT_TASK_ID = 1;
+
+/** 任务范围切换项:默认只看自己创建的 */
+export const TASK_SCOPE_OPTIONS = [
+ { label: '我的任务', value: 'mine' },
+ { label: '全部任务', value: 'all' }
+];
+
+// ===== 取值 / 格式化 =====
+
+/** 扫码结果归一化:兼容字符串 / {result:[]} / {data} 等多种回调结构 */
+export function normalizeScanResult(scanResult) {
+ if (!scanResult) return '';
+ if (typeof scanResult === 'string') return scanResult.trim();
+ if (typeof scanResult.result === 'string') return scanResult.result.trim();
+ if (Array.isArray(scanResult.result)) {
+ const first = scanResult.result.find(item => item);
+ if (typeof first === 'string') return first.trim();
+ if (first && typeof first.data === 'string') return first.data.trim();
+ }
+ if (typeof scanResult.data === 'string') return scanResult.data.trim();
+ return '';
+}
+
+/** 时间格式化(yyyy-MM-dd HH:mm:ss) */
+export function formatDateTime(value) {
+ if (value === null || value === undefined || value === '') return '';
+ const date = new Date(String(value).trim());
+ if (Number.isNaN(date.getTime())) return String(value).trim();
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hour = String(date.getHours()).padStart(2, '0');
+ const minute = String(date.getMinutes()).padStart(2, '0');
+ const second = String(date.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
+}
+
+/** 取第一个非空字段值 */
+export function firstValue(source, keys) {
+ const target = source && typeof source === 'object' ? source : {};
+ for (let i = 0; i < keys.length; i += 1) {
+ const value = target[keys[i]];
+ if (value !== null && value !== undefined && String(value).trim() !== '') {
+ return String(value).trim();
+ }
+ }
+ return '';
+}
+
+// ===== 响应体解析 =====
+
+/** 取响应里的第一个普通对象(各接口包裹层级不一) */
+export function extractObjectPayload(response) {
+ const candidates = [
+ response?.data?.data,
+ response?.data,
+ response?.result,
+ response
+ ];
+ for (let i = 0; i < candidates.length; i += 1) {
+ const current = candidates[i];
+ if (current && typeof current === 'object' && !Array.isArray(current)) {
+ return current;
+ }
+ }
+ return {};
+}
+
+/** 取响应里的第一个数组(list/rows/items/records) */
+export function extractListPayload(payload, response) {
+ const candidates = [
+ payload?.list,
+ payload?.rows,
+ payload?.items,
+ payload?.records,
+ payload?.data?.list,
+ payload?.data?.rows,
+ response?.data?.list,
+ response?.data?.rows,
+ response?.data?.data?.list,
+ response?.data?.data?.rows,
+ response?.list,
+ response?.rows
+ ];
+ for (let i = 0; i < candidates.length; i += 1) {
+ if (Array.isArray(candidates[i])) return candidates[i];
+ }
+ return [];
+}
+
+/** 解析分页总数(兼容 pagination.total / total / 数组长度) */
+export function resolveListTotal(payload, response, list) {
+ const pagination = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
+ const candidates = [
+ pagination?.total,
+ payload?.pagination?.total,
+ payload?.total,
+ payload?.count,
+ response?.data?.pagination?.total,
+ response?.data?.total,
+ response?.total,
+ Array.isArray(list) ? list.length : 0
+ ];
+ for (let i = 0; i < candidates.length; i += 1) {
+ const value = Number(candidates[i]);
+ if (Number.isFinite(value) && value >= 0) return value;
+ }
+ return 0;
+}
+
+// ===== 列表:请求参数与行归一化 =====
+
+/**
+ * 构造收件任务列表查询参数
+ * - warehouse_id 由服务端从登录上下文注入,前端禁止传入
+ * - onlyMine=true 时按 creator_id 等值筛选(当前登录账号ID)
+ */
+export function buildTaskListParams({ page = 1, pageSize = 20, keyword = '', onlyMine = false, creatorId = '' } = {}) {
+ const params = {
+ pagination: {
+ page: Math.max(1, Number(page || 1)),
+ pageSize: Math.max(1, Number(pageSize || 20))
+ },
+ sort: {
+ sortField: 'id',
+ sortOrder: 'desc'
+ }
+ };
+ const where = {};
+ const kw = String(keyword || '').trim();
+ if (kw) {
+ // quickWhere:title / batch_no / creator_name 三字段 OR 模糊匹配
+ where.quickWhere = { value: kw };
+ }
+ if (onlyMine) {
+ const id = Number(creatorId);
+ if (Number.isFinite(id) && id > 0) {
+ where.creator_id = id;
+ }
+ }
+ if (Object.keys(where).length) {
+ params.where = where;
+ }
+ return params;
+}
+
+/** 是否系统预设任务(id=1 历史收件) */
+export function isSystemTask(row) {
+ const id = Number((row && (row.id ?? row.task_id)) || 0);
+ return id === DEFAULT_TASK_ID;
+}
+
+/**
+ * 任务行归一化(列表卡片展示字段)
+ * deletable:系统预设任务(id=1)、系统级任务(warehouse_id=0)、已有登记的(register_count>0)都不可删除
+ * (最终仍以服务端 404/409 判定为准)
+ */
+export function normalizeTaskRows(list) {
+ if (!Array.isArray(list)) return [];
+ return list.map((item, index) => {
+ const source = item && typeof item === 'object' ? item : {};
+ const id = Number(source.id ?? source.task_id ?? 0);
+ const warehouseId = Number(source.warehouse_id ?? source.warehouseId ?? 0);
+ const registerCount = Number(source.register_count ?? source.registerCount ?? 0);
+ const systemTask = id === DEFAULT_TASK_ID;
+ return {
+ id,
+ key: `task-${id || index + 1}`,
+ batchNo: firstValue(source, ['batch_no', 'batchNo']),
+ title: firstValue(source, ['title']),
+ creatorId: firstValue(source, ['creator_id', 'creatorId']),
+ creatorName: firstValue(source, ['creator_name', 'creatorName']),
+ warehouseId: Number.isFinite(warehouseId) ? warehouseId : 0,
+ createdAt: formatDateTime(source.created_at ?? source.createdAt),
+ updatedAt: formatDateTime(source.updated_at ?? source.updatedAt),
+ registerCount: Number.isFinite(registerCount) && registerCount > 0 ? registerCount : 0,
+ isSystem: systemTask,
+ deletable: !systemTask && warehouseId !== 0 && !(registerCount > 0)
+ };
+ });
+}
+
+// ===== 导出任务(returnReceived.export / exportTaskProgress)=====
+
+/**
+ * 导出任务响应归一化
+ * 数组/进度接口的 task_id/status/progress/download_url 都在**顶层**,而 result 里另有上传信息对象
+ * (不能用 extractObjectPayload——会优先命中 result,导致 status 取不到)
+ *
+ * @param {Object} response 接口原始响应
+ * @return {{ taskId: string, status: string, progress: number, message: string, currentCount: number, totalCount: number, error: string, downloadUrl: string, fileName: string }}
+ */
+export function normalizeExportTask(response) {
+ const source = response && typeof response === 'object' ? response : {};
+ const result = (source.result && typeof source.result === 'object' && !Array.isArray(source.result)) ? source.result : {};
+ return {
+ taskId: firstValue(source, ['task_id', 'taskId']),
+ status: firstValue(source, ['status']).toLowerCase(),
+ progress: Math.max(0, Math.min(100, Number(source.progress || 0) || 0)),
+ message: firstValue(source, ['message']),
+ currentCount: Number(source.current_count ?? source.currentCount ?? 0) || 0,
+ totalCount: Number(source.total_count ?? source.totalCount ?? 0) || 0,
+ error: firstValue(source, ['error']),
+ downloadUrl: firstValue(source, ['download_url', 'downloadUrl']) ||
+ firstValue(result, ['url', 'cdnUrl', 'cosUrl', 'fileKey']),
+ fileName: firstValue(result, ['filename'])
+ };
+}
+
+/** 创建任务的响应归一化:返回 { id, batchNo, title } */
+export function normalizeCreatedTask(payload) {
+ const source = extractObjectPayload(payload);
+ return {
+ id: Number(source.id ?? 0),
+ batchNo: firstValue(source, ['batch_no', 'batchNo']),
+ title: firstValue(source, ['title'])
+ };
+}
+
+// ===== 扫描记录(returnReceived.list)行归一化 =====
+
+/**
+ * 退回收到登记行归一化(扫描记录列表)
+ * 只保留属于当前任务的行:接口按 return_received_task_id 过滤时全部命中;
+ * 若后端过滤未生效(返回了其它任务的行),此处兜底剔除,并通过 dropped 告知调用方
+ *
+ * @param {Array} list 接口返回的 list
+ * @param {number|string} taskId 当前收件任务ID
+ * @return {{ rows: Array, dropped: number }}
+ */
+export function normalizeReceivedRows(list, taskId) {
+ const rows = Array.isArray(list) ? list : [];
+ const targetTaskId = Number(taskId);
+ const normalized = [];
+ let dropped = 0;
+ rows.forEach((item, index) => {
+ const source = item && typeof item === 'object' ? item : {};
+ const rowTaskId = Number(source.return_received_task_id ?? source.returnReceivedTaskId ?? 0);
+ if (Number.isFinite(targetTaskId) && targetTaskId > 0 && rowTaskId > 0 && rowTaskId !== targetTaskId) {
+ dropped += 1;
+ return;
+ }
+ const isOriginal = !!(source.is_original_return ?? source.isOriginalReturn);
+ // 原单退回优先展示货主名(store_remark),无货主名时回落「原单退回」
+ const storeRemark = firstValue(source, ['store_remark', 'storeRemark']);
+ normalized.push({
+ key: `rec-${source.id || index + 1}`,
+ id: Number(source.id || 0),
+ waybillCode: firstValue(source, ['waybill_code', 'waybillCode']),
+ scanDate: firstValue(source, ['scan_date', 'scanDate']),
+ scannerName: firstValue(source, ['scanner_name', 'scannerName']),
+ remark: firstValue(source, ['remark']),
+ isOriginal,
+ storeRemark,
+ tagText: storeRemark || (isOriginal ? '原单退回' : '非原单'),
+ createdAt: formatDateTime(source.created_at ?? source.createdAt),
+ taskId: rowTaskId
+ });
+ });
+ return { rows: normalized, dropped };
+}
diff --git a/src/pages/work/order/returnRecord.vue b/src/pages/work/order/returnRecord.vue
index a392a90..13d2d56 100644
--- a/src/pages/work/order/returnRecord.vue
+++ b/src/pages/work/order/returnRecord.vue
@@ -1,622 +1,665 @@
-
-
-
- {{ showScanInput ? '关闭手动输入' : '手动输入' }}
-
-
+
-
- 扫描计数:{{ scanCount }}
+
+ 新建
-
-
-
+
+
+
-
-
+
+ 搜索
+
+
+
+
+ {{ item.label }}
+
+ 点击任务进入扫码登记
+
+
+
+
+
+
+
+ {{ loading ? '加载中...' : '暂无收件任务' }}
+ {{ keyword ? '请检查关键字后重试' : '点击右上角「新建」创建收件任务' }}
+
+
+
+
+
+
+ {{ item.batchNo || '--' }}
+
+ 登记 {{ item.registerCount }}
+
+
+
+ {{ item.title || '未命名任务' }}
+ 系统预设
+
+
+ {{ item.creatorName || '--' }}
+ {{ item.createdAt || '--' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 退回类型
- {{ isOriginal ? '原单退回' : '非原单退回' }}
-
-
- 货主备注
- {{ storeRemark }}
-
-
- 备注
- {{ result.remark }}
-
-
-
-
-
- ⚠ 加急订单,请优先处理
-
-
-
-
- 30日内已登记,本次沿用首次登记记录
-
-
+
diff --git a/src/pages/work/order/returnRecordScan.vue b/src/pages/work/order/returnRecordScan.vue
new file mode 100644
index 0000000..e9a1f6f
--- /dev/null
+++ b/src/pages/work/order/returnRecordScan.vue
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+