feat(receiving): 完善收货流程语音提示交互

This commit is contained in:
zm2000 2026-04-25 17:15:53 +08:00
parent 7c7639a1e9
commit 42fee4319d
5 changed files with 429 additions and 57 deletions

View File

@ -167,6 +167,28 @@
this.$store.dispatch('broadcast/stop'); this.$store.dispatch('broadcast/stop');
}, },
methods: { methods: {
speakMessage(message, options = {}) {
const text = String(message || '').trim();
if (!text) {
return;
}
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') {
return;
}
try {
const task = tools.speakText(text, options);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn('[ReceivingDetail-DetailContainer] 语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail-DetailContainer] 语音播报异常:', error);
}
},
// === 事件处理方法 === // === 事件处理方法 ===
truncateText(text, length = 20) { truncateText(text, length = 20) {
if (!text) return ''; if (!text) return '';
@ -326,6 +348,7 @@
if(this.isSpaceInput){ if(this.isSpaceInput){
this.$emit('searchSpace', data.data); this.$emit('searchSpace', data.data);
}else{ }else{
this.speakMessage('商品条码扫描成功');
this.$emit('tryGetStock', data.data); this.$emit('tryGetStock', data.data);
} }
}, },

View File

@ -13,7 +13,7 @@
<view <view
v-if="canBindStore" v-if="canBindStore"
class="store-bind-trigger" class="store-bind-trigger"
@click="showStorePicker = true" @click="openStorePicker"
> >
<text class="store-bind-text">{{ pendingStoreName || '请选择货主绑定' }}</text> <text class="store-bind-text">{{ pendingStoreName || '请选择货主绑定' }}</text>
<view class="store-bind-action"> <view class="store-bind-action">
@ -204,6 +204,32 @@
} }
}, },
methods: { methods: {
speakMessage(message, options = {}) {
const text = String(message || '').trim();
if (!text) {
return;
}
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') {
return;
}
try {
const task = tools.speakText(text, options);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn('[ReceivingDetail-InfoContainer] 语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail-InfoContainer] 语音播报异常:', error);
}
},
openStorePicker() {
this.speakMessage('选择货主');
this.showStorePicker = true;
},
async loadStoreList() { async loadStoreList() {
try { try {
const res = await this.$http('common.store', {}); const res = await this.$http('common.store', {});
@ -221,11 +247,14 @@
return; return;
} }
this.speakMessage('请确认货主绑定');
uni.showModal({ uni.showModal({
title: '货主绑定', title: '货主绑定',
content: `是否将当前收货单绑定到货主【${option.label}】?绑定后不可更改。`, content: `是否将当前收货单绑定到货主【${option.label}】?绑定后不可更改。`,
success: async ({ confirm }) => { success: async ({ confirm }) => {
if (!confirm) { if (!confirm) {
this.speakMessage('已取消');
return; return;
} }
@ -253,6 +282,7 @@
if (res && res.code === 200) { if (res && res.code === 200) {
this.pendingStoreId = option.value; this.pendingStoreId = option.value;
this.pendingStoreName = option.label; this.pendingStoreName = option.label;
this.speakMessage('绑定成功');
uni.showToast({ uni.showToast({
title: '绑定成功', title: '绑定成功',
icon: 'success' icon: 'success'

View File

@ -123,7 +123,7 @@
</u-form-item> </u-form-item>
<u-form-item label="创建时间" borderBottom> <u-form-item label="创建时间" borderBottom>
<view class="date-range" @click="showSelectDate = true"> <view class="date-range" @click="openDateFilter">
<text>{{where.startDate}} - {{where.endDate}}</text> <text>{{where.startDate}} - {{where.endDate}}</text>
</view> </view>
</u-form-item> </u-form-item>
@ -205,6 +205,8 @@
loading: false, loading: false,
storeId:null, storeId:null,
refreshing: false, refreshing: false,
pageChangeSilentVoice: true,
nextListVoiceDelay: 0,
pageSize: 20, pageSize: 20,
currentPage: 1, currentPage: 1,
totalItems: 0, totalItems: 0,
@ -281,8 +283,13 @@
watch: { watch: {
currentPage(newval) { currentPage(newval) {
console.log('页码变化:', newval); console.log('页码变化:', newval);
const silentVoice = this.pageChangeSilentVoice;
const voiceDelay = Number(this.nextListVoiceDelay || 0);
this.pageChangeSilentVoice = true;
this.nextListVoiceDelay = 0;
this.loadReceivingList({ this.loadReceivingList({
silentVoice: false silentVoice,
voiceDelay
}); });
} }
}, },
@ -421,6 +428,15 @@
// 设置日期范围 // 设置日期范围
setDateRange(type) { setDateRange(type) {
const quickDateVoiceMap = {
today: '今日',
yesterday: '昨日',
beforeYesterday: '前日',
last3days: '3天内',
week: '本周',
month: '本月'
};
this.speakReceivingMessage(quickDateVoiceMap[type] || '筛选日期');
this.dateModel = type; this.dateModel = type;
const dateRange = this.getDateRange(type); const dateRange = this.getDateRange(type);
this.where.startDate = dateRange.startDate; this.where.startDate = dateRange.startDate;
@ -531,6 +547,7 @@
// 加载收货列表 // 加载收货列表
async loadReceivingList(options = {}) { async loadReceivingList(options = {}) {
const silentVoice = !!(options && options.silentVoice); const silentVoice = !!(options && options.silentVoice);
const voiceDelay = Number((options && options.voiceDelay) || 0);
if (this.loading) return; if (this.loading) return;
this.loading = true; this.loading = true;
@ -598,7 +615,14 @@
} }
if (!silentVoice) { if (!silentVoice) {
this.speakReceivingMessage(this.getReceivingListVoiceText()); const resultVoiceText = this.getReceivingListVoiceText();
if (voiceDelay > 0) {
setTimeout(() => {
this.speakReceivingMessage(resultVoiceText);
}, voiceDelay);
} else {
this.speakReceivingMessage(resultVoiceText);
}
} }
} }
} catch (error) { } catch (error) {
@ -608,7 +632,13 @@
icon: 'error' icon: 'error'
}); });
if (!silentVoice) { if (!silentVoice) {
this.speakReceivingMessage('加载收货列表失败,请重试'); if (voiceDelay > 0) {
setTimeout(() => {
this.speakReceivingMessage('加载收货列表失败,请重试');
}, voiceDelay);
} else {
this.speakReceivingMessage('加载收货列表失败,请重试');
}
} }
} finally { } finally {
this.loading = false; this.loading = false;
@ -645,12 +675,14 @@
return typeMap[status] || 'info'; return typeMap[status] || 'info';
}, },
handleShowStore(){ handleShowStore(){
this.speakReceivingMessage('选择货主');
this.showStore = true; this.showStore = true;
console.log("显示选择货主") console.log("显示选择货主")
}, },
// 搜索处理 // 搜索处理
handleSearch() { handleSearch() {
if (this.currentPage !== 1) { if (this.currentPage !== 1) {
this.pageChangeSilentVoice = false;
this.currentPage = 1; this.currentPage = 1;
return; return;
} }
@ -663,6 +695,7 @@
changeStatus(status) { changeStatus(status) {
this.activeStatus = status; this.activeStatus = status;
if (this.currentPage !== 1) { if (this.currentPage !== 1) {
this.pageChangeSilentVoice = false;
this.currentPage = 1; this.currentPage = 1;
return; return;
} }
@ -675,6 +708,7 @@
onRefresh() { onRefresh() {
this.refreshing = true; this.refreshing = true;
if (this.currentPage !== 1) { if (this.currentPage !== 1) {
this.pageChangeSilentVoice = false;
this.currentPage = 1; this.currentPage = 1;
return; return;
} }
@ -685,11 +719,17 @@
// 显示筛选弹窗 // 显示筛选弹窗
showFilterPopup() { showFilterPopup() {
this.speakReceivingMessage('筛选');
this.filterVisible = true; this.filterVisible = true;
}, },
openDateFilter() {
this.speakReceivingMessage('筛选日期');
this.showSelectDate = true;
},
// 重置筛选 // 重置筛选
resetFilter() { resetFilter() {
this.speakReceivingMessage('重置');
this.where = { this.where = {
store: 0, store: 0,
startDate: this.formatDate(new Date()), startDate: this.formatDate(new Date()),
@ -703,18 +743,23 @@
// 应用筛选 // 应用筛选
applyFilter() { applyFilter() {
this.speakReceivingMessage('确定');
this.filterVisible = false; this.filterVisible = false;
this.nextListVoiceDelay = 700;
if (this.currentPage !== 1) { if (this.currentPage !== 1) {
this.pageChangeSilentVoice = false;
this.currentPage = 1; this.currentPage = 1;
return; return;
} }
this.loadReceivingList({ this.loadReceivingList({
silentVoice: false silentVoice: false,
voiceDelay: 700
}); });
}, },
// 新建收货 // 新建收货
createReceiving() { createReceiving() {
this.speakReceivingMessage('新建收货');
this.$store.dispatch('broadcast/stop'); this.$store.dispatch('broadcast/stop');
uni.navigateTo({ uni.navigateTo({
url: './receivingCreate', url: './receivingCreate',
@ -765,6 +810,13 @@
}, },
handlePageChange(page) { handlePageChange(page) {
const previousPage = Number(this.currentPage || 1);
if (page < previousPage) {
this.speakReceivingMessage('上一页');
} else if (page > previousPage) {
this.speakReceivingMessage('下一页');
}
this.pageChangeSilentVoice = true;
this.currentPage = page; this.currentPage = page;
} }
} }

View File

@ -9,7 +9,7 @@
<view class="section-title">基础信息</view> <view class="section-title">基础信息</view>
<!-- 店铺信息 --> <!-- 店铺信息 -->
<u-form-item label="货主" @click="showStorePicker = true"> <u-form-item label="货主" @click="openStorePicker">
<view class="store-select-display"> <view class="store-select-display">
<text :class="['store-select-text', !formData.store_id ? 'store-select-placeholder' : '']">{{ storeName || '请选择货主' }}</text> <text :class="['store-select-text', !formData.store_id ? 'store-select-placeholder' : '']">{{ storeName || '请选择货主' }}</text>
<u-icon name="arrow-right" size="24rpx" color="#c0c4cc"></u-icon> <u-icon name="arrow-right" size="24rpx" color="#c0c4cc"></u-icon>
@ -194,6 +194,111 @@
}, },
methods: { methods: {
normalizeSpeechText(message) {
const rawText = String(message || '').trim();
if (!rawText) {
return '';
}
const digitMap = {
'0': '零',
'1': '一',
'2': '二',
'3': '三',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九'
};
const normalizeCodeSegment = (segment) => {
return segment
.split('-')
.map(part => String(part || '')
.split('')
.map(char => (digitMap[char] || char))
.join(''))
.join('的');
};
return rawText.replace(/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)+)/g, normalizeCodeSegment);
},
speakMessage(message, options = {}) {
const text = this.normalizeSpeechText(message);
if (!text) {
return;
}
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') {
return;
}
try {
const task = tools.speakText(text, options);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn('[ReceivingCreate] 语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingCreate] 语音播报异常:', error);
}
},
stopSpeak() {
const tools = this.$tools;
if (!tools || typeof tools.stopSpeak !== 'function') {
return;
}
try {
tools.stopSpeak();
} catch (error) {
console.warn('[ReceivingCreate] 停止语音播报异常:', error);
}
},
showToastMessage(title, icon = 'none', options = {}) {
const message = String(title || '').trim();
if (!message) {
return;
}
uni.showToast({
title: message,
icon
});
if (options.speak !== false) {
this.speakMessage(options.speakText || message, options.voiceOptions || {});
}
},
extractErrorMessage(error, fallback = '操作失败') {
if (!error) {
return fallback;
}
if (typeof error === 'string') {
return error;
}
if (typeof error.message === 'string' && error.message.trim()) {
return error.message.trim();
}
if (Array.isArray(error) && error.length) {
const firstError = error[0];
if (typeof firstError === 'string') {
return firstError;
}
if (firstError && typeof firstError.message === 'string') {
return firstError.message;
}
}
return fallback;
},
getPlatformInfo() { getPlatformInfo() {
const systemInfo = typeof uni.getSystemInfoSync === 'function' ? uni.getSystemInfoSync() : {}; const systemInfo = typeof uni.getSystemInfoSync === 'function' ? uni.getSystemInfoSync() : {};
return { return {
@ -385,9 +490,8 @@
} }
this.formData.license_plate = licensePlate; this.formData.license_plate = licensePlate;
uni.showToast({ this.showToastMessage('识别成功', 'success', {
title: '识别成功', speakText: `识别成功,车牌:${licensePlate}`
icon: 'success'
}); });
} catch (error) { } catch (error) {
const errMsg = String(error?.errMsg || error?.message || error || '').toLowerCase(); const errMsg = String(error?.errMsg || error?.message || error || '').toLowerCase();
@ -395,10 +499,7 @@
return; return;
} }
uni.showToast({ this.showToastMessage((error && error.message) || '车牌识别失败');
title: (error && error.message) || '车牌识别失败',
icon: 'none'
});
} finally { } finally {
this.recognizingPlate = false; this.recognizingPlate = false;
uni.hideLoading(); uni.hideLoading();
@ -440,14 +541,12 @@
success: (res) => { success: (res) => {
const rawCode = this.normalizeUniScanResult(res); const rawCode = this.normalizeUniScanResult(res);
if (!rawCode) { if (!rawCode) {
uni.showToast({ this.showToastMessage('未识别到有效内容');
title: '未识别到有效内容',
icon: 'none'
});
return; return;
} }
this.formData.tracking_number = rawCode; this.formData.tracking_number = rawCode;
this.speakMessage('扫描成功');
}, },
fail: (error) => { fail: (error) => {
const errMsg = String(error?.errMsg || '').toLowerCase(); const errMsg = String(error?.errMsg || '').toLowerCase();
@ -455,10 +554,7 @@
return; return;
} }
uni.showToast({ this.showToastMessage('扫码失败,请重试');
title: '扫码失败,请重试',
icon: 'none'
});
} }
}); });
}, },
@ -499,11 +595,7 @@
this.formData.video_device_id = deviceCode; this.formData.video_device_id = deviceCode;
// 可选:给用户一个提示 // 可选:给用户一个提示
uni.showToast({ this.showToastMessage(`已扫描录像设备: ${deviceCode}`, 'success');
title: `已扫描录像设备: ${deviceCode}`,
icon: 'success',
duration: 2000
});
} }
// 如果没有提取到设备编号,也直接忽略,不提示用户 // 如果没有提取到设备编号,也直接忽略,不提示用户
return; return;
@ -511,6 +603,7 @@
if (this.formData.delivery_method === 'express') { if (this.formData.delivery_method === 'express') {
this.formData.tracking_number = scanText; this.formData.tracking_number = scanText;
this.speakMessage('扫描成功');
} }
} }
}, },
@ -526,10 +619,7 @@
const result = await this.$http("storage.receiving.create",submitData); const result = await this.$http("storage.receiving.create",submitData);
if(result.code==200){ if(result.code==200){
uni.showToast({ this.showToastMessage('创建成功', 'success');
title: '创建成功',
icon: 'success'
});
}else{ }else{
throw new Error("创建失败"+result.message); throw new Error("创建失败"+result.message);
@ -541,16 +631,14 @@
}, 1500); }, 1500);
} catch (error) { } catch (error) {
uni.showToast({ this.showToastMessage(this.extractErrorMessage(error, '创建失败'));
title: '创建失败'+error,
icon: 'error'
});
} finally { } finally {
this.submitting = false; this.submitting = false;
} }
}, },
handleReset() { handleReset() {
this.speakMessage('请确认重置表单');
uni.showModal({ uni.showModal({
title: '确认重置', title: '确认重置',
content: '确定要重置所有表单数据吗?', content: '确定要重置所有表单数据吗?',
@ -559,11 +647,19 @@
this.$refs.formRef.resetFields(); this.$refs.formRef.resetFields();
this.storeName = "不设置"; this.storeName = "不设置";
this.formData.store_id = null; this.formData.store_id = null;
this.showToastMessage('已重置表单');
} else {
this.speakMessage('已取消');
} }
} }
}); });
}, },
openStorePicker() {
this.speakMessage('选择货主');
this.showStorePicker = true;
},
handleStoreChange(option) { handleStoreChange(option) {
if (!option) { if (!option) {
this.storeName = "不设置"; this.storeName = "不设置";
@ -588,9 +684,11 @@
}, },
onHide() { onHide() {
this.$store.dispatch('broadcast/pause'); this.$store.dispatch('broadcast/pause');
this.stopSpeak();
}, },
onUnload() { onUnload() {
this.$store.dispatch('broadcast/stop'); this.$store.dispatch('broadcast/stop');
this.stopSpeak();
} }
}; };
</script> </script>

