technology.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. let theOption = [];
  83. if (data.error && data.error.length) {
  84. message.error(data.error[0].message);
  85. } else {
  86. for (var item in data.data) {
  87. theOption.push(
  88. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  89. )
  90. };
  91. };
  92. this.setState({
  93. authorOption: theOption
  94. });
  95. }.bind(this),
  96. }).always(function () {
  97. this.setState({
  98. loading: false
  99. });
  100. }.bind(this));
  101. },
  102. getContactsList() {
  103. $.ajax({
  104. method: "get",
  105. dataType: "json",
  106. crossDomain: false,
  107. url: globalConfig.context + "/api/user/getContacts",
  108. success: function (data) {
  109. let theOption = [];
  110. if (data.error && data.error.length) {
  111. message.error(data.error[0].message);
  112. } else {
  113. for (let item in data.data) {
  114. let theData = data.data[item];
  115. theOption.push(
  116. <Select.Option value={item} key={item}>{theData}</Select.Option>
  117. );
  118. };
  119. };
  120. this.setState({
  121. contactsOption: theOption
  122. });
  123. }.bind(this),
  124. });
  125. },
  126. getDepartment() {
  127. $.ajax({
  128. method: "get",
  129. dataType: "json",
  130. crossDomain: false,
  131. url: globalConfig.context + "/api/user/techproject/getDepartment",
  132. success: function (data) {
  133. let theOption = [];
  134. if (data.error && data.error.length) {
  135. message.error(data.error[0].message);
  136. } else {
  137. for (let item in data.data) {
  138. let theData = data.data[item];
  139. theOption.push(
  140. <Select.Option value={item} key={item}>{theData}</Select.Option>
  141. );
  142. };
  143. };
  144. this.setState({
  145. departmentOption: theOption
  146. });
  147. }.bind(this),
  148. });
  149. },
  150. getInitialState() {
  151. return {
  152. authorOption: [],
  153. selectedRows: [],
  154. loading: false,
  155. showAdd: false,
  156. showDesc: false,
  157. pagination: {
  158. defaultCurrent: 1,
  159. defaultPageSize: 10,
  160. showQuickJumper: true,
  161. pageSize: 10,
  162. onChange: function (page) {
  163. this.loadData(page);
  164. }.bind(this),
  165. showTotal: function (total) {
  166. return '共' + total + '条数据';
  167. }
  168. },
  169. columns: [
  170. {
  171. title: '编号',
  172. dataIndex: 'serialNumber',
  173. key: 'serialNumber'
  174. }, {
  175. title: '省份',
  176. dataIndex: 'province',
  177. key: 'province',
  178. render: text => { return getProvince(text) }
  179. }, {
  180. title: '公司',
  181. dataIndex: 'unitName',
  182. key: 'unitName'
  183. }, {
  184. title: '联系方式',
  185. dataIndex: 'contacts',
  186. key: 'contacts'
  187. }, {
  188. title: '项目名称',
  189. dataIndex: 'projectName',
  190. key: 'projectName'
  191. }, {
  192. title: '项目类型',
  193. dataIndex: 'projectCatagory',
  194. key: 'projectCatagory'
  195. }, {
  196. title: '技术领域',
  197. dataIndex: 'techField',
  198. key: 'techField'
  199. }, {
  200. title: '项目情况',
  201. dataIndex: 'state',
  202. key: 'state',
  203. render: text => { return getTechnologyState(text) },
  204. }, {
  205. title: '派单日',
  206. dataIndex: 'createTime',
  207. key: 'createTime'
  208. }, {
  209. title: '负责人',
  210. dataIndex: 'consultant',
  211. key: 'consultant'
  212. }
  213. ],
  214. dataSource: []
  215. };
  216. },
  217. componentWillMount() {
  218. this.loadData();
  219. this.getAuthorList();
  220. this.getContactsList();
  221. this.getDepartment();
  222. },
  223. tableRowClick(record, index) {
  224. this.state.RowData = record;
  225. this.setState({
  226. showDesc: true
  227. });
  228. },
  229. addClick() {
  230. this.setState({
  231. showAdd: true
  232. });
  233. },
  234. delectRow() {
  235. let deletedIds = [];
  236. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  237. let rowItem = this.state.selectedRows[idx];
  238. if (rowItem.id) {
  239. deletedIds.push(rowItem.id)
  240. }
  241. }
  242. $.ajax({
  243. method: "POST",
  244. dataType: "json",
  245. crossDomain: false,
  246. url: globalConfig.context + "/api/user/cognizance/deleteCognizance",
  247. data: {
  248. ids: deletedIds
  249. }
  250. }).done(function (data) {
  251. if (!data.error.length) {
  252. message.success('删除成功!');
  253. this.setState({
  254. loading: false,
  255. });
  256. } else {
  257. message.warning(data.error[0].message);
  258. };
  259. this.loadData();
  260. }.bind(this));
  261. },
  262. closeDesc(e) {
  263. this.state.showDesc = e;
  264. this.loadData();
  265. },
  266. closeAdd(e) {
  267. this.state.showAdd = e;
  268. this.loadData();
  269. },
  270. render() {
  271. return (
  272. <div className="foster-content" >
  273. <div className="content-title">
  274. <span>科技项目申报管理</span>
  275. </div>
  276. <div className="patent-table">
  277. <Spin spinning={this.state.loading}>
  278. <Table columns={this.state.columns}
  279. dataSource={this.state.dataSource}
  280. pagination={this.state.pagination}
  281. onRowClick={this.tableRowClick} />
  282. </Spin>
  283. </div>
  284. <ApplyChange
  285. data={this.state.RowData}
  286. contactsOption={this.state.contactsOption}
  287. departmentOption={this.state.departmentOption}
  288. showDesc={this.state.showDesc}
  289. closeDesc={this.closeDesc} />
  290. <ApplyAdd
  291. authorOption={this.state.authorOption}
  292. contactsOption={this.state.contactsOption}
  293. departmentOption={this.state.departmentOption}
  294. showAdd={this.state.showAdd}
  295. closeAdd={this.closeAdd} />
  296. </div >
  297. );
  298. }
  299. });
  300. export default Technology;
  301. // <div className="foster-query" style={{ float: "right" }}>
  302. // <div>
  303. // <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  304. // onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  305. // </div>
  306. // </div>