"FormBasicForm/package.json" did not exist on "bdc92d5c991f72d720fa460995dc19bcd83c5817"
index.tsx 5.75 KB
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2
import React, { Component } from 'react';
import { connect } from 'dva';
陈帅's avatar
陈帅 committed
3
import { Card, Badge, Table, Descriptions, Divider } from 'antd';
4
import { PageHeaderWrapper } from '@ant-design/pro-layout';
5
import styles from './style.less';
陈帅's avatar
陈帅 committed
6 7
import { BasicProfileDataType, BasicGood } from './data';
import { Dispatch } from 'redux';
ddcat1115's avatar
ddcat1115 committed
8

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

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

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

208
export default PAGE_NAME_UPPER_CAMEL_CASE;