technology.jsx 9.3 KB

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