云
8 天以前 78caa769e452f63288743b8997f7b4c21bb06ce5
src/views/mobile/query.vue
@@ -8,6 +8,7 @@
import { can } from '#/mobile/access';
import { lookup, errorText, writeBlockReason, type TraceResult, type TraceObject } from '#/mobile/api';
import Scanner from './scanner.vue';
import { speakDuplicateScan } from '#/mobile/scanVoice';
defineOptions({name:'MobileQuery'});
const route=useRoute(),key=route.path.split('/')[2]||'bags';
const expected={bags:'bag',pallets:'pallet',batches:'batch'}[key];
@@ -39,9 +40,9 @@
    if((binding.value||autoPacking.value)&&writeBlockReason(r))throw new Error(writeBlockReason(r));
    if(autoPacking.value){
      if(r.type!=='bag')throw new Error('请扫描袋码');
      if(r.data.palletId)throw new Error('该袋码已绑定托盘,请核实后操作');
      if(r.data.palletId){speakDuplicateScan('bind');throw new Error('该袋码已绑定托盘,请核实后操作');}
      if(!r.data.itemId)throw new Error('该袋码缺少品种,无法绑定托盘');
      if(bags.value.some(b=>b.data.id===r.data.id))throw new Error('本次已经采集该袋码');
      if(bags.value.some(b=>b.data.id===r.data.id)){speakDuplicateScan('bind');throw new Error('本次已经采集该袋码');}
      const first=bags.value[0];
      if(first&&first.data.itemId!==r.data.itemId)throw new Error('袋码品种与本次托盘不一致');
      if(first&&first.data.batchId!==r.data.batchId)throw new Error('袋码所属批次与本次托盘不一致');
@@ -58,9 +59,9 @@
    }else{
      if(r.type!==expected)throw new Error('请扫描'+(key==='bags'?'袋码':'托盘码'));
      if(key==='bags'){
        if(r.data.palletId)throw new Error('该袋码已绑定托盘,请核实后操作');
        if(r.data.palletId){speakDuplicateScan('bind');throw new Error('该袋码已绑定托盘,请核实后操作');}
        if(r.data.batchId&&target.value.data.batchId&&r.data.batchId!==target.value.data.batchId)throw new Error('袋码与目标托盘批次不一致');
        if(bags.value.some(b=>b.data.id===r.data.id))throw new Error('本次已经采集该袋码');
        if(bags.value.some(b=>b.data.id===r.data.id)){speakDuplicateScan('bind');throw new Error('本次已经采集该袋码');}
        bags.value.push(r);
      }else{
        if(r.data.batchId)throw new Error('该托盘已绑定批次');
@@ -138,7 +139,7 @@
      <div v-if="target" class="m-panel"><p>目标:{{target.code}}</p><p class="m-muted">{{target.data.itemName||'未录入品种'}} · {{target.data.batchCode||'未绑定批次'}}</p></div>
    </template>
    <template v-if="autoPacking"><h2 class="m-title">扫描袋码生成托盘</h2><p class="m-muted">{{palletSize}} 袋为提醒节点 · 已采集 {{bags.length}} 袋。达到节点会提醒,可随时生成并绑定。</p></template>
    <Scanner :disabled="busy||thresholdPrompt" :continuous="autoPacking" @code="identify"/>
    <Scanner voice-operation="bind" :duplicate-voice="binding||autoPacking" :disabled="busy||thresholdPrompt" :continuous="autoPacking" @code="identify"/>
    <section v-if="autoPacking&&thresholdPrompt" class="m-panel" role="alert" aria-labelledby="pallet-threshold-title" aria-describedby="pallet-threshold-description">
      <h2 id="pallet-threshold-title" class="m-title">已达到 {{palletSize}} 袋提醒节点</h2>
      <p id="pallet-threshold-description">可立即生成并绑定托盘码,也可继续扫描更多袋码加入本托盘。</p>
@@ -150,8 +151,7 @@
      <p v-else class="m-status">{{detail.data.inboundTime ? '已入库' : '未入库'}}<span v-if="detail.type === 'pallet'"> · 待入库 {{detail.data.pendingBagQuantity ?? '—'}} 袋</span></p>
      <p v-if="writeBlockReason(detail)" class="m-warning">{{writeBlockReason(detail)}}</p>
      <dl><div class="m-row"><dt>码值</dt><dd>{{detail.code}}</dd></div><div class="m-row"><dt>批次</dt><dd>{{detail.data.batchCode||detail.data.tempCode||'未绑定'}}</dd></div><div class="m-row"><dt>托盘</dt><dd>{{detail.data.palletCode||'—'}}</dd></div><div class="m-row"><dt>生产日期</dt><dd>{{detail.data.produceDate||'未录入'}}</dd></div><div class="m-row"><dt>产线</dt><dd>{{detail.data.lineName||'未录入'}}</dd></div></dl>
      <dl v-if="detail.type==='bag'"><div class="m-row"><dt>追溯码</dt><dd>{{detail.data.code}}</dd></div><div class="m-row"><dt>业务码</dt><dd>{{detail.data.businessCode||'未生成'}}</dd></div></dl>
      <dl v-else><div class="m-row"><dt>业务码</dt><dd>{{detail.data.businessCode||'未生成'}}</dd></div></dl>
      <dl v-if="detail.type==='bag'"><div class="m-row"><dt>追溯码</dt><dd>{{detail.data.code}}</dd></div></dl>
    </div>
    <template v-if="binding||autoPacking">
      <p v-if="key==='bags'" class="m-muted">已采集 {{bags.length}} 袋,尚未提交绑定</p>