Commit 79f72261b21a4278bb6c2d91761661de4449fb8f
Merge branch 'perf/thermometer-component' into 'main_dev'
perf: 优化温度计预览时无法显示具体值 See merge request yunteng/thingskit-scada!197
Showing
3 changed files
with
27 additions
and
6 deletions
1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
2 | import { computed, nextTick, onMounted, reactive, unref } from 'vue' | 2 | import { computed, nextTick, onMounted, reactive, unref } from 'vue' |
3 | -import { Tag } from 'ant-design-vue' | 3 | +import { Empty, Tag } from 'ant-design-vue' |
4 | import { useIntervalFn } from '@vueuse/core' | 4 | import { useIntervalFn } from '@vueuse/core' |
5 | import { ScrollList } from './ScrollList' | 5 | import { ScrollList } from './ScrollList' |
6 | import { fetchAlarmList } from '@/api/alarm' | 6 | import { fetchAlarmList } from '@/api/alarm' |
@@ -86,6 +86,7 @@ onMounted(async () => { | @@ -86,6 +86,7 @@ onMounted(async () => { | ||
86 | <template> | 86 | <template> |
87 | <div class="seamless-scroll w-full h-full flex justify-center items-center overflow-y-scroll"> | 87 | <div class="seamless-scroll w-full h-full flex justify-center items-center overflow-y-scroll"> |
88 | <ScrollList | 88 | <ScrollList |
89 | + v-if="initOptions.alarmList.length" | ||
89 | v-model="initOptions.scroll" :single-wait-time="initOptions.interval" :list="initOptions.alarmList" | 90 | v-model="initOptions.scroll" :single-wait-time="initOptions.interval" :list="initOptions.alarmList" |
90 | :is-rem-unit="true" :delay="10" :wheel="true" hover | 91 | :is-rem-unit="true" :delay="10" :wheel="true" hover |
91 | > | 92 | > |
@@ -103,6 +104,7 @@ onMounted(async () => { | @@ -103,6 +104,7 @@ onMounted(async () => { | ||
103 | </div> | 104 | </div> |
104 | </div> | 105 | </div> |
105 | </ScrollList> | 106 | </ScrollList> |
107 | + <Empty v-else description="暂无数据" /> | ||
106 | </div> | 108 | </div> |
107 | </template> | 109 | </template> |
108 | 110 |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | import { computed, onMounted, onUnmounted, ref, unref } from 'vue' | 2 | import { computed, onMounted, onUnmounted, ref, unref } from 'vue' |
3 | import type { ECharts, EChartsOption } from 'echarts' | 3 | import type { ECharts, EChartsOption } from 'echarts' |
4 | import { init } from 'echarts' | 4 | import { init } from 'echarts' |
5 | -import { defaultOption, getShowValue } from './index.config' | 5 | +import { getDefaultOption, getShowValue } from './index.config' |
6 | import type { CreateComponentType, RenderComponentExposeType } from '@/core/Library/types' | 6 | import type { CreateComponentType, RenderComponentExposeType } from '@/core/Library/types' |
7 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' | 7 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' |
8 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' | 8 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' |
@@ -20,13 +20,13 @@ const chartInstance = ref<Nullable<ECharts>>() | @@ -20,13 +20,13 @@ const chartInstance = ref<Nullable<ECharts>>() | ||
20 | 20 | ||
21 | function initChartInstance() { | 21 | function initChartInstance() { |
22 | chartInstance.value = init(unref(chartElRef)) | 22 | chartInstance.value = init(unref(chartElRef)) |
23 | - chartInstance.value.setOption(defaultOption) | 23 | + chartInstance.value.setOption(getDefaultOption) |
24 | } | 24 | } |
25 | 25 | ||
26 | const { onMessage } = useOnMessage({ | 26 | const { onMessage } = useOnMessage({ |
27 | onReceiveDataSourceMessage(commandSource, message) { | 27 | onReceiveDataSourceMessage(commandSource, message) { |
28 | const { data } = commandSource | 28 | const { data } = commandSource |
29 | - const { deviceInfo, attrInfo } = data || {} | 29 | + const { deviceInfo, attrInfo } = (data || {}) as NodeDataDataSourceJsonType |
30 | const { deviceName } = deviceInfo || {} | 30 | const { deviceName } = deviceInfo || {} |
31 | const { attr } = data as NodeDataDataSourceJsonType | 31 | const { attr } = data as NodeDataDataSourceJsonType |
32 | const { latestValue } = useLatestMessageValue(message.data, attr) | 32 | const { latestValue } = useLatestMessageValue(message.data, attr) |
@@ -34,7 +34,26 @@ const { onMessage } = useOnMessage({ | @@ -34,7 +34,26 @@ const { onMessage } = useOnMessage({ | ||
34 | title: { | 34 | title: { |
35 | text: `${deviceName || ''}-${attrInfo.name || ''}`, | 35 | text: `${deviceName || ''}-${attrInfo.name || ''}`, |
36 | }, | 36 | }, |
37 | - series: [{ data: [{ value: getShowValue(Number(latestValue)) }] }], | 37 | + series: [{ |
38 | + data: [{ | ||
39 | + value: getShowValue(Number(latestValue)), | ||
40 | + label: { | ||
41 | + show: true, | ||
42 | + position: [20, '40%'], | ||
43 | + width: 100, | ||
44 | + height: 30, | ||
45 | + color: '#000', | ||
46 | + padding: 5, | ||
47 | + fontSize: 20, | ||
48 | + formatter: `${Number(latestValue)} {unit|℃}`, | ||
49 | + rich: { | ||
50 | + unit: { | ||
51 | + fontSize: 14, | ||
52 | + }, | ||
53 | + }, | ||
54 | + }, | ||
55 | + }], | ||
56 | + }], | ||
38 | } as EChartsOption) | 57 | } as EChartsOption) |
39 | }, | 58 | }, |
40 | }) | 59 | }) |