applyManage.jsx 15 KB

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