BasicProfile.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import React, { Component } from 'react';
  2. import { connect } from 'dva';
  3. import { Card, Badge, Table } from 'antd';
  4. import PageHeaderLayout from '../../layouts/PageHeaderLayout';
  5. import DescriptionList from '../../components/DescriptionList';
  6. import styles from './BasicProfile.less';
  7. const { Description } = DescriptionList;
  8. const progressColumns = [{
  9. title: '时间',
  10. dataIndex: 'time',
  11. key: 'time',
  12. }, {
  13. title: '当前进度',
  14. dataIndex: 'rate',
  15. key: 'rate',
  16. }, {
  17. title: '状态',
  18. dataIndex: 'status',
  19. key: 'status',
  20. render: text => (
  21. text === 'success' ? <Badge status="success" text="成功" /> : <Badge status="processing" text="进行中" />
  22. ),
  23. }, {
  24. title: '操作员ID',
  25. dataIndex: 'operator',
  26. key: 'operator',
  27. }, {
  28. title: '耗时',
  29. dataIndex: 'cost',
  30. key: 'cost',
  31. }];
  32. @connect(state => ({
  33. profile: state.profile,
  34. }))
  35. export default class BasicProfile extends Component {
  36. componentDidMount() {
  37. const { dispatch } = this.props;
  38. dispatch({
  39. type: 'profile/fetchBasic',
  40. });
  41. }
  42. render() {
  43. const { profile } = this.props;
  44. const { basicGoods, basicProgress, basicLoading } = profile;
  45. let goodsData = [];
  46. if (basicGoods.length) {
  47. let num = 0;
  48. let amount = 0;
  49. basicGoods.forEach((item) => {
  50. num += Number(item.num);
  51. amount += Number(item.amount);
  52. });
  53. goodsData = basicGoods.concat({
  54. id: '总计',
  55. num,
  56. amount,
  57. });
  58. }
  59. const renderContent = (value, row, index) => {
  60. const obj = {
  61. children: value,
  62. props: {},
  63. };
  64. if (index === basicGoods.length) {
  65. obj.props.colSpan = 0;
  66. }
  67. return obj;
  68. };
  69. const goodsColumns = [{
  70. title: '商品编号',
  71. dataIndex: 'id',
  72. key: 'id',
  73. render: (text, row, index) => {
  74. if (index < basicGoods.length) {
  75. return <a href="">{text}</a>;
  76. }
  77. return {
  78. children: <span style={{ fontWeight: 600 }}>总计</span>,
  79. props: {
  80. colSpan: 4,
  81. },
  82. };
  83. },
  84. }, {
  85. title: '商品名称',
  86. dataIndex: 'name',
  87. key: 'name',
  88. render: renderContent,
  89. }, {
  90. title: '商品条码',
  91. dataIndex: 'barcode',
  92. key: 'barcode',
  93. render: renderContent,
  94. }, {
  95. title: '单价',
  96. dataIndex: 'price',
  97. key: 'price',
  98. className: 'col-money',
  99. render: renderContent,
  100. }, {
  101. title: '数量(件)',
  102. dataIndex: 'num',
  103. key: 'num',
  104. className: 'col-money',
  105. render: (text, row, index) => {
  106. if (index < basicGoods.length) {
  107. return text;
  108. }
  109. return <span style={{ fontWeight: 600 }}>{text}</span>;
  110. },
  111. }, {
  112. title: '金额',
  113. dataIndex: 'amount',
  114. key: 'amount',
  115. className: 'col-money',
  116. render: (text, row, index) => {
  117. if (index < basicGoods.length) {
  118. return text;
  119. }
  120. return <span style={{ fontWeight: 600 }}>{text}</span>;
  121. },
  122. }];
  123. return (
  124. <PageHeaderLayout title="基础详情页">
  125. <Card bordered={false}>
  126. <DescriptionList title="退款申请" style={{ marginBottom: 32 }}>
  127. <Description term="取货单号">1000000000</Description>
  128. <Description term="状态">已取货</Description>
  129. <Description term="销售单号">1234123421</Description>
  130. <Description term="子订单">3214321432</Description>
  131. </DescriptionList>
  132. <div className={styles.divider} />
  133. <DescriptionList title="用户信息" style={{ marginBottom: 32 }}>
  134. <Description term="用户姓名">付小小</Description>
  135. <Description term="联系电话">18100000000</Description>
  136. <Description term="常用快递">菜鸟仓储</Description>
  137. <Description term="取货地址">浙江省杭州市西湖区万塘路18号</Description>
  138. <Description term="备注">无</Description>
  139. </DescriptionList>
  140. <div className={styles.divider} />
  141. <div className={styles.title}>退货商品</div>
  142. <Table
  143. style={{ marginBottom: 24 }}
  144. pagination={false}
  145. loading={basicLoading}
  146. dataSource={goodsData}
  147. columns={goodsColumns}
  148. rowKey="id"
  149. />
  150. <div className={styles.title}>退货进度</div>
  151. <Table
  152. style={{ marginBottom: 16 }}
  153. pagination={false}
  154. loading={basicLoading}
  155. dataSource={basicProgress}
  156. columns={progressColumns}
  157. />
  158. </Card>
  159. </PageHeaderLayout>
  160. );
  161. }
  162. }