mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-23 20:44:58 +08:00
临时提交
This commit is contained in:
parent
db7031eb20
commit
fdea342eec
|
@ -1,46 +0,0 @@
|
|||
let ws: WebSocket;
|
||||
|
||||
function init(url: string | URL, protocols?: string | string[]) {
|
||||
return new Promise(resolve => {
|
||||
try {
|
||||
ws = new WebSocket(url);
|
||||
resolve(true)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function close(code?: number, reason?: string) {
|
||||
ws.close(code, reason)
|
||||
}
|
||||
|
||||
function send(data: string | ArrayBufferLike | Blob | ArrayBufferView) {
|
||||
ws.send(data)
|
||||
}
|
||||
|
||||
function closeListener(cb: any) {
|
||||
ws.onclose = cb
|
||||
}
|
||||
|
||||
function openListener(cb: any) {
|
||||
ws.onopen = cb
|
||||
}
|
||||
|
||||
function errorListener(cb: any) {
|
||||
ws.onerror = cb
|
||||
}
|
||||
|
||||
function messageListener(cb: any) {
|
||||
ws.onmessage = cb
|
||||
}
|
||||
|
||||
export const wsApi= {
|
||||
init,
|
||||
close,
|
||||
send,
|
||||
closeListener,
|
||||
openListener,
|
||||
errorListener,
|
||||
messageListener
|
||||
}
|
|
@ -67,7 +67,6 @@ import {ElMessage, ElMessageBox} from 'element-plus'
|
|||
import {useLoginStore} from '@/stores/user-info-store'
|
||||
import {getHospitalsData} from '@/static-data/core'
|
||||
import userInfoForm from '@/components/user-info.vue'
|
||||
import {wsApi} from "@/api/ws";
|
||||
import {Session} from "@/utils/storage";
|
||||
import {logout} from "@/api/login";
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<template>
|
||||
<div class="remote-manage-page">
|
||||
<button @click="getSurgeryData">123</button>
|
||||
<button @click="disconnectSurgeryData">断开</button>
|
||||
<div class="header-box">
|
||||
<div class="thumbnail" @click="viewThumbnail">
|
||||
<el-icon>
|
||||
|
@ -26,16 +28,14 @@
|
|||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
|
||||
import {ref} from 'vue'
|
||||
import {useRouter} from 'vue-router'
|
||||
import {useRemoteStore} from '@/stores/remote-info-store'
|
||||
import type {RemoteItem} from '@/utils/public-interface'
|
||||
import RemoteDialog from './part/remote-dialog.vue'
|
||||
import RemotePart from './part/remote-part.vue'
|
||||
import MessagePart from './part/message-part.vue'
|
||||
import {Client} from "@stomp/stompjs";
|
||||
import {Session} from "@/utils/storage";
|
||||
import {wsApi} from "@/api/ws";
|
||||
|
||||
const router = useRouter()
|
||||
const remoteStore = useRemoteStore()
|
||||
|
@ -123,7 +123,7 @@ const confirmRemote = (e: RemoteItem) => {
|
|||
remoteTask.value[e.index] = e // 状态设置为可连接
|
||||
remotePartRef.value.initData(e)
|
||||
console.log(e);
|
||||
getSurgeryData(e.patientCode, e.patientName);
|
||||
getSurgeryData();
|
||||
}
|
||||
// 连接失败
|
||||
const errorRemote = (e: RemoteItem) => {
|
||||
|
@ -142,12 +142,34 @@ const breakRemote = (e: RemoteItem) => {
|
|||
title: e.title,
|
||||
state: '断开连接'
|
||||
}, e.index)
|
||||
disconnectSurgeryData("", "1")
|
||||
// disconnectSurgeryData("", "1")
|
||||
}
|
||||
const addLogAfter = () => {
|
||||
messagePartRef.value.scrollToBottom()
|
||||
}
|
||||
|
||||
const ws = new WebSocket("ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken());
|
||||
|
||||
ws.onopen = function () {
|
||||
}
|
||||
|
||||
function getSurgeryData() {
|
||||
const params = {
|
||||
patientName: "1111111",
|
||||
idNum: "123567890",
|
||||
date: "20230505"
|
||||
}
|
||||
ws.send(JSON.stringify(params))
|
||||
}
|
||||
|
||||
function disconnectSurgeryData() {
|
||||
ws.close();
|
||||
}
|
||||
|
||||
ws.onmessage = function (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
/*const surgeryClient = new Client({
|
||||
brokerURL: 'ws://localhost:5173/socket.io/admin/rax/SurgeryData',
|
||||
connectHeaders: {
|
||||
|
@ -229,13 +251,6 @@ function sendChatMessage() {
|
|||
})
|
||||
}*/
|
||||
|
||||
wsApi.init("ws://localhost:5173/socket.io/admin/vitalSignsMedicine").then(() => {
|
||||
|
||||
})
|
||||
wsApi.openListener((cb: any) => {
|
||||
console.log(cb)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
|
Loading…
Reference in New Issue
Block a user