applyManage.jsx 12 KB

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