diff --git a/src/api/log.ts b/src/api/log.ts index 8dce0b0..242d066 100644 --- a/src/api/log.ts +++ b/src/api/log.ts @@ -29,3 +29,4 @@ export function deleteLogs(ids: number[]) { data: ids, }); } + diff --git a/src/api/tsl.ts b/src/api/tsl.ts index 8abecc7..01f25e0 100644 --- a/src/api/tsl.ts +++ b/src/api/tsl.ts @@ -24,6 +24,7 @@ export interface eventRecord extends Record { level?: string; identifier?: string; productId?: number; + clientId?: number; } export function queryServeList(data: ServeRecord) { @@ -50,6 +51,15 @@ export function queryEventList(data: eventRecord) { }); } +// 事件记录 +export function queryEventLog(data: eventRecord) { + return axios({ + url: '/api/rest/tsl/event/log', + method: 'get', + params: data, + }); +} + export function createServe(data: any) { return axios.post(`/api/rest/tsl/serve`, data); } diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts index b89025e..ab3d9bd 100644 --- a/src/router/routes/modules/iot.ts +++ b/src/router/routes/modules/iot.ts @@ -44,7 +44,7 @@ const IOT: AppRouteRecordRaw = { locale: '设备管理(卡片)', title: '设备管理(卡片)', requiresAuth: true, - permissions: ['iot:device'], + permissions: ['iot:deviceCard'], }, }, { diff --git a/src/views/iot/device/components/device-detail.vue b/src/views/iot/device/components/device-detail.vue index 8bfb9b7..bb10245 100644 --- a/src/views/iot/device/components/device-detail.vue +++ b/src/views/iot/device/components/device-detail.vue @@ -100,15 +100,25 @@ + + + + + - + @@ -157,7 +167,7 @@ import { onMounted, ref } from 'vue'; import { Message } from '@arco-design/web-vue'; import { queryDeviceDetail, queryDeviceRecord, sendCommand } from '@/api/device'; - import { queryServeDetail, queryServeList } from '@/api/tsl'; + import { queryEventLog, queryServeDetail, queryServeList } from '@/api/tsl'; import useVisible from '@/hooks/visible'; import dynamicForm from './dynamic-form.vue'; import DeviceMap from './device-map.vue'; @@ -221,6 +231,18 @@ slotName: 'operations', }, ]; + const deviceEventColumns = [ + { + title: ' 事件名称', + dataIndex: 'name', + slotName: 'name', + }, + { + title: '操作', + dataIndex: 'operations', + slotName: 'operations', + }, + ];; const activeKey = ref('1'); const detailVisible = ref(false); @@ -243,24 +265,44 @@ } ); const deviceReportData = ref([]); + const deviceEventData = ref([]); + const deviceServerData = ref([]); const fields = ref([]); const fetchData = async (Id: number) => { - const res = await queryDeviceDetail(Id); - renderData.value = res.data; - const res1 = await queryDeviceRecord({ - clientId: renderData.value.clientId, - size: 10, - current: 1, - }); - deviceReportData.value = res1.data.records; - const res2 = await queryServeList({ - productId: renderData.value.productId, - size: 10, - current: 1, - }) - deviceServerData.value = res2.data.records; + try { + const [detailRes, recordRes, serveRes, eventRes] = await Promise.all([ + queryDeviceDetail(Id), + queryDeviceRecord({ + clientId: renderData.value.clientId, + size: 10, + current: 1, + }), + queryServeList({ + productId: renderData.value.productId, + size: 10, + current: 1, + }), + queryEventLog({ + clientId: renderData.value.clientId, + size: 10, + current: 1, + }), + ]); + + renderData.value = detailRes.data; + deviceReportData.value = recordRes.data.records; + deviceServerData.value = serveRes.data.records; + deviceEventData.value = eventRes.data.records; + } catch (error) { + console.error('Failed to fetch data:', error); + Message.error({ + content: '数据加载失败', + duration: 5 * 1000, + }); + } }; + const handleMenuClick = (e: any) => { activeKey.value = e; }; diff --git a/src/views/iot/device/components/device-map.vue b/src/views/iot/device/components/device-map.vue index d10a853..c4c7056 100644 --- a/src/views/iot/device/components/device-map.vue +++ b/src/views/iot/device/components/device-map.vue @@ -1,7 +1,7 @@ diff --git a/src/views/iot/product/components/product-edit.vue b/src/views/iot/product/components/product-edit.vue index 331f6c6..4833232 100644 --- a/src/views/iot/product/components/product-edit.vue +++ b/src/views/iot/product/components/product-edit.vue @@ -82,12 +82,12 @@ label="预览图" > @@ -97,11 +97,10 @@ > @@ -153,81 +152,11 @@ > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -