fix(core): 修复审计字段缺失和组件状态管理问题
- 在Account、ChargeItem、EncounterParticipant和Encounter服务中添加审计字段验证 - 确保tenantId、createBy和createTime字段在插入数据库前正确设置 - 修复EMR模块中删除模板API的导出问题 - 更新患者信息状态管理,统一使用localPatientInfo替换patientInfo - 在EMR组件中实现防抖机制优化历史记录刷新性能 - 修复病历模板切换时的表单数据重置逻辑 - 在首页统计组件中使用markRaw包装图标组件 - 为住院记录模板添加默认表单数据结构 - 修复SVG患者图标路径错误
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user