technology.jsx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. getInitialState() {
  94. return {
  95. authorOption: [],
  96. selectedRows: [],
  97. loading: false,
  98. showAdd: false,
  99. showDesc: false,
  100. pagination: {
  101. defaultCurrent: 1,
  102. defaultPageSize: 10,
  103. showQuickJumper: true,
  104. pageSize: 10,
  105. onChange: function (page) {
  106. this.loadData(page);
  107. }.bind(this),
  108. showTotal: function (total) {
  109. return '共' + total + '条数据';
  110. }
  111. },
  112. columns: [
  113. {
  114. title: '编号',
  115. dataIndex: 'serialNumber',
  116. key: 'serialNumber'
  117. }, {
  118. title: '省份',
  119. dataIndex: 'province',
  120. key: 'province'
  121. }, {
  122. title: '公司',
  123. dataIndex: 'unitName',
  124. key: 'unitName'
  125. }, {
  126. title: '联系方式',
  127. dataIndex: 'contacts',
  128. key: 'contacts'
  129. }, {
  130. title: '项目名称',
  131. dataIndex: 'projectName',
  132. key: 'projectName'
  133. }, {
  134. title: '项目类型',
  135. dataIndex: 'projectCatagory',
  136. key: 'projectCatagory'
  137. },{
  138. title: '技术领域',
  139. dataIndex: 'techField',
  140. key: 'techField'
  141. }, {
  142. title: '项目情况',
  143. dataIndex: 'state',
  144. key: 'state',
  145. render: text => { return getTechnologyState(text) },
  146. },{
  147. title: '派单日',
  148. dataIndex: 'createTime',
  149. key: 'createTime'
  150. }, {
  151. title: '咨询师',
  152. dataIndex: 'consultant',
  153. key: 'consultant'
  154. }
  155. ],
  156. dataSource: []
  157. };
  158. },
  159. componentWillMount() {
  160. this.loadData();
  161. this.getAuthorList();
  162. // this.getContactsList();
  163. },
  164. tableRowClick(record, index) {
  165. this.state.RowData = record;
  166. this.setState({
  167. showDesc: true
  168. });
  169. },
  170. addClick() {
  171. this.setState({
  172. showAdd: true
  173. });
  174. },
  175. delectRow() {
  176. let deletedIds = [];
  177. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  178. let rowItem = this.state.selectedRows[idx];
  179. if (rowItem.id) {
  180. deletedIds.push(rowItem.id)
  181. }
  182. }
  183. $.ajax({
  184. method: "POST",
  185. dataType: "json",
  186. crossDomain: false,
  187. url: globalConfig.context + "/api/user/cognizance/deleteCognizance",
  188. data: {
  189. ids: deletedIds
  190. }
  191. }).done(function (data) {
  192. if (!data.error.length) {
  193. message.success('保存成功!');
  194. this.setState({
  195. loading: false,
  196. });
  197. } else {
  198. message.warning(data.error[0].message);
  199. };
  200. this.loadData();
  201. }.bind(this));
  202. },
  203. closeDesc(e) {
  204. this.state.showDesc = e;
  205. this.loadData();
  206. },
  207. closeAdd(e) {
  208. this.state.showAdd = e;
  209. this.loadData();
  210. },
  211. render() {
  212. return (
  213. <div className="foster-content" >
  214. <div className="content-title">
  215. <span>科技项目申报管理</span>
  216. <div className="foster-query" style={{ float: "right" }}>
  217. <div>
  218. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  219. onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  220. </div>
  221. </div>
  222. </div>
  223. <div className="patent-table">
  224. <Spin spinning={this.state.loading}>
  225. <Table columns={this.state.columns}
  226. dataSource={this.state.dataSource}
  227. pagination={this.state.pagination}
  228. onRowClick={this.tableRowClick} />
  229. </Spin>
  230. </div>
  231. <ApplyChange
  232. data={this.state.RowData}
  233. showDesc={this.state.showDesc}
  234. closeDesc={this.closeDesc} />
  235. <ApplyAdd
  236. authorOption={this.state.authorOption}
  237. showAdd={this.state.showAdd}
  238. closeAdd={this.closeAdd} />
  239. </div >
  240. );
  241. }
  242. });
  243. export default Technology;