Showing
15 changed files
with
283 additions
and
49 deletions
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | - import { computed, ref, watch } from 'vue'; | 2 | + import { computed, ref, toRaw, watch } from 'vue'; |
3 | import { BasicInfoForm } from './components/BasicInfoForm'; | 3 | import { BasicInfoForm } from './components/BasicInfoForm'; |
4 | import { ModalParamsType } from '/#/utils'; | 4 | import { ModalParamsType } from '/#/utils'; |
5 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 5 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
@@ -134,12 +134,13 @@ | @@ -134,12 +134,13 @@ | ||
134 | oldCategory !== category && | 134 | oldCategory !== category && |
135 | firstEnter; | 135 | firstEnter; |
136 | 136 | ||
137 | - firstEnter = true; | ||
138 | - | ||
139 | dataSource.value = unref(dataSource).map((item) => ({ | 137 | dataSource.value = unref(dataSource).map((item) => ({ |
140 | ...item, | 138 | ...item, |
141 | ...(needReset ? { attribute: null } : {}), | 139 | ...(needReset ? { attribute: null } : {}), |
142 | - componentInfo: { ...unref(getComponentConfig).persetOption, ...item.componentInfo }, | 140 | + componentInfo: { |
141 | + ...toRaw(unref(getComponentConfig).persetOption), | ||
142 | + ...(firstEnter ? {} : item.componentInfo), | ||
143 | + }, | ||
143 | })); | 144 | })); |
144 | 145 | ||
145 | if ((window as any).requestIdleCallback as unknown as boolean) { | 146 | if ((window as any).requestIdleCallback as unknown as boolean) { |
@@ -154,6 +155,8 @@ | @@ -154,6 +155,8 @@ | ||
154 | setFormValues({ dataSource: unref(dataSource) } as WidgetDataType); | 155 | setFormValues({ dataSource: unref(dataSource) } as WidgetDataType); |
155 | }, 500); | 156 | }, 500); |
156 | } | 157 | } |
158 | + | ||
159 | + firstEnter = true; | ||
157 | } | 160 | } |
158 | } | 161 | } |
159 | ); | 162 | ); |
@@ -5,6 +5,6 @@ const componentKeys = useComponentKeys('LateralNumericalControl'); | @@ -5,6 +5,6 @@ const componentKeys = useComponentKeys('LateralNumericalControl'); | ||
5 | 5 | ||
6 | export const LateralNumericalControlConfig: ConfigType = { | 6 | export const LateralNumericalControlConfig: ConfigType = { |
7 | ...componentKeys, | 7 | ...componentKeys, |
8 | - title: '控制组件1', | 8 | + title: '控制组件4', |
9 | package: PackagesCategoryEnum.CONTROL, | 9 | package: PackagesCategoryEnum.CONTROL, |
10 | }; | 10 | }; |
@@ -152,7 +152,9 @@ | @@ -152,7 +152,9 @@ | ||
152 | unref(getDesign).dataSource.map((item, index) => ({ | 152 | unref(getDesign).dataSource.map((item, index) => ({ |
153 | value: 30, | 153 | value: 30, |
154 | name: `${ | 154 | name: `${ |
155 | - item.showDeviceName ? item.deviceRename || item.deviceName + '-' + item.attribute : '' | 155 | + item.showDeviceName |
156 | + ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | ||
157 | + : '' | ||
156 | }`, | 158 | }`, |
157 | attribute: item.attribute, | 159 | attribute: item.attribute, |
158 | id: item.id, | 160 | id: item.id, |
@@ -274,10 +276,11 @@ | @@ -274,10 +276,11 @@ | ||
274 | const { forEachGroupMessage } = useReceiveMessage(); | 276 | const { forEachGroupMessage } = useReceiveMessage(); |
275 | const { getNumberValue } = useReceiveValue(); | 277 | const { getNumberValue } = useReceiveValue(); |
276 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 278 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
277 | - forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 279 | + forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
278 | series.value.forEach((item) => { | 280 | series.value.forEach((item) => { |
279 | if (item.id === deviceId && item.attribute === attribute) { | 281 | if (item.id === deviceId && item.attribute === attribute) { |
280 | item.value = getNumberValue(value); | 282 | item.value = getNumberValue(value); |
283 | + time.value = timespan; | ||
281 | } | 284 | } |
282 | }); | 285 | }); |
283 | }); | 286 | }); |
1 | +import cloneDeep from 'lodash-es/cloneDeep'; | ||
2 | +import { SwitchSignalLightConfig } from '.'; | ||
3 | +import { | ||
4 | + ConfigType, | ||
5 | + CreateComponentType, | ||
6 | + PublicComponentOptions, | ||
7 | + PublicPresetOptions, | ||
8 | +} from '/@/views/visual/packages/index.type'; | ||
9 | +import { PublicConfigClass, componentInitConfig } from '/@/views/visual/packages/publicConfig'; | ||
10 | +import { ComponentConfigFieldEnum } from '/@/views/visual/packages/enum'; | ||
11 | + | ||
12 | +export const option: PublicPresetOptions = { | ||
13 | + [ComponentConfigFieldEnum.OPEN_COLOR]: '#30f230', | ||
14 | + [ComponentConfigFieldEnum.CLOSE_COLOR]: '#eeeeee', | ||
15 | + [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: true, | ||
16 | +}; | ||
17 | + | ||
18 | +export default class Config extends PublicConfigClass implements CreateComponentType { | ||
19 | + public key: string = SwitchSignalLightConfig.key; | ||
20 | + | ||
21 | + public attr = { ...componentInitConfig }; | ||
22 | + | ||
23 | + public componentConfig: ConfigType = cloneDeep(SwitchSignalLightConfig); | ||
24 | + | ||
25 | + public persetOption = cloneDeep(option); | ||
26 | + | ||
27 | + public option: PublicComponentOptions; | ||
28 | + | ||
29 | + constructor(option: PublicComponentOptions) { | ||
30 | + super(); | ||
31 | + this.option = { ...option }; | ||
32 | + } | ||
33 | +} |
1 | +<script lang="ts" setup> | ||
2 | + import { ComponentConfigFieldEnum } from '/@/views/visual/packages/enum'; | ||
3 | + import { useForm, BasicForm } from '/@/components/Form'; | ||
4 | + import { PublicFormInstaceType } from '/@/views/visual/dataSourceBindPanel/index.type'; | ||
5 | + import { option } from './config'; | ||
6 | + | ||
7 | + const [register, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | ||
8 | + schemas: [ | ||
9 | + { | ||
10 | + field: ComponentConfigFieldEnum.OPEN_COLOR, | ||
11 | + label: 'ON颜色', | ||
12 | + component: 'ColorPicker', | ||
13 | + changeEvent: 'update:value', | ||
14 | + componentProps: { | ||
15 | + defaultValue: option.openColor, | ||
16 | + }, | ||
17 | + }, | ||
18 | + { | ||
19 | + field: ComponentConfigFieldEnum.CLOSE_COLOR, | ||
20 | + label: 'OFF颜色', | ||
21 | + component: 'ColorPicker', | ||
22 | + changeEvent: 'update:value', | ||
23 | + componentProps: { | ||
24 | + defaultValue: option.closeColor, | ||
25 | + }, | ||
26 | + }, | ||
27 | + { | ||
28 | + field: ComponentConfigFieldEnum.SHOW_DEVICE_NAME, | ||
29 | + label: '显示设备名称', | ||
30 | + component: 'Checkbox', | ||
31 | + defaultValue: option.showDeviceName, | ||
32 | + }, | ||
33 | + ], | ||
34 | + showActionButtonGroup: false, | ||
35 | + labelWidth: 120, | ||
36 | + baseColProps: { | ||
37 | + span: 12, | ||
38 | + }, | ||
39 | + }); | ||
40 | + | ||
41 | + const getFormValues = () => { | ||
42 | + return getFieldsValue(); | ||
43 | + }; | ||
44 | + | ||
45 | + const setFormValues = (data: Recordable) => { | ||
46 | + return setFieldsValue(data); | ||
47 | + }; | ||
48 | + | ||
49 | + defineExpose({ | ||
50 | + getFormValues, | ||
51 | + setFormValues, | ||
52 | + resetFormValues: resetFields, | ||
53 | + } as PublicFormInstaceType); | ||
54 | +</script> | ||
55 | + | ||
56 | +<template> | ||
57 | + <BasicForm @register="register" /> | ||
58 | +</template> |
1 | +<script lang="ts" setup> | ||
2 | + import { commonDataSourceSchemas } from '../../../config/common.config'; | ||
3 | + import { BasicForm, useForm } from '/@/components/Form'; | ||
4 | + import { PublicFormInstaceType } from '/@/views/visual/dataSourceBindPanel/index.type'; | ||
5 | + | ||
6 | + const [register, { getFieldsValue, setFieldsValue, validate, resetFields }] = useForm({ | ||
7 | + labelWidth: 0, | ||
8 | + showActionButtonGroup: false, | ||
9 | + layout: 'horizontal', | ||
10 | + labelCol: { span: 0 }, | ||
11 | + schemas: commonDataSourceSchemas(), | ||
12 | + }); | ||
13 | + | ||
14 | + const getFormValues = () => { | ||
15 | + return getFieldsValue(); | ||
16 | + }; | ||
17 | + | ||
18 | + const setFormValues = (record: Recordable) => { | ||
19 | + return setFieldsValue(record); | ||
20 | + }; | ||
21 | + | ||
22 | + defineExpose({ | ||
23 | + getFormValues, | ||
24 | + setFormValues, | ||
25 | + validate, | ||
26 | + resetFormValues: resetFields, | ||
27 | + } as PublicFormInstaceType); | ||
28 | +</script> | ||
29 | + | ||
30 | +<template> | ||
31 | + <BasicForm @register="register" /> | ||
32 | +</template> |
1 | +// import { ComponentEnum, ComponentNameEnum } from '../index.type'; | ||
2 | +import { useComponentKeys } from '/@/views/visual/packages/hook/useComponentKeys'; | ||
3 | +import { ConfigType, PackagesCategoryEnum } from '/@/views/visual/packages/index.type'; | ||
4 | + | ||
5 | +const componentKeys = useComponentKeys('SwitchSignalLight'); | ||
6 | +export const SwitchSignalLightConfig: ConfigType = { | ||
7 | + ...componentKeys, | ||
8 | + // title: ComponentNameEnum.TEXT_COMPONENT_1, | ||
9 | + title: '开关量信号灯', | ||
10 | + package: PackagesCategoryEnum.OTHER, | ||
11 | +}; |
1 | +<script lang="ts" setup> | ||
2 | + import { ComponentPropsConfigType, DataFetchUpdateFn } from '/@/views/visual/packages/index.type'; | ||
3 | + import { option } from './config'; | ||
4 | + import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; | ||
5 | + import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; | ||
6 | + import { computed } from 'vue'; | ||
7 | + import { ref, onMounted, unref } from 'vue'; | ||
8 | + import { useIntervalFn } from '@vueuse/core'; | ||
9 | + import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | ||
10 | + import { useReceiveValue } from '../../../hook/useReceiveValue'; | ||
11 | + | ||
12 | + const props = defineProps<{ | ||
13 | + config: ComponentPropsConfigType<typeof option>; | ||
14 | + }>(); | ||
15 | + | ||
16 | + const isOpenClose = ref<boolean>(true); | ||
17 | + | ||
18 | + const getDesign = computed(() => { | ||
19 | + const { persetOption = {}, option } = props.config; | ||
20 | + const { | ||
21 | + openColor: persetOpenColor, | ||
22 | + closeColor: persetCloseColor, | ||
23 | + showDeviceName: persetShowDeviceName, | ||
24 | + } = persetOption || {}; | ||
25 | + const { componentInfo } = option; | ||
26 | + | ||
27 | + const { openColor, closeColor, showDeviceName } = componentInfo || {}; | ||
28 | + return { | ||
29 | + openColor: openColor ?? persetOpenColor, | ||
30 | + closeColor: closeColor ?? persetCloseColor, | ||
31 | + showDeviceName: showDeviceName ?? persetShowDeviceName, | ||
32 | + }; | ||
33 | + }); | ||
34 | + | ||
35 | + const randomFn = () => { | ||
36 | + useIntervalFn(() => { | ||
37 | + isOpenClose.value = !unref(isOpenClose); | ||
38 | + }, 2000); | ||
39 | + }; | ||
40 | + const { getNumberValue } = useReceiveValue(); | ||
41 | + const updateFn: DataFetchUpdateFn = (message, attribute) => { | ||
42 | + const { data = {} } = message; | ||
43 | + const [latest] = data[attribute] || []; | ||
44 | + const [_, value] = latest; | ||
45 | + isOpenClose.value = Boolean(getNumberValue(value)); | ||
46 | + }; | ||
47 | + | ||
48 | + onMounted(() => { | ||
49 | + !props.config.option.uuid && randomFn(); | ||
50 | + }); | ||
51 | + | ||
52 | + useDataFetch(props, updateFn); | ||
53 | + | ||
54 | + const { getScale } = useComponentScale(props); | ||
55 | +</script> | ||
56 | + | ||
57 | +<template> | ||
58 | + <main :style="getScale" class="w-full h-full flex flex-col justify-center items-center"> | ||
59 | + <DeviceName :config="config" class="text-center" /> | ||
60 | + <div | ||
61 | + :style="{ | ||
62 | + '--open-color': getDesign.openColor, | ||
63 | + '--close-color': getDesign.closeColor, | ||
64 | + }" | ||
65 | + :class="isOpenClose ? 'switch_open' : 'switch_close'" | ||
66 | + ></div> | ||
67 | + </main> | ||
68 | +</template> | ||
69 | +<style lang="less" scoped> | ||
70 | + .switch_open { | ||
71 | + background: var(--open-color); | ||
72 | + box-shadow: var(--open-color) 0 0 10px 3px; | ||
73 | + width: 60px; | ||
74 | + height: 60px; | ||
75 | + border-radius: 50%; | ||
76 | + margin: 10px 0; | ||
77 | + } | ||
78 | + | ||
79 | + .switch_close { | ||
80 | + background-color: var(--close-color); | ||
81 | + box-shadow: none; | ||
82 | + width: 42.023px; | ||
83 | + height: 42.023px; | ||
84 | + border-radius: 50%; | ||
85 | + margin: 10px 0; | ||
86 | + } | ||
87 | +</style> |
1 | import { MonitorVideoConfig } from './MonitorVideo'; | 1 | import { MonitorVideoConfig } from './MonitorVideo'; |
2 | import { PictureConfig } from './Picture'; | 2 | import { PictureConfig } from './Picture'; |
3 | +import { SwitchSignalLightConfig } from './SwitchSignalLight'; | ||
3 | 4 | ||
4 | -export const OtherList = [MonitorVideoConfig, PictureConfig]; | 5 | +export const OtherList = [MonitorVideoConfig, PictureConfig, SwitchSignalLightConfig]; |
@@ -19,7 +19,7 @@ export enum GradientColor { | @@ -19,7 +19,7 @@ export enum GradientColor { | ||
19 | } | 19 | } |
20 | export const option: PublicPresetOptions = { | 20 | export const option: PublicPresetOptions = { |
21 | multipleDataSourceComponent: true, | 21 | multipleDataSourceComponent: true, |
22 | - [ComponentConfigFieldEnum.FONT_COLOR]: '#FD7347', | 22 | + [ComponentConfigFieldEnum.FONT_COLOR]: '#5470c6', |
23 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, | 23 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, |
24 | [ComponentConfigFieldEnum.UNIT]: '℃', | 24 | [ComponentConfigFieldEnum.UNIT]: '℃', |
25 | }; | 25 | }; |
@@ -59,12 +59,23 @@ | @@ -59,12 +59,23 @@ | ||
59 | unref(getDesign).dataSource.map((item) => ({ | 59 | unref(getDesign).dataSource.map((item) => ({ |
60 | value: 0, | 60 | value: 0, |
61 | name: `${ | 61 | name: `${ |
62 | - item.showDeviceName ? item.deviceRename || item.deviceName + '-' + item.attribute : '' | 62 | + item.showDeviceName |
63 | + ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | ||
64 | + : '' | ||
63 | }`, | 65 | }`, |
64 | attribute: item.attribute, | 66 | attribute: item.attribute, |
65 | id: item.id, | 67 | id: item.id, |
68 | + itemStyle: { | ||
69 | + color: item.fontColor, | ||
70 | + }, | ||
71 | + tooltip: { | ||
72 | + valueFormatter(value) { | ||
73 | + return `${value} ${item.unit ?? ''}`; | ||
74 | + }, | ||
75 | + }, | ||
66 | })) | 76 | })) |
67 | ); | 77 | ); |
78 | + // console.log(unref(series), 'series'); | ||
68 | 79 | ||
69 | const options = (): EChartsOption => { | 80 | const options = (): EChartsOption => { |
70 | // getStageColor(gradientInfo); | 81 | // getStageColor(gradientInfo); |
@@ -133,10 +144,11 @@ | @@ -133,10 +144,11 @@ | ||
133 | const { forEachGroupMessage } = useReceiveMessage(); | 144 | const { forEachGroupMessage } = useReceiveMessage(); |
134 | const { getNumberValue } = useReceiveValue(); | 145 | const { getNumberValue } = useReceiveValue(); |
135 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 146 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
136 | - forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 147 | + forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
137 | series.value.forEach((item) => { | 148 | series.value.forEach((item) => { |
138 | if (item.id === deviceId && item.attribute === attribute) { | 149 | if (item.id === deviceId && item.attribute === attribute) { |
139 | item.value = getNumberValue(value); | 150 | item.value = getNumberValue(value); |
151 | + time.value = timespan; | ||
140 | } | 152 | } |
141 | }); | 153 | }); |
142 | }); | 154 | }); |
@@ -19,7 +19,7 @@ export enum GradientColor { | @@ -19,7 +19,7 @@ export enum GradientColor { | ||
19 | } | 19 | } |
20 | export const option: PublicPresetOptions = { | 20 | export const option: PublicPresetOptions = { |
21 | multipleDataSourceComponent: true, | 21 | multipleDataSourceComponent: true, |
22 | - [ComponentConfigFieldEnum.FONT_COLOR]: '#FD7347', | 22 | + [ComponentConfigFieldEnum.FONT_COLOR]: '#5470c6', |
23 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, | 23 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, |
24 | [ComponentConfigFieldEnum.UNIT]: '℃', | 24 | [ComponentConfigFieldEnum.UNIT]: '℃', |
25 | }; | 25 | }; |
@@ -133,15 +133,10 @@ | @@ -133,15 +133,10 @@ | ||
133 | const series = ref( | 133 | const series = ref( |
134 | unref(getDesign).dataSource.map((item) => ({ | 134 | unref(getDesign).dataSource.map((item) => ({ |
135 | value: 0, | 135 | value: 0, |
136 | - // name: `${ | ||
137 | - // item.showDeviceName | ||
138 | - // ? item.deviceRename | ||
139 | - // ? item.deviceRename | ||
140 | - // : item.deviceName + '-' + item.attribute | ||
141 | - // : '' | ||
142 | - // }`, | ||
143 | name: `${ | 136 | name: `${ |
144 | - item.showDeviceName ? item.deviceRename || item.deviceName + '-' + item.attribute : '' | 137 | + item.showDeviceName |
138 | + ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | ||
139 | + : '' | ||
145 | }`, | 140 | }`, |
146 | itemStyle: { color: item.fontColor }, | 141 | itemStyle: { color: item.fontColor }, |
147 | attribute: item.attribute, | 142 | attribute: item.attribute, |
@@ -155,10 +150,12 @@ | @@ -155,10 +150,12 @@ | ||
155 | ); | 150 | ); |
156 | 151 | ||
157 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 152 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
158 | - forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 153 | + // console.log(unref(series), 'series', unref(getDesign).dataSource); |
154 | + forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { | ||
159 | series.value.forEach((item) => { | 155 | series.value.forEach((item) => { |
160 | if (item.id === deviceId && item.attribute === attribute) { | 156 | if (item.id === deviceId && item.attribute === attribute) { |
161 | item.value = getNumberValue(value); | 157 | item.value = getNumberValue(value); |
158 | + time.value = timespan; | ||
162 | } | 159 | } |
163 | }); | 160 | }); |
164 | }); | 161 | }); |
@@ -175,7 +172,6 @@ | @@ -175,7 +172,6 @@ | ||
175 | show: false, | 172 | show: false, |
176 | }, | 173 | }, |
177 | }; | 174 | }; |
178 | - // console.log([...toRaw(unref(series)), option], 'series'); | ||
179 | updateChart([...toRaw(unref(series)), option]); | 175 | updateChart([...toRaw(unref(series)), option]); |
180 | }; | 176 | }; |
181 | 177 |
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
10 | import { unref } from 'vue'; | 10 | import { unref } from 'vue'; |
11 | import { onMounted } from 'vue'; | 11 | import { onMounted } from 'vue'; |
12 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | ||
12 | import { useReceiveMessage } from '../../../hook/useReceiveMessage'; | 13 | import { useReceiveMessage } from '../../../hook/useReceiveMessage'; |
13 | import { buildUUID } from '/@/utils/uuid'; | 14 | import { buildUUID } from '/@/utils/uuid'; |
14 | import { useReceiveValue } from '../../../hook/useReceiveValue'; | 15 | import { useReceiveValue } from '../../../hook/useReceiveValue'; |
@@ -17,6 +18,8 @@ | @@ -17,6 +18,8 @@ | ||
17 | config: ComponentPropsConfigType<typeof option>; | 18 | config: ComponentPropsConfigType<typeof option>; |
18 | }>(); | 19 | }>(); |
19 | 20 | ||
21 | + const time = ref<Nullable<number>>(null); | ||
22 | + | ||
20 | interface PercentType { | 23 | interface PercentType { |
21 | value?: number; | 24 | value?: number; |
22 | fontColor: string; | 25 | fontColor: string; |
@@ -49,15 +52,6 @@ | @@ -49,15 +52,6 @@ | ||
49 | attribute: '3', | 52 | attribute: '3', |
50 | id: buildUUID(), | 53 | id: buildUUID(), |
51 | }, | 54 | }, |
52 | - { | ||
53 | - value: 49, | ||
54 | - fontColor: '#2196F3', | ||
55 | - backgroundColor: '#2196F3', | ||
56 | - unit: '℃', | ||
57 | - deviceName: '温度', | ||
58 | - attribute: '2', | ||
59 | - id: buildUUID(), | ||
60 | - }, | ||
61 | ]; | 55 | ]; |
62 | 56 | ||
63 | const getDesign = computed(() => { | 57 | const getDesign = computed(() => { |
@@ -93,10 +87,11 @@ | @@ -93,10 +87,11 @@ | ||
93 | 87 | ||
94 | const { getNumberValue } = useReceiveValue(); | 88 | const { getNumberValue } = useReceiveValue(); |
95 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 89 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
96 | - forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 90 | + forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
97 | percentList.value.forEach((item) => { | 91 | percentList.value.forEach((item) => { |
98 | if (item.id === deviceId && item.attribute === attribute) { | 92 | if (item.id === deviceId && item.attribute === attribute) { |
99 | item.value = getNumberValue(value); | 93 | item.value = getNumberValue(value); |
94 | + time.value = timespan; | ||
100 | } | 95 | } |
101 | }); | 96 | }); |
102 | }); | 97 | }); |
@@ -111,10 +106,18 @@ | @@ -111,10 +106,18 @@ | ||
111 | <main class="w-full h-full flex flex-col justify-center"> | 106 | <main class="w-full h-full flex flex-col justify-center"> |
112 | <DeviceName :config="config" /> | 107 | <DeviceName :config="config" /> |
113 | 108 | ||
114 | - <div v-for="item in percentList" :key="item.id" class="flex flex-col ml-3 mr-3 items-stretch"> | 109 | + <div |
110 | + v-for="item in percentList" | ||
111 | + :key="item.id" | ||
112 | + class="mt-2 flex flex-col ml-3 mr-3 items-stretch" | ||
113 | + > | ||
115 | <div class="flex justify-between"> | 114 | <div class="flex justify-between"> |
116 | <div class="text-gray-500 text-lg truncate" :style="{ color: item.fontColor }"> | 115 | <div class="text-gray-500 text-lg truncate" :style="{ color: item.fontColor }"> |
117 | - {{ item.deviceRename || item.deviceName + '-' + item.attribute || '温度' }} | 116 | + {{ |
117 | + (item.deviceRename || item.deviceName) + | ||
118 | + '-' + | ||
119 | + (item.attributeRename || item.attribute) || '温度' | ||
120 | + }} | ||
118 | </div> | 121 | </div> |
119 | <span class="text-lg" :style="{ color: item.fontColor }" | 122 | <span class="text-lg" :style="{ color: item.fontColor }" |
120 | >{{ item.value }} {{ item.unit }}</span | 123 | >{{ item.value }} {{ item.unit }}</span |
@@ -131,6 +134,7 @@ | @@ -131,6 +134,7 @@ | ||
131 | /> --> | 134 | /> --> |
132 | </div> | 135 | </div> |
133 | </div> | 136 | </div> |
137 | + <UpdateTime :time="time" /> | ||
134 | </main> | 138 | </main> |
135 | </template> | 139 | </template> |
136 | <style lang="less" scoped> | 140 | <style lang="less" scoped> |
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | import { useMultipleDataFetch } from '/@/views/visual/packages/hook/useSocket'; | 5 | import { useMultipleDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
6 | import { ref, unref } from 'vue'; | 6 | import { ref, unref } from 'vue'; |
7 | import { SvgIcon } from '/@/components/Icon'; | 7 | import { SvgIcon } from '/@/components/Icon'; |
8 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | ||
8 | import { computed } from 'vue'; | 9 | import { computed } from 'vue'; |
9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | 10 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
10 | import { useReceiveMessage } from '../../../hook/useReceiveMessage'; | 11 | import { useReceiveMessage } from '../../../hook/useReceiveMessage'; |
@@ -14,6 +15,8 @@ | @@ -14,6 +15,8 @@ | ||
14 | config: ComponentPropsConfigType<typeof option>; | 15 | config: ComponentPropsConfigType<typeof option>; |
15 | }>(); | 16 | }>(); |
16 | 17 | ||
18 | + const time = ref<Nullable<number>>(null); | ||
19 | + | ||
17 | const getDesign = computed(() => { | 20 | const getDesign = computed(() => { |
18 | const { persetOption = {}, option } = props.config; | 21 | const { persetOption = {}, option } = props.config; |
19 | const { dataSource = [] } = option || {}; | 22 | const { dataSource = [] } = option || {}; |
@@ -78,23 +81,11 @@ | @@ -78,23 +81,11 @@ | ||
78 | 81 | ||
79 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 82 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
80 | // console.log(unref(getDesign).dataSource, 'dataSource'); | 83 | // console.log(unref(getDesign).dataSource, 'dataSource'); |
81 | - forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | ||
82 | - // unref(getDesign).dataSource.forEach((item) => { | ||
83 | - // if (item.id === deviceId && item.attribute === attribute) { | ||
84 | - // svgList.value = unref(getDesign).dataSource.map((item) => { | ||
85 | - // return { | ||
86 | - // value: getNumberValue(value), | ||
87 | - // name: item.deviceRename || item.deviceName, | ||
88 | - // icon: item.icon, | ||
89 | - // unit: item.unit, | ||
90 | - // fontColor: item.fontColor, | ||
91 | - // iconColor: item.iconColor, | ||
92 | - // }; | ||
93 | - // }); | ||
94 | - // } | 84 | + forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
95 | updateSvgList.value.forEach((item) => { | 85 | updateSvgList.value.forEach((item) => { |
96 | if (item.id === deviceId && item.attribute === attribute) { | 86 | if (item.id === deviceId && item.attribute === attribute) { |
97 | item.value = getNumberValue(value); | 87 | item.value = getNumberValue(value); |
88 | + time.value = timespan; | ||
98 | } | 89 | } |
99 | }); | 90 | }); |
100 | // }); | 91 | // }); |
@@ -139,7 +130,9 @@ | @@ -139,7 +130,9 @@ | ||
139 | /> | 130 | /> |
140 | 131 | ||
141 | <div class="text-gray-500 text-lg truncate ml-6">{{ | 132 | <div class="text-gray-500 text-lg truncate ml-6">{{ |
142 | - item.deviceRename || item.deviceName || '温度' | 133 | + item.deviceRename || |
134 | + item.deviceName + '-' + (item.attributeRename || item.attribute) || | ||
135 | + '温度' | ||
143 | }}</div> | 136 | }}</div> |
144 | </div> | 137 | </div> |
145 | 138 | ||
@@ -148,5 +141,6 @@ | @@ -148,5 +141,6 @@ | ||
148 | <span>{{ item.unit }} </span> | 141 | <span>{{ item.unit }} </span> |
149 | </h1> | 142 | </h1> |
150 | </div> | 143 | </div> |
144 | + <UpdateTime :time="time" /> | ||
151 | </main> | 145 | </main> |
152 | </template> | 146 | </template> |