feat: 成功失败及提交审核增加语音播报

This commit is contained in:
2026-10-26 12:07:53 +08:00
parent 51222f608a
commit 7cf50486ef
15 changed files with 101 additions and 67 deletions
+32 -2
View File
@@ -2,6 +2,7 @@
* 通用公共js库,主要定义api接口,auth apikey 常量值和通用函数 * 通用公共js库,主要定义api接口,auth apikey 常量值和通用函数
*/ */
import store from '@/store/index.js'; import store from '@/store/index.js';
import { speak } from './tts.js';
// var apiurl = 'http://192.168.1.66:50002/hcscm/pda/v1/'; //开发环境 添 // var apiurl = 'http://192.168.1.66:50002/hcscm/pda/v1/'; //开发环境 添
// var apiurl = 'http://192.168.1.55:50002/hcscm/pda/v1/'; //开发环境 添 // var apiurl = 'http://192.168.1.55:50002/hcscm/pda/v1/'; //开发环境 添
@@ -332,7 +333,34 @@ function createAudio(src) {
let successAudio = undefined; let successAudio = undefined;
let errorAudio = undefined; let errorAudio = undefined;
function playSuccessAudio() { /** 审核类操作成功时的固定播报 */
function statusSuccessVoice(action) {
const map = {
approve: '审核成功',
void: '作废成功',
unapprove: '消审成功',
};
return map[action] || '操作成功';
}
/** 成功/失败提示音约 0.9 秒,播完再朗读,避免提示音抢走语音 */
let speakFeedbackTimer = null;
function speakFeedback(text, fallback) {
let content = String(text == null ? '' : text)
.replace(/[\r\n\t]/g, '')
.replace(/[!!。..??;;,,、]/g, '')
.trim();
if (!content || content.length > 32) content = fallback;
if (speakFeedbackTimer) clearTimeout(speakFeedbackTimer);
speakFeedbackTimer = setTimeout(() => {
speakFeedbackTimer = null;
speak(content);
}, 1100);
}
function playSuccessAudio(text) {
speakFeedback(text, '成功');
if (!successAudio) { if (!successAudio) {
//console.log("create success"); //console.log("create success");
successAudio = createAudio('/static/audio/appright.wav'); successAudio = createAudio('/static/audio/appright.wav');
@@ -349,7 +377,8 @@ function playSuccessAudio() {
successAudio.play(); successAudio.play();
} }
function playErrorAudio() { function playErrorAudio(text) {
speakFeedback(text, '失败');
if (!errorAudio) { if (!errorAudio) {
//console.log("create error"); //console.log("create error");
errorAudio = createAudio('/static/audio/apperror.wav'); errorAudio = createAudio('/static/audio/apperror.wav');
@@ -378,4 +407,5 @@ export default {
parGetData, parGetData,
playSuccessAudio, playSuccessAudio,
playErrorAudio, playErrorAudio,
statusSuccessVoice,
}; };
+10 -11
View File
@@ -218,11 +218,11 @@ export default {
this.openPhoneScan(); this.openPhoneScan();
}, },
playSuccess() { playSuccess(text) {
util.playSuccessAudio(); util.playSuccessAudio(text);
}, },
playError() { playError(text) {
util.playErrorAudio(); util.playErrorAudio(text);
}, },
handleAllCrockNoChange() { handleAllCrockNoChange() {
@@ -289,7 +289,7 @@ export default {
}, },
// 添加通用错误提示方法 // 添加通用错误提示方法
showError(message) { showError(message) {
this.playError(); this.playError(message);
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
@@ -298,7 +298,7 @@ export default {
}, },
// 添加成功提示方法 // 添加成功提示方法
showSuccess(message) { showSuccess(message) {
this.playSuccess(); this.playSuccess(message);
uni.showToast({ uni.showToast({
title: message, title: message,
icon: 'success' icon: 'success'
@@ -364,7 +364,6 @@ export default {
if (res.data.code == 0 && res.data.msg == "success") { if (res.data.code == 0 && res.data.msg == "success") {
var aResultData = res.data.data; var aResultData = res.data.data;
this.playSuccess();
this.FabricGoodsNo = aResultData.product_code; this.FabricGoodsNo = aResultData.product_code;
this.FabricGoodsName = aResultData.product_name; this.FabricGoodsName = aResultData.product_name;
this.GoodsCodeNo = aResultData.product_color_code; this.GoodsCodeNo = aResultData.product_color_code;
@@ -401,7 +400,7 @@ export default {
// 提交按钮方法 // 提交按钮方法
submitBtnFun: function () { submitBtnFun: function () {
if (this.BillMasterID == 0) { if (this.BillMasterID == 0) {
this.playError(); this.playError("单号为空,不能提交");
this.BillDataMessage = "单号为空,不能提交"; this.BillDataMessage = "单号为空,不能提交";
return; return;
} }
@@ -438,15 +437,15 @@ export default {
console.log('outFpmArrangeOrder res', res) console.log('outFpmArrangeOrder res', res)
if (res) { if (res) {
this.BillDataMessage = "成功生成出仓单!"; this.BillDataMessage = "成功生成出仓单!";
this.playSuccess(); this.playSuccess("提交成功");
} else { } else {
this.playError(); this.playError("提交生成出仓单出错");
this.BillDataMessage = "提交生成出仓单出错!" + res.msg; this.BillDataMessage = "提交生成出仓单出错!" + res.msg;
return; return;
} }
}).catch(error => { }).catch(error => {
this.submitLoading = false this.submitLoading = false
this.playError(); this.playError("连接服务器出错");
this.BillDataMessage = "连接服务器出错,请检查后台服务是否启动!"; this.BillDataMessage = "连接服务器出错,请检查后台服务是否启动!";
}); });
}, },
@@ -248,7 +248,7 @@ export default {
this.applyOrder(order); this.applyOrder(order);
this.headerSaved = true; this.headerSaved = true;
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,可以扫码'); this.showSuccess('保存成功,可以扫码', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
}) })
.catch((e) => { .catch((e) => {
@@ -390,16 +390,16 @@ export default {
if (!order) return; if (!order) return;
this.applyOrder(order); this.applyOrder(order);
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('操作成功'); this.showSuccess(util.statusSuccessVoice(action));
}), }),
}); });
}, },
showError(message, options = {}) { showError(message, options = {}) {
if (!options.skipErrorAudio) util.playErrorAudio(); if (!options.skipErrorAudio) util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
showSuccess(message) { showSuccess(message, voiceText) {
util.playSuccessAudio(); util.playSuccessAudio(voiceText || message);
uni.showToast({ title: message, icon: 'success' }); uni.showToast({ title: message, icon: 'success' });
}, },
getBillTypeName() { getBillTypeName() {
@@ -123,13 +123,14 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(res); const order = normalizeOrder(res);
if (order) this.order = order; if (order) this.order = order;
util.playSuccessAudio(); const voice = util.statusSuccessVoice(action);
uni.showToast({ title: '操作成功', icon: 'success' }); util.playSuccessAudio(voice);
uni.showToast({ title: voice, icon: 'success' });
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
}, },
@@ -250,7 +250,7 @@
// 添加通用错误提示方法 // 添加通用错误提示方法
showError(message) { showError(message) {
this.playError(); this.playError(message);
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
@@ -260,7 +260,7 @@
// 添加成功提示方法 // 添加成功提示方法
showSuccess(message) { showSuccess(message) {
this.playSuccess(); this.playSuccess(message);
uni.showToast({ uni.showToast({
title: message, title: message,
icon: 'success' icon: 'success'
@@ -269,11 +269,11 @@
playSuccess() { playSuccess(text) {
util.playSuccessAudio(); util.playSuccessAudio(text);
}, },
playError() { playError(text) {
util.playErrorAudio(); util.playErrorAudio(text);
}, },
BarCodeDelChange: function() { BarCodeDelChange: function() {
@@ -183,7 +183,7 @@ export default {
// 添加通用错误提示方法 // 添加通用错误提示方法
showError(message) { showError(message) {
this.playError(); this.playError(message);
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
@@ -191,11 +191,11 @@ export default {
}); });
}, },
playSuccess() { playSuccess(text) {
util.playSuccessAudio(); util.playSuccessAudio(text);
}, },
playError() { playError(text) {
util.playErrorAudio(); util.playErrorAudio(text);
}, },
BarCodeDelChange: function () { BarCodeDelChange: function () {
@@ -189,8 +189,8 @@ export default {
playSuccess() { playSuccess() {
util.playSuccessAudio(); util.playSuccessAudio();
}, },
playError() { playError(text) {
util.playErrorAudio(); util.playErrorAudio(text);
}, },
// 自定义扫码处理回调 - 处理本页面特有的扫码逻辑 // 自定义扫码处理回调 - 处理本页面特有的扫码逻辑
@@ -268,7 +268,7 @@ export default {
// 添加一个通用的错误提示方法 // 添加一个通用的错误提示方法
showError(message) { showError(message) {
this.playError(); this.playError(message);
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
@@ -496,7 +496,7 @@ export default {
this.headerSaved = true; this.headerSaved = true;
this.clearWarehouseBin(); this.clearWarehouseBin();
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,请先扫描仓位'); this.showSuccess('保存成功,请先扫描仓位', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
}) })
.catch((e) => { .catch((e) => {
@@ -637,16 +637,16 @@ export default {
if (!order) return; if (!order) return;
this.applyOrder(order); this.applyOrder(order);
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('操作成功'); this.showSuccess(util.statusSuccessVoice(action));
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
showSuccess(message) { showSuccess(message, voiceText) {
util.playSuccessAudio(); util.playSuccessAudio(voiceText || message);
uni.showToast({ title: message, icon: 'success' }); uni.showToast({ title: message, icon: 'success' });
}, },
}, },
@@ -122,13 +122,14 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(res); const order = normalizeOrder(res);
if (order) this.order = order; if (order) this.order = order;
util.playSuccessAudio(); const voice = util.statusSuccessVoice(action);
uni.showToast({ title: '操作成功', icon: 'success' }); util.playSuccessAudio(voice);
uni.showToast({ title: voice, icon: 'success' });
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
}, },
@@ -367,7 +367,7 @@ export default {
this.applyOrder(order); this.applyOrder(order);
this.headerSaved = true; this.headerSaved = true;
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,请开始扫码'); this.showSuccess('保存成功,请开始扫码', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
}) })
.catch((e) => { .catch((e) => {
@@ -480,16 +480,16 @@ export default {
if (!order) return; if (!order) return;
this.applyOrder(order); this.applyOrder(order);
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('操作成功'); this.showSuccess(util.statusSuccessVoice(action));
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
showSuccess(message) { showSuccess(message, voiceText) {
util.playSuccessAudio(); util.playSuccessAudio(voiceText || message);
uni.showToast({ title: message, icon: 'success' }); uni.showToast({ title: message, icon: 'success' });
}, },
}, },
@@ -107,13 +107,14 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(res); const order = normalizeOrder(res);
if (order) this.order = order; if (order) this.order = order;
util.playSuccessAudio(); const voice = util.statusSuccessVoice(action);
uni.showToast({ title: '操作成功', icon: 'success' }); util.playSuccessAudio(voice);
uni.showToast({ title: voice, icon: 'success' });
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
}, },
@@ -419,7 +419,7 @@ export default {
this.headerSaved = true; this.headerSaved = true;
this.clearWarehouseBin(); this.clearWarehouseBin();
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,请先扫描仓位'); this.showSuccess('保存成功,请先扫描仓位', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
}) })
.catch((e) => { .catch((e) => {
@@ -537,16 +537,16 @@ export default {
if (!order) return; if (!order) return;
this.applyOrder(order); this.applyOrder(order);
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('操作成功'); this.showSuccess(util.statusSuccessVoice(action));
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
showSuccess(message) { showSuccess(message, voiceText) {
util.playSuccessAudio(); util.playSuccessAudio(voiceText || message);
uni.showToast({ title: message, icon: 'success' }); uni.showToast({ title: message, icon: 'success' });
}, },
}, },
@@ -107,13 +107,14 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(res); const order = normalizeOrder(res);
if (order) this.order = order; if (order) this.order = order;
util.playSuccessAudio(); const voice = util.statusSuccessVoice(action);
uni.showToast({ title: '操作成功', icon: 'success' }); util.playSuccessAudio(voice);
uni.showToast({ title: voice, icon: 'success' });
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
}, },
@@ -501,7 +501,7 @@ export default {
this.headerSaved = true; this.headerSaved = true;
this.clearWarehouseBin(); this.clearWarehouseBin();
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,请先扫描仓位'); this.showSuccess('保存成功,请先扫描仓位', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
}) })
.catch((e) => { .catch((e) => {
@@ -642,16 +642,16 @@ export default {
if (!order) return; if (!order) return;
this.applyOrder(order); this.applyOrder(order);
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('操作成功'); this.showSuccess(util.statusSuccessVoice(action));
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
showSuccess(message) { showSuccess(message, voiceText) {
util.playSuccessAudio(); util.playSuccessAudio(voiceText || message);
uni.showToast({ title: message, icon: 'success' }); uni.showToast({ title: message, icon: 'success' });
}, },
}, },
@@ -122,13 +122,14 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(res); const order = normalizeOrder(res);
if (order) this.order = order; if (order) this.order = order;
util.playSuccessAudio(); const voice = util.statusSuccessVoice(action);
uni.showToast({ title: '操作成功', icon: 'success' }); util.playSuccessAudio(voice);
uni.showToast({ title: voice, icon: 'success' });
}), }),
}); });
}, },
showError(message) { showError(message) {
util.playErrorAudio(); util.playErrorAudio(message);
uni.showModal({ title: '提示', content: message, showCancel: false }); uni.showModal({ title: '提示', content: message, showCancel: false });
}, },
}, },