This commit is contained in:
2026-10-12 13:43:37 +08:00
parent 9c3855cec2
commit aebe4f9528
21 changed files with 482 additions and 141 deletions
+30
View File
@@ -44,6 +44,7 @@ function scanState() {
open(row) { this.task = row }, $nextTick(callback) { callback() } }
value.run = scope.page.methods.run.bind(value)
value.enterTask = scope.page.methods.enterTask.bind(value)
value.offerNextPalletTask = scope.page.methods.offerNextPalletTask.bind(value)
return value
}
@@ -63,6 +64,35 @@ test('box and single-batch pallet scans claim and open counting directly without
}
})
test('completed pallet offers remaining batches and starts only after confirmation', async () => {
for (const confirm of [false, true]) {
const value = scanState(); value.task = null
const next = { receiptNo: 'RR-NEXT', palletCode: 'PLT-1', status: 'PENDING' }
scope.scanReturnCountTasks = async code => { assert.equal(code, 'PLT-1'); return [next, { ...next, receiptNo: 'RR-DONE', status: 'CONFIRMED' }, { ...next, palletCode: 'PLT-2' }] }
scope.getCurrentReturnCountTask = async () => null
let claimed = 0
scope.beginReturnCountTask = async receiptNo => { claimed++; assert.equal(receiptNo, 'RR-NEXT'); return { ...next, status: 'COUNTING' } }
value.ask = async options => { assert.match(options.content, /还有 1 项/); assert.equal(options.cancelText, '暂不清点'); return { confirm } }
await value.offerNextPalletTask({ receiptNo: 'RR-DONE', palletCode: 'PLT-1' })
assert.equal(claimed, confirm ? 1 : 0)
assert.equal(value.task?.status || null, confirm ? 'COUNTING' : null)
}
})
test('no remaining pallet task skips prompt and claim conflicts remain visible', async () => {
const value = scanState(); value.task = null
value.ask = async () => assert.fail('no remaining task should not prompt')
scope.scanReturnCountTasks = async () => []
await value.offerNextPalletTask({ receiptNo: 'RR-DONE', palletCode: 'PLT-1' })
scope.scanReturnCountTasks = async () => [{ receiptNo: 'RR-NEXT', palletCode: 'PLT-1', status: 'COUNTING' }]
value.ask = async () => ({ confirm: true })
scope.getCurrentReturnCountTask = async () => null
scope.beginReturnCountTask = async () => { throw Object.assign(new Error('该任务正在由其他人员清点'), { code: 'A0409' }) }
await value.run(() => value.offerNextPalletTask({ receiptNo: 'RR-DONE', palletCode: 'PLT-1' }))
assert.equal(value.error.code, 'A0409')
assert.equal(value.task, null)
})
test('direct scan cannot claim a different task while the operator has unfinished work', async () => {
const value = scanState()
scope.scanReturnCountTasks = async () => [{ receiptNo: 'RR-NEW', returnNo: 'RT-NEW' }]