提交
This commit is contained in:
1 parent
195c4c0a34
commit
64219a68c7
317 files changed
+66845
-33515
No files matched your search
@@ -225,7 +225,6 @@
|
||||
value: taskStatusLabel(d.taskStatus),
|
||||
tagType: taskStatusTagType(d.taskStatus)
|
||||
},
|
||||
{ label: '协议号', value: d.protocolNo || '—' },
|
||||
{ label: '样本编码', value: d.sampleCode || '—' },
|
||||
{ label: '开始时间', value: d.startedTime || '—' },
|
||||
{
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
<div class="protocol-payment-detail-readonly">
|
||||
<h4 v-if="title" class="detail-block-title">{{ title }}</h4>
|
||||
<dl class="view-kv-grid view-kv-grid--4">
|
||||
<div class="view-kv">
|
||||
<dt>协议号</dt>
|
||||
<dd>{{ dash(detail?.protocolNo) }}</dd>
|
||||
</div>
|
||||
<div class="view-kv">
|
||||
<dt>协议状态</dt>
|
||||
<dd>{{ protocolStatusLabel(String(detail?.protocolStatus || '')) }}</dd>
|
||||
|
||||
@@ -40,12 +40,22 @@
|
||||
:index="(index) => index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="materialName"
|
||||
label="物料名称"
|
||||
min-width="160"
|
||||
prop="stockInNo"
|
||||
label="入库编号"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="materialName"
|
||||
label="物料名称"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column label="批号" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ row.batchNo || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格型号" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ row.specModel || '—' }}</template>
|
||||
</el-table-column>
|
||||
@@ -86,7 +96,7 @@
|
||||
fetchQcTaskMaterialUsages,
|
||||
type QcTaskMaterialUsageItem
|
||||
} from '@/api/qc-task-result'
|
||||
import { fetchQcMaterialOptions, type QcMaterialOption } from '@/api/qc-material'
|
||||
import { fetchQcMaterialBatchOptions, type QcMaterialBatchOption } from '@/api/qc-material'
|
||||
import {
|
||||
taskTypeLabel,
|
||||
taskStatusLabel,
|
||||
@@ -117,9 +127,11 @@
|
||||
})
|
||||
|
||||
type ViewMaterialUsageRow = {
|
||||
materialId: string
|
||||
batchId: string
|
||||
stockInNo: string
|
||||
materialName: string
|
||||
specModel: string
|
||||
batchNo: string
|
||||
unit: string
|
||||
qty: number | undefined
|
||||
remark: string
|
||||
@@ -131,34 +143,28 @@
|
||||
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
|
||||
function materialRowsFromApi(items: QcTaskMaterialUsageItem[]): ViewMaterialUsageRow[] {
|
||||
const merged = new Map<string, ViewMaterialUsageRow>()
|
||||
for (const u of items || []) {
|
||||
const mid = (u.materialId || '').trim()
|
||||
if (!mid) continue
|
||||
const qtyRaw = Math.abs(Number(u.changeQty) || 0)
|
||||
const prev = merged.get(mid)
|
||||
if (prev) {
|
||||
prev.qty = (Number(prev.qty) || 0) + qtyRaw
|
||||
} else {
|
||||
merged.set(mid, {
|
||||
materialId: mid,
|
||||
materialName: u.materialName || '',
|
||||
specModel: '',
|
||||
unit: '',
|
||||
qty: qtyRaw > 0 ? qtyRaw : undefined,
|
||||
remark: u.remark || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
return Array.from(merged.values())
|
||||
return (items || [])
|
||||
.filter((u) => (u.batchId || '').trim())
|
||||
.map((u) => ({
|
||||
batchId: u.batchId,
|
||||
stockInNo: u.stockInNo || '',
|
||||
materialName: u.materialName || '',
|
||||
specModel: '',
|
||||
batchNo: u.batchNo || '',
|
||||
unit: '',
|
||||
qty: Math.abs(Number(u.changeQty) || 0) || undefined,
|
||||
remark: u.remark || ''
|
||||
}))
|
||||
}
|
||||
|
||||
function enrichMaterialUsageRows(rows: ViewMaterialUsageRow[], options: QcMaterialOption[]) {
|
||||
function enrichMaterialUsageRows(rows: ViewMaterialUsageRow[], options: QcMaterialBatchOption[]) {
|
||||
for (const row of rows) {
|
||||
const opt = options.find((o) => o.id === row.materialId)
|
||||
const opt = options.find((o) => o.id === row.batchId)
|
||||
if (opt) {
|
||||
row.stockInNo = opt.stockInNo || row.stockInNo
|
||||
row.materialName = opt.materialName || row.materialName
|
||||
row.specModel = opt.specModel || ''
|
||||
row.batchNo = opt.batchNo || row.batchNo
|
||||
row.unit = opt.unit || ''
|
||||
}
|
||||
}
|
||||
@@ -186,7 +192,7 @@
|
||||
try {
|
||||
const [savedUsages, opts] = await Promise.all([
|
||||
fetchQcTaskMaterialUsages(id).catch(() => [] as QcTaskMaterialUsageItem[]),
|
||||
fetchQcMaterialOptions().catch(() => [] as QcMaterialOption[])
|
||||
fetchQcMaterialBatchOptions().catch(() => [] as QcMaterialBatchOption[])
|
||||
])
|
||||
const rows = materialRowsFromApi(savedUsages || [])
|
||||
enrichMaterialUsageRows(rows, opts || [])
|
||||
@@ -274,7 +280,6 @@
|
||||
{
|
||||
title: '样本信息',
|
||||
fields: [
|
||||
{ label: '协议号', value: r.protocolNo || d.protocolNo || '—' },
|
||||
{ label: '样本编码', value: r.sampleCode || d.sampleCode || '—' },
|
||||
{
|
||||
label: '样本来源',
|
||||
|
||||
@@ -0,0 +1,687 @@
|
||||
<!-- 协议单/捐赠单 · 样本及运输信息(列表 + 子弹窗) -->
|
||||
<template>
|
||||
<div class="sample-transport-section">
|
||||
<div class="sample-toolbar">
|
||||
<el-button type="primary" @click="openAddSampleDialog">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加样本
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
:disabled="!selectedSamples.length"
|
||||
@click="openBatchTransportDialog"
|
||||
>
|
||||
配置运输信息
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="samples.length" class="list-body list-wrap sample-transport-table-wrap">
|
||||
<el-table
|
||||
ref="sampleTableRef"
|
||||
:data="samples"
|
||||
stripe
|
||||
class="list-table inner-table"
|
||||
row-key="_rowKey"
|
||||
@selection-change="onSampleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
min-width="64"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column label="样本类型" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ sampleTypeName(row.sampleTypeId) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="样本编码" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.sampleCode || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="采集量" min-width="88" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ row.collectAmount ?? '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="72" align="center" header-align="center">
|
||||
<template #default="{ row }">{{ unitName(row.unitId) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showPrice"
|
||||
label="原价格(元)"
|
||||
min-width="100"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ fmtMoney(row.originalPrice) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showPrice"
|
||||
label="优惠价格(元)"
|
||||
min-width="108"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ fmtMoney(row.price) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="存储年限" min-width="96" align="center" header-align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.storageYears != null ? row.storageYears + '年' : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="样本状态" min-width="96" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="row.sampleStatus"
|
||||
:type="sampleStatusTagType(String(row.sampleStatus))"
|
||||
size="small"
|
||||
>
|
||||
{{ sampleStatusLabel(String(row.sampleStatus)) }}
|
||||
</el-tag>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="运输类型" min-width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
row.transport?.transportType
|
||||
? transportTypeLabel(String(row.transport.transportType))
|
||||
: '—'
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="目的站点" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{
|
||||
siteName(String(row.transport?.destSiteId || ''))
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="预计到达" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.transport?.etaTime || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="快递/携带" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ sampleTransportExtra(row.transport) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
min-width="160"
|
||||
fixed="right"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row, $index }">
|
||||
<el-button class="btn-op-item" @click="openEditSampleDialog(row, $index)">
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="removeSample($index)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<el-empty v-else description="暂无样本,点击上方按钮添加" :image-size="48" />
|
||||
|
||||
<!-- 添加/编辑样本 -->
|
||||
<el-dialog
|
||||
v-model="sampleDialogVisible"
|
||||
:title="sampleDialogMode === 'add' ? '添加样本' : '编辑样本'"
|
||||
width="840px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="sampleFormRef"
|
||||
:model="sampleDraft"
|
||||
label-position="top"
|
||||
class="biz-dialog-form"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="样本类型">
|
||||
<el-select
|
||||
v-model="sampleDraft.sampleTypeId"
|
||||
placeholder="选择类型"
|
||||
style="width: 100%"
|
||||
@change="onSampleTypeChange(sampleDraft)"
|
||||
>
|
||||
<el-option
|
||||
v-for="st in sampleTypeOptions"
|
||||
:key="st.id"
|
||||
:label="st.typeName + (st.typeCode ? ' (' + st.typeCode + ')' : '')"
|
||||
:value="st.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="样本编码">
|
||||
<el-select
|
||||
v-model="sampleDraft.sampleCodeId"
|
||||
placeholder="选择编码"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="onSampleCodeChange(sampleDraft)"
|
||||
>
|
||||
<el-option
|
||||
v-for="sc in sampleCodeOptions"
|
||||
:key="sc.id"
|
||||
:label="sampleCodeOptionLabel(sc)"
|
||||
:value="sc.id"
|
||||
:disabled="isSampleCodeOptionDisabled(sc, sampleDraft)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="采集量">
|
||||
<el-input
|
||||
v-model="sampleDraft.collectAmount"
|
||||
type="number"
|
||||
step="any"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="单位">
|
||||
<el-select
|
||||
v-model="sampleDraft.unitId"
|
||||
placeholder="单位"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="u in unitOptions" :key="u.id" :label="u.unitName" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="showPrice" label="原价格(元)">
|
||||
<el-input
|
||||
:model-value="fmtMoney(sampleDraft.originalPrice)"
|
||||
disabled
|
||||
placeholder="—"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="showPrice" label="优惠价格(元)">
|
||||
<AmountInput v-model="sampleDraft.price" :min="0" placeholder="请输入优惠价格" />
|
||||
</el-form-item>
|
||||
<el-form-item label="存储年限(年)">
|
||||
<el-input
|
||||
v-model="sampleDraft.storageYears"
|
||||
type="number"
|
||||
step="any"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="样本状态">
|
||||
<el-select
|
||||
v-model="sampleDraft.sampleStatus"
|
||||
placeholder="状态"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="onSampleStatusChange(sampleDraft)"
|
||||
>
|
||||
<el-option label="已采集" value="ycj" />
|
||||
<el-option label="检测中" value="jcz" />
|
||||
<el-option label="已入库" value="yrk" />
|
||||
<el-option label="已作废" value="yzf" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="sampleDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="confirmSampleDialog">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 配置运输信息 -->
|
||||
<el-dialog
|
||||
v-model="batchTransportVisible"
|
||||
title="配置运输信息"
|
||||
width="1200px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="sample-transport-hint batch-transport-dialog-hint">
|
||||
将以下运输信息应用到已选中的 {{ selectedSamples.length }} 个样本。
|
||||
</p>
|
||||
<el-form label-position="top" class="biz-dialog-form">
|
||||
<div
|
||||
class="sample-transport-form-row"
|
||||
:class="{
|
||||
'sample-transport-form-row--ryxd': batchTransport.transportType === 'ryxd'
|
||||
}"
|
||||
>
|
||||
<el-form-item label="运输类型">
|
||||
<el-select
|
||||
v-model="batchTransport.transportType"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="快递运输" value="kdys" />
|
||||
<el-option label="人员携带" value="ryxd" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="目的站点">
|
||||
<el-select
|
||||
v-model="batchTransport.destSiteId"
|
||||
placeholder="选择站点"
|
||||
filterable
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="site in siteOptions"
|
||||
:key="site.id"
|
||||
:label="site.siteName"
|
||||
:value="site.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="预计到达时间">
|
||||
<el-date-picker
|
||||
v-model="batchTransport.etaTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
placeholder="选择预计到达时间"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<template v-if="batchTransport.transportType === 'kdys'">
|
||||
<el-form-item label="快递公司">
|
||||
<el-select
|
||||
v-model="batchTransport.expressCompanyId"
|
||||
placeholder="选择快递公司"
|
||||
filterable
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="ec in expressCompanyOptions"
|
||||
:key="ec.id"
|
||||
:label="ec.expressName"
|
||||
:value="ec.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="快递单号">
|
||||
<el-input v-model="batchTransport.waybillNo" placeholder="请输入快递单号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="快递费用(元)">
|
||||
<el-input
|
||||
v-model="batchTransport.expressFee"
|
||||
type="number"
|
||||
step="any"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template v-if="batchTransport.transportType === 'ryxd'">
|
||||
<el-form-item label="携带人员姓名">
|
||||
<el-input v-model="batchTransport.carrierName" placeholder="请输入姓名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="携带人员电话">
|
||||
<el-input v-model="batchTransport.carrierPhone" placeholder="请输入电话" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="batchTransportVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="confirmBatchTransportApply">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定应用
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Plus, Edit, Delete, Close, Check } from '@element-plus/icons-vue'
|
||||
import AmountInput from '@/components/common/amount-input/index.vue'
|
||||
import {
|
||||
sampleStatusLabel,
|
||||
sampleStatusTagType,
|
||||
transportTypeLabel
|
||||
} from '@/utils/status-tag-registry'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
defineOptions({ name: 'SampleTransportFormSection' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
samples: Array<Record<string, any>>
|
||||
sampleTypeOptions: Array<{
|
||||
id: string
|
||||
typeName: string
|
||||
typeCode?: string
|
||||
storagePrice?: number | null
|
||||
storageYears?: number | null
|
||||
}>
|
||||
sampleCodeOptions: Api.BizSampleCode.SampleCodeItem[]
|
||||
unitOptions: Array<{ id: string; unitName: string }>
|
||||
siteOptions: Api.Site.SiteItem[]
|
||||
expressCompanyOptions: Api.ExpressCompany.ExpressCompanyItem[]
|
||||
showPrice?: boolean
|
||||
sampleCodeUsedKey?: 'usedInProtocol'
|
||||
}>(),
|
||||
{ showPrice: false, sampleCodeUsedKey: 'usedInProtocol' }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:samples', val: Array<Record<string, any>>): void
|
||||
(e: 'price-change'): void
|
||||
}>()
|
||||
|
||||
type SampleTransportForm = {
|
||||
transportType: string
|
||||
expressCompanyId: string
|
||||
waybillNo: string
|
||||
destSiteId: string
|
||||
expressFee: number | null
|
||||
etaTime: string
|
||||
carrierName: string
|
||||
carrierPhone: string
|
||||
}
|
||||
|
||||
const sampleTableRef = ref()
|
||||
const selectedSamples = ref<Array<Record<string, any>>>([])
|
||||
let sampleRowSeq = 0
|
||||
|
||||
const batchTransport = reactive<SampleTransportForm>(createEmptyTransport())
|
||||
const batchTransportVisible = ref(false)
|
||||
|
||||
const sampleDialogVisible = ref(false)
|
||||
const sampleDialogMode = ref<'add' | 'edit'>('add')
|
||||
const sampleDialogIndex = ref(-1)
|
||||
const sampleDraft = reactive<Record<string, any>>({})
|
||||
|
||||
function fmtMoney(v: unknown): string {
|
||||
if (v == null || v === '') return '—'
|
||||
return '¥' + formatMoneyDisplay(v)
|
||||
}
|
||||
|
||||
function createEmptyTransport(): SampleTransportForm {
|
||||
return {
|
||||
transportType: '',
|
||||
expressCompanyId: '',
|
||||
waybillNo: '',
|
||||
destSiteId: '',
|
||||
expressFee: null,
|
||||
etaTime: '',
|
||||
carrierName: '',
|
||||
carrierPhone: ''
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeSampleRow(raw: Record<string, any>, _index: number) {
|
||||
const transportRaw = raw.transport && typeof raw.transport === 'object' ? raw.transport : {}
|
||||
const statusRaw = raw.sampleStatus
|
||||
const sampleStatus =
|
||||
statusRaw != null && String(statusRaw).trim() !== '' ? String(statusRaw).trim() : ''
|
||||
return {
|
||||
...raw,
|
||||
sampleStatus,
|
||||
_rowKey: raw.id || raw._rowKey || `new-${++sampleRowSeq}`,
|
||||
transport: {
|
||||
...createEmptyTransport(),
|
||||
transportType: transportRaw.transportType || '',
|
||||
expressCompanyId: transportRaw.expressCompanyId || '',
|
||||
waybillNo: transportRaw.waybillNo || '',
|
||||
destSiteId: transportRaw.destSiteId || '',
|
||||
expressFee: transportRaw.expressFee ?? null,
|
||||
etaTime: transportRaw.etaTime || '',
|
||||
carrierName: transportRaw.carrierName || '',
|
||||
carrierPhone: transportRaw.carrierPhone || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateSamples(next: Array<Record<string, any>>) {
|
||||
emit('update:samples', next)
|
||||
}
|
||||
|
||||
function sampleTypeName(id: string) {
|
||||
if (!id) return '—'
|
||||
return props.sampleTypeOptions.find((x) => x.id === id)?.typeName || '—'
|
||||
}
|
||||
|
||||
function originalPriceFromSampleType(sampleTypeId: string) {
|
||||
if (!sampleTypeId) return null
|
||||
const st = props.sampleTypeOptions.find((x) => x.id === sampleTypeId)
|
||||
return st?.storagePrice ?? null
|
||||
}
|
||||
|
||||
function ensureSampleOriginalPrice(row: Record<string, any>) {
|
||||
if (!props.showPrice) return
|
||||
if (row.originalPrice != null && row.originalPrice !== '') return
|
||||
const fromType = originalPriceFromSampleType(String(row.sampleTypeId || ''))
|
||||
if (fromType != null) row.originalPrice = fromType
|
||||
}
|
||||
|
||||
function unitName(id: string) {
|
||||
if (!id) return '—'
|
||||
return props.unitOptions.find((x) => x.id === id)?.unitName || '—'
|
||||
}
|
||||
|
||||
function siteName(id: string) {
|
||||
if (!id) return '—'
|
||||
return props.siteOptions.find((x) => x.id === id)?.siteName || '—'
|
||||
}
|
||||
|
||||
function expressName(id: string) {
|
||||
if (!id) return '—'
|
||||
return props.expressCompanyOptions.find((x) => x.id === id)?.expressName || '—'
|
||||
}
|
||||
|
||||
function sampleTransportExtra(transport: Record<string, any> | undefined) {
|
||||
if (!transport?.transportType) return '—'
|
||||
if (transport.transportType === 'kdys') {
|
||||
const parts: string[] = []
|
||||
const ec = expressName(String(transport.expressCompanyId || ''))
|
||||
if (ec !== '—') parts.push(ec)
|
||||
if (transport.waybillNo) parts.push(String(transport.waybillNo))
|
||||
if (transport.expressFee != null && transport.expressFee !== '') {
|
||||
parts.push(`¥${transport.expressFee}`)
|
||||
}
|
||||
return parts.length ? parts.join(' · ') : '—'
|
||||
}
|
||||
if (transport.transportType === 'ryxd') {
|
||||
const parts: string[] = []
|
||||
if (transport.carrierName) parts.push(String(transport.carrierName))
|
||||
if (transport.carrierPhone) parts.push(String(transport.carrierPhone))
|
||||
return parts.length ? parts.join(' · ') : '—'
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
function sampleCodeOptionLabel(sc: Api.BizSampleCode.SampleCodeItem) {
|
||||
if (sc.usedInProtocol) return `${sc.sampleCode}(已占用)`
|
||||
if (sc.issued) return `${sc.sampleCode}(已下发)`
|
||||
return sc.sampleCode
|
||||
}
|
||||
|
||||
function isSampleCodeOptionDisabled(
|
||||
sc: Api.BizSampleCode.SampleCodeItem,
|
||||
row: Record<string, any>
|
||||
) {
|
||||
if (sc.usedInProtocol && String(row.sampleCodeId || '') !== sc.id) return true
|
||||
return props.samples.some((s) => s !== row && String(s.sampleCodeId || '') === sc.id)
|
||||
}
|
||||
|
||||
function onSampleCodeChange(row: Record<string, any>) {
|
||||
const sc = props.sampleCodeOptions.find((x) => x.id === row.sampleCodeId)
|
||||
if (sc) {
|
||||
row.sampleCode = sc.sampleCode
|
||||
row.sampleCodeId = sc.id
|
||||
}
|
||||
}
|
||||
|
||||
function onSampleTypeChange(row: Record<string, any>) {
|
||||
const st = props.sampleTypeOptions.find((x) => x.id === row.sampleTypeId)
|
||||
if (st) {
|
||||
if (props.showPrice) {
|
||||
row.originalPrice = st.storagePrice ?? null
|
||||
row.price = st.storagePrice
|
||||
}
|
||||
row.storageYears = st.storageYears
|
||||
}
|
||||
}
|
||||
|
||||
function onSampleStatusChange(row: Record<string, any>) {
|
||||
if (row.sampleStatus == null) {
|
||||
row.sampleStatus = ''
|
||||
}
|
||||
}
|
||||
|
||||
function onSampleSelectionChange(rows: Array<Record<string, any>>) {
|
||||
selectedSamples.value = rows
|
||||
}
|
||||
|
||||
function openBatchTransportDialog() {
|
||||
if (!selectedSamples.value.length) {
|
||||
ElMessage.warning('请先勾选需要应用运输信息的样本')
|
||||
return
|
||||
}
|
||||
Object.assign(batchTransport, createEmptyTransport())
|
||||
batchTransportVisible.value = true
|
||||
}
|
||||
|
||||
function confirmBatchTransportApply() {
|
||||
if (!batchTransport.transportType) {
|
||||
ElMessage.warning('请选择运输类型')
|
||||
return
|
||||
}
|
||||
const payload = { ...batchTransport }
|
||||
const selectedSet = new Set(selectedSamples.value)
|
||||
const next = props.samples.map((row) => {
|
||||
if (!selectedSet.has(row)) return row
|
||||
const transport = { ...(row.transport || createEmptyTransport()), ...payload }
|
||||
return { ...row, transport }
|
||||
})
|
||||
updateSamples(next)
|
||||
batchTransportVisible.value = false
|
||||
ElMessage.success(`已为 ${selectedSamples.value.length} 个样本应用运输信息`)
|
||||
}
|
||||
|
||||
function openAddSampleDialog() {
|
||||
sampleDialogMode.value = 'add'
|
||||
sampleDialogIndex.value = -1
|
||||
Object.assign(
|
||||
sampleDraft,
|
||||
normalizeSampleRow(
|
||||
{
|
||||
sampleTypeId: '',
|
||||
sampleCode: '',
|
||||
sampleCodeId: '',
|
||||
collectAmount: null,
|
||||
unitId: '',
|
||||
price: props.showPrice ? null : undefined,
|
||||
originalPrice: props.showPrice ? null : undefined,
|
||||
storageYears: null,
|
||||
sampleStatus: 'ycj'
|
||||
},
|
||||
props.samples.length
|
||||
)
|
||||
)
|
||||
sampleDialogVisible.value = true
|
||||
}
|
||||
|
||||
function openEditSampleDialog(row: Record<string, any>, index: number) {
|
||||
sampleDialogMode.value = 'edit'
|
||||
sampleDialogIndex.value = index
|
||||
const draft = normalizeSampleRow({ ...row, transport: { ...row.transport } }, index)
|
||||
ensureSampleOriginalPrice(draft)
|
||||
Object.assign(sampleDraft, draft)
|
||||
sampleDialogVisible.value = true
|
||||
}
|
||||
|
||||
function confirmSampleDialog() {
|
||||
if (!sampleDraft.sampleTypeId) {
|
||||
ElMessage.warning('请选择样本类型')
|
||||
return
|
||||
}
|
||||
if (!sampleDraft.sampleCodeId) {
|
||||
ElMessage.warning('请选择样本编码')
|
||||
return
|
||||
}
|
||||
ensureSampleOriginalPrice(sampleDraft)
|
||||
const next = [...props.samples]
|
||||
const normalized = normalizeSampleRow(
|
||||
{ ...sampleDraft },
|
||||
sampleDialogIndex.value >= 0 ? sampleDialogIndex.value : next.length
|
||||
)
|
||||
if (sampleDialogMode.value === 'add') {
|
||||
next.push(normalized)
|
||||
} else {
|
||||
next[sampleDialogIndex.value] = normalized
|
||||
}
|
||||
updateSamples(next)
|
||||
if (props.showPrice) emit('price-change')
|
||||
sampleDialogVisible.value = false
|
||||
}
|
||||
|
||||
function removeSample(index: number) {
|
||||
const next = [...props.samples]
|
||||
next.splice(index, 1)
|
||||
updateSamples(next)
|
||||
sampleTableRef.value?.clearSelection?.()
|
||||
if (props.showPrice) emit('price-change')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.sample-transport-section {
|
||||
.sample-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.sample-transport-table-wrap {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sample-transport-hint {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.batch-transport-dialog-hint {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.sample-transport-form-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 12px 16px;
|
||||
align-items: start;
|
||||
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&--ryxd {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user