| | |
| | | submitProductSales, |
| | | updateProductSales, |
| | | } from '#/api/mes/wm/productsales'; |
| | | import TraceScanInput from '#/components/TraceScanInput.vue'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useFormSchema } from '../data'; |
| | |
| | | const formType = ref<FormType>('create'); |
| | | const formData = ref<MesWmProductSalesApi.ProductSales>(); |
| | | const scanContent = ref(''); |
| | | const scanType = ref<'BAG' | 'PALLET' | 'BATCH'>('BAG'); |
| | | const scanType = ref<'' | 'BAG' | 'BATCH' | 'PALLET'>(''); |
| | | const scanPreview = ref<MesWmProductSalesApi.ProductSalesScanResponse>(); |
| | | const selectedBagIds = ref<number[]>([]); |
| | | const scanLoading = ref(false); |
| | |
| | | } |
| | | } |
| | | |
| | | /** 先识别对象并选择袋码,回车不会直接写入拣货。 */ |
| | | async function handleScan() { |
| | | if (!formData.value?.id || !scanContent.value.trim() || scanLoading.value) { |
| | | /** 先识别对象并选择袋码,确认后才写入拣货。 */ |
| | | async function handleScan(raw?: string) { |
| | | const content = (raw ?? scanContent.value).trim(); |
| | | if (!formData.value?.id || !content || scanLoading.value) { |
| | | return; |
| | | } |
| | | scanContent.value = content; |
| | | scanLoading.value = true; |
| | | try { |
| | | scanPreview.value = undefined; |
| | | selectedBagIds.value = []; |
| | | const result = await previewProductSalesScan(scanContent.value.trim(), scanType.value, formData.value.id); |
| | | const result = await previewProductSalesScan(content, scanType.value || undefined, formData.value.id); |
| | | scanPreview.value = result; |
| | | if (result.scanType === 'BAG') selectedBagIds.value = result.bags?.filter(b => b.selectable).map(b => b.id) || []; |
| | | if (!result.scanQuantity) message.warning('当前对象没有可拣袋码,请核对质检和库存状态'); |
| | |
| | | <div v-if="isStock" class="mb-3 flex items-center gap-2 px-4"> |
| | | <label for="sales-picking-type" class="sr-only">拣货扫码类型</label> |
| | | <a-select id="sales-picking-type" v-model:value="scanType" :disabled="scanLoading" style="width:140px" @change="scanPreview = undefined; selectedBagIds = []"> |
| | | <a-select-option value="BAG">袋码</a-select-option><a-select-option value="PALLET">托盘码</a-select-option><a-select-option value="BATCH">生产批次码</a-select-option> |
| | | <a-select-option value="">自动识别</a-select-option><a-select-option value="BAG">袋码</a-select-option><a-select-option value="PALLET">托盘码</a-select-option><a-select-option value="BATCH">生产批次码</a-select-option> |
| | | </a-select> |
| | | <a-input |
| | | v-model:value="scanContent" |
| | | :disabled="scanLoading" |
| | | autofocus |
| | | <TraceScanInput |
| | | class="flex-1" |
| | | placeholder="扫描所选类型码,回车识别" |
| | | @press-enter="handleScan" |
| | | :disabled="scanLoading" |
| | | placeholder="扫描追溯二维码或输入追溯码,回车识别" |
| | | @code="handleScan" |
| | | /> |
| | | <Button :loading="scanLoading" type="default" @click="handleScan"> |
| | | 识别码值 |
| | | </Button> |
| | | </div> |
| | | <section v-if="isStock && scanPreview" class="mb-4 rounded-lg border border-border p-4"> |
| | | <h3 class="font-semibold">核对拣货对象</h3><p>批次 {{scanPreview.batchCode}} · 可拣 {{scanPreview.scanQuantity}} 袋</p> |