page.js 3.4 KB

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