View File

@ -151,6 +151,87 @@
}, },
methods: { methods: {
normalizeSpeechText(message) {
const rawText = String(message || '').trim();
if (!rawText) {
return '';
}
const digitMap = {
'0': '零',
'1': '一',
'2': '二',
'3': '三',
'4': '四',
'5': '五',
'6': '六',
'7': '七',
'8': '八',
'9': '九'
};
const normalizeCodeSegment = (segment) => {
return segment
.split('-')
.map(part => String(part || '')
.split('')
.map(char => (digitMap[char] || char))
.join(''))
.join('的');
};
return rawText.replace(/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)+)/g, normalizeCodeSegment);
},
speakMessage(message, options = {}) {
const text = this.normalizeSpeechText(message);
if (!text) {
return;
}
const tools = this.$tools;
if (!tools || typeof tools.speakText !== 'function') {
return;
}
try {
const task = tools.speakText(text, options);
if (task && typeof task.catch === 'function') {
task.catch(error => {
console.warn('[ReceivingDetail] 语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail] 语音播报异常:', error);
}
},
stopSpeak() {
const tools = this.$tools;
if (!tools || typeof tools.stopSpeak !== 'function') {
return;
}
try {
tools.stopSpeak();
} catch (error) {
console.warn('[ReceivingDetail] 停止语音播报异常:', error);
}
},
showToastMessage(title, icon = 'none', options = {}) {
const message = String(title || '').trim();
if (!message) {
return;
}
uni.showToast({
title: message,
icon,
duration: options.duration || 1500
});
if (options.speak !== false) {
this.speakMessage(options.speakText || message, options.voiceOptions || {});
}
},
getTodayStartTimestamp() { getTodayStartTimestamp() {
const today = new Date(); const today = new Date();
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
@ -222,6 +303,41 @@
return invalidDetail || null; return invalidDetail || null;
}, },
validateReceivingBaseFields() {
const detailList = this.details || [];
// 1) 先校验商品名称
const invalidNameDetail = detailList.find(detail => !String(detail?.product_name || '').trim());
if (invalidNameDetail) {
return {
detail: invalidNameDetail,
message: `${invalidNameDetail.product_name || '当前商品'}缺少商品名称`
};
}
// 2) 再校验实际数量是否为空
const invalidEmptyQtyDetail = detailList.find(detail => !String(detail?.actual_quantity ?? '').trim());
if (invalidEmptyQtyDetail) {
return {
detail: invalidEmptyQtyDetail,
message: `${invalidEmptyQtyDetail.product_name || '当前商品'}缺少实际数量`
};
}
// 3) 最后校验实际数量是否大于0
const invalidQtyValueDetail = detailList.find(detail => {
const quantityValue = Number(String(detail?.actual_quantity ?? '').trim());
return !Number.isFinite(quantityValue) || quantityValue <= 0;
});
if (invalidQtyValueDetail) {
return {
detail: invalidQtyValueDetail,
message: `${invalidQtyValueDetail.product_name || '当前商品'}实际数量需大于0`
};
}
return null;
},
// 初始化数据 // 初始化数据
async initData() { async initData() {
await this.loadReceivingInfo(); await this.loadReceivingInfo();
@ -274,14 +390,15 @@
try { try {
// 货主确认逻辑 // 货主确认逻辑
if (this.receivingInfo.store_id == null && data.system_product_id) { if (this.receivingInfo.store_id == null && data.system_product_id) {
this.speakMessage('请确认货主');
const confirm = await this.confirmStoreOwner(); const confirm = await this.confirmStoreOwner();
if (!confirm) { if (!confirm) {
uni.showToast({ this.showToastMessage('已取消', 'none', {
title: '已取消', speakText: '已取消'
icon: 'none'
}); });
return; return;
} }
this.speakMessage('已确认');
} }
// 调用API更新 // 调用API更新
@ -362,6 +479,8 @@
return; return;
} }
this.speakMessage('请确认删除');
uni.showModal({ uni.showModal({
title: '确认删除', title: '确认删除',
content: `确定要删除商品"${detailToDelete.product_name}"吗?`, content: `确定要删除商品"${detailToDelete.product_name}"吗?`,
@ -374,9 +493,8 @@
}); });
if (result.code === 200) { if (result.code === 200) {
uni.showToast({ this.showToastMessage('删除成功', 'success', {
title: '删除成功', speakText: '删除成功'
icon: 'success'
}); });
// 删除后统一以服务端最新数据重建列表与选中态,避免残留旧引用 // 删除后统一以服务端最新数据重建列表与选中态,避免残留旧引用
@ -411,6 +529,10 @@
icon: 'error' icon: 'error'
}); });
} }
} else {
this.showToastMessage('已取消', 'none', {
speakText: '已取消'
});
} }
} }
}); });
@ -423,9 +545,8 @@
}); });
if (result.code === 200) { if (result.code === 200) {
uni.showToast({ this.showToastMessage('添加成功', 'success', {
title: '添加成功', speakText: '添加成功'
icon: 'success'
}); });
if (result.data.selectId) { if (result.data.selectId) {
@ -516,6 +637,20 @@
}, },
async completeReceiving() { async completeReceiving() {
this.showComplete = false; this.showComplete = false;
const baseValidation = this.validateReceivingBaseFields();
if (baseValidation) {
this.currentTab = 1;
this.selectedDetail = baseValidation.detail;
const message = baseValidation.message || '商品信息不完整';
this.speakMessage(message);
uni.showModal({
title: '商品信息不完整',
content: message,
showCancel: false
});
return;
}
const shelfLifeValidation = this.validateShelfLifeRequiredFields(); const shelfLifeValidation = this.validateShelfLifeRequiredFields();
if (shelfLifeValidation) { if (shelfLifeValidation) {
this.currentTab = 1; this.currentTab = 1;
@ -539,6 +674,34 @@
return; return;
} }
try { try {
const tools = this.$tools;
if (tools && typeof tools.speakText === 'function') {
try {
const speakTask = tools.speakText('请确认完成收货', {
force: true,
minInterval: 0
});
if (speakTask && typeof speakTask.catch === 'function') {
speakTask.catch(error => {
console.warn('[ReceivingDetail] 完成收货前语音播报失败:', error);
});
}
} catch (error) {
console.warn('[ReceivingDetail] 完成收货前语音播报失败:', error);
}
} else {
this.speakMessage('请确认完成收货', {
force: true,
minInterval: 0
});
}
uni.showToast({
title: '请确认完成收货',
icon: 'none',
duration: 800
});
await new Promise(resolve => setTimeout(resolve, 900));
// 1. 显示确认弹窗 // 1. 显示确认弹窗
const confirmResult = await uni.showModal({ const confirmResult = await uni.showModal({
title: '完成收货', title: '完成收货',
@ -553,6 +716,9 @@
// 修正:直接使用confirmResult.confirm // 修正:直接使用confirmResult.confirm
if (!confirmResult[1].confirm) { if (!confirmResult[1].confirm) {
this.showToastMessage('已取消', 'none', {
speakText: '已取消'
});
return; return;
} }
@ -576,11 +742,7 @@
// 根据你的后端响应结构调整 // 根据你的后端响应结构调整
if (res.code === 200 || res.success) { if (res.code === 200 || res.success) {
// 成功提示 // 成功提示
uni.showToast({ this.showToastMessage('收货完成成功', 'success');
title: '收货完成成功',
icon: 'success',
duration: 1500
});
// 延迟跳转 // 延迟跳转
setTimeout(() => { setTimeout(() => {
@ -628,15 +790,14 @@
uni.hideLoading(); uni.hideLoading();
console.error('完成收货失败:', error); console.error('完成收货失败:', error);
this.currentTab = 1; this.currentTab = 1;
uni.showToast({ this.showToastMessage(error.message || '操作失败,请稍后重试', 'none', {
title: error.message || '操作失败,请稍后重试', duration: 3000
icon: 'none',
duration: 3000
}); });
} }
}, },
async cancel() { async cancel() {
try { try {
this.speakMessage('请确认作废');
// 1. 显示确认弹窗 // 1. 显示确认弹窗
const confirmResult = await uni.showModal({ const confirmResult = await uni.showModal({
title: '整单作废', title: '整单作废',
@ -648,6 +809,9 @@
}); });
console.log(confirmResult); console.log(confirmResult);
if (!confirmResult[1].confirm) { if (!confirmResult[1].confirm) {
this.showToastMessage('已取消', 'none', {
speakText: '已取消'
});
return; return;
} }
@ -670,10 +834,8 @@
throw new Error("取消失败"+res.message) throw new Error("取消失败"+res.message)
} }
// 5. 显示成功提示 // 5. 显示成功提示
uni.showToast({ this.showToastMessage('取消成功', 'success', {
title: '取消成功', speakText: '取消成功'
icon: 'success',
duration: 1500
}); });
// 6. 延迟跳转,让用户看到成功提示 // 6. 延迟跳转,让用户看到成功提示
@ -816,6 +978,7 @@
}; };
console.log("更新仓位",updateData); console.log("更新仓位",updateData);
await this.handleSelectDetailChange(updateData); await this.handleSelectDetailChange(updateData);
this.speakMessage('库位条码扫描成功');
} else if (spaceInfo.total > 1) { } else if (spaceInfo.total > 1) {
console.log("多个仓位",spaceInfo.data); console.log("多个仓位",spaceInfo.data);
this.showSpaceList = true; this.showSpaceList = true;
@ -841,6 +1004,12 @@
this.$nextTick(() => { this.$nextTick(() => {
this.updateReceivingListHeaderTop(); this.updateReceivingListHeaderTop();
}); });
},
onHide() {
this.stopSpeak();
},
onUnload() {
this.stopSpeak();
} }
}; };
</script> </script>