"ProfileBasic/src/index.tsx" did not exist on "474c74680deae020de21f5e034035073e9712723"
index.tsx 5.76 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';
陈帅's avatar
陈帅 committed
4
import DescriptionList from './components/DescriptionList';
5
import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
import styles from './style.less';
陈帅's avatar
陈帅 committed
7 8
import { BasicProfileDataType, BasicGood } from './data';
import { Dispatch } from 'redux';
ddcat1115's avatar
ddcat1115 committed
9 10
const { Description } = DescriptionList;

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

陈帅's avatar
陈帅 committed
45 46
interface PAGE_NAME_UPPER_CAMEL_CASEProps {
  loading: boolean;
陈帅's avatar
陈帅 committed
47
  dispatch: Dispatch<any>;
陈帅's avatar
陈帅 committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  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
66
  }),
陈帅's avatar
陈帅 committed
67 68 69 70 71
)
class PAGE_NAME_UPPER_CAMEL_CASE extends Component<
  PAGE_NAME_UPPER_CAMEL_CASEProps,
  PAGE_NAME_UPPER_CAMEL_CASEState
> {
ddcat1115's avatar
ddcat1115 committed
72 73 74
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
75
      type: 'BLOCK_NAME_CAMEL_CASE/fetchBasic',
ddcat1115's avatar
ddcat1115 committed
76 77 78 79
    });
  }

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

210
export default PAGE_NAME_UPPER_CAMEL_CASE;