解决合并冲突

This commit is contained in:
2025-12-10 14:20:24 +08:00
parent e1385cb3e6
commit 18f6a845e6
804 changed files with 61881 additions and 13577 deletions

View File

@@ -0,0 +1,584 @@
<!--
* @Author: sjjh
* @Date: 2025-09-18 15:41:10
* @Description: 门诊病历组件
-->
<template>
<div class="emr-use-container">
<div
class="disBtn"
:class="{ disLeftBtnNor: leftShow, disLeftBtnAct: !leftShow }"
@click="disNode"
>
<img src="../../../../assets/icons/svg/foldup.svg" />
</div>
<div
class="disBtn"
:class="{ disRightBtnNor: rightShow, disRightBtnAct: !rightShow }"
@click="disNode_R"
>
<img src="../../../../assets/icons/svg/foldup.svg" />
</div>
<transition name="el-zoom-in-left">
<div class="template-tree-container" v-if="leftShow">
<div class="search-box">
<el-input placeholder="病历名称搜索..." v-model="queryParams.name">
<template #append>
<el-button @click="queryTemplateTree">查询</el-button>
</template>
</el-input>
</div>
<el-scrollbar class="template-tree-scrollbar">
<el-tree
ref="templateTree"
:data="templateData"
:props="defaultProps"
auto-expand-parent
node-key="id"
@node-click="handleNodeClick"
class="template-tree"
></el-tree>
</el-scrollbar>
</div>
</transition>
<div class="operate-container">
<div class="operate-btns">
<el-space>
<!-- <el-button type="primary" @click="newEmr">新建</el-button> -->
<el-button type="primary" @click="saveAsModel">存为模版</el-button>
<el-button @click="refresh">刷新</el-button>
<el-button type="primary" @click="save">保存</el-button>
<!-- <el-button type="primary" @click="print">打印</el-button> -->
</el-space>
</div>
<div class="operate-main">
<el-scrollbar class="template-tree-scrollbar">
<component
:is="currentComponent"
ref="emrComponentRef"
:patientInfo="props.patientInfo"
@submitOk="handleSubmitOk"
/>
</el-scrollbar>
</div>
</div>
<transition name="el-zoom-in-left">
<div class="quickly-container" v-if="rightShow">
<el-tabs v-model="quicklyactiveName" type="card">
<el-tab-pane label="历史" name="history">
<History
@historyClick="handleHistoryClick"
ref="historyRef"
v-model:definitionId="currentSelectTemplate.id"
/>
</el-tab-pane>
<el-tab-pane label="模版" name="model">
<Template
@templateClick="handleTemplateClick"
ref="templateRef"
v-model:definitionId="currentSelectTemplate.id"
@edit="templateEdit"
/>
</el-tab-pane>
</el-tabs>
</div>
</transition>
<TemplateEdit
ref="templateEditRef"
:formData="editTemplateForm"
v-model:dialogVisible="templateEditVisible"
@submitOk="templateEditSubmitOk"
/>
</div>
</template>
<script setup>
import { getCurrentInstance, nextTick, onBeforeMount, onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
import { getTreeList } from '@/views/basicmanage/caseTemplates/api';
import { addRecord, addTemplate } from './api';
import { patientInfo } from '../store/patient.js';
import dayjs from 'dayjs';
// 打印工具
// import { simplePrint, PRINT_TEMPLATE } from '@/utils/printUtils.js';
const { proxy } = getCurrentInstance();
const emits = defineEmits(['emrSaved']);
const props = defineProps({
/** 患者信息 doctorStation 传递信息*/
patientInfo: {
type: Object,
required: true,
},
activeTab: {
type: String,
},
});
const state = reactive({});
import History from './components/history';
import Template from './components/template';
import TemplateEdit from './components/templateEdit.vue';
import useUserStore from '@/store/modules/user';
const userStore = useUserStore();
// 定义响应式变量
const templateData = ref([]);
const queryParams = ref({
name: '',
useRanges: [1, 2], // 0 暂不使用 1 全院 2 科室 3 个人
organizationId: userStore.orgId,
});
const currentSelectTemplate = ref({
id: '',
});
const currentComponent = ref('');
const emrComponentRef = ref(null);
const quicklyactiveName = ref('history');
const leftShow = ref(true);
const rightShow = ref(true);
// 树配置(模板树)
const defaultProps = {
children: 'children',
label: 'name',
value: 'id',
};
/** 初始化病历模板树(按科室筛选) */
const queryTemplateTree = async () => {
try {
const res = await getTreeList(queryParams.value);
templateData.value = res.data || [];
} catch (error) {
// ElMessage.error('获取模板树失败');
templateData.value = [];
}
};
// 处理节点点击,根据后台返回的路径加载组件
const handleNodeClick = (data, node) => {
if (node.isLeaf) {
// 存储当前节点数据
currentSelectTemplate.value = data.document;
currentComponent.value = currentSelectTemplate.value.vueRouter || '';
// currentComponent.value = data.document.vueRouter || '';
} else {
currentSelectTemplate.value = {
id: '',
};
// currentComponent.value = null;
}
historyRef.value?.queryList();
templateRef.value?.queryList();
};
const newEmr = () => {
if (currentSelectTemplate.value) {
currentComponent.value = currentSelectTemplate.value.vueRouter || '';
return;
}
ElMessage.error('请选择模版!');
};
const saveAsModel = async () => {
try {
currentOperate.value = 'addTemplate';
await emrComponentRef.value?.submit();
} catch (error) {
ElMessage.error('存为模版失败');
}
};
const editForm = ref({
id: '',
definitionId: '',
definitionBusNo: '',
contentJson: '',
statusEnum: 1, // 0草稿/暂存 1提交 2归档 3修改
organizationId: 0,
encounterId: '',
patientId: '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
createBy: '',
source: '',
});
const editTemplateForm = ref({
id: '',
name: '',
displayOrder: 0,
contextJson: '',
definitionId: '',
useRange: 2,
organizationId: '',
userId: '',
remark: '',
});
const currentOperate = ref('add');
const handleSubmitOk = async (data) => {
if (currentOperate.value === 'add') {
//
try {
if (!patientInfo.value?.encounterId || !patientInfo.value?.patientId) {
ElMessage.error('请先选择患者!');
return;
}
editForm.value.definitionId = currentSelectTemplate.value.id;
editForm.value.definitionBusNo = currentSelectTemplate.value.busNo;
editForm.value.contentJson = JSON.stringify(data);
editForm.value.encounterId = patientInfo.value.encounterId;
editForm.value.patientId = patientInfo.value.patientId;
editForm.value.recordTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
await addRecord(editForm.value);
ElMessage.success('病历保存成功');
historyRef.value?.queryList();
templateRef.value?.queryList();
// 通知父组件病历保存成功
emits('emrSaved', true);
} catch (error) {
ElMessage.error('提交失败');
console.log(error);
}
} else if (currentOperate.value === 'addTemplate') {
// 新增或者编辑模板
// editTemplateForm.value.id=
editTemplateForm.value.name =
currentSelectTemplate.value.name + dayjs().format('YYYY/MM/DD HH:mm');
editTemplateForm.value.contextJson = JSON.stringify(data);
editTemplateForm.value.definitionId = currentSelectTemplate.value.id;
templateEditVisible.value = true;
}
};
const refresh = () => {
queryTemplateTree();
historyRef.value?.queryList();
templateRef.value?.queryList();
};
const deleteEmr = async () => {
try {
// 这里应该添加实际的删除逻辑
ElMessage.success('删除成功!');
} catch (error) {
ElMessage.error('删除失败');
}
};
const save = async () => {
try {
currentOperate.value = 'add';
await emrComponentRef.value?.submit();
} catch (error) {
ElMessage.error('保存失败');
}
};
const historyRef = ref(null);
const handleHistoryClick = (data) => {
newEmr();
editForm.value = data;
nextTick(() => {
emrComponentRef.value?.setFormData(JSON.parse(editForm.value.contentJson));
});
};
const templateRef = ref(null);
const handleTemplateClick = (data) => {
newEmr();
editForm.value = data;
nextTick(() => {
emrComponentRef.value?.setFormData(JSON.parse(editForm.value.contextJson));
});
};
const templateEdit = (data) => {
editTemplateForm.value = data;
templateEditVisible.value = true;
};
// ====dialog
const templateEditVisible = ref(false);
// const templateEditSubmitOk = () => {};
// 打印方法实现
const print = async () => {
try {
// 检查是否有选中的病历模板
if (!currentSelectTemplate.value || !currentSelectTemplate.value.id) {
ElMessage.warning('请先选择病历模板');
return;
}
// 获取当前病历组件的表单数据
const formData = emrComponentRef.value?.formData || {};
// 准备打印数据不依赖子组件的getPrintData方法
// const printData = {
// // 使用当前选中的模板信息
// templateInfo: currentSelectTemplate.value,
// // 添加患者信息
// patientInfo: props.patientInfo,
// // 添加打印时间
// printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
// // 添加基本病历信息
// emrInfo: {
// documentName: currentSelectTemplate.value.name || '住院病历',
// documentId: currentSelectTemplate.value.id || '',
// encounterId: props.patientInfo.encounterId || '',
// patientId: props.patientInfo.patientId || '',
// recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
// },
// // 添加病历表单数据(包含红框内的所有字段)
// formData: formData,
// doctorName: userStore.nickName,
// };
const printData = {
// 模板信息
templateName: currentSelectTemplate.value.name || '住院病历',
templateId: currentSelectTemplate.value.id || '',
// 医生信息
doctorName: userStore.nickName,
// 患者信息
patientName: props.patientInfo.patientName || '',
patientId: props.patientInfo.patientId || '',
medicalRecordNo: props.patientInfo.medicalRecordNo || '',
gender: props.patientInfo.gender || '',
age: props.patientInfo.age || '',
genderEnum_enumText: props.patientInfo.genderEnum_enumText || '',
idCard: props.patientInfo.idCard || '',
phone: props.patientInfo.phone || '',
registerTime: props.patientInfo.registerTime || '',
// 就诊信息
encounterId: props.patientInfo.encounterId || '',
department: props.patientInfo.department || '',
attendingDoctor: props.patientInfo.attendingDoctor || '',
// 病历信息
documentName: currentSelectTemplate.value.name || '住院病历',
documentId: currentSelectTemplate.value.id || '',
recordTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
// 表单数据 - 需要将嵌套结构展开
...flattenObject(formData),
};
// 执行打印
await simplePrint(PRINT_TEMPLATE.OUTPATIENT_MEDICAL_RECORD, printData);
ElMessage.success('打印成功');
} catch (error) {
console.error('打印失败:', error);
ElMessage.error('打印失败: ' + (error.message || '未知错误'));
}
};
// 辅助函数:将嵌套对象扁平化为单层结构
const flattenObject = (obj, prefix = '') => {
const flattened = {};
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
const newKey = prefix ? `${prefix}_${key}` : key;
if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
// 递归处理嵌套对象
Object.assign(flattened, flattenObject(obj[key], newKey));
} else if (Array.isArray(obj[key])) {
// 数组转换为字符串
flattened[newKey] = JSON.stringify(obj[key]);
} else {
// 基本类型直接赋值
flattened[newKey] = obj[key];
}
}
}
return flattened;
};
// 重新添加被覆盖的函数定义
const templateEditSubmitOk = () => {
templateEditVisible.value = false;
historyRef.value?.queryList();
templateRef.value?.queryList();
};
// onBeforeMount(() => {});
// 刚进页面默认显示门诊病历
const selectDefaultTemplate = () => {
nextTick(() => {
// 查找门诊病历(1.0.0)节点
const findTemplate = (nodes) => {
for (const node of nodes) {
if (node.children && node.children.length > 0) {
const found = findTemplate(node.children);
if (found) {
return found;
}
}
// 根据ID查找门诊病历模板
if (node.document && node.document.id === '1963474077201162242') {
return node;
}
}
return null;
};
const defaultTemplate = findTemplate(templateData.value);
if (defaultTemplate) {
// 模拟点击节点
const mockNode = {
isLeaf: true,
};
handleNodeClick(defaultTemplate, mockNode);
}
});
};
onMounted(async () => {
console.log('hospitalizationEmr mounted', userStore);
await queryTemplateTree();
selectDefaultTemplate();
});
defineExpose({ state });
const disNode = () => {
leftShow.value = !leftShow.value;
};
const disNode_R = () => {
rightShow.value = !rightShow.value;
};
</script>
<style lang="scss" scoped>
.emr-use-container {
display: flex;
height: 100%;
img {
width: 200%;
height: 200%;
}
.disBtn {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow: hidden;
}
.disLeftBtnNor {
cursor: pointer;
position: absolute;
top: 40%;
left: 18%;
width: 20px;
height: 60px;
z-index: 1111;
img {
transform: rotate(-90deg);
}
}
.disLeftBtnAct {
cursor: pointer;
position: absolute;
top: 40%;
left: 0;
width: 20px;
height: 60px;
z-index: 1111;
img {
transform: rotate(90deg);
}
}
.disRightBtnNor {
cursor: pointer;
position: absolute;
top: 40%;
right: 18.5%;
width: 20px;
height: 60px;
z-index: 1111;
img {
transform: rotate(90deg);
}
}
.disRightBtnAct {
cursor: pointer;
position: absolute;
top: 40%;
right: 0;
width: 20px;
height: 60px;
z-index: 1111;
img {
transform: rotate(-90deg);
}
}
.template-tree-container {
border-right: 1px solid #ebeef5;
width: 300px;
flex: none;
height: 100%;
padding: 0 8px 8px 0;
display: flex;
flex-direction: column;
.search-box {
height: 40px;
display: flex;
align-items: center;
flex: none;
border-bottom: 1px solid #ebeef5;
}
.template-tree-scrollbar {
height: calc(100% - 48px);
flex: auto;
overflow-y: auto;
}
}
.operate-container {
width: 100%;
//width: 300px;
//flex: auto;
display: flex;
flex-direction: column;
padding: 0 8px 8px 8px;
.operate-btns {
height: 40px;
flex: none;
display: flex;
align-items: center;
border-bottom: 1px solid #ebeef5;
}
.operate-main {
height: calc(100vh - 150px);
flex: auto;
}
.operate-main .template-tree-scrollbar {
height: 100%;
overflow-y: auto;
}
}
.quickly-container {
border-left: 1px solid #ebeef5;
width: 300px;
padding: 0 8px 8px 8px;
flex: none;
.el-tabs {
height: 100%;
}
}
}
@layer utilities {
.transition-width {
transition-property: width;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 300ms;
}
}
</style>