错误修复

This commit is contained in:
yy 2024-05-30 09:24:07 +08:00
parent 134d202f67
commit 63ccb81c9b
5 changed files with 944 additions and 941 deletions

View File

@ -50,7 +50,7 @@ if (token) {
router.addRoute({ router.addRoute({
name: "root", name: "root",
path: "/", path: "/",
redirect: "/home" redirect: "/remote-manage"
}) })
} else { } else {
router.addRoute({ router.addRoute({

View File

@ -36,7 +36,7 @@
</el-button> </el-button>
<el-dropdown trigger="click" @command="userCommand"> <el-dropdown trigger="click" @command="userCommand">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
{{ userInfo.name }} {{ userInfo?.name }}
<el-icon class="el-icon--right"> <el-icon class="el-icon--right">
<arrow-down/> <arrow-down/>
</el-icon> </el-icon>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="chart-dom-box"> <div class="chart-dom-box">
<div ref="chartDom" style="width: 100%; height: 100%"></div> <div ref="chartDom" style="width: 100%; height: 100%"></div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -12,12 +12,12 @@ import {useRemoteWsStore} from "@/stores/remote-ws-store";
const chartDom = ref(); const chartDom = ref();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
names: string[] names: string[]
}>(), { }>(), {
names: ['BIS', 'HR'] names: ['BIS', 'HR']
}); });
defineExpose({ defineExpose({
updateChartData updateChartData
}); });
const emit = defineEmits(["exceptionEvent"]); const emit = defineEmits(["exceptionEvent"]);
let chart: any; let chart: any;
@ -29,191 +29,196 @@ let currentNode: any;
const remoteWsStore = useRemoteWsStore(); const remoteWsStore = useRemoteWsStore();
onMounted(() => { onMounted(() => {
chartInit(); chartInit();
}); });
function updateChartData(data: any) { function updateChartData(data: any) {
if (data) { if (data) {
if (currentNode && currentNode.Time == data.Time) { if (currentNode && currentNode.Time == data[0].Time) {
return; return;
} else { } else {
currentNode = data; currentNode = data[0];
} }
xData.shift(); for (let i = data.length - 1; i >= 0; i--) {
xData.push(dateFormater("HH:mm:ss", data.Time ? data.Time - 8 * 60 * 60 * 1000 : '')); const item = data[i]
series.forEach(serie => { if (xData.indexOf(dateFormater("HH:mm:ss", item.Time)) == -1) {
serie.data.shift(); xData.shift();
serie.data.push(data[serie.name]); xData.push(dateFormater("HH:mm:ss", item.Time));
if (data[serie.name + '_except']) { series.forEach((serie: any) => {
emit("exceptionEvent", remoteWsStore.exceptionMsg[serie.name + '_except']); serie.data.shift();
serie.data.push(item[serie.name]);
if (item[serie.name + '_except']) {
emit("exceptionEvent", remoteWsStore.exceptionMsg[serie.name + '_except']);
}
})
chart.setOption({
xAxis: {
data: xData,
},
series,
})
} }
}) }
chart.setOption({
xAxis: {
data: xData,
},
series,
})
} }
} }
function chartInit() { function chartInit() {
chart = echarts.init(chartDom.value as HTMLElement); chart = echarts.init(chartDom.value as HTMLElement);
chart.clear(); chart.clear();
getSeries(); getSeries();
getXData(); getXData();
getLegendData(); getLegendData();
const option: any = { const option: any = {
color: colors, color: colors,
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
formatter: (params: any) => { formatter: (params: any) => {
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, index) => {
str += params[index].marker; str += params[index].marker;
str += params[index].seriesName + ' '; str += params[index].seriesName + ' ';
switch (item) { switch (item) {
case 'BIS': case 'BIS':
str += `脑电双频指数<麻醉深度>${params[index].value}`; str += `脑电双频指数<麻醉深度>${params[index].value}`;
break; break;
case 'HR': case 'HR':
str += `心率:${params[index].value} 次/分`; str += `心率:${params[index].value} 次/分`;
break; break;
case 'SBP': case 'SBP':
str += `收缩压:${params[index].value} mmHg`; str += `收缩压:${params[index].value} mmHg`;
break; break;
case 'DBP': case 'DBP':
str += `舒张压:${params[index].value} mmHg`; str += `舒张压:${params[index].value} mmHg`;
break; break;
case 'SPO2': case 'SPO2':
str += `体温:${params[index].value}`; str += `体温:${params[index].value}`;
break; break;
case 'TEMP': case 'TEMP':
str += `氧饱和度:${params[index].value}`; str += `氧饱和度:${params[index].value}`;
break; break;
default: default:
break; break;
} }
str += index === 0 ? '<br>' : ''; str += index === 0 ? '<br>' : '';
}); });
return str; return str;
}, },
}, },
legend: { legend: {
type: 'plain', type: 'plain',
show: true, show: true,
top: 0, top: 0,
right: 15, right: 15,
itemGap: 30, itemGap: 30,
itemWidth: 20, itemWidth: 20,
itemHeight: 3, itemHeight: 3,
icon: 'rect', icon: 'rect',
textStyle: { textStyle: {
fontSize: 16, fontSize: 16,
fontWeight: 600, fontWeight: 600,
lineHeight: 30, lineHeight: 30,
}, },
formatter: (params: string) => { formatter: (params: string) => {
const index = props.names.findIndex((item) => item === params); const index = props.names.findIndex((item) => item === params);
let str = params + ' '; let str = params + ' ';
switch (params) { switch (params) {
case 'BIS': case 'BIS':
str += `${series[index].data[series[index].data.length - 1]}`; str += `${series[index].data[series[index].data.length - 1]}`;
break; break;
case 'HR': case 'HR':
str += `${series[index].data[series[index].data.length - 1]} 次/分`; str += `${series[index].data[series[index].data.length - 1]} 次/分`;
break; break;
case 'SBP': case 'SBP':
str += `${series[index].data[series[index].data.length - 1]} mmHg`; str += `${series[index].data[series[index].data.length - 1]} mmHg`;
break; break;
case 'DBP': case 'DBP':
str += `${series[index].data[series[index].data.length - 1]} mmHg`; str += `${series[index].data[series[index].data.length - 1]} mmHg`;
break; break;
case 'SPO2': case 'SPO2':
str += `${series[index].data[series[index].data.length - 1]}`; str += `${series[index].data[series[index].data.length - 1]}`;
break; break;
case 'TEMP': case 'TEMP':
str += `${series[index].data[series[index].data.length - 1]}`; str += `${series[index].data[series[index].data.length - 1]}`;
break; break;
default: default:
break; break;
} }
return str; return str;
}, },
data: legendData data: legendData
}, },
grid: { grid: {
left: 5, left: 5,
right: 25, right: 25,
bottom: 5, bottom: 5,
top: 40, top: 40,
containLabel: true, containLabel: true,
}, },
xAxis: { xAxis: {
show: true, show: true,
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: [], data: [],
axisLine: {lineStyle: {color: '#006080'}} axisLine: {lineStyle: {color: '#006080'}}
}, },
yAxis: { yAxis: {
show: true, show: true,
type: 'value', type: 'value',
axisLabel: { axisLabel: {
formatter: `{value} ${props.names[0] === 'BIS' ? '次/分' : props.names[0] === 'SBP' ? 'mmHg' : ''}` formatter: `{value} ${props.names[0] === 'BIS' ? '次/分' : props.names[0] === 'SBP' ? 'mmHg' : ''}`
}, },
axisLine: {show: true, lineStyle: {color: '#006080'}}, axisLine: {show: true, lineStyle: {color: '#006080'}},
splitLine: {lineStyle: {color: '#C0C4CC', width: 1, type: 'dashed'}}, splitLine: {lineStyle: {color: '#C0C4CC', width: 1, type: 'dashed'}},
}, },
series, series,
}; };
if (props.names[0] !== 'BIS' if (props.names[0] !== 'BIS'
) { ) {
option.yAxis.max = (value: any) => value.max + 20; option.yAxis.max = (value: any) => value.max + 20;
} }
chart.setOption(option); chart.setOption(option);
chart.resize(); chart.resize();
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
chart.resize(); chart.resize();
}); });
} }
function getSeries() { function getSeries() {
props.names.forEach(name => { props.names.forEach(name => {
const serie = { const serie = {
name, name,
type: 'line', type: 'line',
symbol: 'none', symbol: 'none',
smooth: true, smooth: true,
data: [] as number[], data: [] as number[],
}; };
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
serie.data.push(0); serie.data.push(0);
} }
series.push(serie) series.push(serie)
}); });
} }
function getXData() { function getXData() {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
xData.push(0); xData.push(0);
} }
} }
function getLegendData() { function getLegendData() {
props.names.forEach((name, index) => { props.names.forEach((name, index) => {
legendData.push({ legendData.push({
name, name,
textStyle: {color: colors[index]}, textStyle: {color: colors[index]},
}); });
}); });
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.chart-dom-box { .chart-dom-box {
position: relative; position: relative;
} }
</style> </style>

View File

@ -140,7 +140,9 @@ onMounted(() => {
}) })
onUnmounted(() => { onUnmounted(() => {
remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex); if (remoteItem.value) {
remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, currentIndex);
}
}) })
function showData(i: any) { function showData(i: any) {

File diff suppressed because it is too large Load Diff