错误修复

This commit is contained in:
yy 2024-05-30 14:57:25 +08:00
parent 6dfbce71dd
commit aa69fcab6c
9 changed files with 1158 additions and 1305 deletions

View File

@ -22,7 +22,7 @@ export function getMonthlyLogCount(startTime: string, endTime: string) {
}) })
} }
export function getPage(current: number, size: number, condition: {timeInterval: string, logType: string}) { export function getPage(current: number, size: number, condition?: {timeInterval: string, logType: string}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request.get(getPageUrl, { request.get(getPageUrl, {
params: { params: {

View File

@ -13,7 +13,8 @@
</loading> </loading>
</div> </div>
<canvas id="bg_canvas" v-show="!loading"></canvas> <canvas id="bg_canvas" v-show="!loading"></canvas>
<canvas v-show="!loading" id="block_canvas" @mousedown.prevent="(e) => drag(e, 'block_canvas', 'circle')" <canvas v-show="!loading" id="block_canvas"
@mousedown.prevent="(e) => drag(e, 'block_canvas', 'circle')"
@touchstart.prevent="(e) => { @touchstart.prevent="(e) => {
terminal = 'mobile' terminal = 'mobile'
drag(e, 'block_canvas', 'circle') drag(e, 'block_canvas', 'circle')
@ -52,7 +53,8 @@
</div> </div>
</div> </div>
</div> </div>
<popup v-model:show="popupShow" position="bottom" :overlay="false" :teleport="getContainer()" class="result-popup" <popup v-model:show="popupShow" position="bottom" :overlay="false" :teleport="getContainer()"
class="result-popup"
:class="{ 'popup-success': verifyResult }"> :class="{ 'popup-success': verifyResult }">
{{ verifyResult ? sText : eText }} {{ verifyResult ? sText : eText }}
</popup> </popup>
@ -71,6 +73,7 @@ import {
toRefs, toRefs,
} from 'vue' } from 'vue'
import {Popup, Loading, Toast} from 'vant' import {Popup, Loading, Toast} from 'vant'
import {getAssetsFile} from "@/utils/other";
const l = 42 // const l = 42 //
const r = 9 // const r = 9 //
@ -320,14 +323,13 @@ export default defineComponent({
img.crossOrigin = 'Anonymous' img.crossOrigin = 'Anonymous'
img.src = props.imgUrl img.src = props.imgUrl
? props.imgUrl ? props.imgUrl
: `/medical/src/assets/imgs/SliderVerify/SliderVerify-${bgRandom}.jpg` : getAssetsFile(`imgs/SliderVerify/SliderVerify-${bgRandom}.jpg`)
img.onerror = () => { img.onerror = () => {
Toast({ Toast({
message: '图片加载失败', message: '图片加载失败',
position: 'top', position: 'top',
}) })
img.src = img.src = getAssetsFile('imgs/SliderVerify/SliderVerify-error.png')
'/medical/src/assets/imgs/SliderVerify/SliderVerify-error.png'
} }
/** /**

View File

@ -1,159 +0,0 @@
<template>
<div></div>
</template>
<script setup lang="ts" name="global-websocket">
import { ElNotification } from 'element-plus';
import { Session } from '/@/utils/storage';
const emit = defineEmits(['rollback']);
const props = defineProps({
uri: {
type: String,
},
});
const state = reactive({
webSocket: ref(), // webSocket
lockReconnect: false, //
maxReconnect: 6, // -1
reconnectTime: 0, //
heartbeat: {
interval: 30 * 1000, //
timeout: 10 * 1000, //
pingTimeoutObj: ref(), //
pongTimeoutObj: ref(), //
pingMessage: JSON.stringify({ type: 'ping' }), //
},
});
const token = computed(() => {
return Session.getToken();
});
const tenant = computed(() => {
return Session.getTenant();
});
onMounted(() => {
initWebSocket();
});
onUnmounted(() => {
state.webSocket.close();
clearTimeoutObj(state.heartbeat);
});
const initWebSocket = () => {
// ws
let host = window.location.host;
// baseURL
let baseURL = import.meta.env.VITE_API_URL;
let wsUri = `ws://${host}${baseURL}${props.uri}?access_token=${token.value}&TENANT-ID=${tenant.value}`;
//
state.webSocket = new WebSocket(wsUri);
//
state.webSocket.onopen = onOpen;
//
state.webSocket.onerror = onError;
//
state.webSocket.onmessage = onMessage;
//
state.webSocket.onclose = onClose;
};
const reconnect = () => {
if (!token) {
return;
}
if (state.lockReconnect || (state.maxReconnect !== -1 && state.reconnectTime > state.maxReconnect)) {
return;
}
state.lockReconnect = true;
setTimeout(() => {
state.reconnectTime++;
//
initWebSocket();
state.lockReconnect = false;
}, 5000);
};
/**
* 清空定时器
*/
const clearTimeoutObj = (heartbeat: any) => {
heartbeat.pingTimeoutObj && clearTimeout(heartbeat.pingTimeoutObj);
heartbeat.pongTimeoutObj && clearTimeout(heartbeat.pongTimeoutObj);
};
/**
* 开启心跳
*/
const startHeartbeat = () => {
const webSocket = state.webSocket;
const heartbeat = state.heartbeat;
//
clearTimeoutObj(heartbeat);
//
heartbeat.pingTimeoutObj = setTimeout(() => {
//
if (webSocket.readyState === 1) {
//
webSocket.send(heartbeat.pingMessage);
//
heartbeat.pongTimeoutObj = setTimeout(() => {
webSocket.close();
}, heartbeat.timeout);
} else {
//
reconnect();
}
}, heartbeat.interval);
};
/**
* 连接成功事件
*/
const onOpen = () => {
//
startHeartbeat();
state.reconnectTime = 0;
};
/**
* 连接失败事件
* @param e
*/
const onError = () => {
//
reconnect();
};
/**
* 连接关闭事件
* @param e
*/
const onClose = () => {
//
reconnect();
};
/**
* 接收服务器推送的信息
* @param msgEvent
*/
const onMessage = (msgEvent: any) => {
//
startHeartbeat();
const text = msgEvent.data;
if (text.indexOf('pong') > 0) {
return;
}
ElNotification.warning({
title: '消息提醒',
dangerouslyUseHTMLString: true,
message: text + '请及时处理',
offset: 60,
});
emit('rollback', text);
};
</script>

View File

@ -2,9 +2,9 @@ import { defineStore } from "pinia";
import {Session} from "@/utils/storage"; import {Session} from "@/utils/storage";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
const vitalUrl = "ws://localhost:5173/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken() const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
const medicineUrl = "ws://localhost:5173/socket.io/admin/rax/addMedicine?token=" + Session.getToken() const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
const chatUrl = "ws://localhost:5173/socket.io/admin/rax/chatRoom?token=" + Session.getToken() const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
export const useRemoteWsStore = defineStore("remoteWs", { export const useRemoteWsStore = defineStore("remoteWs", {
state: () => { state: () => {

View File

@ -69,3 +69,9 @@ function componentToHex(c: number) {
const hex = c.toString(16); const hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex; return hex.length == 1 ? "0" + hex : hex;
} }
// 获取assets静态资源
export const getAssetsFile = (url: string) => {
return new URL(`../assets/${url}`, import.meta.url).href
}

View File

@ -11,7 +11,7 @@ import {dateFormater} from '@/utils/date-util';
import {useRemoteWsStore} from "@/stores/remote-ws-store"; import {useRemoteWsStore} from "@/stores/remote-ws-store";
const chartDom = ref(); const chartDom = ref();
const props = withDefaults(defineProps<{ names?: string[] }>(), { const props = withDefaults(defineProps<{ names?: any }>(), {
names: ['CH1', 'CH2'] names: ['CH1', 'CH2']
}); });
defineExpose({ defineExpose({
@ -67,7 +67,7 @@ function chartInit() {
formatter: (params: any) => { formatter: (params: any) => {
let str = params[0].axisValue; let str = params[0].axisValue;
str += `<br>`; str += `<br>`;
props.names.forEach((item, index) => { props.names.forEach((item: any, index: any) => {
str += params[index].marker; str += params[index].marker;
str += params[index].seriesName + ' '; str += params[index].seriesName + ' ';
str += `${params[index].value} HZ`; str += `${params[index].value} HZ`;
@ -124,8 +124,8 @@ function getXData() {
} }
function getSeries() { function getSeries() {
props.names.forEach((name, index) => { props.names.forEach((name: any, index: any) => {
const serie = { const serie: any = {
name, name,
type: 'line', type: 'line',
symbol: 'none', symbol: 'none',

View File

@ -12,7 +12,7 @@ import {useRemoteWsStore} from "@/stores/remote-ws-store";
const chartDom = ref(); const chartDom = ref();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
names: string[] names: any
}>(), { }>(), {
names: ['BIS', 'HR'] names: ['BIS', 'HR']
}); });
@ -76,7 +76,7 @@ function chartInit() {
let str = ''; let str = '';
str += params[0].axisValue; str += params[0].axisValue;
str += '<br>'; str += '<br>';
props.names.forEach((item, index) => { props.names.forEach((item: any, index: any) => {
str += params[index].marker; str += params[index].marker;
str += params[index].seriesName + ' '; str += params[index].seriesName + ' ';
switch (item) { switch (item) {
@ -121,7 +121,7 @@ function chartInit() {
lineHeight: 30, lineHeight: 30,
}, },
formatter: (params: string) => { formatter: (params: string) => {
const index = props.names.findIndex((item) => item === params); const index = props.names.findIndex((item: any) => item === params);
let str = params + ' '; let str = params + ' ';
switch (params) { switch (params) {
case 'BIS': case 'BIS':
@ -186,7 +186,7 @@ function chartInit() {
} }
function getSeries() { function getSeries() {
props.names.forEach(name => { props.names.forEach((name: any) => {
const serie = { const serie = {
name, name,
type: 'line', type: 'line',
@ -208,7 +208,7 @@ function getXData() {
} }
function getLegendData() { function getLegendData() {
props.names.forEach((name, index) => { props.names.forEach((name: any, index: any) => {
legendData.push({ legendData.push({
name, name,
textStyle: {color: colors[index]}, textStyle: {color: colors[index]},

View File

@ -126,6 +126,7 @@ const remoteItem = ref({} as any)
let currentIndex = -1; let currentIndex = -1;
const patientInfo = ref({} as any) const patientInfo = ref({} as any)
const remoteWsStore = useRemoteWsStore() const remoteWsStore = useRemoteWsStore()
let currentException: any = {}
defineExpose({ defineExpose({
initData, showData initData, showData
@ -187,18 +188,21 @@ function getData() {
} }
function setLog(data: any) { function setLog(data: any) {
if (currentException?.Time != data.Time) {
currentException = data
remoteWsStore.exceptionType.forEach((item: any) => { remoteWsStore.exceptionType.forEach((item: any) => {
if (data[item]) { if (data[item]) {
const msg: any = remoteWsStore.exceptionMsg[item]; const msg: any = remoteWsStore.exceptionMsg[item];
remoteWsStore.setRemoteLog({ remoteWsStore.setRemoteLog({
state: msg, state: msg,
taskName: remoteItem.value.taskName, taskName: remoteItem.value.taskName,
time: new Date(), time: item.Time,
type: "exception" type: "exception"
}, currentIndex); }, currentIndex);
} }
}) })
} }
}
const breakRemote = () => { const breakRemote = () => {
remoteWsStore.getRemoteTask()[currentIndex] remoteWsStore.getRemoteTask()[currentIndex]

View File

@ -6,7 +6,7 @@ import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
base: '/medical/', // base: '/medical/',
plugins: [vue()], plugins: [vue()],
resolve: { resolve: {
alias: { alias: {