Browse Source

电子病历优化

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
3bb91f7ece

+ 64 - 49
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/EmrMain.vue

@@ -392,6 +392,50 @@ const predefineColors = ref([
   '#c7158577',
 ])
 
+const emrEvent = {
+  'loaded': async (event) => {
+    editor = currentEmr.value.getEditor()
+    loaded = false
+    setEditorModeFun()
+    courseSegmentLocking()
+    setTheProgressAnchor()
+    deleteDataElement()
+    reQueryPatientInformation()
+    isRevisionMode()
+  },
+
+  'contentchange': (event) => {
+    if (!readonlyPattern()) {
+      // 如果是空的编辑器就不触发了
+      if (!emrRef.value.src.includes('/emr/runtime/#/editor')) {
+        // 判断内容是否改变
+        isEditorChange = true
+        emrSidebarRef.value.changeTemplateType(2)
+      }
+    }
+  },
+
+  'contextUpdate': (evt, contextMap, component, context) => {
+    emrStyle.fontSize = context.fontSize
+    emrStyle.fontFamily = context.fontFamily
+    emrStyle.fontStyle = context.italic ? 'oblique' : 'normal'
+    emrStyle.fontWeight = context.bold ? 'bold' : 'normal'
+    emrStyle.underline = context.underline
+    emrStyle.lineThrough = context.linethrough
+    emrStyle.super = context.superScript
+    emrStyle.sub = context.subScript
+    emrStyle.color = context.color
+    emrStyle.backgroundColor = context.backgroundColor
+    emrStyle.paragraphStyle = context.paragraphStyle
+
+  },
+
+  'ready': (event) => {
+    editor = currentEmr.value.getEditor()
+  }
+
+}
+
 // 点击保存病历
 const clickSaveData = async () => {
   // 只读模式无法保存数据
@@ -638,8 +682,25 @@ const clickSnippet = ({content, styles, code}) => {
     }
   }
   if (!readonlyPattern()) {
-    currentEmr.value.callMethod('setCursor', 'AREA_END')
-    currentEmr.value.insertSnippet(content, styles, data)
+    let root = editor.model.document.getRoot()
+    let lastView = root.getChild(root.childCount - 1).view
+    lastView.setAttribute('readonly', false)
+    //移动到文档结尾
+    editor.setCursor('DOCUMENT_END');
+    editor.scrollToCursor()
+    let insertContent = {
+      // 内容
+      value: content,
+      // 样式
+      styles: styles,
+      isFragment: true,
+      // 就是在这里填充的值
+      defaultData: data
+    }
+    editor.execute("insertContents", insertContent);
+    lastView.setAttribute('readonly', true)
+    editor.setCursor('DOCUMENT_END');
+    editor.scrollToCursor()
   }
 }
 
@@ -661,50 +722,6 @@ const getCurrentPersonnelInformation = (data) => {
   patientData.user_token = userData.token
 }
 
-const emrEvent = {
-  'loaded': async (event) => {
-    editor = currentEmr.value.getEditor()
-    loaded = false
-    setEditorModeFun()
-    courseSegmentLocking()
-    setTheProgressAnchor()
-    deleteDataElement()
-    reQueryPatientInformation()
-    isRevisionMode()
-  },
-
-  'contentchange': (event) => {
-    if (!readonlyPattern()) {
-      // 如果是空的编辑器就不触发了
-      if (!emrRef.value.src.includes('/emr/runtime/#/editor')) {
-        // 判断内容是否改变
-        isEditorChange = true
-        emrSidebarRef.value.changeTemplateType(2)
-      }
-    }
-  },
-
-  'contextUpdate': (evt, contextMap, component, context) => {
-    emrStyle.fontSize = context.fontSize
-    emrStyle.fontFamily = context.fontFamily
-    emrStyle.fontStyle = context.italic ? 'oblique' : 'normal'
-    emrStyle.fontWeight = context.bold ? 'bold' : 'normal'
-    emrStyle.underline = context.underline
-    emrStyle.lineThrough = context.linethrough
-    emrStyle.super = context.superScript
-    emrStyle.sub = context.subScript
-    emrStyle.color = context.color
-    emrStyle.backgroundColor = context.backgroundColor
-    emrStyle.paragraphStyle = context.paragraphStyle
-
-    console.log(evt, contextMap, component, context)
-  },
-
-  'ready': (event) => {
-    editor = currentEmr.value.getEditor()
-  }
-
-}
 
 // 设置编辑器的模式
 const setEditorModeFun = () => {
@@ -715,7 +732,7 @@ const setEditorModeFun = () => {
     // 如果不是首次病程记录就需要执行下面的代码
     if (!categoryCode.includes('shoucibingchengjilu')) {
       if (createId === null) {
-        return
+        return currentEmr.value.callMethod('setEditorMode', 'readonly');
       }
       // 创建人不是自己就只能看
       if (doctorLevel === 1 && createId !== userData.code) {
@@ -734,7 +751,6 @@ const setEditorModeFun = () => {
         currentEmr.value.callMethod('setEditorMode', 'free');
       }
     }
-
     // 如果创建人不是自己就要开启审阅
     if (createId === userData.code) {
       editor.setRevisionMode('off')
@@ -742,7 +758,6 @@ const setEditorModeFun = () => {
       xcMessage.warning('当前病历创建人不是您,你的操作将会留痕。')
       editor.setRevisionMode('on')
     }
-
   } else {
     currentEmr.value.callMethod('setEditorMode', 'readonly')
   }