diff --git a/src/pages/business_basic/module/RiskAssessment.js b/src/pages/business_basic/module/RiskAssessment.js index f8209a8..4865e36 100644 --- a/src/pages/business_basic/module/RiskAssessment.js +++ b/src/pages/business_basic/module/RiskAssessment.js @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; -import { Card, Result, Select, Button } from 'antd'; +import { Card, Result, Select, Button, Segmented } from 'antd'; import { CheckCircleOutlined } from '@ant-design/icons'; import * as echarts from 'echarts'; import StandardTable from '@/components/StandardTable'; @@ -21,6 +21,7 @@ import eqicon4 from '@/assets/business_basic/eqicon4.png'; const RiskAssessment = () => { const chartRef = useRef(null); + const pieChartRef = useRef(null); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRows, setSelectedRows] = useState([]); const [loading, setLoading] = useState(false); @@ -31,6 +32,74 @@ const RiskAssessment = () => { total: 0, }); + // 饼图初始化 + useEffect(() => { + if (pieChartRef.current) { + const pieChart = echarts.init(pieChartRef.current); + + const pieOption = { + color: ['#44BB5F', '#F8C541', '#A493FB', '#4B69F1', '#949FD0'], + legend: { + orient: 'vertical', + right: '10%', + top: 'center', + itemWidth: 8, + itemHeight: 8, + textStyle: { + fontSize: 12, + color: '#333' + } + }, + series: [{ + name: '设备状态', + type: 'pie', + radius: ['40%', '70%'], + center: ['35%', '50%'], + avoidLabelOverlap: false, + label: { + show: false, + position: 'center' + }, + emphasis: { + label: { + show: true, + fontSize: '14', + fontWeight: 'bold' + } + }, + labelLine: { + show: false + }, + data: [ + { value: 480, name: '正常' }, + { value: 289, name: '故障' }, + { value: 200, name: '维修中' }, + { value: 150, name: '待验收' }, + { value: 161, name: '停用' } + ] + }] + }; + + pieChart.setOption(pieOption); + + // 响应式调整 + const handlePieResize = () => { + if (pieChart && !pieChart.isDisposed()) { + pieChart.resize(); + } + }; + + window.addEventListener('resize', handlePieResize); + + return () => { + window.removeEventListener('resize', handlePieResize); + if (pieChart && !pieChart.isDisposed()) { + pieChart.dispose(); + } + }; + } + }, []); + useEffect(() => { if (chartRef.current) { const chart = echarts.init(chartRef.current); @@ -43,13 +112,13 @@ const RiskAssessment = () => { }, 100); const option = { - color: ['#FF2526', '#FF8800', '#FFC403', '#65E5F9'], + color: ['#8979FF', '#3CC3DF'], legend: { - data: ['重大风险', '较高风险', '一般风险', '低风险'], + data: ['消防水泵1', '消防水泵2'], top: "-3px", left: "center", - itemGap: 40, // 图例间距 + itemGap: 40, textStyle: { fontSize: 10 } @@ -64,7 +133,7 @@ const RiskAssessment = () => { xAxis: { type: 'category', boundaryGap: false, - data: ['9/22', '9/23', '9/24', '9/25', '9/26', '9/27', '9/28'], + data: ['9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00'], axisLabel: { fontSize: 10 } @@ -80,12 +149,12 @@ const RiskAssessment = () => { }, series: [ { - name: '重大风险', + name: '消防水泵1', type: 'line', smooth: true, lineStyle: { - width: 1.5, - color: '#FF2526' + width: 2, + color: '#8979FF' }, areaStyle: { color: { @@ -95,45 +164,27 @@ const RiskAssessment = () => { x2: 0, y2: 1, colorStops: [ - { offset: 0, color: 'rgba(38, 12, 12, 0.4)' }, - { offset: 1, color: 'rgba(255, 37, 38, 0)' } + { offset: 0, color: 'rgba(137, 121, 255, 0.3)' }, + { offset: 1, color: 'rgba(137, 121, 255, 0.05)' } ] } }, - symbol: 'none', - data: [8, 15, 12, 22, 18, 26, 20] - }, - { - name: '较高风险', - type: 'line', - smooth: true, - lineStyle: { - width: 1.5, - color: '#FF8800' - }, - areaStyle: { - color: { - type: 'linear', - x: 0, - y: 0, - x2: 0, - y2: 1, - colorStops: [ - { offset: 0, color: 'rgba(255, 136, 0, 0.4)' }, - { offset: 1, color: 'rgba(255, 136, 0, 0)' } - ] - } + symbol: 'circle', + symbolSize: 4, + itemStyle: { + color: '#fff', + borderColor: '#8979FF', + borderWidth: 1 }, - symbol: 'none', - data: [5, 8, 6, 12, 10, 15, 13] + data: [12, 15, 18, 14, 16, 20, 22, 19, 17, 21, 23, 25, 24] }, { - name: '一般风险', + name: '消防水泵2', type: 'line', smooth: true, lineStyle: { - width: 1.5, - color: '#FFC403' + width: 2, + color: '#3CC3DF' }, areaStyle: { color: { @@ -143,37 +194,19 @@ const RiskAssessment = () => { x2: 0, y2: 1, colorStops: [ - { offset: 0, color: 'rgba(255, 196, 3, 0.4)' }, - { offset: 1, color: 'rgba(255, 196, 3, 0)' } + { offset: 0, color: 'rgba(60, 195, 223, 0.3)' }, + { offset: 1, color: 'rgba(60, 195, 223, 0.05)' } ] } }, - symbol: 'none', - data: [12, 18, 15, 25, 22, 24, 26] - }, - { - name: '低风险', - type: 'line', - smooth: true, - lineStyle: { - width: 1.5, - color: '#65E5F9' - }, - areaStyle: { - color: { - type: 'linear', - x: 0, - y: 0, - x2: 0, - y2: 1, - colorStops: [ - { offset: 0, color: 'rgba(101, 229, 249, 0.4)' }, - { offset: 1, color: 'rgba(101, 229, 249, 0)' } - ] - } + symbol: 'circle', + symbolSize: 4, + itemStyle: { + color: '#fff', + borderColor: '#3CC3DF', + borderWidth: 1 }, - symbol: 'none', - data: [3, 5, 7, 9, 6, 8, 4] + data: [8, 11, 14, 10, 13, 17, 19, 16, 14, 18, 20, 22, 21] } ] }; @@ -553,60 +586,43 @@ const RiskAssessment = () => {