import React, { Component } from 'react'; import { connect } from 'dva'; import { formatMessage, FormattedMessage } from 'umi/locale'; 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 '@/components/PageHeaderWrapper/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); this.rankingListData = []; for (let i = 0; i < 7; i += 1) { this.rankingListData.push({ title: formatMessage({ id: 'app.analysis.test' }, { no: i }), total: 323234, }); } this.state = { salesType: 'all', currentTabKey: '', loading: true, rangePickerValue: getTimeDistance('year'), }; } state = { salesType: 'all', currentTabKey: '', rangePickerValue: getTimeDistance('year'), }; componentDidMount() { const { dispatch } = this.props; this.reqRef = requestAnimationFrame(() => { dispatch({ type: 'chart/fetch', }); setTimeout(() => { this.setState({ loading: false, }); }, 1000); }); } componentWillUnmount() { const { dispatch } = this.props; dispatch({ type: 'chart/clear', }); cancelAnimationFrame(this.reqRef); } 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; } return ''; } render() { const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state; const { chart, loading: stateLoading } = this.props; const { visitData, visitData2, salesData, searchData, offlineData, offlineChartData, salesTypeData, salesTypeDataOnline, salesTypeDataOffline, } = chart; const loading = propsLoding || stateLoading; let salesPieData; if (salesType === 'all') { salesPieData = salesTypeData; } else { salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; } const menu = ( 操作一 操作二 ); const iconGroup = ( ); const salesExtra = (
this.selectDate('today')}> this.selectDate('week')}> this.selectDate('month')}> this.selectDate('year')}>
); const columns = [ { title: , dataIndex: 'index', key: 'index', }, { title: ( ), dataIndex: 'keyword', key: 'keyword', render: text => {text}, }, { title: , dataIndex: 'count', key: 'count', sorter: (a, b) => a.count - b.count, className: styles.alignRight, }, { title: ( ), dataIndex: 'range', key: 'range', sorter: (a, b) => a.range - b.range, render: (text, record) => ( {text}% ), align: 'right', }, ]; const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); const CustomTab = ({ data, currentTabKey: currentKey }) => ( } gap={2} total={`${data.cvr * 100}%`} theme={currentKey !== data.name && 'light'} /> ); const topColResponsiveProps = { xs: 24, sm: 12, md: 12, lg: 12, xl: 6, style: { marginBottom: 24 }, }; return ( } action={ } > } loading={loading} total={() => 126560} footer={ } value={`¥${numeral(12423).format('0,0')}`} /> } contentHeight={46} > 12% 11% } action={ } > } total={numeral(8846).format('0,0')} footer={ } value={numeral(1234).format('0,0')} /> } contentHeight={46} > } action={ } > } total={numeral(6560).format('0,0')} footer={ } value="60%" /> } contentHeight={46} > } action={ } > } total="78%" footer={
12% 11%
} contentHeight={46} >
} key="sales" >
} data={salesData} />

    {this.rankingListData.map((item, i) => (
  • {i + 1} {item.title} {numeral(item.total).format('0,0')}
  • ))}
} key="views" >
} data={salesData} />

    {this.rankingListData.map((item, i) => (
  • {i + 1} {item.title} {numeral(item.total).format('0,0')}
  • ))}
} extra={iconGroup} style={{ marginTop: 24 }} > } > } gap={8} total={numeral(12321).format('0,0')} status="up" subTotal={17.1} /> } total={2.7} status="down" subTotal={26.2} gap={8} /> record.index} size="small" columns={columns} dataSource={searchData} pagination={{ style: { marginBottom: 0 }, pageSize: 5, }} /> } bodyStyle={{ padding: 24 }} extra={
{iconGroup}
} style={{ marginTop: 24, minHeight: 509 }} >

} total={() => {salesPieData.reduce((pre, now) => now.y + pre, 0)}} data={salesPieData} valueFormat={value => {value}} height={248} lineWidth={4} />
{offlineData.map(shop => ( } key={shop.name}>
))}
); } } export default Analysis;