import React, { useState, useEffect, useRef, Component } from "react"; import { connect } from "dva"; import { initFilter, extendOrder, guid } from "../../../utils/common"; import { Row, Col, Modal, Table, Button, Select, DatePicker, message } from "antd"; import echarts from "echarts"; import moment from "moment"; import IconFont from "../../../utils/iconFont"; import FormPage from '../../../components/FormPage' class BI056Performance extends React.Component { constructor(props) { super(props); this.state = { ColorShow: ["#c02e30", "#f7aa52", "#fbe06a", "#5185f3", "#EF9494", "#51b5f3"], dtStart: null,//开始时间 dtEnd: null,//结束时间 mineType: 0,//生产单元 detailForm: { formCode: "", title: "", isShow: false, }, ret: { IsSuccessful: true, Data: { checkMineType1_1: { mineTypeName: ["露天矿", "选矿厂", "尾矿库", "职能部门"], checkCount: [[3, 3, 3, 3], [12, 12, 12, 6], [24, 24, 24, 12], [90, 90, 120, 36]], legendName: ["公司级", "部门级", "车间级", "班组级"], }, riskMineType1_2: { legendName: ["露天矿", "选矿厂", "尾矿库", "职能部门"], riskCount: [16, 23, 8, 1], }, riskDealMonth2_1: { legendName: ['已整改', '未整改', '整改率'], xAxisName: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], countDeal: [5, 10, 8, 5, 12, 15, 10, 9, 8, 10, 11, 6], countNotDeal: [0, 1, 1, 2, 3, 2, 0, 1, 3, 3, 3, 2], linePercent: [100.00, 90.00, 87.5, 60.00, 75.00, 86.67, 100.00, 88.89, 62.50, 70.00, 72.73, 66.67] }, riskTop2_2: { yAxisName: ["隐患名称", "电机车轨道枕木下沉", "电机车刹车闸瓦磨损", "电机车导线线夹断裂", "电机车轨道断裂", "电机车刹车泵漏气"], count: [31, 22, 19, 15, 8, 5], }, checkTypeMineType3_1: { legendName: ["露天矿", "选矿厂", "尾矿库", "职能部门"], xAxisName: ["巡回检查", "例行检查", "专业检查", "综合检查", "日常巡检", "防洪安全检查", "坝体安全检查", "库区安全检查", "重大事故隐患专项排查"], arrayCount: [[1200, 1200, 300, 500, 0, 0, 0, 0, 100], [500, 1500, 300, 500, 0, 0, 0, 0, 0], [0, 0, 100, 10, 800, 800, 800, 500, 100], [30, 30, 60, 50, 20, 10, 0, 0, 0]], }, checkTypeRiskMineType3_2: { legendName: ["露天矿", "选矿厂", "尾矿库", "职能部门"], xAxisName: ["巡回检查", "例行检查", "专业检查", "综合检查", "日常巡检", "防洪安全检查", "坝体安全检查", "库区安全检查", "重大事故隐患专项排查"], arrayCount: [[10, 10, 3, 5, 0, 0, 0, 0, 1], [15, 15, 3, 5, 0, 0, 0, 0, 0], [0, 0, 1, 10, 20, 10, 9, 5, 1], [1, 2, 3, 2, 0, 0, 0, 0, 0]] } } } } } componentDidMount() { this.getBaseInfoData(); } //获取数据 getBaseInfoDataOnline = (mineType) => { const json2 = initFilter(this.props.login.OrgId); extendOrder(json2, "CREATE_TIME", 1); json2.Parameter1 = mineType; this.props.dispatch({ type: "app/getDataByPost", url: "BI/BIController/getRiskPerformanceData", payload: json2, onlyData: false, onComplete: (ret) => { this.CheckCount1_1(ret?.Data.checkMineType1_1); this.RiskCount1_2(ret?.Data.riskMineType1_2, this.state.ColorShow); this.RiskCount1_22(ret?.Data.riskMineType1_2, this.state.ColorShow); this.RiskTop2_2(ret?.Data.riskTop2_2, this.state.ColorShow); this.CheckTypeCount3(ret?.Data.checkTypeMineType3_1, "divCheckTypeCount3_1"); this.CheckTypeCount3(ret?.Data.checkTypeRiskMineType3_2, "divCheckTypeRiskCount3_2"); }, }); }; getBaseInfoData = (mineType) => { this.CheckCount1_1(this.state.ret.Data.checkMineType1_1); this.RiskCount1_2(this.state.ret.Data.riskMineType1_2, this.state.ColorShow); this.RiskCount1_22(this.state.ret.Data.riskMineType1_2, this.state.ColorShow); //动态处理数据 var countDeal = [] var countNotDeal = [] var linePercent = [] var month = (new Date()).getMonth() + 1//取当前月 for (var i = 0; i < month; i++) { countDeal.push(this.state.ret.Data.riskDealMonth2_1.countDeal[i]) countNotDeal.push(this.state.ret.Data.riskDealMonth2_1.countNotDeal[i]) linePercent.push(this.state.ret.Data.riskDealMonth2_1.linePercent[i]) } this.state.ret.Data.riskDealMonth2_1.countDeal = countDeal this.state.ret.Data.riskDealMonth2_1.countNotDeal = countNotDeal this.state.ret.Data.riskDealMonth2_1.linePercent = linePercent this.RiskDeal2_1(this.state.ret.Data.riskDealMonth2_1); //动态处理数据 this.RiskTop2_2(this.state.ret.Data.riskTop2_2, this.state.ColorShow); this.CheckTypeCount3(this.state.ret.Data.checkTypeMineType3_1, "divCheckTypeCount3_1"); this.CheckTypeCount3(this.state.ret.Data.checkTypeRiskMineType3_2, "divCheckTypeRiskCount3_2"); }; CheckCount1_1 = (Data) => { let divCheckCount1_1 = document.getElementById("divCheckCount1_1"); if (divCheckCount1_1) { let myChart = echarts.init(divCheckCount1_1); myChart.setOption( { // title: { // text: "生产单元", // left: "center", // }, tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, }, legend: { left: "center", align: "left", bottom: "2%", textStyle: { color: "#000", }, itemWidth: 10, itemHeight: 10, data: Data.legendName, }, grid: { left: "3%", right: "3%", bottom: "12%", top: "10%", containLabel: true, }, xAxis: [ { type: "category", data: Data.mineTypeName, }, ], yAxis: [ { type: "value", }, ], series: [ { name: "公司级", type: "bar", data: Data.checkCount[0], itemStyle: { color: this.state.ColorShow[0] }, barWidth: 30,//横轴的柱状图宽度 label: { normal: { show: true, position: 'top', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 color: '#333', // 字体颜色 }, }, }, barWidth: 30 }, { name: "部门级", type: "bar", data: Data.checkCount[1], itemStyle: { color: this.state.ColorShow[1] }, label: { normal: { show: true, position: 'top', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 color: '#333', // 字体颜色 }, }, }, }, { name: "车间级", type: "bar", data: Data.checkCount[2], itemStyle: { color: this.state.ColorShow[2] }, label: { normal: { show: true, position: 'top', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 color: '#333', // 字体颜色 }, }, }, }, { name: "班组级", type: "bar", data: Data.checkCount[3], itemStyle: { color: this.state.ColorShow[3] }, label: { normal: { show: true, position: 'top', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 color: '#333', // 字体颜色 }, }, }, }, ], }, true ); } }; RiskCount1_2 = (Data, ColorShow) => { let divRiskCount1_2 = document.getElementById("divRiskCount1_2"); if (divRiskCount1_2) { let myChart = echarts.init(divRiskCount1_2); myChart.setOption( { tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, }, grid: { containLabel: true, }, xAxis: [ { type: "category", data: Data.legendName, }, ], yAxis: [ { type: "value", }, ], series: [ { type: "bar", data: Data.riskCount, itemStyle: { color: function (params) { return ColorShow[params.dataIndex] } }, barWidth: 30, label: { normal: { show: true, position: 'top', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 color: '#333', // 字体颜色 }, }, }, }, ], }, true ); } }; RiskCount1_22 = (Data, ColorShow) => { var dataShow = [] for (var i = 0; i < Data.legendName.length; i++) { dataShow.push({ name: Data.legendName[i], value: Data.riskCount[i] }) } let divRiskCount1_22 = document.getElementById("divRiskCount1_22"); if (divRiskCount1_22) { let myChart = echarts.init(divRiskCount1_22); myChart.setOption( { tooltip: { trigger: "item", formatter: "{b} : ({d}%)", }, legend: { left: "0%", bottom: "10%", data: Data.legend, }, series: [ { type: "pie", radius: '55%', center: ["50%", "45%"], data: dataShow, itemStyle: { color: function (params) { return ColorShow[params.dataIndex] } }, emphasis: { itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' } }, label: { show: true, // 开启标签显示 formatter: '{d}%', // 格式化标签文本,仅显示数值 }, }, ], }, true ); } }; RiskDeal2_1 = (Data) => { let divRiskDeal2_1 = document.getElementById("divRiskDeal2_1"); if (divRiskDeal2_1) { let myChart = echarts.init(divRiskDeal2_1); myChart.setOption( { // title: { // text: "区域(生产单元+等级)", // left: "center", // }, tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, formatter: function (value) { var tooltipShow = '' if (value.length > 0) { tooltipShow += value[0].axisValueLabel + '
' for (var i = 0; i < value.length; i++) { if (value[i].componentSubType == "bar") { tooltipShow += value[i].marker + value[i].seriesName + ":" + value[i].value + "
" } else { tooltipShow += value[i].marker + value[i].seriesName + ":" + value[i].value + "%" } } } return tooltipShow } }, legend: { left: "center", align: "left", bottom: "2%", textStyle: { color: "#000", }, itemWidth: 10, itemHeight: 10, data: Data.legendName, }, grid: { left: "3%", right: "3%", bottom: "12%", top: "10%", containLabel: true, }, xAxis: { type: "category", data: Data.xAxisName, axisLabel: { interval: 0, rotate: 20, formatter: function (value) { return value } } }, yAxis: [ // type: "value", { name: '整改情况', type: 'value', // min: 0, // max: 100000, // axisLabel: { // 坐标轴标签样式设置 // textStyle: { fontSize: 20 }, // formatter: '{value} 件', // 给坐标轴标签加单位 // }, // nameTextStyle: { fontSize: 20 }, }, { name: "完成率(%)", type: "value", min: 0, max: 70, position: "middle",// "right", formatter: "{value}%", min: 0, max: 100, axisLabel: { // textStyle: { fontSize: 20 }, formatter: '{value} %', // 给坐标轴标签加单位 }, splitLine: { //网格线 show: false } } ], series: [ { name: "已整改", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.countDeal, itemStyle: { color: this.state.ColorShow[0] }, barWidth: 30 }, { name: "未整改", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.countNotDeal, itemStyle: { color: this.state.ColorShow[1] }, }, { name: "整改率", type: "line", label: { show: true, position: "top", formatter: "{c}%" }, lineStyle: { color: "#ffb122" }, data: Data.linePercent, itemStyle: { color: this.state.ColorShow[2] }, yAxisIndex: 1 }, ], }, true ); } }; RiskTop2_2 = (Data, ColorShow) => { let divRiskTop2_2 = document.getElementById("divRiskTop2_2"); if (divRiskTop2_2) { var count = Data.count let myChart = echarts.init(divRiskTop2_2); myChart.setOption( { tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, }, grid: { left: "3%", right: "3%", bottom: "12%", top: "10%", containLabel: true, }, xAxis: [ { type: "value", }, ], yAxis: [ { type: "category", data: Data.yAxisName, }, ], series: [ { type: "bar", data: count, itemStyle: { color: function (params) { return ColorShow[params.dataIndex] } }, barWidth: 30,//横轴的柱状图宽度 label: { normal: { show: true, // position: 'insideRight', // 或者 'inside'(内部)、'insideLeft'、'insideRight' 等其他位置 formatter: '{c}', // 使用变量 {c} 表示数值,也可以自定义格式化函数 textStyle: { fontSize: 12, // 字体大小 // color: '#333', // 字体颜色 }, }, }, }, ], }, true ); } }; // 检查类型 次数/隐患 统计 CheckTypeCount3 = (Data, divid) => { let divShow = document.getElementById(divid); if (divShow) { let myChart = echarts.init(divShow); var series = [] for (let i = 0; i < Data.legendName.length; i++) { series.push({ name: Data.legendName[i], type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.arrayCount[i],//.slice(0, 10), itemStyle: { color: this.state.ColorShow[i] }, barWidth: 30 }) } myChart.setOption( { // title: { // text: "风险类别(等级)", // left: "center", // }, tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, }, legend: { left: "center", align: "left", bottom: "2%", textStyle: { color: "#000", }, itemWidth: 10, itemHeight: 10, data: Data.legendName, }, grid: { left: "3%", right: "5%", bottom: "12%", top: "10%", containLabel: true, }, xAxis: { type: "category", data: Data.xAxisName,//.slice(0, 10), axisLabel: { interval: 0, rotate: 20, formatter: function (value) { return value } } }, yAxis: { type: "value", }, series: series }, true ); } }; CheckTypeRiskCount3_2 = (Data) => { let divCheckTypeRiskCount3_2 = document.getElementById("divCheckTypeRiskCount3_2"); if (divCheckTypeRiskCount3_2) { let myChart = echarts.init(divCheckTypeRiskCount3_2); myChart.setOption( { tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, }, legend: { left: "center", align: "left", bottom: "2%", textStyle: { color: "#000", }, itemWidth: 10, itemHeight: 10, data: Data.legendName, }, grid: { left: "3%", right: "5%", bottom: "12%", top: "10%", containLabel: true, }, xAxis: { type: "category", data: Data.xAxisName,//.NAME.slice(0, 10), axisLabel: { interval: 0, rotate: 20, formatter: function (value) { return value } } }, yAxis: { type: "value", }, series: [ { name: "露天矿", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.arrayCount[0],//.Count1.slice(0, 10), itemStyle: { color: this.state.ColorShow[0] }, barWidth: 30 }, { name: "选矿厂", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.arrayCount[1],//Count2.slice(0, 10), itemStyle: { color: this.state.ColorShow[1] }, }, { name: "尾矿库", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.arrayCount[2],//Count3.slice(0, 10), itemStyle: { color: this.state.ColorShow[2] }, }, { name: "职能部门", type: "bar", stack: "总量", label: { show: true, position: "insideRight", }, data: Data.arrayCount[3],//Count4.slice(0, 10), itemStyle: { color: this.state.ColorShow[3] }, }, ], }, true ); } }; //显示详情弹窗 参考 BS064ShowPrint showDetailModal = (formCode) => { var titleTemp = "年度安全检查明细" const newtmpData = { data: { id: guid(), mineType: this.state.mineType, dtStart: this.state.dtStart, dtEnd: this.state.dtEnd, homeReload: true, }, formCode: formCode, }; this.setState({ tmpData: newtmpData }, () => { var detailForm = { title: titleTemp, isShow: true }; this.setState({ detailForm: detailForm, }); }); }; // //显示详情弹窗 // showDetailModal = (SUBMIT_CONTENT_ID) => { // const newtmpData = { // data: { // id: SUBMIT_CONTENT_ID,//必须动态参数 这个会影响页面去后台操作数据 '00000000-0000-0000-0000-000000000000' 或者 ''都不行 // SUBMIT_CONTENT_ID: SUBMIT_CONTENT_ID, // }, // formCode: "BS044_SHOWPRINT", // }; // this.setState({ tmpData: newtmpData }, () => { // var detailForm = { // isShow: true, // title: "隐患整改单", // }; // this.setState({ // detailForm: detailForm, // }); // }); // }; //详情弹窗关闭(隐藏) detailFormClose = () => { var detailForm = { formCode: "", title: "", isShow: false }; this.setState({ detailForm: detailForm, }); }; render() { return (
{/*
*/}
{/* 第一行 */}
年度安全检查统计
this.showDetailModal("BI056_DILG1_1")}>
年度隐患数量统计
this.showDetailModal("年度隐患数量统计")}>
{/* 第二行 */}
隐患整改情况
this.showDetailModal("隐患整改情况")}>
隐患top6
this.showDetailModal("隐患top6")}>
{/* 第三行 */}
检查类型次数统计
this.showDetailModal("检查类型次数统计")}>
检查类型隐患统计
this.showDetailModal("检查类型隐患统计")}>

); } } export default connect(({ login, app }) => ({ login, app }))(BI056Performance);