This commit is contained in:
zlwu committed 2026-06-24 10:39:55 +08:00
1 parent 93c28759d0
commit b23a2eb350
129 files changed
+28511 -17769

No files matched your search

@@ -271,6 +271,7 @@
</div>
<SampleTransportFormSection
v-model:samples="formData.samples"
hide-dialog-collect-amount-unit
:sample-type-options="sampleTypeOptions"
:sample-type-options-loading="sampleTypeLoading"
:sample-code-options="sampleCodeOptions"
@@ -461,7 +462,7 @@
style="width: 100%"
/>
</el-form-item>
<el-form-item label="新生儿评分1分钟">
<el-form-item label="新生儿评分">
<el-input
v-model="formData.apgar1min"
type="number"
@@ -471,16 +472,6 @@
style="width: 100%"
/>
</el-form-item>
<el-form-item label="新生儿评分5分钟">
<el-input
v-model="formData.apgar5min"
type="number"
step="any"
:min="0"
:max="10"
style="width: 100%"
/>
</el-form-item>
</div>
</div>
</div>
@@ -571,13 +571,9 @@
><div class="data-value">{{ dash(partyCustomer?.newbornWeightGram) }}</div></div
>
<div class="data-item"
><div class="data-label">新生儿评分1分钟</div
><div class="data-label">新生儿评分</div
><div class="data-value">{{ dash(partyCustomer?.apgar1min) }}</div></div
>
<div class="data-item data-item--full"
><div class="data-label">新生儿评分5分钟</div
><div class="data-value">{{ dash(partyCustomer?.apgar5min) }}</div></div
>
</div>
</div>
</div>
@@ -676,8 +676,8 @@
const formData = reactive({
garmentCode: '',
garmentName: '',
washDiscardLimit: 10,
sterilizeDiscardLimit: 10,
washDiscardLimit: 100,
sterilizeDiscardLimit: 100,
inboundDate: '',
remark: ''
})
@@ -859,8 +859,8 @@
function resetForm() {
formData.garmentCode = ''
formData.garmentName = ''
formData.washDiscardLimit = 10
formData.sterilizeDiscardLimit = 10
formData.washDiscardLimit = 100
formData.sterilizeDiscardLimit = 100
formData.inboundDate = todayStr()
formData.remark = ''
editingId.value = null
@@ -0,0 +1,285 @@
<!-- 质检管理 — 预产及在途样本 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2>预产及在途样本</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="姓名/身份证号/电话"
clearable
/>
</el-form-item>
<el-form-item label="来源类型">
<el-select
v-model="searchForm.sourceType"
placeholder="全部"
clearable
style="width: 100%"
>
<el-option label="细胞存储" value="cell_storage" />
<el-option label="科研捐赠" value="research_donation" />
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="createTimeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="样本采集时间">
<el-date-picker
v-model="sampleCollectTimeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
clearable
style="width: 100%"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">列表为概要信息,详情见弹窗。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="pre-transit-section">
<div class="panel-top pre-transit-section-head">
<h2 class="title-bar-heading">在途样本</h2>
</div>
<PreTransitProtocolCardList
mode="in_transit"
:rows="inTransitData"
:loading="inTransitLoading"
:pagination="inTransitPagination"
empty-description="暂无在途样本"
@view="handleView"
@page-size-change="onInTransitPageSizeChange"
@page-change="onInTransitPageChange"
/>
</div>
<div class="pre-transit-section">
<div class="panel-top pre-transit-section-head">
<h2 class="title-bar-heading">预产样本</h2>
</div>
<PreTransitProtocolCardList
mode="pre_delivery"
:rows="preDeliveryData"
:loading="preDeliveryLoading"
:pagination="preDeliveryPagination"
empty-description="暂无预产样本"
@view="handleView"
@page-size-change="onPreDeliveryPageSizeChange"
@page-change="onPreDeliveryPageChange"
/>
</div>
</section>
<ProtocolViewDialog
v-model="protocolViewVisible"
:protocol-id="viewProtocolId"
:list-row="protocolViewRow"
/>
<DonationViewDialog
v-model="donationViewVisible"
:donation-id="viewDonationId"
:list-row="donationViewRow"
/>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { Search, RefreshLeft } from '@element-plus/icons-vue'
import PreTransitProtocolCardList from './PreTransitProtocolCardList.vue'
import ProtocolViewDialog from '@/views/cell-storage/protocol/ProtocolViewDialog.vue'
import DonationViewDialog from '@/views/research-donation/list/DonationViewDialog.vue'
import {
fetchPreTransitInTransitList,
fetchPreTransitPreDeliveryList,
type PreTransitProtocolRow
} from '@/api/pre-transit-sample'
import type { CollectionProtocolRow } from '@/api/collection-protocol'
import type { ResearchDonationRow } from '@/api/research-donation'
defineOptions({ name: 'QualityInspectionPreTransitSample' })
const searchForm = reactive({ keyword: '', sourceType: '' })
const createTimeRange = ref<[string, string] | null>(null)
const sampleCollectTimeRange = ref<[string, string] | null>(null)
const inTransitData = ref<PreTransitProtocolRow[]>([])
const preDeliveryData = ref<PreTransitProtocolRow[]>([])
const inTransitLoading = ref(false)
const preDeliveryLoading = ref(false)
const inTransitPagination = reactive({ page: 1, pageSize: 10, total: 0 })
const preDeliveryPagination = reactive({ page: 1, pageSize: 10, total: 0 })
const protocolViewVisible = ref(false)
const donationViewVisible = ref(false)
const viewProtocolId = ref<string | null>(null)
const viewDonationId = ref<string | null>(null)
const protocolViewRow = ref<CollectionProtocolRow | null>(null)
const donationViewRow = ref<ResearchDonationRow | null>(null)
function listParams(page: number, pageSize: number) {
return {
page,
pageSize,
keyword: searchForm.keyword || undefined,
sourceType: searchForm.sourceType || undefined,
createTimeStart: createTimeRange.value?.[0] || undefined,
createTimeEnd: createTimeRange.value?.[1] || undefined,
sampleCollectTimeStart: sampleCollectTimeRange.value?.[0] || undefined,
sampleCollectTimeEnd: sampleCollectTimeRange.value?.[1] || undefined
}
}
async function loadInTransit() {
inTransitLoading.value = true
try {
const result = await fetchPreTransitInTransitList(
listParams(inTransitPagination.page, inTransitPagination.pageSize)
)
const res = (result as Record<string, unknown>) || {}
inTransitData.value = (res.list as PreTransitProtocolRow[]) || []
inTransitPagination.total = Number(res.total) || 0
} finally {
inTransitLoading.value = false
}
}
async function loadPreDelivery() {
preDeliveryLoading.value = true
try {
const result = await fetchPreTransitPreDeliveryList(
listParams(preDeliveryPagination.page, preDeliveryPagination.pageSize)
)
const res = (result as Record<string, unknown>) || {}
preDeliveryData.value = (res.list as PreTransitProtocolRow[]) || []
preDeliveryPagination.total = Number(res.total) || 0
} finally {
preDeliveryLoading.value = false
}
}
async function loadAll() {
await Promise.all([loadInTransit(), loadPreDelivery()])
}
function handleSearch() {
inTransitPagination.page = 1
preDeliveryPagination.page = 1
loadAll()
}
function handleReset() {
Object.assign(searchForm, { keyword: '', sourceType: '' })
createTimeRange.value = null
sampleCollectTimeRange.value = null
handleSearch()
}
function onInTransitPageSizeChange(val: number) {
inTransitPagination.page = 1
inTransitPagination.pageSize = val
loadInTransit()
}
function onInTransitPageChange(val: number) {
inTransitPagination.page = val
loadInTransit()
}
function onPreDeliveryPageSizeChange(val: number) {
preDeliveryPagination.page = 1
preDeliveryPagination.pageSize = val
loadPreDelivery()
}
function onPreDeliveryPageChange(val: number) {
preDeliveryPagination.page = val
loadPreDelivery()
}
function handleView(row: PreTransitProtocolRow) {
const source = String(row.sourceType || 'cell_storage')
if (source === 'research_donation') {
const did = String(row.researchDonationId || '')
if (!did) {
ElMessage.warning('缺少关联捐赠协议单,无法查看')
return
}
viewDonationId.value = did
donationViewRow.value = {
id: did,
motherName: row.motherName,
newbornName: row.newbornName
} as ResearchDonationRow
donationViewVisible.value = true
return
}
const pid = String(row.collectionProtocolId || row.id || '')
if (!pid) {
ElMessage.warning('缺少关联协议单,无法查看')
return
}
viewProtocolId.value = pid
protocolViewRow.value = {
id: pid,
motherName: row.motherName,
newbornName: row.newbornName
} as CollectionProtocolRow
protocolViewVisible.value = true
}
watchDebounced(
[searchForm, createTimeRange, sampleCollectTimeRange],
() => {
inTransitPagination.page = 1
preDeliveryPagination.page = 1
loadAll()
},
{ debounce: 300, deep: true }
)
onMounted(() => {
loadAll()
})
</script>
<style scoped lang="scss">
.pre-transit-section-head {
margin-top: 0;
}
.pre-transit-section + .pre-transit-section {
margin-top: 24px;
padding-top: 8px;
}
</style>
@@ -145,94 +145,95 @@
class="protocol-form"
>
<div id="form-section-sample" class="form-tab-pane">
<div v-if="currentRow" class="section-card">
<div class="section-title">
<div class="section-title-left"><h3>样本信息</h3></div>
</div>
<div class="data-grid data-grid--4">
<div class="data-item">
<div class="data-label">协议状态</div>
<div class="data-value">
<el-tag
:type="
protocolStatusTagTypeBySource(
String(currentRow.protocolStatus || ''),
currentRow.sourceType || 'cell_storage'
)
"
size="small"
>
{{
protocolStatusLabelBySource(
String(currentRow.protocolStatus || ''),
currentRow.sourceType || 'cell_storage'
)
}}
</el-tag>
<div v-if="currentRow" class="section-card section-card--sample-transport">
<div class="sample-transport-row">
<div class="sample-transport-col">
<div class="section-title section-title--compact">
<div class="section-title-left"><h3>样本信息</h3></div>
</div>
<div class="data-grid data-grid--2">
<div class="data-item">
<div class="data-label">协议状态</div>
<div class="data-value">
<el-tag
:type="
protocolStatusTagTypeBySource(
String(currentRow.protocolStatus || ''),
currentRow.sourceType || 'cell_storage'
)
"
size="small"
>
{{
protocolStatusLabelBySource(
String(currentRow.protocolStatus || ''),
currentRow.sourceType || 'cell_storage'
)
}}
</el-tag>
</div>
</div>
<div class="data-item">
<div class="data-label">样本编码</div>
<div class="data-value">{{ currentRow.sampleCode || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">样本类型</div>
<div class="data-value">{{ currentRow.sampleTypeName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">预计到达</div>
<div class="data-value">{{ currentRow.etaTime || '-' }}</div>
</div>
<div class="data-item data-item--full">
<div class="data-label">客户</div>
<div class="data-value">
{{ currentRow.motherName || '-' }} / {{ currentRow.newbornName || '-' }}
</div>
</div>
</div>
</div>
<div class="data-item">
<div class="data-label">样本编码</div>
<div class="data-value">{{ currentRow.sampleCode || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">样本类型</div>
<div class="data-value">{{ currentRow.sampleTypeName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">预计到达</div>
<div class="data-value">{{ currentRow.etaTime || '-' }}</div>
</div>
<div class="data-item data-item--full">
<div class="data-label">客户</div>
<div class="data-value">
{{ currentRow.motherName || '-' }} / {{ currentRow.newbornName || '-' }}
<div id="form-section-transport" class="sample-transport-col">
<div class="section-title section-title--compact">
<div class="section-title-left"><h3>运输信息</h3></div>
</div>
<div class="data-grid data-grid--2">
<div class="data-item">
<div class="data-label">运输方式</div>
<div class="data-value">
{{ transportTypeLabel(String(currentRow.transportType || '')) }}
</div>
</div>
<div class="data-item">
<div class="data-label">预计到达</div>
<div class="data-value">{{ currentRow.etaTime || '-' }}</div>
</div>
<template v-if="currentRow.transportType === 'kdys'">
<div class="data-item">
<div class="data-label">快递公司</div>
<div class="data-value">{{ currentRow.expressCompanyName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">快递单号</div>
<div class="data-value">{{ currentRow.waybillNo || '-' }}</div>
</div>
</template>
<template v-else-if="currentRow.transportType === 'ryxd'">
<div class="data-item">
<div class="data-label">携带人</div>
<div class="data-value">{{ currentRow.carrierName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">携带人电话</div>
<div class="data-value">{{ currentRow.carrierPhone || '-' }}</div>
</div>
</template>
</div>
</div>
</div>
</div>
</div>
<div id="form-section-transport" class="form-tab-pane">
<div v-if="currentRow" class="section-card">
<div class="section-title">
<div class="section-title-left"><h3>运输信息</h3></div>
</div>
<div class="data-grid data-grid--4">
<div class="data-item">
<div class="data-label">运输方式</div>
<div class="data-value">
{{ transportTypeLabel(String(currentRow.transportType || '')) }}
</div>
</div>
<div class="data-item">
<div class="data-label">预计到达</div>
<div class="data-value">{{ currentRow.etaTime || '-' }}</div>
</div>
<template v-if="currentRow.transportType === 'kdys'">
<div class="data-item">
<div class="data-label">快递公司</div>
<div class="data-value">{{ currentRow.expressCompanyName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">快递单号</div>
<div class="data-value">{{ currentRow.waybillNo || '-' }}</div>
</div>
</template>
<template v-else-if="currentRow.transportType === 'ryxd'">
<div class="data-item">
<div class="data-label">携带人</div>
<div class="data-value">{{ currentRow.carrierName || '-' }}</div>
</div>
<div class="data-item">
<div class="data-label">携带人电话</div>
<div class="data-value">{{ currentRow.carrierPhone || '-' }}</div>
</div>
</template>
</div>
</div>
</div>
<div id="form-section-reception" class="form-tab-pane">
<div class="section-card">
<div class="section-title">
@@ -738,6 +739,9 @@
defineOptions({ name: 'QualityInspectionSampleReception' })
/** 经手人下拉:仅展示拥有该角色的用户 */
const SAMPLE_RECEPTION_HANDLER_ROLE = '采集接受人'
const userStore = useUserStore()
const STATUS_TABS = [
@@ -999,18 +1003,15 @@
return { userId, label }
}
function ensureCurrentUserInOptions() {
const { userId, label } = getCurrentUserHandler()
if (!userId) return
if (!userOptions.value.some((o) => o.value === userId)) {
userOptions.value = [{ label: label || userId, value: userId }, ...userOptions.value]
}
}
function applyDefaultHandler() {
const { userId, label } = getCurrentUserHandler()
receiveForm.handlerUserId = userId
receiveForm.handlerName = label
if (userId && userOptions.value.some((o) => o.value === userId)) {
receiveForm.handlerUserId = userId
receiveForm.handlerName = label
} else {
receiveForm.handlerUserId = ''
receiveForm.handlerName = ''
}
}
function onHandlerChange(userId: string) {
@@ -1173,6 +1174,7 @@
function createBatchEntry(row: Record<string, unknown>): BatchReceiveEntry {
const { userId, label } = getCurrentUserHandler()
const hasCurrentUser = userId && userOptions.value.some((o) => o.value === userId)
return {
protocolSampleId: String(row.protocolSampleId || ''),
protocolNo: String(row.protocolNo || ''),
@@ -1184,8 +1186,8 @@
sourceType: (row.sourceType as 'cell_storage' | 'research_donation') || 'cell_storage',
transportType: String(row.transportType || ''),
receptionTime: formatNowDatetime(),
handlerUserId: userId,
handlerName: label,
handlerUserId: hasCurrentUser ? userId : '',
handlerName: hasCurrentUser ? label : '',
receiveTemperature: '',
volumeMl: undefined,
netWeightG: undefined,
@@ -1235,8 +1237,6 @@
}
if (!userOptions.value.length) {
await loadUserOptions()
} else {
ensureCurrentUserInOptions()
}
await loadActiveCheckItems()
if (!activeCheckItems.value.length) {
@@ -1321,15 +1321,13 @@
async function loadUserOptions() {
try {
const list = await fetchUserOptions()
const list = await fetchUserOptions({ roleName: SAMPLE_RECEPTION_HANDLER_ROLE })
userOptions.value = (list || []).map((u) => ({
label: String(u.label || ''),
value: String(u.value || '')
}))
ensureCurrentUserInOptions()
} catch {
userOptions.value = []
ensureCurrentUserInOptions()
}
}
@@ -1414,8 +1412,6 @@
currentRow.value = row
if (!userOptions.value.length) {
await loadUserOptions()
} else {
ensureCurrentUserInOptions()
}
await loadActiveCheckItems()
resetReceiveForm()
@@ -1435,8 +1431,6 @@
currentRow.value = row
if (!userOptions.value.length) {
await loadUserOptions()
} else {
ensureCurrentUserInOptions()
}
await loadActiveCheckItems()
let detail: Record<string, unknown> = row
@@ -1581,6 +1575,26 @@
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
&--sample-transport {
padding: 16px 20px;
margin-bottom: 16px;
}
}
.sample-transport-row {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 0 20px;
}
.sample-transport-col {
min-width: 0;
& + & {
padding-left: 20px;
border-left: 1px solid #e2e8f0;
}
}
.section-title {
@@ -1590,6 +1604,11 @@
margin-bottom: 18px;
padding-bottom: 12px;
border-bottom: 1px solid #e2e8f0;
&--compact {
margin-bottom: 10px;
padding-bottom: 8px;
}
}
.section-title-left {
@@ -1620,6 +1639,17 @@
&--4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
&--2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px 12px;
}
}
.section-card--sample-transport {
.data-label {
margin-bottom: 2px;
}
}
.data-item {
@@ -32,13 +32,41 @@
scroll-to-error
class="protocol-form"
>
<!-- Tab 1: 基本信息 -->
<div id="form-section-basic" class="form-tab-pane">
<!-- Tab 1: 基本信息(新增时左侧一键导入、右侧基本信息) -->
<div
id="form-section-basic"
class="form-tab-pane"
:class="{ 'form-tab-pane--import-basic': !isEdit }"
>
<div v-if="!isEdit" class="section-card section-card--import">
<div class="section-title">
<div class="section-title-left"><h3>一键导入</h3></div>
</div>
<el-form-item label="标准信息">
<el-input
v-model="standardImportText"
type="textarea"
:rows="8"
placeholder="请粘贴标准格式信息,点击「一键导入」自动填充右侧空白字段"
/>
</el-form-item>
<div class="import-actions">
<el-button
class="btn-main"
type="primary"
:loading="standardImportLoading"
@click="handleStandardImport"
>
<el-icon><Upload /></el-icon>
一键导入
</el-button>
</div>
</div>
<div class="section-card">
<div class="section-title">
<div class="section-title-left"><h3>基本信息</h3></div>
</div>
<div class="form-grid form-grid--col4">
<div class="form-grid" :class="isEdit ? 'form-grid--col4' : 'form-grid--col2'">
<el-form-item label="捐赠状态" prop="donationStatus">
<el-select
v-model="formData.donationStatus"
@@ -219,6 +247,8 @@
<SampleTransportFormSection
v-model:samples="formData.samples"
hide-collect-detail-fields
auto-generate-sample-code
:reserve-sample-code="reserveDonationSampleCode"
:sample-type-options="sampleTypeOptions"
:sample-type-options-loading="sampleTypeLoading"
:sample-code-options="sampleCodeOptions"
@@ -433,7 +463,7 @@
"
/>
</el-form-item>
<el-form-item label="新生儿评分1分钟">
<el-form-item label="新生儿评分">
<el-input
v-model="formData.apgar1min"
type="number"
@@ -443,16 +473,6 @@
style="width: 100%"
/>
</el-form-item>
<el-form-item label="新生儿评分5分钟">
<el-input
v-model="formData.apgar5min"
type="number"
step="any"
:min="0"
:max="10"
style="width: 100%"
/>
</el-form-item>
</div>
</div>
</div>
@@ -659,17 +679,26 @@
Document,
VideoPlay,
Loading,
Download
Download,
Upload
} from '@element-plus/icons-vue'
import {
fetchResearchDonationDetail,
fetchCreateResearchDonation,
fetchUpdateResearchDonation
fetchUpdateResearchDonation,
fetchNextDonationSampleCode
} from '@/api/research-donation'
import { fetchUploadAttachment } from '@/api/business'
import { downloadAttachmentFile } from '@/utils/download-attachment'
import { handleChineseDatetimePaste } from '@/utils/chinese-datetime-parse'
import { extractNumericPart } from '@/utils/numeric-input-parse'
import {
parseDonationStandardImportText,
matchCellSampleType,
matchExpressCompany,
isBlankString,
isEmptyNumber
} from '@/utils/donation-standard-import-parse'
import {
fetchCustomerList,
fetchUserList,
@@ -678,6 +707,7 @@
fetchItemUnitList,
fetchCollectionRegionList,
fetchHospitalList,
fetchSearchCollectionHospitals,
fetchSampleCodeList,
fetchExpressCompanyList,
fetchSiteList
@@ -821,6 +851,8 @@
const editingId = ref<string | null>(null)
const formRef = ref()
const activeFormTab = ref('basic')
const standardImportText = ref('')
const standardImportLoading = ref(false)
type AttachmentFileItem = {
id?: string
@@ -936,6 +968,7 @@
siteOptions.value = []
expressCompanyOptions.value = []
activeFormTab.value = 'basic'
standardImportText.value = ''
}
function scrollToSection(key: string) {
@@ -961,6 +994,7 @@
expressCompanyId: transportRaw.expressCompanyId || '',
waybillNo: transportRaw.waybillNo || '',
destSiteId: transportRaw.destSiteId || '',
destSiteName: transportRaw.destSiteName || '',
expressFee: transportRaw.expressFee ?? null,
etaTime: transportRaw.etaTime || '',
carrierName: transportRaw.carrierName || '',
@@ -1136,6 +1170,12 @@
}
await Promise.all(hydrateTasks)
if (formData.samples.length) {
await Promise.all([
remoteSearchSampleTypes(''),
remoteSearchSites(''),
remoteSearchUnits(''),
remoteSearchSampleCodes('')
])
hydrateSampleLookupOptions()
}
} catch {
@@ -1145,11 +1185,47 @@
}
}
async function reserveDonationSampleCode() {
const pending = formData.samples
.map((s) => String(s.sampleCode || '').trim())
.filter(Boolean)
const res = await fetchNextDonationSampleCode({
pendingCodes: pending.length ? pending.join(',') : undefined
})
return res.sampleCode
}
async function assignDonationSampleCodeIfMissing(sample: Record<string, any>) {
if (String(sample.sampleCode || '').trim()) return
sample.sampleCode = await reserveDonationSampleCode()
sample.sampleCodeId = ''
}
async function ensureDonationSampleCodesBeforeSave() {
for (const sample of formData.samples) {
await assignDonationSampleCodeIfMissing(sample)
}
}
async function handleSubmit() {
if (!formRef.value) return
await formRef.value.validate()
try {
await ensureDonationSampleCodesBeforeSave()
} catch {
ElMessage.error('样本编码生成失败,请稍后重试')
return
}
if (!isEdit.value) {
const seenCodes = new Set<string>()
for (const sampleRow of formData.samples) {
const code = String(sampleRow.sampleCode || '').trim()
if (!code) continue
if (seenCodes.has(code)) {
ElMessage.warning(`样本编码「${code}」重复,请检查后重试`)
return
}
seenCodes.add(code)
if (!sampleRow.sampleCodeId) continue
const sc = sampleCodeOptions.value.find((x) => x.id === sampleRow.sampleCodeId)
if (sc?.usedInProtocol) {
@@ -1450,11 +1526,19 @@
const merged = [...siteOptions.value]
for (const s of samples) {
const id = String(s.transport?.destSiteId || '')
if (!id || merged.some((x) => x.id === id)) continue
if (!id) continue
const name = String(s.transport?.destSiteName || '').trim()
const existing = merged.find((x) => x.id === id)
if (existing) {
if (name && (!existing.siteName || existing.siteName === existing.id)) {
existing.siteName = name
}
continue
}
merged.push({
id,
siteCode: '',
siteName: id,
siteName: name || id,
siteType: '',
status: '',
address: '',
@@ -1770,6 +1854,303 @@
formData.hospitalId = val
}
function formatNowDatetime(): string {
const d = new Date()
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
function applyUserToCollector(u: Api.User.UserItem) {
collectorSnapshot.value = { ...u }
collectorUserId.value = u.id
formData.collectorUserId = u.id
if (!collectorUserOptions.value.some((x) => x.id === u.id)) {
collectorUserOptions.value = [u, ...collectorUserOptions.value]
}
}
function applyUserToSales(u: Api.User.UserItem) {
salesSnapshot.value = { ...u }
salesUserId.value = u.id
formData.salesUserId = u.id
if (!salesUserOptions.value.some((x) => x.id === u.id)) {
salesUserOptions.value = [u, ...salesUserOptions.value]
}
}
async function applySalesUserByName(name: string): Promise<boolean> {
const keyword = (name || '').trim()
if (!keyword) return false
try {
const res = await fetchUserList({
page: 1,
pageSize: 50,
keyword,
status: '1'
})
const list = res.list || []
const match =
list.find((u) => u.nickName === keyword) ||
list.find((u) => (u.nickName || '').includes(keyword))
if (!match) return false
applyUserToCollector(match)
applyUserToSales(match)
return true
} catch {
return false
}
}
async function applyMotherByName(name: string): Promise<'linked' | 'name-only' | 'skipped'> {
const keyword = (name || '').trim()
if (!keyword) return 'skipped'
if (!isBlankString(formData.customerId)) return 'skipped'
if (!isBlankString(formData.motherName)) return 'skipped'
try {
const res = await fetchCustomerList({ page: 1, pageSize: 50, keyword })
const list = res.list || []
const match =
list.find((c) => c.customerName === keyword) ||
list.find((c) => (c.customerName || '').includes(keyword))
if (match) {
customerOptions.value = [match, ...list.filter((c) => c.id !== match.id)]
onCustomerChange(match.id)
return 'linked'
}
formData.motherName = keyword
return 'name-only'
} catch {
formData.motherName = keyword
return 'name-only'
}
}
async function applyHospitalByName(name: string): Promise<boolean> {
const keyword = (name || '').trim()
if (!keyword || !isBlankString(formData.hospitalId)) return false
try {
const res = await fetchSearchCollectionHospitals({ keyword, limit: 20 })
const list = res.list || []
const match =
list.find((h) => h.hospitalName === keyword) ||
list.find((h) => (h.hospitalName || '').includes(keyword)) ||
list[0]
if (!match) return false
const regionStub: Api.BizCollectionRegion.RegionItem = {
id: match.regionId,
regionName: match.regionName || match.regionId,
hospitalNames: [],
tenantNo: match.tenantNo || '',
orderNum: 0,
remark: '',
createTime: '',
updateTime: ''
}
if (!regionOptions.value.some((r) => r.id === match.regionId)) {
regionOptions.value = [regionStub, ...regionOptions.value]
}
formData.regionId = match.regionId
await loadHospitalsByRegion(match.regionId, keyword)
if (!hospitalOptions.value.some((h) => h.id === match.id)) {
hospitalOptions.value = [match, ...hospitalOptions.value]
}
formData.hospitalId = match.id
return true
} catch {
return false
}
}
async function handleStandardImport() {
const parsed = parseDonationStandardImportText(standardImportText.value)
if (!parsed) {
ElMessage.warning('请粘贴有效的标准信息')
return
}
standardImportLoading.value = true
const warnings: string[] = []
const filledLabels: string[] = []
try {
await remoteSearchSampleTypes('')
const tasks: Promise<void>[] = []
if (parsed.motherName) {
tasks.push(
applyMotherByName(parsed.motherName).then((result) => {
if (result === 'linked') filledLabels.push('母亲信息(已关联客户)')
else if (result === 'name-only') filledLabels.push('母亲姓名')
})
)
}
if (parsed.hospitalName) {
tasks.push(
applyHospitalByName(parsed.hospitalName).then((ok) => {
if (ok) filledLabels.push('采集地区/采集医院')
else if (isBlankString(formData.hospitalId)) {
warnings.push(`未找到采集医院「${parsed.hospitalName}」`)
}
})
)
}
if (parsed.salesUserName) {
tasks.push(
applySalesUserByName(parsed.salesUserName).then((ok) => {
if (ok) filledLabels.push('采集专员/销售人员')
else warnings.push(`未找到销售人员「${parsed.salesUserName}」`)
})
)
}
const needsTransport = !!parsed.transportExpressName
if (needsTransport) {
tasks.push(
remoteSearchSites('').then(() => undefined),
remoteSearchExpressCompanies(
(parsed.transportExpressName || '').replace(/快递$/, '') || '顺丰'
).then(() => undefined)
)
}
await Promise.all(tasks)
if (parsed.newbornSex && isBlankString(formData.newbornSex)) {
formData.newbornSex = parsed.newbornSex
filledLabels.push('新生儿性别')
}
if (parsed.newbornWeightGram != null && isEmptyNumber(formData.newbornWeightGram)) {
formData.newbornWeightGram = parsed.newbornWeightGram
filledLabels.push('新生儿体重')
}
if (parsed.apgarScore != null && isEmptyNumber(formData.apgar1min)) {
formData.apgar1min = parsed.apgarScore
filledLabels.push('新生儿评分')
}
if (parsed.newbornDeliveryTime && isBlankString(formData.newbornDeliveryTime)) {
formData.newbornDeliveryTime = parsed.newbornDeliveryTime
filledLabels.push('新生儿分娩时间')
}
if (parsed.sampleCollectTime && isBlankString(formData.sampleCollectTime)) {
formData.sampleCollectTime = parsed.sampleCollectTime
filledLabels.push('样本采集时间')
}
if (parsed.maternalBloodExplicitEmpty && isBlankString(formData.maternalBloodCollectTime)) {
formData.maternalBloodCollectTime = ''
filledLabels.push('母血采集时间')
} else if (
parsed.maternalBloodCollectTime &&
isBlankString(formData.maternalBloodCollectTime)
) {
formData.maternalBloodCollectTime = parsed.maternalBloodCollectTime
filledLabels.push('母血采集时间')
}
if (parsed.deliveryMode && isBlankString(formData.deliveryMode)) {
formData.deliveryMode = parsed.deliveryMode
filledLabels.push('分娩方式')
}
if (parsed.birthOrder != null && isEmptyNumber(formData.birthOrder)) {
formData.birthOrder = parsed.birthOrder
filledLabels.push('胎次')
}
if (parsed.medicalStaff && isBlankString(formData.medicalStaff)) {
formData.medicalStaff = parsed.medicalStaff
filledLabels.push('采集医护')
}
const matchedType = matchCellSampleType(parsed.sampleTypeHeader, sampleTypeOptions.value)
const needsSampleRow = !!matchedType || needsTransport
if (needsSampleRow) {
if (!formData.samples.length) {
formData.samples = [normalizeSampleRow({ sampleTypeId: '', sampleStatus: 'ycj' })]
}
const sample = formData.samples[0]
if (matchedType && isBlankString(sample.sampleTypeId)) {
sample.sampleTypeId = matchedType.id
sample.storageYears = matchedType.storageYears ?? null
if (!sampleTypeOptions.value.some((x) => x.id === matchedType.id)) {
sampleTypeOptions.value = [matchedType, ...sampleTypeOptions.value]
}
filledLabels.push('样本类型')
} else if (parsed.sampleTypeHeader && !matchedType && isBlankString(sample.sampleTypeId)) {
warnings.push(`无法匹配样本类型「${parsed.sampleTypeHeader}」`)
}
if (needsTransport) {
const transport = { ...(sample.transport || createEmptyTransport()) }
let transportFilled = false
if (isBlankString(transport.transportType)) {
transport.transportType = 'kdys'
transportFilled = true
}
if (isBlankString(transport.destSiteId) && siteOptions.value.length) {
transport.destSiteId = siteOptions.value[0].id
transportFilled = true
}
if (isBlankString(transport.etaTime)) {
transport.etaTime = formatNowDatetime()
transportFilled = true
}
if (isBlankString(transport.expressCompanyId)) {
const ec = matchExpressCompany(
parsed.transportExpressName || '顺丰快递',
expressCompanyOptions.value
)
if (ec) {
transport.expressCompanyId = ec.id
if (!expressCompanyOptions.value.some((x) => x.id === ec.id)) {
expressCompanyOptions.value = [ec, ...expressCompanyOptions.value]
}
transportFilled = true
} else {
warnings.push(`未找到快递公司「${parsed.transportExpressName}」`)
}
}
sample.transport = transport
if (transportFilled) filledLabels.push('运输信息')
}
try {
await assignDonationSampleCodeIfMissing(sample)
if (String(sample.sampleCode || '').trim()) {
filledLabels.push('样本编码')
}
} catch {
warnings.push('样本编码自动生成失败')
}
hydrateSampleLookupOptions()
} else if (parsed.sampleTypeHeader) {
const sample = formData.samples[0]
const matched = matchCellSampleType(parsed.sampleTypeHeader, sampleTypeOptions.value)
if (!matched && (!sample || isBlankString(sample.sampleTypeId))) {
warnings.push(`无法匹配样本类型「${parsed.sampleTypeHeader}」`)
}
}
const uniqueFilled = [...new Set(filledLabels)]
if (uniqueFilled.length) {
ElMessage.success(`已填充:${uniqueFilled.join('、')}`)
} else if (!warnings.length) {
ElMessage.info('没有可填充的空白字段')
}
if (warnings.length) {
ElMessage.warning(warnings.join(';'))
}
} catch {
ElMessage.error('导入失败,请检查标准信息格式')
} finally {
standardImportLoading.value = false
}
}
/* ====== 母亲身份证号 ↔ 出生年月联动 ====== */
function calcBirthFromIdCard() {
const idCard = (formData.motherIdCard || '').trim()
@@ -1950,6 +2331,29 @@
width: 100%;
}
.section-card--import {
margin-bottom: 0;
}
.import-actions {
display: flex;
justify-content: flex-end;
padding: 0 0 8px;
}
.form-tab-pane--import-basic {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 16px;
align-items: stretch;
margin-bottom: 28px;
.section-card {
margin-bottom: 0;
height: 100%;
}
}
/* ═══════════════════════════════════════════
SECTION CARDS
═══════════════════════════════════════════ */
@@ -2302,6 +2706,10 @@
RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 900px) {
.form-tab-pane--import-basic {
grid-template-columns: 1fr;
}
.form-grid {
grid-template-columns: repeat(2, 1fr);
@@ -499,13 +499,9 @@
><div class="data-value">{{ dash(party?.newbornWeightGram) }}</div></div
>
<div class="data-item"
><div class="data-label">新生儿评分1分钟</div
><div class="data-label">新生儿评分</div
><div class="data-value">{{ dash(party?.apgar1min) }}</div></div
>
<div class="data-item data-item--full"
><div class="data-label">新生儿评分5分钟</div
><div class="data-value">{{ dash(party?.apgar5min) }}</div></div
>
</div>
</div>
</div>
+37 -1
View File
@@ -253,6 +253,23 @@
<el-form-item label="用户名" prop="nickName">
<el-input v-model="formData.nickName" placeholder="显示名称" />
</el-form-item>
<el-form-item label="所属组织" prop="deptId">
<el-tree-select
v-model="formData.deptId"
:data="deptTreeSelectData"
node-key="value"
:props="{ label: 'label', children: 'children' }"
check-strictly
filterable
clearable
placeholder="请选择所属组织"
class="w-full"
>
<template #label="{ value }">
{{ formatDeptPathLabel(value) }}
</template>
</el-tree-select>
</el-form-item>
<el-form-item v-if="!isEdit" label="密码" prop="password">
<el-input
v-model="formData.password"
@@ -378,6 +395,24 @@
})
)
type DeptTreeSelectNode = { value: string; label: string; children?: DeptTreeSelectNode[] }
function buildDeptTreeSelectData(nodes: Api.Dept.DeptItem[]): DeptTreeSelectNode[] {
return (nodes || []).map((n) => ({
value: n.id,
label: n.deptName || '',
children: n.children?.length ? buildDeptTreeSelectData(n.children) : undefined
}))
}
const deptTreeSelectData = computed(() => buildDeptTreeSelectData(deptTree.value))
function formatDeptPathLabel(nodeId: string | null | undefined) {
const id = String(nodeId ?? '').trim()
if (!id) return ''
return deptPathLabelMap.value.get(id) || ''
}
function formatUserDeptDisplay(row: Api.User.UserItem) {
const id = (row.deptId || '').trim()
if (!id) return '—'
@@ -424,7 +459,8 @@
const formRules = {
userNo: [{ required: true, message: '请输入用户账号', trigger: 'blur' }],
nickName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
deptId: [{ required: true, message: '请选择所属组织', trigger: 'change' }]
}
function filterDeptNode(value: string, data: Api.Dept.DeptItem) {