fix(core): 修复审计字段缺失和组件状态管理问题

- 在Account、ChargeItem、EncounterParticipant和Encounter服务中添加审计字段验证
- 确保tenantId、createBy和createTime字段在插入数据库前正确设置
- 修复EMR模块中删除模板API的导出问题
- 更新患者信息状态管理,统一使用localPatientInfo替换patientInfo
- 在EMR组件中实现防抖机制优化历史记录刷新性能
- 修复病历模板切换时的表单数据重置逻辑
- 在首页统计组件中使用markRaw包装图标组件
- 为住院记录模板添加默认表单数据结构
- 修复SVG患者图标路径错误
This commit is contained in:
2026-01-25 16:41:19 +08:00
parent 6382741b71
commit 5cf2dd165c
17 changed files with 493 additions and 116 deletions

View File

@@ -438,7 +438,7 @@
:show-overflow-tooltip="true"
/>
<el-table-column
label="挂号类型 "
label="*挂号类型 "
align="center"
key="healthcareName"
prop="healthcareName"
@@ -734,6 +734,7 @@ const data = reactive({
priorityEnum: [{ required: true, message: '优先级不能为空', trigger: 'blur' }],
organizationId: [{ required: true, message: '优先级不能为空', trigger: 'blur' }],
orgId: [{ required: true, message: '就诊科室不能为空', trigger: 'blur' }],
serviceTypeId: [{ required: true, message: '挂号类型不能为空', trigger: 'blur' }],
practitionerId: [{ required: true, message: '医生不能为空', trigger: 'blur' }],
typeCode: [{ required: true, message: '账户类型不能为空', trigger: 'blur' }],
definitionId: [{ required: true, message: '费用定价不能为空', trigger: 'blur' }],

View File

@@ -26,9 +26,9 @@
</template>
<script setup>
import {defineEmits, ref, unref} from 'vue';
import {defineEmits, ref, unref, watch} from 'vue';
import {deleteTemplate, getListByDefinitionId} from '../api';
import {ElMessage} from 'element-plus';
import {ElMessage, ElMessageBox} from 'element-plus';
const emits = defineEmits(['templateClick', 'edit']);
const props = defineProps({
@@ -45,26 +45,54 @@ const defaultProps = {
children: 'children',
label: 'name',
};
// 缓存已加载的模板数据
const templateCache = new Map();
const queryParams = ref({
searchKey: '',
isPage: 0,
});
const templateData = ref([]);
// 防抖定时器
let debounceTimer = null;
// 删除模板
const handleDelete = async (item) => {
try {
await deleteTemplate(item.id);
ElMessage.success('删除成功');
queryList();
ElMessageBox.confirm('确定要删除该模板吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
await deleteTemplate(item.id);
ElMessage.success('删除成功');
// 清除缓存中的数据,强制重新加载
templateCache.delete(unref(definitionId));
queryList();
});
} catch (error) {
ElMessage.error('删除失败');
if (error !== 'cancel') {
ElMessage.error('删除失败');
}
}
};
const queryList = async () => {
try {
if (unref(definitionId) && unref(definitionId) !== '') {
const res = await getListByDefinitionId(unref(definitionId));
templateData.value = res.data || [];
const id = unref(definitionId);
if (id && id !== '') {
// 检查缓存中是否存在数据
if (templateCache.has(id)) {
templateData.value = templateCache.get(id);
return;
}
const res = await getListByDefinitionId(id);
const data = res.data || [];
// 将数据存入缓存
templateCache.set(id, data);
templateData.value = data;
} else {
templateData.value = [];
}
@@ -73,6 +101,23 @@ const queryList = async () => {
templateData.value = [];
}
};
// 防抖版本的查询函数
const debouncedQueryList = async () => {
if (debounceTimer) {
clearTimeout(debounceTimer);
}
debounceTimer = setTimeout(async () => {
await queryList();
}, 300); // 300ms 防抖延迟
};
// 监听 definitionId 变化,使用防抖
watch(definitionId, () => {
debouncedQueryList();
}, { immediate: true });
const handleNodeClick = (data) => {
emits('templateClick', data);
};

View File

@@ -125,6 +125,7 @@
<script setup name="Home">
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { markRaw } from 'vue'
import useUserStore from '@/store/modules/user'
import { getHomeStatistics } from '@/api/home'
import {
@@ -171,90 +172,90 @@ const statisticsData = ref({
// 不同角色的统计数据配置
const roleStatsConfig = {
admin: [
{ key: 'totalPatients', label: '在院患者', icon: User, type: 'primary', iconColor: '#409eff' },
{ key: 'todayRevenue', label: '今日收入', icon: Money, type: 'success', iconColor: '#67c23a' },
{ key: 'appointments', label: '今日预约', icon: Calendar, type: 'warning', iconColor: '#e6a23c' },
{ key: 'pendingApprovals', label: '待审核', icon: Document, type: 'danger', iconColor: '#f56c6c' }
{ key: 'totalPatients', label: '在院患者', icon: markRaw(User), type: 'primary', iconColor: '#409eff' },
{ key: 'todayRevenue', label: '今日收入', icon: markRaw(Money), type: 'success', iconColor: '#67c23a' },
{ key: 'appointments', label: '今日预约', icon: markRaw(Calendar), type: 'warning', iconColor: '#e6a23c' },
{ key: 'pendingApprovals', label: '待审核', icon: markRaw(Document), type: 'danger', iconColor: '#f56c6c' }
],
doctor: [
{ key: 'myPatients', label: '我的患者', icon: User, type: 'primary', iconColor: '#409eff' },
{ key: 'todayAppointments', label: '今日门诊', icon: Calendar, type: 'success', iconColor: '#67c23a' },
{ key: 'pendingRecords', label: '待写病历', icon: Document, type: 'warning', iconColor: '#e6a23c' },
{ key: 'prescriptions', label: '今日处方', icon: Box, type: 'info', iconColor: '#909399' }
{ key: 'myPatients', label: '我的患者', icon: markRaw(User), type: 'primary', iconColor: '#409eff' },
{ key: 'todayAppointments', label: '今日门诊', icon: markRaw(Calendar), type: 'success', iconColor: '#67c23a' },
{ key: 'pendingRecords', label: '待写病历', icon: markRaw(Document), type: 'warning', iconColor: '#e6a23c' },
{ key: 'prescriptions', label: '今日处方', icon: markRaw(Box), type: 'info', iconColor: '#909399' }
],
nurse: [
{ key: 'wardPatients', label: '病房患者', icon: User, type: 'primary', iconColor: '#409eff' },
{ key: 'todayTreatments', label: '今日治疗', icon: Operation, type: 'success', iconColor: '#67c23a' },
{ key: 'vitalSigns', label: '待测体征', icon: Monitor, type: 'warning', iconColor: '#e6a23c' },
{ key: 'drugDistribution', label: '发药次数', icon: Box, type: 'info', iconColor: '#909399' }
{ key: 'wardPatients', label: '病房患者', icon: markRaw(User), type: 'primary', iconColor: '#409eff' },
{ key: 'todayTreatments', label: '今日治疗', icon: markRaw(Operation), type: 'success', iconColor: '#67c23a' },
{ key: 'vitalSigns', label: '待测体征', icon: markRaw(Monitor), type: 'warning', iconColor: '#e6a23c' },
{ key: 'drugDistribution', label: '发药次数', icon: markRaw(Box), type: 'info', iconColor: '#909399' }
],
pharmacist: [
{ key: 'todayPrescriptions', label: '今日处方', icon: Box, type: 'primary', iconColor: '#409eff' },
{ key: 'pendingReview', label: '待审核', icon: Document, type: 'warning', iconColor: '#e6a23c' },
{ key: 'outOfStock', label: '缺货药品', icon: Warning, type: 'danger', iconColor: '#f56c6c' },
{ key: 'nearExpiry', label: '近效期', icon: Clock, type: 'info', iconColor: '#909399' }
{ key: 'todayPrescriptions', label: '今日处方', icon: markRaw(Box), type: 'primary', iconColor: '#409eff' },
{ key: 'pendingReview', label: '待审核', icon: markRaw(Document), type: 'warning', iconColor: '#e6a23c' },
{ key: 'outOfStock', label: '缺货药品', icon: markRaw(Warning), type: 'danger', iconColor: '#f56c6c' },
{ key: 'nearExpiry', label: '近效期', icon: markRaw(Clock), type: 'info', iconColor: '#909399' }
],
cashier: [
{ key: 'todayPayments', label: '今日缴费', icon: Money, type: 'primary', iconColor: '#409eff' },
{ key: 'refundRequests', label: '退费申请', icon: Document, type: 'warning', iconColor: '#e6a23c' },
{ key: 'pendingInvoices', label: '待开发票', icon: Files, type: 'info', iconColor: '#909399' },
{ key: 'insuranceClaims', label: '医保结算', icon: Wallet, type: 'success', iconColor: '#67c23a' }
{ key: 'todayPayments', label: '今日缴费', icon: markRaw(Money), type: 'primary', iconColor: '#409eff' },
{ key: 'refundRequests', label: '退费申请', icon: markRaw(Document), type: 'warning', iconColor: '#e6a23c' },
{ key: 'pendingInvoices', label: '待开发票', icon: markRaw(Files), type: 'info', iconColor: '#909399' },
{ key: 'insuranceClaims', label: '医保结算', icon: markRaw(Wallet), type: 'success', iconColor: '#67c23a' }
]
}
// 不同角色的快捷功能配置
const roleQuickAccessConfig = {
admin: [
{ key: 'patient', label: '患者管理', icon: User, iconColor: '#409eff', route: '/patientmanagement' },
{ key: 'appointment', label: '预约管理', icon: Calendar, iconColor: '#67c23a', route: '/appoinmentmanage' },
{ key: 'doctor', label: '医生管理', icon: User, iconColor: '#e6a23c', route: '/doctorstation' },
{ key: 'surgery', label: '手术管理', icon: Operation, iconColor: '#f56c6c', route: '/surgerymanage' },
{ key: 'drug', label: '药品管理', icon: Box, iconColor: '#909399', route: '/pharmacymanagement' },
{ key: 'statistic', label: '数据统计', icon: TrendCharts, iconColor: '#409eff', route: '/monitor' },
{ key: 'invoice', label: '发票管理', icon: Files, iconColor: '#67c23a', route: '/basicmanage/InvoiceManagement' },
{ key: 'system', label: '系统设置', icon: Setting, iconColor: '#909399', route: '/system' }
{ key: 'patient', label: '患者管理', icon: markRaw(User), iconColor: '#409eff', route: '/patientmanagement' },
{ key: 'appointment', label: '预约管理', icon: markRaw(Calendar), iconColor: '#67c23a', route: '/appoinmentmanage' },
{ key: 'doctor', label: '医生管理', icon: markRaw(User), iconColor: '#e6a23c', route: '/doctorstation' },
{ key: 'surgery', label: '手术管理', icon: markRaw(Operation), iconColor: '#f56c6c', route: '/surgerymanage' },
{ key: 'drug', label: '药品管理', icon: markRaw(Box), iconColor: '#909399', route: '/pharmacymanagement' },
{ key: 'statistic', label: '数据统计', icon: markRaw(TrendCharts), iconColor: '#409eff', route: '/monitor' },
{ key: 'invoice', label: '发票管理', icon: markRaw(Files), iconColor: '#67c23a', route: '/basicmanage/InvoiceManagement' },
{ key: 'system', label: '系统设置', icon: markRaw(Setting), iconColor: '#909399', route: '/system' }
],
doctor: [
{ key: 'outpatient', label: '门诊接诊', icon: ChatDotRound, iconColor: '#409eff', route: '/doctorstation' },
{ key: 'emr', label: '病历管理', icon: Document, iconColor: '#67c23a', route: '/doctorstation/doctorphrase' },
{ key: 'prescription', label: '开立处方', icon: Box, iconColor: '#e6a23c', route: '/clinicmanagement/ePrescribing' },
{ key: 'history', label: '历史处方', icon: Clock, iconColor: '#f56c6c', route: '/clinicmanagement/historicalPrescription' },
{ key: 'schedule', label: '排班管理', icon: Calendar, iconColor: '#909399', route: '/appoinmentmanage/deptManage' },
{ key: 'inquiry', label: '患者查询', icon: Search, iconColor: '#409eff', route: '/patientmanagement' }
{ key: 'outpatient', label: '门诊接诊', icon: markRaw(ChatDotRound), iconColor: '#409eff', route: '/doctorstation' },
{ key: 'emr', label: '病历管理', icon: markRaw(Document), iconColor: '#67c23a', route: '/doctorstation/doctorphrase' },
{ key: 'prescription', label: '开立处方', icon: markRaw(Box), iconColor: '#e6a23c', route: '/clinicmanagement/ePrescribing' },
{ key: 'history', label: '历史处方', icon: markRaw(Clock), iconColor: '#f56c6c', route: '/clinicmanagement/historicalPrescription' },
{ key: 'schedule', label: '排班管理', icon: markRaw(Calendar), iconColor: '#909399', route: '/appoinmentmanage/deptManage' },
{ key: 'inquiry', label: '患者查询', icon: markRaw(Search), iconColor: '#409eff', route: '/patientmanagement' }
],
nurse: [
{ key: 'ward', label: '病房管理', icon: User, iconColor: '#409eff', route: '/inpatientNurse/inpatientNurseStation' },
{ key: 'execution', label: '医嘱执行', icon: Operation, iconColor: '#67c23a', route: '/inpatientNurse/medicalOrderExecution' },
{ key: 'proofread', label: '医嘱核对', icon: Document, iconColor: '#e6a23c', route: '/inpatientNurse/medicalOrderProofread' },
{ key: 'drugCollect', label: '领药管理', icon: Box, iconColor: '#f56c6c', route: '/inpatientNurse/medicineCollect' },
{ key: 'tpr', label: '体温单', icon: Monitor, iconColor: '#909399', route: '/inpatientNurse/tprsheet' },
{ key: 'nursing', label: '护理记录', icon: ChatDotRound, iconColor: '#409eff', route: '/inpatientNurse/nursingRecord' }
{ key: 'ward', label: '病房管理', icon: markRaw(User), iconColor: '#409eff', route: '/inpatientNurse/inpatientNurseStation' },
{ key: 'execution', label: '医嘱执行', icon: markRaw(Operation), iconColor: '#67c23a', route: '/inpatientNurse/medicalOrderExecution' },
{ key: 'proofread', label: '医嘱核对', icon: markRaw(Document), iconColor: '#e6a23c', route: '/inpatientNurse/medicalOrderProofread' },
{ key: 'drugCollect', label: '领药管理', icon: markRaw(Box), iconColor: '#f56c6c', route: '/inpatientNurse/medicineCollect' },
{ key: 'tpr', label: '体温单', icon: markRaw(Monitor), iconColor: '#909399', route: '/inpatientNurse/tprsheet' },
{ key: 'nursing', label: '护理记录', icon: markRaw(ChatDotRound), iconColor: '#409eff', route: '/inpatientNurse/nursingRecord' }
],
pharmacist: [
{ key: 'dispensing', label: '发药管理', icon: Box, iconColor: '#409eff', route: '/pharmacymanagement' },
{ key: 'prescription', label: '处方审核', icon: Document, iconColor: '#67c23a', route: '/pharmacymanagement' },
{ key: 'inventory', label: '库存管理', icon: Van, iconColor: '#e6a23c', route: '/medicineStorage' },
{ key: 'purchase', label: '采购管理', icon: ShoppingCart, iconColor: '#f56c6c', route: '/medicineStorage' },
{ key: 'warning', label: '效期预警', icon: Warning, iconColor: '#f56c6c', route: '/medicationmanagement/statisticalManagement/statisticalManagement' },
{ key: 'statistics', label: '用药统计', icon: DataLine, iconColor: '#909399', route: '/monitor' }
{ key: 'dispensing', label: '发药管理', icon: markRaw(Box), iconColor: '#409eff', route: '/pharmacymanagement' },
{ key: 'prescription', label: '处方审核', icon: markRaw(Document), iconColor: '#67c23a', route: '/pharmacymanagement' },
{ key: 'inventory', label: '库存管理', icon: markRaw(Van), iconColor: '#e6a23c', route: '/medicineStorage' },
{ key: 'purchase', label: '采购管理', icon: markRaw(ShoppingCart), iconColor: '#f56c6c', route: '/medicineStorage' },
{ key: 'warning', label: '效期预警', icon: markRaw(Warning), iconColor: '#f56c6c', route: '/medicationmanagement/statisticalManagement/statisticalManagement' },
{ key: 'statistics', label: '用药统计', icon: markRaw(DataLine), iconColor: '#909399', route: '/monitor' }
],
cashier: [
{ key: 'registration', label: '挂号收费', icon: Money, iconColor: '#409eff', route: '/charge/outpatientregistration' },
{ key: 'clinicCharge', label: '门诊收费', icon: Wallet, iconColor: '#67c23a', route: '/charge/cliniccharge' },
{ key: 'refund', label: '退费管理', icon: Document, iconColor: '#e6a23c', route: '/charge/clinicrefund' },
{ key: 'invoice', label: '发票打印', icon: Files, iconColor: '#f56c6c', route: '/basicmanage/InvoiceManagement' },
{ key: 'record', label: '收费记录', icon: Clock, iconColor: '#909399', route: '/charge/clinicRecord' },
{ key: 'insurance', label: '医保结算', icon: Bell, iconColor: '#409eff', route: '/ybmanagement' }
{ key: 'registration', label: '挂号收费', icon: markRaw(Money), iconColor: '#409eff', route: '/charge/outpatientregistration' },
{ key: 'clinicCharge', label: '门诊收费', icon: markRaw(Wallet), iconColor: '#67c23a', route: '/charge/cliniccharge' },
{ key: 'refund', label: '退费管理', icon: markRaw(Document), iconColor: '#e6a23c', route: '/charge/clinicrefund' },
{ key: 'invoice', label: '发票打印', icon: markRaw(Files), iconColor: '#f56c6c', route: '/basicmanage/InvoiceManagement' },
{ key: 'record', label: '收费记录', icon: markRaw(Clock), iconColor: '#909399', route: '/charge/clinicRecord' },
{ key: 'insurance', label: '医保结算', icon: markRaw(Bell), iconColor: '#409eff', route: '/ybmanagement' }
]
}
// 待办事项
const todoList = ref([
{ id: 1, title: '审核处方申请', desc: '张医生提交的5条处方待审核', priority: 'high', icon: Document, time: '10分钟前' },
{ id: 2, title: '确认患者入院', desc: '李某某45岁已办理入院', priority: 'medium', icon: User, time: '30分钟前' },
{ id: 3, title: '处理投诉反馈', desc: '患者家属对服务态度的投诉', priority: 'high', icon: ChatDotRound, time: '1小时前' },
{ id: 4, title: '药品效期预警', desc: '阿莫西林等3种药品即将过期', priority: 'low', icon: Warning, time: '2小时前' },
{ id: 5, title: '月度报表审核', desc: '11月份门诊收入报表待审核', priority: 'medium', icon: Files, time: '3小时前' }
{ id: 1, title: '审核处方申请', desc: '张医生提交的5条处方待审核', priority: 'high', icon: markRaw(Document), time: '10分钟前' },
{ id: 2, title: '确认患者入院', desc: '李某某45岁已办理入院', priority: 'medium', icon: markRaw(User), time: '30分钟前' },
{ id: 3, title: '处理投诉反馈', desc: '患者家属对服务态度的投诉', priority: 'high', icon: markRaw(ChatDotRound), time: '1小时前' },
{ id: 4, title: '药品效期预警', desc: '阿莫西林等3种药品即将过期', priority: 'low', icon: markRaw(Warning), time: '2小时前' },
{ id: 5, title: '月度报表审核', desc: '11月份门诊收入报表待审核', priority: 'medium', icon: markRaw(Files), time: '3小时前' }
])
// 今日日程

View File

@@ -348,7 +348,7 @@ import {
} from '../api';
import adviceBaseList from '../adviceBaseList';
import {calculateQuantityByDays} from '@/utils/his';
import {patientInfo} from '../../store/patient.js';
import {localPatientInfo as patientInfo} from '../../store/localPatient.js';
import OrderGroupDrawer from '@/views/doctorstation/components/prescription/orderGroupDrawer.vue';
import PrescriptionHistory from '@/views/doctorstation/components/prescription/prescriptionHistory.vue';
import Decimal from 'decimal.js';

View File

@@ -72,3 +72,12 @@ export function updateTemplate(data) {
data,
});
}
// 删除模板
export function deleteTemplate(ids) {
return request({
url: '/document/template/delete',
method: 'delete',
data: ids,
});
}

View File

@@ -39,7 +39,7 @@ import {defineEmits, nextTick, ref, unref} from 'vue';
import {deleteRecord, getRecordByEncounterIdList} from '../api';
import {ElMessage} from 'element-plus';
import {Delete} from '@element-plus/icons-vue';
import {patientInfo} from '../../store/patient.js';
import {localPatientInfo as patientInfo} from '../../store/localPatient.js';
const emits = defineEmits(['historyClick']);
const props = defineProps({

View File

@@ -26,8 +26,8 @@
</template>
<script setup>
import {defineEmits, ref, unref} from 'vue';
import {getListByDefinitionId} from '../api';
import {defineEmits, ref, unref, watch} from 'vue';
import {getListByDefinitionId, deleteTemplate} from '../api';
import {ElMessage, ElMessageBox} from 'element-plus';
import {Edit} from '@element-plus/icons-vue';
@@ -46,16 +46,33 @@ const defaultProps = {
children: 'children',
label: 'name',
};
// 缓存已加载的模板数据
const templateCache = new Map();
const queryParams = ref({
searchKey: '',
isPage: 0,
});
const templateData = ref([]);
// 防抖定时器
let debounceTimer = null;
const queryList = async () => {
try {
if (unref(definitionId) && unref(definitionId) !== '') {
const res = await getListByDefinitionId(unref(definitionId));
templateData.value = res.data || [];
const id = unref(definitionId);
if (id && id !== '') {
// 检查缓存中是否存在数据
if (templateCache.has(id)) {
templateData.value = templateCache.get(id);
return;
}
const res = await getListByDefinitionId(id);
const data = res.data || [];
// 将数据存入缓存
templateCache.set(id, data);
templateData.value = data;
} else {
templateData.value = [];
}
@@ -64,6 +81,23 @@ const queryList = async () => {
templateData.value = [];
}
};
// 防抖版本的查询函数
const debouncedQueryList = async () => {
if (debounceTimer) {
clearTimeout(debounceTimer);
}
debounceTimer = setTimeout(async () => {
await queryList();
}, 300); // 300ms 防抖延迟
};
// 监听 definitionId 变化,使用防抖
watch(definitionId, () => {
debouncedQueryList();
}, { immediate: true });
const handleNodeClick = (data) => {
emits('templateClick', data);
};
@@ -81,6 +115,8 @@ const handleDelete = async (item) => {
}).then(async () => {
await deleteTemplate(item.id);
ElMessage.success('删除成功');
// 清除缓存中的数据,强制重新加载
templateCache.delete(unref(definitionId));
queryList();
});
} catch (error) {

View File

@@ -115,7 +115,7 @@ import {nextTick, onMounted, reactive, ref, watch} from 'vue';
import {ElMessage, ElMessageBox} from 'element-plus';
import {getTreeList} from '@/views/basicmanage/caseTemplates/api';
import {addTemplate, getRecordByEncounterIdList, saveOrUpdateRecord} from './api';
import {patientInfo} from '../store/patient.js';
import {localPatientInfo as patientInfo} from '../store/localPatient.js';
import NursingStatus from '@/views/inpatientDoctor/home/components/applicationShow/nursingStatus.vue';
import dayjs from 'dayjs';
// 打印工具
@@ -148,9 +148,18 @@ const emrComponentRef = ref(null);
const quicklyactiveName = ref('history');
const leftShow = ref(true);
const rightShow = ref(true);
// 使用防抖处理历史记录和模板列表的刷新
let listRefreshDebounceTimer = null;
watch(patientInfo, () => {
historyRef.value?.queryList();
templateRef.value?.queryList();
if (listRefreshDebounceTimer) {
clearTimeout(listRefreshDebounceTimer);
}
listRefreshDebounceTimer = setTimeout(() => {
historyRef.value?.queryList();
// 模板查询已经在模板组件内部通过防抖和缓存优化,这里不再重复调用
// templateRef.value?.queryList();
}, 150); // 稍微延后刷新,避免频繁更新
});
const templateTree = ref(null);
@@ -185,8 +194,29 @@ const handleNodeClick = (data, node) => {
if (node.isLeaf) {
// 存储当前节点数据
currentSelectTemplate.value = data.document;
currentComponent.value = currentSelectTemplate.value.vueRouter || '';
// currentComponent.value = data.document.vueRouter || '';
// 在切换组件前先重置表单数据,避免显示之前的数据
editForm.value = {
id: '',
definitionId: '',
definitionBusNo: '',
contentJson: '',
statusEnum: 1,
organizationId: 0,
encounterId: '',
patientId: '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
createBy: '',
source: '',
};
// 先清空当前组件,再设置新组件,确保组件完全重新渲染
currentComponent.value = '';
// 使用 nextTick 确保 DOM 更新后再设置新组件
nextTick(() => {
currentComponent.value = currentSelectTemplate.value.vueRouter || '';
});
} else {
currentSelectTemplate.value = {
id: '',
@@ -198,7 +228,8 @@ const handleNodeClick = (data, node) => {
nextTick(() => {
setTimeout(() => {
historyRef.value?.queryList();
templateRef.value?.queryList();
// 模板查询已经在模板组件内部通过防抖和缓存优化,这里不再重复调用
// templateRef.value?.queryList();
// 选择任何病历模板后,都加载该病历类型的最新历史记录
if (node.isLeaf && patientInfo.value && patientInfo.value.patientId) {
@@ -270,7 +301,8 @@ const handleSubmitOk = async (data) => {
// 刷新历史记录列表
historyRef.value?.queryList();
templateRef.value?.queryList();
// 模板查询已经在模板组件内部通过防抖和缓存优化,这里不再重复调用
// templateRef.value?.queryList();
// 等待历史记录列表更新后,重新加载最新病历并更新选中状态
setTimeout(() => {
@@ -429,7 +461,8 @@ const print = async () => {
const refresh = () => {
queryTemplateTree();
historyRef.value?.queryList();
templateRef.value?.queryList();
// 模板查询已经在模板组件内部通过防抖和缓存优化,这里不再重复调用
// templateRef.value?.queryList();
};
const deleteEmr = async () => {
@@ -522,7 +555,7 @@ const selectOutpatientMedicalRecordTemplate = async () => {
// 加载最新的病历数据并回显
const loadLatestMedicalRecord = async () => {
if (!patientInfo.value.encounterId || !currentSelectTemplate.value.id) return;
if (!patientInfo.value?.encounterId || !currentSelectTemplate.value.id) return;
editForm.value.id = '';
loading.value = true;
try {
@@ -546,7 +579,17 @@ const loadLatestMedicalRecord = async () => {
editForm.value = latestRecord;
nextTick(() => {
if (emrComponentRef.value && latestRecord.contentJson) {
emrComponentRef.value.setFormData(JSON.parse(latestRecord.contentJson));
try {
const parsedData = JSON.parse(latestRecord.contentJson);
emrComponentRef.value.setFormData(parsedData);
} catch (parseError) {
console.error('解析病历数据失败:', parseError);
// 解析失败时仍然尝试设置空数据以清空之前的残留数据
emrComponentRef.value.setFormData({});
}
} else {
// 如果没有内容数据,也要清空组件中的数据
emrComponentRef.value.setFormData({});
}
// 通知History组件更新选中状态
@@ -557,16 +600,52 @@ const loadLatestMedicalRecord = async () => {
} else {
// 清空选中状态
selectedHistoryRecordId.value = '';
// 病案首页切换晴空逻辑
emrComponentRef.value.setFormData?.({});
// 当没有历史记录时,也要清空当前表单数据,避免显示之前患者的数据
editForm.value = {
id: '',
definitionId: '',
definitionBusNo: '',
contentJson: '',
statusEnum: 1,
organizationId: 0,
encounterId: '',
patientId: '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
createBy: '',
source: '',
};
nextTick(() => {
if (emrComponentRef.value) {
emrComponentRef.value.setFormData({});
}
});
loading.value = false;
}
} catch (error) {
ElMessage.error('加载最新病历数据失败=====>', error);
// 出错时也清空选中状态
selectedHistoryRecordId.value = '';
// 病案首页切换晴空逻辑
emrComponentRef.value.setFormData?.({});
// 出错时也要清空表单数据,避免显示之前患者的数据
editForm.value = {
id: '',
definitionId: '',
definitionBusNo: '',
contentJson: '',
statusEnum: 1,
organizationId: 0,
encounterId: '',
patientId: '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
createBy: '',
source: '',
};
nextTick(() => {
if (emrComponentRef.value) {
emrComponentRef.value.setFormData({});
}
});
loading.value = false;
} finally {
loading.value = false;
@@ -672,6 +751,7 @@ const templateEditSubmitOk = async () => {
ElMessage.success('模板新增成功');
// 刷新模板列表
if (templateRef.value && typeof templateRef.value.queryList === 'function') {
// 在模板操作后,需要清除缓存并重新加载
templateRef.value.queryList();
}
// 关闭模板编辑弹窗
@@ -703,7 +783,8 @@ const templateEditSubmitOk = async () => {
} finally {
// 无论成功失败都刷新列表
historyRef.value?.queryList();
templateRef.value?.queryList();
// 模板查询已经在模板组件内部通过防抖和缓存优化,这里不再重复调用
// templateRef.value?.queryList();
}
};
// onBeforeMount(() => {});
@@ -726,6 +807,29 @@ watch(
});
});
}
} else {
// 如果没有患者信息,也要重置组件和表单数据
currentComponent.value = '';
editForm.value = {
id: '',
definitionId: '',
definitionBusNo: '',
contentJson: '',
statusEnum: 1,
organizationId: 0,
encounterId: '',
patientId: '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
createBy: '',
source: '',
};
// 如果有动态组件实例,也需要重置其表单数据
nextTick(() => {
if (emrComponentRef.value && emrComponentRef.value.setFormData) {
emrComponentRef.value.setFormData({});
}
});
}
},
{ deep: true, immediate: true }

View File

@@ -46,6 +46,7 @@ import {computed, onBeforeMount, onMounted, provide, reactive, ref, watch,} from
import Emr from './emr/index.vue';
import inPatientBarDoctorFold from '@/components/patientBar/inPatientBarDoctorFold.vue';
import PatientList from '@/components/PatientList/patient-list.vue';
import {localPatientInfo, updateLocalPatientInfo} from './store/localPatient';
import {patientInfo, updatePatientInfo} from './store/patient';
import {getPatientList} from './components/api';
import {
@@ -121,21 +122,40 @@ watch(
) {
const firstPatient = newData[0];
if (firstPatient?.encounterId) {
handleItemClick(firstPatient);
isFirstLoad.value = false;
// 使用防抖处理默认选择
if (debounceTimer) {
clearTimeout(debounceTimer);
}
debounceTimer = setTimeout(() => {
handleItemClick(firstPatient);
isFirstLoad.value = false;
}, 100);
}
}
},
{ immediate: true }
);
// 防抖函数,防止快速点击导致状态冲突
let debounceTimer = null;
const handleItemClick = (node) => {
cardId.value = node.encounterId;
updatePatientInfo(node);
// 清除之前的计时器
if (debounceTimer) {
clearTimeout(debounceTimer);
}
diagnosisRef.value?.getList();
adviceRef.value?.getListInfo();
adviceRef.value?.getDiagnosisInfo();
// 设置新的计时器
debounceTimer = setTimeout(() => {
cardId.value = node.encounterId;
// 同时更新本地和全局状态,确保模块内组件和跨模块组件都能正确响应
updatePatientInfo(node);
updateLocalPatientInfo(node);
diagnosisRef.value?.getList();
adviceRef.value?.getListInfo();
adviceRef.value?.getDiagnosisInfo();
}, 100); // 100ms 防抖延迟
};
const handleSearch = (keyword) => {