technology.jsx 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import React from 'react';
  2. import { Icon, Button, Select, Spin, Table, message } from 'antd';
  3. import { companySearch, getTechnologyState } from '../../tools.js';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import './technology.less';
  7. import ApplyAdd from './technologyAdd.jsx';
  8. import ApplyChange from './technologyChange.jsx';
  9. const Technology = React.createClass({
  10. loadData(pageNo) {
  11. this.state.data = [];
  12. this.setState({
  13. loading: true
  14. });
  15. $.ajax({
  16. method: "post",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/user/techproject/listClientTechProject",
  20. success: function (data) {
  21. if (data.error.length || !data.data || !data.data.list) {
  22. message.warning(data.error[0].message);
  23. return;
  24. }
  25. for (let i = 0; i < data.data.list.length; i++) {
  26. let thisdata = data.data.list[i];
  27. switch (thisdata.contacts) {
  28. case 1:
  29. thisdata.contacts = thisdata.firstContacts;
  30. break;
  31. case 2:
  32. thisdata.contacts = thisdata.secondContacts;
  33. break;
  34. case 3:
  35. thisdata.contacts = thisdata.thirdContacts;
  36. break;
  37. }
  38. this.state.data.push({
  39. key: i,
  40. pid: thisdata.id,
  41. uid: thisdata.uid,
  42. serialNumber: thisdata.serialNumber,
  43. province: thisdata.province,
  44. unitName: thisdata.unitName,
  45. contacts: thisdata.contacts,
  46. projectName: thisdata.projectName,
  47. projectCatagory: thisdata.projectCatagory,
  48. techField: thisdata.techField,
  49. state: thisdata.state,
  50. createTime: thisdata.createTimeFormattedDate,
  51. consultant: thisdata.consultant
  52. });
  53. };
  54. this.state.pagination.current = data.data.pageNo;
  55. this.state.pagination.total = data.data.totalCount;
  56. this.setState({
  57. dataSource: this.state.data,
  58. pagination: this.state.pagination
  59. });
  60. }.bind(this),
  61. }).always(function () {
  62. this.setState({
  63. loading: false
  64. });
  65. }.bind(this));
  66. },
  67. getAuthorList() {
  68. this.setState({
  69. loading: true
  70. });
  71. $.ajax({
  72. method: "get",
  73. dataType: "json",
  74. crossDomain: false,
  75. url: globalConfig.context + "/api/user/patent/getAdmin",
  76. success: function (data) {
  77. if (data.error.length || !data.data) {
  78. return;
  79. };
  80. let _me = this;
  81. for (var item in data.data) {
  82. _me.state.authorOption.push(
  83. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  84. )
  85. };
  86. }.bind(this),
  87. }).always(function () {
  88. this.setState({
  89. loading: false
  90. });
  91. }.bind(this));
  92. },
  93. getContactsList() {
  94. $.ajax({
  95. method: "get",
  96. dataType: "json",
  97. crossDomain: false,
  98. url: globalConfig.context + "/api/user/getContacts",
  99. success: function (data) {
  100. let theOption = [];
  101. if (data.error.length || !data.data) {
  102. return;
  103. };
  104. for (let item in data.data) {
  105. let theData = data.data[item];
  106. theOption.push(
  107. <Select.Option value={item} key={item}>{theData}</Select.Option>
  108. );
  109. };
  110. this.setState({
  111. contactsOption: theOption
  112. });
  113. }.bind(this),
  114. });
  115. },
  116. getInitialState() {
  117. return {
  118. authorOption: [],
  119. selectedRows: [],
  120. loading: false,
  121. showAdd: false,
  122. showDesc: false,
  123. pagination: {
  124. defaultCurrent: 1,
  125. defaultPageSize: 10,
  126. showQuickJumper: true,
  127. pageSize: 10,
  128. onChange: function (page) {
  129. this.loadData(page);
  130. }.bind(this),
  131. showTotal: function (total) {
  132. return '共' + total + '条数据';
  133. }
  134. },
  135. columns: [
  136. {
  137. title: '编号',
  138. dataIndex: 'serialNumber',
  139. key: 'serialNumber'
  140. }, {
  141. title: '省份',
  142. dataIndex: 'province',
  143. key: 'province'
  144. }, {
  145. title: '公司',
  146. dataIndex: 'unitName',
  147. key: 'unitName'
  148. }, {
  149. title: '联系方式',
  150. dataIndex: 'contacts',
  151. key: 'contacts'
  152. }, {
  153. title: '项目名称',
  154. dataIndex: 'projectName',
  155. key: 'projectName'
  156. }, {
  157. title: '项目类型',
  158. dataIndex: 'projectCatagory',
  159. key: 'projectCatagory'
  160. }, {
  161. title: '技术领域',
  162. dataIndex: 'techField',
  163. key: 'techField'
  164. }, {
  165. title: '项目情况',
  166. dataIndex: 'state',
  167. key: 'state',
  168. render: text => { return getTechnologyState(text) },
  169. }, {
  170. title: '派单日',
  171. dataIndex: 'createTime',
  172. key: 'createTime'
  173. }, {
  174. title: '负责人',
  175. dataIndex: 'consultant',
  176. key: 'consultant'
  177. }
  178. ],
  179. dataSource: []
  180. };
  181. },
  182. componentWillMount() {
  183. this.loadData();
  184. this.getAuthorList();
  185. this.getContactsList();
  186. },
  187. tableRowClick(record, index) {
  188. this.state.RowData = record;
  189. this.setState({
  190. showDesc: true
  191. });
  192. },
  193. addClick() {
  194. this.setState({
  195. showAdd: true
  196. });
  197. },
  198. delectRow() {
  199. let deletedIds = [];
  200. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  201. let rowItem = this.state.selectedRows[idx];
  202. if (rowItem.id) {
  203. deletedIds.push(rowItem.id)
  204. }
  205. }
  206. $.ajax({
  207. method: "POST",
  208. dataType: "json",
  209. crossDomain: false,
  210. url: globalConfig.context + "/api/user/cognizance/deleteCognizance",
  211. data: {
  212. ids: deletedIds
  213. }
  214. }).done(function (data) {
  215. if (!data.error.length) {
  216. message.success('保存成功!');
  217. this.setState({
  218. loading: false,
  219. });
  220. } else {
  221. message.warning(data.error[0].message);
  222. };
  223. this.loadData();
  224. }.bind(this));
  225. },
  226. closeDesc(e) {
  227. this.state.showDesc = e;
  228. this.loadData();
  229. },
  230. closeAdd(e) {
  231. this.state.showAdd = e;
  232. this.loadData();
  233. },
  234. render() {
  235. return (
  236. <div className="foster-content" >
  237. <div className="content-title">
  238. <span>科技项目申报管理</span>
  239. <div className="foster-query" style={{ float: "right" }}>
  240. <div>
  241. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  242. onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  243. </div>
  244. </div>
  245. </div>
  246. <div className="patent-table">
  247. <Spin spinning={this.state.loading}>
  248. <Table columns={this.state.columns}
  249. dataSource={this.state.dataSource}
  250. pagination={this.state.pagination}
  251. onRowClick={this.tableRowClick} />
  252. </Spin>
  253. </div>
  254. <ApplyChange
  255. data={this.state.RowData}
  256. contactsOption={this.state.contactsOption}
  257. showDesc={this.state.showDesc}
  258. closeDesc={this.closeDesc} />
  259. <ApplyAdd
  260. authorOption={this.state.authorOption}
  261. contactsOption={this.state.contactsOption}
  262. showAdd={this.state.showAdd}
  263. closeAdd={this.closeAdd} />
  264. </div >
  265. );
  266. }
  267. });
  268. export default Technology;