Commit 7b2dea0ac0d6388c076bd97609d9f0cc7ab6c377
Merge branch 'fix/data-board-attribute-name' into 'main_dev'
fix: 修复数据看板属性未使用物模型名称 See merge request yunteng/thingskit-front!702
Showing
24 changed files
with
121 additions
and
148 deletions
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | import { option } from './config'; |
| 4 | 4 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
| 5 | 5 | import { Spin } from 'ant-design-vue'; |
| 6 | - import { ref } from 'vue'; | |
| 6 | + import { computed, ref } from 'vue'; | |
| 7 | 7 | import { useComponentScale } from '../../../hook/useComponentScale'; |
| 8 | 8 | import { useSendCommand } from '../../../hook/useSendCommand'; |
| 9 | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| ... | ... | @@ -16,6 +16,14 @@ |
| 16 | 16 | |
| 17 | 17 | const currentValue = ref(false); |
| 18 | 18 | |
| 19 | + const getDesign = computed(() => { | |
| 20 | + const { option } = props.config; | |
| 21 | + const { attribute, attributeRename, attributeName } = option; | |
| 22 | + return { | |
| 23 | + attribute: attributeRename || attributeName || attribute, | |
| 24 | + }; | |
| 25 | + }); | |
| 26 | + | |
| 19 | 27 | const { sendCommand, loading } = useSendCommand(); |
| 20 | 28 | const handleChange = async (event: Event) => { |
| 21 | 29 | const target = event.target as HTMLInputElement; |
| ... | ... | @@ -52,7 +60,9 @@ |
| 52 | 60 | <span class="on">ON</span> |
| 53 | 61 | <span class="off">OFF</span> |
| 54 | 62 | </label> |
| 55 | - <div class="text-center mt-2 text-gray-700" :style="getScale"> 属性 </div> | |
| 63 | + <div class="text-center mt-2 text-gray-700" :style="getScale"> | |
| 64 | + {{ getDesign.attribute || '属性' }} | |
| 65 | + </div> | |
| 56 | 66 | </Spin> |
| 57 | 67 | </main> |
| 58 | 68 | </main> | ... | ... |
| ... | ... | @@ -18,13 +18,13 @@ |
| 18 | 18 | |
| 19 | 19 | const getDesign = computed(() => { |
| 20 | 20 | const { option, persetOption } = props.config; |
| 21 | - const { componentInfo, attribute, attributeRename } = option; | |
| 21 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 22 | 22 | const { icon: presetIcon, iconColor: presetIconColor } = persetOption || {}; |
| 23 | 23 | const { icon, iconColor } = componentInfo || {}; |
| 24 | 24 | return { |
| 25 | 25 | icon: icon ?? presetIcon, |
| 26 | 26 | iconColor: iconColor || presetIconColor, |
| 27 | - attribute: attributeRename || attribute, | |
| 27 | + attribute: attributeRename || attributeName || attribute, | |
| 28 | 28 | }; |
| 29 | 29 | }); |
| 30 | 30 | ... | ... |
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | import { option } from './config'; |
| 4 | 4 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
| 5 | 5 | import { Spin } from 'ant-design-vue'; |
| 6 | - import { ref } from 'vue'; | |
| 6 | + import { computed, ref } from 'vue'; | |
| 7 | 7 | import { useComponentScale } from '../../../hook/useComponentScale'; |
| 8 | 8 | import { useSendCommand } from '../../../hook/useSendCommand'; |
| 9 | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| ... | ... | @@ -16,6 +16,14 @@ |
| 16 | 16 | |
| 17 | 17 | const currentValue = ref(false); |
| 18 | 18 | |
| 19 | + const getDesign = computed(() => { | |
| 20 | + const { option } = props.config; | |
| 21 | + const { attribute, attributeRename, attributeName } = option; | |
| 22 | + return { | |
| 23 | + attribute: attributeRename || attributeName || attribute, | |
| 24 | + }; | |
| 25 | + }); | |
| 26 | + | |
| 19 | 27 | const { loading, sendCommand } = useSendCommand(); |
| 20 | 28 | const handleChange = async (event: Event) => { |
| 21 | 29 | const target = event.target as HTMLInputElement; |
| ... | ... | @@ -51,7 +59,9 @@ |
| 51 | 59 | </div> |
| 52 | 60 | </label> |
| 53 | 61 | </div> |
| 54 | - <div class="text-center mt-2 text-gray-500" :style="getScale">属性</div> | |
| 62 | + <div class="text-center mt-2 text-gray-500" :style="getScale">{{ | |
| 63 | + getDesign.attribute || '属性' | |
| 64 | + }}</div> | |
| 55 | 65 | </Spin> |
| 56 | 66 | </main> |
| 57 | 67 | </main> | ... | ... |
| ... | ... | @@ -22,12 +22,12 @@ |
| 22 | 22 | |
| 23 | 23 | const getDesign = computed(() => { |
| 24 | 24 | const { option, persetOption } = props.config; |
| 25 | - const { componentInfo, attribute, attributeRename } = option; | |
| 25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 26 | 26 | const { controlBarColor: persetControlBarColor, fonColor: persetFontColor } = |
| 27 | 27 | persetOption || {}; |
| 28 | 28 | const { controlBarColor, fontColor } = componentInfo || {}; |
| 29 | 29 | return { |
| 30 | - attribute: attributeRename || attribute, | |
| 30 | + attribute: attributeRename || attributeName || attribute, | |
| 31 | 31 | controlBarColor: controlBarColor ?? persetControlBarColor, |
| 32 | 32 | fontColor: fontColor ?? persetFontColor, |
| 33 | 33 | }; |
| ... | ... | @@ -87,7 +87,7 @@ |
| 87 | 87 | :style="{ color: getDesign.fontColor }" |
| 88 | 88 | class="mt-3 truncate font-bold text-xs text-center" |
| 89 | 89 | > |
| 90 | - {{ getDesign.attribute || '设备1' }} | |
| 90 | + {{ getDesign.attribute || '属性' }} | |
| 91 | 91 | </span> |
| 92 | 92 | </div> |
| 93 | 93 | </Spin> | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | import { ref } from 'vue'; |
| 7 | 7 | import { unref } from 'vue'; |
| 8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| 9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
| 9 | 10 | |
| 10 | 11 | const props = defineProps<{ |
| 11 | 12 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -13,9 +14,11 @@ |
| 13 | 14 | |
| 14 | 15 | const currentValue = ref(25); |
| 15 | 16 | |
| 17 | + const time = ref<Nullable<number>>(null); | |
| 18 | + | |
| 16 | 19 | const getDesign = computed(() => { |
| 17 | 20 | const { option, persetOption } = props.config; |
| 18 | - const { componentInfo } = option; | |
| 21 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
| 19 | 22 | const { flowmeterConfig, unit, fontColor } = componentInfo || {}; |
| 20 | 23 | const { backgroundColor, waveFirst, waveSecond, waveThird } = flowmeterConfig || {}; |
| 21 | 24 | const { |
| ... | ... | @@ -36,6 +39,7 @@ |
| 36 | 39 | waveThird: waveThird ?? presetWaveThird, |
| 37 | 40 | unit: unit ?? persetUnit, |
| 38 | 41 | fontColor: fontColor ?? presetFontColor, |
| 42 | + attribute: attributeRename || attributeName || attribute, | |
| 39 | 43 | }; |
| 40 | 44 | }); |
| 41 | 45 | |
| ... | ... | @@ -62,7 +66,8 @@ |
| 62 | 66 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
| 63 | 67 | const { data = {} } = message; |
| 64 | 68 | const [latest] = data[attribute] || []; |
| 65 | - const [_, value] = latest; | |
| 69 | + const [timespan, value] = latest; | |
| 70 | + time.value = timespan; | |
| 66 | 71 | currentValue.value = Number(value); |
| 67 | 72 | }; |
| 68 | 73 | |
| ... | ... | @@ -112,6 +117,10 @@ |
| 112 | 117 | <div>{{ currentValue }}</div> |
| 113 | 118 | <div class="ml-1">{{ getDesign.unit }}</div> |
| 114 | 119 | </div> |
| 120 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
| 121 | + getDesign.attribute || '属性' | |
| 122 | + }}</div> | |
| 123 | + <UpdateTime :time="time" /> | |
| 115 | 124 | </main> |
| 116 | 125 | </template> |
| 117 | 126 | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | import { ref } from 'vue'; |
| 7 | 7 | import { unref } from 'vue'; |
| 8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| 9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
| 9 | 10 | |
| 10 | 11 | const props = defineProps<{ |
| 11 | 12 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -13,9 +14,11 @@ |
| 13 | 14 | |
| 14 | 15 | const currentValue = ref(25); |
| 15 | 16 | |
| 17 | + const time = ref<Nullable<number>>(null); | |
| 18 | + | |
| 16 | 19 | const getDesign = computed(() => { |
| 17 | 20 | const { option, persetOption } = props.config; |
| 18 | - const { componentInfo } = option; | |
| 21 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
| 19 | 22 | const { flowmeterConfig, unit, fontColor } = componentInfo || {}; |
| 20 | 23 | const { backgroundColor, waveFirst, waveSecond, waveThird } = flowmeterConfig || {}; |
| 21 | 24 | const { |
| ... | ... | @@ -36,6 +39,7 @@ |
| 36 | 39 | waveThird: waveThird ?? presetWaveThird, |
| 37 | 40 | unit: unit ?? persetUnit, |
| 38 | 41 | fontColor: fontColor ?? presetFontColor, |
| 42 | + attribute: attributeRename || attributeName || attribute, | |
| 39 | 43 | }; |
| 40 | 44 | }); |
| 41 | 45 | |
| ... | ... | @@ -52,7 +56,8 @@ |
| 52 | 56 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
| 53 | 57 | const { data = {} } = message; |
| 54 | 58 | const [latest] = data[attribute] || []; |
| 55 | - const [_, value] = latest; | |
| 59 | + const [timespan, value] = latest; | |
| 60 | + time.value = timespan; | |
| 56 | 61 | currentValue.value = Number(value); |
| 57 | 62 | }; |
| 58 | 63 | |
| ... | ... | @@ -105,6 +110,10 @@ |
| 105 | 110 | <div>{{ currentValue }}</div> |
| 106 | 111 | <div class="ml-1">{{ getDesign.unit }}</div> |
| 107 | 112 | </div> |
| 113 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
| 114 | + getDesign.attribute || '属性' | |
| 115 | + }}</div> | |
| 116 | + <UpdateTime :time="time" /> | |
| 108 | 117 | </main> |
| 109 | 118 | </template> |
| 110 | 119 | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | import { computed } from 'vue'; |
| 7 | 7 | import { unref } from 'vue'; |
| 8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| 9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
| 9 | 10 | |
| 10 | 11 | const props = defineProps<{ |
| 11 | 12 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -13,6 +14,8 @@ |
| 13 | 14 | |
| 14 | 15 | const currentValue = ref(50); |
| 15 | 16 | |
| 17 | + const time = ref<Nullable<number>>(null); | |
| 18 | + | |
| 16 | 19 | const getValue = computed(() => { |
| 17 | 20 | const maxHeight = 190; |
| 18 | 21 | const minHeight = 15; |
| ... | ... | @@ -34,17 +37,19 @@ |
| 34 | 37 | const getDesign = computed(() => { |
| 35 | 38 | const { persetOption, option } = props.config; |
| 36 | 39 | const { fontColor: presetFontColor } = persetOption || {}; |
| 37 | - const { componentInfo } = option || {}; | |
| 40 | + const { componentInfo, attribute, attributeName, attributeRename } = option || {}; | |
| 38 | 41 | const { fontColor } = componentInfo || {}; |
| 39 | 42 | return { |
| 40 | 43 | fontColor: fontColor ?? presetFontColor, |
| 44 | + attribute: attributeRename || attributeName || attribute, | |
| 41 | 45 | }; |
| 42 | 46 | }); |
| 43 | 47 | |
| 44 | 48 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
| 45 | 49 | const { data = {} } = message; |
| 46 | 50 | const [latest] = data[attribute] || []; |
| 47 | - const [_, value] = latest; | |
| 51 | + const [timespan, value] = latest; | |
| 52 | + time.value = timespan; | |
| 48 | 53 | |
| 49 | 54 | currentValue.value = Number(value); |
| 50 | 55 | }; |
| ... | ... | @@ -247,6 +252,10 @@ |
| 247 | 252 | <span>{{ '℃' }}</span> |
| 248 | 253 | </div> |
| 249 | 254 | </div> |
| 255 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
| 256 | + getDesign.attribute || '属性' | |
| 257 | + }}</div> | |
| 258 | + <UpdateTime :time="time" /> | |
| 250 | 259 | </main> |
| 251 | 260 | </template> |
| 252 | 261 | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | import { Space } from 'ant-design-vue'; |
| 7 | 7 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; |
| 8 | 8 | import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; |
| 9 | + import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | |
| 9 | 10 | |
| 10 | 11 | const props = defineProps<{ |
| 11 | 12 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -45,13 +46,13 @@ |
| 45 | 46 | |
| 46 | 47 | const getDesign = computed(() => { |
| 47 | 48 | const { option, persetOption } = props.config; |
| 48 | - const { componentInfo, attribute, attributeRename } = option; | |
| 49 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 49 | 50 | const { fontColor: presetFontColor, unit: presetUnit } = persetOption || {}; |
| 50 | 51 | const { unit, fontColor } = componentInfo || {}; |
| 51 | 52 | return { |
| 52 | 53 | unit: unit ?? presetUnit, |
| 53 | 54 | fontColor: fontColor ?? presetFontColor, |
| 54 | - attribute: attributeRename || attribute, | |
| 55 | + attribute: attributeRename || attributeName || attribute, | |
| 55 | 56 | }; |
| 56 | 57 | }); |
| 57 | 58 | |
| ... | ... | @@ -71,6 +72,8 @@ |
| 71 | 72 | <template> |
| 72 | 73 | <main class="w-full h-full flex flex-col justify-center items-center"> |
| 73 | 74 | <div class="flex flex-col w-full h-full"> |
| 75 | + <DeviceName class="text-center" :config="config" /> | |
| 76 | + | |
| 74 | 77 | <div class="flex-1 flex justify-center items-center"> |
| 75 | 78 | <div class="flex px-4 items-center transform scale-75" :style="getScale"> |
| 76 | 79 | <Space | ... | ... |
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | const getDesign = computed(() => { |
| 24 | 24 | const { option, persetOption } = props.config; |
| 25 | - const { componentInfo, attribute, attributeRename } = option; | |
| 25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 26 | 26 | const { |
| 27 | 27 | fontColor: presetFontColor, |
| 28 | 28 | unit: presetUnit, |
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | return { |
| 36 | 36 | unit: unit ?? presetUnit, |
| 37 | 37 | fontColor: fontColor ?? presetFontColor, |
| 38 | - attribute: attributeRename || attribute, | |
| 38 | + attribute: attributeRename || attributeName || attribute, | |
| 39 | 39 | pointerColor: pointerColor ?? presetPointerColor, |
| 40 | 40 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
| 41 | 41 | gradientInfo: gradientInfo ?? presetGradientInfo, | ... | ... |
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | const getDesign = computed(() => { |
| 24 | 24 | const { option, persetOption } = props.config; |
| 25 | - const { componentInfo, attribute, attributeRename } = option; | |
| 25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 26 | 26 | const { |
| 27 | 27 | fontColor: presetFontColor, |
| 28 | 28 | unit: presetUnit, |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | return { |
| 37 | 37 | unit: unit ?? presetUnit, |
| 38 | 38 | fontColor: fontColor ?? presetFontColor, |
| 39 | - attribute: attributeRename || attribute, | |
| 39 | + attribute: attributeRename || attributeName || attribute, | |
| 40 | 40 | pointerColor: pointerColor ?? presetPointerColor, |
| 41 | 41 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
| 42 | 42 | progressBarCircle: progressBarCircle ?? presetProgressBarCircle, | ... | ... |
| ... | ... | @@ -32,7 +32,8 @@ |
| 32 | 32 | return { |
| 33 | 33 | dataSource: dataSource.map((item) => { |
| 34 | 34 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
| 35 | - const { deviceName, deviceRename, attribute, attributeRename, deviceId } = item; | |
| 35 | + const { deviceName, deviceRename, attribute, attributeRename, deviceId, attributeName } = | |
| 36 | + item; | |
| 36 | 37 | // return { |
| 37 | 38 | // unit: unit ?? persetUnit, |
| 38 | 39 | // fontColor: fontColor ?? persetFontColor, |
| ... | ... | @@ -49,6 +50,7 @@ |
| 49 | 50 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
| 50 | 51 | deviceName, |
| 51 | 52 | deviceRename, |
| 53 | + attributeName, | |
| 52 | 54 | id: deviceId, |
| 53 | 55 | }; |
| 54 | 56 | }), |
| ... | ... | @@ -151,10 +153,8 @@ |
| 151 | 153 | const series = ref( |
| 152 | 154 | unref(getDesign).dataSource.map((item, index) => ({ |
| 153 | 155 | value: 30, |
| 154 | - name: `${ | |
| 155 | - item.showDeviceName | |
| 156 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
| 157 | - : '' | |
| 156 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
| 157 | + item.attributeRename || item.attributeName || item.attribute | |
| 158 | 158 | }`, |
| 159 | 159 | attribute: item.attribute, |
| 160 | 160 | id: item.id, |
| ... | ... | @@ -334,9 +334,6 @@ |
| 334 | 334 | <main class="w-full h-full flex flex-col justify-center items-center"> |
| 335 | 335 | <DeviceName :config="config" /> |
| 336 | 336 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> |
| 337 | - <!-- <div class="text-gray-500 text-xs text-center truncate">{{ | |
| 338 | - getDesign.attribute || '湿度' | |
| 339 | - }}</div> --> | |
| 340 | 337 | <UpdateTime :time="time" /> |
| 341 | 338 | </main> |
| 342 | 339 | </template> | ... | ... |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | const getDesign = computed(() => { |
| 23 | 23 | const { option, persetOption } = props.config; |
| 24 | - const { componentInfo, attribute, attributeRename } = option; | |
| 24 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 25 | 25 | const { |
| 26 | 26 | fontColor: presetFontColor, |
| 27 | 27 | unit: presetUnit, |
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | return { |
| 35 | 35 | unit: unit ?? presetUnit, |
| 36 | 36 | fontColor: fontColor ?? presetFontColor, |
| 37 | - attribute: attributeRename || attribute, | |
| 37 | + attribute: attributeRename || attributeName || attribute, | |
| 38 | 38 | pointerColor: pointerColor ?? presetPointerColor, |
| 39 | 39 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
| 40 | 40 | gradientInfo: gradientInfo ?? presetGradientInfo, | ... | ... |
| ... | ... | @@ -25,13 +25,13 @@ |
| 25 | 25 | |
| 26 | 26 | const getDesign = computed(() => { |
| 27 | 27 | const { option, persetOption } = props.config; |
| 28 | - const { componentInfo, attribute, attributeRename } = option; | |
| 28 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 29 | 29 | const { fontColor: presetFontColor, unit: presetUnit } = persetOption || {}; |
| 30 | 30 | const { unit, fontColor } = componentInfo || {}; |
| 31 | 31 | return { |
| 32 | 32 | unit: unit ?? presetUnit, |
| 33 | 33 | fontColor: fontColor ?? presetFontColor, |
| 34 | - attribute: attributeRename || attribute, | |
| 34 | + attribute: attributeRename || attributeName || attribute, | |
| 35 | 35 | }; |
| 36 | 36 | }); |
| 37 | 37 | ... | ... |
| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; |
| 11 | 11 | import { useIntervalFn } from '@vueuse/core'; |
| 12 | 12 | import { nextTick } from 'vue'; |
| 13 | + import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | |
| 13 | 14 | |
| 14 | 15 | const props = defineProps<{ |
| 15 | 16 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -28,7 +29,7 @@ |
| 28 | 29 | |
| 29 | 30 | const getDesign = computed(() => { |
| 30 | 31 | const { option, persetOption } = props.config; |
| 31 | - const { componentInfo, attributeRename, attribute } = option; | |
| 32 | + const { componentInfo, attributeRename, attribute, attributeName } = option; | |
| 32 | 33 | |
| 33 | 34 | const { |
| 34 | 35 | fontColor: presetFontColor, |
| ... | ... | @@ -41,7 +42,7 @@ |
| 41 | 42 | unit: unit ?? presetUnit, |
| 42 | 43 | fontColor: fontColor ?? presetFontColor, |
| 43 | 44 | gradientInfo: gradientInfo ?? presetGradientInfo, |
| 44 | - attribute: attributeRename || attribute, | |
| 45 | + attribute: attributeRename || attributeName || attribute, | |
| 45 | 46 | }; |
| 46 | 47 | }); |
| 47 | 48 | |
| ... | ... | @@ -204,6 +205,7 @@ |
| 204 | 205 | |
| 205 | 206 | <template> |
| 206 | 207 | <main class="w-full h-full flex flex-col justify-center items-center"> |
| 208 | + <DeviceName :config="config" /> | |
| 207 | 209 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> |
| 208 | 210 | <div class="text-center text-gray-500 text-xs truncate"> |
| 209 | 211 | {{ getDesign.attribute || '速度' }} | ... | ... |
| ... | ... | @@ -24,13 +24,14 @@ |
| 24 | 24 | closeColor: persetCloseColor, |
| 25 | 25 | showDeviceName: persetShowDeviceName, |
| 26 | 26 | } = persetOption || {}; |
| 27 | - const { componentInfo } = option; | |
| 27 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
| 28 | 28 | |
| 29 | 29 | const { openColor, closeColor, showDeviceName } = componentInfo || {}; |
| 30 | 30 | return { |
| 31 | 31 | openColor: openColor ?? persetOpenColor, |
| 32 | 32 | closeColor: closeColor ?? persetCloseColor, |
| 33 | 33 | showDeviceName: showDeviceName ?? persetShowDeviceName, |
| 34 | + attribute: attributeRename || attributeName || attribute, | |
| 34 | 35 | }; |
| 35 | 36 | }); |
| 36 | 37 | |
| ... | ... | @@ -60,6 +61,7 @@ |
| 60 | 61 | <template> |
| 61 | 62 | <main :style="getScale" class="w-full h-full flex flex-col justify-center items-center"> |
| 62 | 63 | <DeviceName :config="config" class="text-center" /> |
| 64 | + | |
| 63 | 65 | <div |
| 64 | 66 | :style="{ |
| 65 | 67 | '--open-color': getDesign.openColor, |
| ... | ... | @@ -67,6 +69,7 @@ |
| 67 | 69 | }" |
| 68 | 70 | :class="isOpenClose ? 'switch_open' : 'switch_close'" |
| 69 | 71 | ></div> |
| 72 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute }}</div> | |
| 70 | 73 | <UpdateTime :time="time" /> |
| 71 | 74 | </main> |
| 72 | 75 | </template> | ... | ... |
| ... | ... | @@ -31,21 +31,14 @@ |
| 31 | 31 | return { |
| 32 | 32 | dataSource: dataSource?.map((item) => { |
| 33 | 33 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
| 34 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
| 35 | - // return { | |
| 36 | - // unit: unit ?? presetUnit, | |
| 37 | - // fontColor: fontColor ?? presetFontColor, | |
| 38 | - // attribute, | |
| 39 | - // attributeRename, | |
| 40 | - // deviceName, | |
| 41 | - // deviceRename, | |
| 42 | - // showDeviceName: showDeviceName ?? presetShowDeviceName, | |
| 43 | - // }; | |
| 34 | + const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = | |
| 35 | + item; | |
| 44 | 36 | return { |
| 45 | 37 | unit: unit ?? presetUnit, |
| 46 | 38 | fontColor: fontColor ?? presetFontColor, |
| 47 | 39 | attribute, |
| 48 | 40 | attributeRename, |
| 41 | + attributeName, | |
| 49 | 42 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
| 50 | 43 | deviceName, |
| 51 | 44 | deviceRename, |
| ... | ... | @@ -58,10 +51,8 @@ |
| 58 | 51 | const series = ref( |
| 59 | 52 | unref(getDesign).dataSource.map((item) => ({ |
| 60 | 53 | value: 0, |
| 61 | - name: `${ | |
| 62 | - item.showDeviceName | |
| 63 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
| 64 | - : '' | |
| 54 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
| 55 | + item.attributeRename || item.attributeName || item.attribute | |
| 65 | 56 | }`, |
| 66 | 57 | attribute: item.attribute, |
| 67 | 58 | id: item.id, |
| ... | ... | @@ -125,19 +116,9 @@ |
| 125 | 116 | chartInstance.value.setOption(options()); |
| 126 | 117 | }; |
| 127 | 118 | |
| 128 | - // const randomFn = () => { | |
| 129 | - // useIntervalFn(() => { | |
| 130 | - // const value = (Math.random() * 100).toFixed(0); | |
| 131 | - // unref(chartInstance)?.setOption({ | |
| 132 | - // series: [{ data: [{ value }] }, { data: [{ value }] }], | |
| 133 | - // } as EChartsOption); | |
| 134 | - // }, 3000); | |
| 135 | - // }; | |
| 136 | - | |
| 137 | 119 | const updateChart = (data: SeriesOption['data']) => { |
| 138 | 120 | unref(chartInstance)?.setOption({ |
| 139 | 121 | series: [{ data }], |
| 140 | - // color: unref(list).map((item) => item.title.color), | |
| 141 | 122 | } as EChartsOption); |
| 142 | 123 | }; |
| 143 | 124 | |
| ... | ... | @@ -154,32 +135,12 @@ |
| 154 | 135 | }); |
| 155 | 136 | |
| 156 | 137 | updateChart(unref(series)); |
| 157 | - // const { data = {} } = message; | |
| 158 | - // const { dataSource } = unref(getDesign); | |
| 159 | - // const series = dataSource.map((item) => { | |
| 160 | - // const { attribute, fontColor, unit, showDeviceName, deviceName, deviceRename } = item; | |
| 161 | - // const [latest] = data[attribute] || []; | |
| 162 | - // const [_timespan, value] = latest || []; | |
| 163 | - | |
| 164 | - // return { | |
| 165 | - // value, | |
| 166 | - // name: showDeviceName ? (deviceRename ? deviceRename : deviceName) : '', | |
| 167 | - // itemStyle: { color: fontColor }, | |
| 168 | - // tooltip: { | |
| 169 | - // valueFormatter(value) { | |
| 170 | - // return `${value} ${unit ?? ''}`; | |
| 171 | - // }, | |
| 172 | - // }, | |
| 173 | - // } as SeriesOption['data']; | |
| 174 | - // }); | |
| 175 | - // updateChart(series); | |
| 176 | 138 | }; |
| 177 | 139 | |
| 178 | 140 | useMultipleDataFetch(props, updateFn); |
| 179 | 141 | |
| 180 | 142 | onMounted(() => { |
| 181 | 143 | initial(); |
| 182 | - // !props.config.option.uuid && randomFn(); | |
| 183 | 144 | !props.config.option.uuid; |
| 184 | 145 | }); |
| 185 | 146 | ... | ... |
| ... | ... | @@ -32,16 +32,8 @@ |
| 32 | 32 | return { |
| 33 | 33 | dataSource: dataSource?.map((item) => { |
| 34 | 34 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
| 35 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
| 36 | - // return { | |
| 37 | - // unit: unit ?? presetUnit, | |
| 38 | - // fontColor: fontColor ?? presetFontColor, | |
| 39 | - // attribute, | |
| 40 | - // attributeRename, | |
| 41 | - // deviceName, | |
| 42 | - // deviceRename, | |
| 43 | - // showDeviceName: showDeviceName ?? presetShowDeviceName, | |
| 44 | - // }; | |
| 35 | + const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = | |
| 36 | + item; | |
| 45 | 37 | return { |
| 46 | 38 | unit: unit ?? presetUnit, |
| 47 | 39 | fontColor: fontColor ?? presetFontColor, |
| ... | ... | @@ -50,6 +42,7 @@ |
| 50 | 42 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
| 51 | 43 | deviceName, |
| 52 | 44 | deviceRename, |
| 45 | + attributeName, | |
| 53 | 46 | id: deviceId, |
| 54 | 47 | }; |
| 55 | 48 | }), |
| ... | ... | @@ -57,7 +50,6 @@ |
| 57 | 50 | }); |
| 58 | 51 | |
| 59 | 52 | const options = (): EChartsOption => { |
| 60 | - // getStageColor(gradientInfo); | |
| 61 | 53 | return { |
| 62 | 54 | tooltip: { |
| 63 | 55 | trigger: 'item', |
| ... | ... | @@ -112,19 +104,9 @@ |
| 112 | 104 | chartInstance.value.setOption(options()); |
| 113 | 105 | }; |
| 114 | 106 | |
| 115 | - // const randomFn = () => { | |
| 116 | - // useIntervalFn(() => { | |
| 117 | - // const value = (Math.random() * 100).toFixed(0); | |
| 118 | - // unref(chartInstance)?.setOption({ | |
| 119 | - // series: [{ data: [{ value }] }, { data: [{ value }] }], | |
| 120 | - // } as EChartsOption); | |
| 121 | - // }, 3000); | |
| 122 | - // }; | |
| 123 | - | |
| 124 | 107 | const updateChart = (data: SeriesOption['data']) => { |
| 125 | 108 | unref(chartInstance)?.setOption({ |
| 126 | 109 | series: [{ data }], |
| 127 | - // color: unref(list).map((item) => item.title.color), | |
| 128 | 110 | } as EChartsOption); |
| 129 | 111 | }; |
| 130 | 112 | const { forEachGroupMessage } = useReceiveMessage(); |
| ... | ... | @@ -133,10 +115,8 @@ |
| 133 | 115 | const series = ref( |
| 134 | 116 | unref(getDesign).dataSource.map((item) => ({ |
| 135 | 117 | value: 0, |
| 136 | - name: `${ | |
| 137 | - item.showDeviceName | |
| 138 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
| 139 | - : '' | |
| 118 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
| 119 | + item.attributeRename || item.attributeName || item.attribute | |
| 140 | 120 | }`, |
| 141 | 121 | itemStyle: { color: item.fontColor }, |
| 142 | 122 | attribute: item.attribute, |
| ... | ... | @@ -150,7 +130,6 @@ |
| 150 | 130 | ); |
| 151 | 131 | |
| 152 | 132 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
| 153 | - // console.log(unref(series), 'series', unref(getDesign).dataSource); | |
| 154 | 133 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
| 155 | 134 | series.value.forEach((item) => { |
| 156 | 135 | if (item.id === deviceId && item.attribute === attribute) { |
| ... | ... | @@ -179,7 +158,6 @@ |
| 179 | 158 | |
| 180 | 159 | onMounted(() => { |
| 181 | 160 | initial(); |
| 182 | - // !props.config.option.uuid && randomFn(); | |
| 183 | 161 | !props.config.option.uuid; |
| 184 | 162 | }); |
| 185 | 163 | ... | ... |
| ... | ... | @@ -3,7 +3,6 @@ |
| 3 | 3 | import { option } from './config'; |
| 4 | 4 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; |
| 5 | 5 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
| 6 | - import { computed } from 'vue'; | |
| 7 | 6 | import { ref, onMounted, unref } from 'vue'; |
| 8 | 7 | import { useIntervalFn } from '@vueuse/core'; |
| 9 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| ... | ... | @@ -15,23 +14,6 @@ |
| 15 | 14 | |
| 16 | 15 | const isOpenClose = ref<boolean>(true); |
| 17 | 16 | |
| 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 | 17 | const randomFn = () => { |
| 36 | 18 | useIntervalFn(() => { |
| 37 | 19 | isOpenClose.value = !unref(isOpenClose); |
| ... | ... | @@ -58,12 +40,10 @@ |
| 58 | 40 | <main :style="getScale" class="w-full h-full flex flex-col justify-center items-center"> |
| 59 | 41 | <DeviceName :config="config" class="text-center" /> |
| 60 | 42 | <div |
| 61 | - :style="{ | |
| 62 | - '--open-color': getDesign.openColor, | |
| 63 | - '--close-color': getDesign.closeColor, | |
| 64 | - }" | |
| 43 | + style="--open-color: `${getDesign.openColor}`; --close-color: `${getDesign.closeColor}`" | |
| 65 | 44 | :class="isOpenClose ? 'switch_open' : 'switch_close'" |
| 66 | - ></div> | |
| 45 | + > | |
| 46 | + </div> | |
| 67 | 47 | </main> |
| 68 | 48 | </template> |
| 69 | 49 | <style lang="less" scoped> | ... | ... |
| ... | ... | @@ -18,12 +18,12 @@ |
| 18 | 18 | |
| 19 | 19 | const { fontColor: persetFontColor } = persetOption; |
| 20 | 20 | |
| 21 | - const { componentInfo, attribute, attributeRename } = option; | |
| 21 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 22 | 22 | |
| 23 | 23 | const { fontColor } = componentInfo || {}; |
| 24 | 24 | return { |
| 25 | 25 | fontColor: fontColor || persetFontColor, |
| 26 | - attribute: attributeRename || attribute, | |
| 26 | + attribute: attributeRename || attributeName || attribute, | |
| 27 | 27 | }; |
| 28 | 28 | }); |
| 29 | 29 | |
| ... | ... | @@ -46,7 +46,7 @@ |
| 46 | 46 | <h1 class="my-4 font-bold text-xl !my-2 truncate" :style="{ color: getDesign.fontColor }"> |
| 47 | 47 | {{ currentValue || 0 }} |
| 48 | 48 | </h1> |
| 49 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 49 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 50 | 50 | <!-- <div v-if="config.option.componentInfo.showDeviceName"> |
| 51 | 51 | {{ config.option.deviceRename || config.option.deviceName }} |
| 52 | 52 | </div> --> | ... | ... |
| ... | ... | @@ -20,13 +20,13 @@ |
| 20 | 20 | |
| 21 | 21 | const { fontColor: persetFontColor } = persetOption; |
| 22 | 22 | |
| 23 | - const { componentInfo, attribute, attributeRename } = option; | |
| 23 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
| 24 | 24 | |
| 25 | 25 | const { fontColor } = componentInfo || {}; |
| 26 | 26 | |
| 27 | 27 | return { |
| 28 | 28 | fontColor: fontColor || persetFontColor, |
| 29 | - attribute: attributeRename || attribute, | |
| 29 | + attribute: attributeRename || attributeName || attribute, | |
| 30 | 30 | }; |
| 31 | 31 | }); |
| 32 | 32 | |
| ... | ... | @@ -51,7 +51,7 @@ |
| 51 | 51 | <h1 class="my-4 font-bold text-xl !my-2 truncate" :style="{ color: getDesign.fontColor }"> |
| 52 | 52 | {{ currentValue || 0 }} |
| 53 | 53 | </h1> |
| 54 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 54 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 55 | 55 | </div> |
| 56 | 56 | <UpdateTime :time="time" /> |
| 57 | 57 | </main> | ... | ... |
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | fontColor: persetFontColor, |
| 28 | 28 | } = persetOption; |
| 29 | 29 | |
| 30 | - const { componentInfo, attribute, attributeRename } = option; | |
| 30 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 31 | 31 | |
| 32 | 32 | const { icon, iconColor, fontColor, unit } = componentInfo || {}; |
| 33 | 33 | return { |
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | unit: unit ?? perseUnit, |
| 36 | 36 | icon: icon || persetIcon, |
| 37 | 37 | fontColor: fontColor || persetFontColor, |
| 38 | - attribute: attributeRename || attribute, | |
| 38 | + attribute: attributeRename || attributeName || attribute, | |
| 39 | 39 | }; |
| 40 | 40 | }); |
| 41 | 41 | |
| ... | ... | @@ -66,7 +66,7 @@ |
| 66 | 66 | <span> {{ currentValue || 0 }}</span> |
| 67 | 67 | <span>{{ getDesign.unit }} </span> |
| 68 | 68 | </h1> |
| 69 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 69 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 70 | 70 | </div> |
| 71 | 71 | <UpdateTime :time="time" /> |
| 72 | 72 | </main> | ... | ... |
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | fontColor: persetFontColor, |
| 25 | 25 | } = persetOption; |
| 26 | 26 | |
| 27 | - const { componentInfo, attribute, attributeRename } = option; | |
| 27 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
| 28 | 28 | |
| 29 | 29 | const { icon, iconColor, fontColor, unit } = componentInfo || {}; |
| 30 | 30 | return { |
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | unit: unit ?? perseUnit, |
| 33 | 33 | icon: icon || persetIcon, |
| 34 | 34 | fontColor: fontColor || persetFontColor, |
| 35 | - attribute: attributeRename || attribute, | |
| 35 | + attribute: attributeRename || attributeName || attribute, | |
| 36 | 36 | }; |
| 37 | 37 | }); |
| 38 | 38 | |
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | <span>{{ currentValue || 0 }}</span> |
| 63 | 63 | <span>{{ getDesign.unit }}</span> |
| 64 | 64 | </h1> |
| 65 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 65 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
| 66 | 66 | </div> |
| 67 | 67 | </main> |
| 68 | 68 | </template> | ... | ... |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | attributeRename?: string; |
| 31 | 31 | deviceId?: string; |
| 32 | 32 | deviceName?: string; |
| 33 | + attributeName?: string; | |
| 33 | 34 | deviceRename?: string; |
| 34 | 35 | } |
| 35 | 36 | |
| ... | ... | @@ -65,7 +66,8 @@ |
| 65 | 66 | return { |
| 66 | 67 | dataSource: dataSource.map((item) => { |
| 67 | 68 | const { unit, fontColor, backgroundColor } = item.componentInfo || {}; |
| 68 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
| 69 | + const { attribute, attributeRename, deviceName, deviceRename, deviceId, attributeName } = | |
| 70 | + item; | |
| 69 | 71 | return { |
| 70 | 72 | unit: unit ?? presetUnit, |
| 71 | 73 | fontColor: fontColor ?? presetFontColor, |
| ... | ... | @@ -74,6 +76,7 @@ |
| 74 | 76 | deviceRename, |
| 75 | 77 | attribute, |
| 76 | 78 | attributeRename, |
| 79 | + attributeName, | |
| 77 | 80 | id: deviceId, |
| 78 | 81 | } as PercentType; |
| 79 | 82 | }), |
| ... | ... | @@ -112,11 +115,11 @@ |
| 112 | 115 | class="mt-2 flex flex-col ml-3 mr-3 items-stretch" |
| 113 | 116 | > |
| 114 | 117 | <div class="flex justify-between"> |
| 115 | - <div class="text-gray-500 text-lg truncate" :style="{ color: item.fontColor }"> | |
| 118 | + <div class="text-gray-500 text-sm truncate" :style="{ color: item.fontColor }"> | |
| 116 | 119 | {{ |
| 117 | - (item.deviceRename || item.deviceName) + | |
| 118 | - '-' + | |
| 119 | - (item.attributeRename || item.attribute) || '温度' | |
| 120 | + `${item.deviceRename || item.deviceName} | |
| 121 | + - | |
| 122 | + ${item.attributeRename || item.attributeName || item.attribute || '温度'}` | |
| 120 | 123 | }} |
| 121 | 124 | </div> |
| 122 | 125 | <span class="text-lg" :style="{ color: item.fontColor }" | ... | ... |