technology.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. departmentObj: data.data
  147. });
  148. }.bind(this),
  149. });
  150. },
  151. getInitialState() {
  152. return {
  153. authorOption: [],
  154. selectedRows: [],
  155. loading: false,
  156. showAdd: false,
  157. showDesc: false,
  158. pagination: {
  159. defaultCurrent: 1,
  160. defaultPageSize: 10,
  161. showQuickJumper: true,
  162. pageSize: 10,
  163. onChange: function (page) {
  164. this.loadData(page);
  165. }.bind(this),
  166. showTotal: function (total) {
  167. return '共' + total + '条数据';
  168. }
  169. },
  170. columns: [
  171. {
  172. title: '编号',
  173. dataIndex: 'serialNumber',
  174. key: 'serialNumber'
  175. }, {
  176. title: '省份',
  177. dataIndex: 'province',
  178. key: 'province',
  179. render: text => { return getProvince(text) }
  180. }, {
  181. title: '公司',
  182. dataIndex: 'unitName',
  183. key: 'unitName'
  184. }, {
  185. title: '联系方式',
  186. dataIndex: 'contacts',
  187. key: 'contacts'
  188. }, {
  189. title: '项目名称',
  190. dataIndex: 'projectName',
  191. key: 'projectName'
  192. }, {
  193. title: '项目类型',
  194. dataIndex: 'projectCatagory',
  195. key: 'projectCatagory'
  196. }, {
  197. title: '技术领域',
  198. dataIndex: 'techField',
  199. key: 'techField'
  200. }, {
  201. title: '项目情况',
  202. dataIndex: 'state',
  203. key: 'state',
  204. render: text => { return getTechnologyState(text) },
  205. }, {
  206. title: '派单日',
  207. dataIndex: 'createTime',
  208. key: 'createTime'
  209. }, {
  210. title: '负责人',
  211. dataIndex: 'consultant',
  212. key: 'consultant'
  213. }
  214. ],
  215. dataSource: []
  216. };
  217. },
  218. componentWillMount() {
  219. this.loadData();
  220. this.getAuthorList();
  221. this.getContactsList();
  222. this.getDepartment();
  223. },
  224. tableRowClick(record, index) {
  225. this.state.RowData = record;
  226. this.setState({
  227. showDesc: true
  228. });
  229. },
  230. addClick() {
  231. this.setState({
  232. showAdd: true
  233. });
  234. },
  235. delectRow() {
  236. let deletedIds = [];
  237. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  238. let rowItem = this.state.selectedRows[idx];
  239. if (rowItem.id) {
  240. deletedIds.push(rowItem.id)
  241. }
  242. }
  243. $.ajax({
  244. method: "POST",
  245. dataType: "json",
  246. crossDomain: false,
  247. url: globalConfig.context + "/api/user/cognizance/deleteCognizance",
  248. data: {
  249. ids: deletedIds
  250. }
  251. }).done(function (data) {
  252. if (!data.error.length) {
  253. message.success('删除成功!');
  254. this.setState({
  255. loading: false,
  256. });
  257. } else {
  258. message.warning(data.error[0].message);
  259. };
  260. this.loadData();
  261. }.bind(this));
  262. },
  263. closeDesc(e) {
  264. this.state.showDesc = e;
  265. this.loadData();
  266. },
  267. closeAdd(e) {
  268. this.state.showAdd = e;
  269. this.loadData();
  270. },
  271. render() {
  272. return (
  273. <div className="foster-content" >
  274. <div className="content-title">
  275. <span>科技项目申报管理</span>
  276. </div>
  277. <div className="patent-table">
  278. <Spin spinning={this.state.loading}>
  279. <Table columns={this.state.columns}
  280. dataSource={this.state.dataSource}
  281. pagination={this.state.pagination}
  282. style={{
  283. cursor: 'pointer',
  284. }}
  285. onRowClick={this.tableRowClick} />
  286. </Spin>
  287. </div>
  288. <ApplyChange
  289. data={this.state.RowData}
  290. contactsOption={this.state.contactsOption}
  291. departmentOption={this.state.departmentOption}
  292. departmentObj={this.state.departmentObj}
  293. showDesc={this.state.showDesc}
  294. closeDesc={this.closeDesc} />
  295. <ApplyAdd
  296. authorOption={this.state.authorOption}
  297. contactsOption={this.state.contactsOption}
  298. departmentOption={this.state.departmentOption}
  299. departmentObj={this.state.departmentObj}
  300. showAdd={this.state.showAdd}
  301. closeAdd={this.closeAdd} />
  302. </div >
  303. );
  304. }
  305. });
  306. export default Technology;
  307. // <div className="foster-query" style={{ float: "right" }}>
  308. // <div>
  309. // <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  310. // onClick={this.addClick}>申请新科技项目<Icon type="plus" /></Button>
  311. // </div>
  312. // </div>