Browse Source

feat: 在线调试

lvkun 3 năm trước cách đây
mục cha
commit
498788cb8b
2 tập tin đã thay đổi với 73 bổ sung17 xóa
  1. 71 15
      src/pages/Iot/model/components/onlineTest.vue
  2. 2 2
      src/type/iot.d.ts

+ 71 - 15
src/pages/Iot/model/components/onlineTest.vue

@@ -1,7 +1,25 @@
 <template>
   <a-row>
-    <a-col>
-      online
+    <a-col :span="24" >
+      <a-table
+        :columns="columns"
+        :loading="state.loading"
+        :data-source="state.dataSource"
+      >
+        <template #bodyCell="{column, record}" >
+          <template v-if="column.key === 'deviceStatus'" >
+            <a-tag :color="record.deviceStatus.color" >{{record.deviceStatus.name}}</a-tag>
+          </template>
+          <template v-if="column.key === 'deviceNodeType'" >
+            {{record.deviceNodeType == 'GATEWAY' ? '直连类型' : '非直连类型' }}
+          </template>
+          <template  v-if="column.key === 'action'" >
+            <a-space>
+              <a @click="goDebugPage(record)">调试</a>
+            </a-space>
+          </template>
+        </template>
+      </a-table>
     </a-col>
   </a-row>
 </template>
@@ -9,34 +27,72 @@
 <script lang="ts" setup >
 import { EventController, DeviceContriller } from '@/controller/index'
 import { onMounted, reactive } from 'vue'
-import { useRoute } from 'vue-router'
+import { useRouter } from 'vue-router'
+
 const columns = [
-  {
 
+  {
+    title: '设备ID',
+    dataIndex: 'id'
+  },
+  {
+    title: '设备名称',
+    dataIndex: 'deviceLabel'
+  },
+  {
+    title: '设备标识码',
+    dataIndex: 'deviceCode'
+  },
+  {
+    title: '设备描述',
+    dataIndex: 'deviceDescription'
+  },
+  {
+    title: '节点类型',
+    dataIndex: 'deviceNodeType',
+    key: 'deviceNodeType'
+  },
+  {
+    title: '所属产品',
+    dataIndex: 'modelLabel'
+  },
+  {
+    title: '状态',
+    dataIndex: 'deviceStatus',
+    key: 'deviceStatus'
+  },
+  {
+    title: '操作',
+    key: 'action'
   }
 ]
 
-const route = useRoute()
-const modelId = route.query.id as string
+const router = useRouter()
 
 const state = reactive({
+  loading: false,
+  dataSource: [],
   queryParams: {
-    deviceId: modelId,
-    lastId: '',
-    startTime: 0
+    page: 1,
+    pageSize: 200,
+    total: 0
   }
 })
 
-// const getDeviceList = async () => {
-//   await DeviceContriller.page()
-// }
+const goDebugPage = (record) => {
+  router.push({ path: '/devOps/onlineTest', query: { deviceId: record.id } })
+}
 
-const getEventList = async () => {
-  const { data, sum } = await EventController.list(state.queryParams)
+const getDevicePage = async () => {
+  state.loading = true
+  const { data, sum } = await DeviceContriller.page({ page: 1, pageSize: 200 })
+  state.loading = false
+  state.dataSource = data
+  state.queryParams.total = sum
 }
 
 onMounted(() => {
-  getEventList()
+  getDevicePage()
 })
 </script>
 

+ 2 - 2
src/type/iot.d.ts

@@ -78,10 +78,10 @@ declare namespace IOT {
       type QueryPamars = {
         page: number
         pageSize: number
-        deviceStatus: DeviceTypeEnum
+        deviceStatus?: DeviceTypeEnum
         modelId?: string
         searchKey?: string
-        searchValue: string
+        searchValue?: string
       }
 
       type BodyParams = {