解决合并冲突

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,60 @@
/*
* @Author: sjjh
* @Date: 2025-09-20 17:02:37
* @Description:
*/
import request from '@/utils/request'
// ====== 文书记录
// 新增记录
export function addRecord(data) {
return request({
url: '/document/record/addRecord',
method: 'post',
data
})
}
// 根据患者ID或就诊ID获取文书记录列表,只针对不需返回患者具体信息的列表,体温单除外,单独处理
export function getRecordByEncounterIdList(params) {
return request({
url: '/document/record/getRecordByEncounterIdList',
method: 'get',
params
})
}
// 初始化文书定义
export function init() {
return request({
url: '/document/record/init',
method: 'get',
})
}
// ====== 文书模板
// 新增模板
export function addTemplate(data) {
return request({
url: '/document/template/add',
method: 'post',
data
})
}
//
export function getListByDefinitionId(definitionId) {
return request({
url: '/document/template/getListByDefinitionId',
method: 'get',
params: {definitionId}
})
}
// 更新模板
export function updateTemplate(data) {
return request({
url: '/document/template/update',
method: 'put',
data
})
}

View File

@@ -0,0 +1,96 @@
<template>
<div class="emr-history-container">
<div class="search-box">
<el-input placeholder="病历名称搜索..." v-model="queryParams.searchKey">
<template #append>
<el-button @click="queryList">查询</el-button>
</template>
</el-input>
</div>
<el-scrollbar class="emr-history-scrollbar-container" style="width: 100%">
<div v-for="item in historyData" :key="item.id" class="scrollbar-item">
<el-tooltip effect="dark" :content="`${item.name}(${item.recordTime})`" placement="bottom">
<el-text class="w-150px mb-2" truncated @click="handleNodeClick(item)">
{{ item.name }}({{ item.recordTime }})
</el-text>
</el-tooltip>
</div>
</el-scrollbar>
</div>
</template>
<script setup>
import { ref, reactive, defineEmits, unref } from 'vue';
import { getRecordByEncounterIdList } from '../api';
import { ElTree } from 'element-plus';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
import { patientInfo } from '../../store/patient.js';
const emits = defineEmits(['historyClick']);
const props = defineProps({
definitionId: {
type: String,
default: '',
},
});
const definitionId = defineModel('definitionId', {
type: String,
default: '',
});
const defaultProps = {
children: 'children',
label: 'name',
};
const queryParams = ref({
searchKey: '',
isPage: 0,
});
const historyData = ref([]);
const queryList = async () => {
try {
if (patientInfo.value.encounterId && unref(definitionId) && unref(definitionId) !== '') {
const res = await getRecordByEncounterIdList({
...queryParams.value,
encounterId: patientInfo.value.encounterId,
patientId: patientInfo.value.patientId,
definitionId: unref(definitionId),
});
historyData.value = res.data || [];
} else {
historyData.value = [];
}
} catch (error) {
// ElMessage.error('获取模板树失败');
historyData.value = [];
}
};
const handleNodeClick = (data) => {
emits('historyClick', data);
};
const currentSelectTemplate = ref({});
defineExpose({ queryList });
</script>
<style lang="scss" scoped>
.emr-history-container {
height: 100%;
// padding: 8px;
.search-box {
height: 40px;
line-height: 40px;
}
.emr-history-scrollbar-container {
padding: 8px;
height: calc(100% - 40px);
.scrollbar-item {
height: 40px;
line-height: 40px;
border-radius: 4px;
cursor: pointer;
background: var(--el-color-primary-light-9);
& + .scrollbar-item {
margin-top: 8px;
}
}
}
}
</style>

View File

