page.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import React from 'react';
  2. import './index.less';
  3. import Page from '@src/containers/Page';
  4. import Block from '@src/components/Block';
  5. import FilterLayout from '@src/layouts/FilterLayout';
  6. // import ActionLayout from '@src/layouts/ActionLayout';
  7. import TableLayout from '@src/layouts/TableLayout';
  8. import { bindSearch, formatDate } from '@src/services/Tools';
  9. import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools';
  10. // import { QuestionType, AskStatus, MoneyRange, SwitchSelect, AskTarget } from '../../../../Constant';
  11. import { User } from '../../../stores/user';
  12. export default class extends Page {
  13. init() {
  14. this.filterForm = [{
  15. key: 'userId',
  16. type: 'select',
  17. allowClear: true,
  18. name: '用户',
  19. select: [],
  20. number: true,
  21. placeholder: '请输入',
  22. }, {
  23. key: 'totalAlert',
  24. type: 'number',
  25. allowClear: true,
  26. name: '实名认证',
  27. number: true,
  28. }, {
  29. key: 'time',
  30. type: 'daterange',
  31. name: '注册时间',
  32. }];
  33. this.columns = [{
  34. title: '登录时间',
  35. dataIndex: 'createTime',
  36. render: (text) => {
  37. return formatDate(text);
  38. },
  39. }, {
  40. title: '用户id',
  41. dataIndex: 'user.id',
  42. }, {
  43. title: '手机号',
  44. dataIndex: 'user.mobile',
  45. }, {
  46. title: '昵称',
  47. dataIndex: 'user.nickname',
  48. }, {
  49. title: '注册时间',
  50. dataIndex: 'user.createTime',
  51. render: (text) => {
  52. return formatDate(text);
  53. },
  54. }, {
  55. title: '注册ip',
  56. dataIndex: 'user.registerIp',
  57. }, {
  58. title: '注册地',
  59. dataIndex: 'user.registerCity',
  60. }, {
  61. title: '本次登录ip',
  62. dataIndex: 'loginIp',
  63. }, {
  64. title: '本次登录地',
  65. dataIndex: 'loginCity',
  66. }, {
  67. title: '累计警告次数',
  68. dataIndex: 'user.totalAlert',
  69. }, {
  70. title: '操作',
  71. dataIndex: 'handler',
  72. render: (text, record) => {
  73. return <div className="table-button">
  74. {!record.isIgnore && !record.isAlert && (
  75. <a onClick={() => {
  76. this.alertAction(record);
  77. }}>警告</a>
  78. )}
  79. {!record.isIgnore && !record.isAlert && (
  80. <a onClick={() => {
  81. this.frozenAction(record);
  82. }}>封禁</a>
  83. )}
  84. {!record.isIgnore && !record.isAlert && (
  85. <a onClick={() => {
  86. this.ignoreAction(record);
  87. }}>忽略</a>
  88. )}
  89. </div>;
  90. },
  91. }];
  92. bindSearch(this.filterForm, 'userId', this, (search) => {
  93. return User.list(search);
  94. }, (row) => {
  95. return {
  96. title: `${row.nickname}(${row.mobile})`,
  97. value: row.id,
  98. };
  99. }, this.state.search.userId ? Number(this.state.search.userId) : null, null);
  100. }
  101. initData() {
  102. User.listAbnormal(this.state.search).then(result => {
  103. this.setTableData(result.list, result.total);
  104. });
  105. }
  106. alertAction(row) {
  107. asyncDelConfirm('警告确认', '是否警告选中记录?', () => {
  108. return User.handleAbnormal({ id: row.id, isAlert: 1 }).then(() => {
  109. asyncSMessage('操作成功!');
  110. this.refresh();
  111. });
  112. });
  113. }
  114. ignoreAction(row) {
  115. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  116. return User.handleAbnormal({ id: row.id, isIgnore: 1 }).then(() => {
  117. asyncSMessage('操作成功!');
  118. this.refresh();
  119. });
  120. });
  121. }
  122. frozenAction(row) {
  123. asyncDelConfirm('封禁确认', '是否封禁选中用户?', () => {
  124. return User.frozen({ id: row.userId }).then(() => {
  125. asyncSMessage('操作成功!');
  126. this.refresh();
  127. });
  128. });
  129. }
  130. renderView() {
  131. return <Block flex>
  132. <FilterLayout
  133. show
  134. itemList={this.filterForm}
  135. data={this.state.search}
  136. onChange={data => {
  137. if (data.time.length > 0) {
  138. data.time = [data.time[0].format('YYYY-MM-DD HH:mm:ss'), data.time[1].format('YYYY-MM-DD HH:mm:ss')];
  139. }
  140. this.search(data);
  141. }} />
  142. {/* <ActionLayout
  143. itemList={this.actionList}
  144. selectedKeys={this.state.selectedKeys}
  145. onAction={key => this.onAction(key)}
  146. /> */}
  147. <TableLayout
  148. select
  149. columns={this.tableSort(this.columns)}
  150. list={this.state.list}
  151. pagination={this.state.page}
  152. loading={this.props.core.loading}
  153. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  154. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  155. selectedKeys={this.state.selectedKeys}
  156. />
  157. </Block>;
  158. }
  159. }