collection.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import React from 'react';
  2. import { Spin, Button, Tabs } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import DemandDesc from '../../portal/search/demandDesc';
  6. import AchievementDesc from '../../portal/search/achievementDesc';
  7. import './content.less';
  8. const TabPane = Tabs.TabPane;
  9. const Content = React.createClass({
  10. achievementLoadData(pageNo) {
  11. this.state.data = [];
  12. this.setState({
  13. loading: true
  14. });
  15. $.ajax({
  16. method: "get",
  17. dataType: "json",
  18. crossDomain: false,
  19. url: globalConfig.context + "/api/user/portal/achievementInterestList",
  20. data: {
  21. pageNo: pageNo || 1,
  22. pageSize: this.state.pagination.pageSize
  23. },
  24. success: function (data) {
  25. let theArr = [];
  26. if (!data.data && !data.data.list) {
  27. if (data.error && data.error.length) {
  28. message.warning(data.error[0].message);
  29. };
  30. } else {
  31. for (let i = 0; i < data.data.list.length; i++) {
  32. let thisdata = data.data.list[i];
  33. theArr.push({
  34. key: i,
  35. id: thisdata.id,
  36. achievementId: thisdata.achievementId,
  37. createTime: thisdata.createTime,
  38. name: thisdata.name,
  39. serialNumber: thisdata.serialNumber,
  40. deletedSign: thisdata.deletedSign,
  41. auditStatus: thisdata.auditStatus,
  42. createTimeFormattedDate: thisdata.createTimeFormattedDate
  43. });
  44. };
  45. }
  46. this.state.achievementPagination.current = data.data.pageNo;
  47. this.state.achievementPagination.total = data.data.totalCount;
  48. this.setState({
  49. achievementDataSource: theArr,
  50. achievementPagination: this.state.achievementPagination
  51. });
  52. }.bind(this),
  53. }).always(function () {
  54. this.setState({
  55. loading: false
  56. });
  57. }.bind(this));
  58. },
  59. demandLoadData(pageNo) {
  60. this.state.data = [];
  61. this.setState({
  62. loading: true
  63. });
  64. $.ajax({
  65. method: "get",
  66. dataType: "json",
  67. crossDomain: false,
  68. url: globalConfig.context + "/api/user/demand/list",
  69. data: {
  70. pageNo: pageNo || 1,
  71. pageSize: this.state.pagination.pageSize,
  72. serialNumber: this.state.serialNumber,
  73. name: this.state.name,
  74. keyword: this.state.keyword,
  75. demandType: this.state.demandType ? Number(this.state.demandType) : undefined,
  76. status: this.state.status ? Number(this.state.status) : undefined,
  77. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined,
  78. validityPeriodStartDate: this.state.validityPeriodDate[0],
  79. validityPeriodEndDate: this.state.validityPeriodDate[1],
  80. releaseDateStartDate: this.state.releaseDate[0],
  81. releaseDateEndDate: this.state.releaseDate[1],
  82. auditStatus: this.state.auditStatus
  83. },
  84. success: function (data) {
  85. let theArr = [];
  86. if (!data.data && !data.data.list) {
  87. if (data.error && data.error.length) {
  88. message.warning(data.error[0].message);
  89. };
  90. } else {
  91. for (let i = 0; i < data.data.list.length; i++) {
  92. let thisdata = data.data.list[i];
  93. theArr.push({
  94. key: i,
  95. id: thisdata.id,
  96. serialNumber: thisdata.serialNumber,
  97. dataCategory: thisdata.dataCategory,
  98. name: thisdata.name,
  99. keyword: thisdata.keyword,
  100. releaseDate: thisdata.releaseDate,
  101. demandType: thisdata.demandType,
  102. validityPeriod: thisdata.validityPeriod,
  103. status: thisdata.status,
  104. releaseStatus: thisdata.releaseStatus,
  105. employerId: thisdata.employerId,
  106. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  107. validityPeriodFormattedDate: thisdata.validityPeriodFormattedDate,
  108. auditStatus: thisdata.auditStatus
  109. });
  110. };
  111. }
  112. this.state.pagination.current = data.data.pageNo;
  113. this.state.pagination.total = data.data.totalCount;
  114. this.setState({
  115. dataSource: theArr,
  116. pagination: this.state.pagination
  117. });
  118. }.bind(this),
  119. }).always(function () {
  120. this.setState({
  121. loading: false
  122. });
  123. }.bind(this));
  124. },
  125. getInitialState() {
  126. return {
  127. loading: false,
  128. demandShowDesc: false,
  129. achievementShowDesc: false,
  130. achievementPagination: {
  131. defaultCurrent: 1,
  132. defaultPageSize: 10,
  133. showQuickJumper: true,
  134. pageSize: 10,
  135. onChange: function (page) {
  136. this.achievementLoadData(page);
  137. }.bind(this),
  138. showTotal: function (total) {
  139. return '共' + total + '条数据';
  140. }
  141. },
  142. achievementColumns: [
  143. {
  144. title: '编号',
  145. dataIndex: 'serialNumber',
  146. key: 'serialNumber',
  147. }, {
  148. title: '需求名称',
  149. dataIndex: 'name',
  150. key: 'name',
  151. }, {
  152. title: '关键字',
  153. dataIndex: 'keyword',
  154. key: 'keyword',
  155. }, {
  156. title: '需求类型',
  157. dataIndex: 'demandType',
  158. key: 'demandType',
  159. render: text => { return getDemandType(text); }
  160. }, {
  161. title: '审核状态',
  162. dataIndex: 'auditStatus',
  163. key: 'auditStatus',
  164. render: text => {
  165. switch (text) {
  166. case "0":
  167. return <span>未提交审核(草稿)</span>;
  168. case "1":
  169. return <span>提交审核</span>;
  170. case "2":
  171. return <span>审核中</span>;
  172. case "3":
  173. return <span>审核通过</span>;
  174. case "4":
  175. return <span>审核未通过</span>;
  176. }
  177. }
  178. }, {
  179. title: '需求状态',
  180. dataIndex: 'status',
  181. key: 'status',
  182. render: text => {
  183. switch (text) {
  184. case "0":
  185. return <span>进行中</span>;
  186. case "1":
  187. return <span>未解决</span>;
  188. case "2":
  189. return <span>已解决</span>;
  190. }
  191. }
  192. }, {
  193. title: '有效期限',
  194. dataIndex: 'validityPeriodFormattedDate',
  195. key: 'validityPeriodFormattedDate',
  196. }, {
  197. title: '发布时间',
  198. dataIndex: 'releaseDateFormattedDate',
  199. key: 'releaseDateFormattedDate',
  200. }
  201. ],
  202. achievementDataSource: [],
  203. demandPagination: {
  204. defaultCurrent: 1,
  205. defaultPageSize: 10,
  206. showQuickJumper: true,
  207. pageSize: 10,
  208. onChange: function (page) {
  209. this.demandLoadData(page);
  210. }.bind(this),
  211. showTotal: function (total) {
  212. return '共' + total + '条数据';
  213. }
  214. },
  215. demandColumns: [
  216. {
  217. title: '编号',
  218. dataIndex: 'serialNumber',
  219. key: 'serialNumber',
  220. }, {
  221. title: '需求名称',
  222. dataIndex: 'name',
  223. key: 'name',
  224. }, {
  225. title: '关键字',
  226. dataIndex: 'keyword',
  227. key: 'keyword',
  228. }, {
  229. title: '需求类型',
  230. dataIndex: 'demandType',
  231. key: 'demandType',
  232. render: text => { return getDemandType(text); }
  233. }, {
  234. title: '审核状态',
  235. dataIndex: 'auditStatus',
  236. key: 'auditStatus',
  237. render: text => {
  238. switch (text) {
  239. case "0":
  240. return <span>未提交审核(草稿)</span>;
  241. case "1":
  242. return <span>提交审核</span>;
  243. case "2":
  244. return <span>审核中</span>;
  245. case "3":
  246. return <span>审核通过</span>;
  247. case "4":
  248. return <span>审核未通过</span>;
  249. }
  250. }
  251. }, {
  252. title: '需求状态',
  253. dataIndex: 'status',
  254. key: 'status',
  255. render: text => {
  256. switch (text) {
  257. case "0":
  258. return <span>进行中</span>;
  259. case "1":
  260. return <span>未解决</span>;
  261. case "2":
  262. return <span>已解决</span>;
  263. }
  264. }
  265. }, {
  266. title: '有效期限',
  267. dataIndex: 'validityPeriodFormattedDate',
  268. key: 'validityPeriodFormattedDate',
  269. }, {
  270. title: '发布时间',
  271. dataIndex: 'releaseDateFormattedDate',
  272. key: 'releaseDateFormattedDate',
  273. }
  274. ],
  275. demandDataSource: [],
  276. };
  277. },
  278. componentDidMount() {
  279. this.achievementLoadData();
  280. },
  281. tabChange(key) {
  282. },
  283. demandRowClick(record, index) {
  284. this.state.demandRowData = record;
  285. this.setState({
  286. demandShowDesc: true
  287. });
  288. },
  289. achievementRowClick(record, index) {
  290. this.state.achievementRowData = record;
  291. this.setState({
  292. achievementShowDesc: true
  293. });
  294. },
  295. demandCloseDesc(e) {
  296. this.setState({
  297. demandShowDesc: e
  298. });
  299. },
  300. achievementCloseDesc(e) {
  301. this.setState({
  302. achievementShowDesc: e
  303. });
  304. },
  305. render() {
  306. return (
  307. <div className="collection">
  308. <Spin spinning={this.state.loading} >
  309. <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  310. <TabPane tab="我感兴趣的成果" key="1">
  311. <Table columns={this.state.achievementColumns}
  312. dataSource={this.state.achievementDataSource}
  313. pagination={this.state.achievementPagination}
  314. onRowClick={this.achievementRowClick} />
  315. </TabPane>
  316. <TabPane tab="我感兴趣的需求" key="2">
  317. <Table columns={this.state.demandColumns}
  318. dataSource={this.state.demandDataSource}
  319. pagination={this.state.demandPagination}
  320. onRowClick={this.demandRowClick} />
  321. </TabPane>
  322. </Tabs>
  323. </Spin>
  324. <DemandDesc data={this.state.demandRowData}
  325. showDesc={this.state.demandShowDesc}
  326. closeDesc={this.demandShowDesc} />
  327. <AchievementDesc data={this.state.achievementRowData}
  328. showDesc={this.state.achievementShowDesc}
  329. closeDesc={this.achievementShowDesc} />
  330. </div>
  331. )
  332. }
  333. });
  334. export default Content;