import React, { Component } from 'react';
import { connect } from 'dva';
import { Row, Col, Icon, Card, Tabs, Table, Radio, DatePicker, Tooltip } from 'antd';
import numeral from 'numeral';
import { ChartCard, Trend, yuan, MiniArea, MiniBar, MiniProgress, Field, Bar, Pie, NumberInfo, IconUp, IconDown, TimelineChart } from '../../components/Charts';
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(state => ({
chart: state.chart,
}))
export default class Analysis extends Component {
state = {
salesType: 'all',
currentTabKey: '',
rangePickerValue: [],
}
componentDidMount() {
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) => {
this.setState({
rangePickerValue,
});
this.props.dispatch({
type: 'chart/fetchSalesData',
});
}
selectDate = (type) => {
this.setState({
rangePickerValue: getTimeDistance(type),
});
this.props.dispatch({
type: 'chart/fetchSalesData',
});
}
render() {
const { rangePickerValue, salesType, currentTabKey } = this.state;
const { chart } = this.props;
const {
visitData,
salesData,
searchData,
offlineData,
offlineChartData,
salesTypeData,
salesTypeDataOnline,
salesTypeDataOffline,
} = chart;
const salesPieData = salesType === 'all' ?
salesTypeData
:
(salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline);
const iconGroup = (