Analysis.js 22.2 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
        total: 323234,
      });
    }
  }
陈帅's avatar
陈帅 committed
62

Anderson's avatar
Anderson committed
63 64 65 66
  state = {
    salesType: 'all',
    currentTabKey: '',
    rangePickerValue: getTimeDistance('year'),
Anderson's avatar
Anderson committed
67
    loading: true,
Anderson's avatar
Anderson committed
68 69
  };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    return (
jim's avatar
jim committed
284
      <GridContent>
285 286 287 288
        <Row gutter={24}>
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
289 290 291
              title={
                <FormattedMessage id="app.analysis.total-sales" defaultMessage="Total Sales" />
              }
niko's avatar
niko committed
292
              action={
陈帅's avatar
陈帅 committed
293 294
                <Tooltip
                  title={
David Z. Han's avatar
David Z. Han committed
295
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />
陈帅's avatar
陈帅 committed
296 297
                  }
                >
niko's avatar
niko committed
298 299 300
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
301
              loading={loading}
jim's avatar
jim committed
302
              total={() => <Yuan>126560</Yuan>}
陈帅's avatar
陈帅 committed
303 304 305
              footer={
                <Field
                  label={
David Z. Han's avatar
David Z. Han committed
306
                    <FormattedMessage id="app.analysis.day-sales" defaultMessage="Daily Sales" />
陈帅's avatar
陈帅 committed
307 308 309 310
                  }
                  value={`¥${numeral(12423).format('0,0')}`}
                />
              }
311 312
              contentHeight={46}
            >
afc163's avatar
afc163 committed
313
              <Trend flag="up" style={{ marginRight: 16 }}>
陈帅's avatar
陈帅 committed
314
                <FormattedMessage id="app.analysis.week" defaultMessage="Weekly Changes" />
315
                <span className={styles.trendText}>12%</span>
afc163's avatar
afc163 committed
316 317
              </Trend>
              <Trend flag="down">
陈帅's avatar
陈帅 committed
318
                <FormattedMessage id="app.analysis.day" defaultMessage="Daily Changes" />
319
                <span className={styles.trendText}>11%</span>
afc163's avatar
afc163 committed
320
              </Trend>
321 322
            </ChartCard>
          </Col>
David Z. Han's avatar
David Z. Han committed
323

324 325 326
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
327
              loading={loading}
David Z. Han's avatar
David Z. Han committed
328
              title={<FormattedMessage id="app.analysis.visits" defaultMessage="Visits" />}
niko's avatar
niko committed
329
              action={
陈帅's avatar
陈帅 committed
330 331
                <Tooltip
                  title={
David Z. Han's avatar
David Z. Han committed
332
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />
陈帅's avatar
陈帅 committed
333 334
                  }
                >
niko's avatar
niko committed
335 336 337
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
338
              total={numeral(8846).format('0,0')}
陈帅's avatar
陈帅 committed
339 340 341
              footer={
                <Field
                  label={
David Z. Han's avatar
David Z. Han committed
342
                    <FormattedMessage id="app.analysis.day-visits" defaultMessage="Daily Visits" />
陈帅's avatar
陈帅 committed
343 344 345 346
                  }
                  value={numeral(1234).format('0,0')}
                />
              }
347 348
              contentHeight={46}
            >
niko's avatar
niko committed
349
              <MiniArea color="#975FE4" data={visitData} />
350 351 352 353 354
            </ChartCard>
          </Col>
          <Col {...topColResponsiveProps}>
            <ChartCard
              bordered={false}
陈帅's avatar
陈帅 committed
355
              loading={loading}
陈帅's avatar
陈帅 committed
356
              title={<FormattedMessage id="app.analysis.payments" defaultMessage="Payments" />}
niko's avatar
niko committed
357
              action={
陈帅's avatar
陈帅 committed
358 359 360 361 362
                <Tooltip
                  title={
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />
                  }
                >
niko's avatar
niko committed
363 364 365
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
366
              total={numeral(6560).format('0,0')}
陈帅's avatar
陈帅 committed
367 368 369 370 371 372 373 374 375 376 377
              footer={
                <Field
                  label={
                    <FormattedMessage
                      id="app.analysis.conversion-rate"
                      defaultMessage="Conversion Rate"
                    />
                  }
                  value="60%"
                />
              }
378 379
              contentHeight={46}
            >
niko's avatar
niko committed
380
              <MiniBar data={visitData} />
381 382 383 384
            </ChartCard>
          </Col>
          <Col {...topColResponsiveProps}>
            <ChartCard
385
              loading={loading}
386
              bordered={false}
陈帅's avatar
陈帅 committed
387 388 389 390 391 392
              title={
                <FormattedMessage
                  id="app.analysis.operational-effect"
                  defaultMessage="Operational Effect"
                />
              }
niko's avatar
niko committed
393
              action={
陈帅's avatar
陈帅 committed
394 395
                <Tooltip
                  title={
David Z. Han's avatar
David Z. Han committed
396
                    <FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />
陈帅's avatar
陈帅 committed
397 398
                  }
                >
niko's avatar
niko committed
399 400 401
                  <Icon type="info-circle-o" />
                </Tooltip>
              }
402
              total="78%"
afc163's avatar
afc163 committed
403
              footer={
afc163's avatar
afc163 committed
404
                <div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}>
afc163's avatar
afc163 committed
405
                  <Trend flag="up" style={{ marginRight: 16 }}>
David Z. Han's avatar
David Z. Han committed
406
                    <FormattedMessage id="app.analysis.week" defaultMessage="Weekly Changes" />
407
                    <span className={styles.trendText}>12%</span>
afc163's avatar
afc163 committed
408 409
                  </Trend>
                  <Trend flag="down">
David Z. Han's avatar
David Z. Han committed
410
                    <FormattedMessage id="app.analysis.day" defaultMessage="Weekly Changes" />
411
                    <span className={styles.trendText}>11%</span>
afc163's avatar
afc163 committed
412
                  </Trend>
偏右's avatar
偏右 committed
413
                </div>
afc163's avatar
afc163 committed
414
              }
415 416
              contentHeight={46}
            >
niko's avatar
niko committed
417
              <MiniProgress percent={78} strokeWidth={8} target={80} color="#13C2C2" />
418 419 420 421
            </ChartCard>
          </Col>
        </Row>

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

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

        <Card
664
          loading={loading}
niko's avatar
niko committed
665
          className={styles.offlineCard}
666
          bordered={false}
niko's avatar
niko committed
667 668
          bodyStyle={{ padding: '0 0 32px 0' }}
          style={{ marginTop: 32 }}
669
        >
niko's avatar
niko committed
670 671 672 673 674 675 676
          <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
677
                    titleMap={{
陈帅's avatar
陈帅 committed
678 679
                      y1: formatMessage({ id: 'app.analysis.traffic' }),
                      y2: formatMessage({ id: 'app.analysis.payments' }),
陈帅's avatar
陈帅 committed
680
                    }}
niko's avatar
niko committed
681 682 683 684
                  />
                </div>
              </TabPane>
            ))}
685 686
          </Tabs>
        </Card>
jim's avatar
jim committed
687
      </GridContent>
688 689
    );
  }
afc163's avatar
afc163 committed
690
}
ddcat1115's avatar
ddcat1115 committed
691

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