浏览代码

小优化

xiaochan 5 月之前
父节点
当前提交
ff04668214

+ 106 - 65
src/components/xmlr/components/TableFee.vue

@@ -3,53 +3,54 @@ import CyDateRange from "@/components/cy/date-range/CyDateRange.vue";
 import SystemItemDrug from "@/components/system/item-drug/SystemItemDrug.vue";
 import XcElOption from "@/components/xiao-chan/xc-el-option/XcElOption.vue";
 import FeeTableColumn from "@/components/xmlr/components/FeeTableColumn.vue";
-import {key, ProjectInput} from "@/components/xmlr/index";
-import {isDev} from "@/utils/public";
-import {useDialog} from "@/components/cy/CyDialog/index";
+import { key, ProjectInput } from "@/components/xmlr/index";
+import { isDev } from "@/utils/public";
+import { useDialog } from "@/components/cy/CyDialog/index";
 import RefundDialog from "@/components/xmlr/dialog/RefundDialog.vue";
-import {xcMessage} from "@/utils/xiaochan-element-plus";
-import {receiveAndRecalculateCost} from "@/api/inpatient/patient";
-import GenerateMedicineReturnOrder
-  from "@/components/medical-insurance/medicine-return-order/GenerateMedicineReturnOrder.vue";
-import {useUserStore} from "@/pinia/user-store";
+import { xcMessage } from "@/utils/xiaochan-element-plus";
+import { receiveAndRecalculateCost } from "@/api/inpatient/patient";
+import GenerateMedicineReturnOrder from "@/components/medical-insurance/medicine-return-order/GenerateMedicineReturnOrder.vue";
+import { useUserStore } from "@/pinia/user-store";
 
-const {store, mutation, feeTableRef, medicalTechnology} = inject(key) as ProjectInput
+const { store, mutation, feeTableRef, medicalTechnology } = inject(
+  key
+) as ProjectInput;
 const userInfo = useUserStore().userInfo;
 const deptList = userInfo.partTimeDeptMap;
 
 const chargeTypeOptions = [
-  {code: 0, name: "全部"},
-  {code: 1, name: "项目"},
-  {code: 2, name: "药品"}
-]
+  { code: 0, name: "全部" },
+  { code: 1, name: "项目" },
+  { code: 2, name: "药品" },
+];
 
 const feeSourcesOptions = [
-  {code: 0, name: "护士"},
-  {code: 1, name: "医嘱"},
-  {code: 2, name: "全部"},
-  {code: 3, name: "医技"}
+  { code: 0, name: "护士" },
+  { code: 1, name: "医嘱" },
+  { code: 2, name: "全部" },
+  { code: 3, name: "医技" },
 ];
 
 const refundSymbol = [
-  {code: 0, name: "未退"},
-  {code: 1, name: "已退"},
-  {code: 2, name: "被退"},
-  {code: 3, name: "全部"}
-]
+  { code: 0, name: "未退" },
+  { code: 1, name: "已退" },
+  { code: 2, name: "被退" },
+  { code: 3, name: "全部" },
+];
 
 function refund() {
   useDialog(RefundDialog, {
     dialogProps: {
       title: "退费",
-      width: "90vw"
+      width: "90vw",
     },
     params: {
       feeTableRef: feeTableRef.value,
-      medicalTechnology
-    }
-  }).then((result) => {
+      medicalTechnology,
+    },
+  }).then(result => {
     mutation.refund(result);
-  })
+  });
 }
 
 function rcvrcalcost() {
@@ -60,8 +61,6 @@ function rcvrcalcost() {
     mutation.getFee();
   });
 }
-
-
 </script>
 
 <template>
