page.js 4.2 KB

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