Commit bd9accafe538f9d62ab1fd933bd782a04b1f589c

Authored by loveumiko
1 parent c6f9e680

fix: 看板两个设备显示名称,未显示生效

... ... @@ -8,6 +8,7 @@
8 8 // import { useIntervalFn } from '@vueuse/core';
9 9 import { DeviceName } from '/@/views/visual/commonComponents/DeviceName';
10 10 import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale';
  11 + // import { SeriesOption } from 'echarts/types/dist/shared';
11 12
12 13 const props = defineProps<{
13 14 config: ComponentPropsConfigType<typeof option>;
... ... @@ -21,6 +22,27 @@
21 22
22 23 const getDesign = computed(() => {
23 24 const { option, persetOption } = props.config;
  25 + // const { dataSource = [] } = option || {};
  26 + // const {
  27 + // fontColor: persetFontColor,
  28 + // unit: persetUnit,
  29 + // showDeviceName: persetShowDeviceName,
  30 + // } = persetOption || {};
  31 + // return {
  32 + // dataSource: dataSource.map((item) => {
  33 + // const { unit, fontColor, showDeviceName } = item.componentInfo || {};
  34 + // const { deviceName, deviceRename, attribute } = item;
  35 + // return {
  36 + // unit: unit ?? persetUnit,
  37 + // fontColor: fontColor ?? persetFontColor,
  38 + // showDeviceName: showDeviceName ?? persetShowDeviceName,
  39 + // attribute,
  40 + // deviceName,
  41 + // deviceRename,
  42 + // };
  43 + // }),
  44 + // };
  45 +
24 46 const { componentInfo, attribute, attributeRename } = option;
25 47 const {
26 48 fontColor: presetFontColor,
... ... @@ -53,6 +75,7 @@
53 75 detail: {
54 76 valueAnimation: true,
55 77 offsetCenter: ['0%', '-20%'],
  78 + // formatter: `{value} ℃`,
56 79 },
57 80 },
58 81 {
... ... @@ -64,14 +87,17 @@
64 87 detail: {
65 88 valueAnimation: true,
66 89 offsetCenter: ['0%', '15%'],
  90 + // formatter: `{value} ℃`,
67 91 },
68 92 },
69 93 ];
70 94
71 95 const options = (): EChartsOption => {
72 96 const { fontColor } = unref(getDesign);
  97 + // const { fontColor, unit } = unref(getDesign).dataSource[0] || [];
  98 + // console.log(fontColor, unit, 'unit', unref(getDesign));
73 99 return {
74   - color: ['#ED6C0D', '#D3DB00', '#00F0F0'],
  100 + color: ['#377DFF', '#FD666D', '#00F0F0'],
75 101 series: [
76 102 {
77 103 type: 'gauge',
... ... @@ -83,11 +109,11 @@
83 109 progress: {
84 110 show: true,
85 111 overlap: false,
86   - roundCap: true,
  112 + // roundCap: true,
87 113 clip: false,
88 114 itemStyle: {
89   - // borderWidth: 1,
90   - // borderColor: '#464646',
  115 + borderWidth: 1,
  116 + borderColor: '#464646',
91 117 },
92 118 },
93 119 axisLine: {
... ... @@ -144,9 +170,11 @@
144 170 // });
145 171 // }, 3000);
146 172 // };
  173 +
147 174 const list = ref<any>([]);
148 175 const updateFn: MultipleDataFetchUpdateFn = (message) => {
149 176 const { data = {} } = message;
  177 +
150 178 const { dataSource } = props.config.option;
151 179 // const dataList = Object.keys(data);
152 180 const dataList = dataSource?.map((item) => item.attribute);
... ... @@ -167,9 +195,14 @@
167 195 });
168 196 dataSource?.forEach((item, index) => {
169 197 list.value.forEach((item1, index1) => {
  198 + console.log(item, 'item');
170 199 if (index == index1) {
171 200 // item1.value = item1.value + item.componentInfo.unit;
172   - item1.name = item.attributeRename;
  201 + item1.name = item.componentInfo.showDeviceName
  202 + ? item.deviceRename
  203 + ? item.deviceRename
  204 + : item.deviceName
  205 + : '';
173 206 item1.title.color = item.componentInfo.fontColor;
174 207 item1.detail.color = item.componentInfo.fontColor;
175 208 item1.detail.formatter = `{value} ${item.componentInfo.unit ?? ''}`;
... ... @@ -182,9 +215,42 @@
182 215 color: unref(list).map((item) => item.title.color),
183 216 } as EChartsOption);
184 217
185   - // updateChart(isNaN(value as unknown as number) ? 0 : Number(value));
  218 + // const { dataSource } = unref(getDesign);
  219 + // const series = dataSource.map((item, index) => {
  220 + // const { unit, fontColor, showDeviceName, attribute, deviceName, deviceRename } = item;
  221 + // const [latest] = data[attribute] || [];
  222 + // const [_timespan, value] = latest || [];
  223 + // return {
  224 + // value,
  225 + // name: showDeviceName ? (deviceRename ? deviceRename : deviceName) : '',
  226 + // title: {
  227 + // color: fontColor,
  228 + // offsetCenter: index == 0 ? ['0%', '-35%'] : index == 1 ? ['0%', '0%'] : ['0%', '35%'],
  229 + // },
  230 + // detail: {
  231 + // color: fontColor,
  232 + // valueAnimation: true,
  233 + // offsetCenter: index == 0 ? ['0%', '-20%'] : index == 1 ? ['0%', '18%'] : ['0%', '50%'],
  234 + // formatter: `{value} ${unit ?? ''}`,
  235 + // },
  236 + // } as SeriesOption['data'];
  237 + // });
  238 + // const xAxisData = dataSource.map((item: any) => item.fontColor as any);
  239 + // console.log(series, xAxisData, 'xAxisData');
  240 + // unref(chartInstance)?.setOption({
  241 + // series: [{ data: series, pointer: { show: false } }],
  242 + // color: xAxisData as any,
  243 + // });
  244 + // updateChart(series, xAxisData);
186 245 };
187 246
  247 + // const updateChart = (data: SeriesOption['data'], xAxisData) => {
  248 + // unref(chartInstance)?.setOption({
  249 + // series: [{ data }],
  250 + // xAxis: { data: xAxisData },
  251 + // });
  252 + // };
  253 +
188 254 useMultipleDataFetch(props, updateFn);
189 255
190 256 onMounted(() => {
... ... @@ -229,9 +295,9 @@
229 295 <main class="w-full h-full flex flex-col justify-center items-center">
230 296 <DeviceName :config="config" />
231 297 <div ref="chartRefEl" class="flex-1 w-full h-full"> </div>
232   - <div class="text-gray-500 text-xs text-center truncate">{{
  298 + <!-- <div class="text-gray-500 text-xs text-center truncate">{{
233 299 getDesign.attribute || '湿度'
234   - }}</div>
  300 + }}</div> -->
235 301 <UpdateTime :time="time" />
236 302 </main>
237 303 </template>
... ...