From 70dd41963245c8ab711580c71132022e99e335d5 Mon Sep 17 00:00:00 2001
From: zm2000 <18386612143@163.com>
Date: Thu, 6 Aug 2026 18:38:18 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E3=80=81=E8=AE=A2=E5=8D=95=E5=A4=8D=E6=A0=B8=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
core/request/apis.js | 6 +
env.js | 4 +-
.../order/order-review-comps/ReviewDetail.vue | 17 ++-
pages/work/order/order-review.vue | 9 ++
pages/work/product/detail.vue | 14 +-
pages/work/product/edit.vue | 140 ++++++++++++++++++
6 files changed, 185 insertions(+), 5 deletions(-)
diff --git a/core/request/apis.js b/core/request/apis.js
index ad3f77f..57dac6e 100644
--- a/core/request/apis.js
+++ b/core/request/apis.js
@@ -288,6 +288,12 @@ export default {
method: "POST",
isSystemApi: true
},
+ saveWarehouseStockBarcode: {
+ path: "stock.warehouse.saveWarehouseStockBarcode",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
saveWarehouseStock: {
path: "stock.warehouse.saveWarehouseStock",
auth: true,
diff --git a/env.js b/env.js
index b87b72a..c33f58a 100644
--- a/env.js
+++ b/env.js
@@ -1,4 +1,4 @@
-export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
-// export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
+// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
+export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
export const API_URL = `${BASE_URL}/system` //后台接口域名
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss
diff --git a/pages/work/order/order-review-comps/ReviewDetail.vue b/pages/work/order/order-review-comps/ReviewDetail.vue
index ff25d36..64144c5 100644
--- a/pages/work/order/order-review-comps/ReviewDetail.vue
+++ b/pages/work/order/order-review-comps/ReviewDetail.vue
@@ -57,7 +57,7 @@
>
- {{ item.lineNo || 0 }}
+ {{ showBoxNoColumn ? (item.boxNo || '--') : (item.lineNo || 0) }}
{{ item.planQty || 0 }}
{{ item.scannedQty || 0 }}
@@ -82,6 +82,10 @@
>
+
+ 蓝号
+ {{ item.boxNo || '--' }}
+
数量
{{ item.planQty || 0 }}
@@ -249,6 +253,10 @@ import voice from '@/core/utils/voice';
scannedPackageMaterial: {
type: Object,
default: null
+ },
+ pickMode: {
+ type: [Number, String],
+ default: ''
}
},
data() {
@@ -297,6 +305,11 @@ import voice from '@/core/utils/voice';
isReadOnly() {
return String(this.detailInfo?.recheckStatus || '').toLowerCase() === 'fin';
},
+ showBoxNoColumn() {
+ // 散单模式 pick_mode=3 时显示蓝号列,顺序为 蓝号、数量、已扫
+ // 以 pick_mode 为准(pick_mode=3 即散单模式),避免依赖 listType 取值差异
+ return Number(this.pickMode) === 3;
+ },
isScannedComplete() {
const plan = Number(this.currentGoods?.planQty || 0);
const scanned = Number(this.currentGoods?.scannedQty || 0);
@@ -1133,7 +1146,7 @@ import voice from '@/core/utils/voice';
padding: 20rpx 0 8rpx 16rpx;
}
- .list-card-qty-item:first-child {
+ .list-card-qty-item:not(:last-child) {
border-right: 1rpx solid #000000;
}
diff --git a/pages/work/order/order-review.vue b/pages/work/order/order-review.vue
index c546218..1043e93 100644
--- a/pages/work/order/order-review.vue
+++ b/pages/work/order/order-review.vue
@@ -44,6 +44,7 @@
:scanQty="scanQuantity"
:autoShip="autoShip"
:scannedPackageMaterial="scannedPackageMaterial"
+ :pickMode="pickMode"
@updateScannedQty="handleUpdateScannedQty"
@allScanned="handleDetailAllScanned"
@resetScanQty="handleResetScanQty"
@@ -457,6 +458,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
goodsInfoList: [],
orderList: [],
listType: '', packingRequirements: '',
+ pickMode: '',
totalOrders: 0,
taskId: '',
scanPickerName: '',
@@ -1607,6 +1609,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
const matchType = String(payload?.match_type || payload?.matchType || '').trim();
const taskId = String(payload?.task_id ?? payload?.taskId ?? '').trim();
const pickerName = String(payload?.picker_name || payload?.pickerName || '').trim();
+ const pickMode = payload?.pick_mode ?? payload?.pickMode ?? '';
// 扁平化订单列表模式(散单:运单号/波次号命中)
const totalOrders = Number(payload?.total_orders ?? payload?.totalOrders ?? 0);
@@ -1617,6 +1620,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
return {
listType: 'single',
matchType,
+ pickMode,
list: list.map(item => this.normalizeScanOrderItem(item)),
total: Number(payload?.total ?? payload?.count ?? list.length),
totalOrders,
@@ -1665,6 +1669,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
return {
listType: 'group',
matchType,
+ pickMode,
waves: normalizedWaves,
waybillNo: groupWaybillNo,
waveId: currentWaveId,
@@ -1718,6 +1723,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
return {
listType: 'detail',
matchType,
+ pickMode,
cartMatchView,
orderId,
recheckStatus,
@@ -1775,6 +1781,7 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
this.listType = result?.listType || '';
this.taskId = result?.taskId || '';
this.scanPickerName = result?.pickerName || '';
+ this.pickMode = result?.pickMode || '';
const listType = this.listType;
// 散单模式(list_type=single):刷新当前页面列表
@@ -2310,10 +2317,12 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
const stockName = stockItem ? String(stockItem.item_name || '').trim() : '';
const barcodeSource = stockItem?.barcodes || rawItem?.barcodes || rawItem?.barcode || snapshot?.barcodes || snapshot?.barcode || [];
const stockBarcodes = this.normalizeBarcodeValues(barcodeSource);
+ const boxNo = String(stockItem?.box_no ?? stockItem?.boxNo ?? rawItem?.box_no ?? rawItem?.boxNo ?? '').trim();
return {
id: String(rawItem?.id || stockItem?.stock_id || `item-${index + 1}`),
lineNo: Number(rawItem?.order_line_no) || (index + 1),
+ boxNo,
planQty: isNaN(planQty) ? 0 : planQty,
scannedQty: isNaN(scannedQty) ? 0 : scannedQty,
packageRequirement: String(rawItem?.packing_requirements || rawItem?.package_requirement || rawItem?.packageRequirement || rawItem?.packing_requirement || '').trim() || '--',
diff --git a/pages/work/product/detail.vue b/pages/work/product/detail.vue
index 6ed7f24..c440103 100644
--- a/pages/work/product/detail.vue
+++ b/pages/work/product/detail.vue
@@ -203,6 +203,18 @@ export default {
this.item = cached;
}
},
+ onShow() {
+ // 从编辑页返回时,重新读取缓存,确保展示最新数据(含商品条码)
+ if (this.cacheKey) {
+ const cached = uni.getStorageSync(this.cacheKey);
+ if (cached && typeof cached === 'object') {
+ this.item = {
+ ...(this.item || {}),
+ ...cached
+ };
+ }
+ }
+ },
onUnload() {
if (this.onProductUpdated) {
uni.$off('product:detail:updated', this.onProductUpdated);
@@ -226,7 +238,7 @@ export default {
const editCacheKey = `product_edit_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
uni.setStorageSync(editCacheKey, this.item);
uni.navigateTo({
- url: `/pages/work/product/edit?cacheKey=${editCacheKey}`
+ url: `/pages/work/product/edit?cacheKey=${editCacheKey}&detailCacheKey=${encodeURIComponent(this.cacheKey || '')}`
});
},
getValueOrDash(value) {
diff --git a/pages/work/product/edit.vue b/pages/work/product/edit.vue
index 8a6d33f..f07d4a3 100644
--- a/pages/work/product/edit.vue
+++ b/pages/work/product/edit.vue
@@ -12,6 +12,9 @@
+
+
+
@@ -104,6 +107,7 @@ export default {
data() {
return {
cacheKey: '',
+ detailCacheKey: '',
saving: false,
canceling: false,
keepVoiceOnExit: false,
@@ -120,6 +124,7 @@ export default {
formData: {
item_name: '',
goods_code: '',
+ barcodes: '',
brand_name: '',
sku_property: '',
prohibited_type_id: null,
@@ -142,6 +147,11 @@ export default {
onLoad(options) {
this.keepVoiceOnExit = false;
this.cacheKey = (options && options.cacheKey) || '';
+ this.detailCacheKey = (options && options.detailCacheKey) || '';
+ this.safeDispatchBroadcast('setCallbacks', {
+ onResult: this.handleBroadcastResult
+ });
+ this.safeDispatchBroadcast('start');
this.loadProhibitedTypes();
this.loadStockUnits();
if (!this.cacheKey) {
@@ -158,6 +168,7 @@ export default {
};
this.formData.item_name = String(cached.item_name || cached.product_name || cached.name || '');
this.formData.goods_code = String(cached.goods_code || cached.item_code || '');
+ this.formData.barcodes = this.normalizeBarcodeDisplay(cached);
this.formData.brand_name = String(cached.brand_name || '');
this.formData.sku_property = String(cached.sku_property || '');
this.formData.prohibited_type_id = this.getProhibitedTypeId(cached);
@@ -174,6 +185,13 @@ export default {
this.sessionUploadedFileIds = [];
this.latestImagesLoadPromise = this.loadLatestImages();
},
+ onShow() {
+ // 返回页面时重新注册广播回调并恢复扫描
+ this.safeDispatchBroadcast('setCallbacks', {
+ onResult: this.handleBroadcastResult
+ });
+ this.safeDispatchBroadcast('resume');
+ },
onBackPress() {
if (this.bypassBackIntercept || this.saving) {
// 已经在回退流程中,放行系统返回
@@ -192,6 +210,7 @@ export default {
if (!this.keepVoiceOnExit) {
this.stopProductEditSpeak();
}
+ this.safeDispatchBroadcast('stop');
if (this.cacheKey) {
uni.removeStorageSync(this.cacheKey);
}
@@ -200,8 +219,54 @@ export default {
if (!this.keepVoiceOnExit) {
this.stopProductEditSpeak();
}
+ this.safeDispatchBroadcast('pause');
},
methods: {
+ safeDispatchBroadcast(action, payload) {
+ try {
+ const task = this.$store.dispatch(`broadcast/${action}`, payload);
+ if (task && typeof task.catch === 'function') {
+ task.catch(error => {
+ console.warn(`[ProductEdit] broadcast/${action} 调用失败:`, error);
+ });
+ }
+ } catch (error) {
+ console.warn(`[ProductEdit] broadcast/${action} 调用异常:`, error);
+ }
+ },
+ normalizeScanResult(scanResult) {
+ if (!scanResult) {
+ return '';
+ }
+
+ let value = '';
+ if (typeof scanResult === 'string') {
+ value = scanResult;
+ } else if (typeof scanResult.result === 'string') {
+ value = scanResult.result;
+ } else if (Array.isArray(scanResult.result)) {
+ const firstResult = scanResult.result.find(item => item);
+ if (typeof firstResult === 'string') {
+ value = firstResult;
+ } else if (firstResult && typeof firstResult.data === 'string') {
+ value = firstResult.data;
+ }
+ } else if (typeof scanResult.data === 'string') {
+ value = scanResult.data;
+ }
+
+ return String(value || '').replace(/\s+/g, '').trim();
+ },
+ handleBroadcastResult(result) {
+ const scanResult = this.normalizeScanResult(result);
+ if (!scanResult) {
+ return;
+ }
+
+ // 广播扫描仅支持单个条码:直接替换当前值
+ this.formData.barcodes = scanResult;
+ this.showToastMessage(`已录入条码 ${scanResult}`, 'none', { speak: false });
+ },
normalizePositiveId(value) {
const numericValue = Number(value);
if (!Number.isFinite(numericValue)) {
@@ -211,6 +276,61 @@ export default {
const normalized = Math.trunc(numericValue);
return normalized > 0 ? normalized : null;
},
+ normalizeBarcodeDisplay(item) {
+ if (!item || typeof item !== 'object') {
+ return '';
+ }
+
+ const source = item.barcodes || item.barcode || '';
+ if (Array.isArray(source)) {
+ return source
+ .map(entry => {
+ if (entry === null || entry === undefined) {
+ return '';
+ }
+ if (typeof entry === 'string') {
+ return entry.trim();
+ }
+ if (typeof entry === 'object') {
+ return String(entry.barcode || entry.code || '').trim();
+ }
+ return '';
+ })
+ .filter(Boolean)
+ .join(';');
+ }
+
+ return String(source || '').trim();
+ },
+ parseBarcodeInput(value) {
+ const raw = String(value || '');
+ return raw
+ .split(/[;,,\s]+/)
+ .map(item => item.trim())
+ .filter(Boolean);
+ },
+ extractSavedIdFromResponse(response) {
+ if (!response || typeof response !== 'object') {
+ return null;
+ }
+
+ const data = response.data;
+ const candidates = [
+ data && typeof data === 'object' ? (data.id || data.stock_id) : null,
+ typeof data === 'number' || typeof data === 'string' ? data : null,
+ response.id,
+ response.stock_id
+ ];
+
+ for (let i = 0; i < candidates.length; i++) {
+ const normalized = this.normalizePositiveId(candidates[i]);
+ if (normalized) {
+ return normalized;
+ }
+ }
+
+ return null;
+ },
normalizeSpeechText(message) {
const rawText = String(message || '').trim();
if (!rawText) {
@@ -1062,6 +1182,19 @@ export default {
throw new Error((saveRes && saveRes.message) || '保存失败');
}
+ // 保存商品条码:stock.warehouse.saveWarehouseStockBarcode
+ const barcodeList = this.parseBarcodeInput(this.formData.barcodes);
+ const targetStockId = recordId || this.extractSavedIdFromResponse(saveRes);
+ if (targetStockId && barcodeList.length > 0) {
+ const barcodeRes = await this.$http('stock.warehouse.saveWarehouseStockBarcode', {
+ id: Number(targetStockId),
+ barcodes: barcodeList
+ });
+ if (!barcodeRes || Number(barcodeRes.code) !== 200) {
+ throw new Error((barcodeRes && barcodeRes.message) || '商品条码保存失败');
+ }
+ }
+
let latestItem = null;
try {
const refreshRes = await this.$http(
@@ -1088,6 +1221,8 @@ export default {
name: itemName,
goods_code: itemCode,
item_code: itemCode,
+ barcodes: barcodeList,
+ barcode: barcodeList[0] || (this.rawItem && this.rawItem.barcode) || '',
brand_name: String(this.formData.brand_name || '').trim(),
sku_property: String(this.formData.sku_property || '').trim(),
prohibited_type_id: this.formData.prohibited_type_id,
@@ -1110,6 +1245,11 @@ export default {
timestamp: Date.now()
});
+ // 同步更新详情页缓存,保证详情页返回后展示最新数据(含商品条码)
+ if (this.detailCacheKey) {
+ uni.setStorageSync(this.detailCacheKey, nextItem);
+ }
+
uni.setStorageSync('product_query_need_refresh', Date.now());
uni.$emit('product:query:updated', {
item: nextItem,