applyManage.jsx 17 KB

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