@@ -69,71 +68,113 @@ function rcvrcalcost() {
     <header>
       <el-form inline>
         <el-form-item label="项目/药品">
-          <SystemItemDrug v-model="store.searchFeeParams.chargeCode" clearable/>
+          <SystemItemDrug
+            v-model="store.searchFeeParams.chargeCode"
+            clearable
+          />
         </el-form-item>
         <el-form-item label="医嘱号">
-          <el-input v-model="store.searchFeeParams.orderNo" clearable style="width: 95px"/>
+          <el-input
+            v-model="store.searchFeeParams.orderNo"
+            clearable
+            style="width: 95px"
+          />
         </el-form-item>
         <el-form-item label="录入时间">
-          <CyDateRange v-model="store.searchFeeParams" :shortcuts-index="isDev ? 0 : 0"/>
+          <CyDateRange
+            v-model="store.searchFeeParams"
+            :shortcuts-index="isDev ? 0 : 0"
+          />
         </el-form-item>
         <el-form-item label="日期">
-          <el-switch v-model="store.searchFeeParams.orderBy" active-text="升序" inactive-text="降序"/>
+          <el-switch
+            v-model="store.searchFeeParams.orderBy"
+            active-text="升序"
+            inactive-text="降序"
+          />
         </el-form-item>
         <el-form-item label="项目类型">
-          <el-select v-model="store.searchFeeParams.chargeType" style="width: 70px;">
-            <xc-el-option :data="chargeTypeOptions"/>
+          <el-select
+            v-model="store.searchFeeParams.chargeType"
+            style="width: 70px"
+          >
+            <xc-el-option :data="chargeTypeOptions" />
           </el-select>
         </el-form-item>
         <el-form-item label="费用类型">
-          <el-select v-model="store.searchFeeParams.feeSources" style="width: 70px;">
-            <xc-el-option :data="feeSourcesOptions"/>
+          <el-select
+            v-model="store.searchFeeParams.feeSources"
+            style="width: 70px"
+          >
+            <xc-el-option :data="feeSourcesOptions" />
           </el-select>
         </el-form-item>
         <el-form-item label="退费标志">
-          <el-select v-model="store.searchFeeParams.refundSymbol" style="width: 70px;">
-            <xc-el-option :data="refundSymbol"/>
+          <el-select
+            v-model="store.searchFeeParams.refundSymbol"
+            style="width: 70px"
+          >
+            <xc-el-option :data="refundSymbol" />
           </el-select>
         </el-form-item>
         <el-form-item label="执行科室" v-if="medicalTechnology">
-          <el-select v-model="store.searchFeeParams.execDept" style="width: 120px;">
+          <el-select
+            v-model="store.searchFeeParams.execDept"
+            style="width: 120px"
+          >
             <el-option
-                v-for="(value, key) in deptList"
-                :value="key"
-                :label="value"
+              v-for="(value, key) in deptList"
+              :value="key"
+              :label="value"
             />
           </el-select>
         </el-form-item>
         <el-form-item>
-          <el-button type="primary" icon="Search" @click="mutation.getFee">查询</el-button>
-          <el-button type="warning" icon="RefreshRight" @click="rcvrcalcost">费用接受重算</el-button>
-          <el-button type="danger" icon="Delete" @click="refund">退费</el-button>
-          <GenerateMedicineReturnOrder v-if="!medicalTechnology"/>
+          <el-button type="primary" icon="Search" @click="mutation.getFee"
+            >查询</el-button
+          >
+          <el-button type="warning" icon="RefreshRight" @click="rcvrcalcost"
+            >费用接受重算</el-button
+          >
+          <el-button type="danger" icon="Delete" @click="refund"
+            >退费</el-button
+          >
+          <GenerateMedicineReturnOrder v-if="!medicalTechnology" />
         </el-form-item>
       </el-form>
     </header>
     <div class="layout_main">
       <el-table
-          height="100%"
-          @row-click="(row) => {feeTableRef.toggleRowSelection(row)}"
-          :summary-method="mutation.feeTableSummaryMethod"
-          show-summary
-          border
-          ref="feeTableRef"
-          row-key="detailSn"
-          :data="store.feeData.slice((store.feeCurrentPage - 1) * store.feePageSize,store.feeCurrentPage  * store.feePageSize )">
-        <el-table-column type="selection" reserve-selection/>
-        <FeeTableColumn/>
+        height="100%"
+        @row-click="
+          row => {
+            feeTableRef.toggleRowSelection(row);
+          }
+        "
+        :summary-method="mutation.feeTableSummaryMethod"
+        show-summary
+        border
+        ref="feeTableRef"
+        row-key="detailSn"
+        :data="
+          store.feeData.slice(
+            (store.feeCurrentPage - 1) * store.feePageSize,
+            store.feeCurrentPage * store.feePageSize
+          )
+        "
+      >
+        <el-table-column type="selection" reserve-selection />
+        <FeeTableColumn />
       </el-table>
     </div>
-    <el-pagination v-model:current-page="store.feeCurrentPage"
-                   v-model:page-size="store.feePageSize"
-                   layout="prev, pager, next, jumper,sizes,total"
-                   :page-sizes="[50, 100, 200]"
-                   :total="store.feeData.length"/>
+    <el-pagination
+      v-model:current-page="store.feeCurrentPage"
+      v-model:page-size="store.feePageSize"
+      layout="prev, pager, next, jumper,sizes,total"
+      :page-sizes="[50, 100, 200]"
+      :total="store.feeData.length"
+    />
   </div>
 </template>
 
-<style lang="scss">
-
-</style>
+<style lang="scss"></style>

+ 18 - 16
src/layout/fillet-layout/ToolInfoBar.vue

@@ -1,32 +1,36 @@
 <template>
   <div class="tool_info_bar">
     <div class="function-list">
-      <div class="function-list-item" style="width:max-content">
-        <scroll-notifications/>
+      <div class="function-list-item" style="width: max-content">
+        <scroll-notifications />
       </div>
       <div class="function-list-item">
-        <Download/>
+        <Download />
       </div>
       <div class="function-list-item">
-        <Message/>
+        <Message />
       </div>
       <div class="function-list-item" id="tutorial_full_screen">
-        <Full-screen/>
+        <Full-screen />
       </div>
       <div class="function-list-item">
-        <Theme/>
+        <Theme />
       </div>
-      <div class="function-list-item" style="width: auto; margin-left: 6px;padding: 0 6px" id="tutorial_user_info">
-        <user-info @password="changePassword" @logout="logout"/>
+      <div
+        class="function-list-item"
+        style="width: auto; margin-left: 6px; padding: 0 6px"
+        id="tutorial_user_info"
+      >
+        <user-info @password="changePassword" @logout="logout" />
       </div>
     </div>
   </div>
 </template>
 
 <script setup lang="ts">
-import Download from '@/layout/function-list/Download.vue'
-import Message from '@/layout/function-list/message/Message.vue'
-import FullScreen from '@/layout/function-list/Fullscreen.vue'
+import Download from "@/layout/function-list/Download.vue";
+import Message from "@/layout/function-list/message/Message.vue";
+import FullScreen from "@/layout/function-list/Fullscreen.vue";
 import UserInfo from "@/layout/function-list/UserInfo.vue";
 import ScrollNotifications from "../HeaderV2/ScrollNotifications.vue";
 import Theme from "@/layout/function-list/system-config/index.vue";
@@ -34,10 +38,9 @@ import changePassword from "@/components/system/password-layer";
 import router from "@/router";
 
 const logout = () => {
-  localStorage.clear()
-  router.push('/login')
-}
-
+  localStorage.clear();
+  router.push("/login");
+};
 </script>
 
 <style scoped lang="scss">
