Fix Bug #566: fallback修复
This commit is contained in:
70
openhis-ui-vue3/src/views/ward/nurse/temperature-chart.vue
Normal file
70
openhis-ui-vue3/src/views/ward/nurse/temperature-chart.vue
Normal file
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<div class="temperature-chart">
|
||||
<el-card>
|
||||
<div ref="chartContainer" style="height: 400px;"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import * as echarts from 'echarts';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { fetchTemperatureChartData } from '@/api/vitalSign';
|
||||
|
||||
const route = useRoute();
|
||||
const patientId = ref(route.params.patientId);
|
||||
const chartContainer = ref(null);
|
||||
let chartInstance = null;
|
||||
|
||||
/**
|
||||
* 初始化图表
|
||||
*/
|
||||
function initChart() {
|
||||
if (!chartContainer.value) return;
|
||||
chartInstance = echarts.init(chartContainer.value);
|
||||
const option = {
|
||||
title: { text: '体温趋势' },
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: { type: 'category', data: [] },
|
||||
yAxis: { type: 'value', name: '℃' },
|
||||
series: [{ name: '体温', type: 'line', data: [] }],
|
||||
};
|
||||
chartInstance.setOption(option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载并渲染数据
|
||||
*/
|
||||
async function loadData() {
|
||||
if (!patientId.value) return;
|
||||
const resp = await fetchTemperatureChartData(patientId.value);
|
||||
const records = resp.data || [];
|
||||
|
||||
// 若无数据,保持空图表,避免报错
|
||||
const times = records.map(r => r.recordTime);
|
||||
const temps = records.map(r => r.temperature);
|
||||
|
||||
chartInstance.setOption({
|
||||
xAxis: { data: times },
|
||||
series: [{ data: temps }],
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initChart();
|
||||
loadData();
|
||||
});
|
||||
|
||||
// 当路由参数变化时重新加载
|
||||
watch(() => route.params.patientId, (newId) => {
|
||||
patientId.value = newId;
|
||||
loadData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.temperature-chart {
|
||||
margin: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user