This commit is contained in:
zlwu committed 2026-10-17 11:46:53 +08:00
1 parent 48dcf991dc
commit be2226e4ca
100 files changed
+61340 -40975

No files matched your search

@@ -204,7 +204,7 @@
<SampleTransportFormSection
v-model:samples="formData.samples"
sample-source="cell_storage"
:protocol-id="formData.id || ''"
:protocol-id="editingId || ''"
hide-dialog-collect-amount-unit
:sample-type-options="sampleTypeOptions"
:sample-type-options-loading="sampleTypeLoading"
@@ -1232,9 +1232,6 @@
import { formatMoneyDisplay } from '@/utils/money-format'
import {
payModeLabel,
newbornSexLabel,
deliveryModeLabel,
sampleStatusLabel,
loadTransferTypeDict,
getTransferTypeOptions,
transferTypeLabel,
@@ -1262,7 +1259,7 @@
/** 金额只读展示:千分位 + ¥ 前缀 */
function fmtMoney(v: unknown): string {
if (v == null || v === '') return '—'
return '¥' + formatMoneyDisplay(v)
return '¥' + formatMoneyDisplay(v as string | number)
}
const userStore = useUserStore()
@@ -1469,6 +1466,7 @@
/* ====== 新增/编辑弹窗 ====== */
const dialogFormLoading = ref(false)
const editDetailLoaded = ref(false)
const dialogTitle = ref('新增协议单')
const isEdit = ref(false)
const submitLoading = ref(false)
@@ -2078,6 +2076,7 @@
function handleOpenForAdd() {
isEdit.value = false
editingId.value = null
dialogTitle.value = '新增协议单'
resetForm()
formData.protocolStatus = 'sxz'
@@ -2278,6 +2277,7 @@
if (!row || !props.editId) return
isEdit.value = true
editDetailLoaded.value = false
dialogTitle.value = '编辑协议单'
editingId.value = props.editId
resetForm()
@@ -2296,11 +2296,11 @@
try {
const [, bundle] = await Promise.all([
loadEthnicOptions(),
fetchCollectionProtocolDetail(String(row.id)).catch(() => null)
fetchCollectionProtocolDetail(String(row.id))
])
if (bundle) {
applyProtocolBundleToForm(bundle as Record<string, any>, row)
}
if (!bundle) throw new Error('协议详情为空')
applyProtocolBundleToForm(bundle as Record<string, any>, row)
editDetailLoaded.value = true
const ciBundle = (bundle as any)?.collectionInfo as Record<string, any> | null
const hydrateTasks: Promise<void>[] = [
@@ -2345,7 +2345,10 @@
hydrateSampleLookupOptions()
}
} catch {
/* 保留列表行已填基础字段 */
if (!editDetailLoaded.value) {
ElMessage.error('协议详情加载失败,请重新打开后重试')
emit('update:modelValue', false)
}
} finally {
dialogFormLoading.value = false
}
@@ -2353,6 +2356,25 @@
async function handleSubmit() {
if (!formRef.value || submitLoading.value) return
if (isEdit.value && !editDetailLoaded.value) {
ElMessage.warning('协议详情尚未加载成功,请重新打开后重试')
return
}
const uploadLists = [
formData.attachments,
formData.consentAttachments,
formData.healthSurveyAttachments,
...formData.paymentDetails.map((d) => d.attachments || []),
...formData.samplePayments.flatMap((p) =>
(p.schedules || []).flatMap((sch: any) =>
(sch.transfers || []).map((t: any) => t.attachments || [])
)
)
]
if (uploadLists.some((list) => list.some((f: any) => f._uploading))) {
ElMessage.warning('附件正在上传,请稍后再保存')
return
}
submitLoading.value = true
try {
await formRef.value.validate()
@@ -2438,12 +2460,11 @@
.join(',')
const payload: Record<string, unknown> = {
protocolStatus: formData.protocolStatus,
registerDate: formData.registerDate || undefined,
collectorUserId: formData.collectorUserId || undefined,
protocolAttachments: protocolAttachmentUrls || formData.protocolAttachments || undefined,
consentFormUrls: consentAttachmentUrls || formData.consentFormUrls || undefined,
healthSurveyFormUrls:
healthSurveyAttachmentUrls || formData.healthSurveyFormUrls || undefined,
registerDate: formData.registerDate || '',
collectorUserId: formData.collectorUserId || '',
protocolAttachments: protocolAttachmentUrls,
consentFormUrls: consentAttachmentUrls,
healthSurveyFormUrls: healthSurveyAttachmentUrls,
attachments: formData.attachments.map((a) => ({
id: a.id,
fileName: a.fileName,
@@ -2468,39 +2489,39 @@
fileSizeDisplay: a.fileSizeDisplay,
fileType: a.fileType
})),
remark: formData.remark || undefined,
remark: formData.remark || '',
partyCustomer: {
customerId: formData.customerId || undefined,
fatherCustomerId: formData.fatherCustomerId || undefined,
motherName: formData.motherName || undefined,
motherPhone: formData.motherPhone || undefined,
motherIdCard: formData.motherIdCard || undefined,
motherBirthYm: formData.motherBirthYm || undefined,
motherEthnic: formData.motherEthnic || undefined,
motherEmail: formData.motherEmail || undefined,
motherAddress: formData.motherAddress || undefined,
fatherName: formData.fatherName || undefined,
fatherPhone: formData.fatherPhone || undefined,
fatherIdCard: formData.fatherIdCard || undefined,
newbornName: formData.newbornName || undefined,
newbornIdCard: formData.newbornIdCard || undefined,
expectedDeliveryDate: formData.expectedDeliveryDate || undefined,
newbornDeliveryTime: formData.newbornDeliveryTime || undefined,
newbornSex: formData.newbornSex || undefined,
deliveryMode: formData.deliveryMode || undefined,
birthOrder: formData.birthOrder ?? undefined,
newbornWeightGram: formData.newbornWeightGram ?? undefined,
apgar1min: formData.apgar1min ?? undefined,
apgar5min: formData.apgar5min ?? undefined
customerId: formData.customerId || '',
fatherCustomerId: formData.fatherCustomerId || '',
motherName: formData.motherName || '',
motherPhone: formData.motherPhone || '',
motherIdCard: formData.motherIdCard || '',
motherBirthYm: formData.motherBirthYm || '',
motherEthnic: formData.motherEthnic || '',
motherEmail: formData.motherEmail || '',
motherAddress: formData.motherAddress || '',
fatherName: formData.fatherName || '',
fatherPhone: formData.fatherPhone || '',
fatherIdCard: formData.fatherIdCard || '',
newbornName: formData.newbornName || '',
newbornIdCard: formData.newbornIdCard || '',
expectedDeliveryDate: formData.expectedDeliveryDate || '',
newbornDeliveryTime: formData.newbornDeliveryTime || '',
newbornSex: formData.newbornSex || '',
deliveryMode: formData.deliveryMode || '',
birthOrder: formData.birthOrder ?? null,
newbornWeightGram: formData.newbornWeightGram ?? null,
apgar1min: formData.apgar1min ?? null,
apgar5min: formData.apgar5min ?? null
},
collectionInfo: {
regionId: formData.regionId || undefined,
hospitalId: formData.hospitalId || undefined,
medicalStaff: formData.medicalStaff || undefined,
salesUserId: formData.salesUserId || undefined,
regionManagerUserId: formData.regionManagerUserId || undefined,
sampleCollectTime: formData.sampleCollectTime || undefined,
maternalBloodCollectTime: formData.maternalBloodCollectTime || undefined
regionId: formData.regionId || '',
hospitalId: formData.hospitalId || '',
medicalStaff: formData.medicalStaff || '',
salesUserId: formData.salesUserId || '',
regionManagerUserId: formData.regionManagerUserId || '',
sampleCollectTime: formData.sampleCollectTime || '',
maternalBloodCollectTime: formData.maternalBloodCollectTime || ''
},
samples: formData.samples.map(({ _rowKey, transport, freight, freightDraft, ...s }) => ({
...s,
@@ -2560,7 +2581,9 @@
transferType: t.transferType,
transferAmount: t.transferAmount,
transferTime: t.transferTime,
transferAttachments: fromFiles || t.transferAttachments || undefined,
transferAttachments: Array.isArray(t.attachments)
? fromFiles
: t.transferAttachments || '',
payStatus: t.payStatus || 'dfj',
remark: t.remark
}
@@ -3376,13 +3399,15 @@
const q = (query || '').trim()
if (!q) {
cb([])
return
return []
}
try {
const res = await fetchCustomerList({ page: 1, pageSize: 20, keyword: q })
cb(res.list || [])
return res.list || []
} catch {
cb([])
return []
}
}
@@ -3524,13 +3549,13 @@
fileType: file.type || '',
_uploading: true
})
const idx = list.length - 1
try {
const fd = new FormData()
fd.append('folder', folder)
fd.append('file', file)
const res = await fetchUploadAttachment(fd)
const idx = list.findIndex((f) => f.id === tempId)
if (idx < 0) return
list[idx] = {
...list[idx],
id: res.id || tempId,
@@ -3543,7 +3568,8 @@
}
} catch {
ElMessage.error('文件上传失败')
list.splice(idx, 1)
const idx = list.findIndex((f) => f.id === tempId)
if (idx >= 0) list.splice(idx, 1)
} finally {
nextTick(() => uploadRef.value?.clearFiles())
}
@@ -3668,13 +3694,13 @@
fileType: file.type || '',
_uploading: true
})
const aIdx = detail.attachments.length - 1
try {
const fd = new FormData()
fd.append('folder', 'protocol-payment')
fd.append('file', file)
const res = await fetchUploadAttachment(fd)
const aIdx = detail.attachments.findIndex((f) => f.id === tempId)
if (aIdx < 0) return
detail.attachments[aIdx] = {
...detail.attachments[aIdx],
id: res.id || tempId,
@@ -3687,7 +3713,8 @@
}
} catch {
ElMessage.error('文件上传失败')
detail.attachments.splice(aIdx, 1)
const aIdx = detail.attachments.findIndex((f) => f.id === tempId)
if (aIdx >= 0) detail.attachments.splice(aIdx, 1)
}
}