import { inject, observer, } from 'mobx-react'; import { toJS } from 'mobx'; import { WeaReportCard, WeaEchart, WeaLocaleProvider, } from 'ecCom'; import { downloadCvs2Img } from './util' const getLabel = WeaLocaleProvider.getLabel; @inject('hrmApplicant') @observer export default class BarCharts extends React.Component { constructor(props) { super(props); this.count = -1; } componentDidMount() { // this.props.hrmApplicant.getBarChartsDatas(); } componentDidUpdate() { [0, 1].map(val => { this[`echart${val}`] && this[`echart${val}`].paint(); }) } componentWillUnmount() { this.props.hrmApplicant.resetBarCharts(); } setRef = (ref, alias) => { const { hrmApplicant } = this.props, { setRef } = hrmApplicant; this[alias] = ref; setRef({ ref, alias, type: 'barCharts', }); } chartAction = (chart, index) => { chart.off('click'); chart.on('click', params => this.handleChartAction(params, index)); } handleChartAction = (params, index) => { const { hrmApplicant } = this.props, { barCharts, openDialog } = hrmApplicant, { ids } = barCharts; const { name, dataIndex } = params; openDialog('bar', (index == '0') ? { value: ids[dataIndex], valueSpan: name, valueObj: [{ id: ids[dataIndex], name: name }] } : { createMonth: name }) } downloadImg = (index, title) => { const cvs = document.getElementsByTagName('canvas'); downloadCvs2Img({ cvs: cvs[index], title: title }); } render() { const { hrmApplicant } = this.props, { barCharts, openDialog, } = hrmApplicant, { charts } = barCharts; this.count = -1; return toJS(charts).map((chart, index) => { const { title, option } = chart; const bl1 = option.series[0].data.length > 0; bl1 && this.count++; const ct = this.count; return (