page.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 { TextbookFeedbackStatus, TextbookFeedbackTarget, TextbookSubject } from '../../../../Constant';
  12. import { User } from '../../../stores/user';
  13. const TextbookSubjectMap = getMap(TextbookSubject, 'value', 'label');
  14. const TextbookFeedbackStatusMap = getMap(TextbookFeedbackStatus, 'value', 'label');
  15. const TextbookFeedbackTargetMap = getMap(TextbookFeedbackTarget, 'value', 'label');
  16. export default class extends Page {
  17. init() {
  18. this.actionList = [{
  19. key: 'handle',
  20. type: 'danger',
  21. name: '批量采纳',
  22. needSelect: 1,
  23. }, {
  24. key: 'nohandle',
  25. type: 'danger',
  26. name: '批量不修改',
  27. needSelect: 1,
  28. }, {
  29. key: 'ignore',
  30. type: 'danger',
  31. name: '批量忽略',
  32. needSelect: 1,
  33. }];
  34. this.filterForm = [{
  35. key: 'questionSubject',
  36. type: 'select',
  37. allowClear: true,
  38. name: '单项',
  39. select: TextbookSubject,
  40. placeholder: '请选择',
  41. }, {
  42. key: 'target',
  43. type: 'select',
  44. allowClear: true,
  45. name: '反馈类型',
  46. select: TextbookFeedbackTarget,
  47. placeholder: '请选择',
  48. }, {
  49. key: 'status',
  50. type: 'select',
  51. name: '处理状态',
  52. allowClear: true,
  53. select: TextbookFeedbackStatus,
  54. number: true,
  55. placeholder: '请选择',
  56. }, {
  57. key: 'no',
  58. type: 'number',
  59. name: '序号',
  60. allowClear: true,
  61. number: true,
  62. placeholder: '请输入',
  63. }];
  64. this.columns = [{
  65. title: '单项',
  66. dataIndex: 'topic.textbookSubject',
  67. render: (text) => {
  68. return TextbookSubjectMap[text] || '';
  69. },
  70. }, {
  71. title: '反馈类型',
  72. dataIndex: 'target',
  73. render: (text) => {
  74. return TextbookFeedbackTargetMap[text] || '';
  75. },
  76. }, {
  77. title: '换库表',
  78. dataIndex: 'library',
  79. render: (text) => {
  80. return `${formatDate(text.startDate, 'YYYY-MM-DD')}-${text.endDate ? `${formatDate(text.endDate, 'YYYY-MM-DD')}` : '至今'}`;
  81. },
  82. }, {
  83. title: '题目序号',
  84. dataIndex: 'topic.no',
  85. }, {
  86. title: '关键词',
  87. dataIndex: 'topic.keyword',
  88. }, {
  89. title: '提交时间',
  90. dataIndex: 'createTime',
  91. render: (text) => {
  92. return formatDate(text, 'YYYY-MM-DD HH:mm:ss');
  93. },
  94. }, {
  95. title: '提交人',
  96. dataIndex: 'user.nickname',
  97. }, {
  98. title: '处理状态',
  99. dataIndex: 'status',
  100. render: (text) => {
  101. return TextbookFeedbackStatusMap[text] || text;
  102. },
  103. }, {
  104. title: '操作',
  105. dataIndex: 'handler',
  106. render: (text, record) => {
  107. return <div className="table-button">
  108. {(
  109. <a onClick={() => {
  110. this.detailAction(record);
  111. }}>查看</a>
  112. )}
  113. </div>;
  114. },
  115. }];
  116. }
  117. initData() {
  118. User.listTextbookFeedback(this.state.search).then(result => {
  119. this.setTableData(result.list, result.total);
  120. });
  121. }
  122. detailAction(row) {
  123. this.setState({ detail: row });
  124. }
  125. handleDetail() {
  126. const { detail } = this.state;
  127. asyncDelConfirm('采纳确认', '是否采纳选中记录?', () => {
  128. return User.editTextbookFeedback({ id: detail.id, status: 1 }).then(() => {
  129. asyncSMessage('操作成功!');
  130. this.setState({ detail: null });
  131. this.refresh();
  132. });
  133. });
  134. }
  135. nohandleDetail() {
  136. const { detail } = this.state;
  137. asyncDelConfirm('不处理确认', '是否不处理选中记录?', () => {
  138. return User.editTextbookFeedback({ id: detail.id, status: 3 }).then(() => {
  139. asyncSMessage('操作成功!');
  140. this.setState({ detail: null });
  141. this.refresh();
  142. });
  143. });
  144. }
  145. ignoreDetail() {
  146. const { detail } = this.state;
  147. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  148. return User.editTextbookFeedback({ id: detail.id, status: 2 }).then(() => {
  149. asyncSMessage('操作成功!');
  150. this.setState({ detail: null });
  151. this.refresh();
  152. });
  153. });
  154. }
  155. handleAction() {
  156. const { selectedKeys } = this.state;
  157. asyncDelConfirm('采纳确认', '是否采纳选中记录?', () => {
  158. return Promise.all(selectedKeys.map(row => User.editTextbookFeedback({ id: row, status: 1 }))).then(() => {
  159. asyncSMessage('操作成功!');
  160. this.refresh();
  161. });
  162. });
  163. }
  164. nohandleAction() {
  165. const { selectedKeys } = this.state;
  166. asyncDelConfirm('不修改确认', '是否不修改选中记录?', () => {
  167. return Promise.all(selectedKeys.map(row => User.editTextbookFeedback({ id: row, status: 3 }))).then(() => {
  168. asyncSMessage('操作成功!');
  169. this.refresh();
  170. });
  171. });
  172. }
  173. ignoreAction() {
  174. const { selectedKeys } = this.state;
  175. asyncDelConfirm('忽略确认', '是否忽略选中记录?', () => {
  176. return Promise.all(selectedKeys.map(row => User.editTextbookFeedback({ id: row, status: 2 }))).then(() => {
  177. asyncSMessage('操作成功!');
  178. this.refresh();
  179. });
  180. });
  181. }
  182. renderView() {
  183. return <Block flex>
  184. <FilterLayout
  185. show
  186. itemList={this.filterForm}
  187. data={this.state.search}
  188. onChange={data => {
  189. data.page = 1;
  190. this.search(data);
  191. }} />
  192. <ActionLayout
  193. itemList={this.actionList}
  194. selectedKeys={this.state.selectedKeys}
  195. onAction={key => this.onAction(key)}
  196. />
  197. <TableLayout
  198. select
  199. columns={this.tableSort(this.columns)}
  200. list={this.state.list}
  201. pagination={this.state.page}
  202. loading={this.props.core.loading}
  203. onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
  204. onSelect={(keys, rows) => this.tableSelect(keys, rows)}
  205. selectedKeys={this.state.selectedKeys}
  206. />
  207. {this.state.detail && <Modal visible title='勘误详情' footer={null} closable onCancel={() => {
  208. this.setState({ detail: null });
  209. }}>
  210. <p>单项:{TextbookSubjectMap[this.state.detail.topic.questionSubject]}</p>
  211. <p>换库表:{formatDate(this.state.detail.library.startDate, 'YYYY-MM-DD')}-{this.state.detail.library.endDate ? `${formatDate(this.state.detail.library.endDate, 'YYYY-MM-DD')}` : '至今'}</p>
  212. <p>反馈题目序号:{this.state.detail.topic.no}</p>
  213. <p>反馈内容{this.state.detail.content}</p>
  214. {!this.state.detail.status && <p><Button type="primary" onClick={() => {
  215. this.handleDetail();
  216. }}>采纳</Button><Button type="primary" onClick={() => {
  217. this.nohandleDetail();
  218. }}>无需修改</Button><Button type="ghost" onClick={() => {
  219. this.ignoreDetail();
  220. }}>忽略</Button></p>}
  221. </Modal>}
  222. </Block>;
  223. }
  224. }