2026-01-22 17:39:23 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<!-- 详情页参考截图:顶部蓝条显示创建信息,支持编辑/删除;黄底提示不渲染 -->
|
|
|
|
|
|
<view class="page">
|
|
|
|
|
|
<view class="topbar">
|
|
|
|
|
|
<view class="topbar-text">{{ topText }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="content">
|
|
|
|
|
|
<view class="section">
|
|
|
|
|
|
<view class="row">
|
|
|
|
|
|
<view class="label">病历类型</view>
|
|
|
|
|
|
<view class="value">{{ typeLabel }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="row">
|
|
|
|
|
|
<view class="label">就诊日期</view>
|
|
|
|
|
|
<view class="value">{{ visitDate || '--' }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="row">
|
|
|
|
|
|
<view class="label">诊断</view>
|
|
|
|
|
|
<view class="value">{{ diagnosisText }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view v-if="templateType === 'inhospital' && record.surgeryName" class="row">
|
|
|
|
|
|
<view class="label">手术名称</view>
|
|
|
|
|
|
<view class="value">{{ record.surgeryName }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view v-for="(s, idx) in sections" :key="idx" class="section">
|
|
|
|
|
|
<view class="h2">{{ s.title }}</view>
|
|
|
|
|
|
<view class="p">{{ s.value }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="section">
|
|
|
|
|
|
<view class="h2">文件上传</view>
|
|
|
|
|
|
<view v-if="files.length" class="files">
|
|
|
|
|
|
<view v-for="(f, idx) in files" :key="idx" class="file" @click="preview(idx)">
|
|
|
|
|
|
<image class="thumb" :src="f.url" mode="aspectFill" />
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view v-else class="files-empty">暂无附件</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="footer">
|
|
|
|
|
|
<button class="btn danger" @click="remove">删除</button>
|
|
|
|
|
|
<button class="btn primary" @click="edit">编辑</button>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
|
|
|
|
import dayjs from 'dayjs';
|
2026-01-27 16:46:36 +08:00
|
|
|
|
import api from '@/utils/api';
|
|
|
|
|
|
import { loading, hideLoading, toast } from '@/utils/widget';
|
|
|
|
|
|
import { getVisitRecordTemplate } from '@/components/archive-detail/templates';
|
2026-01-22 17:39:23 +08:00
|
|
|
|
|
|
|
|
|
|
const archiveId = ref('');
|
|
|
|
|
|
const id = ref('');
|
2026-01-27 16:46:36 +08:00
|
|
|
|
const medicalType = ref('');
|
2026-01-22 17:39:23 +08:00
|
|
|
|
const record = ref({});
|
|
|
|
|
|
|
|
|
|
|
|
const files = computed(() => {
|
|
|
|
|
|
const arr = record.value?.files;
|
|
|
|
|
|
return Array.isArray(arr) ? arr.filter((i) => i && i.url) : [];
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const templateType = computed(() => record.value?.templateType || record.value?.medicalType || '');
|
|
|
|
|
|
|
2026-01-27 16:46:36 +08:00
|
|
|
|
const typeLabel = computed(() => record.value?.tempName || getVisitRecordTemplate(templateType.value || medicalType.value)?.templateName || '病历');
|
|
|
|
|
|
|
|
|
|
|
|
function normalizeText(v) {
|
|
|
|
|
|
if (Array.isArray(v)) return v.filter((i) => i !== null && i !== undefined && String(i).trim()).join(',');
|
|
|
|
|
|
if (v === 0) return '0';
|
|
|
|
|
|
return v ? String(v) : '';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function formatPositiveFind(v, { withOpinion = false } = {}) {
|
|
|
|
|
|
if (Array.isArray(v)) {
|
|
|
|
|
|
const list = v
|
|
|
|
|
|
.map((i) => (i && typeof i === 'object' ? { category: i.category, opinion: i.opinion } : null))
|
|
|
|
|
|
.filter((i) => i && (i.category || i.opinion));
|
|
|
|
|
|
if (!list.length) return '';
|
|
|
|
|
|
if (!withOpinion) return list.map((i) => String(i.category || '').trim()).filter(Boolean).join(':');
|
|
|
|
|
|
return list
|
|
|
|
|
|
.map((i) => {
|
|
|
|
|
|
const c = String(i.category || '').trim();
|
|
|
|
|
|
const o = String(i.opinion || '').trim();
|
|
|
|
|
|
if (c && o) return `${c}:${o}`;
|
|
|
|
|
|
return c || o;
|
|
|
|
|
|
})
|
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
|
.join('\n');
|
|
|
|
|
|
}
|
|
|
|
|
|
return normalizeText(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getCorpId() {
|
|
|
|
|
|
const team = uni.getStorageSync('ykt_case_current_team') || {};
|
|
|
|
|
|
return team?.corpId ? String(team.corpId) : '';
|
|
|
|
|
|
}
|
2026-01-22 17:39:23 +08:00
|
|
|
|
|
|
|
|
|
|
const visitDate = computed(() => {
|
|
|
|
|
|
const t = templateType.value;
|
|
|
|
|
|
if (t === 'outpatient') return record.value?.visitTime || '';
|
|
|
|
|
|
if (t === 'inhospital') return record.value?.inhosDate || '';
|
|
|
|
|
|
if (t === 'preConsultation') return record.value?.consultDate || '';
|
|
|
|
|
|
if (t === 'physicalExaminationTemplate') return record.value?.inspectDate || '';
|
|
|
|
|
|
return record.value?.dateStr || '';
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const diagnosisText = computed(() => {
|
|
|
|
|
|
const t = templateType.value;
|
2026-01-27 16:46:36 +08:00
|
|
|
|
if (t === 'preConsultation') return normalizeText(record.value?.chiefComplaint) || normalizeText(record.value?.summary) || '--';
|
|
|
|
|
|
if (t === 'physicalExaminationTemplate') return formatPositiveFind(record.value?.positiveFind) || normalizeText(record.value?.summary) || '--';
|
|
|
|
|
|
if (t === 'outpatient' || t === 'inhospital') return normalizeText(record.value?.diagnosisName || record.value?.diagnosis) || normalizeText(record.value?.summary) || '--';
|
|
|
|
|
|
return normalizeText(record.value?.diagnosisName || record.value?.diagnosis || record.value?.summary) || '--';
|
2026-01-22 17:39:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const sections = computed(() => {
|
|
|
|
|
|
const t = templateType.value;
|
|
|
|
|
|
const push = (title, value) => {
|
|
|
|
|
|
const v = value === 0 ? '0' : value ? String(value) : '';
|
|
|
|
|
|
if (!v.trim()) return;
|
|
|
|
|
|
return { title, value: v };
|
|
|
|
|
|
};
|
|
|
|
|
|
const list = [];
|
|
|
|
|
|
if (t === 'outpatient') {
|
|
|
|
|
|
const corp = push('就诊机构', record.value?.corpName);
|
|
|
|
|
|
const dept = push('科室', record.value?.deptName);
|
|
|
|
|
|
const doctor = push('医生', record.value?.doctor);
|
|
|
|
|
|
const treatment = push('治疗方案', record.value?.treatmentPlan);
|
|
|
|
|
|
const dispose = push('处置计划', record.value?.disposePlan);
|
|
|
|
|
|
const summary = push('备注/摘要', record.value?.summary);
|
|
|
|
|
|
[corp, dept, doctor, treatment, dispose, summary].forEach((i) => i && list.push(i));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (t === 'inhospital') {
|
|
|
|
|
|
const corp = push('住院机构', record.value?.corpName);
|
|
|
|
|
|
const summary = push('摘要', record.value?.summary);
|
|
|
|
|
|
[corp, summary].forEach((i) => i && list.push(i));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (t === 'preConsultation') {
|
|
|
|
|
|
const illness = push('现病史', record.value?.presentIllness);
|
|
|
|
|
|
const past = push('既往史', record.value?.pastHistory);
|
|
|
|
|
|
const allergy = push('过敏史', record.value?.allergyHistory);
|
|
|
|
|
|
const summary = push('摘要', record.value?.summary);
|
|
|
|
|
|
[illness, past, allergy, summary].forEach((i) => i && list.push(i));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (t === 'physicalExaminationTemplate') {
|
|
|
|
|
|
const corp = push('体检机构', record.value?.corpName);
|
|
|
|
|
|
const pkg = push('体检套餐', record.value?.inspectPakageName);
|
2026-01-27 16:46:36 +08:00
|
|
|
|
const positive = push('阳性发现及处理意见', formatPositiveFind(record.value?.positiveFind, { withOpinion: true }));
|
2026-01-22 17:39:23 +08:00
|
|
|
|
const summary = push('摘要', record.value?.summary);
|
|
|
|
|
|
[corp, pkg, positive, summary].forEach((i) => i && list.push(i));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
const summary = push('摘要', record.value?.summary);
|
|
|
|
|
|
if (summary) list.push(summary);
|
|
|
|
|
|
return list;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const topText = computed(() => {
|
|
|
|
|
|
const time = record.value?.createTime ? dayjs(record.value.createTime).format('YYYY-MM-DD HH:mm') : '';
|
2026-01-27 16:46:36 +08:00
|
|
|
|
const rawName = record.value?.creatorName ? String(record.value.creatorName) : '';
|
|
|
|
|
|
const cleanName = ['-', '—', '--'].includes(rawName.trim()) ? '' : rawName.trim();
|
|
|
|
|
|
const byCustomer = record.value?.ignore === 'checkIn';
|
|
|
|
|
|
const suffix = byCustomer ? '患者自建' : cleanName ? `${cleanName}代建` : record.value?.creator ? '员工代建' : '';
|
|
|
|
|
|
return suffix ? `${time || '--'} ${suffix}` : `${time || '--'}`;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-01-27 16:46:36 +08:00
|
|
|
|
onLoad(async (opt) => {
|
2026-01-22 17:39:23 +08:00
|
|
|
|
archiveId.value = opt?.archiveId ? String(opt.archiveId) : '';
|
|
|
|
|
|
id.value = opt?.id ? String(opt.id) : '';
|
2026-01-27 16:46:36 +08:00
|
|
|
|
medicalType.value = opt?.type ? String(opt.type) : '';
|
|
|
|
|
|
if (!archiveId.value || !id.value || !medicalType.value) {
|
|
|
|
|
|
toast('参数缺失');
|
2026-01-22 17:39:23 +08:00
|
|
|
|
setTimeout(() => uni.navigateBack(), 300);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-01-27 16:46:36 +08:00
|
|
|
|
|
|
|
|
|
|
// 使用真实 API 获取病历记录
|
|
|
|
|
|
loading('加载中...');
|
|
|
|
|
|
try {
|
|
|
|
|
|
const corpId = getCorpId();
|
|
|
|
|
|
if (!corpId) {
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
toast('缺少 corpId');
|
|
|
|
|
|
setTimeout(() => uni.navigateBack(), 300);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const res = await api('getMedicalRecordById', {
|
|
|
|
|
|
_id: id.value,
|
|
|
|
|
|
corpId,
|
|
|
|
|
|
memberId: archiveId.value,
|
|
|
|
|
|
medicalType: medicalType.value,
|
|
|
|
|
|
});
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
const r = res?.record || res?.data?.record || null;
|
|
|
|
|
|
if (!res?.success || !r) {
|
|
|
|
|
|
toast('记录不存在');
|
|
|
|
|
|
setTimeout(() => uni.navigateBack(), 300);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 兼容模板字段:wxapp 使用 diagnosis,但接口通常返回 diagnosisName
|
|
|
|
|
|
if ((r.medicalType === 'outpatient' || r.medicalType === 'inhospital') && !r.diagnosis && r.diagnosisName) {
|
|
|
|
|
|
r.diagnosis = r.diagnosisName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
record.value = r;
|
|
|
|
|
|
uni.setNavigationBarTitle({ title: String(typeLabel.value || '病历详情') });
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
console.error('获取病历记录失败:', error);
|
|
|
|
|
|
toast('加载失败');
|
2026-01-22 17:39:23 +08:00
|
|
|
|
setTimeout(() => uni.navigateBack(), 300);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function preview(idx) {
|
|
|
|
|
|
const urls = files.value.map((i) => i.url);
|
|
|
|
|
|
uni.previewImage({ urls, current: urls[idx] });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function edit() {
|
|
|
|
|
|
const type = record.value?.templateType || record.value?.medicalType || '';
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/case/visit-record-detail?archiveId=${encodeURIComponent(archiveId.value)}&id=${encodeURIComponent(id.value)}&type=${encodeURIComponent(type)}`,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function remove() {
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '提示',
|
|
|
|
|
|
content: '确定删除当前记录?',
|
2026-01-27 16:46:36 +08:00
|
|
|
|
success: async (res) => {
|
2026-01-22 17:39:23 +08:00
|
|
|
|
if (!res.confirm) return;
|
2026-01-27 16:46:36 +08:00
|
|
|
|
|
|
|
|
|
|
loading('删除中...');
|
|
|
|
|
|
try {
|
|
|
|
|
|
const corpId = getCorpId();
|
|
|
|
|
|
if (!corpId) {
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
return toast('缺少 corpId');
|
|
|
|
|
|
}
|
|
|
|
|
|
await api('removeMedicalRecord', { corpId, memberId: archiveId.value, medicalType: medicalType.value, _id: id.value });
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
uni.$emit('archive-detail:visit-record-changed');
|
|
|
|
|
|
toast('已删除');
|
|
|
|
|
|
setTimeout(() => uni.navigateBack(), 300);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
hideLoading();
|
|
|
|
|
|
console.error('删除病历记录失败:', error);
|
|
|
|
|
|
toast('删除失败');
|
|
|
|
|
|
}
|
2026-01-22 17:39:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.page {
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
background: #fff;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding-bottom: calc(152rpx + env(safe-area-inset-bottom));
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.topbar {
|
|
|
|
|
|
background: #5d6df0;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 20rpx 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.topbar-text {
|
|
|
|
|
|
color: #fff;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
font-size: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
.content {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 28rpx 28rpx 0;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.section {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
margin-bottom: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.row {
|
|
|
|
|
|
display: flex;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 20rpx 0;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.label {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
width: 180rpx;
|
|
|
|
|
|
font-size: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #111827;
|
|
|
|
|
|
}
|
|
|
|
|
|
.value {
|
|
|
|
|
|
flex: 1;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
font-size: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
color: #111827;
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
}
|
|
|
|
|
|
.h2 {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
font-size: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
color: #111827;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 16rpx 0;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.p {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
font-size: 28rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
color: #111827;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
line-height: 40rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
white-space: pre-wrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
.files {
|
|
|
|
|
|
display: flex;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
gap: 20rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
.file {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
width: 180rpx;
|
|
|
|
|
|
height: 140rpx;
|
|
|
|
|
|
border: 2rpx solid #d1d5db;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
background: #f9fafb;
|
|
|
|
|
|
}
|
|
|
|
|
|
.thumb {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
width: 180rpx;
|
|
|
|
|
|
height: 140rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.files-empty {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
font-size: 26rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
color: #9aa0a6;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 16rpx 0;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.footer {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
background: #fff;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
padding: 24rpx 28rpx calc(24rpx + env(safe-area-inset-bottom));
|
2026-01-22 17:39:23 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
gap: 28rpx;
|
|
|
|
|
|
box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.btn {
|
2026-01-28 20:01:28 +08:00
|
|
|
|
width: 240rpx;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
line-height: 88rpx;
|
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
|
font-size: 30rpx;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.btn::after {
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
.btn.danger {
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
color: #ff4d4f;
|
2026-01-28 20:01:28 +08:00
|
|
|
|
border: 2rpx solid #ff4d4f;
|
2026-01-22 17:39:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
.btn.primary {
|
|
|
|
|
|
background: #4f6ef7;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|