diff --git a/src/pages/warehouse/inventoryCountDetail.vue b/src/pages/warehouse/inventoryCountDetail.vue index 3e94d67..3d7adb0 100644 --- a/src/pages/warehouse/inventoryCountDetail.vue +++ b/src/pages/warehouse/inventoryCountDetail.vue @@ -306,6 +306,8 @@ export default { // 从库位明细页返回:刷新作业列表(状态/已盘数可能变化) if (this._pendingWorkRefresh) { this._pendingWorkRefresh = false; + // 返回时清空输入框数据,列表显示全部库位 + this.scanKeyword = ''; if (this.isWorkTab && this.canEdit) { this.loadWorkList(this.workPage); } @@ -657,11 +659,12 @@ export default { cancelText: '取消', success: async (res) => { if (!res.confirm) return; - await this.submitReport({ + const ok = await this.submitReport({ detailId: row.detailId, location: row.location, isEmpty: true }, '已标记空库位'); + this.speakMessage(ok ? '已标记空库位' : '标记失败', { force: true, minInterval: 0 }); } }); }, @@ -799,6 +802,21 @@ export default { if (!this.hasActions || this.submitting) return; this.showActionsPopup = true; }, + /** 语音播报(复用全局 $tools.speakText,受 voice.enabled 开关控制) */ + 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('[inventoryCountDetail] 语音播报失败:', error)); + } + } catch (error) { + console.warn('[inventoryCountDetail] 语音播报异常:', error); + } + }, async handleFinish() { this.showActionsPopup = false; if (this.submitting || !this.taskId) return; @@ -813,6 +831,7 @@ export default { try { const response = await this.$http('check.finish', { id: Number(this.taskId) }); if (response?.flag === 'failure') { + this.speakMessage('盘点失败', { force: true, minInterval: 0 }); uni.showToast({ title: response.message || '完成失败', icon: 'none' }); return; } @@ -822,6 +841,8 @@ export default { if (profit || loss) { title = `盘点完成 盘盈${profit} 盘亏${loss}`; } + // 语音播报统一为「盘点完成」(盘盈/盘亏详情仅弹窗展示) + this.speakMessage('盘点完成', { force: true, minInterval: 0 }); uni.showModal({ title, content: '该盘点任务已完成。', @@ -833,6 +854,7 @@ export default { }); } catch (error) { console.error('[inventoryCountDetail] 完成盘点失败:', error); + this.speakMessage('盘点失败', { force: true, minInterval: 0 }); uni.showToast({ title: '完成盘点失败', icon: 'none' }); } finally { this.submitting = false; diff --git a/src/pages/warehouse/inventoryCountLocation.vue b/src/pages/warehouse/inventoryCountLocation.vue index e699304..b82e691 100644 --- a/src/pages/warehouse/inventoryCountLocation.vue +++ b/src/pages/warehouse/inventoryCountLocation.vue @@ -229,6 +229,21 @@ export default { handleKeywordClear() { this.scanKeyword = ''; }, + /** 语音播报(复用全局 $tools.speakText,受 voice.enabled 开关控制) */ + 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('[inventoryCountLocation] 语音播报失败:', error)); + } + } catch (error) { + console.warn('[inventoryCountLocation] 语音播报异常:', error); + } + }, // ===== 添加商品记录 / 标记空库位 ===== openAddPopup(barcode) { this.pendingBarcode = String(barcode || '').trim(); @@ -250,12 +265,13 @@ export default { } uni.showModal({ title: '标记空库位', - content: `确认库位「${this.locationCode || this.detailId}」为空?该库位已有的商品记录会被清除。`, + content: `确认库位「${this.locationName || this.locationCode || this.detailId}」为空?该库位已有的商品记录会被清除。`, confirmText: '确认', cancelText: '取消', success: async (res) => { if (!res.confirm) return; - await this.submitReport({ isEmpty: true }, '已标记空库位'); + const ok = await this.submitReport({ isEmpty: true, detailId: this.detailId }, '已标记空库位'); + this.speakMessage(ok ? '已标记空库位' : '标记失败', { force: true, minInterval: 0 }); } }); },