@@ -92,5 +95,4 @@ const logout = () => {
     color: var(--system-header-breadcrumb-text-color);
   }
 }
-
 </style>

+ 87 - 82
src/utils/cyRefList.ts

@@ -1,11 +1,16 @@
-import {ref, computed, Ref} from 'vue'
+import { ref, computed, Ref } from "vue";
 import XEUtils from "xe-utils";
-import {BizException, ExceptionEnum} from "@/utils/BizException";
-import {stringIsBlank} from "@/utils/blank-utils";
+import { BizException, ExceptionEnum } from "@/utils/BizException";
+import { stringIsBlank } from "@/utils/blank-utils";
 
-declare type CodeType<T> = keyof T & string | ((item: T) => string);
+declare type CodeType<T> = (keyof T & string) | ((item: T) => string);
 
-function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = () => '请勿重复添加'): [Ref<T[]>, {
+function cyRefList<T = any>(
+  code: CodeType<T>,
+  errMsg: (item: T) => string = () => "请勿重复添加"
+): [
+  Ref<T[]>,
+  {
     push: (...items: T[]) => number;
     watchPush: (cb: (value: T) => void) => () => void;
     delIndex: (index: number) => void;
@@ -14,90 +19,90 @@ function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = ()
     emptyError: (errorMsg?: string) => void;
     forEach: (cb: (item: T, index: number) => void) => void;
     eachAndReturnList: (iteration: (item: T, index: number) => any) => any[];
-}] {
-    const list = ref([]) as Ref<T[]>
-    const watchFunc: Function[] = []
+  },
+] {
+  const list = ref([]) as Ref<T[]>;
+  const watchFunc: Function[] = [];
 
-    const codeIsFunction = typeof code === 'function'
+  const codeIsFunction = typeof code === "function";
 
-    const codeKey = computed<string[]>(() => {
-        return XEUtils.eachAndReturnList(list.value, (item) => {
-            if (codeIsFunction) {
-                return code(item)
-            }
-            return item[code]
-        });
+  const codeKey = computed<string[]>(() => {
+    return XEUtils.eachAndReturnList(list.value, item => {
+      if (codeIsFunction) {
+        return code(item);
+      }
+      return item[code];
     });
+  });
 
-    function sendListening(items: any) {
-        return new Promise(resolve => {
-            watchFunc.forEach(item => item(items))
-            resolve(true)
-        })
-    }
+  function sendListening(items: any) {
+    return new Promise(resolve => {
+      watchFunc.forEach(item => item(items));
+      resolve(true);
+    });
+  }
 
-    const listProxy = {
-        push: function (...items: T[]) {
-            const msgList: string[] = []
-            items.forEach((item: T) => {
-                let key: string;
-                if (codeIsFunction) {
-                    key = code(item)
-                } else {
-                    key = item[code] as string
-                }
-                if (stringIsBlank(key)) {
-                    BizException(ExceptionEnum.MESSAGE_ERROR, "没有找到唯一值");
-                }
-                if (codeKey.value.includes(key)) {
-                    const msg = errMsg(item)
-                    msgList.push(msg)
-                }
-            })
-            if (msgList.length === 1) {
-                BizException(ExceptionEnum.MESSAGE_ERROR, msgList[0]);
-            } else if (msgList.length > 0) {
-                BizException(ExceptionEnum.MESSAGE_HTML_ERROR, msgList.join("<br/>"));
-            }
-            sendListening(items).then(r => {
-            });
-            return list.value.push(...items)
-        },
-        watchPush: function (cb: (value: T) => void) {
-            const index = watchFunc.push(cb)
+  const listProxy = {
+    push: function (...items: T[]) {
+      const msgList: string[] = [];
+      items.forEach((item: T) => {
+        let key: string;
+        if (codeIsFunction) {
+          key = code(item);
+        } else {
+          key = item[code] as string;
+        }
+        if (stringIsBlank(key)) {
+          BizException(ExceptionEnum.MESSAGE_ERROR, "没有找到唯一值");
+        }
+        if (codeKey.value.includes(key)) {
+          const msg = errMsg(item);
+          msgList.push(msg);
+        }
+      });
+      if (msgList.length === 1) {
+        BizException(ExceptionEnum.MESSAGE_ERROR, msgList[0]);
+      } else if (msgList.length > 0) {
+        BizException(ExceptionEnum.MESSAGE_HTML_ERROR, msgList.join("<br/>"));
+      }
+      sendListening(items).then(r => {});
+      return list.value.push(...items);
+    },
+    watchPush: function (cb: (value: T) => void) {
+      const index = watchFunc.push(cb);
 
-            function stop() {
-                watchFunc.splice(index, 0)
-            }
+      function stop() {
+        watchFunc.splice(index, 0);
+      }
 
-            return stop
-        },
-        delIndex: function (index: number) {
-            list.value.splice(index, 1);
-        },
-        clear: function () {
-            list.value = []
-        },
-        isEmpty() {
-            return list.value === null || list.value.length === 0
-        },
-        emptyError(errorMsg = '请先选择数据') {
-            if (this.isEmpty()) {
-                BizException(ExceptionEnum.MESSAGE_ERROR, errorMsg)
-            }
-        },
-        forEach(cb: (item: T, index: number) => void) {
-            for (let i = 0, len = list.value.length; i < len; i++) {
-                const item = list.value[i]
-                cb(item, i)
-            }
-        },
-        eachAndReturnList(iteration: (item: T, index: number) => any) {
-            return XEUtils.eachAndReturnList(list, iteration)
-        },
-    }
+      return stop;
+    },
+    delIndex: function (index: number) {
+      list.value.splice(index, 1);
+    },
+    clear: function () {
+      list.value = [];
+    },
+    isEmpty() {
+      return list.value === null || list.value.length === 0;
+    },
+    emptyError(errorMsg = "请先选择数据") {
+      if (this.isEmpty()) {
+        BizException(ExceptionEnum.MESSAGE_ERROR, errorMsg);
+      }
+    },
+    forEach(cb: (item: T, index: number) => void) {
+      for (let i = 0, len = list.value.length; i < len; i++) {
+        const item = list.value[i];
+        cb(item, i);
+      }
+    },
+    eachAndReturnList(iteration: (item: T, index: number) => any) {
+      return XEUtils.eachAndReturnList(list, iteration);
+    },
+  };
 
-    return [list, listProxy]
+  return [list, listProxy];
 }
 
-export default cyRefList
+export default cyRefList;

+ 23 - 17
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins/opinion/AuditRecord.vue

@@ -1,19 +1,20 @@
 <script setup lang="ts">
-import {emrAuditRootContextKey, EmrAuditV2Store} from "./useEmrAudit";
+import { emrAuditRootContextKey, EmrAuditV2Store } from "./useEmrAudit";
 import {
   deleteEmrAuditByEmrId,
   EmrAuditDetail,
   rectifyMedicalRecords,
 } from "@/api/zhu-yuan-yi-sheng/emr-audit";
-import {useUserStore} from "@/pinia/user-store";
-import {formatDateToStr} from "@/utils/moment-utils";
-import AuditDisplayComponent
-  from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins/opinion/AuditDisplayComponent.vue";
-import {ElMessageBox} from "element-plus";
-import {needRule} from "@/utils/public";
+import { useUserStore } from "@/pinia/user-store";
+import { formatDateToStr } from "@/utils/moment-utils";
+import AuditDisplayComponent from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins/opinion/AuditDisplayComponent.vue";
+import { ElMessageBox } from "element-plus";
+import { needRule } from "@/utils/public";
 
 const root = inject(emrAuditRootContextKey) as EmrAuditV2Store;
 
+const userInfo = useUserStore().userInfo;
+
 function rectification(row: EmrAuditDetail, flag) {
   rectifyMedicalRecords(row.id, flag).then(() => {
     row.modificationTime = formatDateToStr(new Date());
@@ -23,11 +24,15 @@ function rectification(row: EmrAuditDetail, flag) {
 }
 
 async function delById(row: EmrAuditDetail, index: number) {
-  await ElMessageBox.confirm('是否删除该意见', '提示', {
-    type: 'error',
+  await ElMessageBox.confirm("是否删除该意见", "提示", {
+    type: "error",
   });
-  await deleteEmrAuditByEmrId(row.id)
-  root!.state.currentAudit.splice(index, 1)
+  await deleteEmrAuditByEmrId(row.id);
+  root!.state.currentAudit.splice(index, 1);
+}
+
+function showDel(item: EmrAuditDetail) {
+  return needRule(78) || item.approver === userInfo.code;
 }
 </script>
 
@@ -43,12 +48,13 @@ async function delById(row: EmrAuditDetail, index: number) {
         <el-col :span="12">
           <el-button @click="rectification(item, 2)"> 已知</el-button>
         </el-col>
-        <el-col :span="24" v-if="needRule(78)">
-          <el-button size="default"
-                     style="width: 100%"
-                     type="danger"
-                     @click="() =>delById(item, index)"
-          >删除
+        <el-col :span="24" v-if="showDel(item)">
+          <el-button
+            size="default"
+            style="width: 100%"
+            type="danger"
+            @click="() => delById(item, index)"
+            >删除
           </el-button>
         </el-col>
       </template>

+ 250 - 262
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore.ts

@@ -1,303 +1,291 @@
-import {type InjectionKey, ref} from "vue";
-import {EditType, Outline} from "@/utils/emr/edit";
-import {xcMessage} from "@/utils/xiaochan-element-plus";
-import {stringNotBlank} from "@/utils/blank-utils";
+import { ref } from "vue";
+import { EditType, Outline } from "@/utils/emr/edit";
+import { xcMessage } from "@/utils/xiaochan-element-plus";
+import { stringNotBlank } from "@/utils/blank-utils";
 import usePromise from "@/utils/cy-use/usePromise";
 import XEUtils from "xe-utils";
-import {CyMessageBox} from "@/components/cy/message-box";
+import { CyMessageBox } from "@/components/cy/message-box";
 import * as utilsPlugins from "../emr-editor/plugins";
-import {ReturnPlugins} from "../emr-editor/plugins";
-import {UseEmrInitReturn} from "@/utils/emr/emr-init-v2";
-import {EmrRightTabs} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
+import { ReturnPlugins } from "../emr-editor/plugins";
+import { UseEmrInitReturn } from "@/utils/emr/emr-init-v2";
+import { EmrRightTabs } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
 import sleep from "@/utils/sleep";
 import emrFunUtils from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/emr-fun-utils";
-import {EmrPatientData} from "@/api/zhu-yuan-yi-sheng/emr-patient";
-import * as socket
-    from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/socket/useEmrSocket";
+import { EmrPatientData } from "@/api/zhu-yuan-yi-sheng/emr-patient";
+import * as socket from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/socket/useEmrSocket";
 
 type Pl<D> = {
-    [K in keyof D]: D[K] extends (...args: any[]) => infer R ? R : any;
+  [K in keyof D]: D[K] extends (...args: any[]) => infer R ? R : any;
 };
 
 export const rightCompIndex = {
-    opinion: 0,
-    ca: 1,
+  opinion: 0,
+  ca: 1,
 };
 
 function getPlugins() {
-    const tmp = {};
-    for (let key in utilsPlugins) {
-        tmp[key] = utilsPlugins[key]();
-    }
-    return tmp as Pl<typeof utilsPlugins>;
+  const tmp = {};
+  for (let key in utilsPlugins) {
+    tmp[key] = utilsPlugins[key]();
+  }
+  return tmp as Pl<typeof utilsPlugins>;
 }
 
 export type RightComp = {
-    name: string;
-    comp: any;
-    refValue?: any;
-    paneProps?: any;
+  name: string;
+  comp: any;
+  refValue?: any;
+  paneProps?: any;
 };
 
 export const useEmrStore = (patId: string) => {
-    const patInfo = ref({});
-    const emrPatientData = ref({});
-    const outline = ref<Outline[]>([]);
-    let editor: EditType | null = null;
+  const patInfo = ref({});
+  const emrPatientData = ref({});
+  const outline = ref<Outline[]>([]);
+  let editor: EditType | null = null;
 
-    const emrTemplate = ref({
-        emrTree: [],
-        deptTree: [],
-        patientTree: [],
-    });
+  const emrTemplate = ref({
+    emrTree: [],
+    deptTree: [],
+    patientTree: [],
+  });
 
-    const store = reactive({
-        currentPlugins: [] as ReturnPlugins[],
-        plugins: [] as ReturnPlugins[],
-        right: EmrRightTabs.fragment,
-        rightWidth: 220,
-        courseJumpId: null,
-        editor: null as EditType,
-        rightComp: [] as RightComp[],
-        // 病历的名称
-        templateName: "",
-        // 病历的编码
-        categoryCode: "",
-        // 如果不是模板就有这个
-        emrPatientData: {} as EmrPatientData,
-        parent: "",
-        isEditorChange: false,
+  const store = reactive({
+    currentPlugins: [] as ReturnPlugins[],
+    plugins: [] as ReturnPlugins[],
+    right: EmrRightTabs.fragment,
+    rightWidth: 220,
+    courseJumpId: null,
+    editor: null as EditType,
+    rightComp: [] as RightComp[],
+    // 病历的名称
+    templateName: "",
+    // 病历的编码
+    categoryCode: "",
+    // 如果不是模板就有这个
+    emrPatientData: {} as EmrPatientData,
+    parent: "",
+    isEditorChange: false,
 
-        currentDocumentData: [] as { id: string; name: string }[],
+    currentDocumentData: [] as { id: string; name: string }[],
 
-        socketToken: "",
-    });
+    socketToken: "",
+  });
 
-    const kicked = reactive({
-        // 踢人方
-        a: {
-            dialog: false,
-            id: "",
-            waitForSeconds: 0,
-            resolve: () => {
-            },
-            reject: () => {
-            },
+  const kicked = reactive({
+    // 踢人方
+    a: {
+      dialog: false,
+      id: "",
+      waitForSeconds: 0,
+      resolve: () => {},
+      reject: () => {},
 
-            open(value: string) {
-                kicked.a.waitForSeconds = 0;
-                kicked.a.id = value;
-                kicked.a.dialog = true;
-                return new Promise((resolve, reject) => {
-                    //@ts-ignore
-                    kicked.a.resolve = resolve;
-                    kicked.a.reject = reject;
-                });
-            },
-        },
-        // 被踢方
-        b: {
-            dialog: false,
-            title: "",
-            message: [],
-            userInfo: {},
-            wsSend: (value: { code: string; data?: any }) => {
-            },
-            onMsg: {
-                kickItOut: value => {
-                    kicked.b.userInfo = value;
-                    kicked.b.dialog = true;
-                    kicked.b.title = `【${value.name}】想要编辑,当前病历`;
-                },
-            },
-            agree: () => 0 as any,
+      open(value: string) {
+        kicked.a.waitForSeconds = 0;
+        kicked.a.id = value;
+        kicked.a.dialog = true;
+        return new Promise((resolve, reject) => {
+          //@ts-ignore
+          kicked.a.resolve = resolve;
+          kicked.a.reject = reject;
+        });
+      },
+    },
+    // 被踢方
+    b: {
+      dialog: false,
+      title: "",
+      message: [],
+      userInfo: {},
+      wsSend: (value: { code: string; data?: any }) => {},
+      onMsg: {
+        kickItOut: value => {
+          kicked.b.userInfo = value;
+          kicked.b.dialog = true;
+          kicked.b.title = `【${value.name}】想要编辑,当前病历`;
         },
-    });
+      },
+      agree: () => 0 as any,
+    },
+  });
 
-    const plugins = getPlugins();
-    const editFun = emrFunUtils();
-
-    const mutation = {
-        setEmrPatientData(data: any) {
-            emrPatientData.value = data;
-        },
-        setEditor(value: EditType) {
-            editor = value;
-            store.editor = editor;
-            editFun.setEditor(value);
-        },
-        async setOutline() {
-            await sleep(500);
-            outline.value = editor.getOutline();
-        },
-        installPlugins(value: UseEmrInitReturn, tmpStore: any) {
-            for (let key in plugins) {
-                const item = plugins[key];
-                item?.install?.({e: value.editor, r: value.runtime, s: tmpStore});
-                store.plugins.push(item);
-            }
-        },
-        setCurrentPlugin(code: string) {
-            if (!code) {
-                store.currentPlugins = [];
-            }
-            const tmp = [];
-            for (let i = 0; i < store.plugins.length; i++) {
-                const item = store.plugins[i];
-                if (typeof item.categoryCode === "undefined") {
-                    tmp.push(item);
-                }
-                if (item.categoryCode && item.categoryCode.includes(code)) {
-                    tmp.push(item);
-                }
-            }
-            store.currentPlugins = tmp;
-        },
-    };
+  const plugins = getPlugins();
+  const editFun = emrFunUtils();
 
-    const cache = {
-        open() {
-            if (window.indexedDB) {
-                editor?.openCache();
-                xcMessage.success("您的电脑支持本地缓存");
-                return;
-            }
-            xcMessage.error("您的电脑不支持缓存,请升级浏览器");
-        },
-        saveCache() {
-            if (editor == null) {
-                xcMessage.error("无法缓存,请等待页面加载完成");
-                return;
-            }
-            if (!editor!._cacheDBIsOpen) {
-                xcMessage.error("您的电脑不支持缓存,请升级浏览器");
-                return;
-            }
-            let key = "";
-            if (stringNotBlank(editor?.documentData._id)) {
-                key = "id-" + editor?.documentData._id;
-            } else if (stringNotBlank(editor?.documentData.categoryId)) {
-                key = "code-" + patId + "-" + editor?.documentData.categoryId;
-            } else {
-                xcMessage.error("无法缓存,请先打开一个病历");
-                return;
-            }
-            editor.setCacheData(key);
-            xcMessage.success("缓存成功,刷新后可恢复");
-        },
-        getAll(table = "docdata") {
-            const promise = usePromise<{ _key: string }[]>();
+  const mutation = {
+    setEmrPatientData(data: any) {
+      emrPatientData.value = data;
+    },
+    setEditor(value: EditType) {
+      editor = value;
+      store.editor = editor;
+      editFun.setEditor(value);
+    },
+    async setOutline() {
+      await sleep(500);
+      outline.value = editor.getOutline();
+    },
+    installPlugins(value: UseEmrInitReturn, tmpStore: any) {
+      for (let key in plugins) {
+        const item = plugins[key];
+        item?.install?.({ e: value.editor, r: value.runtime, s: tmpStore });
+        store.plugins.push(item);
+      }
+    },
+    setCurrentPlugin(code: string) {
+      if (!code) {
+        store.currentPlugins = [];
+      }
+      const tmp = [];
+      for (let i = 0; i < store.plugins.length; i++) {
+        const item = store.plugins[i];
+        if (typeof item.categoryCode === "undefined") {
+          tmp.push(item);
+        }
+        if (item.categoryCode && item.categoryCode.includes(code)) {
+          tmp.push(item);
+        }
+      }
+      store.currentPlugins = tmp;
+    },
+  };
 
-            const transaction = editor!._cacheDB.db.transaction(table, "readwrite");
-            transaction.oncomplete = event => {
-                promise.resolve(event);
-            };
-            transaction.onerror = event => {
-                promise.reject(event);
-            };
-            let objectStore = transaction.objectStore(table);
-            objectStore.getAll().onsuccess = event => {
-                // @ts-ignore
-                const data = event.target.result;
-                if (XEUtils.isArray(data)) {
-                    promise.resolve(data);
-                } else {
-                    promise.reject(event);
-                }
-            };
-            return promise.promise;
-        },
-        reduction({
-                      id,
-                      categoryId,
-                  }: {
-            id: string | null | undefined;
-            categoryId: string;
-        }) {
-            return new Promise(async (resolve, reject) => {
-                const cacheData = await this.getAll().catch(() => []);
-                let key = "";
-                if (stringNotBlank(id)) {
-                    key = "id-" + id;
-                } else if (stringNotBlank(categoryId)) {
-                    key = "code-" + patId + "-" + categoryId;
-                }
+  const cache = {
+    open() {
+      if (window.indexedDB) {
+        editor?.openCache();
+        xcMessage.success("您的电脑支持本地缓存");
+        return;
+      }
+      xcMessage.error("您的电脑不支持缓存,请升级浏览器");
+    },
+    saveCache() {
+      if (editor == null) {
+        xcMessage.error("无法缓存,请等待页面加载完成");
+        return;
+      }
+      if (!editor!._cacheDBIsOpen) {
+        xcMessage.error("您的电脑不支持缓存,请升级浏览器");
+        return;
+      }
+      let key = "";
+      if (stringNotBlank(editor?.documentData._id)) {
+        key = "id-" + editor?.documentData._id;
+      } else if (stringNotBlank(editor?.documentData.categoryId)) {
+        key = "code-" + patId + "-" + editor?.documentData.categoryId;
+      } else {
+        xcMessage.error("无法缓存,请先打开一个病历");
+        return;
+      }
+      editor.setCacheData(key);
+      xcMessage.success("缓存成功,刷新后可恢复");
+    },
+    getAll(table = "docdata") {
+      const promise = usePromise<{ _key: string }[]>();
 
-                function dialog(dataKey: string) {
-                    CyMessageBox.confirm({
-                        message: "监测到本地缓存是否使用缓存的数据",
-                        confirmButtonText: "使用",
-                        cancelButtonText: "不使用",
-                    })
-                        .then(() => {
-                            editor!.loadCacheData(dataKey);
-                            editor!.delCacheData(dataKey);
-                            resolve(true);
-                        })
-                        .catch(() => {
-                            reject(false);
-                        });
-                }
+      const transaction = editor!._cacheDB.db.transaction(table, "readwrite");
+      transaction.oncomplete = event => {
+        promise.resolve(event);
+      };
+      transaction.onerror = event => {
+        promise.reject(event);
+      };
+      let objectStore = transaction.objectStore(table);
+      objectStore.getAll().onsuccess = event => {
+        // @ts-ignore
+        const data = event.target.result;
+        if (XEUtils.isArray(data)) {
+          promise.resolve(data);
+        } else {
+          promise.reject(event);
+        }
+      };
+      return promise.promise;
+    },
+    reduction({
+      id,
+      categoryId,
+    }: {
+      id: string | null | undefined;
+      categoryId: string;
+    }) {
+      return new Promise(async (resolve, reject) => {
+        const cacheData = await this.getAll().catch(() => []);
+        let key = "";
+        if (stringNotBlank(id)) {
+          key = "id-" + id;
+        } else if (stringNotBlank(categoryId)) {
+          key = "code-" + patId + "-" + categoryId;
+        }
 
-                for (let i = 0; i < cacheData.length; i++) {
-                    const item = cacheData[i];
-                    if (item._key === key) {
-                        dialog(item._key);
-                        return;
-                    }
-                }
-                reject(false);
+        function dialog(dataKey: string) {
+          CyMessageBox.confirm({
+            message: "监测到本地缓存是否使用缓存的数据",
+            confirmButtonText: "使用",
+            cancelButtonText: "不使用",
+          })
+            .then(() => {
+              editor!.loadCacheData(dataKey);
+              editor!.delCacheData(dataKey);
+              resolve(true);
+            })
+            .catch(() => {
+              reject(false);
             });
-        },
-    };
-
-    const emrSocket = socket.useEmrSocket(patId, store, () => editor);
-    const documentSocket = socket.documentSocket(kicked, () => editor);
-
-    return {
-        patInfo,
-        getEditor() {
-            return editor;
-        },
-        documentSocket,
-        emrSocket,
-        emrPatientData,
-        mutation,
-        outline,
-        cache,
-        plugins,
-        store,
-        emrTemplate,
-        editFun,
-        kicked,
-        getRightComp(index) {
-            return store.rightComp[index];
-        },
-    };
-};
+        }
 
-type EmrStore = ReturnType<typeof useEmrStore>;
-export const emrRootContextKey = "emrRootContext"
+        for (let i = 0; i < cacheData.length; i++) {
+          const item = cacheData[i];
+          if (item._key === key) {
+            dialog(item._key);
+            return;
+          }
+        }
+        reject(false);
+      });
+    },
+  };
 
-type EmrRootContext = {
-    store: EmrStore;
-}
+  const emrSocket = socket.useEmrSocket(patId, store, () => editor);
+  const documentSocket = socket.documentSocket(kicked, () => editor);
 
-export type {EmrStore, EmrRootContext};
+  return {
+    patInfo,
+    getEditor() {
+      return editor;
+    },
+    documentSocket,
+    emrSocket,
+    emrPatientData,
+    mutation,
+    outline,
+    cache,
+    plugins,
+    store,
+    emrTemplate,
+    editFun,
+    kicked,
+    getRightComp(index) {
+      return store.rightComp[index];
+    },
+  };
+};
 
+export type EmrStore = ReturnType<typeof useEmrStore>;
+export const emrRootContextKey = "emrRootContext";
 
 export const elementHas = (
-    view,
-    name,
-    code: "internal" | "business" = "internal"
+  view,
+  name,
+  code: "internal" | "business" = "internal"
 ) => {
-    const element = view.getAttribute("element");
-    if (element) {
-        const data = XEUtils.get(element, `code.${code}`);
-        if (data === name) {
-            return element;
-        }
+  const element = view.getAttribute("element");
+  if (element) {
+    const data = XEUtils.get(element, `code.${code}`);
+    if (data === name) {
+      return element;
     }
-    throw new Error("no elementHas");
+  }
+  throw new Error("no elementHas");
 };
-

+ 34 - 35
src/views/hospitalization/zhu-yuan-yi-sheng/public-js/useDoctorStore.ts

@@ -1,47 +1,46 @@
-import {ref} from 'vue'
+import { ref } from "vue";
 import CyCache from "@/utils/CyCache";
-import {viewInspectionItemDetails} from "@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing";
-import {useCyNamespace} from "@/utils/xiaochan-element-plus";
-
+import { viewInspectionItemDetails } from "@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing";
+import { useCyNamespace } from "@/utils/xiaochan-element-plus";
 
 export enum YzSidebarEnum {
-    PATIENT_LIST = 'patientList',
-    YZ = 'yz',
-    JC = 'jc',
-    JY = 'jy',
+  PATIENT_LIST = "patientList",
+  YZ = "yz",
+  JC = "jc",
+  JY = "jy",
 }
 
 const useDoctorStore = () => {
-    const yzSidebar = ref('patientList')
-    const jcJyCache = new CyCache('jcJy');
-    const ns = useCyNamespace('zy-doctor')
-
-    async function getJcFeeDetails(key: string, row: any) {
-        return await jcJyCache.get(key, async () => {
-            return await viewInspectionItemDetails(key).catch(() => {
-                return null
-            })
-        })
-    }
-
-    function setYzSidebar(val: YzSidebarEnum) {
-        yzSidebar.value = val
-    }
-
-    return {
-        yzSidebar,
-        getJcFeeDetails,
-        setYzSidebar,
-        ns
-    }
-}
+  const yzSidebar = ref("patientList");
+  const jcJyCache = new CyCache("jcJy");
+  const ns = useCyNamespace("zy-doctor");
+
+  async function getJcFeeDetails(key: string, row: any) {
+    return await jcJyCache.get(key, async () => {
+      return await viewInspectionItemDetails(key).catch(() => {
+        return null;
+      });
+    });
+  }
+
+  function setYzSidebar(val: YzSidebarEnum) {
+    yzSidebar.value = val;
+  }
+
+  return {
+    yzSidebar,
+    getJcFeeDetails,
+    setYzSidebar,
+    ns,
+  };
+};
 
 class DoctorStore {
-    Return = useDoctorStore()
+  Return = useDoctorStore();
 }
 
-export type DoctorStoreType = DoctorStore['Return']
+export type DoctorStoreType = DoctorStore["Return"];
 
-const doctorStore = useDoctorStore()
+const doctorStore = useDoctorStore();
 
-export default doctorStore
+export default doctorStore;