import React, { Component } from 'react'; import { connect } from 'dva'; import { injectIntl } from 'react-intl'; import { Row, Col, Icon, Card, Tabs, Table, Radio, DatePicker, Tooltip, Menu, Dropdown, } from 'antd'; import { ChartCard, MiniArea, MiniBar, MiniProgress, Field, Bar, Pie, TimelineChart, } from 'components/Charts'; import Trend from 'components/Trend'; import NumberInfo from 'components/NumberInfo'; import numeral from 'numeral'; import GridContent from '../layouts/GridContent'; import Yuan from '../../utils/Yuan'; import { getTimeDistance } from '../../utils/utils'; import styles from './Analysis.less'; const { TabPane } = Tabs; const { RangePicker } = DatePicker; const rankingListData = []; for (let i = 0; i < 7; i += 1) { rankingListData.push({ title: `工专路 ${i} 号店`, total: 323234, }); } @connect(({ chart, loading }) => ({ chart, loading: loading.effects['chart/fetch'], })) class Analysis extends Component { constructor(props) { super(props); const { intl } = props; this.rankingListData = []; for (let i = 0; i < 7; i += 1) { this.rankingListData.push({ title: intl.formatMessage({ id: 'app.analysis.test' }, { no: i }), total: 323234, }); } this.state = { salesType: 'all', currentTabKey: '', rangePickerValue: getTimeDistance('year'), }; } state = { salesType: 'all', currentTabKey: '', rangePickerValue: getTimeDistance('year'), }; componentDidMount() { const { dispatch } = this.props; dispatch({ type: 'chart/fetch', }); } componentWillUnmount() { const { dispatch } = this.props; dispatch({ type: 'chart/clear', }); } handleChangeSalesType = e => { this.setState({ salesType: e.target.value, }); }; handleTabChange = key => { this.setState({ currentTabKey: key, }); }; handleRangePickerChange = rangePickerValue => { const { dispatch } = this.props; this.setState({ rangePickerValue, }); dispatch({ type: 'chart/fetchSalesData', }); }; selectDate = type => { const { dispatch } = this.props; this.setState({ rangePickerValue: getTimeDistance(type), }); dispatch({ type: 'chart/fetchSalesData', }); }; isActive(type) { const { rangePickerValue } = this.state; const value = getTimeDistance(type); if (!rangePickerValue[0] || !rangePickerValue[1]) { return; } if ( rangePickerValue[0].isSame(value[0], 'day') && rangePickerValue[1].isSame(value[1], 'day') ) { return styles.currentDate; } } render() { const { rangePickerValue, salesType, currentTabKey } = this.state; const { chart, loading } = this.props; const { visitData, visitData2, salesData, searchData, offlineData, offlineChartData, salesTypeData, salesTypeDataOnline, salesTypeDataOffline, } = chart; const salesPieData = salesType === 'all' ? salesTypeData : salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; const menu = (
); const iconGroup = (