applyManage.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. import React from 'react';
  2. import { Icon, Button, Select, Spin, Table, message, Input } 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. uid: this.state.unitName,
  26. contractId: this.state.contractId
  27. },
  28. success: function (data) {
  29. let theArr = [];
  30. if (data.error.length || !data.data || !data.data.list) {
  31. message.warning(data.error[0].message);
  32. return;
  33. }
  34. for (let i = 0; i < data.data.list.length; i++) {
  35. let thisdata = data.data.list[i];
  36. switch (thisdata.contacts) {
  37. case 1:
  38. thisdata.contacts = thisdata.firstContacts;
  39. break;
  40. case 2:
  41. thisdata.contacts = thisdata.secondContacts;
  42. break;
  43. case 3:
  44. thisdata.contacts = thisdata.thirdContacts;
  45. break;
  46. }
  47. theArr.push({
  48. key: i,
  49. id: thisdata.id,
  50. uid: thisdata.uid,
  51. serialNumber: thisdata.serialNumber,
  52. province: thisdata.province,
  53. unitName: thisdata.unitName,
  54. contacts: thisdata.contacts,
  55. projectName: thisdata.projectName,
  56. projectCatagory: thisdata.projectCatagory,
  57. techField: thisdata.techField,
  58. state: thisdata.state,
  59. createTime: thisdata.createTimeFormattedDate,
  60. website: thisdata.website,
  61. accountNumber: thisdata.accountNumber,
  62. password: thisdata.password,
  63. consultant: thisdata.consultant,
  64. founder: thisdata.founder, //创建人
  65. techPrincipal: thisdata.techPrincipal //技术员
  66. });
  67. };
  68. this.state.pagination.current = data.data.pageNo;
  69. this.state.pagination.total = data.data.totalCount;
  70. this.setState({
  71. dataSource: theArr,
  72. pagination: this.state.pagination
  73. });
  74. }.bind(this),
  75. }).always(function () {
  76. this.setState({
  77. loading: false
  78. });
  79. }.bind(this));
  80. },
  81. getAuthorList() {
  82. this.setState({
  83. loading: true
  84. });
  85. $.ajax({
  86. method: "get",
  87. dataType: "json",
  88. crossDomain: false,
  89. url: globalConfig.context + "/api/admin/techproject/getPrincipal",
  90. success: function (data) {
  91. if (!data.data) {
  92. if (data.error && data.error.length) {
  93. message.warning(data.error[0].message);
  94. };
  95. return;
  96. };
  97. let _me = this;
  98. for (var item in data.data) {
  99. _me.state.authorOption.push(
  100. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  101. )
  102. };
  103. }.bind(this),
  104. }).always(function () {
  105. this.setState({
  106. loading: false
  107. });
  108. }.bind(this));
  109. },
  110. getSalesmanList() {
  111. this.setState({
  112. loading: true
  113. });
  114. $.ajax({
  115. method: "get",
  116. dataType: "json",
  117. crossDomain: false,
  118. url: globalConfig.context + "/api/admin/salesman",
  119. success: function (data) {
  120. if (!data.data) {
  121. if (data.error && data.error.length) {
  122. message.warning(data.error[0].message);
  123. }
  124. return;
  125. };
  126. let _me = this, theArr = [];
  127. for (var item in data.data) {
  128. theArr.push(
  129. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  130. )
  131. };
  132. this.setState({
  133. salesmanOption: theArr
  134. });
  135. }.bind(this),
  136. }).always(function () {
  137. this.setState({
  138. loading: false
  139. });
  140. }.bind(this));
  141. },
  142. getConsultant() {
  143. this.setState({
  144. loading: true
  145. });
  146. $.ajax({
  147. method: "get",
  148. dataType: "json",
  149. crossDomain: false,
  150. url: globalConfig.context + "/api/admin/techproject/getConsultant",
  151. success: function (data) {
  152. if (!data.data) {
  153. if (data.error && data.error.length) {
  154. message.warning(data.error[0].message);
  155. };
  156. return;
  157. };
  158. let _me = this;
  159. for (var item in data.data) {
  160. _me.state.consultantOption.push(
  161. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  162. )
  163. };
  164. }.bind(this),
  165. }).always(function () {
  166. this.setState({
  167. loading: false
  168. });
  169. }.bind(this));
  170. },
  171. getCompanyList() {
  172. this.setState({
  173. loading: true
  174. });
  175. $.ajax({
  176. method: "get",
  177. dataType: "json",
  178. crossDomain: false,
  179. url: globalConfig.context + "/api/admin/getUnitNames",
  180. success: function (data) {
  181. if (!data.data) {
  182. if (data.error && data.error.length) {
  183. message.warning(data.error[0].message);
  184. }
  185. return;
  186. };
  187. let _me = this;
  188. for (var item in data.data) {
  189. _me.state.companyOption.push(
  190. <Select.Option value={item} key={data.data[item]}>{data.data[item]}</Select.Option>
  191. )
  192. _me.state.companyAddOption.push(
  193. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  194. )
  195. };
  196. }.bind(this),
  197. }).always(function () {
  198. this.setState({
  199. loading: false
  200. });
  201. }.bind(this));
  202. },
  203. getContractList() {
  204. this.setState({
  205. loading: true
  206. });
  207. $.ajax({
  208. method: "get",
  209. dataType: "json",
  210. crossDomain: false,
  211. url: globalConfig.context + "/api/admin/contract/serialNumber",
  212. success: function (data) {
  213. if (!data.data) {
  214. if (data.error && data.error.length) {
  215. message.warning(data.error[0].message);
  216. };
  217. return;
  218. };
  219. let theArr = [];
  220. for (let i = 0; i < data.data.length; i++) {
  221. let item = data.data[i];
  222. theArr.push(
  223. <Select.Option value={item.contractId} key={item.contractId}>{item.serialNumber}</Select.Option>
  224. );
  225. };
  226. this.setState({
  227. contractListOption: theArr
  228. });
  229. }.bind(this),
  230. }).always(function () {
  231. this.setState({
  232. loading: false
  233. });
  234. }.bind(this));
  235. },
  236. getInitialState() {
  237. return {
  238. provinceOption: [],
  239. companyOption: [],
  240. companyAddOption: [],
  241. authorOption: [],
  242. consultantOption: [],
  243. selectedRows: [],
  244. selectedRowKeys: [],
  245. loading: false,
  246. showAdd: false,
  247. showDesc: false,
  248. pagination: {
  249. defaultCurrent: 1,
  250. defaultPageSize: 10,
  251. showQuickJumper: true,
  252. pageSize: 10,
  253. onChange: function (page) {
  254. this.loadData(page);
  255. }.bind(this),
  256. showTotal: function (total) {
  257. return '共' + total + '条数据';
  258. }
  259. },
  260. columns: [
  261. {
  262. title: '编号',
  263. dataIndex: 'serialNumber',
  264. key: 'serialNumber'
  265. }, {
  266. title: '省份',
  267. dataIndex: 'province',
  268. key: 'province'
  269. }, {
  270. title: '公司',
  271. dataIndex: 'unitName',
  272. key: 'unitName'
  273. }, {
  274. title: '联系方式',
  275. dataIndex: 'contacts',
  276. key: 'contacts'
  277. }, {
  278. title: '项目名称',
  279. dataIndex: 'projectName',
  280. key: 'projectName'
  281. }, {
  282. title: '项目类型',
  283. dataIndex: 'projectCatagory',
  284. key: 'projectCatagory'
  285. }, {
  286. title: '技术领域',
  287. dataIndex: 'techField',
  288. key: 'techField'
  289. }, {
  290. title: '项目情况',
  291. dataIndex: 'state',
  292. key: 'state',
  293. render: text => { return getTechnologyState(text) },
  294. }, {
  295. title: '派单日',
  296. dataIndex: 'createTime',
  297. key: 'createTime'
  298. }, {
  299. title: '网址',
  300. dataIndex: 'website',
  301. key: 'website'
  302. }, {
  303. title: '用户名',
  304. dataIndex: 'accountNumber',
  305. key: 'accountNumber'
  306. }, {
  307. title: '密码',
  308. dataIndex: 'password',
  309. key: 'password'
  310. }, {
  311. title: '创建人',
  312. dataIndex: 'founder',
  313. key: 'founder'
  314. }, {
  315. title: '技术员',
  316. dataIndex: 'techPrincipal',
  317. key: 'techPrincipal',
  318. }
  319. ],
  320. dataSource: []
  321. };
  322. },
  323. componentWillMount() {
  324. let _me = this;
  325. provinceArr.map(function (item) {
  326. _me.state.provinceOption.push(
  327. <Select.Option value={item} key={item}>{item}</Select.Option>
  328. )
  329. });
  330. this.getAuthorList();
  331. this.getSalesmanList();
  332. this.getCompanyList();
  333. this.getConsultant();
  334. this.getContractList();
  335. if (window.location.search) {
  336. let theObj = getSearchUrl(window.location.search);
  337. if (theObj.rid) {
  338. theObj.id = theObj.rid;
  339. if (theObj.rid != 'null' && theObj.uid != 'null') {
  340. this.tableRowClick(theObj);
  341. };
  342. } else {
  343. if (theObj.uid) {
  344. this.state.unitName = theObj.uid;
  345. } else if (theObj.contractId) {
  346. this.state.contractId = theObj.contractId;
  347. };
  348. };
  349. };
  350. this.loadData();
  351. },
  352. tableRowClick(record, index) {
  353. this.state.RowData = record;
  354. this.setState({
  355. showDesc: true
  356. });
  357. },
  358. addClick() {
  359. this.setState({
  360. showAdd: true
  361. });
  362. },
  363. delectRow() {
  364. let deletedIds = [];
  365. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  366. let rowItem = this.state.selectedRows[idx];
  367. if (rowItem.id) {
  368. deletedIds.push(rowItem.id)
  369. }
  370. }
  371. this.setState({
  372. selectedRowKeys: [],
  373. loading: deletedIds.length > 0
  374. });
  375. $.ajax({
  376. method: "POST",
  377. dataType: "json",
  378. crossDomain: false,
  379. url: globalConfig.context + "/api/admin/techproject/deleteTechProject",
  380. data: {
  381. ids: deletedIds
  382. }
  383. }).done(function (data) {
  384. if (!data.error.length) {
  385. message.success('删除成功!');
  386. this.setState({
  387. loading: false,
  388. });
  389. } else {
  390. message.warning(data.error[0].message);
  391. };
  392. this.loadData();
  393. }.bind(this));
  394. },
  395. closeDesc(e) {
  396. this.state.showDesc = e;
  397. this.loadData();
  398. },
  399. closeAdd(e) {
  400. this.state.showAdd = e;
  401. this.loadData();
  402. },
  403. search() {
  404. this.loadData();
  405. },
  406. reset() {
  407. this.state.province = undefined;
  408. this.state.unitName = undefined;
  409. this.state.contractId = undefined;
  410. this.loadData();
  411. },
  412. render() {
  413. const rowSelection = {
  414. selectedRowKeys: this.state.selectedRowKeys,
  415. onChange: (selectedRowKeys, selectedRows) => {
  416. this.setState({
  417. selectedRows: selectedRows,
  418. selectedRowKeys: selectedRowKeys
  419. });
  420. }
  421. };
  422. const hasSelected = this.state.selectedRowKeys.length > 0;
  423. return (
  424. <div className="foster-content" >
  425. <div className="content-title">
  426. <span>科技项目申报管理</span>
  427. </div>
  428. <div className="foster-query">
  429. <Select placeholder="选择省份"
  430. style={{ width: 200 }}
  431. value={this.state.province}
  432. showSearch
  433. filterOption={companySearch}
  434. onChange={(e) => { this.setState({ province: e }) }}>
  435. {this.state.provinceOption}
  436. </Select>
  437. <Select placeholder="选择公司"
  438. style={{ width: 200 }}
  439. value={this.state.unitName}
  440. showSearch
  441. filterOption={companySearch}
  442. onChange={(e) => { this.setState({ unitName: e }) }}>
  443. {this.state.companyOption}
  444. </Select>
  445. <Select placeholder="选择合同编号"
  446. style={{ width: 120 }}
  447. value={this.state.contractId}
  448. showSearch
  449. filterOption={companySearch}
  450. onChange={(e) => { this.setState({ contractId: e }) }}>
  451. {this.state.contractListOption}
  452. </Select>
  453. <Button type="primary" onClick={this.search}>搜索</Button>
  454. <Button onClick={this.reset}>重置</Button>
  455. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  456. disabled={!hasSelected}
  457. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  458. </div>
  459. <div className="patent-table">
  460. <Spin spinning={this.state.loading}>
  461. <Table columns={this.state.columns}
  462. rowSelection={rowSelection}
  463. dataSource={this.state.dataSource}
  464. pagination={this.state.pagination}
  465. onRowClick={this.tableRowClick} />
  466. </Spin>
  467. </div>
  468. <ApplyChange
  469. data={this.state.RowData}
  470. authorOption={this.state.authorOption}
  471. showDesc={this.state.showDesc}
  472. closeDesc={this.closeDesc} />
  473. <ApplyAdd
  474. consultantOption={this.state.consultantOption}
  475. companyAddOption={this.state.companyAddOption}
  476. salesmanOption={this.state.salesmanOption}
  477. showAdd={this.state.showAdd}
  478. closeAdd={this.closeAdd} />
  479. </div >
  480. );
  481. }
  482. });
  483. export default ApplyManage;
  484. // <div className="foster-query" style={{ float: "right" }}>
  485. // <div>
  486. // <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  487. // onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  488. // </div>
  489. // </div>