|
@@ -1,111 +1,126 @@
|
|
|
<template>
|
|
|
<EmrChatBox
|
|
|
- v-if="dialog"
|
|
|
- :userSize
|
|
|
- ref="dialogRef"
|
|
|
- :current-editor-user="props.currentEditorUser"
|
|
|
- @closed="dialog = false"
|
|
|
- :user-list="userList"
|
|
|
- :sid="sid"/>
|
|
|
-
|
|
|
- <el-dialog v-model="errDialog" title="与服务器断开连接"
|
|
|
- :show-close="false"
|
|
|
- :close-on-press-escape="false"
|
|
|
- :close-on-click-modal="false">
|
|
|
- <div v-loading="errDialog"
|
|
|
- element-loading-text="正在尝试重新连接..."
|
|
|
- style="width: 100%;height: 400px"/>
|
|
|
+ v-if="dialog"
|
|
|
+ :userSize
|
|
|
+ ref="dialogRef"
|
|
|
+ :current-editor-user="props.currentEditorUser"
|
|
|
+ @closed="dialog = false"
|
|
|
+ :user-list="userList"
|
|
|
+ :sid="sid"
|
|
|
+ />
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ v-model="errDialog"
|
|
|
+ title="与服务器断开连接"
|
|
|
+ :show-close="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ v-loading="errDialog"
|
|
|
+ element-loading-text="正在尝试重新连接..."
|
|
|
+ style="width: 100%; height: 400px"
|
|
|
+ />
|
|
|
</el-dialog>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {stringIsBlank} from "@/utils/blank-utils";
|
|
|
-import {ref, defineProps, onMounted, nextTick, computed, onBeforeUnmount} from 'vue'
|
|
|
-import {xcMessage} from '@/utils/xiaochan-element-plus'
|
|
|
-import {getRoomPeople, sendAMessage} from '@/api/zhu-yuan-yi-sheng/emr-socket'
|
|
|
-import {ElMessageBox, ElNotification} from "element-plus";
|
|
|
-import EmrChatBox from "@/components/zhu-yuan-yi-sheng/emr/web-socket/EmrChatBox.vue";
|
|
|
+import { stringIsBlank } from "@/utils/blank-utils";
|
|
|
import {
|
|
|
- emrMitt
|
|
|
-} from '@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init'
|
|
|
+ ref,
|
|
|
+ defineProps,
|
|
|
+ onMounted,
|
|
|
+ nextTick,
|
|
|
+ computed,
|
|
|
+ onBeforeUnmount,
|
|
|
+} from "vue";
|
|
|
+import { xcMessage } from "@/utils/xiaochan-element-plus";
|
|
|
import {
|
|
|
- forceRefreshDialog
|
|
|
-} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/force-refresh-func";
|
|
|
-import {useUserStore} from "@/pinia/user-store";
|
|
|
-import {isDev} from "@/utils/public";
|
|
|
-import {CyMessageBox} from "@/components/cy/message-box";
|
|
|
+ getRoomPeople,
|
|
|
+ sendAMessage,
|
|
|
+} from "@/api/zhu-yuan-yi-sheng/emr-socket";
|
|
|
+import { ElMessageBox, ElNotification } from "element-plus";
|
|
|
+import EmrChatBox from "@/components/zhu-yuan-yi-sheng/emr/web-socket/EmrChatBox.vue";
|
|
|
+import { emrMitt } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
|
|
|
+import { forceRefreshDialog } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/force-refresh-func";
|
|
|
+import { useUserStore } from "@/pinia/user-store";
|
|
|
+import { isDev } from "@/utils/public";
|
|
|
+import { CyMessageBox } from "@/components/cy/message-box";
|
|
|
|
|
|
const props = defineProps<{
|
|
|
- patInfo: {
|
|
|
- inpatientNo: string,
|
|
|
- admissTimes: string
|
|
|
- } | any,
|
|
|
- currentEditorUser: any
|
|
|
-}>()
|
|
|
-const userData = useUserStore().userInfo
|
|
|
-const roomRef = ref<HTMLElement | null>(null)
|
|
|
+ patInfo:
|
|
|
+ | {
|
|
|
+ inpatientNo: string;
|
|
|
+ admissTimes: string;
|
|
|
+ }
|
|
|
+ | any;
|
|
|
+ currentEditorUser: any;
|
|
|
+}>();
|
|
|
+const userData = useUserStore().userInfo;
|
|
|
+const roomRef = ref<HTMLElement | null>(null);
|
|
|
|
|
|
-const dialog = ref<boolean>(false)
|
|
|
-const errDialog = ref<boolean>(false)
|
|
|
-const userMap = ref<any>({})
|
|
|
-const dialogRef = ref(null)
|
|
|
+const dialog = ref<boolean>(false);
|
|
|
+const errDialog = ref<boolean>(false);
|
|
|
+const userMap = ref<any>({});
|
|
|
+const dialogRef = ref(null);
|
|
|
|
|
|
-const SOCKET_URL = import.meta.env.VITE_SOCKET_URL
|
|
|
+const SOCKET_URL = import.meta.env.VITE_SOCKET_URL;
|
|
|
|
|
|
-let webSocket = null
|
|
|
+let webSocket = null;
|
|
|
|
|
|
-
|
|
|
-const sid = ref(null)
|
|
|
+const sid = ref(null);
|
|
|
|
|
|
const onmessageFunc = {
|
|
|
- "connect": async (data) => {
|
|
|
- await queryTheNumberOfPeopleInTheRoom()
|
|
|
- xcMessage.success('连接成功')
|
|
|
+ connect: async data => {
|
|
|
+ await queryTheNumberOfPeopleInTheRoom();
|
|
|
+ xcMessage.success("连接成功");
|
|
|
},
|
|
|
- "connectToJoin": async (val) => {
|
|
|
- await queryTheNumberOfPeopleInTheRoom()
|
|
|
- let userInfo = userMap.value[val]
|
|
|
+ connectToJoin: async val => {
|
|
|
+ await queryTheNumberOfPeopleInTheRoom();
|
|
|
+ let userInfo = userMap.value[val];
|
|
|
ElNotification({
|
|
|
- type: 'success',
|
|
|
- title: '有新的连接加入',
|
|
|
+ type: "success",
|
|
|
+ title: "有新的连接加入",
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
message: `<span>姓名:${userInfo.name}</span>
|
|
|
<br>
|
|
|
- <span>科室:${userInfo.deptName}</span>`
|
|
|
- })
|
|
|
+ <span>科室:${userInfo.deptName}</span>`,
|
|
|
+ });
|
|
|
},
|
|
|
- "exitEmrEditor": async (val) => {
|
|
|
- let userInfo = userMap.value[val]
|
|
|
+ exitEmrEditor: async val => {
|
|
|
+ let userInfo = userMap.value[val];
|
|
|
ElNotification({
|
|
|
- type: 'error',
|
|
|
- title: '有连接退出',
|
|
|
+ type: "error",
|
|
|
+ title: "有连接退出",
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
message: `<span>姓名:${userInfo.name}</span>
|
|
|
<br>
|
|
|
- <span>科室:${userInfo.deptName}</span>`
|
|
|
- })
|
|
|
- await queryTheNumberOfPeopleInTheRoom()
|
|
|
+ <span>科室:${userInfo.deptName}</span>`,
|
|
|
+ });
|
|
|
+ await queryTheNumberOfPeopleInTheRoom();
|
|
|
},
|
|
|
- "message": async (val) => {
|
|
|
+ message: async val => {
|
|
|
if (dialog.value) {
|
|
|
dialogRef.value.queryJump();
|
|
|
}
|
|
|
- dialog.value = true
|
|
|
+ dialog.value = true;
|
|
|
},
|
|
|
- "notice": (val) => {
|
|
|
+ notice: val => {
|
|
|
ElNotification({
|
|
|
- type: 'success',
|
|
|
- title: '查看或编辑',
|
|
|
- message: val
|
|
|
- })
|
|
|
+ type: "success",
|
|
|
+ title: "查看或编辑",
|
|
|
+ message: val,
|
|
|
+ });
|
|
|
},
|
|
|
- "closeSoctek": (val) => {
|
|
|
+ closeSoctek: val => {
|
|
|
if (isDev) {
|
|
|
- window.location.reload()
|
|
|
- return
|
|
|
+ window.location.reload();
|
|
|
+ return;
|
|
|
}
|
|
|
- if (navigator.userAgent.indexOf("Firefox") !== -1 || navigator.userAgent.indexOf("Chrome") !== -1) {
|
|
|
+ if (
|
|
|
+ navigator.userAgent.indexOf("Firefox") !== -1 ||
|
|
|
+ navigator.userAgent.indexOf("Chrome") !== -1
|
|
|
+ ) {
|
|
|
window.location.href = "about:blank";
|
|
|
window.close();
|
|
|
} else {
|
|
@@ -114,157 +129,151 @@ const onmessageFunc = {
|
|
|
window.close();
|
|
|
}
|
|
|
},
|
|
|
- "forceRefresh": (val) => {
|
|
|
- emrMitt.emit('forceRefresh', val)
|
|
|
+ forceRefresh: val => {
|
|
|
+ emrMitt.emit("forceRefresh", val);
|
|
|
},
|
|
|
- "receivedMessage": (val) => {
|
|
|
- forceRefreshDialog.value.message.push(val.message)
|
|
|
+ receivedMessage: val => {
|
|
|
+ forceRefreshDialog.value.message.push(val.message);
|
|
|
if (val.flag && val.flag === 1) {
|
|
|
- emrMitt.emit('closeForceRefreshDialog')
|
|
|
+ emrMitt.emit("closeForceRefreshDialog");
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
+ },
|
|
|
+};
|
|
|
|
|
|
const userSize = computed(() => {
|
|
|
- return Object.keys(userMap.value).length
|
|
|
-})
|
|
|
+ return Object.keys(userMap.value).length;
|
|
|
+});
|
|
|
|
|
|
const userList = computed(() => {
|
|
|
- return Object.values(userMap.value)
|
|
|
-})
|
|
|
+ return Object.values(userMap.value);
|
|
|
+});
|
|
|
|
|
|
const queryTheNumberOfPeopleInTheRoom = async () => {
|
|
|
- userMap.value = await getRoomPeople(sid.value) as any
|
|
|
-}
|
|
|
+ userMap.value = (await getRoomPeople(sid.value)) as any;
|
|
|
+};
|
|
|
|
|
|
function initWebSocket(patNo, times) {
|
|
|
if (stringIsBlank(patNo)) {
|
|
|
- return null
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
- if ('WebSocket' in window) {
|
|
|
- sid.value = 'emr_' + patNo.trim() + '_' + times;
|
|
|
- const url = SOCKET_URL + sid.value + '?userCode=' + userData.code;
|
|
|
+ if ("WebSocket" in window) {
|
|
|
+ sid.value = "emr_" + patNo.trim() + "_" + times;
|
|
|
+ const url = SOCKET_URL + sid.value + "?userCode=" + userData.code;
|
|
|
webSocket = new WebSocket(url);
|
|
|
} else {
|
|
|
- alert('该浏览器不支持websocket!');
|
|
|
- webSocket = 'unsupport';
|
|
|
+ alert("该浏览器不支持websocket!");
|
|
|
+ webSocket = "unsupport";
|
|
|
}
|
|
|
|
|
|
webSocket.onopen = () => {
|
|
|
- errDialog.value = false
|
|
|
- }
|
|
|
-
|
|
|
+ errDialog.value = false;
|
|
|
+ };
|
|
|
|
|
|
webSocket.onmessage = async function (e) {
|
|
|
- let data = JSON.parse(e.data)
|
|
|
+ let data = JSON.parse(e.data);
|
|
|
for (let key in data) {
|
|
|
- onmessageFunc[key](data[key])
|
|
|
+ onmessageFunc[key](data[key]);
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
- webSocket.onclose = (e) => {
|
|
|
- if (e.code === 1000 && e.reason === '服务器主动断开连接') {
|
|
|
- documentSocket = null
|
|
|
- webSocket = null
|
|
|
- onmessageFunc.closeSoctek(e.reason)
|
|
|
- return
|
|
|
+ webSocket.onclose = e => {
|
|
|
+ if (e.code === 1000 && e.reason === "服务器主动断开连接") {
|
|
|
+ documentSocket = null;
|
|
|
+ webSocket = null;
|
|
|
+ onmessageFunc.closeSoctek(e.reason);
|
|
|
+ return;
|
|
|
}
|
|
|
- errDialog.value = true
|
|
|
- initWebSocket(props.patInfo.inpatientNo, props.patInfo.admissTimes)
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-const medicalRecordSwitching = async (name) => {
|
|
|
- await sendAMessage(sid.value, "notice", name)
|
|
|
+ errDialog.value = true;
|
|
|
+ initWebSocket(props.patInfo.inpatientNo, props.patInfo.admissTimes);
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
+const medicalRecordSwitching = async name => {
|
|
|
+ await sendAMessage(sid.value, "notice", name);
|
|
|
+};
|
|
|
|
|
|
-let documentSocket = null
|
|
|
-let documentSid = null
|
|
|
-const documentChange = (id) => {
|
|
|
- documentSid = 'documentEmr_' + id + '_' + userData.code
|
|
|
+let documentSocket = null;
|
|
|
+let documentSid = null;
|
|
|
+const documentChange = id => {
|
|
|
+ documentSid = "documentEmr_" + id + "_" + userData.code;
|
|
|
if (documentSocket != null) {
|
|
|
- documentSocket.close()
|
|
|
- documentSocket = null
|
|
|
+ documentSocket.close();
|
|
|
+ documentSocket = null;
|
|
|
} else {
|
|
|
- if ('WebSocket' in window) {
|
|
|
- initDocumentSocket()
|
|
|
+ if ("WebSocket" in window) {
|
|
|
+ initDocumentSocket();
|
|
|
} else {
|
|
|
- alert('该浏览器不支持websocket!');
|
|
|
+ alert("该浏览器不支持websocket!");
|
|
|
documentSocket = null;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
const initDocumentSocket = () => {
|
|
|
- if (documentSid == null) return
|
|
|
- let temp = SOCKET_URL + documentSid
|
|
|
+ if (documentSid == null) return;
|
|
|
+ let temp = SOCKET_URL + documentSid;
|
|
|
|
|
|
- documentSocket = new WebSocket(temp)
|
|
|
+ documentSocket = new WebSocket(temp);
|
|
|
documentSocket.onopen = () => {
|
|
|
- console.log('连接成功')
|
|
|
- }
|
|
|
+ console.log("连接成功");
|
|
|
+ };
|
|
|
|
|
|
documentSocket.onmessage = function (e) {
|
|
|
- let data = JSON.parse(e.data)
|
|
|
+ let data = JSON.parse(e.data);
|
|
|
for (let key in data) {
|
|
|
- onmessageFunc[key](data[key])
|
|
|
+ onmessageFunc[key](data[key]);
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
- documentSocket.onclose = (e) => {
|
|
|
- if (e.code === 1000 && e.reason === '服务器主动断开连接') {
|
|
|
- documentSocket = null
|
|
|
- emrMitt.emit('setEditorReadonly');
|
|
|
+ documentSocket.onclose = e => {
|
|
|
+ if (e.code === 1000 && e.reason === "服务器主动断开连接") {
|
|
|
+ documentSocket = null;
|
|
|
+ emrMitt.emit("setEditorReadonly");
|
|
|
CyMessageBox.alert({
|
|
|
- message: '服务器主动断开连接,有医生把您踢下线'
|
|
|
- })
|
|
|
- return
|
|
|
+ message: "服务器主动断开连接,有医生把您踢下线",
|
|
|
+ });
|
|
|
+ return;
|
|
|
}
|
|
|
- initDocumentSocket()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
+ initDocumentSocket();
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
const clearDocument = () => {
|
|
|
if (documentSocket != null) {
|
|
|
- documentSocket.close()
|
|
|
- documentSocket = null
|
|
|
- documentSid = null
|
|
|
+ documentSocket.close();
|
|
|
+ documentSocket = null;
|
|
|
+ documentSid = null;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
const clearSocket = () => {
|
|
|
if (webSocket != null) {
|
|
|
- webSocket.close()
|
|
|
- webSocket = null
|
|
|
+ webSocket.close();
|
|
|
+ webSocket = null;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
onMounted(async () => {
|
|
|
- await nextTick()
|
|
|
- initWebSocket(props.patInfo.inpatientNo, props.patInfo.admissTimes)
|
|
|
- emrMitt.on('getDocumentSocket', () => {
|
|
|
- console.log(documentSocket)
|
|
|
+ await nextTick();
|
|
|
+ initWebSocket(props.patInfo.inpatientNo, props.patInfo.admissTimes);
|
|
|
+ emrMitt.on("getDocumentSocket", () => {
|
|
|
return documentSocket;
|
|
|
- })
|
|
|
- emrMitt.on('openChatRoom', () => {
|
|
|
- dialog.value = true
|
|
|
- })
|
|
|
-})
|
|
|
+ });
|
|
|
+ emrMitt.on("openChatRoom", () => {
|
|
|
+ dialog.value = true;
|
|
|
+ });
|
|
|
+});
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
- clearDocument()
|
|
|
- clearSocket()
|
|
|
-})
|
|
|
+ clearDocument();
|
|
|
+ clearSocket();
|
|
|
+});
|
|
|
|
|
|
defineExpose({
|
|
|
medicalRecordSwitching,
|
|
|
documentChange,
|
|
|
clearDocument,
|
|
|
- clearSocket
|
|
|
-})
|
|
|
-
|
|
|
+ clearSocket,
|
|
|
+});
|
|
|
</script>
|