@@ -0,0 +1,112 @@
<template>
<div class="emr-template-container">
<!-- <div class="search-box">
<el-input placeholder="病历名称搜索..." v-model="queryParams.searchKey">
<template #append>
<el-button @click="queryList">查询</el-button>
</template>
</el-input>
</div> -->
<el-scrollbar class="emr-template-scrollbar-container" style="width: 100%">
<div v-for="item in templateData" :key="item.id" class="scrollbar-item">
<el-tooltip
effect="dark"
:content="`${item.name}`"
placement="bottom"
>
<el-text class="2" truncated @click="handleNodeClick(item)">
<div class="template-item">{{ item.name }}
<el-space>
<el-icon><Edit @click="handleEdit(item)" /></el-icon>
</el-space></div>
</el-text>
</el-tooltip>
</div>
</el-scrollbar>
</div>
</template>
<script setup>
import { ref, reactive, defineEmits, unref } from 'vue';
import { getListByDefinitionId } from '../api';
import { ElTree } from 'element-plus';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus';
import { patientInfo } from '../../store/patient.js';
const emits = defineEmits(['templateClick','edit']);
const props = defineProps({
definitionId: {
type: String,
default: '',
},
});
const definitionId = defineModel('definitionId', {
type: String,
default: '',
});
const defaultProps = {
children: 'children',
label: 'name',
};
const queryParams = ref({
searchKey: '',
isPage: 0,
});
const templateData = ref([]);
const queryList = async () => {
try {
if ( unref(definitionId)&&unref(definitionId) !== '') {
const res = await getListByDefinitionId(unref(definitionId));
templateData.value = res.data || [];
}else{
templateData.value = [];
}
} catch (error) {
ElMessage.error('获取模板失败');
templateData.value = [];
}
};
const handleNodeClick = (data) => {
emits('templateClick', data);
};
const handleEdit = (data) => {
emits('edit', data);
};
const currentSelectTemplate = ref({});
defineExpose({ queryList });
</script>
<style lang="scss" scoped>
.emr-template-container {
height: 100%;
// padding: 8px;
.emr-template-scrollbar-container{
padding: 8px;
height: 100%;
.scrollbar-item {
height: 40px;
line-height: 40px;
border-radius: 4px;
cursor: pointer;
background: var(--el-color-primary-light-9);
& + .scrollbar-item {
margin-top: 8px;
}
.el-text{
width: calc(100% - 0px);
display: flex;
justify-content: space-between;
padding: 0 8px;
}
.template-item{
width: 100%;
display: flex;
justify-content: space-between;
}
}
}
}
</style>

View File

@@ -0,0 +1,133 @@
<template>
<!-- 病历文件基本信息弹窗 -->
<el-dialog
:title="formData.id ? '编辑模板' : '新增模板'"
v-model="dialogVisible"
width="900px"
destroy-on-close
@open="handleOpen"
>
<!-- 使用el-form包裹表单 -->
<el-form :model="formData" ref="formRef" :rules="rules" label-width="120px">
<el-row :gutter="24" class="mb8">
<el-col :span="24">
<el-form-item label="模板名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入模板名称"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="使用范围" prop="useRange">
<el-radio-group v-model="formData.useRange">
<el-radio :value="0" size="large">全院</el-radio>
<el-radio :value="1" size="large">指定机构</el-radio>
<el-radio :value="2" size="large">指定用户</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入版本"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer"></div>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitForm">确定</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import useUserStore from '@/store/modules/user';
import { addTemplate, updateTemplate } from '../api';
import { ElMessage } from 'element-plus';
import { components } from '@/template';
const emits = defineEmits(['submitOk']);
const props = defineProps({
formData: {
type: Object,
default: () => ({}),
},
});
const formRef = ref(null);
const dialogVisible = defineModel('dialogVisible', {
type: Boolean,
default: false,
});
// 表单数据
const formData = ref({
id: 0,
name: '',
displayOrder: 0,
contextJson: '',
definitionId: 0,
useRange: 2,
organizationId: 0,
userId: 0,
remark: '',
});
// 表单验证规则(响应式,支持动态验证)
const rules = reactive({
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
});
const handleOpen = () => {
if (props.formData) {
formData.value = props.formData;
} else {
resetForm();
}
};
// 提交表单
const submitForm = () => {
formRef.value.validate((valid) => {
if (valid) {
// 表单验证通过,执行保存操作
saveForm();
} else {
// 表单验证失败
ElMessage.error('请填写必填项');
return false;
}
});
};
// 保存表单
const saveForm = async () => {
try {
// 如果有当前节点数据,表示是编辑操作
if (formData.value.id && formData.value.id !== '') {
const res = await updateTemplate(formData.value);
if (res.code == 200) {
ElMessage.success('更新成功');
emits('submitOk');
} else {
ElMessage.error('更新失败', error);
}
} else {
// 新建操作
const res = await addTemplate(formData.value);
if (res.code == 200) {
ElMessage.success('保存成功');
emits('submitOk');
} else {
ElMessage.error('保存失败', error);
}
}
} catch (error) {
console.log(error);
// ElMessage.error('保存失败',error);
}
};
// 重置表单
const resetForm = () => {
formRef.value?.resetFields();
};
onMounted(() => {});
</script>
<style lang="scss" scoped></style>

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>