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

const { Description } = DescriptionList;

N
niko 已提交
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 =>
J
jim 已提交
26
      text === 'success' ? (
N
niko 已提交
27 28 29
        <Badge status="success" text="成功" />
      ) : (
        <Badge status="processing" text="进行中" />
J
jim 已提交
30
      ),
N
niko 已提交
31 32 33 34 35 36 37 38 39 40 41 42
  },
  {
    title: '操作员ID',
    dataIndex: 'operator',
    key: 'operator',
  },
  {
    title: '耗时',
    dataIndex: 'cost',
    key: 'cost',
  },
];
D
ddcat1115 已提交
43

A
Andreas Cederström 已提交
44 45 46
@connect(({ profile, loading }) => ({
  profile,
  loading: loading.effects['profile/fetchBasic'],
D
ddcat1115 已提交
47
}))
A
afc163 已提交
48
class BasicProfile extends Component {
D
ddcat1115 已提交
49
  componentDidMount() {
50 51 52
    const { dispatch, match } = this.props;
    const { params } = match;

D
ddcat1115 已提交
53 54
    dispatch({
      type: 'profile/fetchBasic',
55
      payload: params.id || '1000000000',
D
ddcat1115 已提交
56 57 58 59
    });
  }

  render() {
60 61
    const { profile = {}, loading } = this.props;
    const { basicGoods = [], basicProgress = [], userInfo = {}, application = {} } = profile;
D
ddcat1115 已提交
62 63 64 65
    let goodsData = [];
    if (basicGoods.length) {
      let num = 0;
      let amount = 0;
J
jim 已提交
66
      basicGoods.forEach(item => {
D
ddcat1115 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
        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;
    };
N
niko 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    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,
            },
          };
        },
D
ddcat1115 已提交
102
      },
N
niko 已提交
103 104 105 106 107
      {
        title: '商品名称',
        dataIndex: 'name',
        key: 'name',
        render: renderContent,
D
ddcat1115 已提交
108
      },
N
niko 已提交
109 110 111 112 113
      {
        title: '商品条码',
        dataIndex: 'barcode',
        key: 'barcode',
        render: renderContent,
D
ddcat1115 已提交
114
      },
N
niko 已提交
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 145 146
      {
        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>;
        },
      },
    ];
D
ddcat1115 已提交
147
    return (
148
      <PageHeaderWrapper title="基础详情页" loading={loading}>
D
ddcat1115 已提交
149
        <Card bordered={false}>
N
nikogu 已提交
150
          <DescriptionList size="large" title="退款申请" style={{ marginBottom: 32 }}>
151 152 153 154
            <Description term="取货单号">{application.id}</Description>
            <Description term="状态">{application.status}</Description>
            <Description term="销售单号">{application.orderNo}</Description>
            <Description term="子订单">{application.childOrderNo}</Description>
D
ddcat1115 已提交
155
          </DescriptionList>
A
afc163 已提交
156
          <Divider style={{ marginBottom: 32 }} />
N
nikogu 已提交
157
          <DescriptionList size="large" title="用户信息" style={{ marginBottom: 32 }}>
158 159 160 161 162
            <Description term="用户姓名">{userInfo.name}</Description>
            <Description term="联系电话">{userInfo.tel}</Description>
            <Description term="常用快递">{userInfo.delivery}</Description>
            <Description term="取货地址">{userInfo.addr}</Description>
            <Description term="备注">{userInfo.remark}</Description>
D
ddcat1115 已提交
163
          </DescriptionList>
A
afc163 已提交
164
          <Divider style={{ marginBottom: 32 }} />
D
ddcat1115 已提交
165 166 167 168
          <div className={styles.title}>退货商品</div>
          <Table
            style={{ marginBottom: 24 }}
            pagination={false}
A
Andreas Cederström 已提交
169
            loading={loading}
D
ddcat1115 已提交
170 171 172 173 174 175
            dataSource={goodsData}
            columns={goodsColumns}
            rowKey="id"
          />
          <div className={styles.title}>退货进度</div>
          <Table
D
ddcat1115 已提交
176
            style={{ marginBottom: 16 }}
D
ddcat1115 已提交
177
            pagination={false}
A
Andreas Cederström 已提交
178
            loading={loading}
D
ddcat1115 已提交
179 180 181 182
            dataSource={basicProgress}
            columns={progressColumns}
          />
        </Card>
183
      </PageHeaderWrapper>
D
ddcat1115 已提交
184 185 186
    );
  }
}
L
lijiehua 已提交
187 188

export default BasicProfile;