1
|
<script lang="ts" setup>
|
1
|
<script lang="ts" setup>
|
2
|
- import { nextTick, reactive, ref, unref } from 'vue';
|
2
|
+ import { nextTick, onUnmounted, reactive, ref, unref } from 'vue';
|
3
|
import { List, Button, Tooltip, Card } from 'ant-design-vue';
|
3
|
import { List, Button, Tooltip, Card } from 'ant-design-vue';
|
4
|
import { PageWrapper } from '/@/components/Page';
|
4
|
import { PageWrapper } from '/@/components/Page';
|
5
|
import { AppstoreOutlined, BarsOutlined } from '@ant-design/icons-vue';
|
5
|
import { AppstoreOutlined, BarsOutlined } from '@ant-design/icons-vue';
|
|
@@ -13,6 +13,9 @@ |
|
@@ -13,6 +13,9 @@ |
13
|
import { BasicForm, useForm } from '/@/components/Form';
|
13
|
import { BasicForm, useForm } from '/@/components/Form';
|
14
|
import HistoryData from './HistoryData.vue';
|
14
|
import HistoryData from './HistoryData.vue';
|
15
|
import { BasicModal, useModal } from '/@/components/Modal';
|
15
|
import { BasicModal, useModal } from '/@/components/Modal';
|
|
|
16
|
+ import { getDeviceAttrs } from '/@/api/device/deviceManager';
|
|
|
17
|
+ import { DeviceModelOfMatterAttrs } from '/@/api/device/model/deviceModel';
|
|
|
18
|
+ import { computed } from '@vue/reactivity';
|
16
|
|
19
|
|
17
|
interface ReceiveMessage {
|
20
|
interface ReceiveMessage {
|
18
|
data: {
|
21
|
data: {
|
|
@@ -27,7 +30,7 @@ |
|
@@ -27,7 +30,7 @@ |
27
|
}
|
30
|
}
|
28
|
|
31
|
|
29
|
const props = defineProps<{
|
32
|
const props = defineProps<{
|
30
|
- deviceDetail: Record<'tbDeviceId', string>;
|
33
|
+ deviceDetail: Record<'tbDeviceId' | 'profileId' | 'id', string>;
|
31
|
}>();
|
34
|
}>();
|
32
|
|
35
|
|
33
|
const grid = {
|
36
|
const grid = {
|
|
@@ -43,16 +46,21 @@ |
|
@@ -43,16 +46,21 @@ |
43
|
originData: [] as DataSource[],
|
46
|
originData: [] as DataSource[],
|
44
|
dataSource: [] as DataSource[],
|
47
|
dataSource: [] as DataSource[],
|
45
|
message: {} as ReceiveMessage['data'],
|
48
|
message: {} as ReceiveMessage['data'],
|
46
|
- sendValue: {
|
49
|
+ attrKeys: [] as DeviceModelOfMatterAttrs[],
|
|
|
50
|
+ });
|
|
|
51
|
+
|
|
|
52
|
+ const getSendValue = computed(() => {
|
|
|
53
|
+ return {
|
47
|
tsSubCmds: [
|
54
|
tsSubCmds: [
|
48
|
{
|
55
|
{
|
49
|
entityType: 'DEVICE',
|
56
|
entityType: 'DEVICE',
|
50
|
- entityId: props.deviceDetail!.tbDeviceId || 'd2526c70-60a9-11ed-ba9c-6b98bfcc8255',
|
57
|
+ entityId: props.deviceDetail!.tbDeviceId,
|
51
|
scope: 'LATEST_TELEMETRY',
|
58
|
scope: 'LATEST_TELEMETRY',
|
52
|
cmdId: 1,
|
59
|
cmdId: 1,
|
|
|
60
|
+ keys: socketInfo.attrKeys.map((item) => item.identifier).join(','),
|
53
|
},
|
61
|
},
|
54
|
],
|
62
|
],
|
55
|
- },
|
63
|
+ };
|
56
|
});
|
64
|
});
|
57
|
|
65
|
|
58
|
const [registerForm, { getFieldsValue }] = useForm({
|
66
|
const [registerForm, { getFieldsValue }] = useForm({
|
|
@@ -115,8 +123,12 @@ |
|
@@ -115,8 +123,12 @@ |
115
|
const { createMessage } = useMessage();
|
123
|
const { createMessage } = useMessage();
|
116
|
|
124
|
|
117
|
const { send, close, data } = useWebSocket(socketInfo.origin, {
|
125
|
const { send, close, data } = useWebSocket(socketInfo.origin, {
|
118
|
- onConnected() {
|
|
|
119
|
- send(JSON.stringify(socketInfo.sendValue));
|
126
|
+ async onConnected() {
|
|
|
127
|
+ const { id, profileId } = props.deviceDetail;
|
|
|
128
|
+ const value = await getDeviceAttrs(profileId, id);
|
|
|
129
|
+ console.log(value);
|
|
|
130
|
+ socketInfo.attrKeys = value;
|
|
|
131
|
+ send(JSON.stringify(unref(getSendValue)));
|
120
|
},
|
132
|
},
|
121
|
async onMessage() {
|
133
|
async onMessage() {
|
122
|
try {
|
134
|
try {
|
|
@@ -154,6 +166,8 @@ |
|
@@ -154,6 +166,8 @@ |
154
|
socketInfo.attr = key;
|
166
|
socketInfo.attr = key;
|
155
|
openModal(true);
|
167
|
openModal(true);
|
156
|
};
|
168
|
};
|
|
|
169
|
+
|
|
|
170
|
+ onUnmounted(() => close());
|
157
|
</script>
|
171
|
</script>
|
158
|
|
172
|
|
159
|
<template>
|
173
|
<template>
|
|
@@ -203,9 +217,9 @@ |
|
@@ -203,9 +217,9 @@ |
203
|
<template #extra>
|
217
|
<template #extra>
|
204
|
<Button type="link" class="!p-0" @click="handleShowDetail(item)">历史数据</Button>
|
218
|
<Button type="link" class="!p-0" @click="handleShowDetail(item)">历史数据</Button>
|
205
|
</template>
|
219
|
</template>
|
206
|
- <section>
|
220
|
+ <section class="min-h-16 flex flex-col justify-between">
|
207
|
<div class="flex font-bold text-lg mb-4">
|
221
|
<div class="flex font-bold text-lg mb-4">
|
208
|
- <div>{{ item.value }}</div>
|
222
|
+ <div>{{ item.value || '暂无数据' }}</div>
|
209
|
</div>
|
223
|
</div>
|
210
|
<div class="text-dark-800 text-xs">{{ formatToDateTime(item.time) }}</div>
|
224
|
<div class="text-dark-800 text-xs">{{ formatToDateTime(item.time) }}</div>
|
211
|
</section>
|
225
|
</section>
|