// 核心库
import React from 'react'
import { connect } from 'dva'
// 组件库
import { Icon } from 'antd'
import { Scrollbars } from 'react-custom-scrollbars'
import { LocalSearch, FullDatePicker, LayoutCard } from '@woowalker/feui'
import TableChart from '../../Chart/TableChart'
import CommonChart from '../../Chart/CommonChart'
// 工具库
import { initFilter, addRuleAndGroups } from '../../../utils/common'
import moment from 'moment'
// 样式
import styles from './index.css'
class EMEnergyClassPage extends React.Component {
constructor (props) {
super(props)
this.state = {
dateType: '1',
dateString: moment().format('YYYY-MM'),
statisticalDatas: [],
chartData: {},
pieDatas: [],
pieFeeDatas: []
}
}
handleSearch = (value) => {
const { formParam, data } = this.props
const { dateType, dateString } = this.state
value.rules.push({
field: 'Parameter1',
operator: 0,
value: formParam.Parameter1,
isCustom: true,
isSysParam: false,
})
value.rules.push({
field: 'Parameter2',
operator: 0,
value: dateType,
isCustom: true,
isSysParam: false,
})
value.rules.push({
field: 'Parameter3',
operator: 0,
value: dateString,
isCustom: true,
isSysParam: false,
})
value.rules.push({
field: 'Parameter4',
operator: 0,
value: data.selectedNodes ? data.selectedNodes.map(item => item.node.id).join(',') : null,
isCustom: true,
isSysParam: false,
})
// 获取数据
const { login, dispatch } = this.props
const json = initFilter(login.OrgId)
addRuleAndGroups(json, value)
dispatch({
type: 'app/getDataByPost',
url: 'EM/Monitoring/GetEnergyClassData',
payload: json
}).then(res => {
if (res) {
const { statisticalDatas, chartDataModel, pieDatas, pieFeeDatas } = res
this.setState({
statisticalDatas,
chartData: {
xAxis: chartDataModel?.XAxis[0].Data,
yAxis: chartDataModel?.YAxis,
data: chartDataModel?.Data
},
pieDatas: pieDatas.map(({ name, value, color }) => ({ name, value, itemStyle: { color } })),
pieFeeDatas: pieFeeDatas.map(({ name, value, color }) => ({ name, value, itemStyle: { color } }))
})
}
})
}
getOption = () => {
return {
tooltip: {
trigger: 'item',
formatter: "{a}
{b} : {c} ({d}%)"
},
legend: {
top: 30,
textStyle: {
color: '#8C8C8C'
}
},
series: [
{
name: '矿山安全分类分项',
type: 'pie',
radius: [0, 60],
minShowLabelAngle: 30,
top: 100,
label: {
formatter: [
'{title|{b}({d}%)}',
'{detail|用量:{c}}'
].join('\n'),
rich: {
title: { fontSize: 12 },
detail: { fontSize: 12 }
}
},
data: this.state.pieDatas
}
]
}
}
getFeeOption = () => {
return {
tooltip: {
trigger: 'item',
formatter: "{a}
{b} : {c} ({d}%)"
},
legend: {
top: 30,
textStyle: {
color: '#8C8C8C'
}
},
series: [
{
name: '矿山安全分类分项费用',
type: 'pie',
radius: [0, 60],
minShowLabelAngle: 30,
top: 100,
label: {
formatter: [
'{title|{b}({d}%)}',
'{detail|费用:{c}}'
].join('\n'),
rich: {
title: { fontSize: 12 },
detail: { fontSize: 12 }
}
},
data: this.state.pieFeeDatas
}
]
}
}
render () {
const { statisticalDatas, chartData } = this.state
return (