applyManage.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. pid: 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. getInitialState() {
  203. return {
  204. provinceOption: [],
  205. companyOption: [],
  206. companyAddOption: [],
  207. authorOption: [],
  208. consultantOption: [],
  209. selectedRows: [],
  210. selectedRowKeys: [],
  211. loading: false,
  212. showAdd: false,
  213. showDesc: false,
  214. pagination: {
  215. defaultCurrent: 1,
  216. defaultPageSize: 10,
  217. showQuickJumper: true,
  218. pageSize: 10,
  219. onChange: function (page) {
  220. this.loadData(page);
  221. }.bind(this),
  222. showTotal: function (total) {
  223. return '共' + total + '条数据';
  224. }
  225. },
  226. columns: [
  227. {
  228. title: '编号',
  229. dataIndex: 'serialNumber',
  230. key: 'serialNumber'
  231. }, {
  232. title: '省份',
  233. dataIndex: 'province',
  234. key: 'province'
  235. }, {
  236. title: '公司',
  237. dataIndex: 'unitName',
  238. key: 'unitName'
  239. }, {
  240. title: '联系方式',
  241. dataIndex: 'contacts',
  242. key: 'contacts'
  243. }, {
  244. title: '项目名称',
  245. dataIndex: 'projectName',
  246. key: 'projectName'
  247. }, {
  248. title: '项目类型',
  249. dataIndex: 'projectCatagory',
  250. key: 'projectCatagory'
  251. }, {
  252. title: '技术领域',
  253. dataIndex: 'techField',
  254. key: 'techField'
  255. }, {
  256. title: '项目情况',
  257. dataIndex: 'state',
  258. key: 'state',
  259. render: text => { return getTechnologyState(text) },
  260. }, {
  261. title: '派单日',
  262. dataIndex: 'createTime',
  263. key: 'createTime'
  264. }, {
  265. title: '网址',
  266. dataIndex: 'website',
  267. key: 'website'
  268. }, {
  269. title: '用户名',
  270. dataIndex: 'accountNumber',
  271. key: 'accountNumber'
  272. }, {
  273. title: '密码',
  274. dataIndex: 'password',
  275. key: 'password'
  276. }, {
  277. title: '创建人',
  278. dataIndex: 'founder',
  279. key: 'founder'
  280. }, {
  281. title: '技术员',
  282. dataIndex: 'techPrincipal',
  283. key: 'techPrincipal',
  284. }
  285. ],
  286. dataSource: []
  287. };
  288. },
  289. componentWillMount() {
  290. let _me = this;
  291. provinceArr.map(function (item) {
  292. _me.state.provinceOption.push(
  293. <Select.Option value={item} key={item}>{item}</Select.Option>
  294. )
  295. });
  296. this.getAuthorList();
  297. this.getSalesmanList();
  298. this.getCompanyList();
  299. this.getConsultant();
  300. if (window.location.search) {
  301. let theArr = getSearchUrl(window.location.search);
  302. if (theArr.length > 1) {
  303. let theObj = {};
  304. theObj.pid = theArr[0].value;
  305. theObj.uid = theArr[1].value;
  306. if (theObj.pid != 'null' && theObj.uid != 'null') {
  307. this.tableRowClick(theObj);
  308. };
  309. } else if (theArr.length == 1) {
  310. if (theArr[0].key == 'uid') {
  311. this.state.unitName = theArr[0].value;
  312. } else if (theArr[0].key == 'contractId ') {
  313. this.state.contractId = theArr[0].value;
  314. };
  315. };
  316. };
  317. this.loadData();
  318. },
  319. tableRowClick(record, index) {
  320. this.state.RowData = record;
  321. this.setState({
  322. showDesc: true
  323. });
  324. },
  325. addClick() {
  326. this.setState({
  327. showAdd: true
  328. });
  329. },
  330. delectRow() {
  331. let deletedIds = [];
  332. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  333. let rowItem = this.state.selectedRows[idx];
  334. if (rowItem.pid) {
  335. deletedIds.push(rowItem.pid)
  336. }
  337. }
  338. this.setState({
  339. selectedRowKeys: [],
  340. loading: deletedIds.length > 0
  341. });
  342. $.ajax({
  343. method: "POST",
  344. dataType: "json",
  345. crossDomain: false,
  346. url: globalConfig.context + "/api/admin/techproject/deleteTechProject",
  347. data: {
  348. ids: deletedIds
  349. }
  350. }).done(function (data) {
  351. if (!data.error.length) {
  352. message.success('保存成功!');
  353. this.setState({
  354. loading: false,
  355. });
  356. } else {
  357. message.warning(data.error[0].message);
  358. };
  359. this.loadData();
  360. }.bind(this));
  361. },
  362. closeDesc(e) {
  363. this.state.showDesc = e;
  364. this.loadData();
  365. },
  366. closeAdd(e) {
  367. this.state.showAdd = e;
  368. this.loadData();
  369. },
  370. search() {
  371. this.loadData();
  372. },
  373. reset() {
  374. this.state.province = undefined;
  375. this.state.unitName = undefined;
  376. this.state.contractId = undefined;
  377. this.loadData();
  378. },
  379. render() {
  380. const rowSelection = {
  381. selectedRowKeys: this.state.selectedRowKeys,
  382. onChange: (selectedRowKeys, selectedRows) => {
  383. this.setState({
  384. selectedRows: selectedRows,
  385. selectedRowKeys: selectedRowKeys
  386. });
  387. }
  388. };
  389. const hasSelected = this.state.selectedRowKeys.length > 0;
  390. return (
  391. <div className="foster-content" >
  392. <div className="content-title">
  393. <span>科技项目申报管理</span>
  394. </div>
  395. <div className="foster-query">
  396. <Select placeholder="选择省份"
  397. style={{ width: 200 }}
  398. value={this.state.province}
  399. showSearch
  400. filterOption={companySearch}
  401. onChange={(e) => { this.setState({ province: e }) }}>
  402. {this.state.provinceOption}
  403. </Select>
  404. <Select placeholder="选择公司"
  405. style={{ width: 200 }}
  406. value={this.state.unitName}
  407. showSearch
  408. filterOption={companySearch}
  409. onChange={(e) => { this.setState({ unitName: e }) }}>
  410. {this.state.companyOption}
  411. </Select>
  412. <Input style={{ width: 160 }}
  413. placeholder="请输入合同编号"
  414. value={this.state.contractId}
  415. onChange={(e) => { this.setState({ contractId: e.target.value }); }} />
  416. <Button type="primary" onClick={this.search}>搜索</Button>
  417. <Button onClick={this.reset}>重置</Button>
  418. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  419. disabled={!hasSelected}
  420. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  421. </div>
  422. <div className="patent-table">
  423. <Spin spinning={this.state.loading}>
  424. <Table columns={this.state.columns}
  425. rowSelection={rowSelection}
  426. dataSource={this.state.dataSource}
  427. pagination={this.state.pagination}
  428. onRowClick={this.tableRowClick} />
  429. </Spin>
  430. </div>
  431. <ApplyChange
  432. data={this.state.RowData}
  433. authorOption={this.state.authorOption}
  434. showDesc={this.state.showDesc}
  435. closeDesc={this.closeDesc} />
  436. <ApplyAdd
  437. consultantOption={this.state.consultantOption}
  438. companyAddOption={this.state.companyAddOption}
  439. salesmanOption={this.state.salesmanOption}
  440. showAdd={this.state.showAdd}
  441. closeAdd={this.closeAdd} />
  442. </div >
  443. );
  444. }
  445. });
  446. export default ApplyManage;
  447. // <div className="foster-query" style={{ float: "right" }}>
  448. // <div>
  449. // <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  450. // onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  451. // </div>
  452. // </div>