Analysis.js 21.4 KB
Newer Older
jim's avatar
jim committed
1
import React, { Component } from 'react';
2
import { connect } from 'dva';
陈帅's avatar
陈帅 committed
3
import { formatMessage, FormattedMessage } from 'umi/locale';
niko's avatar
niko committed
4 5 6 7 8 9 10 11 12 13 14 15 16
import {
  Row,
  Col,
  Icon,
  Card,
  Tabs,
  Table,
  Radio,
  DatePicker,
  Tooltip,
  Menu,
  Dropdown,
} from 'antd';
偏右's avatar
偏右 committed
17
import {
niko's avatar
niko committed
18 19 20 21 22 23 24 25
  ChartCard,
  MiniArea,
  MiniBar,
  MiniProgress,
  Field,
  Bar,
  Pie,
  TimelineChart,
26 27 28
} from '@/components/Charts';
import Trend from '@/components/Trend';
import NumberInfo from '@/components/NumberInfo';
jim's avatar
jim committed
29
import numeral from 'numeral';
30
import GridContent from '@/components/PageHeaderWrapper/GridContent';
31 32
import Yuan from '@/utils/Yuan';
import { getTimeDistance } from '@/utils/utils';
33 34 35

import styles from './Analysis.less';

afc163's avatar
afc163 committed
36
const { TabPane } = Tabs;
37 38 39 40 41 42 43 44 45 46
const { RangePicker } = DatePicker;

const rankingListData = [];
for (let i = 0; i < 7; i += 1) {
  rankingListData.push({
    title: `工专路 ${i} 号店`,
    total: 323234,
  });
}

Andreas Cederström's avatar
Andreas Cederström committed
47 48 49
@connect(({ chart, loading }) => ({
  chart,
  loading: loading.effects['chart/fetch'],
50
}))
ddcat1115's avatar
ddcat1115 committed
51 52 53 54 55 56
class Analysis extends Component {
  constructor(props) {
    super(props);
    this.rankingListData = [];
    for (let i = 0; i < 7; i += 1) {
      this.rankingListData.push({
陈帅's avatar
陈帅 committed
57
        title: formatMessage({ id: 'app.analysis.test' }, { no: i }),
ddcat1115's avatar
ddcat1115 committed
58 59 60 61 62 63
        total: 323234,
      });
    }
    this.state = {
      salesType: 'all',
      currentTabKey: '',
64
      loading: true,
ddcat1115's avatar
ddcat1115 committed
65 66 67
      rangePickerValue: getTimeDistance('year'),
    };
  }
陈帅's avatar
陈帅 committed
68

69
  componentDidMount() {
70
    const { dispatch } = this.props;
71 72 73 74
    this.reqRef = requestAnimationFrame(() => {
      dispatch({
        type: 'chart/fetch',
      });
afc163's avatar
afc163 committed
75
      this.timeoutId = setTimeout(() => {
76 77 78
        this.setState({
          loading: false,
        });
afc163's avatar
afc163 committed
79
      }, 600);
80
    });
81 82 83 84 85 86 87
  }

  componentWillUnmount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'chart/clear',
    });
88
    cancelAnimationFrame(this.reqRef);
afc163's avatar
afc163 committed
89
    clearTimeout(this.timeoutId);
90 91
  }

jim's avatar
jim committed
92
  handleChangeSalesType = e => {
93 94 95
    this.setState({
      salesType: e.target.value,
    });
niko's avatar
niko committed
96
  };
97

jim's avatar
jim committed
98
  handleTabChange = key => {
99 100 101
    this.setState({
      currentTabKey: key,
    });
niko's avatar
niko committed
102
  };
103

jim's avatar
jim committed
104
  handleRangePickerChange = rangePickerValue => {
105
    const { dispatch } = this.props;
106 107 108
    this.setState({
      rangePickerValue,
    });
nikogu's avatar
nikogu committed
109

110
    dispatch({
nikogu's avatar
nikogu committed
111 112
      type: 'chart/fetchSalesData',
    });
niko's avatar
niko committed
113
  };
114

jim's avatar
jim committed
115
  selectDate = type => {
116
    const { dispatch } = this.props;
117 118 119 120
    this.setState({
      rangePickerValue: getTimeDistance(type),
    });

121
    dispatch({
122 123
      type: 'chart/fetchSalesData',
    });
niko's avatar
niko committed
124
  };
125

