From 9561f94074367e6e52e6831b1ec443f68eed32ed Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Wed, 21 Oct 2026 19:20:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BD=91=E9=A1=B5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=BA=E4=B8=B0=E8=BF=90=E8=B4=B9=E6=97=B6=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=9C=88=E7=BB=93=E5=B9=B6=E5=A1=AB=E5=86=99=E9=A1=BA=E4=B8=B0?= =?UTF-8?q?=E5=8D=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- web-admin/src/api/sample-freight.ts | 11 +- .../sample-transport-form-section/index.vue | 140 ++++++++++-------- .../src/utils/sf-express-freight.test.ts | 48 ++++++ web-admin/src/utils/sf-express-freight.ts | 59 ++++++++ .../sample-freight/FreightConfigDialog.vue | 59 ++++++-- .../sample-freight/FreightEditDialog.vue | 52 +++++-- .../cell-storage/sample-freight/index.vue | 41 +++-- 7 files changed, 312 insertions(+), 98 deletions(-) create mode 100644 web-admin/src/utils/sf-express-freight.test.ts create mode 100644 web-admin/src/utils/sf-express-freight.ts diff --git a/web-admin/src/api/sample-freight.ts b/web-admin/src/api/sample-freight.ts index 2efa8d71..b21627b0 100644 --- a/web-admin/src/api/sample-freight.ts +++ b/web-admin/src/api/sample-freight.ts @@ -18,7 +18,11 @@ export type SampleFreight = { freightNo?: string transportMode: string transportModeLabel?: string - freightAmount: number + freightAmount: number | null + waybillNo?: string + settleStatus?: string + settleTime?: string + freightAmountLabel?: string linkedSampleCount?: number createBy?: string createByName?: string @@ -63,7 +67,8 @@ export function fetchSampleFreightDetail(id: string) { export function fetchCreateSampleFreight(data: { transportMode: string - freightAmount: number + freightAmount: number | null + waybillNo?: string items: SampleFreightItem[] }) { return request.post({ @@ -75,7 +80,7 @@ export function fetchCreateSampleFreight(data: { export function fetchUpdateSampleFreight( id: string, - data: { transportMode?: string; freightAmount?: number } + data: { transportMode?: string; freightAmount?: number | null; waybillNo?: string } ) { return request.put({ url: `/web/admin/sample-freights/${id}`, diff --git a/web-admin/src/components/business/sample-transport-form-section/index.vue b/web-admin/src/components/business/sample-transport-form-section/index.vue index 7b130eb7..0240e01f 100644 --- a/web-admin/src/components/business/sample-transport-form-section/index.vue +++ b/web-admin/src/components/business/sample-transport-form-section/index.vue @@ -6,19 +6,11 @@ 添加样本 - + 配置运费 - + 取消运费 @@ -104,12 +96,7 @@ - + @@ -209,11 +196,7 @@ - + @@ -318,9 +301,25 @@ /> - + + + + + + + @@ -200,6 +216,11 @@ type SampleFreightItem } from '@/api/sample-freight' import { receptionSourceLabel, receptionSourceTagType } from '@/utils/status-tag-registry' + import { + buildFreightHeaderPayload, + isSfExpress, + validateFreightHeader + } from '@/utils/sf-express-freight' defineOptions({ name: 'FreightConfigDialog' }) @@ -229,7 +250,8 @@ }) const form = reactive({ transportMode: '', - freightAmount: null as number | null + freightAmount: null as number | null, + waybillNo: '' }) async function loadTransportModeOptions() { @@ -258,7 +280,9 @@ keyword: existingKeyword.value || undefined }) const data = (res as any)?.data || res - existingFreightList.value = data?.list || [] + existingFreightList.value = ((data?.list || []) as SampleFreight[]).filter( + (row) => row.settleStatus !== 'yjs' + ) } catch { existingFreightList.value = [] } finally { @@ -316,6 +340,7 @@ mode.value = 'create' form.transportMode = '' form.freightAmount = null + form.waybillNo = '' selectedExisting.value = null selectedFreightId.value = '' existingKeyword.value = '' @@ -370,18 +395,24 @@ submitting.value = true try { if (mode.value === 'create') { - if (!form.transportMode || form.freightAmount == null) { - ElMessage.warning('请填写运输方式与运费') - return - } - const amount = Number(form.freightAmount) - if (Number.isNaN(amount) || amount < 0) { - ElMessage.warning('运费须为不小于 0 的数字') - return - } - await fetchCreateSampleFreight({ + const message = validateFreightHeader({ transportMode: form.transportMode, - freightAmount: amount, + freightAmount: form.freightAmount, + waybillNo: form.waybillNo + }) + if (message) { + ElMessage.warning(message) + return + } + const header = buildFreightHeaderPayload({ + transportMode: form.transportMode, + freightAmount: form.freightAmount, + waybillNo: form.waybillNo + }) + await fetchCreateSampleFreight({ + transportMode: header.transportMode, + freightAmount: header.freightAmount, + waybillNo: header.waybillNo, items: toItems(samples) }) } else { diff --git a/web-admin/src/views/cell-storage/sample-freight/FreightEditDialog.vue b/web-admin/src/views/cell-storage/sample-freight/FreightEditDialog.vue index f1cfefc8..d6245f8a 100644 --- a/web-admin/src/views/cell-storage/sample-freight/FreightEditDialog.vue +++ b/web-admin/src/views/cell-storage/sample-freight/FreightEditDialog.vue @@ -41,9 +41,25 @@ /> - + + + + + + + @@ -135,7 +144,12 @@ align="right" header-align="center" > - +