technology.jsx 9.5 KB

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