import React, { Component } from 'react'; import { connect } from 'dva'; import { Row, Col, Icon, Card, Tabs, Table, Radio, DatePicker, Tooltip, Menu, Dropdown } from 'antd'; import numeral from 'numeral'; import { ChartCard, yuan, MiniArea, MiniBar, MiniProgress, Field, Bar, Pie, TimelineChart, } from '../../components/Charts'; import Trend from '../../components/Trend'; import NumberInfo from '../../components/NumberInfo'; 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 = { loading: true, salesType: 'all', currentTabKey: '', rangePickerValue: [], } componentDidMount() { this.props.dispatch({ type: 'chart/fetch', }).then(() => { this.setState({ loading: false, }); }); } 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', }); } 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, loading } = this.state; const { chart } = 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 = (