applyManage.jsx 18 KB

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