afc163's avatar
afc163 committed
126 127 128 129
  isActive(type) {
    const { rangePickerValue } = this.state;
    const value = getTimeDistance(type);
    if (!rangePickerValue[0] || !rangePickerValue[1]) {
愚道's avatar
愚道 committed
130
      return '';
afc163's avatar
afc163 committed
131
    }
niko's avatar
niko committed
132 133 134 135
    if (
      rangePickerValue[0].isSame(value[0], 'day') &&
      rangePickerValue[1].isSame(value[1], 'day')
    ) {
afc163's avatar
afc163 committed
136 137
      return styles.currentDate;
    }
愚道's avatar
愚道 committed
138
    return '';
afc163's avatar
afc163 committed
139 140
  }

141
  render() {
142 143
    const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state;
    const { chart, loading: stateLoading } = this.props;
144 145
    const {
      visitData,
afc163's avatar
afc163 committed
146
      visitData2,
147 148 149 150 151 152 153
      salesData,
      searchData,
      offlineData,
      offlineChartData,
      salesTypeData,
      salesTypeDataOnline,
      salesTypeDataOffline,
afc163's avatar
afc163 committed
154
    } = chart;
155
    const loading = propsLoding || stateLoading;
156 157 158 159 160 161
    let salesPieData;
    if (salesType === 'all') {
      salesPieData = salesTypeData;
    } else {
      salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline;
    }
afc163's avatar
afc163 committed
162 163 164 165 166 167 168
    const menu = (
      <Menu>
        <Menu.Item>操作一</Menu.Item>
        <Menu.Item>操作二</Menu.Item>
      </Menu>
    );

169 170
    const iconGroup = (
      <span className={styles.iconGroup}>
afc163's avatar
afc163 committed
171 172 173
        <Dropdown overlay={menu} placement="bottomRight">
          <Icon type="ellipsis" />
        </Dropdown>
174 175 176
      </span>
    );

afc163's avatar
afc163 committed
177 178 179
    const salesExtra = (
      <div className={styles.salesExtraWrap}>
        <div className={styles.salesExtra}>
afc163's avatar
afc163 committed
180
          <a className={this.isActive('today')} onClick={() => this.selectDate('today')}>
陈帅's avatar
陈帅 committed
181
            <FormattedMessage id="app.analysis.all-day" defaultMessage="All Day" />
afc163's avatar
afc163 committed
182 183
          </a>
          <a className={this.isActive('week')} onClick={() => this.selectDate('week')}>
陈帅's avatar
陈帅 committed
184
            <FormattedMessage id="app.analysis.all-week" defaultMessage="All Week" />
afc163's avatar
afc163 committed
185 186
          </a>
          <a className={this.isActive('month')} onClick={() => this.selectDate('month')}>
陈帅's avatar
陈帅 committed
187
            <FormattedMessage id="app.analysis.all-month" defaultMessage="All Month" />
afc163's avatar
afc163 committed
188 189
          </a>
          <a className={this.isActive('year')} onClick={() => this.selectDate('year')}>
陈帅's avatar
陈帅 committed
190
            <FormattedMessage id="app.analysis.all-year" defaultMessage="All Year" />
afc163's avatar
afc163 committed
191
          </a>
afc163's avatar
afc163 committed
192 193 194 195 196 197
        </div>
        <RangePicker
          value={rangePickerValue}
          onChange={this.handleRangePickerChange}
          style={{ width: 256 }}
        />
198
      </div>
afc163's avatar
afc163 committed
199
    );
200 201 202

    const columns = [
      {
陈帅's avatar
陈帅 committed
203
        title: <FormattedMessage id="app.analysis.table.rank" defaultMessage="Rank" />,
204 205 206 207
        dataIndex: 'index',
        key: 'index',
      },
      {
陈帅's avatar
陈帅 committed
208 209 210 211 212 213
        title: (
          <FormattedMessage
            id="app.analysis.table.search-keyword"
            defaultMessage="Search keyword"
          />
        ),
214 215 216 217 218
        dataIndex: 'keyword',
        key: 'keyword',
        render: text => <a href="/">{text}</a>,
      },
      {
陈帅's avatar
陈帅 committed
219
        title: <FormattedMessage id="app.analysis.table.users" defaultMessage="Users" />,
220 221 222
        dataIndex: 'count',
        key: 'count',
        sorter: (a, b) => a.count - b.count,
afc163's avatar
afc163 committed
223
        className: styles.alignRight,
224 225
      },
      {
陈帅's avatar
陈帅 committed
226 227 228
        title: (
          <FormattedMessage id="app.analysis.table.weekly-range" defaultMessage="Weekly Range" />
        ),
229 230 231 232
        dataIndex: 'range',
        key: 'range',
        sorter: (a, b) => a.range - b.range,
        render: (text, record) => (
偏右's avatar
偏右 committed
233
          <Trend flag={record.status === 1 ? 'down' : 'up'}>
陈帅's avatar
陈帅 committed
234
            <span style={{ marginRight: 4 }}>{text}%</span>
偏右's avatar
偏右 committed
235
          </Trend>
236
        ),
afc163's avatar
afc163 committed
237
        align: 'right',
238 239 240
      },
    ];

nikogu's avatar
nikogu committed
241 242
    const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name);

