applyManage.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 } 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/admintechproject/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. });
  63. };
  64. this.state.pagination.current = data.data.pageNo;
  65. this.state.pagination.total = data.data.totalCount;
  66. this.setState({
  67. dataSource: this.state.data,
  68. pagination: this.state.pagination
  69. });
  70. }.bind(this),
  71. }).always(function () {
  72. this.setState({
  73. loading: false
  74. });
  75. }.bind(this));
  76. },
  77. getAuthorList() {
  78. this.setState({
  79. loading: true
  80. });
  81. $.ajax({
  82. method: "get",
  83. dataType: "json",
  84. crossDomain: false,
  85. url: globalConfig.context + "/techservice/patent/getAdmin",
  86. success: function (data) {
  87. if (data.error.length || !data.data) {
  88. return;
  89. };
  90. let _me = this;
  91. for (var item in data.data) {
  92. _me.state.authorOption.push(
  93. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  94. )
  95. };
  96. }.bind(this),
  97. }).always(function () {
  98. this.setState({
  99. loading: false
  100. });
  101. }.bind(this));
  102. },
  103. getCompanyList() {
  104. this.setState({
  105. loading: true
  106. });
  107. $.ajax({
  108. method: "get",
  109. dataType: "json",
  110. crossDomain: false,
  111. url: globalConfig.context + "/techservice/patent/getUnitNames",
  112. success: function (data) {
  113. if (data.error.length || !data.data) {
  114. return;
  115. };
  116. let _me = this;
  117. for (var item in data.data) {
  118. _me.state.companyOption.push(
  119. <Select.Option value={data.data[item]} key={data.data[item]}>{data.data[item]}</Select.Option>
  120. )
  121. _me.state.companyAddOption.push(
  122. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  123. )
  124. };
  125. }.bind(this),
  126. }).always(function () {
  127. this.setState({
  128. loading: false
  129. });
  130. }.bind(this));
  131. },
  132. getInitialState() {
  133. return {
  134. provinceOption: [],
  135. companyOption: [],
  136. companyAddOption: [],
  137. authorOption: [],
  138. selectedRows: [],
  139. selectedRowKeys: [],
  140. loading: false,
  141. showAdd: false,
  142. showDesc: false,
  143. pagination: {
  144. defaultCurrent: 1,
  145. defaultPageSize: 10,
  146. showQuickJumper: true,
  147. pageSize: 10,
  148. onChange: function (page) {
  149. this.loadData(page);
  150. }.bind(this),
  151. showTotal: function (total) {
  152. return '共' + total + '条数据';
  153. }
  154. },
  155. columns: [
  156. {
  157. title: '编号',
  158. dataIndex: 'serialNumber',
  159. key: 'serialNumber'
  160. }, {
  161. title: '省份',
  162. dataIndex: 'province',
  163. key: 'province'
  164. }, {
  165. title: '公司',
  166. dataIndex: 'unitName',
  167. key: 'unitName'
  168. }, {
  169. title: '联系方式',
  170. dataIndex: 'contacts',
  171. key: 'contacts'
  172. }, {
  173. title: '项目名称',
  174. dataIndex: 'projectName',
  175. key: 'projectName'
  176. }, {
  177. title: '项目类型',
  178. dataIndex: 'projectCatagory',
  179. key: 'projectCatagory'
  180. },{
  181. title: '技术领域',
  182. dataIndex: 'techField',
  183. key: 'techField'
  184. }, {
  185. title: '项目情况',
  186. dataIndex: 'state',
  187. key: 'state',
  188. render: text => { return getTechnologyState(text) },
  189. },{
  190. title: '派单日',
  191. dataIndex: 'createTime',
  192. key: 'createTime'
  193. }, {
  194. title: '网址',
  195. dataIndex: 'website',
  196. key: 'website'
  197. }, {
  198. title: '用户名',
  199. dataIndex: 'accountNumber',
  200. key: 'accountNumber'
  201. }, {
  202. title: '密码',
  203. dataIndex: 'password',
  204. key: 'password'
  205. }, {
  206. title: '咨询师',
  207. dataIndex: 'consultant',
  208. key: 'consultant'
  209. }
  210. ],
  211. dataSource: []
  212. };
  213. },
  214. componentWillMount() {
  215. let _me = this;
  216. provinceArr.map(function (item) {
  217. _me.state.provinceOption.push(
  218. <Select.Option value={item} key={item}>{item}</Select.Option>
  219. )
  220. });
  221. this.loadData();
  222. this.getAuthorList();
  223. this.getCompanyList();
  224. // this.getContactsList();
  225. },
  226. tableRowClick(record, index) {
  227. this.state.RowData = record;
  228. this.setState({
  229. showDesc: true
  230. });
  231. },
  232. addClick() {
  233. this.setState({
  234. showAdd: true
  235. });
  236. },
  237. delectRow() {
  238. let deletedIds = [];
  239. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  240. let rowItem = this.state.selectedRows[idx];
  241. if (rowItem.id) {
  242. deletedIds.push(rowItem.id)
  243. }
  244. }
  245. this.setState({
  246. selectedRowKeys: [],
  247. loading: deletedIds.length > 0
  248. });
  249. $.ajax({
  250. method: "POST",
  251. dataType: "json",
  252. crossDomain: false,
  253. url: globalConfig.context + "/api/admintechproject/deleteTechProject",
  254. data: {
  255. ids: deletedIds
  256. }
  257. }).done(function (data) {
  258. if (!data.error.length) {
  259. message.success('保存成功!');
  260. this.setState({
  261. loading: false,
  262. });
  263. } else {
  264. message.warning(data.error[0].message);
  265. };
  266. this.loadData();
  267. }.bind(this));
  268. },
  269. closeDesc(e) {
  270. this.state.showDesc = e;
  271. this.loadData();
  272. },
  273. closeAdd(e) {
  274. this.state.showAdd = e;
  275. this.loadData();
  276. },
  277. search() {
  278. this.loadData();
  279. },
  280. reset() {
  281. this.state.province = undefined;
  282. this.state.unitName = undefined;
  283. this.loadData();
  284. },
  285. render() {
  286. const rowSelection = {
  287. selectedRowKeys: this.state.selectedRowKeys,
  288. onChange: (selectedRowKeys, selectedRows) => {
  289. this.setState({
  290. selectedRows: selectedRows,
  291. selectedRowKeys: selectedRowKeys
  292. });
  293. }
  294. };
  295. const hasSelected = this.state.selectedRowKeys.length > 0;
  296. return (
  297. <div className="foster-content" >
  298. <div className="content-title">
  299. <span>科技项目申报管理</span>
  300. <div className="foster-query" style={{ float: "right" }}>
  301. <div>
  302. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  303. onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  304. </div>
  305. </div>
  306. </div>
  307. <div className="foster-query">
  308. <Select placeholder="选择省份"
  309. style={{ width: 200 }}
  310. value={this.state.province}
  311. showSearch
  312. filterOption={companySearch}
  313. onChange={(e) => { this.setState({ province: e }) }}>
  314. {this.state.provinceOption}
  315. </Select>
  316. <Select placeholder="选择公司"
  317. style={{ width: 200 }}
  318. value={this.state.unitName}
  319. showSearch
  320. filterOption={companySearch}
  321. onChange={(e) => { this.setState({ unitName: e }) }}>
  322. {this.state.companyOption}
  323. </Select>
  324. <Button type="primary" onClick={this.search}>搜索</Button>
  325. <Button onClick={this.reset}>重置</Button>
  326. </div>
  327. <div className="patent-table">
  328. <Spin spinning={this.state.loading}>
  329. <Table columns={this.state.columns}
  330. rowSelection={rowSelection}
  331. dataSource={this.state.dataSource}
  332. pagination={this.state.pagination}
  333. onRowClick={this.tableRowClick} />
  334. </Spin>
  335. </div>
  336. <ApplyChange
  337. data={this.state.RowData}
  338. authorOption={this.state.authorOption}
  339. showDesc={this.state.showDesc}
  340. closeDesc={this.closeDesc} />
  341. <ApplyAdd
  342. authorOption={this.state.authorOption}
  343. companyAddOption={this.state.companyAddOption}
  344. showAdd={this.state.showAdd}
  345. closeAdd={this.closeAdd} />
  346. </div >
  347. );
  348. }
  349. });
  350. export default ApplyManage;