From fb5f085432cc9012b50229530bbb774667bbc04f Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 4 Feb 2026 15:00:52 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E9=87=87=E9=9B=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87-=E8=AE=BE=E5=A4=87=E5=91=8A=E8=AD=A6=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=BC=B9=E6=A1=86-=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E9=A1=B5=E3=80=81=E5=91=8A=E8=AD=A6=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=AD=9B=E9=80=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en.ts | 1 + src/locales/zh-CN.ts | 1 + src/views/iot/device/index.vue | 200 +++++++++++++++++++++++++++++++-- 3 files changed, 193 insertions(+), 9 deletions(-) diff --git a/src/locales/en.ts b/src/locales/en.ts index 07f9d69e..fea31a1d 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -3471,6 +3471,7 @@ export default { alarmPointName: 'Point Name', alarmPointValue: 'Point Value', alarmLevel: 'Alarm Level', + alarmTime: 'Alarm Time', emptyDescription: 'Click "Point" in the device list to view points and rules', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 492a4986..e7c9c1ea 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -3459,6 +3459,7 @@ export default { alarmPointName: '点位名称', alarmPointValue: '点位值', alarmLevel: '告警等级', + alarmTime: '告警时间', emptyDescription: '请点击设备列表的“点位”查看采集点和点位规则', diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index 45643aa9..66b45ada 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -494,13 +494,78 @@ - + + + + + + + + + + + + + + + + + + + {{ t('DataCollection.Device.search') }} + + + + {{ t('DataCollection.Device.reset') }} + + + + @@ -510,7 +575,22 @@ + +
+ +
@@ -1111,24 +1191,126 @@ onBeforeUnmount(() => { const deviceAlarmDialogVisible = ref(false) const deviceAlarmLoading = ref(false) const deviceAlarmList = ref([]) +const deviceAlarmTotal = ref(0) +const deviceAlarmQueryParams = reactive({ + pageNo: 1, + pageSize: 10, + deviceId: undefined as number | undefined, + modelId: undefined as number | undefined, + rule: undefined as string | undefined, + alarmLevel: undefined as string | undefined, + addressValue: undefined as string | undefined, + createTime: [] as string[], + ruleId: undefined as number | undefined, +}) +const deviceAlarmQueryFormRef = ref() +const deviceAlarmRuleOptions = ref([]) +const deviceAlarmPointOptions = ref([]) +const deviceAlarmRuleLoading = ref(false) +const deviceAlarmPointLoading = ref(false) -const handleShowDeviceAlarmHistory = async () => { - if (!attributeDeviceId.value) { - message.error(t('DataCollection.Device.messageSelectDeviceRequired')) - return +const loadDeviceAlarmRuleOptions = async () => { + if (!attributeDeviceId.value) return + deviceAlarmRuleLoading.value = true + try { + const res = await request.get({ + url: '/iot/device-point-rules/getList', + params: { id: attributeDeviceId.value }, + }) + const data = (res as any)?.data ?? res + const listData = Array.isArray((data as any)?.list) + ? (data as any).list + : Array.isArray(data) + ? data + : [] + deviceAlarmRuleOptions.value = listData as any[] + } finally { + deviceAlarmRuleLoading.value = false } - deviceAlarmDialogVisible.value = true - deviceAlarmLoading.value = true +} + +const loadDeviceAlarmPointOptions = async () => { + if (!attributeDeviceId.value) return + deviceAlarmPointLoading.value = true try { const res = await request.get({ - url: '/iot/device-warinning-record/getList', + url: '/iot/device/device-attribute/list', params: { deviceId: attributeDeviceId.value }, }) const data = (res as any)?.data ?? res - deviceAlarmList.value = Array.isArray(data) ? data : [] + const listData = Array.isArray((data as any)?.list) + ? (data as any).list + : Array.isArray(data) + ? data + : [] + deviceAlarmPointOptions.value = listData as any[] + } finally { + deviceAlarmPointLoading.value = false + } +} + +const getDeviceAlarmList = async () => { + if (!attributeDeviceId.value) return + deviceAlarmLoading.value = true + try { + deviceAlarmQueryParams.deviceId = attributeDeviceId.value + const params = { + pageNo: deviceAlarmQueryParams.pageNo, + pageSize: deviceAlarmQueryParams.pageSize, + deviceId: deviceAlarmQueryParams.deviceId, + modelId: deviceAlarmQueryParams.modelId, + rule: deviceAlarmQueryParams.rule, + alarmLevel: deviceAlarmQueryParams.alarmLevel, + addressValue: deviceAlarmQueryParams.addressValue, + createTime: deviceAlarmQueryParams.createTime, + ruleId: deviceAlarmQueryParams.ruleId, + } + const data = await request.get({ + url: '/iot/device-warinning-record/page', + params, + }) + const listData = Array.isArray((data as any)?.list) + ? (data as any).list + : Array.isArray(data) + ? data + : [] + const totalData = (data as any)?.total ?? listData.length + deviceAlarmList.value = listData as any[] + deviceAlarmTotal.value = totalData } finally { deviceAlarmLoading.value = false } } +const handleDeviceAlarmQuery = () => { + if (!attributeDeviceId.value) return + deviceAlarmQueryParams.pageNo = 1 + getDeviceAlarmList() +} + +const resetDeviceAlarmQuery = () => { + if (!attributeDeviceId.value) return + deviceAlarmQueryFormRef.value?.resetFields?.() + deviceAlarmQueryParams.pageNo = 1 + getDeviceAlarmList() +} + +const handleShowDeviceAlarmHistory = async () => { + if (!attributeDeviceId.value) { + message.error(t('DataCollection.Device.messageSelectDeviceRequired')) + return + } + deviceAlarmQueryParams.pageNo = 1 + deviceAlarmQueryParams.pageSize = 10 + deviceAlarmQueryParams.modelId = undefined + deviceAlarmQueryParams.rule = undefined + deviceAlarmQueryParams.alarmLevel = undefined + deviceAlarmQueryParams.addressValue = undefined + deviceAlarmQueryParams.createTime = [] + deviceAlarmQueryParams.ruleId = undefined + deviceAlarmDialogVisible.value = true + await Promise.all([loadDeviceAlarmRuleOptions(), loadDeviceAlarmPointOptions()]) + await getDeviceAlarmList() +} +