applyManage.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. import React from 'react';
  2. import { Icon, Button, Select, Spin, Table, message } from 'antd';
  3. import { provinceArr } from '../../../dataDic.js';
  4. import { companySearch, getTechnologyState } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import './technology.less';
  8. import ApplyAdd from './applyAdd.jsx';
  9. import ApplyChange from './applyChange.jsx';
  10. const ApplyManage = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admin/techproject/listTechProject",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. province: this.state.province,
  25. unitName: this.state.unitName,
  26. },
  27. success: function (data) {
  28. if (data.error.length || !data.data || !data.data.list) {
  29. message.warning(data.error[0].message);
  30. return;
  31. }
  32. for (let i = 0; i < data.data.list.length; i++) {
  33. let thisdata = data.data.list[i];
  34. switch (thisdata.contacts) {
  35. case 1:
  36. thisdata.contacts = thisdata.firstContacts;
  37. break;
  38. case 2:
  39. thisdata.contacts = thisdata.secondContacts;
  40. break;
  41. case 3:
  42. thisdata.contacts = thisdata.thirdContacts;
  43. break;
  44. }
  45. this.state.data.push({
  46. key: i,
  47. pid: thisdata.id,
  48. uid: thisdata.uid,
  49. serialNumber: thisdata.serialNumber,
  50. province: thisdata.province,
  51. unitName: thisdata.unitName,
  52. contacts: thisdata.contacts,
  53. projectName: thisdata.projectName,
  54. projectCatagory: thisdata.projectCatagory,
  55. techField: thisdata.techField,
  56. state: thisdata.state,
  57. createTime: thisdata.createTimeFormattedDate,
  58. website: thisdata.website,
  59. accountNumber: thisdata.accountNumber,
  60. password: thisdata.password,
  61. consultant: thisdata.consultant
  62. });
  63. };
  64. this.state.pagination.current = data.data.pageNo;
  65. this.state.pagination.total = data.data.totalCount;
  66. this.setState({
  67. dataSource: this.state.data,
  68. pagination: this.state.pagination
  69. });
  70. }.bind(this),
  71. }).always(function () {
  72. this.setState({
  73. loading: false
  74. });
  75. }.bind(this));
  76. },
  77. getAuthorList() {
  78. this.setState({
  79. loading: true
  80. });
  81. $.ajax({
  82. method: "get",
  83. dataType: "json",
  84. crossDomain: false,
  85. url: globalConfig.context + "/api/admin/techproject/getPrincipal",
  86. success: function (data) {
  87. if (!data.data) {
  88. if (data.error && data.error.length) {
  89. message.warning(data.error[0].message);
  90. };
  91. return;
  92. };
  93. let _me = this;
  94. for (var item in data.data) {
  95. _me.state.authorOption.push(
  96. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  97. )
  98. };
  99. }.bind(this),
  100. }).always(function () {
  101. this.setState({
  102. loading: false
  103. });
  104. }.bind(this));
  105. },
  106. getConsultant() {
  107. this.setState({
  108. loading: true
  109. });
  110. $.ajax({
  111. method: "get",
  112. dataType: "json",
  113. crossDomain: false,
  114. url: globalConfig.context + "/api/admin/techproject/getConsultant",
  115. success: function (data) {
  116. if (!data.data) {
  117. if (data.error && data.error.length) {
  118. message.warning(data.error[0].message);
  119. };
  120. return;
  121. };
  122. let _me = this;
  123. for (var item in data.data) {
  124. _me.state.consultantOption.push(
  125. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  126. )
  127. };
  128. }.bind(this),
  129. }).always(function () {
  130. this.setState({
  131. loading: false
  132. });
  133. }.bind(this));
  134. },
  135. getCompanyList() {
  136. this.setState({
  137. loading: true
  138. });
  139. $.ajax({
  140. method: "get",
  141. dataType: "json",
  142. crossDomain: false,
  143. url: globalConfig.context + "/api/admin/getUnitNames",
  144. success: function (data) {
  145. if (!data.data) {
  146. if (data.error && data.error.length) {
  147. message.warning(data.error[0].message);
  148. }
  149. return;
  150. };
  151. let _me = this;
  152. for (var item in data.data) {
  153. _me.state.companyOption.push(
  154. <Select.Option value={data.data[item]} key={data.data[item]}>{data.data[item]}</Select.Option>
  155. )
  156. _me.state.companyAddOption.push(
  157. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  158. )
  159. };
  160. }.bind(this),
  161. }).always(function () {
  162. this.setState({
  163. loading: false
  164. });
  165. }.bind(this));
  166. },
  167. getInitialState() {
  168. return {
  169. provinceOption: [],
  170. companyOption: [],
  171. companyAddOption: [],
  172. authorOption: [],
  173. consultantOption:[],
  174. selectedRows: [],
  175. selectedRowKeys: [],
  176. loading: false,
  177. showAdd: false,
  178. showDesc: false,
  179. pagination: {
  180. defaultCurrent: 1,
  181. defaultPageSize: 10,
  182. showQuickJumper: true,
  183. pageSize: 10,
  184. onChange: function (page) {
  185. this.loadData(page);
  186. }.bind(this),
  187. showTotal: function (total) {
  188. return '共' + total + '条数据';
  189. }
  190. },
  191. columns: [
  192. {
  193. title: '编号',
  194. dataIndex: 'serialNumber',
  195. key: 'serialNumber'
  196. }, {
  197. title: '省份',
  198. dataIndex: 'province',
  199. key: 'province'
  200. }, {
  201. title: '公司',
  202. dataIndex: 'unitName',
  203. key: 'unitName'
  204. }, {
  205. title: '联系方式',
  206. dataIndex: 'contacts',
  207. key: 'contacts'
  208. }, {
  209. title: '项目名称',
  210. dataIndex: 'projectName',
  211. key: 'projectName'
  212. }, {
  213. title: '项目类型',
  214. dataIndex: 'projectCatagory',
  215. key: 'projectCatagory'
  216. }, {
  217. title: '技术领域',
  218. dataIndex: 'techField',
  219. key: 'techField'
  220. }, {
  221. title: '项目情况',
  222. dataIndex: 'state',
  223. key: 'state',
  224. render: text => { return getTechnologyState(text) },
  225. }, {
  226. title: '派单日',
  227. dataIndex: 'createTime',
  228. key: 'createTime'
  229. }, {
  230. title: '网址',
  231. dataIndex: 'website',
  232. key: 'website'
  233. }, {
  234. title: '用户名',
  235. dataIndex: 'accountNumber',
  236. key: 'accountNumber'
  237. }, {
  238. title: '密码',
  239. dataIndex: 'password',
  240. key: 'password'
  241. }, {
  242. title: '负责人',
  243. dataIndex: 'consultant',
  244. key: 'consultant'
  245. }
  246. ],
  247. dataSource: []
  248. };
  249. },
  250. componentWillMount() {
  251. let _me = this;
  252. provinceArr.map(function (item) {
  253. _me.state.provinceOption.push(
  254. <Select.Option value={item} key={item}>{item}</Select.Option>
  255. )
  256. });
  257. this.loadData();
  258. this.getAuthorList();
  259. this.getCompanyList();
  260. this.getConsultant();
  261. },
  262. tableRowClick(record, index) {
  263. this.state.RowData = record;
  264. this.setState({
  265. showDesc: true
  266. });
  267. },
  268. addClick() {
  269. this.setState({
  270. showAdd: true
  271. });
  272. },
  273. delectRow() {
  274. let deletedIds = [];
  275. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  276. let rowItem = this.state.selectedRows[idx];
  277. if (rowItem.pid) {
  278. deletedIds.push(rowItem.pid)
  279. }
  280. }
  281. this.setState({
  282. selectedRowKeys: [],
  283. loading: deletedIds.length > 0
  284. });
  285. $.ajax({
  286. method: "POST",
  287. dataType: "json",
  288. crossDomain: false,
  289. url: globalConfig.context + "/api/admin/techproject/deleteTechProject",
  290. data: {
  291. ids: deletedIds
  292. }
  293. }).done(function (data) {
  294. if (!data.error.length) {
  295. message.success('保存成功!');
  296. this.setState({
  297. loading: false,
  298. });
  299. } else {
  300. message.warning(data.error[0].message);
  301. };
  302. this.loadData();
  303. }.bind(this));
  304. },
  305. closeDesc(e) {
  306. this.state.showDesc = e;
  307. this.loadData();
  308. },
  309. closeAdd(e) {
  310. this.state.showAdd = e;
  311. this.loadData();
  312. },
  313. search() {
  314. this.loadData();
  315. },
  316. reset() {
  317. this.state.province = undefined;
  318. this.state.unitName = undefined;
  319. this.loadData();
  320. },
  321. render() {
  322. const rowSelection = {
  323. selectedRowKeys: this.state.selectedRowKeys,
  324. onChange: (selectedRowKeys, selectedRows) => {
  325. this.setState({
  326. selectedRows: selectedRows,
  327. selectedRowKeys: selectedRowKeys
  328. });
  329. }
  330. };
  331. const hasSelected = this.state.selectedRowKeys.length > 0;
  332. return (
  333. <div className="foster-content" >
  334. <div className="content-title">
  335. <span>科技项目申报管理</span>
  336. <div className="foster-query" style={{ float: "right" }}>
  337. <div>
  338. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  339. onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  340. </div>
  341. </div>
  342. </div>
  343. <div className="foster-query">
  344. <Select placeholder="选择省份"
  345. style={{ width: 200 }}
  346. value={this.state.province}
  347. showSearch
  348. filterOption={companySearch}
  349. onChange={(e) => { this.setState({ province: e }) }}>
  350. {this.state.provinceOption}
  351. </Select>
  352. <Select placeholder="选择公司"
  353. style={{ width: 200 }}
  354. value={this.state.unitName}
  355. showSearch
  356. filterOption={companySearch}
  357. onChange={(e) => { this.setState({ unitName: e }) }}>
  358. {this.state.companyOption}
  359. </Select>
  360. <Button type="primary" onClick={this.search}>搜索</Button>
  361. <Button onClick={this.reset}>重置</Button>
  362. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  363. disabled={!hasSelected}
  364. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  365. </div>
  366. <div className="patent-table">
  367. <Spin spinning={this.state.loading}>
  368. <Table columns={this.state.columns}
  369. rowSelection={rowSelection}
  370. dataSource={this.state.dataSource}
  371. pagination={this.state.pagination}
  372. onRowClick={this.tableRowClick} />
  373. </Spin>
  374. </div>
  375. <ApplyChange
  376. data={this.state.RowData}
  377. authorOption={this.state.authorOption}
  378. showDesc={this.state.showDesc}
  379. closeDesc={this.closeDesc} />
  380. <ApplyAdd
  381. consultantOption={this.state.consultantOption}
  382. companyAddOption={this.state.companyAddOption}
  383. showAdd={this.state.showAdd}
  384. closeAdd={this.closeAdd} />
  385. </div >
  386. );
  387. }
  388. });
  389. export default ApplyManage;