nationwide.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. import React, { Component } from "react";
  2. import {
  3. Button,
  4. message,
  5. Spin,
  6. Upload,
  7. Tabs,
  8. Table,
  9. Modal,
  10. } from "antd";
  11. import $ from "jquery/src/ajax";
  12. import { ShowModal } from "@/tools";
  13. import moment from "moment";
  14. import ShowModalDiv from "@/showModal.jsx";
  15. import './index.less';
  16. const { TabPane } = Tabs;
  17. class Complete extends Component {
  18. constructor(props) {
  19. super(props);
  20. this.state = {
  21. type: 0,
  22. Loading: false,
  23. columns: [
  24. {
  25. title: "姓名",
  26. dataIndex: "name",
  27. key: "name",
  28. width: 130,
  29. },
  30. {
  31. title: "是否有效",
  32. dataIndex: "povertyStatus",
  33. key: "povertyStatus",
  34. width: 130,
  35. },
  36. {
  37. title: "",
  38. dataIndex: "op",
  39. key: "op",
  40. },
  41. ],
  42. dataSource: [],
  43. totalcount: 0,
  44. effectiveCount: 0,
  45. id: "",
  46. upLoad: {
  47. customRequest: (options) => {
  48. this.setState({
  49. Loading: true,
  50. })
  51. let params = new FormData();
  52. params.append("file", options.file);
  53. $.ajax({
  54. method: "post",
  55. url: globalConfig.context + "/open/selectFlag",
  56. async: true,
  57. cache: false,
  58. contentType: false,
  59. processData: false,
  60. data: params
  61. }).done(
  62. function (data) {
  63. this.setState({
  64. Loading: false,
  65. })
  66. if (data.error.length === 0) {
  67. let info = data.data
  68. this.setState({
  69. dataSource: info.list,
  70. totalcount: info.totalcount,
  71. effectiveCount: info.effectiveCount,
  72. id: info.id,
  73. })
  74. } else {
  75. message.warning(data.error[0].message);
  76. }
  77. }.bind(this)
  78. ).always(
  79. function () {
  80. this.setState({
  81. Loading: false,
  82. });
  83. }.bind(this)
  84. );
  85. },
  86. name: "file",
  87. action: globalConfig.context + "/api/user/channel/import",
  88. },
  89. };
  90. this.exportExec = this.exportExec.bind(this);
  91. this.onSwitch = this.onSwitch.bind(this);
  92. }
  93. componentWillMount() {
  94. }
  95. // 导出
  96. exportExec() {
  97. message.config({
  98. duration: 20,
  99. });
  100. let loading = message.loading("下载中...");
  101. this.setState({
  102. Loading: true,
  103. });
  104. let data = {
  105. id: this.state.id,
  106. type: this.state.type,
  107. };
  108. $.ajax({
  109. method: "get",
  110. dataType: "json",
  111. crossDomain: false,
  112. url: globalConfig.context + "/open/selectPovertyFlagById/export",
  113. data,
  114. success: function (data) {
  115. if (data.error.length === 0) {
  116. this.download(data.data);
  117. } else {
  118. message.warning(data.error[0].message);
  119. }
  120. }.bind(this),
  121. }).always(
  122. function () {
  123. loading();
  124. this.setState({
  125. Loading: false,
  126. });
  127. }.bind(this)
  128. );
  129. }
  130. // 导出下载
  131. download(fileName) {
  132. window.location.href =
  133. globalConfig.context + "/open/download?fileName=" + fileName;
  134. }
  135. // 下载模板
  136. downLoadFile() {
  137. window.open(globalConfig.context + '/open/downloadPovertyTemplate')
  138. }
  139. // 有效数据切换
  140. onSwitch() {
  141. this.setState({
  142. Loading: true,
  143. });
  144. $.ajax({
  145. method: "get",
  146. dataType: "json",
  147. crossDomain: false,
  148. url: globalConfig.context + "/open/selectPovertyFlagById",
  149. data: {
  150. id: this.state.id,
  151. type: this.state.type == 0 ? 1 : 0,
  152. },
  153. success: function (data) {
  154. this.setState({
  155. Loading: false,
  156. });
  157. if (data.error.length === 0) {
  158. this.setState({
  159. type: this.state.type == 0 ? 1 : 0,
  160. dataSource: data.data.list,
  161. })
  162. } else {
  163. message.warning(data.error[0].message);
  164. }
  165. }.bind(this),
  166. }).always(
  167. function () {
  168. this.setState({
  169. Loading: false,
  170. });
  171. }.bind(this)
  172. );
  173. }
  174. render() {
  175. const { columns, dataSource, totalcount, effectiveCount, id, type } = this.state;
  176. return (
  177. <div className="user-content">
  178. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  179. <div className="content-title" style={{ marginBottom: 10 }}>
  180. <span style={{ fontWeight: 900, fontSize: 16 }}>建档立卡脱贫户-批量查询</span>
  181. </div>
  182. <Tabs defaultActiveKey="1">
  183. <TabPane tab="操作" key="1">
  184. <div
  185. style={{
  186. width: "100%",
  187. paddingBottom: 10,
  188. display: "flex",
  189. flexDirection: "row",
  190. justifyContent: "space-between",
  191. }}
  192. >
  193. <div
  194. style={{
  195. display: "flex"
  196. }}
  197. >
  198. <Upload {...this.state.upLoad} disabled={this.state.Loading}>
  199. <Button
  200. type="primary"
  201. onClick={() => {
  202. }}
  203. style={{ marginLeft: "10px" }}
  204. >
  205. 导入查询数据
  206. </Button>
  207. </Upload>
  208. <Button
  209. type="primary"
  210. onClick={this.downLoadFile}
  211. style={{ marginLeft: "10px" }}
  212. >
  213. 下载批量查询模板
  214. </Button>
  215. <Button
  216. type="primary"
  217. loading={this.state.Loading}
  218. onClick={this.exportExec}
  219. style={{ marginLeft: "10px" }}
  220. disabled={!id}
  221. >
  222. 导出EXCEL
  223. </Button>
  224. </div>
  225. <div>
  226. <span>数据统计:有效数据<span style={{ color: "red" }}>{effectiveCount}</span>条,共<span style={{ color: "red" }}>{totalcount}</span>条数据</span>
  227. <Button
  228. type="primary"
  229. onClick={this.onSwitch}
  230. style={{ margin: "0 10px" }}
  231. disabled={!id}
  232. >
  233. {type == 0 ? "仅显示有效数据" : "显示所有数据"}
  234. </Button>
  235. </div>
  236. </div>
  237. </TabPane>
  238. </Tabs>
  239. <div className="patent-table">
  240. <Spin spinning={this.state.Loading}>
  241. <Table
  242. bordered
  243. size="middle"
  244. columns={columns}
  245. dataSource={dataSource}
  246. />
  247. </Spin>
  248. </div>
  249. </div>
  250. );
  251. }
  252. }
  253. export default Complete;