applyManage.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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: 'contractNumber',
  268. key: 'contractNumber'
  269. }, {
  270. title: '省份',
  271. dataIndex: 'province',
  272. key: 'province'
  273. }, {
  274. title: '公司',
  275. dataIndex: 'unitName',
  276. key: 'unitName'
  277. }, {
  278. title: '联系方式',
  279. dataIndex: 'contacts',
  280. key: 'contacts'
  281. }, {
  282. title: '项目名称',
  283. dataIndex: 'projectName',
  284. key: 'projectName'
  285. }, {
  286. title: '项目类型',
  287. dataIndex: 'projectCatagory',
  288. key: 'projectCatagory'
  289. }, {
  290. title: '技术领域',
  291. dataIndex: 'techField',
  292. key: 'techField'
  293. }, {
  294. title: '项目情况',
  295. dataIndex: 'state',
  296. key: 'state',
  297. render: text => { return getTechnologyState(text) },
  298. }, {
  299. title: '派单日',
  300. dataIndex: 'createTime',
  301. key: 'createTime'
  302. }, {
  303. title: '网址',
  304. dataIndex: 'website',
  305. key: 'website'
  306. }, {
  307. title: '用户名',
  308. dataIndex: 'accountNumber',
  309. key: 'accountNumber'
  310. }, {
  311. title: '密码',
  312. dataIndex: 'password',
  313. key: 'password'
  314. }, {
  315. title: '创建人',
  316. dataIndex: 'founder',
  317. key: 'founder'
  318. }, {
  319. title: '技术员',
  320. dataIndex: 'techPrincipal',
  321. key: 'techPrincipal',
  322. }
  323. ],
  324. dataSource: []
  325. };
  326. },
  327. componentWillMount() {
  328. let _me = this;
  329. provinceArr.map(function (item) {
  330. _me.state.provinceOption.push(
  331. <Select.Option value={item} key={item}>{item}</Select.Option>
  332. )
  333. });
  334. this.getAuthorList();
  335. this.getSalesmanList();
  336. this.getCompanyList();
  337. this.getConsultant();
  338. this.getContractList();
  339. if (window.location.search) {
  340. let theObj = getSearchUrl(window.location.search);
  341. if (theObj.rid) {
  342. theObj.id = theObj.rid;
  343. if (theObj.rid != 'null' && theObj.uid != 'null') {
  344. this.tableRowClick(theObj);
  345. };
  346. } else {
  347. if (theObj.uid) {
  348. this.state.unitName = theObj.uid;
  349. } else if (theObj.contractId) {
  350. this.state.contractId = theObj.contractId;
  351. };
  352. };
  353. };
  354. this.loadData();
  355. },
  356. tableRowClick(record, index) {
  357. this.state.RowData = record;
  358. this.setState({
  359. showDesc: true
  360. });
  361. },
  362. addClick() {
  363. this.setState({
  364. showAdd: true
  365. });
  366. },
  367. delectRow() {
  368. let deletedIds = [];
  369. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  370. let rowItem = this.state.selectedRows[idx];
  371. if (rowItem.id) {
  372. deletedIds.push(rowItem.id)
  373. }
  374. }
  375. this.setState({
  376. selectedRowKeys: [],
  377. loading: deletedIds.length > 0
  378. });
  379. $.ajax({
  380. method: "POST",
  381. dataType: "json",
  382. crossDomain: false,
  383. url: globalConfig.context + "/api/admin/techproject/deleteTechProject",
  384. data: {
  385. ids: deletedIds
  386. }
  387. }).done(function (data) {
  388. if (!data.error.length) {
  389. message.success('删除成功!');
  390. this.setState({
  391. loading: false,
  392. });
  393. } else {
  394. message.warning(data.error[0].message);
  395. };
  396. this.loadData();
  397. }.bind(this));
  398. },
  399. closeDesc(e) {
  400. this.state.showDesc = e;
  401. this.loadData();
  402. },
  403. closeAdd(e) {
  404. this.state.showAdd = e;
  405. this.loadData();
  406. },
  407. search() {
  408. this.loadData();
  409. },
  410. reset() {
  411. this.state.province = undefined;
  412. this.state.unitName = undefined;
  413. this.state.contractId = undefined;
  414. this.loadData();
  415. },
  416. render() {
  417. const rowSelection = {
  418. selectedRowKeys: this.state.selectedRowKeys,
  419. onChange: (selectedRowKeys, selectedRows) => {
  420. this.setState({
  421. selectedRows: selectedRows,
  422. selectedRowKeys: selectedRowKeys
  423. });
  424. }
  425. };
  426. const hasSelected = this.state.selectedRowKeys.length > 0;
  427. return (
  428. <div className="foster-content" >
  429. <div className="content-title">
  430. <span>科技项目申报管理</span>
  431. </div>
  432. <div className="foster-query">
  433. <Select placeholder="选择省份"
  434. style={{ width: 200 }}
  435. value={this.state.province}
  436. showSearch
  437. filterOption={companySearch}
  438. onChange={(e) => { this.setState({ province: e }) }}>
  439. {this.state.provinceOption}
  440. </Select>
  441. <Select placeholder="选择公司"
  442. style={{ width: 200 }}
  443. value={this.state.unitName}
  444. showSearch
  445. filterOption={companySearch}
  446. onChange={(e) => { this.setState({ unitName: e }) }}>
  447. {this.state.companyOption}
  448. </Select>
  449. <Select placeholder="选择合同编号"
  450. style={{ width: 120 }}
  451. value={this.state.contractId}
  452. showSearch
  453. filterOption={companySearch}
  454. onChange={(e) => { this.setState({ contractId: e }) }}>
  455. {this.state.contractListOption}
  456. </Select>
  457. <Button type="primary" onClick={this.search}>搜索</Button>
  458. <Button onClick={this.reset}>重置</Button>
  459. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  460. disabled={!hasSelected}
  461. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  462. </div>
  463. <div className="patent-table">
  464. <Spin spinning={this.state.loading}>
  465. <Table columns={this.state.columns}
  466. rowSelection={rowSelection}
  467. dataSource={this.state.dataSource}
  468. pagination={this.state.pagination}
  469. onRowClick={this.tableRowClick} />
  470. </Spin>
  471. </div>
  472. <ApplyChange
  473. data={this.state.RowData}
  474. authorOption={this.state.authorOption}
  475. showDesc={this.state.showDesc}
  476. closeDesc={this.closeDesc} />
  477. <ApplyAdd
  478. consultantOption={this.state.consultantOption}
  479. companyAddOption={this.state.companyAddOption}
  480. salesmanOption={this.state.salesmanOption}
  481. showAdd={this.state.showAdd}
  482. closeAdd={this.closeAdd} />
  483. </div >
  484. );
  485. }
  486. });
  487. export default ApplyManage;
  488. // <div className="foster-query" style={{ float: "right" }}>
  489. // <div>
  490. // <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  491. // onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  492. // </div>
  493. // </div>