index.tsx 5.75 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import { Badge, Card, Descriptions, Divider, Table } from 'antd';
ddcat1115's avatar
ddcat1115 committed
2
import React, { Component } from 'react';
陈帅's avatar
陈帅 committed
3

陈帅's avatar
陈帅 committed
4
import { Dispatch } from 'redux';
陈帅's avatar
陈帅 committed
5 6 7
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { connect } from 'dva';
import { BasicGood, BasicProfileDataType } from './data';
8
import styles from './style.less';
ddcat1115's avatar
ddcat1115 committed
9

niko's avatar
niko committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
const progressColumns = [
  {
    title: '时间',
    dataIndex: 'time',
    key: 'time',
  },
  {
    title: '当前进度',
    dataIndex: 'rate',
    key: 'rate',
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
陈帅's avatar
陈帅 committed
25
    render: (text: string) =>
陈帅's avatar
陈帅 committed
26
      text === 'success' ? (
niko's avatar
niko committed
27 28 29
        <Badge status="success" text="成功" />
      ) : (
        <Badge status="processing" text="进行中" />
陈帅's avatar
陈帅 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

陈帅's avatar
陈帅 committed
44 45
interface PAGE_NAME_UPPER_CAMEL_CASEProps {
  loading: boolean;
陈帅's avatar
陈帅 committed
46
  dispatch: Dispatch<any>;
陈帅's avatar
陈帅 committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  BLOCK_NAME_CAMEL_CASE: BasicProfileDataType;
}
interface PAGE_NAME_UPPER_CAMEL_CASEState {
  visible: boolean;
}

@connect(
  ({
    BLOCK_NAME_CAMEL_CASE,
    loading,
  }: {
    BLOCK_NAME_CAMEL_CASE: BasicProfileDataType;
    loading: {
      effects: { [key: string]: boolean };
    };
  }) => ({
    BLOCK_NAME_CAMEL_CASE,
    loading: loading.effects['BLOCK_NAME_CAMEL_CASE/fetchBasic'],
陈帅's avatar
陈帅 committed
65
  }),
陈帅's avatar
陈帅 committed
66 67 68 69 70
)
class PAGE_NAME_UPPER_CAMEL_CASE extends Component<
  PAGE_NAME_UPPER_CAMEL_CASEProps,
  PAGE_NAME_UPPER_CAMEL_CASEState
> {
ddcat1115's avatar
ddcat1115 committed
71 72 73
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
74
      type: 'BLOCK_NAME_CAMEL_CASE/fetchBasic',
ddcat1115's avatar
ddcat1115 committed
75 76 77 78
    });
  }

  render() {
79 80
    const { BLOCK_NAME_CAMEL_CASE, loading } = this.props;
    const { basicGoods, basicProgress } = BLOCK_NAME_CAMEL_CASE;
陈帅's avatar
陈帅 committed
81
    let goodsData: typeof basicGoods = [];
ddcat1115's avatar
ddcat1115 committed
82 83 84
    if (basicGoods.length) {
      let num = 0;
      let amount = 0;
jim's avatar
jim committed
85
      basicGoods.forEach(item => {
ddcat1115's avatar
ddcat1115 committed
86 87 88 89 90 91 92
        num += Number(item.num);
        amount += Number(item.amount);
      });
      goodsData = basicGoods.concat({
        id: '总计',
        num,
        amount,
陈帅's avatar
陈帅 committed
93
      } as BasicGood);
ddcat1115's avatar
ddcat1115 committed
94
    }
陈帅's avatar
陈帅 committed
95
    const renderContent = (value: any, row: any, index: any) => {
ddcat1115's avatar
ddcat1115 committed
96 97
      const obj = {
        children: value,
陈帅's avatar
陈帅 committed
98 99 100
        props: {} as {
          colSpan?: number;
        },
ddcat1115's avatar
ddcat1115 committed
101 102 103 104 105 106
      };
      if (index === basicGoods.length) {
        obj.props.colSpan = 0;
      }
      return obj;
    };
niko's avatar
niko committed
107 108 109 110 111
    const goodsColumns = [
      {
        title: '商品编号',
        dataIndex: 'id',
        key: 'id',
陈帅's avatar
陈帅 committed
112
        render: (text: React.ReactNode, row: any, index: number) => {
niko's avatar
niko committed
113 114 115 116 117 118 119 120 121 122
          if (index < basicGoods.length) {
            return <a href="">{text}</a>;
          }
          return {
            children: <span style={{ fontWeight: 600 }}>总计</span>,
            props: {
              colSpan: 4,
            },
          };
        },
ddcat1115's avatar
ddcat1115 committed
123
      },
niko's avatar
niko committed
124 125 126 127 128
      {
        title: '商品名称',
        dataIndex: 'name',
        key: 'name',
        render: renderContent,
ddcat1115's avatar
ddcat1115 committed
129
      },
niko's avatar
niko committed
130 131 132 133 134
      {
        title: '商品条码',
        dataIndex: 'barcode',
        key: 'barcode',
        render: renderContent,
ddcat1115's avatar
ddcat1115 committed
135
      },
niko's avatar
niko committed
136 137 138 139
      {
        title: '单价',
        dataIndex: 'price',
        key: 'price',
陈帅's avatar
陈帅 committed
140
        align: 'right' as 'left' | 'right' | 'center',
niko's avatar
niko committed
141 142 143 144 145 146
        render: renderContent,
      },
      {
        title: '数量(件)',
        dataIndex: 'num',
        key: 'num',
陈帅's avatar
陈帅 committed
147 148
        align: 'right' as 'left' | 'right' | 'center',
        render: (text: React.ReactNode, row: any, index: number) => {
niko's avatar
niko committed
149 150 151 152 153 154 155 156 157 158
          if (index < basicGoods.length) {
            return text;
          }
          return <span style={{ fontWeight: 600 }}>{text}</span>;
        },
      },
      {
        title: '金额',
        dataIndex: 'amount',
        key: 'amount',
陈帅's avatar
陈帅 committed
159 160
        align: 'right' as 'left' | 'right' | 'center',
        render: (text: React.ReactNode, row: any, index: number) => {
niko's avatar
niko committed
161 162 163 164 165 166 167
          if (index < basicGoods.length) {
            return text;
          }
          return <span style={{ fontWeight: 600 }}>{text}</span>;
        },
      },
    ];
ddcat1115's avatar
ddcat1115 committed
168
    return (
陈帅's avatar
陈帅 committed
169
      <PageHeaderWrapper>
ddcat1115's avatar
ddcat1115 committed
170
        <Card bordered={false}>
陈帅's avatar
陈帅 committed
171 172 173 174 175 176
          <Descriptions title="退款申请" style={{ marginBottom: 32 }}>
            <Descriptions.Item label="取货单号">1000000000</Descriptions.Item>
            <Descriptions.Item label="状态">已取货</Descriptions.Item>
            <Descriptions.Item label="销售单号">1234123421</Descriptions.Item>
            <Descriptions.Item label="子订单">3214321432</Descriptions.Item>
          </Descriptions>
afc163's avatar
afc163 committed
177
          <Divider style={{ marginBottom: 32 }} />
陈帅's avatar
陈帅 committed
178 179 180 181 182 183 184
          <Descriptions title="用户信息" style={{ marginBottom: 32 }}>
            <Descriptions.Item label="用户姓名">付小小</Descriptions.Item>
            <Descriptions.Item label="联系电话">18100000000</Descriptions.Item>
            <Descriptions.Item label="常用快递">菜鸟仓储</Descriptions.Item>
            <Descriptions.Item label="取货地址">浙江省杭州市西湖区万塘路18号</Descriptions.Item>
            <Descriptions.Item label="备注"></Descriptions.Item>
          </Descriptions>
afc163's avatar
afc163 committed
185
          <Divider style={{ marginBottom: 32 }} />
ddcat1115's avatar
ddcat1115 committed
186 187 188 189
          <div className={styles.title}>退货商品</div>
          <Table
            style={{ marginBottom: 24 }}
            pagination={false}
Andreas Cederström's avatar
Andreas Cederström committed
190
            loading={loading}
ddcat1115's avatar
ddcat1115 committed
191 192 193 194 195 196
            dataSource={goodsData}
            columns={goodsColumns}
            rowKey="id"
          />
          <div className={styles.title}>退货进度</div>
          <Table
ddcat1115's avatar
ddcat1115 committed
197
            style={{ marginBottom: 16 }}
ddcat1115's avatar
ddcat1115 committed
198
            pagination={false}
Andreas Cederström's avatar
Andreas Cederström committed
199
            loading={loading}
ddcat1115's avatar
ddcat1115 committed
200 201 202 203
            dataSource={basicProgress}
            columns={progressColumns}
          />
        </Card>
204
      </PageHeaderWrapper>
ddcat1115's avatar
ddcat1115 committed
205 206 207
    );
  }
}
lijiehua's avatar
lijiehua committed
208

209
export default PAGE_NAME_UPPER_CAMEL_CASE;