| | |
| | | createProductSales, |
| | | finishProductSales, |
| | | getProductSales, |
| | | scanProductSales, |
| | | shippingProductSales, |
| | | stockProductSales, |
| | | submitProductSales, |
| | |
| | | const emit = defineEmits(['success']); |
| | | const formType = ref<FormType>('create'); |
| | | const formData = ref<MesWmProductSalesApi.ProductSales>(); |
| | | const scanContent = ref(''); |
| | | const scanQuantity = ref<number>(); |
| | | const scanLoading = ref(false); |
| | | const scanRefreshKey = ref(0); |
| | | const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求 |
| | | const isEditable = computed(() => |
| | | // 是否为编辑模式(可保存) |
| | |
| | | emit('success'); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | } |
| | | |
| | | /** 扫码拣货:扫码枪通常以回车结束输入 */ |
| | | async function handleScan() { |
| | | if (!formData.value?.id || !scanContent.value.trim() || scanLoading.value) { |
| | | return; |
| | | } |
| | | scanLoading.value = true; |
| | | try { |
| | | const result = await scanProductSales({ |
| | | quantity: scanQuantity.value, |
| | | salesId: formData.value.id, |
| | | scanContent: scanContent.value.trim(), |
| | | }); |
| | | message[result.alreadyScanned ? 'warning' : 'success']( |
| | | result.alreadyScanned |
| | | ? `该码已扫描,明细编号:${result.detailId ?? '-'}` |
| | | : `${result.message || '扫码成功'}${result.scanType ? `(${result.scanType === 'PALLET' ? '托盘码' : '袋码'})` : ''}`, |
| | | ); |
| | | scanContent.value = ''; |
| | | scanQuantity.value = undefined; |
| | | scanRefreshKey.value += 1; |
| | | } finally { |
| | | scanLoading.value = false; |
| | | } |
| | | } |
| | | |
| | |
| | | <template v-if="formData?.id"> |
| | | <Divider>物料信息</Divider> |
| | | <div class="mx-4"> |
| | | <div v-if="isStock" class="mb-3 flex items-center gap-2 px-4"> |
| | | <a-input |
| | | v-model:value="scanContent" |
| | | :disabled="scanLoading" |
| | | autofocus |
| | | class="flex-1" |
| | | placeholder="请扫描袋码或托盘码,回车提交" |
| | | @press-enter="handleScan" |
| | | /> |
| | | <a-input-number |
| | | v-model:value="scanQuantity" |
| | | :disabled="scanLoading" |
| | | :min="0" |
| | | placeholder="数量(可选)" |
| | | style="width: 140px" |
| | | /> |
| | | <Button :loading="scanLoading" type="default" @click="handleScan"> |
| | | 扫码 |
| | | </Button> |
| | | </div> |
| | | <LineList |
| | | :form-type="formType" |
| | | :notice-id="formData.noticeId" |
| | | :refresh-key="scanRefreshKey" |
| | | :sales-id="formData.id" |
| | | /> |
| | | </div> |