243
    const CustomTab = ({ data, currentTabKey: currentKey }) => (
niko's avatar
niko committed
244
      <Row gutter={8} style={{ width: 138, margin: '8px 0' }}>
245 246 247
        <Col span={12}>
          <NumberInfo
            title={data.name}
陈帅's avatar
陈帅 committed
248 249 250 251 252 253
            subTitle={
              <FormattedMessage
                id="app.analysis.conversion-rate"
                defaultMessage="Conversion Rate"
              />
            }
偏右's avatar
偏右 committed
254 255
            gap={2}
            total={`${data.cvr * 100}%`}
niko's avatar
niko committed
256
            theme={currentKey !== data.name && 'light'}
257 258 259 260
          />
        </Col>
        <Col span={12} style={{ paddingTop: 36 }}>
          <Pie
nikogu's avatar
nikogu committed
261
            animate={false}
niko's avatar
niko committed
262
            color={currentKey !== data.name && '#BDE4FF'}
263 264 265 266 267 268 269 270 271 272 273 274 275
            inner={0.55}
            tooltip={false}
            margin={[0, 0, 0, 0]}
            percent={data.cvr * 100}
            height={64}
          />
        </Col>
      </Row>
    );

    const topColResponsiveProps = {
      xs: 24,
      sm: 12,
niko's avatar
niko committed
276 277 278
      md: 12,
      lg: 12,
      xl: 6,
279 280 281 282
      style: { marginBottom: 24 },
    };

    return (
jim's avatar
jim committed
283
      <GridContent>
284 285 286 287
        <Row gutter={24}>
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
288 289 290
              title={
                <FormattedMessage id="app.analysis.total-sales" defaultMessage="Total Sales" />
              }
niko's avatar
niko committed
291
              action={
陈帅's avatar
陈帅 committed
292 293 294 295 296
                <Tooltip
                  title={
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />
                  }
                >
niko's avatar
niko committed
297 298 299
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
300
              loading={loading}
jim's avatar
jim committed
301
              total={() => <Yuan>126560</Yuan>}
陈帅's avatar
陈帅 committed
302 303 304 305 306 307 308 309
              footer={
                <Field
                  label={
                    <FormattedMessage id="app.analysis.day-sales" defaultMessage="Day Sales" />
                  }
                  value={`¥${numeral(12423).format('0,0')}`}
                />
              }
310 311
              contentHeight={46}
            >
afc163's avatar
afc163 committed
312
              <Trend flag="up" style={{ marginRight: 16 }}>
陈帅's avatar
陈帅 committed
313
                <FormattedMessage id="app.analysis.week" defaultMessage="Weekly Changes" />
314
                <span className={styles.trendText}>12%</span>
afc163's avatar
afc163 committed
315 316
              </Trend>
              <Trend flag="down">
陈帅's avatar
陈帅 committed
317
                <FormattedMessage id="app.analysis.day" defaultMessage="Daily Changes" />
318
                <span className={styles.trendText}>11%</span>
afc163's avatar
afc163 committed
319
              </Trend>
320 321 322 323 324
            </ChartCard>
          </Col>
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
325
              loading={loading}
陈帅's avatar
陈帅 committed
326
              title={<FormattedMessage id="app.analysis.visits" defaultMessage="visits" />}
niko's avatar
niko committed
327
              action={
陈帅's avatar
陈帅 committed
328 329 330 331 332
                <Tooltip
                  title={
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />
                  }
                >
niko's avatar
niko committed
333 334 335
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
336
              total={numeral(8846).format('0,0')}
陈帅's avatar
陈帅 committed
337 338 339 340 341 342 343 344
              footer={
                <Field
                  label={
                    <FormattedMessage id="app.analysis.day-visits" defaultMessage="Day Visits" />
                  }
                  value={numeral(1234).format('0,0')}
                />
              }
345 346
              contentHeight={46}
            >
niko's avatar
niko committed
347
              <MiniArea color="#975FE4" data={visitData} />
348 349 350 351 352
            </ChartCard>
          </Col>
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
353
              loading={loading}
陈帅's avatar
陈帅 committed
354
              title={<FormattedMessage id="app.analysis.payments" defaultMessage="Payments" />}
niko's avatar
niko committed
355
              action={
陈帅's avatar
陈帅 committed
356 357 358 359 360
                <Tooltip
                  title={
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />
                  }
                >
niko's avatar
niko committed
361 362 363
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
364
              total={numeral(6560).format('0,0')}
陈帅's avatar
陈帅 committed
365 366 367 368 369 370 371 372 373 374 375
              footer={
                <Field
                  label={
                    <FormattedMessage
                      id="app.analysis.conversion-rate"
                      defaultMessage="Conversion Rate"
                    />
                  }
                  value="60%"
                />
              }
376 377
              contentHeight={46}
            >
niko's avatar
niko committed
378
              <MiniBar data={visitData} />
379 380 381 382
            </ChartCard>
          </Col>
          <Col {...topColResponsiveProps}>
            <ChartCard
383
              loading={loading}
384
              bordered={false}
陈帅's avatar
陈帅 committed
385 386 387 388 389 390
              title={
                <FormattedMessage
                  id="app.analysis.operational-effect"
                  defaultMessage="Operational Effect"
                />
              }
niko's avatar
niko committed
391
              action={
陈帅's avatar
陈帅 committed
392 393 394 395 396
                <Tooltip
                  title={
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />
                  }
                >
niko's avatar
niko committed
397 398 399
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
400
              total="78%"
afc163's avatar
afc163 committed
401
              footer={
afc163's avatar
afc163 committed
402
                <div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}>
afc163's avatar
afc163 committed
403
                  <Trend flag="up" style={{ marginRight: 16 }}>
陈帅's avatar
陈帅 committed
404
                    <FormattedMessage id="app.analysis.week" defaultMessage="Weekly changes" />
405
                    <span className={styles.trendText}>12%</span>
afc163's avatar
afc163 committed
406 407
                  </Trend>
                  <Trend flag="down">
陈帅's avatar
陈帅 committed
408
                    <FormattedMessage id="app.analysis.day" defaultMessage="Weekly changes" />
409
                    <span className={styles.trendText}>11%</span>
afc163's avatar
afc163 committed
410
                  </Trend>
偏右's avatar
偏右 committed
411
                </div>
afc163's avatar
afc163 committed
412
              }
413 414
              contentHeight={46}
            >
niko's avatar
niko committed
415
              <MiniProgress percent={78} strokeWidth={8} target={80} color="#13C2C2" />
416 417 418 419
            </ChartCard>
          </Col>
        </Row>

niko's avatar
niko committed
420
        <Card loading={loading} bordered={false} bodyStyle={{ padding: 0 }}>
421
          <div className={styles.salesCard}>
afc163's avatar
afc163 committed
422
            <Tabs tabBarExtraContent={salesExtra} size="large" tabBarStyle={{ marginBottom: 24 }}>
陈帅's avatar
陈帅 committed
423 424 425 426
              <TabPane
                tab={<FormattedMessage id="app.analysis.sales" defaultMessage="Sales" />}
                key="sales"
              >
niko's avatar
niko committed
427
                <Row>
nikogu's avatar
nikogu committed
428
                  <Col xl={16} lg={12} md={12} sm={24} xs={24}>
429
                    <div className={styles.salesBar}>
陈帅's avatar
陈帅 committed
430 431 432 433 434 435 436 437 438 439
                      <Bar
                        height={295}
                        title={
                          <FormattedMessage
                            id="app.analysis.sales-trend"
                            defaultMessage="Sales Trend"
                          />
                        }
                        data={salesData}
                      />
440
                    </div>
441
                  </Col>
nikogu's avatar
nikogu committed
442
                  <Col xl={8} lg={12} md={12} sm={24} xs={24}>
443
                    <div className={styles.salesRank}>
陈帅's avatar
陈帅 committed
444 445 446 447 448 449
                      <h4 className={styles.rankingTitle}>
                        <FormattedMessage
                          id="app.analysis.sales-ranking"
                          defaultMessage="Sales Ranking"
                        />
                      </h4>
450
                      <ul className={styles.rankingList}>
ddcat1115's avatar
ddcat1115 committed
451
                        {this.rankingListData.map((item, i) => (
niko's avatar
niko committed
452
                          <li key={item.title}>
afc163's avatar
afc163 committed
453 454 455 456 457 458 459 460 461 462 463 464 465
                            <span
                              className={`${styles.rankingItemNumber} ${
                                i < 3 ? styles.active : ''
                              }`}
                            >
                              {i + 1}
                            </span>
                            <span className={styles.rankingItemTitle} title={item.title}>
                              {item.title}
                            </span>
                            <span className={styles.rankingItemValue}>
                              {numeral(item.total).format('0,0')}
                            </span>
niko's avatar
niko committed
466 467
                          </li>
                        ))}
468 469
                      </ul>
                    </div>
470 471 472
                  </Col>
                </Row>
              </TabPane>
陈帅's avatar
陈帅 committed
473 474 475 476
              <TabPane
                tab={<FormattedMessage id="app.analysis.visits" defaultMessage="Visits" />}
                key="views"
              >
陈帅's avatar
陈帅 committed
477
                <Row>
478 479
                  <Col xl={16} lg={12} md={12} sm={24} xs={24}>
                    <div className={styles.salesBar}>
陈帅's avatar
陈帅 committed
480 481 482 483 484 485 486 487 488 489
                      <Bar
                        height={292}
                        title={
                          <FormattedMessage
                            id="app.analysis.visits-trend"
                            defaultMessage="Visits Trend"
                          />
                        }
                        data={salesData}
                      />
490 491 492 493
                    </div>
                  </Col>
                  <Col xl={8} lg={12} md={12} sm={24} xs={24}>
                    <div className={styles.salesRank}>
陈帅's avatar
陈帅 committed
494 495 496 497 498 499
                      <h4 className={styles.rankingTitle}>
                        <FormattedMessage
                          id="app.analysis.visits-ranking"
                          defaultMessage="Visits Ranking"
                        />
                      </h4>
500
                      <ul className={styles.rankingList}>
ddcat1115's avatar
ddcat1115 committed
501
                        {this.rankingListData.map((item, i) => (
niko's avatar
niko committed
502
                          <li key={item.title}>
503
                            <span className={i < 3 ? styles.active : ''}>{i + 1}</span>
niko's avatar
niko committed
504 505 506 507
                            <span>{item.title}</span>
                            <span>{numeral(item.total).format('0,0')}</span>
                          </li>
                        ))}
508 509 510 511
                      </ul>
                    </div>
                  </Col>
                </Row>
512 513 514 515 516 517
              </TabPane>
            </Tabs>
          </div>
        </Card>

        <Row gutter={24}>
518
          <Col xl={12} lg={24} md={24} sm={24} xs={24}>
519
            <Card
520
              loading={loading}
521
              bordered={false}
陈帅's avatar
陈帅 committed
522 523 524 525 526 527
              title={
                <FormattedMessage
                  id="app.analysis.online-top-search"
                  defaultMessage="Online Top Search"
                />
              }
528 529 530 531 532 533
              extra={iconGroup}
              style={{ marginTop: 24 }}
            >
              <Row gutter={68}>
                <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
                  <NumberInfo
afc163's avatar
afc163 committed
534 535
                    subTitle={
                      <span>
陈帅's avatar
陈帅 committed
536 537 538 539 540 541 542 543 544 545 546 547
                        <FormattedMessage
                          id="app.analysis.search-users"
                          defaultMessage="search users"
                        />
                        <Tooltip
                          title={
                            <FormattedMessage
                              id="app.analysis.introduce"
                              defaultMessage="introduce"
                            />
                          }
                        >
afc163's avatar
afc163 committed
548 549 550 551
                          <Icon style={{ marginLeft: 8 }} type="info-circle-o" />
                        </Tooltip>
                      </span>
                    }
偏右's avatar
偏右 committed
552
                    gap={8}
553 554 555 556
                    total={numeral(12321).format('0,0')}
                    status="up"
                    subTotal={17.1}
                  />
niko's avatar
niko committed
557
                  <MiniArea line height={45} data={visitData2} />
558 559 560
                </Col>
                <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
                  <NumberInfo
陈帅's avatar
陈帅 committed
561 562 563 564 565 566
                    subTitle={
                      <FormattedMessage
                        id="app.analysis.per-capita-search"
                        defaultMessage="Per Capita Search"
                      />
                    }
567 568 569
                    total={2.7}
                    status="down"
                    subTotal={26.2}
偏右's avatar
偏右 committed
570
                    gap={8}
571
                  />
niko's avatar
niko committed
572
                  <MiniArea line height={45} data={visitData2} />
573 574 575 576
                </Col>
              </Row>
              <Table
                rowKey={record => record.index}
afc163's avatar
afc163 committed
577
                size="small"
578 579 580 581 582 583 584 585 586
                columns={columns}
                dataSource={searchData}
                pagination={{
                  style: { marginBottom: 0 },
                  pageSize: 5,
                }}
              />
            </Card>
          </Col>
587
          <Col xl={12} lg={24} md={24} sm={24} xs={24}>
588
            <Card
589
              loading={loading}
niko's avatar
niko committed
590
              className={styles.salesCard}
591
              bordered={false}
陈帅's avatar
陈帅 committed
592 593 594 595 596 597
              title={
                <FormattedMessage
                  id="app.analysis.the-proportion-of-sales"
                  defaultMessage="The Proportion of Sales"
                />
              }
598
              bodyStyle={{ padding: 24 }}
niko's avatar
niko committed
599
              extra={
niko's avatar
niko committed
600 601 602 603
                <div className={styles.salesCardExtra}>
                  {iconGroup}
                  <div className={styles.salesTypeRadio}>
                    <Radio.Group value={salesType} onChange={this.handleChangeSalesType}>
陈帅's avatar
陈帅 committed
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
                      <Radio.Button value="all">
                        <FormattedMessage id="app.analysis.channel.all" defaultMessage="ALL" />
                      </Radio.Button>
                      <Radio.Button value="online">
                        <FormattedMessage
                          id="app.analysis.channel.online"
                          defaultMessage="Online"
                        />
                      </Radio.Button>
                      <Radio.Button value="stores">
                        <FormattedMessage
                          id="app.analysis.channel.stores"
                          defaultMessage="Stores"
                        />
                      </Radio.Button>
niko's avatar
niko committed
619 620 621
                    </Radio.Group>
                  </div>
                </div>
niko's avatar
niko committed
622
              }
afc163's avatar
afc163 committed
623
              style={{ marginTop: 24, minHeight: 509 }}
624
            >
陈帅's avatar
陈帅 committed
625 626 627
              <h4 style={{ marginTop: 8, marginBottom: 32 }}>
                <FormattedMessage id="app.analysis.sales" defaultMessage="Sales" />
              </h4>
afc163's avatar
afc163 committed
628 629
              <Pie
                hasLegend
陈帅's avatar
陈帅 committed
630
                subTitle={<FormattedMessage id="app.analysis.sales" defaultMessage="Sales" />}
jim's avatar
jim committed
631
                total={() => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan>}
afc163's avatar
afc163 committed
632
                data={salesPieData}
jim's avatar
jim committed
633
                valueFormat={value => <Yuan>{value}</Yuan>}
afc163's avatar
afc163 committed
634 635 636
                height={248}
                lineWidth={4}
              />
637 638 639 640 641
            </Card>
          </Col>
        </Row>

        <Card
642
          loading={loading}
niko's avatar
niko committed
643
          className={styles.offlineCard}
644
          bordered={false}
niko's avatar
niko committed
645 646
          bodyStyle={{ padding: '0 0 32px 0' }}
          style={{ marginTop: 32 }}
647
        >
niko's avatar
niko committed
648 649 650 651 652 653 654
          <Tabs activeKey={activeKey} onChange={this.handleTabChange}>
            {offlineData.map(shop => (
              <TabPane tab={<CustomTab data={shop} currentTabKey={activeKey} />} key={shop.name}>
                <div style={{ padding: '0 24px' }}>
                  <TimelineChart
                    height={400}
                    data={offlineChartData}
陈帅's avatar
陈帅 committed
655
                    titleMap={{
陈帅's avatar
陈帅 committed
656 657
                      y1: formatMessage({ id: 'app.analysis.traffic' }),
                      y2: formatMessage({ id: 'app.analysis.payments' }),
陈帅's avatar
陈帅 committed
658
                    }}
niko's avatar
niko committed
659 660 661 662
                  />
                </div>
              </TabPane>
            ))}
663 664
          </Tabs>
        </Card>
jim's avatar
jim committed
665
      </GridContent>
666 667
    );
  }
afc163's avatar
afc163 committed
668
}
ddcat1115's avatar
ddcat1115 committed
669

陈帅's avatar
陈帅 committed
670
export default Analysis;