Files
zkxw/web-admin/src/views/pilot-service/checkup-management/CheckupViewDialog.vue
T
2026-05-26 19:04:27 +08:00

401 lines
11 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.
<!-- 体检管理 — 查看弹窗(SystemViewDialog 标准样式) -->
<template>
<SystemViewDialog
v-model:visible="innerVisible"
:title="viewData.patientName || '体检详情'"
:icon="Document"
:code="viewData.applicationNo"
code-label="申请单号"
:sections="sections"
:loading="loading"
:grid-columns="3"
width="1080px"
append-to-body
>
<template #reserve-items>
<div class="list-body list-wrap view-inner-table-wrap">
<el-table
v-if="reserveItems.length"
:data="reserveItems"
stripe
class="list-table inner-table"
max-height="320"
>
<el-table-column
type="index"
label="序号"
min-width="68"
align="center"
header-align="center"
/>
<el-table-column
prop="projectName"
label="项目名称"
min-width="200"
show-overflow-tooltip
/>
<el-table-column
label="项目费用(元)"
min-width="120"
align="right"
header-align="center"
>
<template #default="{ row }">
{{ row.projectFee != null ? `¥${formatMoneyDisplay(row.projectFee)}` : '—' }}
</template>
</el-table-column>
</el-table>
<el-empty v-else description="暂无预约项目" :image-size="48" />
<p v-if="reserveItems.length" class="view-table-summary">
预约费用合计:<strong>¥{{ formatMoneyDisplay(reserveTotal) }}</strong>
</p>
</div>
</template>
<template #actual-items>
<div class="list-body list-wrap view-inner-table-wrap">
<el-table
v-if="actualItems.length"
:data="actualItems"
stripe
class="list-table inner-table"
max-height="320"
>
<el-table-column
type="index"
label="序号"
min-width="68"
align="center"
header-align="center"
/>
<el-table-column
prop="projectName"
label="项目名称"
min-width="200"
show-overflow-tooltip
/>
<el-table-column
label="项目费用(元)"
min-width="120"
align="right"
header-align="center"
>
<template #default="{ row }">
{{ row.projectFee != null ? `¥${formatMoneyDisplay(row.projectFee)}` : '—' }}
</template>
</el-table-column>
</el-table>
<el-empty v-else description="暂无实际项目" :image-size="48" />
<p v-if="actualItems.length" class="view-table-summary">
实际费用合计:<strong>¥{{ formatMoneyDisplay(actualTotal) }}</strong>
</p>
</div>
</template>
<template #reports>
<div v-if="reportFiles.length" class="report-attachment-list">
<div
v-for="(file, idx) in reportFiles"
:key="file.url || idx"
class="report-attachment-item"
>
<div class="report-attachment-preview">
<img v-if="isImageUrl(file.url)" :src="fullFileUrl(file.url)" :alt="file.name" />
<div v-else class="report-attachment-preview__icon">
<el-icon :size="28"><Document /></el-icon>
</div>
</div>
<div class="report-attachment-footer">
<span class="report-attachment-name" :title="file.name">{{ file.name }}</span>
<el-button link type="primary" @click="downloadReport(file)">
<el-icon><Download /></el-icon>下载
</el-button>
</div>
</div>
</div>
<span v-else class="view-empty-hint">—</span>
</template>
</SystemViewDialog>
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { Document, Download } from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewSection,
type TagType
} from '@/components/business/system-view-dialog/index.vue'
import {
fetchPilotCheckupDetail,
fetchPilotCheckupReserveItems,
fetchPilotCheckupActualItems
} from '@/api/admin'
import {
checkupStatusLabel,
checkupStatusTagType,
feeStatusLabel,
feeStatusTagType,
sexLabel
} from '@/utils/status-tag-registry'
import { formatMoneyDisplay } from '@/utils/money-format'
const props = defineProps<{
modelValue: boolean
checkupRow: Record<string, any> | null
}>()
const emit = defineEmits(['update:modelValue'])
const innerVisible = computed({
get: () => props.modelValue,
set: (v: boolean) => emit('update:modelValue', v)
})
const loading = ref(false)
const viewData = ref<Record<string, any>>({})
const reserveItems = ref<any[]>([])
const actualItems = ref<any[]>([])
const reserveTotal = computed(() =>
reserveItems.value.reduce((s, i) => s + (Number(i.projectFee) || 0), 0)
)
const actualTotal = computed(() =>
actualItems.value.reduce((s, i) => s + (Number(i.projectFee) || 0), 0)
)
const formatFee = (val: number | null | undefined) =>
val != null ? `¥${formatMoneyDisplay(val)}` : '—'
const sections = computed((): ViewSection[] => {
const row = viewData.value
if (!row?.id) return []
return [
{
title: '基本信息',
fields: [
{ label: '申请单号', value: row.applicationNo },
{ label: '患者姓名', value: row.patientName },
{ label: '性别', value: sexLabel(row.sex) || '—' },
{ label: '年龄', value: row.age != null ? String(row.age) : undefined },
{ label: '联系电话', value: row.phoneNo },
{ label: '渠道名称', value: row.channelName },
{ label: '体检机构', value: row.institutionName },
{ label: '预约时间', value: row.reserveTime },
{ label: '预约费用', value: formatFee(row.reserveFee) },
{ label: '实际费用', value: formatFee(row.actualCheckupFee) },
{
label: '体检状态',
value: checkupStatusLabel(row.checkupStatus),
tagType: checkupStatusTagType(row.checkupStatus) as TagType
},
{
label: '费用状态',
value: feeStatusLabel(row.feeStatus),
tagType: feeStatusTagType(row.feeStatus) as TagType
}
]
},
{
title: '预约项目',
fields: [],
slot: 'reserve-items'
},
{
title: '实际项目',
fields: [],
slot: 'actual-items'
},
{
title: '体检登记',
fields: [
{ label: '实际体检时间', value: row.actualCheckupTime || undefined },
{ label: '体检备注', value: row.checkupRemark || row.remark, span: true }
]
},
{
title: '体检报告',
fields: [],
slot: 'reports'
}
]
})
const parseAttachmentUrls = (urls: string) => {
if (!urls) return []
return urls
.split(',')
.filter(Boolean)
.map((url) => {
const parts = url.split('/')
const name = decodeURIComponent(parts[parts.length - 1] || '附件')
return { name, url }
})
}
const reportFiles = computed(() => parseAttachmentUrls(viewData.value.reportAttachments || ''))
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
function fullFileUrl(suffix: string) {
if (!suffix) return ''
if (suffix.startsWith('http://') || suffix.startsWith('https://') || suffix.startsWith('/')) {
return suffix
}
return `${minioBaseUrl}/${suffix}`
}
const isImageUrl = (url: string) => {
const u = (url || '').toLowerCase()
return /\.(jpg|jpeg|png|gif|bmp|webp|svg)(\?|$)/.test(u)
}
const downloadReport = (file: { name: string; url: string }) => {
const link = document.createElement('a')
link.href = fullFileUrl(file.url)
link.download = file.name
link.target = '_blank'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
const loadDetail = async () => {
const id = props.checkupRow?.id
if (!id) return
viewData.value = { ...(props.checkupRow || {}) }
loading.value = true
try {
const [detailRes, reserveRes, actualRes]: any[] = await Promise.all([
fetchPilotCheckupDetail({ checkupId: id }),
fetchPilotCheckupReserveItems({ pilotCheckupId: id }),
fetchPilotCheckupActualItems({ pilotCheckupId: id })
])
const detail = detailRes?.data ?? detailRes ?? {}
viewData.value = { ...viewData.value, ...detail }
reserveItems.value = Array.isArray(reserveRes) ? reserveRes : (reserveRes?.list ?? [])
actualItems.value = Array.isArray(actualRes) ? actualRes : (actualRes?.list ?? [])
} catch {
reserveItems.value = []
actualItems.value = []
} finally {
loading.value = false
}
}
watch(
() => props.modelValue,
(val) => {
if (val && props.checkupRow?.id) {
loadDetail()
} else if (!val) {
viewData.value = {}
reserveItems.value = []
actualItems.value = []
}
}
)
</script>
<style lang="scss" scoped>
.view-inner-table-wrap.list-body.list-wrap {
margin-top: 4px;
border: 1px solid var(--mint-border, #e2e8f0);
border-radius: var(--mint-radius, 10px);
overflow: hidden;
background: #fff;
:deep(.el-table) {
--el-table-header-bg-color: var(--mint-table-head, #f8fafc);
--el-table-border-color: var(--mint-border, #e2e8f0);
--el-table-row-hover-bg-color: var(--mint-row-hover, #f0fdf4);
--el-table-text-color: var(--mint-text, #0f172a);
--el-table-header-text-color: var(--mint-text-muted, #64748b);
font-size: 14px;
}
:deep(.el-table th.el-table__cell) {
font-size: 12px;
font-weight: 600;
color: var(--mint-text-muted, #64748b);
}
:deep(.el-table td.el-table__cell) {
font-size: 14px;
font-weight: 500;
color: var(--mint-text, #0f172a);
}
:deep(.el-empty) {
padding: 24px 0;
}
}
.view-table-summary {
margin: 10px 0 0;
padding: 10px 12px;
font-size: 13px;
color: #64748b;
background: #f8fafc;
border-radius: 8px;
border: 1px solid #e2e8f0;
strong {
color: #059669;
font-weight: 600;
}
}
.view-empty-hint {
font-size: 13px;
color: #94a3b8;
}
.report-attachment-list {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.report-attachment-item {
width: 140px;
border: 1px solid #e2e8f0;
border-radius: 8px;
overflow: hidden;
background: #fff;
}
.report-attachment-preview {
width: 100%;
height: 96px;
display: flex;
align-items: center;
justify-content: center;
background: #f8fafc;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
&__icon {
color: #0284c7;
background: #e0f2fe;
width: 48px;
height: 48px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
}
}
.report-attachment-footer {
padding: 6px 8px;
display: flex;
flex-direction: column;
gap: 4px;
align-items: center;
}
.report-attachment-name {
font-size: 11px;
color: #334155;
text-align: center;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>