page.js 5.5 KB

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