| | |
| | | // 现有设备统计 |
| | | getEquipment () { |
| | | const typeData = { |
| | | carCount: '警车', |
| | | carCount: '车辆', |
| | | monitorCount: '摄像头', |
| | | recorderCount: '手台', |
| | | phoneCount: '手持记录仪' |
| | |
| | | |
| | | return data |
| | | } else { |
| | | let normalData = { value: 0, name: '正常', color: '#4caf50', online: true, label: { color: oneColor[0] } } |
| | | let faultData = { value: 0, name: '故障', color: '#ffd600', online: false, label: { color: oneColor[2] } } |
| | | let normalData = { value: 0, name: '在线', color: '#4caf50', online: true, label: { color: oneColor[0] } } |
| | | let faultData = { value: 0, name: '离线', color: '#ffd600', online: false, label: { color: oneColor[2] } } |
| | | |
| | | res.data.forEach(item => { |
| | | this.regionTotal += item.count |
| | |
| | | |
| | | for (let key in typeData) { |
| | | if (item.type == typeData[key]) { |
| | | normalData[key] = item.online |
| | | faultData[key] = item.offline |
| | | normalData[key] = Number(item.online) |
| | | faultData[key] = Number(item.offline) |
| | | } |
| | | } |
| | | |
| | | faultData.value += item.offline |
| | | faultData.value = Number(faultData.value) + Number(item.offline) |
| | | }) |
| | | |
| | | data = [normalData, faultData] |
| | |
| | | |
| | | const data = await this.getEquipment() |
| | | |
| | | equipmentmyChart.setOption(this.initEquipmentOptions(data), true) |
| | | const newData = data.filter(item => { |
| | | if (item.value != 0) { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | equipmentmyChart.setOption(this.initEquipmentOptions(newData)) |
| | | |
| | | if (newData.length > 1) { |
| | | this.equipmentEchartsCarousel() |
| | | } else { |
| | | clearInterval(timer) |
| | | equipmentmyChart.off('mouseover') |
| | | equipmentmyChart.off('mouseout') |
| | | } |
| | | }, |
| | | |
| | | // 现有设备饼图初始化 |
| | |
| | | } |
| | | }) |
| | | |
| | | equipmentmyChart.setOption(this.initEquipmentOptions(data)) |
| | | equipmentmyChart.setOption(this.initEquipmentOptions(newData)) |
| | | |
| | | if (newData.length > 1) { |
| | | this.equipmentEchartsCarousel() |
| | |
| | | equipmentmyChart.off('mouseover') |
| | | equipmentmyChart.off('mouseout') |
| | | } |
| | | |
| | | }, |
| | | |
| | | // 现有设备options饼图数据 |
| | |
| | | formatter: function (params) { |
| | | let tipHtml = `` |
| | | |
| | | if ('carCount' in params.data) { |
| | | if ('carCount' in params.data || 'monitorCount' in params.data) { |
| | | tipHtml = ` |
| | | ${params.marker} |
| | | <strong style="color: ${params.color}">${params.data.name} ${params.data.value}台</strong> |
| | |
| | | <span style="margin-left:10px;color:#91cc75">摄像头:${params.data.monitorCount}台</span> |
| | | ` |
| | | } else { |
| | | tipHtml = `${params.marker} <strong style="color: ${params.color}">${params.data.name} ${params.data.value}台</strong><br /><span style="color:#4caf50">正常:${params.data.working}台</span><br /><span style="color:#ccc">故障:${params.data.fault}台</span><br /><span style="margin-left:10px;color:#ccc">设备故障率:${Math.floor(params.data.fault / (params.data.working + params.data.fault) * 100)}%</span><br />` |
| | | tipHtml = `${params.marker} |
| | | <strong style="color: ${params.color}">${params.data.name} ${params.data.value}台</strong> |
| | | <br /> |
| | | <span style="color:#4caf50">在线:${params.data.working}台</span> |
| | | <br /> |
| | | <span style="color:#ccc">离线:${params.data.fault}台</span> |
| | | <br /> |
| | | <span style="margin-left:10px;color:#ccc">设备离线率:${Math.floor(params.data.fault / (params.data.working + params.data.fault) * 100)}%</span><br />` |
| | | } |
| | | return tipHtml |
| | | }, |
| | |
| | | } |
| | | return colorList[params.dataIndex] |
| | | }, |
| | | fontSize: fontSize(16), |
| | | normal: { |
| | | formatter (e) { |
| | | if (e.data.value == 0) { |
| | | e.data.emphasis.label.show = false |
| | | } else { |
| | | return `${e.data.name}` |
| | | } |
| | | } |
| | | } |
| | | fontSize: fontSize(16) |
| | | }, |
| | | itemStyle: { |
| | | normal: { |