Bladeren bron

优化代码

DESKTOP-0GD05B0\Administrator 2 jaren geleden
bovenliggende
commit
b098555010

+ 3 - 0
src/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/report-of-infectious-diseases/DialogDiseases.vue

@@ -533,6 +533,7 @@ import {getServerDateApi} from "@/api/public-api";
 import {stringIsBlank} from "@/utils/blank-utils";
 import {confirmCrb, getContagiousDiseaseByPatNo, updateCrb} from "@/api/zhu-yuan-yi-sheng/infectious-diseases";
 import XcTableV3 from "@/components/xiao-chan/xc-table-v3/XcTableV3.vue";
+import {xcMessage} from "@/utils/xiaochan-element-plus";
 
 const props = defineProps({
   patNo: {
@@ -663,6 +664,8 @@ const confirm = () => {
         await updateCrb(sheetData)
       }
       await query()
+    } else {
+      xcMessage.error('有必填项不能为空。')
     }
   })
 }

+ 41 - 0
src/utils/public.js

@@ -18,3 +18,44 @@ export function noNeedRule(...val) {
 }
 
 export let isDev = import.meta.env.VITE_BASE_URL !== 'http://172.16.32.160:8706'
+
+
+/**
+ * 对比版本号
+ * @param version1 版本1
+ * @param version2 版本 2
+ * @returns {number} 1 大于 -1小于 0等于
+ */
+export function compareVersion(version1, version2) {
+    const arr1 = version1.split('.')
+    const arr2 = version2.split('.')
+    const length1 = arr1.length
+    const length2 = arr2.length
+    const minlength = Math.min(length1, length2)
+    let i = 0
+    for (i; i < minlength; i++) {
+        let a = parseInt(arr1[i])
+        let b = parseInt(arr2[i])
+        if (a > b) {
+            return 1
+        } else if (a < b) {
+            return -1
+        }
+    }
+    if (length1 > length2) {
+        for (let j = i; j < length1; j++) {
+            if (parseInt(arr1[j]) !== 0) {
+                return 1
+            }
+        }
+        return 0
+    } else if (length1 < length2) {
+        for (let j = i; j < length2; j++) {
+            if (parseInt(arr2[j]) !== 0) {
+                return -1
+            }
+        }
+        return 0
+    }
+    return 0
+}

+ 6 - 6
src/utils/xiaochan-element-plus.js

@@ -2,24 +2,24 @@ import {ElMessage} from "element-plus";
 
 export const xcMessage = {
     success: (msg, isHtml = false) => {
-        message(msg, 'success', isHtml)
+        return message(msg, 'success', isHtml)
     },
     danger: (msg, isHtml = false) => {
-        message(msg, 'danger', isHtml)
+        return message(msg, 'danger', isHtml)
     },
     info: (msg, isHtml = false) => {
-        message(msg, 'info', isHtml)
+        return message(msg, 'info', isHtml)
     },
     warning: (msg, isHtml = false) => {
-        message(msg, 'warning', isHtml)
+        return message(msg, 'warning', isHtml)
     },
     error: (msg, isHtml = false) => {
-        message(msg, 'error', isHtml)
+        return message(msg, 'error', isHtml)
     }
 }
 
 function message(msg, type, isHtml) {
-    ElMessage({
+    return ElMessage({
         type: type,
         duration: 2800,
         dangerouslyUseHTMLString: isHtml,

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

@@ -536,7 +536,7 @@ const emrEvent = {
     await editJudgment()
   },
 
-  'contentchange': (event) => {
+  'contentChange': (event) => {
     if (!readonlyPattern()) {
       // 如果是空的编辑器就不触发了
       if (!emrRef.value.src.includes('/emr/runtime/#/editor')) {
@@ -1112,16 +1112,6 @@ const clickToSubmitTheMedicalRecord = async () => {
 
 }
 
-const visibility = useDocumentVisibility()
-
-watch(() => visibility.value, () => {
-  if (visibility.value === 'hidden' && isEditorChange) {
-    document.title = `患者【${props.huanZheXinXi.name}】,未保存数据`
-  } else {
-    document.title = `电子病历-正在编辑【${props.huanZheXinXi.name}】`
-  }
-}, {immediate: true})
-
 /**
  * 查询患者信息
  * @returns {Promise<void>}
@@ -1407,6 +1397,9 @@ let interval = null
 let intervalTime = 1000 * 60 * 5
 const autoSaveChange = () => {
   store.commit('app/setEmrAutosave', autoSave)
+  if (interval != null) {
+    clearInterval(interval)
+  }
   if (autoSave) {
     interval = setInterval(() => {
       autoSaveFunc()
@@ -1478,9 +1471,10 @@ const openAndSaveTheMedicalRecord = (id) => {
 const showIframe = ref(1)
 const saveDocumentId = ref()
 
+const visibility = useDocumentVisibility()
+
 onMounted(async () => {
   autoSave = store.state.app.emrAutosave;
-  autoSaveChange()
   extractData = await getExtractDataElement(props.huanZheXinXi.inpatientNo, props.huanZheXinXi.admissTimes)
   await nextTick()
   emrSidebarRef.value.queryData()
@@ -1504,6 +1498,19 @@ onMounted(async () => {
   })
   autoSaveFunc()
 
+  watch(() => visibility.value, () => {
+    // 离开页面的时候清空定时器
+    if (visibility.value === 'hidden' && isEditorChange) {
+      if (interval != null) {
+        clearInterval(interval)
+      }
+      document.title = `患者【${props.huanZheXinXi.name}】,未保存数据`
+    } else {
+      autoSaveChange()
+      document.title = `电子病历-正在编辑【${props.huanZheXinXi.name}】`
+    }
+  }, {immediate: true})
+
 })
 
 onDeactivated(() => {