Browse Source

优化代码

xiaochan 1 year ago
parent
commit
ed35923907

+ 1 - 0
.env.dev

@@ -4,5 +4,6 @@ VITE_BASE_URL = 'http://172.16.30.61:7201'
 VITE_SOCKET_URL = 'ws://172.16.30.61:8707/websocket/'
 VITE_EMR_CONTROL_URL = '172.16.30.61:9227'
 VITE_DATA_BASE = 'http://172.16.30.61:9205'
+VITE_EMR_SOCKET = 'http://localhost:8707/socketApi'
 
 VITE_UPLOAD_TEMPLATE_THUMB = 'http://192.168.200.3:8805/wxserver/wxApplet/updateTemplateThumb'

+ 1 - 0
.env.production

@@ -4,5 +4,6 @@ VITE_BASE_URL = 'http://172.16.32.160:8077'
 VITE_SOCKET_URL = 'ws://172.16.32.160:8707/websocket/'
 VITE_EMR_CONTROL_URL = '172.16.32.160:9227'
 VITE_DATA_BASE = 'http://172.16.32.160:9205'
+VITE_EMR_SOCKET = 'http://172.16.32.160:8707/socketApi'
 
 VITE_UPLOAD_TEMPLATE_THUMB = 'http://staticweb.hnthyy.cn/wxserver/wxApplet/updateTemplateThumb'

+ 27 - 12
src/directives/v-el-btn.ts

@@ -3,22 +3,26 @@ import sleep from "../utils/sleep";
 const loadingName: string = 'xc-loading'
 
 const VElBtn = {
-    // 这里有个 bug 如果使用了 v-loading 的话
     created(el: HTMLHtmlElement, binding, vnode, prevVnode) {
+        /**
+         * 这里有个 bug 如果使用了 v-loading 的话有问题
+         * 这个函数一定要是 promise 函数
+         * 如果这个函数需要参数的话,需要:
+         * <el-button v-el-btn="{
+         *     func : a ,
+         *     value: true
+         *   }">测试 </el-button> 这样写
+         *
+         *   无参函数:
+         *   <el-button v-el-btn="a">测试</el-button>
+         *
+         * @param ev 事件
+         */
         el.addEventListener('click', async (ev: Event) => {
             ev.stopPropagation();
             let startTime: Date = new Date();
-            try {
-                vnode.ref.i.props.loading = true
-                el.setAttribute(loadingName, 'true')
-                if (binding.value.func) {
-                    await binding.value.func(binding.value.value)
-                } else {
-                    await binding.value();
-                }
-            } catch (e) {
-                console.error(e)
-            } finally {
+
+            async function finallyFunc() {
                 let endTime = new Date()
                 if (endTime.getTime() - startTime.getTime() < 1000) {
                     await sleep(500)
@@ -27,6 +31,17 @@ const VElBtn = {
                 vnode.ref.i.props.loading = false
             }
 
+            vnode.ref.i.props.loading = true
+            el.setAttribute(loadingName, 'true')
+            if (binding.value.func) {
+                await (binding.value.func(binding.value.value) as Promise<any>).finally(() => {
+                    finallyFunc()
+                })
+            } else {
+                await (binding.value() as Promise<any>).finally(() => {
+                    finallyFunc()
+                })
+            }
         });
     },
     updated(el: HTMLHtmlElement, binding, vnode, prevVnode) {

+ 1 - 1
src/utils/public.ts

@@ -1,6 +1,6 @@
 // @ts-ignore
 import store from '@/store'
-import {xcMessage} from "../utils/xiaochan-element-plus";
+import {xcMessage} from "./xiaochan-element-plus";
 import XEUtils from "xe-utils";
 
 export function needRule(...val) {

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

@@ -87,6 +87,7 @@ import LoadingProgress from "@/components/loading-progress/LoadingProgress.vue";
 import {ref, onMounted, nextTick} from 'vue'
 import {CyMessageBox} from "@/components/cy/message-box";
 import sleep from "@/utils/sleep";
+import {isDev} from "@/utils/public";
 
 const patInfoRef = ref(null)
 const emrMainRef = ref(null)
@@ -160,7 +161,9 @@ const routerFunc = async () => {
     return
   }
   console.log('查询数据 %o', query.value)
-  let reqUnlock = await getMyUnlockByPatNo(query.value.patNo, query.value.times)
+  let reqUnlock = await getMyUnlockByPatNo(query.value.patNo, query.value.times).catch(e => {
+    return null;
+  })
   console.log('申请数据 %o', reqUnlock)
   if (reqUnlock != null) {
     reqUnlock.unlockJson = JSON.parse(reqUnlock.unlockJson)
@@ -206,6 +209,11 @@ const queryDisPatient = async () => {
   if (!emrConfig.value.editor) {
     emrConfig.value.editor = canIUnlockIt(unlockEnum.出院编辑)
   }
+
+  if (isDev) {
+    emrConfig.value.editor = true;
+  }
+
   show.value = true;
 }
 

+ 2 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/force-refresh-func.ts

@@ -2,7 +2,8 @@ import {isDev} from "../../../../../utils/public";
 import {ref} from "vue";
 import requestV2 from "../../../../../utils/request-v2";
 
-const api: string = isDev ? 'http://localhost:8707/socketApi' : 'http://172.16.32.160:8707/socketApi'
+// @ts-ignore
+const api: string = import.meta.env.VITE_EMR_SOCKET
 
 export interface SendEmrSocketParam {
     /**