page.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import './index.less';
  4. import Page from '@src/containers/Page';
  5. import Block from '@src/components/Block';
  6. import FilterLayout from '@src/layouts/FilterLayout';
  7. // import ActionLayout from '@src/layouts/ActionLayout';
  8. import TableLayout from '@src/layouts/TableLayout';
  9. import { getMap, formatDate, formatMoney, bindSearch } from '@src/services/Tools';
  10. import { asyncSMessage, asyncForm } from '@src/services/AsyncTools';
  11. import { ProductTypeMain, RecordBuySource } from '../../../../Constant';
  12. import { User } from '../../../stores/user';
  13. const ProductTypeMainMap = getMap(ProductTypeMain, 'value', 'label');
  14. const RecordBuySourceMap = getMap(RecordBuySource, 'value', 'label');
  15. export default class extends Page {
  16. init() {
  17. this.itemList = [{
  18. key: 'id',
  19. type: 'hidden',
  20. }, {
  21. key: 'transactionNo',
  22. type: 'input',
  23. required: true,
  24. name: '支付流水号',
  25. }];
  26. this.filterF = null;
  27. this.filterForm = [{
  28. key: 'userId',
  29. type: 'select',
  30. allowClear: true,
  31. name: '用户',
  32. select: [],
  33. number: true,
  34. placeholder: '请输入',
  35. }, {
  36. key: 'productType',
  37. type: 'select',
  38. allowClear: true,
  39. name: '种类',
  40. select: ProductTypeMain,
  41. }, {
  42. key: 'payMethod',
  43. type: 'select',
  44. allowClear: true,
  45. name: '购买方式',
  46. select: RecordBuySource,
  47. }, {
  48. key: 'orderId',
  49. type: 'input',
  50. allowClear: true,
  51. name: '订单id',
  52. }];
  53. this.columns = [{
  54. title: '订单号',
  55. dataIndex: 'id',
  56. }, {
  57. title: '下单时间',
  58. dataIndex: 'createTime',
  59. render: (text) => {
  60. return text ? formatDate(text, 'YYYY-MM-DD HH:mm:ss') : '';
  61. },
  62. }, {
  63. title: '用户姓名',
  64. dataIndex: 'user.nickname',
  65. }, {
  66. title: '种类',
  67. dataIndex: 'productTypes',
  68. render: (text) => {
  69. return (text || []).map(row => `${ProductTypeMainMap[row]}`).join(', ');
  70. },
  71. }, {
  72. title: '支付金额',
  73. dataIndex: 'money',
  74. render: (text, record) => {
  75. return `${formatMoney(text)}${text !== record.originMoney ? `(${formatMoney(record.originMoney)})` : ''}`;
  76. },
  77. }, {
  78. title: '支付方式',
  79. dataIndex: 'payMethod',
  80. render: (text) => {
  81. return RecordBuySourceMap[text] || '';
  82. },
  83. }, {
  84. title: '支付时间',
  85. dataIndex: 'payTime',
  86. render: (text) => {
  87. return text ? formatDate(text, 'YYYY-MM-DD HH:mm:ss') : '';
  88. },
  89. }, {
  90. title: '操作',
  91. dataIndex: 'handler',
  92. render: (text, record) => {
  93. return <div className="table-button">
  94. <Link to={`/user/order/detail/${record.id}`}>查看</Link>
  95. {record.payStatus === 0 && (
  96. <a onClick={() => {
  97. this.finishAction(record);
  98. }}>确认收款</a>
  99. )}
  100. </div>;
  101. },
  102. }];
  103. bindSearch(this.filterForm, 'userId', this, (search) => {
  104. return User.list(search);
  105. }, (row) => {
  106. return {
  107. title: `${row.nickname}(${row.mobile})`,
  108. value: row.id,
  109. };
  110. }, this.state.search.userId ? Number(this.state.search.userId) : null, null);
  111. }
  112. initData() {
  113. User.listOrder(Object.assign({}, this.state.search)).then(result => {
  114. this.setTableData(result.list, result.total);
  115. });
  116. }
  117. finishAction(row) {
  118. asyncForm('确认收款', this.itemList, row, data => {
  119. return User.finishOrder(data).then(() => {
  120. asyncSMessage('支付成功!');
  121. this.refresh();
  122. });
  123. }).then(component => {
  124. this.formF = component;
  125. });
  126. }
  127. renderView() {
  128. return <Block flex>
  129. <FilterLayout
  130. show
  131. ref={(ref) => { this.filterF = ref; }}
  132. itemList={this.filterForm}
  133. data={this.state.search}
  134. onChange={data => {
  135. data.page = 1;
  136. this.search(data);
  137. }} />
  138. <TableLayout
  139. columns={this.tableSort(this.columns)}
  140. list={this.state.list}
  141. pagination={this.state.page}
  142. loading={this.props.core.loading}
  143. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  144. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  145. selectedKeys={this.state.selectedKeys}
  146. />
  147. </Block>;
  148. }
  149. }