From 89123fae54970f93f50f4c0d98545a1c1dbac872 Mon Sep 17 00:00:00 2001
From: xuhuajiao <13476289682@163.com>
Date: Wed, 17 Dec 2025 15:36:31 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E8=AE=BE=E5=A4=87=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/storeManage/deviceManage/device.js | 10 ++-
src/views/environmentalScreen/index.vue | 66 ++++++++++++-------
.../environmentalScreen/module/catePie.vue | 47 +++++++++++--
.../deviceManage/module/deviceDetail.vue | 37 ++++++++---
.../archiveStatistics/mixins/statistics.js | 2 +-
5 files changed, 122 insertions(+), 40 deletions(-)
diff --git a/src/api/storeManage/deviceManage/device.js b/src/api/storeManage/deviceManage/device.js
index 496aedc..4a184bd 100644
--- a/src/api/storeManage/deviceManage/device.js
+++ b/src/api/storeManage/deviceManage/device.js
@@ -163,4 +163,12 @@ export function FetchPingIP(params) {
})
}
-export default { add, edit, del, getSupplier, getDeviceType, getDeviceById, getDesecabinetById, getRotarycabinetById, getDeviceList, FetchIsOnline, FetchInBorrowByQuCol, unbind, FetchCallExternalOpenCol, FetchCallExternalResetCol, FetchCallExternalVent, FetchCallExternalStopMove, FetchPingIP }
+// 接口判断手持机状态
+export function FetchRFIDReadStatus(params) {
+ return request({
+ url: 'api/device/getRFIDReadStatus' + '?' + qs.stringify(params, { indices: false }),
+ method: 'get'
+ })
+}
+
+export default { add, edit, del, getSupplier, getDeviceType, getDeviceById, getDesecabinetById, getRotarycabinetById, getDeviceList, FetchIsOnline, FetchInBorrowByQuCol, unbind, FetchCallExternalOpenCol, FetchCallExternalResetCol, FetchCallExternalVent, FetchCallExternalStopMove, FetchPingIP, FetchRFIDReadStatus }
diff --git a/src/views/environmentalScreen/index.vue b/src/views/environmentalScreen/index.vue
index f8c104c..e6edc87 100644
--- a/src/views/environmentalScreen/index.vue
+++ b/src/views/environmentalScreen/index.vue
@@ -121,10 +121,9 @@
-
-
-
-
+
+
+
-
@@ -332,7 +331,7 @@
当日告警统计
-
+
@@ -498,9 +497,9 @@ export default {
}, 1000)
this.getDevice()
this.getTodayHikAlarmLog()
- this.alarmRefreshTimer = setInterval(() => {
- this.getTodayHikAlarmLog()
- }, 300000)
+ // this.alarmRefreshTimer = setInterval(() => {
+ // this.getTodayHikAlarmLog()
+ // }, 100000)
// 初始化逻辑
window.getIframeLoading = this.getIframeLoading
// this.allDisplayConfigData = allDeviceData
@@ -530,7 +529,9 @@ export default {
this.echartsTimer = setInterval(() => {
this.lendData = []
this.typeData = []
+ this.alarmChartData = []
this.getBorrowerNumSta()
+ this.getTodayHikAlarmLog()
}, this.refreshtime)
this.getVideoUrl()
},
@@ -543,14 +544,13 @@ export default {
this.webRtcServer.disconnect()
this.webRtcServer = null
}
- if (this.alarmRefreshTimer) clearInterval(this.alarmRefreshTimer)
+ // if (this.alarmRefreshTimer) clearInterval(this.alarmRefreshTimer)
},
methods: {
- // 重构告警数据获取方法
getTodayHikAlarmLog() {
getTodayHikAlarmLog().then(data => {
console.log('今日海康告警日志', data)
- this.alarmStatisticsRaw = data || []
+ this.alarmStatisticsRaw = this.transformAlarmData(data || {})
this.formatAlarmChartData()
}).catch(error => {
console.error('获取告警统计数据失败:', error)
@@ -558,33 +558,49 @@ export default {
this.alarmChartData = []
})
},
- // 格式化告警数据为饼图数据源
+
+ transformAlarmData(alarmObj) {
+ const fieldMap = [
+ { key: 'accessAlarm', name: '门禁告警' },
+ { key: 'firefightingAlarm', name: '消防告警' },
+ { key: 'equipmentAlarm', name: '设备告警' },
+ { key: 'environmentAlarm', name: '环境告警' }
+ ]
+
+ return fieldMap.map(item => ({
+ alarmValue: item.name,
+ num: alarmObj[item.key] || 0
+ }))
+ },
+
formatAlarmChartData() {
- if (!this.alarmStatisticsRaw.length) {
+ const allZero = this.alarmStatisticsRaw.every(item => item.num === 0)
+ if (allZero) {
this.alarmChartData = [{ name: '无告警', value: 1, itemStyle: { color: '#666666' }}]
return
}
- // 固定颜色列表(按优先级排序)
- const colorList = ['#F65164', '#339CFF', '#FFB800', '#1CADAB', '#9B6BCC', '#FF7D00']
-
const alarmColorMap = {
- '设备断线': '#F65164',
- '红外线报警': '#339CFF',
- '消防报警': '#FFB800',
- '漏水报警': '#1CADAB',
- 'PM2.5超标': '#9B6BCC',
- '甲醛超标': '#FF7D00'
+ '门禁告警': '#F65164',
+ '消防告警': '#FFB800',
+ '设备告警': '#339CFF',
+ '环境告警': '#1CADAB'
}
+ // 备用颜色列表(防止新增告警类型没有配置颜色)
+ const colorList = ['#F65164', '#339CFF', '#FFB800', '#1CADAB', '#9B6BCC', '#FF7D00']
this.alarmChartData = this.alarmStatisticsRaw.map((item, index) => {
const alarmName = item.alarmValue || '未知告警'
+ // 优先使用配置的颜色,没有则使用备用颜色
const color = alarmColorMap[alarmName] || colorList[index % colorList.length] || '#666666'
+
return {
name: alarmName,
- value: item.num || 0,
+ value: item.num || 0, // 保留0值
itemStyle: {
color: color
- }
+ },
+ // 可选:为0值添加特殊样式(比如半透明)
+ ...(item.num === 0 ? { itemStyle: { color: color, opacity: 0.5 }} : {})
}
})
},
@@ -1533,7 +1549,7 @@ export default {
.card-panel-text {
line-height: 30px;
color: rgba(0, 0, 0, 0.45);
- font-size: 24px;
+ font-size: 22px;
margin-bottom: 11px;
& span {
-webkit-background-clip: text;
diff --git a/src/views/environmentalScreen/module/catePie.vue b/src/views/environmentalScreen/module/catePie.vue
index 04607d4..053cddf 100644
--- a/src/views/environmentalScreen/module/catePie.vue
+++ b/src/views/environmentalScreen/module/catePie.vue
@@ -22,6 +22,10 @@ export default {
height: {
type: String,
default: '100%'
+ },
+ refreshtime: {
+ type: Number,
+ default: null // 接收父组件的刷新间隔值
}
},
data() {
@@ -41,7 +45,8 @@ export default {
}
},
mounted() {
- this.initChart()
+ // this.initChart()
+ this.refreshEchart()
},
beforeDestroy() {
if (this.chart) {
@@ -50,6 +55,15 @@ export default {
}
},
methods: {
+ refreshEchart() {
+ if (this.refreshtime) {
+ this.timer = setInterval(() => {
+ this.initChart()
+ }, this.refreshtime)
+ } else {
+ this.initChart()
+ }
+ },
initChart() {
if (this.chart) return
const chartDom = this.$refs.chartRef
@@ -67,11 +81,18 @@ export default {
? this.cateData
: [{ name: '无告警数据', value: 1, itemStyle: { color: '#666666' }}]
+ // 处理0值显示问题:将0替换为极小值,确保标签能显示(视觉上无占比)
+ const processedData = chartData.map(item => ({
+ ...item,
+ value: item.value === 0 ? 0 : item.value
+ }))
+
const option = {
backgroundColor: 'transparent',
tooltip: {
trigger: 'item',
textStyle: { fontSize: 12 },
+ // Tooltip 仍显示 名称+数量+百分比(完整信息)
formatter: '{b}: {c} 次 ({d}%)'
},
legend: {
@@ -102,13 +123,22 @@ export default {
labelLine: {
show: true,
length: 10,
- length2: 20
+ length2: 20,
+ // 0值项的引导线设为半透明
+ lineStyle: (params) => ({
+ color: params.data.value < 0.1 ? 'rgba(255,255,255,0.3)' : '#ffffff'
+ })
},
label: {
show: true,
fontSize: 11,
- formatter: '{d}%',
- color: '#ffffff' // 标签文字白色,适配深色背景
+ color: '#ffffff',
+ // 核心修改:标签显示 实际数量(替换原来的{d}%)
+ formatter: function(params) {
+ // 还原极小值为0显示
+ const value = params.value < 0.1 ? 0 : params.value
+ return `${value} 次`
+ }
},
emphasis: {
label: {
@@ -122,7 +152,7 @@ export default {
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
- data: chartData, // 直接使用带颜色配置的数据
+ data: processedData, // 使用处理后的数据(兼容0值)
animationDuration: 1000,
animationEasing: 'cubicOut'
}
@@ -149,4 +179,11 @@ export default {
border: 1px solid #339cff !important;
border-radius: 4px !important;
}
+
+// 可选:0值项的标签文字设为半透明,视觉区分
+:deep(.ec-label) {
+ &[style*="0 次"] {
+ fill: rgba(255,255,255,0.5) !important;
+ }
+}
diff --git a/src/views/storeManage/deviceManage/module/deviceDetail.vue b/src/views/storeManage/deviceManage/module/deviceDetail.vue
index 223a7f0..5bc9c73 100644
--- a/src/views/storeManage/deviceManage/module/deviceDetail.vue
+++ b/src/views/storeManage/deviceManage/module/deviceDetail.vue
@@ -462,23 +462,44 @@ export default {
},
[CRUD.HOOK.afterRefresh](crud) {
console.log('crud.data', crud.data)
+ const RFID_DEVICE_TYPE_ID = 'E2767FEACA9CE0E3B16B89'
+
crud.data.forEach(element => {
console.log('element', element)
- if (element.deviceIp) {
- this.getDeviceState(element)
+ // 检查设备类型ID是否存在
+ if (element.deviceTypeId?.id === RFID_DEVICE_TYPE_ID) {
+ this.getRFIDReadStatus(element)
} else {
- element.deviceState = 0
+ if (element.deviceIp) {
+ this.getDeviceState(element)
+ } else {
+ element.deviceState = 0
+ }
}
})
},
+
getDeviceState(element) {
- crudDevice.FetchPingIP({ ip: element.deviceIp }).then((data) => {
- element.deviceState = data === true ? 1 : 0
- }).catch((error) => {
- console.error(error)
- })
+ crudDevice.FetchPingIP({ ip: element.deviceIp })
+ .then((data) => {
+ element.deviceState = data === true ? 1 : 0
+ })
+ .catch((error) => {
+ console.error('获取设备IP状态失败:', error)
+ element.deviceState = 0
+ })
},
+ getRFIDReadStatus(element) {
+ crudDevice.FetchRFIDReadStatus({ id: element.deviceTypeId.id })
+ .then((data) => {
+ element.deviceState = data === 0 ? 1 : 0
+ })
+ .catch((error) => {
+ console.error('获取RFID设备状态失败:', error)
+ element.deviceState = 0
+ })
+ },
// 提交前的验证
[CRUD.HOOK.afterValidateCU](crud) {
if (crud.status.edit === 1) {
diff --git a/src/views/system/archiveStatistics/mixins/statistics.js b/src/views/system/archiveStatistics/mixins/statistics.js
index 2c26e02..943718c 100644
--- a/src/views/system/archiveStatistics/mixins/statistics.js
+++ b/src/views/system/archiveStatistics/mixins/statistics.js
@@ -117,7 +117,7 @@ export const statisticsCrud = {
}
}
// 按sequence排序
- this.arrSortByKey(borrowerArr, 'sequence', false)
+ this.arrSortByKey(borrowerArr, 'sequence', true)
// 清空原有数据(避免多次调用累加)
this.lendData = []
borrowerArr.forEach(item => {