From 002fdbf45502901faa939b1aa85dc985823f04dd Mon Sep 17 00:00:00 2001 From: zm2000 <18386612143@163.com> Date: Mon, 26 Oct 2026 17:58:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=9B=98=E7=82=B9):=20=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3=E6=8E=A5=E5=85=A5=20space?= =?UTF-8?q?=5Fid=20=E5=BA=93=E4=BD=8DID=E5=B9=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E4=B8=8A=E9=99=90=E6=A0=A1=E9=AA=8C=EF=BC=8C?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7=E8=87=B3=201.0.132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - check.report 上报新增 space_id(wms_location_space.id)必传,兼容 spaceId/location_id/locationId/space_id 多种写法,按库位ID精确落库 - countModel 各视图(space/goods/location/商品详情)统一补充 spaceId、 locationId 字段,并在 buildWorkUnit 中透传库位ID - 各盘点页(Detail/Goods/Location/Space)提交时补传 space_id,缺失时 弹窗提示「缺少库位ID(space_id)」 - 实盘数量增加上限校验(0~2147483647),防止超出 int 范围导致上报失败 - package.json / manifest.json 版本号升级至 1.0.132(versionCode 1000132) --- package.json | 2 +- src/manifest.json | 4 +- .../inventoryCount-comps/countModel.js | 43 ++++++++++++++++--- src/pages/warehouse/inventoryCountDetail.vue | 20 ++++++--- src/pages/warehouse/inventoryCountGoods.vue | 11 ++++- .../warehouse/inventoryCountLocation.vue | 15 ++++++- src/pages/warehouse/inventoryCountSpace.vue | 16 ++++++- 7 files changed, 91 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 81c07d6..57d4bd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-pda", - "version": "1.0.131", + "version": "1.0.132", "private": true, "description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)", "scripts": { diff --git a/src/manifest.json b/src/manifest.json index d10952b..3f71d89 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "WMS_PDA", "appid" : "__UNI__0B3DAD3", "description" : "多平台快速开发的UI框架", - "versionName" : "1.0.131", - "versionCode" : 1000131, + "versionName" : "1.0.132", + "versionCode" : 1000132, "transformPx" : false, "app-plus" : { "optimization" : { diff --git a/src/pages/warehouse/inventoryCount-comps/countModel.js b/src/pages/warehouse/inventoryCount-comps/countModel.js index 52c7f4f..4a4fbc8 100644 --- a/src/pages/warehouse/inventoryCount-comps/countModel.js +++ b/src/pages/warehouse/inventoryCount-comps/countModel.js @@ -564,13 +564,15 @@ function buildWorkAmount(systemQuantity, checkedQuantity, diffQuantity, open) { } /** 录入单元:detailId + location + 输入值(original 用于判断是否已修改) */ -function buildWorkUnit(detailId, location, currentQuantity, reported, stockId) { +function buildWorkUnit(detailId, location, currentQuantity, reported, stockId, spaceId) { const value = toNumberString(currentQuantity); const done = !!reported; return { detailId: detailId ? String(detailId) : '', location: location ? String(location) : '', stockId: stockId === undefined || stockId === null ? '' : String(stockId), + // 库位ID(wms_location_space.id):report 必传 space_id(兼容 location_id 同值) + spaceId: spaceId === undefined || spaceId === null ? '' : String(spaceId), inputValue: done ? value : '', original: done ? value : '', reported: done, @@ -580,8 +582,10 @@ function buildWorkUnit(detailId, location, currentQuantity, reported, stockId) { /** * 构造 check.report 入参(按 https 文档口径) - * - 商品明细行:stock_id 固定为明细商品;location 可选(未传归入无库位分组) - * - 库位明细行:必须带商品(stock_id 或 barcode 至少一项),location 以明细库位为准 + * - space_id 必传(wms_location_space.id,兼容 spaceId/location_id/locationId 写法):库位一律按库位ID落库 + * - location 降级为可选一致性校验(与 space_id 对应编码不一致返回 400) + * - 商品明细行:stock_id 固定为明细商品(与 space_id 一起定位「库位+商品」) + * - 库位明细行:必须带商品(stock_id 或 barcode 至少一项),space_id 对应编码须等于明细库位编码 * - 未知商品:只传 barcode(item_name 可选,缺省为条码) * - 空库位标记:is_empty=true(仅库位明细行,quantity 恒为 0) */ @@ -592,6 +596,18 @@ export function buildReportParams(taskId, payload = {}) { detail_id: Number(payload.detailId), quantity: isEmpty ? 0 : Number(payload.quantity) }; + // 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() !== '' + ? payload.spaceId + : (payload.locationId !== undefined && payload.locationId !== null && String(payload.locationId).trim() !== '' + ? payload.locationId + : (payload.space_id !== undefined && payload.space_id !== null && String(payload.space_id).trim() !== '' + ? payload.space_id + : (payload.location_id !== undefined && payload.location_id !== null && String(payload.location_id).trim() !== '' + ? payload.location_id : ''))); + if (spaceId !== '') { + params.space_id = Number(spaceId); + } if (isEmpty) { params.is_empty = true; return params; @@ -617,6 +633,8 @@ function joinText(parts, sep = ' · ') { function normalizeSpaceWorkRow(item, index, open) { const source = item && typeof item === 'object' ? item : {}; const spaceCode = firstValue(source, ['space_code', 'spaceCode']) || `#${index + 1}`; + // space 视图行:space_id 与 location_id 均等于既有 id(wms_location_space.id) + const rowSpaceId = firstValue(source, ['space_id', 'location_id', 'id']); const rawGoods = Array.isArray(source.goods) ? source.goods : []; const children = rawGoods.map((row, goodIndex) => { const good = row && typeof row === 'object' ? row : {}; @@ -631,7 +649,7 @@ function normalizeSpaceWorkRow(item, index, open) { statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo', amount: buildWorkAmount(good.system_quantity !== undefined ? good.system_quantity : good.systemQuantity, checkedRaw, null, open), quantityText: '', - unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId'])) + unit: buildWorkUnit(detailId, spaceCode, checkedRaw, done, firstValue(good, ['stock_id', 'stockId']), rowSpaceId) }; }); // 库位统计(口径=商品条数):商品 status=checked 即该明细在该库位已有作业记录 @@ -656,8 +674,8 @@ function normalizeSpaceWorkRow(item, index, open) { children, unit: null, // 宫格展示字段(与 location 视图对齐:行=库位;space 行没有库位明细ID) - // 库位ID(wms_location_space.id)——跳「单库位作业页」(workDataSpaceDetails)用 - spaceId: firstValue(source, ['id']) ? String(firstValue(source, ['id'])) : '', + // 库位ID(wms_location_space.id)——跳「单库位作业页」(workDataSpaceDetails)与 report 回传用 + spaceId: rowSpaceId || '', location: spaceCode, locationName: spaceName || spaceCode, empty: false, @@ -686,6 +704,7 @@ function normalizeGoodsWorkRow(item, index, open) { const loc = row && typeof row === 'object' ? row : {}; const code = firstValue(loc, ['location_code', 'locationCode']); const time = firstValue(loc, ['checked_at', 'checkedAt']); + const locSpaceId = firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']); return { key: `${detailId || index + 1}-loc-${locIndex + 1}`, title: code || '未指定库位', @@ -694,6 +713,9 @@ function normalizeGoodsWorkRow(item, index, open) { statusClass: '', amount: null, quantityText: open && loc.quantity !== undefined && loc.quantity !== null ? String(loc.quantity) : '', + // 库位ID(wms_location_space.id):goods 视图 locations[] 新增字段,供 report 回传 + spaceId: locSpaceId || '', + locationId: locSpaceId || '', unit: null }; }); @@ -747,6 +769,8 @@ function normalizeLocationWorkRow(item, index, open) { const source = item && typeof item === 'object' ? item : {}; const locationCode = firstValue(source, ['location_code', 'locationCode']) || `#${index + 1}`; const detailId = firstValue(source, ['detail_id', 'detailId']); + // 库位明细的库位ID(location 视图 location_id 保持不变):report 的 space_id 以此为库位 + const locationId = firstValue(source, ['location_id', 'locationId', 'space_id', 'spaceId']); const status = String(source.status || '').trim().toLowerCase(); const done = status === 'checked'; const rawGoods = Array.isArray(source.goods) ? source.goods : []; @@ -800,6 +824,9 @@ function normalizeLocationWorkRow(item, index, open) { view: 'location', detailId: detailId ? String(detailId) : '', location: locationCode, + // 库位ID(wms_location_space.id):report 必传 space_id + spaceId: locationId || '', + locationId: locationId || '', // 库位明细面板:标题优先显示库位名称,副标题显示库位编码(与库位/库位名称互换) title: locationName || locationCode, subtitle: locationName && locationName !== locationCode ? locationCode : '', @@ -954,6 +981,7 @@ export function normalizeGoodsDetailInfo(row, mode) { const loc = item && typeof item === 'object' ? item : {}; const locationCode = firstValue(loc, ['location_code', 'locationCode']) || ''; const locationName = firstValue(loc, ['location_name', 'locationName']) || ''; + const spaceId = firstValue(loc, ['space_id', 'location_id', 'locationId', 'spaceId']); const recordIds = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : []; const systemQuantity = toNumberOrNull(loc.system_quantity !== undefined ? loc.system_quantity : loc.systemQuantity); const quantity = toNumberOrNull(loc.quantity); @@ -968,6 +996,9 @@ export function normalizeGoodsDetailInfo(row, mode) { recordIds, recordId: recordIds.length === 1 ? recordIds[0] : '', locationCode, + // 库位ID(wms_location_space.id):goods 视图 locations[] 新增字段,供 report 回传 + spaceId: spaceId || '', + locationId: spaceId || '', systemQuantity, quantity, title: locationName || locationCode || '未指定库位', diff --git a/src/pages/warehouse/inventoryCountDetail.vue b/src/pages/warehouse/inventoryCountDetail.vue index f65e2d4..06c6a8a 100644 --- a/src/pages/warehouse/inventoryCountDetail.vue +++ b/src/pages/warehouse/inventoryCountDetail.vue @@ -250,7 +250,7 @@ export default { markEmptyTarget: null, showDetailPicker: false, showRecordAdd: false, - recordAddTarget: { detailId: '', location: '', locationName: '' }, + recordAddTarget: { detailId: '', location: '', locationName: '', spaceId: '' }, currentTab: 0, // 作业数据(stock.check.workData) workList: [], @@ -706,7 +706,7 @@ export default { const key = payload && payload.key; if (!row || !this.canEdit) return; if (key === 'add-goods') { - this.recordAddTarget = { detailId: row.detailId || '', location: row.location || '', locationName: row.locationName || '' }; + this.recordAddTarget = { detailId: row.detailId || '', location: row.location || '', locationName: row.locationName || '', spaceId: row.spaceId || '' }; this.showRecordAdd = true; return; } @@ -717,7 +717,9 @@ export default { handleRecordAddConfirm(payload) { this.showRecordAdd = false; if (!payload || !payload.detailId) return; - this.submitReport(payload, '已添加'); + this.submitReport(Object.assign({}, payload, { + spaceId: payload.spaceId || this.recordAddTarget.spaceId || '' + }), '已添加'); }, handleMarkEmpty(row) { if (!row || !row.detailId) return; @@ -736,6 +738,7 @@ export default { const ok = await this.submitReport({ detailId: row.detailId, location: row.location, + spaceId: row.spaceId, isEmpty: true }, '已标记空库位'); this.speakMessage(ok ? '已标记空库位' : '标记失败', { force: true, minInterval: 0 }); @@ -749,14 +752,20 @@ export default { } const isEmpty = !!payload.isEmpty; const quantity = Number(payload.quantity); - if (!isEmpty && (!Number.isInteger(quantity) || quantity < 0)) { - uni.showToast({ title: '实盘数量须为不小于0的整数', icon: 'none' }); + if (!isEmpty && (!Number.isInteger(quantity) || quantity < 0 || quantity > 2147483647)) { + uni.showToast({ title: '实盘数量须为不小于0且不超过2147483647的整数', icon: 'none' }); + return false; + } + const spaceId = String(payload.spaceId || '').trim(); + if (!spaceId) { + uni.showToast({ title: '缺少库位ID(space_id)', icon: 'none' }); return false; } try { const response = await this.$http('check.report', buildReportParams(this.taskId, { detailId: payload.detailId, location: payload.location, + spaceId, quantity, stockId: payload.stockId, barcode: payload.barcode, @@ -791,6 +800,7 @@ export default { await this.submitReport({ detailId: unit.detailId, location: unit.location, + spaceId: unit.spaceId, quantity: Number(raw), stockId: unit.stockId }, '已记录', options); diff --git a/src/pages/warehouse/inventoryCountGoods.vue b/src/pages/warehouse/inventoryCountGoods.vue index 211e6a8..97527d1 100644 --- a/src/pages/warehouse/inventoryCountGoods.vue +++ b/src/pages/warehouse/inventoryCountGoods.vue @@ -394,6 +394,7 @@ export default { const ok = await this.submitReport({ detailId: this.detailId, location: payload.location, + spaceId: payload.locationId, quantity: payload.quantity, stockId: this.goodsInfo.stockId }); @@ -415,9 +416,14 @@ export default { uni.showToast({ title: '请选择库位', icon: 'none' }); return false; } + const spaceId = String(payload.spaceId || payload.locationId || '').trim(); + if (!spaceId) { + uni.showToast({ title: '缺少库位ID(space_id)', icon: 'none' }); + return false; + } const quantity = Number(payload.quantity); - if (!Number.isInteger(quantity) || quantity < 0) { - uni.showToast({ title: '请输入不小于0的整数数量', icon: 'none' }); + if (!Number.isInteger(quantity) || quantity < 0 || quantity > 2147483647) { + uni.showToast({ title: '请输入不小于0且不超过2147483647的整数数量', icon: 'none' }); return false; } this.submitting = true; @@ -425,6 +431,7 @@ export default { const response = await this.$http('check.report', buildReportParams(this.taskId, { detailId: payload.detailId, location, + spaceId, quantity, stockId: payload.stockId, barcode: this.goodsInfo.barcode, diff --git a/src/pages/warehouse/inventoryCountLocation.vue b/src/pages/warehouse/inventoryCountLocation.vue index 449f5fc..c2ef6e9 100644 --- a/src/pages/warehouse/inventoryCountLocation.vue +++ b/src/pages/warehouse/inventoryCountLocation.vue @@ -416,8 +416,18 @@ export default { } const isEmpty = !!payload.isEmpty; const quantity = Number(payload.quantity); - if (!isEmpty && (!Number.isInteger(quantity) || quantity < 0)) { - uni.showToast({ title: '实盘数量须为不小于0的整数', icon: 'none' }); + if (!isEmpty && (!Number.isInteger(quantity) || quantity < 0 || quantity > 2147483647)) { + uni.showToast({ title: '实盘数量须为不小于0且不超过2147483647的整数', icon: 'none' }); + return false; + } + // 库位明细行:space_id 取明细的 location_id(workDataDetail 返回,report 必传) + const spaceId = String( + payload.spaceId !== undefined && payload.spaceId !== null && String(payload.spaceId).trim() !== '' + ? payload.spaceId + : (this.row && (this.row.spaceId || this.row.locationId)) || '' + ).trim(); + if (!spaceId) { + uni.showToast({ title: '缺少库位ID(space_id)', icon: 'none' }); return false; } if (this.submitting) return false; @@ -426,6 +436,7 @@ export default { const response = await this.$http('check.report', buildReportParams(this.taskId, { detailId: payload.detailId, location: payload.location, + spaceId, quantity, stockId: payload.stockId, barcode: payload.barcode, diff --git a/src/pages/warehouse/inventoryCountSpace.vue b/src/pages/warehouse/inventoryCountSpace.vue index ff95730..e64eaec 100644 --- a/src/pages/warehouse/inventoryCountSpace.vue +++ b/src/pages/warehouse/inventoryCountSpace.vue @@ -234,6 +234,7 @@ export default { await this.submitReport({ detailId: unit.detailId, location: unit.location, + spaceId: unit.spaceId || (this.row && this.row.spaceId) || this.locationId, quantity: Number(raw), stockId: unit.stockId }, '已记录'); @@ -249,8 +250,18 @@ export default { return false; } const quantity = Number(payload.quantity); - if (!Number.isInteger(quantity) || quantity < 0) { - uni.showToast({ title: '实盘数量须为不小于0的整数', icon: 'none' }); + if (!Number.isInteger(quantity) || quantity < 0 || quantity > 2147483647) { + uni.showToast({ title: '实盘数量须为不小于0且不超过2147483647的整数', icon: 'none' }); + return false; + } + // space 视图行 space_id = 库位ID(wms_location_space.id),report 必传 + const spaceId = String( + payload.spaceId !== undefined && payload.spaceId !== null && String(payload.spaceId).trim() !== '' + ? payload.spaceId + : (this.row && this.row.spaceId) || this.locationId || '' + ).trim(); + if (!spaceId) { + uni.showToast({ title: '缺少库位ID(space_id)', icon: 'none' }); return false; } if (this.submitting) return false; @@ -259,6 +270,7 @@ export default { const response = await this.$http('check.report', buildReportParams(this.taskId, { detailId: payload.detailId, location: payload.location, + spaceId, quantity, stockId: payload.stockId }));