diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts
index dac795b3..4d5a2cd3 100644
--- a/src/api/iot/device/index.ts
+++ b/src/api/iot/device/index.ts
@@ -8,6 +8,7 @@ export interface DeviceVO {
deviceType: string // 设备类型
status: string // 状态
isConnect?: string | number
+ operatingStatus?: string | number
readTopic: string // 读主题
writeTopic: string // 写主题
gatewayId: number // 网关id
@@ -24,6 +25,7 @@ export interface DeviceVO {
password: string // 密码
certificate?: string // 证书
secretKey?: string // 秘钥
+ collectionTime?: string | number
}
export interface DeviceConnectParams {
diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue
index 3f02b108..073f642d 100644
--- a/src/views/iot/device/index.vue
+++ b/src/views/iot/device/index.vue
@@ -70,22 +70,32 @@ ref="tableRef" v-loading="loading" :data="list" :stripe="true" :show-overflow-to
+
+
+
+ {{ getOperatingStatusLabel(scope.row.operatingStatus) }}
+
+
+
-
+
-
+
-
+
-
+
+
点位
@@ -454,20 +471,40 @@ const queryParams = reactive({
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
+const getOperatingStatusLabel = (value: string | number | undefined) => {
+ const text = String(value ?? '').trim()
+ if (!text) return '离线'
+ return text
+}
+
+const getOperatingStatusType = (value: string | number | undefined) => {
+ const text = String(value ?? '').trim()
+ if (!text) return 'info'
+ if (text === '运行') return 'success'
+ if (text === '待机中') return 'info'
+ if (text === '故障中') return 'danger'
+ if (text === '报警中') return 'warning'
+ return 'info'
+}
+
const selectedIds = ref([])
const handleSelectionChange = (rows: any[]) => {
selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? []
}
/** 查询列表 */
-const getList = async () => {
- loading.value = true
+const getList = async (showLoading = true) => {
+ if (showLoading) {
+ loading.value = true
+ }
try {
const data = await DeviceApi.getDevicePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
- loading.value = false
+ if (showLoading) {
+ loading.value = false
+ }
}
}
@@ -948,9 +985,36 @@ const handleToggleConnect = async (row: DeviceVO) => {
}
}
-/** 初始化 **/
+let deviceTimer: number | undefined
+
+const startDeviceTimer = () => {
+ if (deviceTimer) return
+ deviceTimer = window.setInterval(() => {
+ getList(false)
+ }, 5000)
+}
+
+const stopDeviceTimer = () => {
+ if (!deviceTimer) return
+ window.clearInterval(deviceTimer)
+ deviceTimer = undefined
+}
+
onMounted(() => {
getList()
+ startDeviceTimer()
+})
+
+onActivated(() => {
+ startDeviceTimer()
+})
+
+onDeactivated(() => {
+ stopDeviceTimer()
+})
+
+onBeforeUnmount(() => {
+ stopDeviceTimer()
})