Analysis.js 21 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,
niko's avatar
niko committed
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 '../../layouts/GridContent';
jim's avatar
jim committed
31
import Yuan from '../../utils/Yuan';
32 33 34 35
import { getTimeDistance } from '../../utils/utils';

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 70 71
  state = {
    salesType: 'all',
    currentTabKey: '',
afc163's avatar
afc163 committed
72
    rangePickerValue: getTimeDistance('year'),
niko's avatar
niko committed
73
  };
74 75

  componentDidMount() {
76
    const { dispatch } = this.props;
77 78 79 80
    this.reqRef = requestAnimationFrame(() => {
      dispatch({
        type: 'chart/fetch',
      });
81 82 83 84 85
      setTimeout(() => {
        this.setState({
          loading: false,
        });
      }, 1000);
86
    });
87 88 89 90 91 92 93
  }

  componentWillUnmount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'chart/clear',
    });
94
    cancelAnimationFrame(this.reqRef);
95 96
  }

jim's avatar
jim committed
97
  handleChangeSalesType = e => {
98 99 100
    this.setState({
      salesType: e.target.value,
    });
niko's avatar
niko committed
101
  };
102

jim's avatar
jim committed
103
  handleTabChange = key => {
104 105 106
    this.setState({
      currentTabKey: key,
    });
niko's avatar
niko committed
107
  };
108

jim's avatar
jim committed
109
  handleRangePickerChange = rangePickerValue => {
110
    const { dispatch } = this.props;
111 112 113
    this.setState({
      rangePickerValue,
    });
nikogu's avatar
nikogu committed
114

115
    dispatch({
nikogu's avatar
nikogu committed
116 117
      type: 'chart/fetchSalesData',
    });
niko's avatar
niko committed
118
  };
119

jim's avatar
jim committed
120
  selectDate = type => {
121
    const { dispatch } = this.props;
122 123 124 125
    this.setState({
      rangePickerValue: getTimeDistance(type),
    });

126
    dispatch({
127 128
      type: 'chart/fetchSalesData',
    });
niko's avatar
niko committed
129
  };
130

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

145
  render() {
146 147
    const { rangePickerValue, salesType, loading: propsLoding, currentTabKey } = this.state;
    const { chart, loading: stateLoading } = this.props;
148 149
    const {
      visitData,
afc163's avatar
afc163 committed
150
      visitData2,
151 152 153 154 155 156 157
      salesData,
      searchData,
      offlineData,
      offlineChartData,
      salesTypeData,
      salesTypeDataOnline,
      salesTypeDataOffline,
afc163's avatar
afc163 committed
158
    } = chart;
159
    const loading = propsLoding || stateLoading;
niko's avatar
niko committed
160 161 162
    const salesPieData =
      salesType === 'all'
        ? salesTypeData
jim's avatar
jim committed
163 164 165
        : salesType === 'online'
          ? salesTypeDataOnline
          : salesTypeDataOffline;
166

afc163's avatar
afc163 committed
167 168 169 170 171 172 173
    const menu = (
      <Menu>
        <Menu.Item>操作一</Menu.Item>
        <Menu.Item>操作二</Menu.Item>
      </Menu>
    );

174 175
    const iconGroup = (
      <span className={styles.iconGroup}>
afc163's avatar
afc163 committed
176 177 178
        <Dropdown overlay={menu} placement="bottomRight">
          <Icon type="ellipsis" />
        </Dropdown>
179 180 181
      </span>
    );

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

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

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

248
    const CustomTab = ({ data, currentTabKey: currentKey }) => (
niko's avatar
niko committed
249
      <Row gutter={8} style={{ width: 138, margin: '8px 0' }}>
250 251 252
        <Col span={12}>
          <NumberInfo
            title={data.name}
陈帅's avatar
陈帅 committed
253 254 255 256 257 258
            subTitle={
              <FormattedMessage
                id="app.analysis.conversion-rate"
                defaultMessage="Conversion Rate"
              />
            }
偏右's avatar
偏右 committed
259 260
            gap={2}
            total={`${data.cvr * 100}%`}
niko's avatar
niko committed
261
            theme={currentKey !== data.name && 'light'}
262 263 264 265
          />
        </Col>
        <Col span={12} style={{ paddingTop: 36 }}>
          <Pie
nikogu's avatar
nikogu committed
266
            animate={false}
niko's avatar
niko committed
267
            color={currentKey !== data.name && '#BDE4FF'}
268 269 270 271 272 273 274 275 276 277 278 279 280
            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
281 282 283
      md: 12,
      lg: 12,
      xl: 6,
284 285 286 287
      style: { marginBottom: 24 },
    };

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

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

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

        <Card
637
          loading={loading}
niko's avatar
niko committed
638
          className={styles.offlineCard}
639
          bordered={false}
niko's avatar
niko committed
640 641
          bodyStyle={{ padding: '0 0 32px 0' }}
          style={{ marginTop: 32 }}
642
        >
niko's avatar
niko committed
643 644 645 646 647 648 649
          <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
650
                    titleMap={{
陈帅's avatar
陈帅 committed
651 652
                      y1: formatMessage({ id: 'app.analysis.traffic' }),
                      y2: formatMessage({ id: 'app.analysis.payments' }),
陈帅's avatar
陈帅 committed
653
                    }}
niko's avatar
niko committed
654 655 656 657
                  />
                </div>
              </TabPane>
            ))}
658 659
          </Tabs>
        </Card>
jim's avatar
jim committed
660
      </GridContent>
661 662
    );
  }
afc163's avatar
afc163 committed
663
}
ddcat1115's avatar
ddcat1115 committed
664

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