page.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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, formatMoney, formatDate } from '@src/services/Tools';
  10. import { SwitchSelect, ServiceKey, PassSelect } from '../../../../Constant';
  11. import { User } from '../../../stores/user';
  12. const SwitchSelectMap = getMap(SwitchSelect, 'value', 'label');
  13. const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
  14. const PassSelectMap = getMap(PassSelect, 'value', 'label');
  15. export default class extends Page {
  16. constructor(props) {
  17. super(props);
  18. this.filterF = null;
  19. }
  20. init() {
  21. this.filterForm = [{
  22. key: 'keyword',
  23. type: 'input',
  24. name: 'ID/手机号',
  25. placeholder: '请输入',
  26. },
  27. {
  28. key: 'real',
  29. type: 'select',
  30. allowClear: true,
  31. name: '实名认证',
  32. select: PassSelect,
  33. placeholder: '请选择',
  34. number: true,
  35. },
  36. {
  37. key: 'time',
  38. type: 'daterange',
  39. name: '注册时间',
  40. }];
  41. this.columns = [{
  42. title: 'ID',
  43. dataIndex: 'id',
  44. },
  45. {
  46. title: '手机号',
  47. dataIndex: 'mobile',
  48. },
  49. {
  50. title: '注册时间',
  51. dataIndex: 'createTime',
  52. render: (text) => {
  53. return formatDate(text);
  54. },
  55. },
  56. {
  57. title: '实名认证',
  58. dataIndex: 'realStatus',
  59. render: (text) => {
  60. return PassSelectMap[text ? 1 : 0];
  61. },
  62. },
  63. {
  64. title: '备考信息',
  65. dataIndex: 'prepareStatus',
  66. render: (text) => {
  67. return SwitchSelectMap[text ? 1 : 0];
  68. },
  69. }, {
  70. title: '邀请人数',
  71. dataIndex: 'inviteNumber',
  72. }, {
  73. title: '服务中',
  74. dataIndex: 'services',
  75. render: (text) => {
  76. return (text || []).map(row => ServiceKeyMap[row.service]).join(', ');
  77. },
  78. }, {
  79. title: '消费金额',
  80. sorter: true,
  81. dataIndex: 'totalMoney',
  82. render: (text) => {
  83. return formatMoney(text);
  84. },
  85. }, {
  86. title: '操作',
  87. dataIndex: 'handler',
  88. render: (text, record) => {
  89. return <div className="table-button">
  90. {(
  91. <Link to={`/user/detail/${record.id}`}>查看</Link>
  92. )}
  93. </div>;
  94. },
  95. }];
  96. }
  97. initData() {
  98. const { search } = this.state;
  99. const data = Object.assign({}, search);
  100. if (data.time) {
  101. data.startTime = data.time[0] || '';
  102. data.endTime = data.time[1] || '';
  103. }
  104. User.list(data).then(result => {
  105. this.setTableData(result.list, result.total);
  106. });
  107. }
  108. renderView() {
  109. return <Block flex>
  110. <FilterLayout
  111. show
  112. itemList={this.filterForm}
  113. data={this.state.search}
  114. onChange={data => {
  115. if (data.time.length > 0) {
  116. data.time = [data.time[0].format('YYYY-MM-DD HH:mm:ss'), data.time[1].format('YYYY-MM-DD HH:mm:ss')];
  117. }
  118. this.search(data);
  119. }}
  120. ref={(ref) => {
  121. if (ref) this.filterF = ref;
  122. }} />
  123. {/* <ActionLayout
  124. itemList={this.actionList}
  125. selectedKeys={this.state.selectedKeys}
  126. onAction={key => this.onAction(key)}
  127. /> */}
  128. <TableLayout
  129. // select
  130. columns={this.tableSort(this.columns)}
  131. list={this.state.list}
  132. pagination={this.state.page}
  133. loading={this.props.core.loading}
  134. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  135. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  136. selectedKeys={this.state.selectedKeys}
  137. />
  138. </Block>;
  139. }
  140. }