Showing
3 changed files
with
14 additions
and
9 deletions
| ... | ... | @@ -8,12 +8,14 @@ |
| 8 | 8 | import { useIntervalFn } from '@vueuse/core'; |
| 9 | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
| 10 | 10 | import { useReceiveValue } from '../../../hook/useReceiveValue'; |
| 11 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
| 11 | 12 | |
| 12 | 13 | const props = defineProps<{ |
| 13 | 14 | config: ComponentPropsConfigType<typeof option>; |
| 14 | 15 | }>(); |
| 15 | 16 | |
| 16 | 17 | const isOpenClose = ref<boolean>(true); |
| 18 | + const time = ref<Nullable<number>>(null); | |
| 17 | 19 | |
| 18 | 20 | const getDesign = computed(() => { |
| 19 | 21 | const { persetOption = {}, option } = props.config; |
| ... | ... | @@ -41,7 +43,8 @@ |
| 41 | 43 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
| 42 | 44 | const { data = {} } = message; |
| 43 | 45 | const [latest] = data[attribute] || []; |
| 44 | - const [_, value] = latest; | |
| 46 | + const [timespan, value] = latest; | |
| 47 | + time.value = timespan; | |
| 45 | 48 | isOpenClose.value = Boolean(getNumberValue(value)); |
| 46 | 49 | }; |
| 47 | 50 | |
| ... | ... | @@ -64,6 +67,7 @@ |
| 64 | 67 | }" |
| 65 | 68 | :class="isOpenClose ? 'switch_open' : 'switch_close'" |
| 66 | 69 | ></div> |
| 70 | + <UpdateTime :time="time" /> | |
| 67 | 71 | </main> |
| 68 | 72 | </template> |
| 69 | 73 | <style lang="less" scoped> | ... | ... |
| ... | ... | @@ -125,13 +125,6 @@ |
| 125 | 125 | </div> |
| 126 | 126 | <div> |
| 127 | 127 | <Progress :strokeColor="item.backgroundColor" :percent="item.value" :showInfo="false" /> |
| 128 | - <!-- <Slider | |
| 129 | - :style="{ '--slider-color': item.backgroundColor }" | |
| 130 | - v-model:value="item.value" | |
| 131 | - :disabled="true" | |
| 132 | - :min="0" | |
| 133 | - :max="index == 0 ? 100 : 1000" | |
| 134 | - /> --> | |
| 135 | 128 | </div> |
| 136 | 129 | </div> |
| 137 | 130 | <UpdateTime :time="time" /> | ... | ... |
| ... | ... | @@ -49,6 +49,11 @@ const isTcpProfile = (transportType: string) => transportType === TransportTypeE |
| 49 | 49 | |
| 50 | 50 | const isControlComponent = (category?: string) => PackagesCategoryEnum.CONTROL === category; |
| 51 | 51 | |
| 52 | +const isBooleanComponent = (componentKeys: { categoryKey?: string; componentKey?: string }) => { | |
| 53 | + const { categoryKey, componentKey } = componentKeys; | |
| 54 | + return categoryKey == 'OTHER' && componentKey == 'SwitchSignalLight'; | |
| 55 | +}; | |
| 56 | + | |
| 52 | 57 | const getDeviceService = async (deviceProfileId: string) => { |
| 53 | 58 | try { |
| 54 | 59 | const data = await getModelServices({ deviceProfileId }); |
| ... | ... | @@ -238,7 +243,10 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
| 238 | 243 | if (deviceProfileId) { |
| 239 | 244 | return await getDeviceAttribute({ |
| 240 | 245 | deviceProfileId, |
| 241 | - dataType: isControlComponent(category!) ? DataTypeEnum.IS_BOOL : undefined, | |
| 246 | + dataType: | |
| 247 | + isControlComponent(category!) || isBooleanComponent(unref(selectWidgetKeys)) | |
| 248 | + ? DataTypeEnum.IS_BOOL | |
| 249 | + : undefined, | |
| 242 | 250 | }); |
| 243 | 251 | } |
| 244 | 252 | } catch (error) {} | ... | ... |