Commit 46b685a52ac89f463652f5c43f6037023b6c3f91

Authored by loveumiko
1 parent 11c4bd50

fix: 修改开关量信号灯boolean选取

@@ -8,12 +8,14 @@ @@ -8,12 +8,14 @@
8 import { useIntervalFn } from '@vueuse/core'; 8 import { useIntervalFn } from '@vueuse/core';
9 import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; 9 import { DeviceName } from '/@/views/visual/commonComponents/DeviceName';
10 import { useReceiveValue } from '../../../hook/useReceiveValue'; 10 import { useReceiveValue } from '../../../hook/useReceiveValue';
  11 + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime';
11 12
12 const props = defineProps<{ 13 const props = defineProps<{
13 config: ComponentPropsConfigType<typeof option>; 14 config: ComponentPropsConfigType<typeof option>;
14 }>(); 15 }>();
15 16
16 const isOpenClose = ref<boolean>(true); 17 const isOpenClose = ref<boolean>(true);
  18 + const time = ref<Nullable<number>>(null);
17 19
18 const getDesign = computed(() => { 20 const getDesign = computed(() => {
19 const { persetOption = {}, option } = props.config; 21 const { persetOption = {}, option } = props.config;
@@ -41,7 +43,8 @@ @@ -41,7 +43,8 @@
41 const updateFn: DataFetchUpdateFn = (message, attribute) => { 43 const updateFn: DataFetchUpdateFn = (message, attribute) => {
42 const { data = {} } = message; 44 const { data = {} } = message;
43 const [latest] = data[attribute] || []; 45 const [latest] = data[attribute] || [];
44 - const [_, value] = latest; 46 + const [timespan, value] = latest;
  47 + time.value = timespan;
45 isOpenClose.value = Boolean(getNumberValue(value)); 48 isOpenClose.value = Boolean(getNumberValue(value));
46 }; 49 };
47 50
@@ -64,6 +67,7 @@ @@ -64,6 +67,7 @@
64 }" 67 }"
65 :class="isOpenClose ? 'switch_open' : 'switch_close'" 68 :class="isOpenClose ? 'switch_open' : 'switch_close'"
66 ></div> 69 ></div>
  70 + <UpdateTime :time="time" />
67 </main> 71 </main>
68 </template> 72 </template>
69 <style lang="less" scoped> 73 <style lang="less" scoped>
@@ -125,13 +125,6 @@ @@ -125,13 +125,6 @@
125 </div> 125 </div>
126 <div> 126 <div>
127 <Progress :strokeColor="item.backgroundColor" :percent="item.value" :showInfo="false" /> 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 </div> 128 </div>
136 </div> 129 </div>
137 <UpdateTime :time="time" /> 130 <UpdateTime :time="time" />
@@ -49,6 +49,11 @@ const isTcpProfile = (transportType: string) => transportType === TransportTypeE @@ -49,6 +49,11 @@ const isTcpProfile = (transportType: string) => transportType === TransportTypeE
49 49
50 const isControlComponent = (category?: string) => PackagesCategoryEnum.CONTROL === category; 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 const getDeviceService = async (deviceProfileId: string) => { 57 const getDeviceService = async (deviceProfileId: string) => {
53 try { 58 try {
54 const data = await getModelServices({ deviceProfileId }); 59 const data = await getModelServices({ deviceProfileId });
@@ -238,7 +243,10 @@ export const commonDataSourceSchemas = (): FormSchema[] => { @@ -238,7 +243,10 @@ export const commonDataSourceSchemas = (): FormSchema[] => {
238 if (deviceProfileId) { 243 if (deviceProfileId) {
239 return await getDeviceAttribute({ 244 return await getDeviceAttribute({
240 deviceProfileId, 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 } catch (error) {} 252 } catch (error) {}