applyManage.jsx 14 KB

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