This commit is contained in:
2026-11-05 16:03:32 +08:00
parent 63fac79814
commit 1acd33347a
3 changed files with 33 additions and 3 deletions
+8 -2
View File
@@ -34,16 +34,22 @@
import ScanTargetInput from '@/components/ScanTargetInput.vue'
import { listDropshipPalletizationTasks, resolveDropshipWorkspacePallet } from '@/api/pda-dropship.js'
import { session, requireSession } from '@/stores/session.js'
import { startScanBroadcast } from '@/utils/scan-broadcast.js'
import { formatApiError } from '@/utils/user-facing.js'
export default {
components: { PortalHeader, ScanTargetInput },
data() { return { user: session.currentUser, keyword: '', tasks: [], loading: false, error: '', palletNo: '' } },
onLoad(options) { this.palletNo = String(options.palletNo || '') },
onShow() { if (!requireSession()) return; this.user = session.currentUser; this.loadTasks() },
onShow() { if (!requireSession()) return; this.user = session.currentUser; this.startScanner(); this.loadTasks() },
onHide() { this.stopScanner() }, onUnload() { this.stopScanner() }, beforeUnmount() { this.stopScanner() },
methods: {
// 入仓码广播直接驱动查询,不依赖输入框焦点。
startScanner() { this.stopScanner(); this._stopScanner = startScanBroadcast({ onScan: value => { if (this.loading) return; this.keyword = String(value).trim(); this.loadTasks() }, onError: () => { this.error = '扫码头连接失败,可输入入仓码查询' } }) },
stopScanner() { this._stopScanner?.(); this._stopScanner = null },
statusLabel(status) { return status === 'CLAIMED' ? '作业中' : '待领取' },
async loadTasks() {
async loadTasks(value) {
if (typeof value === 'string') this.keyword = value.trim()
if (this.loading) return
if (!this.user?.warehouseId) { this.error = '请返回首页选择作业仓库'; return }
this.loading = true; this.error = ''