applyManage.jsx 13 KB

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