BasicProfile.js 4.89 KB
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2
import React, { Component } from 'react';
import { connect } from 'dva';
afc163's avatar
afc163 committed
3
import { Card, Badge, Table, Divider } from 'antd';
4
import DescriptionList from '@/components/DescriptionList';
5
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
ddcat1115's avatar
ddcat1115 committed
6 7 8 9
import styles from './BasicProfile.less';

const { Description } = DescriptionList;

niko's avatar
niko committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
const progressColumns = [
  {
    title: '时间',
    dataIndex: 'time',
    key: 'time',
  },
  {
    title: '当前进度',
    dataIndex: 'rate',
    key: 'rate',
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    render: text =>
jim's avatar
jim committed
26
      text === 'success' ? (
niko's avatar
niko committed
27 28 29
        <Badge status="success" text="成功" />
      ) : (
        <Badge status="processing" text="进行中" />
jim's avatar
jim committed
30
      ),
niko's avatar
niko committed
31 32 33 34 35 36 37 38 39 40 41 42
  },
  {
    title: '操作员ID',
    dataIndex: 'operator',
    key: 'operator',
  },
  {
    title: '耗时',
    dataIndex: 'cost',
    key: 'cost',
  },
];
ddcat1115's avatar
ddcat1115 committed
43

afc163's avatar
afc163 committed
44
export default
Andreas Cederström's avatar
Andreas Cederström committed
45 46 47
@connect(({ profile, loading }) => ({
  profile,
  loading: loading.effects['profile/fetchBasic'],
ddcat1115's avatar
ddcat1115 committed
48
}))
afc163's avatar
afc163 committed
49
class BasicProfile extends Component {
ddcat1115's avatar
ddcat1115 committed
50 51 52 53 54 55 56 57
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'profile/fetchBasic',
    });
  }

  render() {
Andreas Cederström's avatar
Andreas Cederström committed
58 59
    const { profile, loading } = this.props;
    const { basicGoods, basicProgress } = profile;
ddcat1115's avatar
ddcat1115 committed
60 61 62 63
    let goodsData = [];
    if (basicGoods.length) {
      let num = 0;
      let amount = 0;
jim's avatar
jim committed
64
      basicGoods.forEach(item => {
ddcat1115's avatar
ddcat1115 committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
        num += Number(item.num);
        amount += Number(item.amount);
      });
      goodsData = basicGoods.concat({
        id: '总计',
        num,
        amount,
      });
    }
    const renderContent = (value, row, index) => {
      const obj = {
        children: value,
        props: {},
      };
      if (index === basicGoods.length) {
        obj.props.colSpan = 0;
      }
      return obj;
    };
niko's avatar
niko committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    const goodsColumns = [
      {
        title: '商品编号',
        dataIndex: 'id',
        key: 'id',
        render: (text, row, index) => {
          if (index < basicGoods.length) {
            return <a href="">{text}</a>;
          }
          return {
            children: <span style={{ fontWeight: 600 }}>总计</span>,
            props: {
              colSpan: 4,
            },
          };
        },
ddcat1115's avatar
ddcat1115 committed
100
      },
niko's avatar
niko committed
101 102 103 104 105
      {
        title: '商品名称',
        dataIndex: 'name',
        key: 'name',
        render: renderContent,
ddcat1115's avatar
ddcat1115 committed
106
      },
niko's avatar
niko committed
107 108 109 110 111
      {
        title: '商品条码',
        dataIndex: 'barcode',
        key: 'barcode',
        render: renderContent,
ddcat1115's avatar
ddcat1115 committed
112
      },
niko's avatar
niko committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
      {
        title: '单价',
        dataIndex: 'price',
        key: 'price',
        align: 'right',
        render: renderContent,
      },
      {
        title: '数量(件)',
        dataIndex: 'num',
        key: 'num',
        align: 'right',
        render: (text, row, index) => {
          if (index < basicGoods.length) {
            return text;
          }
          return <span style={{ fontWeight: 600 }}>{text}</span>;
        },
      },
      {
        title: '金额',
        dataIndex: 'amount',
        key: 'amount',
        align: 'right',
        render: (text, row, index) => {
          if (index < basicGoods.length) {
            return text;
          }
          return <span style={{ fontWeight: 600 }}>{text}</span>;
        },
      },
    ];
ddcat1115's avatar
ddcat1115 committed
145
    return (
146
      <PageHeaderWrapper title="基础详情页">
ddcat1115's avatar
ddcat1115 committed
147
        <Card bordered={false}>
nikogu's avatar
nikogu committed
148
          <DescriptionList size="large" title="退款申请" style={{ marginBottom: 32 }}>
ddcat1115's avatar
ddcat1115 committed
149 150 151 152 153
            <Description term="取货单号">1000000000</Description>
            <Description term="状态">已取货</Description>
            <Description term="销售单号">1234123421</Description>
            <Description term="子订单">3214321432</Description>
          </DescriptionList>
afc163's avatar
afc163 committed
154
          <Divider style={{ marginBottom: 32 }} />
nikogu's avatar
nikogu committed
155
          <DescriptionList size="large" title="用户信息" style={{ marginBottom: 32 }}>
ddcat1115's avatar
ddcat1115 committed
156 157 158 159
            <Description term="用户姓名">付小小</Description>
            <Description term="联系电话">18100000000</Description>
            <Description term="常用快递">菜鸟仓储</Description>
            <Description term="取货地址">浙江省杭州市西湖区万塘路18号</Description>
ddcat1115's avatar
ddcat1115 committed
160
            <Description term="备注"></Description>
ddcat1115's avatar
ddcat1115 committed
161
          </DescriptionList>
afc163's avatar
afc163 committed
162
          <Divider style={{ marginBottom: 32 }} />
ddcat1115's avatar
ddcat1115 committed
163 164 165 166
          <div className={styles.title}>退货商品</div>
          <Table
            style={{ marginBottom: 24 }}
            pagination={false}
Andreas Cederström's avatar
Andreas Cederström committed
167
            loading={loading}
ddcat1115's avatar
ddcat1115 committed
168 169 170 171 172 173
            dataSource={goodsData}
            columns={goodsColumns}
            rowKey="id"
          />
          <div className={styles.title}>退货进度</div>
          <Table
ddcat1115's avatar
ddcat1115 committed
174
            style={{ marginBottom: 16 }}
ddcat1115's avatar
ddcat1115 committed
175
            pagination={false}
Andreas Cederström's avatar
Andreas Cederström committed
176
            loading={loading}
ddcat1115's avatar
ddcat1115 committed
177 178 179 180
            dataSource={basicProgress}
            columns={progressColumns}
          />
        </Card>
181
      </PageHeaderWrapper>
ddcat1115's avatar
ddcat1115 committed
182 183 184
    );
  }
}