page.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import React from 'react';
  2. import { Modal, Button } from 'antd';
  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 } from '@src/services/Tools';
  10. import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools';
  11. import { FeedbackStatus } from '../../../../Constant';
  12. import { User } from '../../../stores/user';
  13. const FeedbackStatusMap = getMap(FeedbackStatus, 'value', 'label');
  14. export default class extends Page {
  15. init() {
  16. this.actionList = [{
  17. key: 'handle',
  18. type: 'danger',
  19. name: '批量采纳',
  20. needSelect: 1,
  21. }, {
  22. key: 'nohandle',
  23. type: 'danger',
  24. name: '批量不修改',
  25. needSelect: 1,
  26. }, {
  27. key: 'ignore',
  28. type: 'danger',
  29. name: '批量忽略',
  30. needSelect: 1,
  31. }];
  32. this.filterForm = [{
  33. key: 'status',
  34. type: 'select',
  35. name: '处理状态',
  36. allowClear: true,
  37. select: FeedbackStatus,
  38. number: true,
  39. placeholder: '请选择',
  40. }];
  41. this.columns = [{
  42. title: '考场',
  43. dataIndex: 'room.title',
  44. }, {
  45. title: '提交时间',
  46. dataIndex: 'createTime',
  47. render: (text) => {
  48. return formatDate(text, 'YYYY-MM-DD HH:mm:ss');
  49. },
  50. }, {
  51. title: '提交人',
  52. dataIndex: 'user.nickname',
  53. }, {
  54. title: '处理状态',
  55. dataIndex: 'status',
  56. render: (text) => {
  57. return FeedbackStatusMap[text] || text;
  58. },
  59. }, {
  60. title: '操作',
  61. dataIndex: 'handler',
  62. render: (text, record) => {
  63. return <div className="table-button">
  64. {(
  65. <a onClick={() => {
  66. this.detailAction(record);
  67. }}>查看</a>
  68. )}
  69. </div>;
  70. },
  71. }];
  72. }
  73. initData() {
  74. User.listReadyRoomFeedback(this.state.search).then(result => {
  75. this.setTableData(result.list, result.total);
  76. });
  77. }
  78. detailAction(row) {
  79. this.setState({ detail: row });
  80. }
  81. handleDetail() {
  82. const { detail } = this.state;
  83. asyncDelConfirm('采纳确认', '是否采纳选中记录?', () => {
  84. return User.editReadyRoomFeedback({ id: detail.id, status: 1 }).then(() => {
  85. asyncSMessage('操作成功!');
  86. this.setState({ detail: null });
  87. this.refresh();
  88. });
  89. });
  90. }
  91. nohandleDetail() {
  92. const { detail } = this.state;
  93. asyncDelConfirm('不处理确认', '是否不处理选中记录?', () => {
  94. return User.editReadyRoomFeedback({ id: detail.id, status: 3 }).then(() => {
  95. asyncSMessage('操作成功!');
  96. this.setState({ detail: null });
  97. this.refresh();
  98. });
  99. });
  100. }
  101. ignoreDetail() {
  102. const { detail } = this.state;
  103. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  104. return User.editReadyRoomFeedback({ id: detail.id, status: 2 }).then(() => {
  105. asyncSMessage('操作成功!');
  106. this.setState({ detail: null });
  107. this.refresh();
  108. });
  109. });
  110. }
  111. handleAction() {
  112. const { selectedKeys } = this.state;
  113. asyncDelConfirm('采纳确认', '是否采纳选中记录?', () => {
  114. return Promise.all(selectedKeys.map(row => User.editReadyRoomFeedback({ id: row, status: 1 }))).then(() => {
  115. asyncSMessage('操作成功!');
  116. this.refresh();
  117. });
  118. });
  119. }
  120. nohandleAction() {
  121. const { selectedKeys } = this.state;
  122. asyncDelConfirm('不修改确认', '是否不修改选中记录?', () => {
  123. return Promise.all(selectedKeys.map(row => User.editReadyRoomFeedback({ id: row, status: 3 }))).then(() => {
  124. asyncSMessage('操作成功!');
  125. this.refresh();
  126. });
  127. });
  128. }
  129. ignoreAction() {
  130. const { selectedKeys } = this.state;
  131. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  132. return Promise.all(selectedKeys.map(row => User.editReadyRoomFeedback({ id: row, status: 2 }))).then(() => {
  133. asyncSMessage('操作成功!');
  134. this.refresh();
  135. });
  136. });
  137. }
  138. renderView() {
  139. return <Block flex>
  140. <FilterLayout
  141. show
  142. itemList={this.filterForm}
  143. data={this.state.search}
  144. onChange={data => {
  145. data.page = 1;
  146. this.search(data);
  147. }} />
  148. <ActionLayout
  149. itemList={this.actionList}
  150. selectedKeys={this.state.selectedKeys}
  151. onAction={key => this.onAction(key)}
  152. />
  153. <TableLayout
  154. select
  155. columns={this.tableSort(this.columns)}
  156. list={this.state.list}
  157. pagination={this.state.page}
  158. loading={this.props.core.loading}
  159. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  160. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  161. selectedKeys={this.state.selectedKeys}
  162. />
  163. {this.state.detail && <Modal visible title='补充详情' footer={null} closable onCancel={() => {
  164. this.setState({ detail: null });
  165. }}>
  166. <p>考场:{this.state.detail.room.title}</p>
  167. <p>补充内容:{this.state.detail.content}</p>
  168. {!this.state.detail.status && <p><Button type="primary" onClick={() => {
  169. this.handleDetail();
  170. }}>采纳</Button><Button type="primary" onClick={() => {
  171. this.nohandleDetail();
  172. }}>无需修改</Button><Button type="ghost" onClick={() => {
  173. this.ignoreDetail();
  174. }}>忽略</Button></p>}
  175. </Modal>}
  176. </Block>;
  177. }
  178. }