Files
zkxw/web-admin/src/views/quality-inspection/sample-reception/index.vue
T
zlwuandCursor 71051461a2 fix(web-admin): 样本接收「是否接收」选项拒收改为废弃
质检样本接收登记弹窗与结论标签文案对齐工单 #27,取值 bj 不变。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-05 11:08:18 +08:00

1909 lines
66 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 质量检测 — 样本接收 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<div class="page-container">
<section class="panel">
<div v-if="!receivedOnly" class="panel-pill-tabs panel-pill-tabs--lg">
<div class="panel-pill-tabs__track" role="tablist">
<button
v-for="tab in STATUS_TABS"
:key="tab.name"
type="button"
role="tab"
class="panel-pill-tabs__btn"
:class="{ 'is-active': activeTab === tab.name }"
:aria-selected="activeTab === tab.name"
@click="handleTabChange(tab.name)"
>
{{ tab.label }}
</button>
</div>
</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>
<el-option label="细胞存储" value="cell_storage" />
<el-option label="科研捐赠" value="research_donation" />
</el-select>
</el-form-item>
<el-form-item v-if="activeTab === 'pending'" label="预计到达时间">
<el-date-picker
v-model="etaDateRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
<el-form-item v-else label="接收时间">
<el-date-picker
v-model="receptionTimeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<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 v-if="activeTab === 'pending'" class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedPendingRows.length }}</span> 项
</div>
<el-button
class="btn-ghost"
:disabled="selectedPendingRows.length === 0"
@click="openBatchReceive"
>
<el-icon><Files /></el-icon>批量接收
</el-button>
</div>
</div>
<SampleReceptionCardList
:rows="tableData"
:loading="loading"
:active-tab="activeTab"
:page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:selected-ids="selectedPendingIds"
:can-edit-received="canEditReceivedReception"
@receive="openReceive"
@view="openView"
@edit="openEdit"
@toggle-select="handleCardToggleSelect"
@card-dblclick="handleRowDblClick"
@page-change="(val) => ((pagination.page = val), loadData())"
@page-size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
/>
<el-dialog
v-model="receiveDialogVisible"
:title="receiveDialogTitle"
width="1600px"
class="dialog-form-layout sample-reception-dialog"
align-center
append-to-body
modal-class="protocol-dialog-mask"
destroy-on-close
:close-on-click-modal="false"
@closed="handleReceiveDialogClosed"
>
<DialogFormBody body-class="protocol-dialog-body min-h-[200px]">
<div class="detail-tabs">
<div
v-for="tab in receiveFormTabs"
:key="tab.key"
class="detail-tab"
:class="{ active: activeReceiveFormTab === tab.key }"
@click="scrollReceiveToSection(tab.key)"
>
{{ tab.label }}
</div>
</div>
<el-form
ref="receiveFormRef"
:model="receiveForm"
:rules="receiveRules"
label-position="top"
scroll-to-error
class="protocol-form"
>
<div id="form-section-sample" class="form-tab-pane">
<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',
String(currentRow.voidType || '')
)
}}
</el-tag>
</div>
</div>
<div class="data-item">
<div class="data-label">样本编码</div>
<div class="data-value">
<SampleCodeWithSpecialDisplay
:sample-code="currentRow.sampleCode"
:is-special="!!currentRow.isSpecial"
:special-remark="currentRow.specialRemark"
fallback="-"
monospace
/>
</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">{{ formatDisplayOrDash(currentRow.etaTime) }}</div>
</div>
<div class="data-item">
<div class="data-label">样本采集时间</div>
<div class="data-value">{{ formatDisplayOrDash(currentRow.sampleCollectTime) }}</div>
</div>
<div class="data-item">
<div class="data-label">母血采集时间</div>
<div class="data-value">{{ formatDisplayOrDash(currentRow.maternalBloodCollectTime) }}</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 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">{{ formatDisplayOrDash(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-reception" class="form-tab-pane">
<div class="section-card">
<div class="section-title">
<div class="section-title-left"><h3>接收登记</h3></div>
</div>
<div class="form-grid form-grid--col4">
<el-form-item label="样本接收时间" prop="receptionTime">
<el-date-picker
v-model="receiveForm.receptionTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择接收时间"
style="width: 100%"
@change="onReceiveReceptionTimeChange"
/>
</el-form-item>
<el-form-item label="经手人" prop="handlerUserId">
<el-select
v-model="receiveForm.handlerUserId"
filterable
placeholder="选择经手人"
style="width: 100%"
@change="onHandlerChange"
>
<el-option
v-for="u in userOptions"
:key="String(u.value)"
:label="String(u.label)"
:value="String(u.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="接收温度(℃)">
<el-input
v-model="receiveForm.receiveTemperature"
placeholder="如 4"
clearable
/>
</el-form-item>
<el-form-item label="是否接收" prop="acceptConclusion">
<el-radio-group
v-model="receiveForm.acceptConclusion"
@change="onReceiveAcceptConclusionChange"
>
<el-radio value="js">接收</el-radio>
<el-radio value="bj">废弃</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="实验室入库编码" prop="labStorageCode">
<el-input
v-model="receiveForm.labStorageCode"
placeholder="请填写"
clearable
@input="onLabStorageCodeManualInput"
/>
</el-form-item>
<el-form-item label="检查项确认" class="form-col-span-2">
<div v-if="activeCheckItems.length" class="check-list">
<el-checkbox
v-for="item in activeCheckItems"
:key="item.id"
v-model="checkValues[item.id]"
>
{{ item.itemName }}
</el-checkbox>
</div>
<p v-else class="check-empty-hint">
暂无启用的检查项,请先在「接收检查项配置」中维护。
</p>
</el-form-item>
</div>
<div class="form-grid form-grid--attachment">
<ProtocolFinanceConfirmFields
v-model:finance-remark="receiveForm.remark"
v-model:attachments="attachments"
remark-label="备注信息"
attachment-label="接收附件"
upload-folder="sample-reception"
/>
</div>
</div>
</div>
<div
v-if="receiveDialogMode === 'edit' && editProductionReception !== undefined"
class="form-tab-pane"
>
<div class="section-card">
<div class="section-title">
<div class="section-title-left"><h3>生产接收信息</h3></div>
</div>
<SampleReceptionDualReadonlyPanel
:qc-reception="null"
:production-reception="editProductionReception"
:source-type="String(currentRow?.sourceType || 'cell_storage')"
:sample-type-name="String(currentRow?.sampleTypeName || '')"
:show-qc="false"
production-title=""
:production-grid-cols="4"
/>
</div>
</div>
</el-form>
</DialogFormBody>
<template #footer>
<el-button class="btn-ghost" @click="receiveDialogVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="submitLoading"
@click="submitReceive"
>
<el-icon><Check /></el-icon>{{ receiveDialogMode === 'edit' ? '保存' : '提交' }}
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="viewDialogVisible"
title="接收详情"
width="1200px"
class="dialog-form-layout sample-reception-dialog sample-reception-view-dialog"
align-center
append-to-body
modal-class="protocol-dialog-mask"
destroy-on-close
>
<template v-if="viewRow">
<h4 class="detail-section-title">样本信息</h4>
<div class="readonly-grid form-grid-4">
<div class="readonly-item"
><span class="label">协议状态</span
><el-tag
:type="
protocolStatusTagTypeBySource(
String(viewRow.protocolStatus || ''),
viewRow.sourceType || 'cell_storage'
)
"
size="small"
>{{
protocolStatusLabelBySource(
String(viewRow.protocolStatus || ''),
viewRow.sourceType || 'cell_storage',
String(viewRow.voidType || '')
)
}}</el-tag
></div
>
<div class="readonly-item"
><span class="label">样本编码</span
><SampleCodeWithSpecialDisplay
:sample-code="viewRow.sampleCode"
:is-special="!!viewRow.isSpecial"
:special-remark="viewRow.specialRemark"
fallback="-"
monospace
/></div
>
<div class="readonly-item"
><span class="label">样本类型</span>{{ viewRow.sampleTypeName || '-' }}</div
>
<div class="readonly-item"
><span class="label">预计到达</span>{{ formatDisplayOrDash(viewRow.etaTime) }}</div
>
<div class="readonly-item"
><span class="label">样本采集时间</span>{{ formatDisplayOrDash(viewRow.sampleCollectTime) }}</div
>
<div class="readonly-item"
><span class="label">母血采集时间</span>{{ formatDisplayOrDash(viewRow.maternalBloodCollectTime) }}</div
>
</div>
<div class="form-section-divider" />
<h4 class="detail-section-title">运输信息</h4>
<div class="readonly-grid form-grid-4">
<div class="readonly-item">
<span class="label">运输方式</span
>{{ transportTypeLabel(String(viewRow.transportType || '')) }}
</div>
<div class="readonly-item"
><span class="label">预计到达</span>{{ formatDisplayOrDash(viewRow.etaTime) }}</div
>
<template v-if="viewRow.transportType === 'kdys'">
<div class="readonly-item"
><span class="label">快递公司</span>{{ viewRow.expressCompanyName || '-' }}</div
>
<div class="readonly-item"
><span class="label">快递单号</span>{{ viewRow.waybillNo || '-' }}</div
>
</template>
<template v-else-if="viewRow.transportType === 'ryxd'">
<div class="readonly-item"
><span class="label">携带人</span>{{ viewRow.carrierName || '-' }}</div
>
<div class="readonly-item"
><span class="label">携带人电话</span>{{ viewRow.carrierPhone || '-' }}</div
>
</template>
</div>
<div class="form-section-divider" />
<h4 class="detail-section-title">接收信息</h4>
<div class="readonly-grid form-grid-4">
<div class="readonly-item"
><span class="label">接收时间</span>{{ formatDisplayOrDash(viewRow.receptionTime) }}</div
>
<div class="readonly-item"
><span class="label">经手人</span>{{ viewRow.handlerName || '-' }}</div
>
<div class="readonly-item"
><span class="label">接收温度(℃)</span
>{{ viewRow.receiveTemperature ? viewRow.receiveTemperature + '℃' : '-' }}</div
>
<div class="readonly-item">
<span class="label">实验室入库编码</span>{{ viewRow.labStorageCode || '-' }}
</div>
<div class="readonly-item">
<span class="label">结论</span
><el-tag
:type="viewRow.acceptConclusion === 'js' ? 'success' : 'danger'"
size="small"
>{{ acceptConclusionLabel(String(viewRow.acceptConclusion || '')) }}</el-tag
>
</div>
<div class="readonly-item form-col-span-2 check-items-readonly">
<span class="label">检查项</span>
<div v-if="viewCheckResults.length" class="check-list check-list-view">
<el-checkbox
v-for="item in viewCheckResults"
:key="item.itemCode + String(item.checkItemId)"
:model-value="item.checked"
disabled
>
{{ item.itemName }}
</el-checkbox>
</div>
<span v-else>—</span>
</div>
<div class="readonly-item form-col-span-2">
<span class="label">备注</span>{{ viewRow.remark || '—' }}
</div>
<div class="readonly-item form-col-span-2">
<span class="label">接收附件</span>
<ProtocolAttachmentReadonly
:files="viewAttachmentFiles"
@preview="handleAttachmentPreview"
@download="handleAttachmentDownload"
/>
</div>
</div>
<div class="form-section-divider" />
<h4 class="detail-section-title">生产接收信息</h4>
<div v-if="!viewProductionReception" class="production-view-empty">生产尚未登记</div>
<div v-else class="readonly-grid form-grid-4">
<div class="readonly-item">
<span class="label">处理时间</span
>{{ formatProcessTimeDate(viewProductionReception.processTime) || '—' }}
</div>
<div class="readonly-item">
<span class="label">处理人</span>{{ viewProductionReception.handlerName || '—' }}
</div>
<div
v-for="field in viewProductionFieldDefs"
:key="field.key"
class="readonly-item"
>
<span class="label">{{ field.label }}</span
>{{ formatProductionFieldValue(field, viewProductionReception) }}
</div>
<div class="readonly-item form-col-span-2">
<span class="label">备注</span>{{ viewProductionReception.remark || '—' }}
</div>
</div>
</template>
<template #footer>
<el-button class="btn-ghost" @click="viewDialogVisible = false">
<el-icon><Close /></el-icon>关闭
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="batchReceiveDialogVisible"
title="批量样本接收"
width="960px"
class="dialog-form-layout sample-reception-dialog batch-receive-dialog"
align-center
append-to-body
modal-class="protocol-dialog-mask"
destroy-on-close
:close-on-click-modal="false"
>
<p class="batch-receive-tip">同快递样本可一次登记;以下每项需单独填写接收信息。</p>
<el-scrollbar max-height="calc(100vh - 220px)">
<div
v-for="(entry, index) in batchEntries"
:key="entry.protocolSampleId"
class="batch-receive-card"
>
<h4 class="detail-section-title batch-receive-card__title">
样本 {{ index + 1 }}:
<SampleCodeWithSpecialDisplay
:sample-code="entry.sampleCode"
:is-special="!!entry.isSpecial"
:special-remark="entry.specialRemark"
monospace
/>
</h4>
<div class="readonly-grid form-grid-4 batch-receive-card__meta">
<div class="readonly-item"
><span class="label">协议状态</span
><el-tag
:type="
protocolStatusTagTypeBySource(
String(entry.protocolStatus || ''),
entry.sourceType || 'cell_storage'
)
"
size="small"
>{{
protocolStatusLabelBySource(
String(entry.protocolStatus || ''),
entry.sourceType || 'cell_storage',
String(entry.voidType || '')
)
}}</el-tag
></div
>
<div class="readonly-item"
><span class="label">样本类型</span>{{ entry.sampleTypeName || '—' }}</div
>
<div class="readonly-item form-col-span-2">
<span class="label">客户</span>{{ entry.motherName || '—' }} /
{{ entry.newbornName || '—' }}
</div>
<div class="readonly-item"
><span class="label">样本采集时间</span>{{ formatDisplayOrDash(entry.sampleCollectTime) }}</div
>
<div class="readonly-item"
><span class="label">母血采集时间</span>{{ formatDisplayOrDash(entry.maternalBloodCollectTime) }}</div
>
<div class="readonly-item">
<span class="label">来源</span>
<el-tag
:type="entry.sourceType === 'research_donation' ? 'warning' : 'success'"
size="small"
>
{{ entry.sourceType === 'research_donation' ? '科研捐赠' : '细胞存储' }}
</el-tag>
</div>
<div class="readonly-item"
><span class="label">运输方式</span
>{{
entry.transportType === 'kdys'
? '快递运输'
: entry.transportType === 'ryxd'
? '人员携带'
: '-'
}}</div
>
</div>
<el-form label-position="top" class="biz-dialog-form">
<div class="form-grid-3">
<el-form-item label="样本接收时间" required>
<el-date-picker
v-model="entry.receptionTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择接收时间"
style="width: 100%"
@change="() => onBatchReceptionTimeChange(entry)"
/>
</el-form-item>
<el-form-item label="经手人" required>
<el-select
v-model="entry.handlerUserId"
filterable
placeholder="选择经手人"
style="width: 100%"
@change="(uid: string) => onBatchHandlerChange(entry, uid)"
>
<el-option
v-for="u in userOptions"
:key="String(u.value)"
:label="String(u.label)"
:value="String(u.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="接收温度(℃)">
<el-input v-model="entry.receiveTemperature" placeholder="如 4" clearable />
</el-form-item>
<el-form-item label="是否接收" required>
<el-radio-group
v-model="entry.acceptConclusion"
@change="() => onBatchAcceptConclusionChange(entry)"
>
<el-radio value="js">接收</el-radio>
<el-radio value="bj">废弃</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label="实验室入库编码"
:required="entry.acceptConclusion === 'js'"
>
<el-input
v-model="entry.labStorageCode"
placeholder="请填写"
clearable
@input="() => onBatchLabStorageCodeManualInput(entry)"
/>
</el-form-item>
</div>
<el-form-item label="检查项确认" class="form-col-span-2">
<div v-if="activeCheckItems.length" class="check-list">
<el-checkbox
v-for="item in activeCheckItems"
:key="`${entry.protocolSampleId}_${item.id}`"
v-model="entry.checkValues[item.id]"
>
{{ item.itemName }}
</el-checkbox>
</div>
<p v-else class="check-empty-hint"
>暂无启用的检查项,请先在「接收检查项配置」中维护。</p
>
</el-form-item>
<ProtocolFinanceConfirmFields
v-model:finance-remark="entry.remark"
v-model:attachments="entry.attachments"
remark-label="备注信息"
attachment-label="接收附件"
upload-folder="sample-reception"
/>
</el-form>
</div>
</el-scrollbar>
<template #footer>
<el-button class="btn-ghost" @click="batchReceiveDialogVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="submitLoading"
@click="submitBatchReceive"
>
<el-icon><Check /></el-icon>提交全部
</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { formatDisplayOrDash } from '@/utils/datetime-display'
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Close, Check, Search, RefreshLeft, Files } from '@element-plus/icons-vue'
import { fetchUserOptions } from '@/api/admin'
import {
fetchSampleReceptionPendingList,
fetchSampleReceptionReceivedList,
fetchSampleReceptionSubmit,
fetchSampleReceptionUpdate,
fetchSampleReceptionDetail,
type SampleReceptionCheckResult
} from '@/api/sample-reception'
import {
fetchSampleReceptionCheckItemsActive,
type SampleReceptionCheckItem
} from '@/api/sample-reception-check-item'
import DialogFormBody from '@/components/business/dialog-form-body/index.vue'
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
import SampleReceptionCardList from './SampleReceptionCardList.vue'
import SampleReceptionDualReadonlyPanel from '@/components/business/sample-reception-dual-readonly-panel/index.vue'
import {
financeAttachmentsToUrlString,
type FinanceAttachmentItem
} from '@/components/business/protocol-finance-confirm-fields/finance-attachments'
import { useUserStore } from '@/store/modules/user'
import { downloadAttachmentFile } from '@/utils/download-attachment'
import {
transportTypeLabel,
acceptConclusionLabel,
protocolStatusLabel,
protocolStatusDisplayLabel,
protocolStatusTagType,
donationStatusLabel,
donationStatusDisplayLabel,
donationStatusTagType
} from '@/utils/status-tag-registry'
import type { TagType } from '@/utils/status-tag-registry'
import {
buildPrefilledLabStorageCode,
parseLabStorageReferenceDate
} from '@/utils/sample-reception-lab-storage-code'
import type { ProductionReceptionRecord } from '@/utils/sample-production-reception-fields'
import {
formatProductionFieldValue,
formatProcessTimeDate,
resolveProductionReceptionFields
} from '@/utils/sample-production-reception-fields'
/** 根据来源类型返回协议状态标签 */
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
return source === 'research_donation'
? donationStatusDisplayLabel(status, voidType)
: protocolStatusDisplayLabel(status, voidType)
}
function protocolStatusTagTypeBySource(status: string, source: string): TagType {
return source === 'research_donation'
? donationStatusTagType(status)
: protocolStatusTagType(status)
}
const props = withDefaults(
defineProps<{
/** 生产管理「样本接收信息完善」:仅展示已接收 Tab 内容 */
receivedOnly?: boolean
}>(),
{
receivedOnly: false
}
)
defineOptions({ name: 'QualityInspectionSampleReception' })
/** 经手人下拉:仅展示拥有该角色的用户 */
const SAMPLE_RECEPTION_HANDLER_ROLE = '采集接受人'
/** 已接收记录编辑:除经手人外,拥有该角色的用户也可编辑 */
const SAMPLE_RECEPTION_EDIT_ROLE = '质量主管'
const userStore = useUserStore()
function getCurrentUserId() {
const info = userStore.getUserInfo
return String(info?.id || info?.userId || '').trim()
}
function hasQualitySupervisorRole() {
const roleNames = userStore.getUserInfo?.roleNames
return Array.isArray(roleNames) && roleNames.includes(SAMPLE_RECEPTION_EDIT_ROLE)
}
function canEditReceivedReception(row: Record<string, unknown>) {
const currentUserId = getCurrentUserId()
if (!currentUserId) return false
if (hasQualitySupervisorRole()) return true
const handlerUserId = String(row.handlerUserId || '').trim()
return Boolean(handlerUserId) && handlerUserId === currentUserId
}
const STATUS_TABS = [
{ name: 'pending', label: '待接收' },
{ name: 'received', label: '已接收' }
] as const
const activeTab = ref(props.receivedOnly ? 'received' : 'pending')
const searchForm = reactive({ keyword: '', sourceType: '' })
const etaDateRange = ref<[string, string] | null>(null)
const receptionTimeRange = ref<[string, string] | null>(null)
const tableData = ref<Record<string, unknown>[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const receiveDialogVisible = ref(false)
const receiveDialogMode = ref<'create' | 'edit'>('create')
const editingReceptionId = ref('')
const viewDialogVisible = ref(false)
const submitLoading = ref(false)
const currentRow = ref<Record<string, unknown> | null>(null)
const viewRow = ref<Record<string, unknown> | null>(null)
const viewProductionReception = ref<ProductionReceptionRecord | null>(null)
const viewProductionFieldDefs = computed(() =>
resolveProductionReceptionFields(
String(viewRow.value?.sourceType || 'cell_storage'),
String(viewRow.value?.sampleTypeName || '')
)
)
const editProductionReception = ref<ProductionReceptionRecord | null | undefined>(undefined)
const receiveFormRef = ref()
const userOptions = ref<Array<{ label: string; value: string }>>([])
const attachments = ref<FinanceAttachmentItem[]>([])
const activeCheckItems = ref<SampleReceptionCheckItem[]>([])
const checkValues = reactive<Record<string, boolean>>({})
const selectedPendingRows = ref<Record<string, unknown>[]>([])
const selectedPendingIds = computed(() =>
selectedPendingRows.value.map((r) => String(r.protocolSampleId || ''))
)
const batchReceiveDialogVisible = ref(false)
type BatchReceiveEntry = {
protocolSampleId: string
protocolNo: string
sampleCode: string
isSpecial?: boolean
specialRemark?: string
sampleTypeName: string
waybillNo: string
motherName: string
newbornName: string
sampleCollectTime: string
maternalBloodCollectTime: string
sourceType: 'cell_storage' | 'research_donation'
transportType: string
receptionTime: string
handlerUserId: string
handlerName: string
receiveTemperature: string
acceptConclusion: 'js' | 'bj'
remark: string
labStorageCode: string
labStorageCodeManuallyEdited: boolean
lastAllocatedReceptionDate: string
checkValues: Record<string, boolean>
attachments: FinanceAttachmentItem[]
}
const batchEntries = ref<BatchReceiveEntry[]>([])
const receiveForm = reactive({
receptionTime: '',
handlerUserId: '',
handlerName: '',
receiveTemperature: '',
acceptConclusion: 'js' as 'js' | 'bj',
labStorageCode: '',
remark: ''
})
const labStorageCodeManuallyEdited = ref(false)
const lastAllocatedReceptionDate = ref('')
const receiveRules = {
receptionTime: [{ required: true, message: '请选择样本接收时间', trigger: 'change' }],
handlerUserId: [{ required: true, message: '请选择经手人', trigger: 'change' }],
acceptConclusion: [{ required: true, message: '请选择是否接收', trigger: 'change' }],
labStorageCode: [
{
validator: (_rule: unknown, value: string, callback: (err?: Error) => void) => {
if (receiveForm.acceptConclusion !== 'js') {
callback()
return
}
if (!String(value || '').trim()) {
callback(new Error('请填写或生成实验室入库编码'))
return
}
callback()
},
trigger: 'blur'
}
]
}
const receiveDialogTitle = computed(() =>
receiveDialogMode.value === 'edit' ? '编辑样本接收' : '样本接收'
)
const receiveFormTabs = [
{ key: 'sample', label: '样本信息' },
{ key: 'transport', label: '运输信息' },
{ key: 'reception', label: '接收登记' }
] as const
const activeReceiveFormTab = ref('sample')
function scrollReceiveToSection(key: string) {
activeReceiveFormTab.value = key
const el = document.getElementById(`form-section-${key}`)
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
}
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
const viewCheckResults = computed((): SampleReceptionCheckResult[] => {
const row = viewRow.value
if (!row) return []
const list = row.checkResults
if (!Array.isArray(list)) return []
return list as SampleReceptionCheckResult[]
})
const viewAttachmentFiles = computed(() => {
const row = viewRow.value
if (!row) return []
if (Array.isArray(row.receiveAttachmentFiles)) {
return row.receiveAttachmentFiles as Array<Record<string, unknown>>
}
const urls = String(row.receiveAttachments || '')
if (!urls.trim()) return []
return urls
.split(',')
.map((u, i) => {
const url = u.trim()
if (!url) return null
const name = url.includes('/') ? url.split('/').pop() || `附件${i + 1}` : url
return { id: `url_${i}`, fileUrl: url, fileName: name }
})
.filter(Boolean) as Array<Record<string, unknown>>
})
function formatMetric(v: unknown) {
if (v === null || v === undefined || v === '') return '-'
const n = Number(v)
return Number.isFinite(n) ? String(n) : '-'
}
function apiFilesToFinanceItems(
files?: Array<{ id?: string; fileUrl?: string; fileName?: string; fileType?: string }>
): FinanceAttachmentItem[] {
if (!files?.length) return []
return files.map((f, i) => ({
id: String(f.id || `att_${i}`),
fileName: String(f.fileName || ''),
fileUrl: String(f.fileUrl || ''),
fileType: String(f.fileType || '')
}))
}
function applyCheckResultsFromDetail(results: SampleReceptionCheckResult[]) {
const map = new Map((results || []).map((r) => [String(r.checkItemId || ''), !!r.checked]))
for (const item of activeCheckItems.value) {
checkValues[item.id] = map.has(item.id) ? !!map.get(item.id) : false
}
}
function populateReceiveFormFromDetail(detail: Record<string, unknown>) {
receiveForm.receptionTime = String(detail.receptionTime || '')
receiveForm.handlerUserId = String(detail.handlerUserId || '')
receiveForm.handlerName = String(detail.handlerName || '')
receiveForm.receiveTemperature = String(detail.receiveTemperature || '')
receiveForm.acceptConclusion = String(detail.acceptConclusion || 'js') === 'bj' ? 'bj' : 'js'
receiveForm.labStorageCode = String(detail.labStorageCode || '')
receiveForm.remark = String(detail.remark || '')
labStorageCodeManuallyEdited.value = !!receiveForm.labStorageCode
lastAllocatedReceptionDate.value = extractReceptionDate(receiveForm.receptionTime)
const checkList = detail.checkResults
applyCheckResultsFromDetail(
Array.isArray(checkList) ? (checkList as SampleReceptionCheckResult[]) : []
)
if (Array.isArray(detail.receiveAttachmentFiles)) {
attachments.value = apiFilesToFinanceItems(
detail.receiveAttachmentFiles as Array<{
id?: string
fileUrl?: string
fileName?: string
fileType?: string
}>
)
} else {
const urls = String(detail.receiveAttachments || '')
.split(',')
.map((u) => u.trim())
.filter(Boolean)
attachments.value = urls.map((url, i) => {
const name = url.includes('/') ? url.split('/').pop() || `附件${i + 1}` : url
return { id: `url_${i}`, fileUrl: url, fileName: name }
})
}
}
function resetReceiveDialogState() {
receiveDialogMode.value = 'create'
editingReceptionId.value = ''
currentRow.value = null
activeReceiveFormTab.value = 'sample'
}
function handleReceiveDialogClosed() {
resetReceiveDialogState()
}
function toOptionalMetric(v: number | undefined) {
if (v === null || v === undefined) return undefined
const n = Number(v)
return Number.isFinite(n) ? n : undefined
}
function fullFileUrl(url: string) {
if (!url) return ''
if (/^https?:\/\//i.test(url)) return url
return minioBaseUrl ? `${minioBaseUrl}/${url.replace(/^\//, '')}` : url
}
function handleAttachmentPreview(file: Record<string, unknown>) {
const url = String(file.fileUrl || '')
if (!url) return
window.open(fullFileUrl(url), '_blank')
}
function handleAttachmentDownload(file: Record<string, unknown>) {
downloadAttachmentFile(file, { fullFileUrl })
}
function getCurrentUserHandler() {
const info = userStore.info as Record<string, unknown>
const userId = String(info?.id || info?.userId || '')
const label = String(
info?.realName || info?.nickName || info?.userName || info?.username || ''
)
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() {
ensureCurrentUserInOptions()
const { userId, label } = getCurrentUserHandler()
if (!userId) {
receiveForm.handlerUserId = ''
receiveForm.handlerName = ''
return
}
const opt = userOptions.value.find((o) => o.value === userId)
receiveForm.handlerUserId = userId
receiveForm.handlerName = opt?.label || label
}
function onHandlerChange(userId: string) {
const opt = userOptions.value.find((o) => o.value === userId)
receiveForm.handlerName = opt?.label || ''
}
function formatNowDatetime() {
const now = new Date()
const pad = (n: number) => String(n).padStart(2, '0')
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
}
function createEmptyCheckValues() {
const map: Record<string, boolean> = {}
for (const item of activeCheckItems.value) {
map[item.id] = false
}
return map
}
function extractReceptionDate(receptionTime: string) {
const s = String(receptionTime || '').trim()
return s.length >= 10 ? s.slice(0, 10) : ''
}
function resolvePrefilledLabStorageCode(
sourceType: string,
sampleTypeName: string,
receptionTime: string
) {
return buildPrefilledLabStorageCode(
sourceType,
sampleTypeName,
parseLabStorageReferenceDate(receptionTime)
)
}
const LAB_STORAGE_CODE_UNMODIFIED_MSG =
'实验室入库编码仍为系统预填值,请确认并填写后再提交'
function shouldBlockUnmodifiedLabStorageCode(options: {
acceptConclusion: string
labStorageCodeManuallyEdited: boolean
}): boolean {
if (options.acceptConclusion !== 'js') return false
return !options.labStorageCodeManuallyEdited
}
function refreshReceiveLabStorageCode(force = false) {
if (receiveForm.acceptConclusion !== 'js') return
if (!force && labStorageCodeManuallyEdited.value) return
const row = currentRow.value
if (!row) return
receiveForm.labStorageCode = resolvePrefilledLabStorageCode(
String(row.sourceType || 'cell_storage'),
String(row.sampleTypeName || ''),
receiveForm.receptionTime
)
lastAllocatedReceptionDate.value = extractReceptionDate(receiveForm.receptionTime)
}
function onLabStorageCodeManualInput() {
labStorageCodeManuallyEdited.value = true
}
async function onReceiveReceptionTimeChange() {
const date = extractReceptionDate(receiveForm.receptionTime)
if (!date || receiveForm.acceptConclusion !== 'js') return
if (labStorageCodeManuallyEdited.value) return
refreshReceiveLabStorageCode(true)
}
function onReceiveAcceptConclusionChange(val: string | number | boolean | undefined) {
if (val === 'bj') return
refreshReceiveLabStorageCode(true)
}
function allocateBatchLabStorageCodes() {
for (const entry of batchEntries.value) {
if (entry.acceptConclusion !== 'js') continue
if (entry.labStorageCodeManuallyEdited) continue
entry.labStorageCode = resolvePrefilledLabStorageCode(
entry.sourceType,
entry.sampleTypeName,
entry.receptionTime
)
entry.lastAllocatedReceptionDate = extractReceptionDate(entry.receptionTime)
}
}
function refreshBatchEntryLabStorageCode(entry: BatchReceiveEntry, force = false) {
if (entry.acceptConclusion !== 'js') return
if (!force && entry.labStorageCodeManuallyEdited) return
entry.labStorageCode = resolvePrefilledLabStorageCode(
entry.sourceType,
entry.sampleTypeName,
entry.receptionTime
)
entry.lastAllocatedReceptionDate = extractReceptionDate(entry.receptionTime)
}
function onBatchLabStorageCodeManualInput(entry: BatchReceiveEntry) {
entry.labStorageCodeManuallyEdited = true
}
async function onBatchReceptionTimeChange(entry: BatchReceiveEntry) {
if (entry.acceptConclusion !== 'js' || entry.labStorageCodeManuallyEdited) return
refreshBatchEntryLabStorageCode(entry, true)
}
function onBatchAcceptConclusionChange(entry: BatchReceiveEntry) {
if (entry.acceptConclusion === 'bj') return
refreshBatchEntryLabStorageCode(entry, true)
}
function resetReceiveForm() {
receiveForm.receptionTime = formatNowDatetime()
applyDefaultHandler()
receiveForm.receiveTemperature = ''
receiveForm.acceptConclusion = 'js'
receiveForm.labStorageCode = ''
receiveForm.remark = ''
labStorageCodeManuallyEdited.value = false
lastAllocatedReceptionDate.value = ''
attachments.value = []
}
function createBatchEntry(row: Record<string, unknown>): BatchReceiveEntry {
ensureCurrentUserInOptions()
const { userId, label } = getCurrentUserHandler()
const opt = userOptions.value.find((o) => o.value === userId)
return {
protocolSampleId: String(row.protocolSampleId || ''),
protocolNo: String(row.protocolNo || ''),
sampleCode: String(row.sampleCode || ''),
isSpecial: !!row.isSpecial,
specialRemark: String(row.specialRemark || ''),
sampleTypeName: String(row.sampleTypeName || ''),
waybillNo: String(row.waybillNo || ''),
motherName: String(row.motherName || ''),
newbornName: String(row.newbornName || ''),
sampleCollectTime: String(row.sampleCollectTime || ''),
maternalBloodCollectTime: String(row.maternalBloodCollectTime || ''),
sourceType: (row.sourceType as 'cell_storage' | 'research_donation') || 'cell_storage',
transportType: String(row.transportType || ''),
receptionTime: formatNowDatetime(),
handlerUserId: userId || '',
handlerName: opt?.label || label || '',
receiveTemperature: '',
acceptConclusion: 'js',
labStorageCode: '',
labStorageCodeManuallyEdited: false,
lastAllocatedReceptionDate: '',
remark: '',
checkValues: createEmptyCheckValues(),
attachments: []
}
}
function batchEntryLabel(entry: BatchReceiveEntry, index: number) {
return entry.sampleCode || `第 ${index + 1} 项`
}
function onBatchHandlerChange(entry: BatchReceiveEntry, userId: string) {
const opt = userOptions.value.find((o) => o.value === userId)
entry.handlerName = opt?.label || ''
}
function handleCardToggleSelect(row: Record<string, unknown>, checked: boolean) {
const id = String(row.protocolSampleId || '')
if (checked) {
if (!selectedPendingRows.value.some((r) => String(r.protocolSampleId) === id)) {
selectedPendingRows.value = [...selectedPendingRows.value, row]
}
} else {
selectedPendingRows.value = selectedPendingRows.value.filter(
(r) => String(r.protocolSampleId) !== id
)
}
}
function buildChecksFromEntry(entry: BatchReceiveEntry) {
return activeCheckItems.value.map((item) => ({
checkItemId: item.id,
checked: !!entry.checkValues[item.id]
}))
}
async function openBatchReceive() {
if (selectedPendingRows.value.length === 0) {
ElMessage.warning('请先勾选待接收样本')
return
}
if (!userOptions.value.length) {
await loadUserOptions()
}
await loadActiveCheckItems()
if (!activeCheckItems.value.length) {
ElMessage.warning('暂无启用的检查项,请先在「接收检查项配置」中维护')
return
}
batchEntries.value = selectedPendingRows.value.map((row) => createBatchEntry(row))
batchReceiveDialogVisible.value = true
allocateBatchLabStorageCodes()
}
function validateBatchEntry(entry: BatchReceiveEntry, index: number): string | null {
const label = batchEntryLabel(entry, index)
if (!entry.receptionTime) return `${label}:请选择样本接收时间`
if (!entry.handlerUserId) return `${label}:请选择经手人`
if (!entry.acceptConclusion) return `${label}:请选择是否接收`
if (entry.acceptConclusion === 'js' && !String(entry.labStorageCode || '').trim()) {
return `${label}:请填写或生成实验室入库编码`
}
if (
shouldBlockUnmodifiedLabStorageCode({
acceptConclusion: entry.acceptConclusion,
labStorageCodeManuallyEdited: entry.labStorageCodeManuallyEdited
})
) {
return `${label}:${LAB_STORAGE_CODE_UNMODIFIED_MSG}`
}
if (entry.attachments.some((a) => a._uploading)) return `${label}:附件正在上传,请稍候`
return null
}
async function submitBatchReceive() {
if (!batchEntries.value.length) return
if (!activeCheckItems.value.length) {
ElMessage.warning('暂无启用的检查项,请先在「接收检查项配置」中维护')
return
}
for (let i = 0; i < batchEntries.value.length; i++) {
const err = validateBatchEntry(batchEntries.value[i], i)
if (err) {
ElMessage.warning(err)
return
}
}
submitLoading.value = true
let ok = 0
let fail = 0
try {
for (const entry of batchEntries.value) {
try {
await fetchSampleReceptionSubmit({
sourceType: entry.sourceType,
donationSampleId:
entry.sourceType === 'research_donation' ? entry.protocolSampleId : undefined,
protocolSampleId:
entry.sourceType !== 'research_donation' ? entry.protocolSampleId : undefined,
receptionTime: entry.receptionTime,
handlerUserId: entry.handlerUserId,
handlerName: entry.handlerName,
receiveTemperature: entry.receiveTemperature || undefined,
checks: buildChecksFromEntry(entry),
acceptConclusion: entry.acceptConclusion,
labStorageCode: String(entry.labStorageCode || '').trim() || undefined,
receiveAttachments: financeAttachmentsToUrlString(entry.attachments) || undefined,
remark: entry.remark || undefined
})
ok++
} catch {
fail++
}
}
if (fail === 0) {
ElMessage.success(`已成功接收 ${ok} 个样本`)
batchReceiveDialogVisible.value = false
selectedPendingRows.value = []
pagination.page = 1
activeTab.value = 'received'
loadData()
} else {
ElMessage.warning(`成功 ${ok} 个,失败 ${fail} 个,请检查后重试未成功的样本`)
loadData()
}
} finally {
submitLoading.value = false
}
}
async function loadUserOptions() {
try {
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()
}
}
async function loadData() {
loading.value = true
try {
const baseParams = {
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined,
sourceType: searchForm.sourceType || undefined
}
const res =
activeTab.value === 'pending'
? await fetchSampleReceptionPendingList({
...baseParams,
etaTimeStart: etaDateRange.value?.[0] || undefined,
etaTimeEnd: etaDateRange.value?.[1] || undefined
})
: await fetchSampleReceptionReceivedList({
...baseParams,
receptionTimeStart: receptionTimeRange.value?.[0] || undefined,
receptionTimeEnd: receptionTimeRange.value?.[1] || undefined
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleStatusTabChange() {
selectedPendingRows.value = []
pagination.page = 1
loadData()
}
function handleTabChange(name: string) {
if (activeTab.value === name) return
activeTab.value = name
handleStatusTabChange()
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
searchForm.sourceType = ''
if (activeTab.value === 'pending') {
etaDateRange.value = null
} else {
receptionTimeRange.value = null
}
pagination.page = 1
loadData()
}
function resetCheckValues(items: SampleReceptionCheckItem[]) {
Object.keys(checkValues).forEach((k) => delete checkValues[k])
for (const item of items) {
checkValues[item.id] = false
}
}
async function loadActiveCheckItems() {
try {
const list = await fetchSampleReceptionCheckItemsActive()
activeCheckItems.value = list || []
resetCheckValues(activeCheckItems.value)
} catch {
activeCheckItems.value = []
resetCheckValues([])
}
}
async function openReceive(row: Record<string, unknown>) {
receiveDialogMode.value = 'create'
editingReceptionId.value = ''
currentRow.value = row
if (!userOptions.value.length) {
await loadUserOptions()
}
await loadActiveCheckItems()
resetReceiveForm()
resetCheckValues(activeCheckItems.value)
editProductionReception.value = undefined
receiveDialogVisible.value = true
refreshReceiveLabStorageCode(true)
}
async function openEdit(row: Record<string, unknown>) {
if (!canEditReceivedReception(row)) {
ElMessage.warning('仅该接收记录的经手人或质量主管可编辑')
return
}
const receptionId = String(row.id || '')
if (!receptionId) {
ElMessage.warning('缺少接收记录标识,无法编辑')
return
}
receiveDialogMode.value = 'edit'
editingReceptionId.value = receptionId
currentRow.value = row
if (!userOptions.value.length) {
await loadUserOptions()
}
await loadActiveCheckItems()
let detail: Record<string, unknown> = row
try {
detail = (await fetchSampleReceptionDetail(receptionId)) as Record<string, unknown>
} catch {
/* 列表行已含主要字段,详情失败时回退 */
}
populateReceiveFormFromDetail(detail)
editProductionReception.value =
(detail.productionReception as ProductionReceptionRecord | null | undefined) ?? null
if (detail.handlerUserId) {
const hid = String(detail.handlerUserId)
if (!userOptions.value.some((o) => o.value === hid)) {
userOptions.value = [
{ label: String(detail.handlerName || hid), value: hid },
...userOptions.value
]
}
}
receiveDialogVisible.value = true
}
function openView(row: Record<string, unknown>) {
viewRow.value = row
viewProductionReception.value =
(row.productionReception as ProductionReceptionRecord | null | undefined) || null
viewDialogVisible.value = true
}
function handleRowDblClick(row: Record<string, unknown>) {
if (activeTab.value === 'received') openView(row)
}
async function submitReceive() {
if (!currentRow.value) return
const valid = await receiveFormRef.value?.validate?.().catch(() => false)
if (!valid) return
if (attachments.value.some((a) => a._uploading)) {
ElMessage.warning('附件正在上传,请稍候')
return
}
if (!activeCheckItems.value.length) {
ElMessage.warning('暂无启用的检查项,请先在「接收检查项配置」中维护')
return
}
if (
receiveDialogMode.value === 'create' &&
shouldBlockUnmodifiedLabStorageCode({
acceptConclusion: receiveForm.acceptConclusion,
labStorageCodeManuallyEdited: labStorageCodeManuallyEdited.value
})
) {
ElMessage.warning(LAB_STORAGE_CODE_UNMODIFIED_MSG)
return
}
submitLoading.value = true
const payload = {
receptionTime: receiveForm.receptionTime,
handlerUserId: receiveForm.handlerUserId,
handlerName: receiveForm.handlerName,
receiveTemperature: receiveForm.receiveTemperature || undefined,
checks: activeCheckItems.value.map((item) => ({
checkItemId: item.id,
checked: !!checkValues[item.id]
})),
acceptConclusion: receiveForm.acceptConclusion,
labStorageCode: String(receiveForm.labStorageCode || '').trim() || undefined,
receiveAttachments: financeAttachmentsToUrlString(attachments.value) || undefined,
remark: receiveForm.remark || undefined
}
try {
if (receiveDialogMode.value === 'edit') {
await fetchSampleReceptionUpdate(editingReceptionId.value, payload)
ElMessage.success('接收信息已更新')
receiveDialogVisible.value = false
loadData()
} else {
await fetchSampleReceptionSubmit({
sourceType: (currentRow.value.sourceType as string) || 'cell_storage',
donationSampleId:
currentRow.value.sourceType === 'research_donation'
? String(currentRow.value.protocolSampleId)
: undefined,
protocolSampleId:
currentRow.value.sourceType !== 'research_donation'
? String(currentRow.value.protocolSampleId)
: undefined,
...payload
})
receiveDialogVisible.value = false
pagination.page = 1
if (!props.receivedOnly) {
activeTab.value = 'received'
}
loadData()
}
} finally {
submitLoading.value = false
}
}
// 输入检索条件时自动搜索(防抖 300ms)
watchDebounced(
[searchForm, etaDateRange, receptionTimeRange],
() => {
pagination.page = 1
loadData()
},
{ debounce: 300, deep: true }
)
onMounted(() => {
loadUserOptions()
loadData()
})
</script>
<style scoped lang="scss">
.sample-reception-dialog {
.protocol-dialog-body {
overflow: visible;
background: #f5f7fa;
}
.protocol-form {
:deep(.el-form-item) {
margin-bottom: 4px;
}
}
.form-tab-pane {
padding: 0 28px 4px;
& + .form-tab-pane {
margin-top: 0;
padding-top: 0;
}
}
.section-card {
border-radius: 12px;
padding: 22px 24px;
margin-bottom: 20px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
transition:
transform 0.2s,
box-shadow 0.2s;
position: relative;
background: #fff;
&: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 {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18px;
padding-bottom: 12px;
border-bottom: 1px solid #e2e8f0;
&--compact {
margin-bottom: 10px;
padding-bottom: 8px;
}
}
.section-title-left {
display: flex;
align-items: center;
&::before {
content: '';
width: 3px;
height: 18px;
background: #047857;
border-radius: 2px;
margin-right: 10px;
flex-shrink: 0;
}
}
.section-title h3 {
font-size: 15px;
font-weight: 600;
color: #1e293b;
}
.data-grid {
display: grid;
gap: 14px 20px;
&--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 {
min-width: 0;
&--full {
grid-column: 1 / -1;
}
}
.data-label {
font-size: 12px;
color: var(--mint-text-muted, #334155);
margin-bottom: 3px;
}
.data-value {
font-size: 14px;
color: #1e293b;
font-weight: 500;
word-break: break-word;
}
.form-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px 20px;
&--col4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
&--attachment {
margin-top: 16px;
grid-template-columns: 1fr;
}
}
.form-col-span-2 {
grid-column: 1 / -1;
}
.check-list {
display: flex;
flex-wrap: wrap;
gap: 12px 20px;
}
.check-empty-hint {
margin: 0;
font-size: 13px;
color: var(--mint-text-muted, #64748b);
}
/* 接收详情查看弹窗(沿用旧只读栅格) */
.detail-section-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
color: var(--mint-text, #0f172a);
padding-left: 10px;
position: relative;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 3px;
height: 14px;
background-color: var(--el-color-primary);
border-radius: 2px;
}
}
.form-section-divider {
margin: 16px 0;
border-top: 1px solid var(--mint-border, #e2e8f0);
}
.readonly-grid {
display: grid;
gap: 12px 16px;
}
.readonly-item {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
font-size: 14px;
line-height: 1.5;
.label {
display: block;
min-width: 0;
margin: 0;
font-size: 12px;
font-weight: 500;
color: var(--mint-text-muted, #64748b);
}
> .el-tag {
width: fit-content;
max-width: 100%;
}
}
}
.sample-reception-view-dialog {
:deep(.el-dialog__body) {
padding-top: 8px;
}
.production-view-empty {
font-size: 14px;
color: var(--mint-text-muted, #64748b);
}
}
.batch-receive-dialog {
.batch-receive-tip {
margin: 0 0 16px;
font-size: 13px;
color: var(--mint-text-muted, #64748b);
}
.batch-receive-card {
padding: 16px;
margin-bottom: 16px;
border: 1px solid var(--mint-border, #e2e8f0);
border-radius: 8px;
background: var(--default-box-color, #fff);
&:last-child {
margin-bottom: 0;
}
}
.batch-receive-card__title {
margin-bottom: 12px;
}
.batch-receive-card__meta {
margin-bottom: 12px;
}
}
.sample-reception-dialog .check-items-readonly,
.batch-receive-dialog .check-items-readonly {
display: flex;
flex-direction: column;
gap: 8px;
.label {
margin-right: 0;
}
.check-list {
padding-left: 0;
}
}
.sample-reception-dialog .check-list-view,
.batch-receive-dialog .check-list-view {
pointer-events: none;
:deep(.el-checkbox.is-disabled) {
opacity: 1;
cursor: default;
.el-checkbox__label {
color: var(--el-text-color-regular);
}
.el-checkbox__input.is-disabled {
opacity: 1;
cursor: default;
.el-checkbox__inner {
background-color: var(--el-checkbox-bg-color);
border-color: var(--el-checkbox-input-border-color);
cursor: default;
}
&.is-checked .el-checkbox__inner {
background-color: var(--el-checkbox-checked-bg-color);
border-color: var(--el-checkbox-checked-input-border-color);
&::after {
border-color: var(--el-checkbox-checked-icon-color);
}
}
}
}
}
</style>