|
|
@@ -1,18 +1,58 @@
|
|
|
<template>
|
|
|
- <a-card>
|
|
|
-
|
|
|
+ <a-row justify="space-between" >
|
|
|
+ <a-col style="font-size: 20px;" >消息跟踪</a-col>
|
|
|
+ <a-col>
|
|
|
+ <a-space>
|
|
|
+ {{state.device.deviceLabel}}
|
|
|
+ <a-button type="primary" @click="openSelectDrawer">选择设备</a-button>
|
|
|
+ </a-space>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-card style="margin-top: 20px" >
|
|
|
+ <a-empty v-if="state.dataSource.length === 0" >
|
|
|
+ <template #description>
|
|
|
+ <span>消息跟踪可记录设备运行过程中的各类信息,帮助您定位设备故障</span>
|
|
|
+ </template>
|
|
|
+ </a-empty>
|
|
|
<a-table
|
|
|
+ v-else
|
|
|
:columns="columns"
|
|
|
:loading="state.loading"
|
|
|
:dataSource="state.dataSource"
|
|
|
>
|
|
|
-
|
|
|
</a-table>
|
|
|
</a-card>
|
|
|
+
|
|
|
+ <a-drawer
|
|
|
+ v-model:visible="state.drawerVisible"
|
|
|
+ size="large"
|
|
|
+ class="custom-class"
|
|
|
+ title="选择设备"
|
|
|
+ placement="right"
|
|
|
+ >
|
|
|
+ <SelectDevice ref="selectDeviceRef" />
|
|
|
+ <template #footer >
|
|
|
+ <a-row justify="end" >
|
|
|
+ <a-col>
|
|
|
+ <a-space>
|
|
|
+ <a-button @click="state.drawerVisible = false">取消</a-button>
|
|
|
+ <a-button type="primary" @click="handleSelectDevice">确定</a-button>
|
|
|
+ </a-space>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </template>
|
|
|
+ </a-drawer>
|
|
|
</template>
|
|
|
<script lang='ts' setup >
|
|
|
import { EventController } from '@/controller'
|
|
|
-import { onMounted, reactive } from 'vue'
|
|
|
+import { message } from 'ant-design-vue'
|
|
|
+import { onMounted, reactive, ref } from 'vue'
|
|
|
+import { useRoute } from 'vue-router'
|
|
|
+import SelectDevice from '@/pages/iot/rule/components/selectDevice.vue'
|
|
|
+
|
|
|
+const route = useRoute()
|
|
|
+
|
|
|
+const deviceId = route.query.id as string
|
|
|
|
|
|
const columns = [
|
|
|
{
|
|
|
@@ -36,20 +76,58 @@ const columns = [
|
|
|
dataIndex: 'status'
|
|
|
}
|
|
|
]
|
|
|
+
|
|
|
+const selectDeviceRef = ref()
|
|
|
+
|
|
|
+const queryParamsState = reactive({
|
|
|
+ deviceId: deviceId,
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ eventType: '',
|
|
|
+ success: false,
|
|
|
+ total: 0,
|
|
|
+ startTime: 0,
|
|
|
+ endTime: '',
|
|
|
+ lastId: ''
|
|
|
+})
|
|
|
+
|
|
|
const state = reactive({
|
|
|
loading: false,
|
|
|
- dataSource: []
|
|
|
+ device: {},
|
|
|
+ dataSource: [],
|
|
|
+ drawerVisible: false
|
|
|
})
|
|
|
|
|
|
+const openSelectDrawer = () => {
|
|
|
+ state.drawerVisible = true
|
|
|
+}
|
|
|
+
|
|
|
+const handleSelectDevice = () => {
|
|
|
+ const _device = selectDeviceRef.value.getSelectDevice()
|
|
|
+ if (_device) {
|
|
|
+ state.device = _device
|
|
|
+ console.log(_device)
|
|
|
+ state.drawerVisible = false
|
|
|
+ queryParamsState.deviceId = _device.id
|
|
|
+ queryParamsState.page = 1
|
|
|
+ getMsgTrace()
|
|
|
+ } else {
|
|
|
+ message.warn('请选择产品')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const getMsgTrace = async () => {
|
|
|
state.loading = true
|
|
|
- const { data } = await EventController.list({ deviceId: '1', startTime: 0 })
|
|
|
+ const { data, sum } = await EventController.page(queryParamsState)
|
|
|
state.loading = false
|
|
|
state.dataSource = data
|
|
|
+ state.total = sum
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- getMsgTrace()
|
|
|
+ if (deviceId) {
|
|
|
+ getMsgTrace()
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
</script>
|