1
0

page.js 5.6 KB

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