applyManage.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. unitName: 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. },
  225. tableRowClick(record, index) {
  226. this.state.RowData = record;
  227. this.setState({
  228. showDesc: true
  229. });
  230. },
  231. addClick() {
  232. this.setState({
  233. showAdd: true
  234. });
  235. },
  236. delectRow() {
  237. let deletedIds = [];
  238. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  239. let rowItem = this.state.selectedRows[idx];
  240. if (rowItem.pid) {
  241. deletedIds.push(rowItem.pid)
  242. }
  243. }
  244. this.setState({
  245. selectedRowKeys: [],
  246. loading: deletedIds.length > 0
  247. });
  248. $.ajax({
  249. method: "POST",
  250. dataType: "json",
  251. crossDomain: false,
  252. url: globalConfig.context + "/api/admintechproject/deleteTechProject",
  253. data: {
  254. ids: deletedIds
  255. }
  256. }).done(function (data) {
  257. if (!data.error.length) {
  258. message.success('保存成功!');
  259. this.setState({
  260. loading: false,
  261. });
  262. } else {
  263. message.warning(data.error[0].message);
  264. };
  265. this.loadData();
  266. }.bind(this));
  267. },
  268. closeDesc(e) {
  269. this.state.showDesc = e;
  270. this.loadData();
  271. },
  272. closeAdd(e) {
  273. this.state.showAdd = e;
  274. this.loadData();
  275. },
  276. search() {
  277. this.loadData();
  278. },
  279. reset() {
  280. this.state.province = undefined;
  281. this.state.unitName = undefined;
  282. this.loadData();
  283. },
  284. render() {
  285. const rowSelection = {
  286. selectedRowKeys: this.state.selectedRowKeys,
  287. onChange: (selectedRowKeys, selectedRows) => {
  288. this.setState({
  289. selectedRows: selectedRows,
  290. selectedRowKeys: selectedRowKeys
  291. });
  292. }
  293. };
  294. const hasSelected = this.state.selectedRowKeys.length > 0;
  295. return (
  296. <div className="foster-content" >
  297. <div className="content-title">
  298. <span>科技项目申报管理</span>
  299. <div className="foster-query" style={{ float: "right" }}>
  300. <div>
  301. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  302. onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  303. </div>
  304. </div>
  305. </div>
  306. <div className="foster-query">
  307. <Select placeholder="选择省份"
  308. style={{ width: 200 }}
  309. value={this.state.province}
  310. showSearch
  311. filterOption={companySearch}
  312. onChange={(e) => { this.setState({ province: e }) }}>
  313. {this.state.provinceOption}
  314. </Select>
  315. <Select placeholder="选择公司"
  316. style={{ width: 200 }}
  317. value={this.state.unitName}
  318. showSearch
  319. filterOption={companySearch}
  320. onChange={(e) => { this.setState({ unitName: e }) }}>
  321. {this.state.companyOption}
  322. </Select>
  323. <Button type="primary" onClick={this.search}>搜索</Button>
  324. <Button onClick={this.reset}>重置</Button>
  325. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  326. disabled={!hasSelected}
  327. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  328. </div>
  329. <div className="patent-table">
  330. <Spin spinning={this.state.loading}>
  331. <Table columns={this.state.columns}
  332. rowSelection={rowSelection}
  333. dataSource={this.state.dataSource}
  334. pagination={this.state.pagination}
  335. onRowClick={this.tableRowClick} />
  336. </Spin>
  337. </div>
  338. <ApplyChange
  339. data={this.state.RowData}
  340. authorOption={this.state.authorOption}
  341. showDesc={this.state.showDesc}
  342. closeDesc={this.closeDesc} />
  343. <ApplyAdd
  344. authorOption={this.state.authorOption}
  345. companyAddOption={this.state.companyAddOption}
  346. showAdd={this.state.showAdd}
  347. closeAdd={this.closeAdd} />
  348. </div >
  349. );
  350. }
  351. });
  352. export default ApplyManage;