Files
shanxia2.0/web-admin/src/views/quality-inspection/storage-release-review/StorageReleaseViewDialog.vue
T
2026-05-23 11:41:57 +08:00

404 lines
13 KiB
Vue

<!-- 入库放行审核 — 只读查看 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<SystemViewDialog
v-model:visible="innerVisible"
title="入库放行审核详情"
width="960px"
:grid-columns="2"
:icon="CircleCheck"
:meta="detail?.review?.protocolNo || ''"
:sections="viewSections"
:loading="loading"
append-to-body
>
<template #qc-tasks>
<div v-if="detail?.qcInfo?.tasks?.length" class="view-section-slot">
<div class="qc-task-cards">
<div v-for="task in detail.qcInfo.tasks" :key="task.id" class="qc-task-card">
<div class="qc-task-card__header">
<span class="qc-task-card__type">
<el-tag type="info" size="small">{{
task.taskTypeLabel || task.taskType || '—'
}}</el-tag>
</span>
<span class="qc-task-card__conclusion">
<el-tag
v-if="task.conclusion"
:type="task.conclusion === 'tg' ? 'success' : 'danger'"
size="small"
>{{ task.conclusionLabel || task.conclusion }}</el-tag
>
<span v-else class="qc-kv__muted">—</span>
</span>
</div>
<div class="qc-task-card__body">
<div class="qc-kv">
<span class="qc-kv__label">任务状态</span>
<span class="qc-kv__value">
<el-tag
:type="
task.taskStatus === 'ywc'
? 'success'
: task.taskStatus === 'jxz'
? 'warning'
: 'info'
"
size="small"
>{{ task.taskStatusLabel || task.taskStatus || '—' }}</el-tag
>
</span>
</div>
</div>
</div>
</div>
</div>
<div v-else class="view-section-slot"><p class="view-empty-hint">暂无质检任务</p></div>
</template>
<template #production-tasks>
<div v-if="detail?.productionInfo?.tasks?.length" class="view-section-slot">
<div class="qc-task-cards">
<div v-for="task in detail.productionInfo.tasks" :key="task.id" class="qc-task-card">
<div class="qc-task-card__header">
<span class="qc-task-card__name">{{ task.taskName || task.taskNo || '—' }}</span>
<span class="qc-task-card__conclusion">
<el-tag
:type="
task.taskStatus === 'ywc'
? 'success'
: task.taskStatus === 'jxz'
? 'warning'
: 'info'
"
size="small"
>{{ task.taskStatusLabel || task.taskStatus || '—' }}</el-tag
>
</span>
</div>
<div class="qc-task-card__body">
<div class="qc-kv">
<span class="qc-kv__label">任务号</span>
<span class="qc-kv__value">{{ task.taskNo || '—' }}</span>
</div>
<div class="qc-kv">
<span class="qc-kv__label">开始时间</span>
<span class="qc-kv__value">{{ task.startedTime || '—' }}</span>
</div>
<div class="qc-kv">
<span class="qc-kv__label">完成时间</span>
<span class="qc-kv__value">{{ task.completedTime || '—' }}</span>
</div>
</div>
</div>
</div>
</div>
<div v-else class="view-section-slot"><p class="view-empty-hint">暂无生产任务</p></div>
</template>
<template #review-attachments>
<div class="view-section-slot">
<ProtocolAttachmentReadonly
:files="reviewAttachmentFiles"
@preview="handleAttachmentPreview"
@download="handleAttachmentDownload"
/>
</div>
</template>
</SystemViewDialog>
</template>
<script setup lang="ts">
import { CircleCheck } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import type { ViewSection } from '@/components/business/system-view-dialog/index.vue'
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
import {
fetchStorageReleaseReviewDetail,
type StorageReleaseReview,
type StorageReleaseReviewDetail,
type ProtocolInfo,
type TransportInfo,
type ReceptionInfo,
type QcInfo,
type ProductionInfo
} from '@/api/storage-release-review'
import {
receptionSourceLabel,
receptionSourceTagType,
storageReleaseConclusionLabel,
storageReleaseConclusionTagType,
acceptConclusionLabel,
acceptConclusionTagType,
transportTypeLabel
} from '@/utils/status-tag-registry'
import { downloadAttachmentFile } from '@/utils/download-attachment'
const props = defineProps<{
visible: boolean
reviewId: string
}>()
const emit = defineEmits<{
(e: 'update:visible', val: boolean): void
}>()
const innerVisible = computed({
get: () => props.visible,
set: (val) => emit('update:visible', val)
})
const loading = ref(false)
const detail = ref<StorageReleaseReviewDetail | null>(null)
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
watch(
() => [props.visible, props.reviewId] as const,
async ([vis, id]) => {
if (!vis || !id) {
detail.value = null
return
}
loading.value = true
try {
detail.value = await fetchStorageReleaseReviewDetail(id)
} catch {
detail.value = null
} finally {
loading.value = false
}
},
{ immediate: true }
)
function formatVal(v: unknown) {
if (v === null || v === undefined || v === '') return '—'
return String(v)
}
const reviewAttachmentFiles = computed(() => {
const urls = detail.value?.review?.reviewAttachments || ''
if (!urls.trim()) return []
return urls
.split(',')
.map((u) => u.trim())
.filter(Boolean)
.map((fileUrl, i) => ({
id: `att_${i}`,
fileUrl,
fileName: fileUrl.split('/').pop() || ''
}))
})
const viewSections = computed<ViewSection[]>(() => {
const d = detail.value
if (!d) return []
const rev: Partial<StorageReleaseReview> = d.review || {}
const proto: Partial<ProtocolInfo> = d.protocolInfo || {}
const transport: Partial<TransportInfo> = d.transportInfo || {}
const reception: Partial<ReceptionInfo> = d.receptionInfo || {}
const qc: Partial<QcInfo> = d.qcInfo || {}
const production: Partial<ProductionInfo> = d.productionInfo || {}
const reviewConclusionValue = rev.reviewConclusion || ''
const reviewConclusionDisplay = reviewConclusionValue
? storageReleaseConclusionLabel(reviewConclusionValue)
: '待审核'
const reviewConclusionTagType = reviewConclusionValue
? storageReleaseConclusionTagType(reviewConclusionValue)
: 'info'
return [
{
title: '基础信息',
fields: [
{ label: '协议编号', value: proto.protocolNo || rev.protocolNo || '—' },
{
label: '协议类别',
value: receptionSourceLabel(rev.receptionSource || ''),
tagType: receptionSourceTagType(rev.receptionSource || '')
},
{ label: '样本编码', value: proto.sampleCode || rev.sampleCode || '—' },
{ label: '样本名称', value: rev.sampleName || '—' },
{ label: '样本类型', value: proto.sampleTypeName || '—' },
{ label: '母亲姓名', value: proto.motherName || '—' },
{ label: '母亲电话', value: proto.motherPhone || '—' },
{ label: '新生儿姓名', value: proto.newbornName || '—' }
]
},
{
title: '运输信息',
fields: transport.transportType
? [
{ label: '运输方式', value: transportTypeLabel(transport.transportType) },
...(transport.transportType === 'kdys'
? [{ label: '快递单号', value: transport.waybillNo || '—' }]
: [
{ label: '携带人', value: transport.carrierName || '—' },
{ label: '携带人电话', value: transport.carrierPhone || '—' }
]),
{ label: '预计到达', value: transport.etaTime || '—' }
]
: []
},
{
title: '接收信息',
fields: reception.receptionTime
? [
{ label: '接收时间', value: reception.receptionTime || '—' },
{ label: '接收经手人', value: reception.handlerName || '—' },
{
label: '接收结论',
value: acceptConclusionLabel(reception.acceptConclusion || ''),
tagType: acceptConclusionTagType(reception.acceptConclusion || '')
},
{ label: '接收温度(℃)', value: formatVal(reception.receiveTemperature) },
{ label: '体积(ml)', value: formatVal(reception.volumeMl) }
]
: []
},
{
title: '质检信息',
slot: 'qc-tasks',
fields: [
{ label: '工单号', value: qc.workOrderNo || '—' },
{
label: '工单状态',
value:
qc.workOrderStatus === 'ywc'
? '已完成'
: qc.workOrderStatus === 'ypz'
? '已配置'
: qc.workOrderStatus || '—',
tagType:
qc.workOrderStatus === 'ywc'
? 'success'
: qc.workOrderStatus === 'ypz'
? 'warning'
: 'info'
}
]
},
{
title: '生产信息',
slot: 'production-tasks',
fields: [
{ label: '工单号', value: production.workOrderNo || '—' },
{
label: '工单状态',
value:
production.workOrderStatus === 'ywc'
? '已完成'
: production.workOrderStatus === 'jxz'
? '执行中'
: production.workOrderStatus || '—',
tagType:
production.workOrderStatus === 'ywc'
? 'success'
: production.workOrderStatus === 'jxz'
? 'warning'
: 'info'
}
]
},
{
title: '放行审核',
slot: 'review-attachments',
fields: [
{
label: '审核结论',
value: reviewConclusionDisplay,
tagType: reviewConclusionTagType
},
{ label: '审核人', value: rev.reviewByName || '—' },
{ label: '审核时间', value: rev.reviewTime || '—' },
{ label: '审核备注', value: rev.reviewRemark || '—', span: true }
]
}
]
})
function attachmentFullUrl(url: string) {
const u = String(url || '').trim()
if (!u) return ''
if (/^https?:\/\//i.test(u)) return u
return minioBaseUrl ? `${minioBaseUrl}/${u.replace(/^\//, '')}` : u
}
function handleAttachmentPreview(file: Record<string, unknown>) {
const url = attachmentFullUrl(String(file.fileUrl || ''))
if (url) window.open(url, '_blank')
}
function handleAttachmentDownload(file: Record<string, unknown>) {
downloadAttachmentFile(file, { fullFileUrl: attachmentFullUrl })
}
</script>
<style scoped lang="scss">
.view-empty-hint {
margin: 0;
font-size: 13px;
color: #94a3b8;
}
.qc-task-cards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 10px;
}
.qc-task-card {
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #fff;
overflow: hidden;
}
.qc-task-card__header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 10px 12px;
border-bottom: 1px solid #f1f5f9;
}
.qc-task-card__name {
font-size: 13px;
font-weight: 600;
color: #1e293b;
}
.qc-task-card__body {
padding: 10px 12px;
display: flex;
flex-direction: column;
gap: 8px;
}
.qc-kv {
display: flex;
align-items: flex-start;
gap: 8px;
font-size: 12px;
}
.qc-kv__label {
color: #94a3b8;
flex-shrink: 0;
min-width: 56px;
}
.qc-kv__value {
color: #1e293b;
font-weight: 500;
}
.qc-kv__muted {
color: #94a3b8;
font-weight: 400;
}
</style>