feat(B2B备货): 详情页扫描标记与批量箱号操作,语音播报优化
- pickupOperation/stockPreparation 列表新增"快递"字段展示 - stockPreparation 进入详情页携带运单号,返回列表时清空搜索关键词 - stockPreparationDetail 展示运单号,商品扫描后标记"已扫" - 箱号支持"+总箱数"批量生成、按区间批量删除、清空全部 - 集成扫码广播生命周期,条码归一化后匹配商品 - 语音播报:HTTP 接口失败后 60 秒内跳过避免超时阻塞,TTS 初始化失败清理状态 - 版本号升级至 1.0.146(package.json / manifest.json)
This commit is contained in:
parent
2399a2a4a0
commit
545018caaf
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-pda",
|
"name": "wms-pda",
|
||||||
"version": "1.0.145",
|
"version": "1.0.146",
|
||||||
"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": {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class VoiceBroadcastManager {
|
|||||||
this.lastText = '';
|
this.lastText = '';
|
||||||
this.lastSpeakAt = 0;
|
this.lastSpeakAt = 0;
|
||||||
this.audio = null;
|
this.audio = null;
|
||||||
|
this.httpFailedUntil = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
isSupported() {
|
isSupported() {
|
||||||
@ -91,6 +92,8 @@ class VoiceBroadcastManager {
|
|||||||
try {
|
try {
|
||||||
if (status !== successCode && status !== 0) {
|
if (status !== successCode && status !== 0) {
|
||||||
console.warn('[VoiceBroadcast] TTS 初始化失败, status:', status);
|
console.warn('[VoiceBroadcast] TTS 初始化失败, status:', status);
|
||||||
|
this.tts = null;
|
||||||
|
this.initListener = null;
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -247,8 +250,14 @@ class VoiceBroadcastManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 优先 HTTP 语音接口
|
// 1. 优先 HTTP 语音接口(近期失败过则跳过,避免每次 3 秒超时阻塞后续原生/TTS 播报)
|
||||||
const httpResult = await this.playByHttp(content);
|
let httpResult = false;
|
||||||
|
if (now >= this.httpFailedUntil) {
|
||||||
|
httpResult = await this.playByHttp(content);
|
||||||
|
if (!httpResult) {
|
||||||
|
this.httpFailedUntil = Date.now() + 60000;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (httpResult) {
|
if (httpResult) {
|
||||||
this.lastText = content;
|
this.lastText = content;
|
||||||
this.lastSpeakAt = Date.now();
|
this.lastSpeakAt = Date.now();
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
"name" : "WMS_PDA",
|
"name" : "WMS_PDA",
|
||||||
"appid" : "__UNI__0B3DAD3",
|
"appid" : "__UNI__0B3DAD3",
|
||||||
"description" : "多平台快速开发的UI框架",
|
"description" : "多平台快速开发的UI框架",
|
||||||
"versionName" : "1.0.145",
|
"versionName" : "1.0.146",
|
||||||
"versionCode" : 1000145,
|
"versionCode" : 1000146,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"statusbar" : {
|
"statusbar" : {
|
||||||
|
|||||||
@ -67,6 +67,10 @@
|
|||||||
<text class="info-label">总箱数:</text>
|
<text class="info-label">总箱数:</text>
|
||||||
<text class="info-value">{{ item.total_box_count || 0 }}</text>
|
<text class="info-value">{{ item.total_box_count || 0 }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="info-label">快递:</text>
|
||||||
|
<text class="info-value">{{ getLogisticsName(item) || '--' }}</text>
|
||||||
|
</view>
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text class="info-label">备货人:</text>
|
<text class="info-label">备货人:</text>
|
||||||
<text class="info-value">{{ getPrepOperatorName(item) }}</text>
|
<text class="info-value">{{ getPrepOperatorName(item) }}</text>
|
||||||
@ -463,6 +467,9 @@
|
|||||||
const flag = item?.has_sn_item ?? item?.is_sn_order ?? item?.need_sn ?? item?.has_sn ?? item?.is_sn;
|
const flag = item?.has_sn_item ?? item?.is_sn_order ?? item?.need_sn ?? item?.has_sn ?? item?.is_sn;
|
||||||
return String(flag || '').toUpperCase() === 'Y';
|
return String(flag || '').toUpperCase() === 'Y';
|
||||||
},
|
},
|
||||||
|
getLogisticsName(item) {
|
||||||
|
return item?.logistics_name || item?.sys_logistics_name || '';
|
||||||
|
},
|
||||||
getPickupStatus(item) {
|
getPickupStatus(item) {
|
||||||
return String(item?.is_picked_up || 'N');
|
return String(item?.is_picked_up || 'N');
|
||||||
},
|
},
|
||||||
|
|||||||
@ -67,6 +67,10 @@
|
|||||||
<text class="info-label">总箱数:</text>
|
<text class="info-label">总箱数:</text>
|
||||||
<text class="info-value">{{ item.total_box_count || 0 }}</text>
|
<text class="info-value">{{ item.total_box_count || 0 }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="info-row">
|
||||||
|
<text class="info-label">快递:</text>
|
||||||
|
<text class="info-value">{{ getLogisticsName(item) || '--' }}</text>
|
||||||
|
</view>
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text class="info-label">备货人:</text>
|
<text class="info-label">备货人:</text>
|
||||||
<text class="info-value">{{ item.prep_operator_name || '--' }}</text>
|
<text class="info-value">{{ item.prep_operator_name || '--' }}</text>
|
||||||
@ -160,6 +164,7 @@
|
|||||||
this.safeDispatchBroadcast('resume');
|
this.safeDispatchBroadcast('resume');
|
||||||
// 从详情页返回时刷新备货状态(首次进入由 onLoad 拉取,避免重复)
|
// 从详情页返回时刷新备货状态(首次进入由 onLoad 拉取,避免重复)
|
||||||
if (this._hasShown) {
|
if (this._hasShown) {
|
||||||
|
this.keyword = '';
|
||||||
this.currentPage = 1;
|
this.currentPage = 1;
|
||||||
this.fetchList();
|
this.fetchList();
|
||||||
}
|
}
|
||||||
@ -348,6 +353,9 @@
|
|||||||
const flag = item?.has_sn_item ?? item?.is_sn_order ?? item?.need_sn ?? item?.has_sn ?? item?.is_sn;
|
const flag = item?.has_sn_item ?? item?.is_sn_order ?? item?.need_sn ?? item?.has_sn ?? item?.is_sn;
|
||||||
return String(flag || '').toUpperCase() === 'Y';
|
return String(flag || '').toUpperCase() === 'Y';
|
||||||
},
|
},
|
||||||
|
getLogisticsName(item) {
|
||||||
|
return item?.logistics_name || item?.sys_logistics_name || '';
|
||||||
|
},
|
||||||
getPrepStatus(item) {
|
getPrepStatus(item) {
|
||||||
return String(item?.prep_status || 'none');
|
return String(item?.prep_status || 'none');
|
||||||
},
|
},
|
||||||
@ -434,9 +442,9 @@
|
|||||||
uni.showToast({ title: '该订单已由其他工号备货,无法操作', icon: 'none', duration: 2500 });
|
uni.showToast({ title: '该订单已由其他工号备货,无法操作', icon: 'none', duration: 2500 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.goDetail(orderId);
|
this.goDetail(orderId, this.getWaybillText(item));
|
||||||
} else {
|
} else {
|
||||||
this.goDetail(orderId);
|
this.goDetail(orderId, this.getWaybillText(item));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isCurrentOperator(item) {
|
isCurrentOperator(item) {
|
||||||
@ -444,9 +452,13 @@
|
|||||||
if (!operatorId) return true;
|
if (!operatorId) return true;
|
||||||
return operatorId === this.currentUserId;
|
return operatorId === this.currentUserId;
|
||||||
},
|
},
|
||||||
goDetail(orderId) {
|
goDetail(orderId, waybillText) {
|
||||||
|
const waybill = String(waybillText || '').trim();
|
||||||
|
const url = waybill
|
||||||
|
? `./stockPreparationDetail?orderId=${orderId}&waybill=${encodeURIComponent(waybill)}`
|
||||||
|
: `./stockPreparationDetail?orderId=${orderId}`;
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `./stockPreparationDetail?orderId=${orderId}`,
|
url,
|
||||||
animationType: 'slide-in-right'
|
animationType: 'slide-in-right'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -456,9 +468,9 @@
|
|||||||
uni.showToast({ title: '订单ID缺失', icon: 'none' });
|
uni.showToast({ title: '订单ID缺失', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.doStartPrepAndEnter(orderId);
|
this.doStartPrepAndEnter(orderId, this.getWaybillText(item));
|
||||||
},
|
},
|
||||||
async doStartPrepAndEnter(orderId) {
|
async doStartPrepAndEnter(orderId, waybillText) {
|
||||||
uni.showLoading({ title: '开始备货中...' });
|
uni.showLoading({ title: '开始备货中...' });
|
||||||
try {
|
try {
|
||||||
const response = await this.$http('order.startB2bPrep', { ids: [orderId] }, '', false);
|
const response = await this.$http('order.startB2bPrep', { ids: [orderId] }, '', false);
|
||||||
@ -468,7 +480,7 @@
|
|||||||
uni.showToast({ title: msg, icon: 'none', duration: 2500 });
|
uni.showToast({ title: msg, icon: 'none', duration: 2500 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.goDetail(orderId);
|
this.goDetail(orderId, waybillText);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[stockPreparation] startB2bPrep error:', error);
|
console.error('[stockPreparation] startB2bPrep error:', error);
|
||||||
uni.showToast({ title: '网络异常', icon: 'none' });
|
uni.showToast({ title: '网络异常', icon: 'none' });
|
||||||
|
|||||||
@ -16,8 +16,8 @@
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<view class="summary-card">
|
<view class="summary-card">
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text class="summary-label">发货单号:</text>
|
<text class="summary-label">运单号:</text>
|
||||||
<text class="summary-value">{{ detail.delivery_order_code || '--' }}</text>
|
<text class="summary-value">{{ waybillText }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="summary-row">
|
<view class="summary-row">
|
||||||
<text class="summary-label">备货状态:</text>
|
<text class="summary-label">备货状态:</text>
|
||||||
@ -40,6 +40,7 @@
|
|||||||
<view v-for="(it, idx) in editItems" :key="idx" class="goods-item">
|
<view v-for="(it, idx) in editItems" :key="idx" class="goods-item">
|
||||||
<view class="goods-item__header">
|
<view class="goods-item__header">
|
||||||
<text class="goods-item__name">{{ formatItemName(it) }}</text>
|
<text class="goods-item__name">{{ formatItemName(it) }}</text>
|
||||||
|
<text v-if="it.scanned" class="goods-item__scanned">已扫</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="goods-item__row">
|
<view class="goods-item__row">
|
||||||
<text class="goods-item__label">应拣</text>
|
<text class="goods-item__label">应拣</text>
|
||||||
@ -58,8 +59,16 @@
|
|||||||
<input class="box-edit-input box-edit-input--qty" v-model="box.quantity" type="number" placeholder="数量" @blur="handleBoxInputBlur" />
|
<input class="box-edit-input box-edit-input--qty" v-model="box.quantity" type="number" placeholder="数量" @blur="handleBoxInputBlur" />
|
||||||
<text class="box-edit-del" @click="removeBox(idx, bi)">删除</text>
|
<text class="box-edit-del" @click="removeBox(idx, bi)">删除</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="box-actions">
|
||||||
<view class="box-add" @click="addBox(idx)">
|
<view class="box-add" @click="addBox(idx)">
|
||||||
<text class="box-add__text">+ 添加箱号</text>
|
<text class="box-add__text">+ 箱数</text>
|
||||||
|
</view>
|
||||||
|
<view class="box-add box-add--batch" @click="openBatchBoxPanel(idx)">
|
||||||
|
<text class="box-add__text">+ 总箱数</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="it.boxes && it.boxes.length > 0" class="box-add box-add--batch-del" @click="openBatchDeletePanel(idx)">
|
||||||
|
<text class="box-add__text">批量删除</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -190,6 +199,56 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 添加总箱数弹窗 -->
|
||||||
|
<view v-if="showBatchBoxPanel" class="confirm-mask">
|
||||||
|
<view class="confirm-dialog batch-dialog" @click.stop>
|
||||||
|
<view class="confirm-close" @click="handleBatchBoxCancel">
|
||||||
|
<u-icon name="close" size="18" color="#909399"></u-icon>
|
||||||
|
</view>
|
||||||
|
<text class="confirm-title">添加总箱数</text>
|
||||||
|
<view class="batch-form">
|
||||||
|
<view class="batch-form-row">
|
||||||
|
<text class="batch-form-label">总箱数</text>
|
||||||
|
<input class="batch-form-input" v-model="batchBoxForm.totalBoxes" type="number" />
|
||||||
|
</view>
|
||||||
|
<view class="batch-form-row">
|
||||||
|
<text class="batch-form-label">每箱数量</text>
|
||||||
|
<input class="batch-form-input" v-model="batchBoxForm.perBoxQty" type="number" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="batch-tip">末箱自动填剩余数量(应拣 − 每箱数量 × (总箱数 − 1))</text>
|
||||||
|
<view class="confirm-actions">
|
||||||
|
<view class="confirm-btn confirm-btn--cancel" @click="handleBatchBoxCancel">取消</view>
|
||||||
|
<view class="confirm-btn confirm-btn--primary" @click="handleBatchBoxConfirm">生成箱号</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 批量删除箱号弹窗 -->
|
||||||
|
<view v-if="showBatchDeletePanel" class="confirm-mask">
|
||||||
|
<view class="confirm-dialog batch-dialog" @click.stop>
|
||||||
|
<view class="confirm-close" @click="handleBatchDeleteCancel">
|
||||||
|
<u-icon name="close" size="18" color="#909399"></u-icon>
|
||||||
|
</view>
|
||||||
|
<text class="confirm-title">批量删除箱号</text>
|
||||||
|
<view class="batch-form">
|
||||||
|
<view class="batch-form-row">
|
||||||
|
<text class="batch-form-label">起始箱号</text>
|
||||||
|
<input class="batch-form-input" v-model="batchDeleteForm.start" type="number" placeholder="如 1" />
|
||||||
|
</view>
|
||||||
|
<view class="batch-form-row">
|
||||||
|
<text class="batch-form-label">结束箱号</text>
|
||||||
|
<input class="batch-form-input" v-model="batchDeleteForm.end" type="number" placeholder="如 100" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="batch-tip">删除箱号区间 [起始, 结束] 内的全部分箱</text>
|
||||||
|
<view class="confirm-actions batch-del-actions">
|
||||||
|
<view class="confirm-btn confirm-btn--ok" @click="handleBatchDeleteAll">清空全部</view>
|
||||||
|
<view class="confirm-btn confirm-btn--primary" @click="handleBatchDeleteConfirm">删除</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -198,6 +257,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
orderId: null,
|
orderId: null,
|
||||||
|
waybill: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
detail: {},
|
detail: {},
|
||||||
editing: false,
|
editing: false,
|
||||||
@ -214,6 +274,12 @@
|
|||||||
showFinishPrepConfirm: false,
|
showFinishPrepConfirm: false,
|
||||||
showValidateConfirm: false,
|
showValidateConfirm: false,
|
||||||
validateMessage: '',
|
validateMessage: '',
|
||||||
|
showBatchBoxPanel: false,
|
||||||
|
batchBoxIdx: -1,
|
||||||
|
batchBoxForm: { totalBoxes: '', perBoxQty: '' },
|
||||||
|
showBatchDeletePanel: false,
|
||||||
|
batchDeleteIdx: -1,
|
||||||
|
batchDeleteForm: { start: '', end: '' },
|
||||||
pendingPrepRemark: '',
|
pendingPrepRemark: '',
|
||||||
pendingPrepTotalBoxCount: 0
|
pendingPrepTotalBoxCount: 0
|
||||||
}
|
}
|
||||||
@ -252,16 +318,43 @@
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
return Number(this.detail.total_box_count || 0);
|
return Number(this.detail.total_box_count || 0);
|
||||||
|
},
|
||||||
|
waybillText() {
|
||||||
|
const passed = String(this.waybill || '').trim();
|
||||||
|
if (passed) return passed;
|
||||||
|
const raw = this.detail?.waybill_codes ?? this.detail?.express_numbers;
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
const codes = raw.map(String).filter(Boolean);
|
||||||
|
return codes.length > 0 ? codes.join(' / ') : '--';
|
||||||
|
}
|
||||||
|
if (typeof raw === 'string' && raw.trim()) {
|
||||||
|
const codes = raw.split(/[,,]/).map(s => s.trim()).filter(Boolean);
|
||||||
|
return codes.length > 0 ? codes.join(' / ') : '--';
|
||||||
|
}
|
||||||
|
return '--';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.orderId = Number(options.orderId || 0);
|
this.orderId = Number(options.orderId || 0);
|
||||||
|
this.waybill = this.decodeWaybill(options.waybill);
|
||||||
|
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||||
|
this.safeDispatchBroadcast('start');
|
||||||
if (this.orderId) {
|
if (this.orderId) {
|
||||||
this.fetchDetail();
|
this.fetchDetail();
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '订单ID缺失', icon: 'none' });
|
uni.showToast({ title: '订单ID缺失', icon: 'none' });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||||
|
this.safeDispatchBroadcast('resume');
|
||||||
|
},
|
||||||
|
onHide() {
|
||||||
|
this.safeDispatchBroadcast('pause');
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
this.safeDispatchBroadcast('stop');
|
||||||
|
},
|
||||||
onBackPress() {
|
onBackPress() {
|
||||||
// 提交/取消成功后放行,避免返回键再次拦截导致无法返回列表页
|
// 提交/取消成功后放行,避免返回键再次拦截导致无法返回列表页
|
||||||
if (this.allowDirectBack) {
|
if (this.allowDirectBack) {
|
||||||
@ -279,6 +372,26 @@
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
safeDispatchBroadcast(action, payload) {
|
||||||
|
try {
|
||||||
|
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||||
|
if (task && typeof task.catch === 'function') {
|
||||||
|
task.catch(error => {
|
||||||
|
console.warn(`[stockPreparationDetail] broadcast/${action} 调用失败:`, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[stockPreparationDetail] broadcast/${action} 调用异常:`, error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decodeWaybill(value) {
|
||||||
|
if (value === null || value === undefined || value === '') return '';
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(String(value));
|
||||||
|
} catch (error) {
|
||||||
|
return String(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
speakMessage(message, options = {}) {
|
speakMessage(message, options = {}) {
|
||||||
const text = String(message || '').trim();
|
const text = String(message || '').trim();
|
||||||
if (!text) {
|
if (!text) {
|
||||||
@ -299,6 +412,92 @@
|
|||||||
console.warn('[stockPreparationDetail] 语音播报异常:', error);
|
console.warn('[stockPreparationDetail] 语音播报异常:', error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
normalizeUniScanResult(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 firstResult = scanResult.result.find(item => item);
|
||||||
|
if (typeof firstResult === 'string') {
|
||||||
|
return firstResult.trim();
|
||||||
|
}
|
||||||
|
if (firstResult && typeof firstResult.data === 'string') {
|
||||||
|
return firstResult.data.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof scanResult.data === 'string') {
|
||||||
|
return scanResult.data.trim();
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
normalizeScanCode(value) {
|
||||||
|
return String(value || '').replace(/\s+/g, '').toUpperCase();
|
||||||
|
},
|
||||||
|
extractItemBarcodeCandidates(item) {
|
||||||
|
const sourceFields = [
|
||||||
|
item?.barcode,
|
||||||
|
item?.barcodes,
|
||||||
|
item?.skuCode,
|
||||||
|
item?.sku_code,
|
||||||
|
item?.item_barcode,
|
||||||
|
item?.bar_code,
|
||||||
|
item?.item_code
|
||||||
|
];
|
||||||
|
const result = [];
|
||||||
|
sourceFields.forEach(source => {
|
||||||
|
const list = Array.isArray(source) ? source : [source];
|
||||||
|
list.forEach(s => {
|
||||||
|
const text = String(s || '').trim();
|
||||||
|
if (!text) return;
|
||||||
|
text.split(/[;,,、|\s]+/)
|
||||||
|
.map(part => this.normalizeScanCode(part))
|
||||||
|
.filter(Boolean)
|
||||||
|
.forEach(part => result.push(part));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return Array.from(new Set(result));
|
||||||
|
},
|
||||||
|
handleBroadcastResult(result) {
|
||||||
|
const rawCode = this.normalizeUniScanResult(result);
|
||||||
|
if (!rawCode) return;
|
||||||
|
this.markItemScannedByCode(rawCode);
|
||||||
|
},
|
||||||
|
markItemScannedByCode(rawCode) {
|
||||||
|
if (!this.editing) return false;
|
||||||
|
const code = this.normalizeScanCode(rawCode);
|
||||||
|
if (!code) return false;
|
||||||
|
const matched = [];
|
||||||
|
this.editItems.forEach((it, idx) => {
|
||||||
|
if (this.extractItemBarcodeCandidates(it).includes(code)) {
|
||||||
|
matched.push(idx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (matched.length === 0) {
|
||||||
|
uni.showToast({ title: '无记录', icon: 'none' });
|
||||||
|
this.speakMessage('无记录');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let newlyScanned = 0;
|
||||||
|
matched.forEach(idx => {
|
||||||
|
if (!this.editItems[idx].scanned) {
|
||||||
|
this.editItems[idx].scanned = true;
|
||||||
|
newlyScanned++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (newlyScanned > 0) {
|
||||||
|
uni.showToast({ title: `已扫 ${newlyScanned} 个商品`, icon: 'none' });
|
||||||
|
this.speakMessage('数据一致');
|
||||||
|
} else {
|
||||||
|
uni.showToast({ title: '该条码对应商品已全部标记', icon: 'none' });
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
async fetchDetail() {
|
async fetchDetail() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
try {
|
try {
|
||||||
@ -407,6 +606,13 @@
|
|||||||
item_name: it.item_name,
|
item_name: it.item_name,
|
||||||
plan_qty: it.plan_qty,
|
plan_qty: it.plan_qty,
|
||||||
pick_locations: it.pick_locations || [],
|
pick_locations: it.pick_locations || [],
|
||||||
|
barcode: it.barcode,
|
||||||
|
barcodes: it.barcodes,
|
||||||
|
skuCode: it.skuCode,
|
||||||
|
sku_code: it.sku_code,
|
||||||
|
item_barcode: it.item_barcode,
|
||||||
|
bar_code: it.bar_code,
|
||||||
|
scanned: false,
|
||||||
boxes: (Array.isArray(it.boxes) && it.boxes.length > 0)
|
boxes: (Array.isArray(it.boxes) && it.boxes.length > 0)
|
||||||
? it.boxes.map(b => ({ box_no: b.box_no || '', quantity: b.quantity || 0 }))
|
? it.boxes.map(b => ({ box_no: b.box_no || '', quantity: b.quantity || 0 }))
|
||||||
: []
|
: []
|
||||||
@ -436,6 +642,103 @@
|
|||||||
this.editItems[idx].boxes.splice(bi, 1);
|
this.editItems[idx].boxes.splice(bi, 1);
|
||||||
this.scheduleAutoSave();
|
this.scheduleAutoSave();
|
||||||
},
|
},
|
||||||
|
openBatchBoxPanel(idx) {
|
||||||
|
if (!this.editItems[idx]) return;
|
||||||
|
this.batchBoxIdx = idx;
|
||||||
|
this.batchBoxForm = { totalBoxes: '', perBoxQty: '' };
|
||||||
|
this.showBatchBoxPanel = true;
|
||||||
|
},
|
||||||
|
handleBatchBoxCancel() {
|
||||||
|
this.showBatchBoxPanel = false;
|
||||||
|
this.batchBoxIdx = -1;
|
||||||
|
},
|
||||||
|
handleBatchBoxConfirm() {
|
||||||
|
const item = this.editItems[this.batchBoxIdx];
|
||||||
|
if (!item) {
|
||||||
|
this.handleBatchBoxCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const plan = Number(item.plan_qty || 0);
|
||||||
|
const totalBoxes = Number(this.batchBoxForm.totalBoxes);
|
||||||
|
const perBoxQty = Number(this.batchBoxForm.perBoxQty);
|
||||||
|
if (!Number.isInteger(totalBoxes) || totalBoxes < 1) {
|
||||||
|
uni.showToast({ title: '请输入有效的总箱数', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Number.isInteger(perBoxQty) || perBoxQty < 1) {
|
||||||
|
uni.showToast({ title: '请输入有效的每箱数量', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const lastQty = plan - perBoxQty * (totalBoxes - 1);
|
||||||
|
if (lastQty <= 0) {
|
||||||
|
uni.showToast({ title: '每箱数量×箱数超过应拣数量', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const existing = Array.isArray(item.boxes) ? item.boxes : [];
|
||||||
|
let startNo = 1;
|
||||||
|
existing.forEach(b => {
|
||||||
|
const n = Number(b.box_no);
|
||||||
|
if (Number.isFinite(n) && n >= startNo) startNo = n + 1;
|
||||||
|
});
|
||||||
|
const newBoxes = [];
|
||||||
|
for (let i = 0; i < totalBoxes; i++) {
|
||||||
|
const quantity = (i === totalBoxes - 1) ? lastQty : perBoxQty;
|
||||||
|
newBoxes.push({ box_no: String(startNo + i), quantity });
|
||||||
|
}
|
||||||
|
item.boxes = existing.concat(newBoxes);
|
||||||
|
this.scheduleAutoSave();
|
||||||
|
uni.showToast({ title: `已生成 ${newBoxes.length} 个箱号`, icon: 'none' });
|
||||||
|
this.handleBatchBoxCancel();
|
||||||
|
},
|
||||||
|
openBatchDeletePanel(idx) {
|
||||||
|
if (!this.editItems[idx]) return;
|
||||||
|
this.batchDeleteIdx = idx;
|
||||||
|
this.batchDeleteForm = { start: '', end: '' };
|
||||||
|
this.showBatchDeletePanel = true;
|
||||||
|
},
|
||||||
|
handleBatchDeleteCancel() {
|
||||||
|
this.showBatchDeletePanel = false;
|
||||||
|
this.batchDeleteIdx = -1;
|
||||||
|
},
|
||||||
|
handleBatchDeleteConfirm() {
|
||||||
|
const item = this.editItems[this.batchDeleteIdx];
|
||||||
|
if (!item) {
|
||||||
|
this.handleBatchDeleteCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const start = Number(this.batchDeleteForm.start);
|
||||||
|
const end = Number(this.batchDeleteForm.end);
|
||||||
|
if (!Number.isInteger(start) || start < 1) {
|
||||||
|
uni.showToast({ title: '请输入有效的起始箱号', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Number.isInteger(end) || end < start) {
|
||||||
|
uni.showToast({ title: '请输入有效的结束箱号', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const boxes = Array.isArray(item.boxes) ? item.boxes : [];
|
||||||
|
const before = boxes.length;
|
||||||
|
item.boxes = boxes.filter(b => {
|
||||||
|
const n = Number(b.box_no);
|
||||||
|
return !(Number.isFinite(n) && n >= start && n <= end);
|
||||||
|
});
|
||||||
|
const removed = before - item.boxes.length;
|
||||||
|
this.scheduleAutoSave();
|
||||||
|
uni.showToast({ title: `已删除 ${removed} 个箱号`, icon: 'none' });
|
||||||
|
this.handleBatchDeleteCancel();
|
||||||
|
},
|
||||||
|
handleBatchDeleteAll() {
|
||||||
|
const item = this.editItems[this.batchDeleteIdx];
|
||||||
|
if (!item) {
|
||||||
|
this.handleBatchDeleteCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const removed = Array.isArray(item.boxes) ? item.boxes.length : 0;
|
||||||
|
item.boxes = [];
|
||||||
|
this.scheduleAutoSave();
|
||||||
|
uni.showToast({ title: `已清空 ${removed} 个箱号`, icon: 'none' });
|
||||||
|
this.handleBatchDeleteCancel();
|
||||||
|
},
|
||||||
buildPackingItems() {
|
buildPackingItems() {
|
||||||
const packingItems = [];
|
const packingItems = [];
|
||||||
for (const it of this.editItems) {
|
for (const it of this.editItems) {
|
||||||
@ -925,6 +1228,17 @@
|
|||||||
color: #303133;
|
color: #303133;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.goods-item__scanned {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: 12rpx;
|
||||||
|
padding: 2rpx 14rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: #18a058;
|
||||||
|
background-color: #f0f9eb;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.goods-item__row {
|
.goods-item__row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -1083,6 +1397,12 @@
|
|||||||
color: #f56c6c;
|
color: #f56c6c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.box-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
.box-add {
|
.box-add {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 8rpx 20rpx;
|
padding: 8rpx 20rpx;
|
||||||
@ -1090,6 +1410,22 @@
|
|||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.box-add--batch {
|
||||||
|
background-color: #f0f9eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-add--batch .box-add__text {
|
||||||
|
color: #67c23a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-add--batch-del {
|
||||||
|
background-color: #fef0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-add--batch-del .box-add__text {
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
.box-add__text {
|
.box-add__text {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #2979ff;
|
color: #2979ff;
|
||||||
@ -1190,4 +1526,49 @@
|
|||||||
background: #2979ff;
|
background: #2979ff;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.batch-dialog {
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-form {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-form-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-form-label {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 160rpx;
|
||||||
|
font-size: 36rpx;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-form-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 72rpx;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 36rpx;
|
||||||
|
color: #303133;
|
||||||
|
background-color: #f8f8f8;
|
||||||
|
border: 1rpx solid #dcdfe6;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-tip {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.batch-del-actions .confirm-btn:first-child {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user