Quellcode durchsuchen

电子病历新建病历改为鼠标右键

xiaochan vor 1 Woche
Ursprung
Commit
b19d620115

+ 11 - 16
src/components/zhu-yuan-yi-sheng/emr/emr-template/comp/PatientEmrData.vue

@@ -1,5 +1,5 @@
 <script setup lang="tsx">
-import { useCompRef } from "@/utils/useCompRef";
+import { useCompRef, useCompShallowRef } from "@/utils/useCompRef";
 import { ElIcon, ElInput, ElMessage, ElMessageBox, ElTree } from "element-plus";
 import { h, ref } from "vue";
 import { Document, Folder, Lock, Open } from "@element-plus/icons-vue";
@@ -20,7 +20,7 @@ import { useDialog } from "@/components/cy/CyDialog/index";
 import AddEmrDialog from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/add-emr-dialog/AddEmrDialog.vue";
 import {
   emrRootContextKey,
-  EmrStore
+  EmrStore,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
 import ContextMenu from "@imengyu/vue3-context-menu";
 import XEUtils from "xe-utils";
@@ -36,6 +36,7 @@ const emits = defineEmits(["nodeClick", "refresh"]);
 
 const inputValue = ref("");
 const treeRef = useCompRef(ElTree);
+const addEmrDialogRef = useCompShallowRef(AddEmrDialog);
 
 const defaultProps = {
   children: "children",
@@ -147,20 +148,10 @@ const contextmenuItemV2 = (e, data) => {
         disabled: !createVerification(),
         label: "新建病历",
         onClick: () => {
-          useDialog<any>(AddEmrDialog, {
-            dialogProps: {
-              title: `在【${data.name}】文件夹下面创建病历`,
-              top: "2%",
-            },
-            showConfirm: false,
-            params: {
-              templateData: root.emrTemplate.value.emrTree,
-              deptTree: root.emrTemplate.value.deptTree,
-            },
-          }).then(res => {
-            // @ts-ignore
-            emrMitt.emit("loadTemplate", { ...res, parent: data.folderId });
-          });
+          addEmrDialogRef.value.openDialog(
+            `在【${data.name}】文件夹下面创建病历`,
+            data.folderId
+          );
         },
       },
       {
@@ -250,7 +241,11 @@ function personnel(value: any) {
 
 <template>
   <div class="layout_container">
+    <AddEmrDialog ref="addEmrDialogRef" />
     <div>
+      <span style="color: red"
+        >新建病历的方式修改为:,在文件夹右键,点击【新建病历】</span
+      >
       <el-input
         ref="inputRef"
         v-model="inputValue"

+ 1 - 1
src/utils/cy-message-box/index.tsx

@@ -13,7 +13,7 @@ export type CyMessageBoxOptions = ElMessageBoxOptions &
   Partial<{
     inputMaxLength: number;
     inputAllowEmpty: boolean;
-    type: ElMessageBoxOptions["type"] & "delete";
+    type: "" | "primary" | "success" | "warning" | "info" | "error" | "delete";
     height: string | number;
     width: string | number;
     selectOption:

+ 37 - 3
src/utils/emr/emr-init-v2.ts

@@ -1,6 +1,6 @@
 // @ts-nocheck
 import { EditType, Runtime } from "./edit";
-import { UnwrapRef } from "vue";
+import { resolveDirective, UnwrapRef, withDirectives } from "vue";
 import { BizException, ExceptionEnum } from "../BizException";
 import { ElMessageBox } from "element-plus";
 import XEUtils from "xe-utils";
@@ -109,6 +109,37 @@ function delElementByName(this: any, name: string, editor: EditType) {
   });
 }
 
+export function useEmrDiv(
+  options?: Options,
+  cb?: (res: UseEmrInitReturn) => void
+) {
+  const divRef = shallowRef<{ rst: UseEmrInitReturn }>();
+  const showLoading = shallowRef(true);
+
+  const DivIframe = defineComponent({
+    setup() {
+      onMounted(() => {
+        useEmrInit(divRef.value, options).then(res => {
+          cb?.(res);
+          showLoading.value = false;
+        });
+      });
+      return () =>
+        h(
+          "div",
+          {
+            ref: divRef,
+            class: "layout_h-w_max",
+            props: {},
+          },
+          null
+        );
+    },
+  });
+
+  return [divRef, DivIframe, showLoading];
+}
+
 export function useEmrInit(
   div: UnwrapRef<HTMLElement | null>,
   options?: Options
@@ -209,7 +240,7 @@ export function useEmrInit(
           }
         }
 
-        resolve({
+        const rst = {
           editor,
           runtime,
           iframe,
@@ -217,7 +248,10 @@ export function useEmrInit(
           loadDocument,
           loadAndSetDocument,
           print,
-        });
+        };
+
+        div["rst"] = rst;
+        resolve(rst);
       },
       getAppContext: (): any => {
         if (options && options.appContext) {

+ 1 - 1
src/views/dictionary/diagnose-req-template/index.tsx

@@ -20,7 +20,7 @@ export function useStore() {
   function initPage() {
     return {
       total: 0,
-      pageSize: isDev ? 1 : 50,
+      pageSize: 50,
       currentPage: 1,
     };
   }

+ 5 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/EmrMain.vue

@@ -1631,7 +1631,11 @@ const initEdit = () => {
     emrStore.mutation.installPlugins(res, emrStore);
     if (isDev) {
       await sleep(1000);
-      emrStore.store.right = EmrRightTabs.ca;
+      // emrStore.store.right = EmrRightTabs.ca;
+      res.loadAndSetDocument({
+        categoryId: "e5a801a054ff11edb28ac955a5f5cad1",
+        categoryCode: "shoucibingchengjilu",
+      });
     }
   });
 };

+ 339 - 339
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/EmrSidebar.tsx

@@ -1,403 +1,403 @@
 // @ts-nocheck
-import {computed, defineComponent, h, onMounted, ref} from "vue";
+import { computed, defineComponent, h, onMounted, ref } from "vue";
 // @ts-ignore
-import {ElIcon, ElInput, ElTree, ElTreeV2} from "element-plus";
-import {useCompRef} from "@/utils/useCompRef";
-import {TreeNodeData} from "element-plus/es/components/tree/src/tree.type";
+import { ElIcon, ElInput, ElTree, ElTreeV2 } from "element-plus";
+import { useCompRef } from "@/utils/useCompRef";
+import { TreeNodeData } from "element-plus/es/components/tree/src/tree.type";
 import {
-    EmrCategoryData,
-    EmrPatientData,
-    getEmrTree,
-    getMzPatientDataByPatNo,
-    getPastHistory,
-    getPatientDataTree,
-    whetherItExistsInTheDepartment,
+  EmrCategoryData,
+  EmrPatientData,
+  getEmrTree,
+  getMzPatientDataByPatNo,
+  getPastHistory,
+  getPatientDataTree,
+  whetherItExistsInTheDepartment,
 } from "@/api/zhu-yuan-yi-sheng/emr-patient";
-import {Document, Folder} from "@element-plus/icons-vue";
+import { Document, Folder } from "@element-plus/icons-vue";
 import "./emr-css.scss";
 import {
-    canIUnlockIt,
-    emrConfig,
-    emrMitt,
-    EmrParam,
-    patientInfo,
-    unlockEnum,
+  canIUnlockIt,
+  emrConfig,
+  emrMitt,
+  EmrParam,
+  patientInfo,
+  unlockEnum,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
-import {isDev} from "@/utils/public";
-import {getAllWards} from "@/api/zhu-yuan-yi-sheng/resident-doctor";
-import {BizException, ExceptionEnum} from "@/utils/BizException";
+import { isDev } from "@/utils/public";
+import { getAllWards } from "@/api/zhu-yuan-yi-sheng/resident-doctor";
+import { BizException, ExceptionEnum } from "@/utils/BizException";
 // @ts-ignore
 import PatientEmrData from "@/components/zhu-yuan-yi-sheng/emr/emr-template/comp/PatientEmrData.vue";
 // @ts-ignore
 import PatientHistoryData from "@/components/zhu-yuan-yi-sheng/emr/emr-template/comp/PatientHistoryData.vue";
 // @ts-ignore
 import CyFlex from "@/components/cy/flex/src/CyFlex.vue";
-import {useUserStore} from "@/pinia/user-store";
+import { useUserStore } from "@/pinia/user-store";
 import {
-    emrRootContextKey,
-    EmrStore
+  emrRootContextKey,
+  EmrStore,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
 import TabsResizer from "@/components/cy/cy-el-tabs/TabsResizer.vue";
 import TabPaneResizer from "@/components/cy/cy-el-tabs/TabPaneResizer.vue";
 import XEUtils from "xe-utils";
 
 const defaultProps = {
-    children: "children",
-    label: "name",
-    value: "_id",
+  children: "children",
+  label: "name",
+  value: "_id",
 };
 
 const HospitalTemplate = defineComponent({
-    props: {
-        data: {
-            type: Array,
-            required: true,
-        },
+  props: {
+    data: {
+      type: Array,
+      required: true,
     },
-    emits: ["nodeClick"],
-    setup(props, {emit}) {
-        const inputValue = ref("");
-        const treeRef = useCompRef(ElTreeV2);
+  },
+  emits: ["nodeClick"],
+  setup(props, { emit }) {
+    const inputValue = ref("");
+    const treeRef = useCompRef(ElTreeV2);
 
-        function filterMethod(query: string, node: TreeNodeData) {
-            return node.name!.includes(query);
-        }
+    function filterMethod(query: string, node: TreeNodeData) {
+      return node.name!.includes(query);
+    }
 
-        const isItAFolder = ({data}: any) => {
-            return h(ElIcon, null, {
-                default: () => {
-                    if (data.type === "category") {
-                        return h(Document);
-                    } else {
-                        return h(Folder);
-                    }
-                },
-            });
-        };
+    const isItAFolder = ({ data }: any) => {
+      return h(ElIcon, null, {
+        default: () => {
+          if (data.type === "category") {
+            return h(Document);
+          } else {
+            return h(Folder);
+          }
+        },
+      });
+    };
 
-        function inputChange() {
-            treeRef.value?.filter(inputValue.value);
-        }
+    function inputChange() {
+      treeRef.value?.filter(inputValue.value);
+    }
 
-        function click(node: any) {
-            emit("nodeClick", node);
-        }
+    function click(node: any) {
+      emit("nodeClick", node);
+    }
 
-        return () => {
-            return (
-                <CyFlex>
-                    {{
-                        header: () => (
-                            <ElInput
-                                modelValue={inputValue.value}
-                                onUpdate:modelValue={value => {
-                                    inputValue.value = value;
-                                }}
-                                onInput={inputChange}
-                                clearable
-                            ></ElInput>
-                        ),
-                        content: () => (
-                            <ElTree
-                                class="down-tree"
-                                ref={treeRef}
-                                // @ts-ignore
-                                data={props.data}
-                                filterNodeMethod={filterMethod}
-                                props={defaultProps}
-                                highlightCurrent
-                                onNode-click={click}
-                            >
-                                {{
-                                    default({node}: any) {
-                                        return (
-                                            <div style={{width: "max-content"}}>
+    return () => {
+      return (
+        <CyFlex>
+          {{
+            header: () => (
+              <ElInput
+                modelValue={inputValue.value}
+                onUpdate:modelValue={value => {
+                  inputValue.value = value;
+                }}
+                onInput={inputChange}
+                clearable
+              ></ElInput>
+            ),
+            content: () => (
+              <ElTree
+                class="down-tree"
+                ref={treeRef}
+                // @ts-ignore
+                data={props.data}
+                filterNodeMethod={filterMethod}
+                props={defaultProps}
+                highlightCurrent
+                onNode-click={click}
+              >
+                {{
+                  default({ node }: any) {
+                    return (
+                      <div style={{ width: "max-content" }}>
                         <span title={node.label}>
                           {isItAFolder(node)}&nbsp;&nbsp;{node.label}
                         </span>
-                                            </div>
-                                        );
-                                    },
-                                }}
-                            </ElTree>
-                        ),
-                    }}
-                </CyFlex>
-            );
-        };
-    },
+                      </div>
+                    );
+                  },
+                }}
+              </ElTree>
+            ),
+          }}
+        </CyFlex>
+      );
+    };
+  },
 });
 
 const EmrSidebar = defineComponent({
-    name: "EmrSidebar",
-    props: {
-        doctorGrade: {
-            type: Number,
-        },
-        isCreate: {
-            type: Boolean,
-        },
+  name: "EmrSidebar",
+  props: {
+    doctorGrade: {
+      type: Number,
+    },
+    isCreate: {
+      type: Boolean,
     },
-    setup(props, {emit, expose}) {
-        const root = inject(emrRootContextKey) as EmrStore;
+  },
+  setup(props, { emit, expose }) {
+    const root = inject(emrRootContextKey) as EmrStore;
 
-        const returnData = root.emrTemplate;
+    const returnData = root.emrTemplate;
 
-        const templateType = ref(0);
-        const editor = emrConfig.value.editor;
-        let wardList: (string | undefined)[] = [];
-        const hisData = ref([]);
-        const mzHisDate = ref([]);
+    const templateType = ref(2);
+    const editor = emrConfig.value.editor;
+    let wardList: (string | undefined)[] = [];
+    const hisData = ref([]);
+    const mzHisDate = ref([]);
 
-        function queryData() {
-            return getPatientDataTree(
-                patientInfo.value!.inpatientNo as string,
-                patientInfo.value!.admissTimes as number
-            ).then(res => {
-                if (res?.length > 0) {
-                    templateType.value = 2;
-                }
-                returnData.value.patientTree = res;
-            });
+    function queryData() {
+      return getPatientDataTree(
+        patientInfo.value!.inpatientNo as string,
+        patientInfo.value!.admissTimes as number
+      ).then(res => {
+        if (res?.length > 0) {
+          templateType.value = 2;
         }
+        returnData.value.patientTree = res;
+      });
+    }
 
-        const hisComp = computed(() => {
-            const zy = [
-                {
-                    name: `住院病历`,
-                    children: hisData.value,
-                    emrDocumentId: `住院病历`,
-                    type: "group-category",
-                },
-            ];
+    const hisComp = computed(() => {
+      const zy = [
+        {
+          name: `住院病历`,
+          children: hisData.value,
+          emrDocumentId: `住院病历`,
+          type: "group-category",
+        },
+      ];
 
-            const mz = [
-                {
-                    name: `门诊病历`,
-                    children: mzHisDate.value,
-                    emrDocumentId: `门诊病历`,
-                    type: "group-category",
-                },
-            ];
+      const mz = [
+        {
+          name: `门诊病历`,
+          children: mzHisDate.value,
+          emrDocumentId: `门诊病历`,
+          type: "group-category",
+        },
+      ];
 
-            return [...zy, ...mz];
-        });
+      return [...zy, ...mz];
+    });
 
-        const determineWhetherItCanBeCreated = () => {
-            // @ts-ignore
-            if (
-                useUserStore().userInfo.code === patientInfo.value.referPhysician ||
-                props!.doctorGrade > 1
-            ) {
-                return true;
-            }
-            return wardList.includes(patientInfo.value.ward);
-        };
+    const determineWhetherItCanBeCreated = () => {
+      // @ts-ignore
+      if (
+        useUserStore().userInfo.code === patientInfo.value.referPhysician ||
+        props!.doctorGrade > 1
+      ) {
+        return true;
+      }
+      return wardList.includes(patientInfo.value.ward);
+    };
 
-        const judgeTheCreationOfTransfer = async () => {
-            let res = (await whetherItExistsInTheDepartment(
-                patientInfo.value.inpatientNo,
-                patientInfo.value.admissTimes
-            )) as any;
-            if (res === null) {
-                return false;
-            }
-            if (res.timeout) {
-                return false;
-            }
-            return wardList.includes(res.fDeptCode);
-        };
+    const judgeTheCreationOfTransfer = async () => {
+      let res = (await whetherItExistsInTheDepartment(
+        patientInfo.value.inpatientNo,
+        patientInfo.value.admissTimes
+      )) as any;
+      if (res === null) {
+        return false;
+      }
+      if (res.timeout) {
+        return false;
+      }
+      return wardList.includes(res.fDeptCode);
+    };
 
-        const wardCreationJudgment = async () => {
-            if (determineWhetherItCanBeCreated()) {
-                return;
-            }
-            if (await judgeTheCreationOfTransfer()) {
-                return;
-            }
-            if (canIUnlockIt(unlockEnum.转科创建病历)) {
-                return;
-            }
-            if (isDev) {
-                return;
-            }
-            BizException(
-                ExceptionEnum.MESSAGE_ERROR,
-                "当前患者所在病区不在您的管理病区范围内,无法创建病历。"
-            );
-        };
+    const wardCreationJudgment = async () => {
+      if (determineWhetherItCanBeCreated()) {
+        return;
+      }
+      if (await judgeTheCreationOfTransfer()) {
+        return;
+      }
+      if (canIUnlockIt(unlockEnum.转科创建病历)) {
+        return;
+      }
+      if (isDev) {
+        return;
+      }
+      BizException(
+        ExceptionEnum.MESSAGE_ERROR,
+        "当前患者所在病区不在您的管理病区范围内,无法创建病历。"
+      );
+    };
 
-        const pastHistory = () => {
-            getPastHistory(
-                patientInfo.value.inpatientNo,
-                patientInfo.value.admissTimes
-            ).then(res => {
-                let temp = [];
-                for (let key in res) {
-                    temp.push({
-                        name: `第${key}次住院`,
-                        children: res[key],
-                        emrDocumentId: `第${key}次住院`,
-                        type: "group-category",
-                    });
-                }
-                // @ts-ignore
-                hisData.value = temp;
-            });
-            // @ts-ignore
-            getMzPatientDataByPatNo(patientInfo.value.inpatientNo).then(res => {
-                let temp = [];
-                for (let key in res) {
-                    temp.push({
-                        name: `第${key}次就诊`,
-                        children: res[key],
-                        emrDocumentId: `第${key}次就诊`,
-                        type: "group-category",
-                    });
-                }
-                // @ts-ignore
-                mzHisDate.value = temp;
-            });
-        };
+    const pastHistory = () => {
+      getPastHistory(
+        patientInfo.value.inpatientNo,
+        patientInfo.value.admissTimes
+      ).then(res => {
+        let temp = [];
+        for (let key in res) {
+          temp.push({
+            name: `第${key}次住院`,
+            children: res[key],
+            emrDocumentId: `第${key}次住院`,
+            type: "group-category",
+          });
+        }
+        // @ts-ignore
+        hisData.value = temp;
+      });
+      // @ts-ignore
+      getMzPatientDataByPatNo(patientInfo.value.inpatientNo).then(res => {
+        let temp = [];
+        for (let key in res) {
+          temp.push({
+            name: `第${key}次就诊`,
+            children: res[key],
+            emrDocumentId: `第${key}次就诊`,
+            type: "group-category",
+          });
+        }
+        // @ts-ignore
+        mzHisDate.value = temp;
+      });
+    };
 
-        const template = async (val: EmrCategoryData) => {
-            if (val.type === "group-category") return;
-            await wardCreationJudgment();
-            emrMitt.emit("loadDocument", {
-                categoryCode: val.code,
-                categoryId: val._id,
-                name: val.name,
-                parent: val.parent,
-                emrPatientData: {},
-                courseJumpId: null,
-            });
-        };
+    const template = async (val: EmrCategoryData) => {
+      if (val.type === "group-category") return;
+      await wardCreationJudgment();
+      emrMitt.emit("loadDocument", {
+        categoryCode: val.code,
+        categoryId: val._id,
+        name: val.name,
+        parent: val.parent,
+        emrPatientData: {},
+        courseJumpId: null,
+      });
+    };
 
-        function loadByDocumentId(id: string) {
-            const findData = XEUtils.findTree(returnData.value.patientTree, item => {
-                return item.emrDocumentId === id;
-            });
-            if (findData.item) {
-                saveEmr(findData.item);
-            }
-        }
+    function loadByDocumentId(id: string) {
+      const findData = XEUtils.findTree(returnData.value.patientTree, item => {
+        return item.emrDocumentId === id;
+      });
+      if (findData.item) {
+        saveEmr(findData.item);
+      }
+    }
 
-        function saveEmr(val: EmrPatientData) {
-            const params: EmrParam = {
-                documentId: val.emrDocumentId,
-                categoryCode: val.emrCategoryCode,
-                name: val.name,
-                parent: val.parent,
-                emrPatientData: val,
-                courseJumpId: val.courseJumpId,
-            };
+    function saveEmr(val: EmrPatientData) {
+      const params: EmrParam = {
+        documentId: val.emrDocumentId,
+        categoryCode: val.emrCategoryCode,
+        name: val.name,
+        parent: val.parent,
+        emrPatientData: val,
+        courseJumpId: val.courseJumpId,
+      };
 
-            if (val.signComplete && val.archivePath) {
-                window.open(val.archivePath, "_blank");
-                return;
-            }
+      if (val.signComplete && val.archivePath) {
+        window.open(val.archivePath, "_blank");
+        return;
+      }
 
-            emrMitt.emit("loadDocument", params);
-        }
+      emrMitt.emit("loadDocument", params);
+    }
 
-        emrMitt.on("loadTemplate", template);
-        emrMitt.on("loadByDocumentId", loadByDocumentId);
+    emrMitt.on("loadTemplate", template);
+    emrMitt.on("loadByDocumentId", loadByDocumentId);
 
-        onMounted(() => {
-            emrMitt.on("determineWhetherItCanBeCreated", () => {
-                return determineWhetherItCanBeCreated();
-            });
-            emrMitt.on("querySidebar", queryData);
-            pastHistory();
-            queryData();
-            if (editor) {
-                getAllWards().then(res => {
-                    // @ts-ignore
-                    if (res && res.length > 0) {
-                        // @ts-ignore
-                        for (let i = 0, len = res.length; i < len; i++) {
-                            // @ts-ignore
-                            wardList.push(res[i].code);
-                        }
-                    }
-                });
-                getEmrTree().then(res => {
-                    returnData.value.emrTree = res.all;
-                    returnData.value.deptTree = res.dept;
-                });
-            } else {
-                templateType.value = 2;
+    onMounted(() => {
+      emrMitt.on("determineWhetherItCanBeCreated", () => {
+        return determineWhetherItCanBeCreated();
+      });
+      emrMitt.on("querySidebar", queryData);
+      pastHistory();
+      queryData();
+      if (editor) {
+        getAllWards().then(res => {
+          // @ts-ignore
+          if (res && res.length > 0) {
+            // @ts-ignore
+            for (let i = 0, len = res.length; i < len; i++) {
+              // @ts-ignore
+              wardList.push(res[i].code);
             }
+          }
+        });
+        getEmrTree().then(res => {
+          returnData.value.emrTree = res.all;
+          returnData.value.deptTree = res.dept;
         });
+      } else {
+        templateType.value = 2;
+      }
+    });
 
-        let findNode = false;
+    let findNode = false;
 
-        function diseaseDurationRecordTime(id: string, list: any[]) {
-            findNode = false;
-            findMedicalRecordById(id, list, returnData.value.patientTree);
-        }
+    function diseaseDurationRecordTime(id: string, list: any[]) {
+      findNode = false;
+      findMedicalRecordById(id, list, returnData.value.patientTree);
+    }
 
-        const findMedicalRecordById = (
-            id: string,
-            roundTimes: any[],
-            list: any[]
-        ) => {
-            for (let i = 0, len = list.length; i < len; i++) {
-                if (findNode) return;
-                let item = list[i];
-                if (item.emrDocumentId === id) {
-                    findNode = true;
-                    item.type = "group-category";
-                    item.children = roundTimes;
-                    return;
-                }
-                if (item.children) {
-                    findMedicalRecordById(id, roundTimes, item.children);
-                }
-            }
-        };
+    const findMedicalRecordById = (
+      id: string,
+      roundTimes: any[],
+      list: any[]
+    ) => {
+      for (let i = 0, len = list.length; i < len; i++) {
+        if (findNode) return;
+        let item = list[i];
+        if (item.emrDocumentId === id) {
+          findNode = true;
+          item.type = "group-category";
+          item.children = roundTimes;
+          return;
+        }
+        if (item.children) {
+          findMedicalRecordById(id, roundTimes, item.children);
+        }
+      }
+    };
 
-        expose({
-            queryData,
-            diseaseDurationRecordTime,
-        });
+    expose({
+      queryData,
+      diseaseDurationRecordTime,
+    });
 
-        return () => {
-            return (
-                <TabsResizer
-                    value={220}
-                    min={100}
-                    max={500}
-                    style={{marginRight: "5px"}}
-                    modelValue={templateType.value}
-                    onUpdate:modelValue={val => (templateType.value = val)}
-                >
-                    <TabPaneResizer label="全院" name={0}>
-                        <HospitalTemplate
-                            data={returnData.value.emrTree}
-                            onNodeClick={template}
-                        />
-                    </TabPaneResizer>
-                    <TabPaneResizer label="科室" name={1}>
-                        <HospitalTemplate
-                            onNodeClick={template}
-                            data={returnData.value.deptTree}
-                        />
-                    </TabPaneResizer>
-                    <TabPaneResizer label="当前" name={2}>
-                        <PatientEmrData
-                            onRefresh={queryData}
-                            onNodeClick={saveEmr}
-                            treeData={returnData.value.patientTree}
-                        />
-                    </TabPaneResizer>
-                    <TabPaneResizer label="历史" name={3}>
-                        <PatientHistoryData data={hisComp.value}/>
-                    </TabPaneResizer>
-                </TabsResizer>
-            );
-        };
-    },
+    return () => {
+      return (
+        <TabsResizer
+          value={220}
+          min={100}
+          max={500}
+          style={{ marginRight: "5px" }}
+          modelValue={templateType.value}
+          onUpdate:modelValue={val => (templateType.value = val)}
+        >
+          {/*<TabPaneResizer label="全院" name={0}>*/}
+          {/*    <HospitalTemplate*/}
+          {/*        data={returnData.value.emrTree}*/}
+          {/*        onNodeClick={template}*/}
+          {/*    />*/}
+          {/*</TabPaneResizer>*/}
+          {/*<TabPaneResizer label="科室" name={1}>*/}
+          {/*    <HospitalTemplate*/}
+          {/*        onNodeClick={template}*/}
+          {/*        data={returnData.value.deptTree}*/}
+          {/*    />*/}
+          {/*</TabPaneResizer>*/}
+          <TabPaneResizer label="当前" name={2}>
+            <PatientEmrData
+              onRefresh={queryData}
+              onNodeClick={saveEmr}
+              treeData={returnData.value.patientTree}
+            />
+          </TabPaneResizer>
+          <TabPaneResizer label="历史" name={3}>
+            <PatientHistoryData data={hisComp.value} />
+          </TabPaneResizer>
+        </TabsResizer>
+      );
+    };
+  },
 });
 
 export default EmrSidebar;

+ 93 - 15
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/add-emr-dialog/AddEmrDialog.vue

@@ -2,14 +2,36 @@
 import XEUtils from "xe-utils";
 import CyTreeInput from "@/components/cy/tree-input/src/CyTreeInput.vue";
 import { ElTree } from "element-plus";
-
-const props = defineProps<{ templateData?: any[]; deptTree?: any[] }>();
+import CyTabs from "@/components/cy/tabs/src/CyTabs";
+import CyTabPane from "@/components/cy/tabs/src/CyTabPane.vue";
+import {
+  useEmrDiv,
+  useEmrInit,
+  UseEmrInitReturn,
+} from "@/utils/emr/emr-init-v2";
+import {
+  emrRootContextKey,
+  EmrStore,
+} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
+import { emrMitt } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
 
 const defaultProps = {
   children: "children",
   label: "name",
 };
 
+const root = inject(emrRootContextKey) as EmrStore;
+
+const state = reactive({
+  title: "",
+  folderId: "",
+  dialog: false,
+  templateData: [],
+  deptTree: [],
+
+  emrData: null,
+});
+
 const emits = defineEmits<{
   (e: "cyDialogConfirm" | "cyDialogCancel", value?: any): void;
 }>();
@@ -17,19 +39,34 @@ const emits = defineEmits<{
 const tabsValue = ref("hospAll");
 
 const defaultExpandedKeys = computed(() => {
-  return XEUtils.map(props.templateData, item => {
+  return XEUtils.map(root.emrTemplate.value.emrTree, item => {
     return item._id;
   });
 });
 
+async function handleConfirm() {
+  await nextTick();
+  if (state.emrData == null) {
+    return;
+  }
+  emrMitt.emit("loadTemplate", { ...state.emrData, parent: state.folderId });
+  state.emrData = null;
+  state.dialog = false;
+  emrRef.value.rst.editor.execute("resetBlankEditor");
+}
+
 function contextmenu(data) {
   if (data.type === "group-category") return;
-  emits("cyDialogConfirm", data);
+  emrRef.value.rst.loadAndSetDocument({
+    categoryCode: data.code,
+    categoryId: data._id,
+  });
+  state.emrData = data;
 }
 
 const TreeShow = defineComponent({
   props: {
-    data: Object,
+    data: Array,
     defaultExpandAll: {
       type: Boolean,
       default: false,
@@ -60,17 +97,58 @@ const TreeShow = defineComponent({
     );
   },
 });
+
+const [emrRef, DivIframe, showLoading] = useEmrDiv();
+
+defineExpose({
+  openDialog(title: string, folderId: string) {
+    state.dialog = true;
+    state.folderId = folderId;
+    state.title = title;
+  },
+});
 </script>
 
 <template>
-  <div style="height: calc(100vh - 200px)" class="layout_container">
-    <el-tabs v-model="tabsValue" class="el-tabs__fill layout_main">
-      <el-tab-pane label="全院" name="hospAll">
-        <TreeShow :data="props.templateData" />
-      </el-tab-pane>
-      <el-tab-pane label="科室" name="dept">
-        <TreeShow :data="props.deptTree" defaultExpandAll />
-      </el-tab-pane>
-    </el-tabs>
-  </div>
+  <el-dialog
+    v-model="state.dialog"
+    :title="state.title"
+    class="el-dialog-fullscreen-fill"
+    fullscreen
+    append-to-body
+  >
+    <div class="layout_container layout-horizontal" v-loading="showLoading">
+      <aside style="width: 30%">
+        <CyTabs v-model="tabsValue" type="idea">
+          <CyTabPane label="全院" name="hospAll">
+            <TreeShow :data="root.emrTemplate.value.emrTree" />
+          </CyTabPane>
+          <CyTabPane label="科室" name="dept">
+            <TreeShow
+              :data="root.emrTemplate.value.deptTree"
+              defaultExpandAll
+            />
+          </CyTabPane>
+        </CyTabs>
+      </aside>
+      <div class="layout_main">
+        <DivIframe />
+      </div>
+    </div>
+    <template #footer>
+      <el-button
+        size="default"
+        type="danger"
+        @click="
+          () => {
+            state.dialog = false;
+          }
+        "
+        >取消
+      </el-button>
+      <el-button size="default" type="primary" v-el-btn="handleConfirm"
+        >确认
+      </el-button>
+    </template>
+  </el-dialog>
 </template>