Commit e95e5596cad611c563afcf04206823c48d99702b
1 parent
13768ad9
perf: device detail model of matter struct && text type attribute can not open history data
Showing
1 changed file
with
24 additions
and
2 deletions
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | import { computed } from '@vue/reactivity'; | 18 | import { computed } from '@vue/reactivity'; |
19 | import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 19 | import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
20 | import { isArray, isObject } from '/@/utils/is'; | 20 | import { isArray, isObject } from '/@/utils/is'; |
21 | + import { DateTypeEnum } from '/@/components/Form/src/externalCompns/components/StructForm/config'; | ||
21 | 22 | ||
22 | interface ReceiveMessage { | 23 | interface ReceiveMessage { |
23 | data: { | 24 | data: { |
@@ -135,6 +136,10 @@ | @@ -135,6 +136,10 @@ | ||
135 | : ''; | 136 | : ''; |
136 | }; | 137 | }; |
137 | 138 | ||
139 | + const isStructAndTextType = (type: DateTypeEnum) => { | ||
140 | + return [DateTypeEnum.IS_STRUCT, DateTypeEnum.IS_STRING].includes(type); | ||
141 | + }; | ||
142 | + | ||
138 | const { send, close, data } = useWebSocket(socketInfo.origin, { | 143 | const { send, close, data } = useWebSocket(socketInfo.origin, { |
139 | async onConnected() { | 144 | async onConnected() { |
140 | const { deviceProfileId } = props.deviceDetail; | 145 | const { deviceProfileId } = props.deviceDetail; |
@@ -156,7 +161,18 @@ | @@ -156,7 +161,18 @@ | ||
156 | const { identifier: key, name, detail } = item; | 161 | const { identifier: key, name, detail } = item; |
157 | const unit = getUnit(detail); | 162 | const unit = getUnit(detail); |
158 | const [time, value] = socketInfo.message[key].at(0) || []; | 163 | const [time, value] = socketInfo.message[key].at(0) || []; |
159 | - return { key, value, time, name, unit }; | 164 | + const dataInfo = socketInfo.attrKeys.find((item) => item.identifier === key); |
165 | + | ||
166 | + return { | ||
167 | + key, | ||
168 | + value, | ||
169 | + time, | ||
170 | + name, | ||
171 | + unit, | ||
172 | + showHistoryDataButton: !isStructAndTextType( | ||
173 | + dataInfo?.detail.dataType as unknown as DateTypeEnum | ||
174 | + ), | ||
175 | + }; | ||
160 | }); | 176 | }); |
161 | 177 | ||
162 | await nextTick(); | 178 | await nextTick(); |
@@ -226,7 +242,13 @@ | @@ -226,7 +242,13 @@ | ||
226 | <span class="text-base font-normal">{{ item.name }}</span> | 242 | <span class="text-base font-normal">{{ item.name }}</span> |
227 | </template> | 243 | </template> |
228 | <template #extra> | 244 | <template #extra> |
229 | - <Button type="link" class="!p-0" @click="handleShowDetail(item)">历史数据</Button> | 245 | + <Button |
246 | + v-if="item.showHistoryDataButton" | ||
247 | + type="link" | ||
248 | + class="!p-0" | ||
249 | + @click="handleShowDetail(item)" | ||
250 | + >历史数据</Button | ||
251 | + > | ||
230 | </template> | 252 | </template> |
231 | <section class="min-h-16 flex flex-col justify-between"> | 253 | <section class="min-h-16 flex flex-col justify-between"> |
232 | <div class="flex font-bold text-lg mb-4 gap-2"> | 254 | <div class="flex font-bold text-lg mb-4 gap-2"> |