page.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 && '已忽略'}
  75. {record.isAlert && '已警告'}
  76. {record.isAlert && record.user.isFrozen && (
  77. <a onClick={() => {
  78. this.noFrozenAction(record);
  79. }}>取消封禁</a>
  80. )}
  81. {!record.isIgnore && !record.isAlert && (
  82. <a onClick={() => {
  83. this.alertAction(record);
  84. }}>警告</a>
  85. )}
  86. {!record.isIgnore && !record.isAlert && (
  87. <a onClick={() => {
  88. this.frozenAction(record);
  89. }}>封禁</a>
  90. )}
  91. {!record.isIgnore && !record.isAlert && (
  92. <a onClick={() => {
  93. this.ignoreAction(record);
  94. }}>忽略</a>
  95. )}
  96. </div>;
  97. },
  98. }];
  99. bindSearch(this.filterForm, 'userId', this, (search) => {
  100. return User.list(search);
  101. }, (row) => {
  102. return {
  103. title: `${row.nickname}(${row.mobile})`,
  104. value: row.id,
  105. };
  106. }, this.state.search.userId ? Number(this.state.search.userId) : null, null);
  107. }
  108. initData() {
  109. User.listAbnormal(this.state.search).then(result => {
  110. this.setTableData(result.list, result.total);
  111. });
  112. }
  113. alertAction(row) {
  114. asyncDelConfirm('警告确认', '是否警告选中记录?', () => {
  115. return User.handleAbnormal({ id: row.id, isAlert: 1 }).then(() => {
  116. asyncSMessage('操作成功!');
  117. this.refresh();
  118. });
  119. });
  120. }
  121. ignoreAction(row) {
  122. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  123. return User.handleAbnormal({ id: row.id, isIgnore: 1 }).then(() => {
  124. asyncSMessage('操作成功!');
  125. this.refresh();
  126. });
  127. });
  128. }
  129. frozenAction(row) {
  130. asyncDelConfirm('封禁确认', '是否封禁选中用户?', () => {
  131. return User.frozen({ id: row.userId }).then(() => {
  132. asyncSMessage('操作成功!');
  133. this.refresh();
  134. });
  135. });
  136. }
  137. noFrozenAction(row) {
  138. asyncDelConfirm('取消封禁确认', '是否取消封禁选中用户?', () => {
  139. return User.noFrozen({ id: row.userId }).then(() => {
  140. asyncSMessage('操作成功!');
  141. this.refresh();
  142. });
  143. });
  144. }
  145. renderView() {
  146. return <Block flex>
  147. <FilterLayout
  148. show
  149. itemList={this.filterForm}
  150. data={this.state.search}
  151. onChange={data => {
  152. if (data.time.length > 0) {
  153. data.time = [data.time[0].format('YYYY-MM-DD HH:mm:ss'), data.time[1].format('YYYY-MM-DD HH:mm:ss')];
  154. }
  155. this.search(data);
  156. }} />
  157. {/* <ActionLayout
  158. itemList={this.actionList}
  159. selectedKeys={this.state.selectedKeys}
  160. onAction={key => this.onAction(key)}
  161. /> */}
  162. <TableLayout
  163. select
  164. columns={this.tableSort(this.columns)}
  165. list={this.state.list}
  166. pagination={this.state.page}
  167. loading={this.props.core.loading}
  168. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  169. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  170. selectedKeys={this.state.selectedKeys}
  171. />
  172. </Block>;
  173. }
  174. }