collection.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. import React from 'react';
  2. import { Spin, Button, Tabs, Table } 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.achievementPagination.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. interestId: thisdata.id,
  36. id: thisdata.achievementId,
  37. createTime: thisdata.createTime,
  38. name: thisdata.name,
  39. serialNumber: thisdata.serialNumber,
  40. keyword: thisdata.keyword,
  41. deletedSign: thisdata.deletedSign,
  42. auditStatus: thisdata.auditStatus,
  43. createTimeFormattedDate: thisdata.createTimeFormattedDate
  44. });
  45. };
  46. }
  47. this.state.achievementPagination.current = data.data.pageNo;
  48. this.state.achievementPagination.total = data.data.totalCount;
  49. this.setState({
  50. achievementDataSource: theArr,
  51. achievementPagination: this.state.achievementPagination
  52. });
  53. }.bind(this),
  54. }).always(function () {
  55. this.setState({
  56. loading: false
  57. });
  58. }.bind(this));
  59. },
  60. demandLoadData(pageNo) {
  61. this.state.data = [];
  62. this.setState({
  63. loading: true
  64. });
  65. $.ajax({
  66. method: "get",
  67. dataType: "json",
  68. crossDomain: false,
  69. url: globalConfig.context + "/api/user/portal/demandInterestList",
  70. data: {
  71. pageNo: pageNo || 1,
  72. pageSize: this.state.demandPagination.pageSize
  73. },
  74. success: function (data) {
  75. let theArr = [];
  76. if (!data.data && !data.data.list) {
  77. if (data.error && data.error.length) {
  78. message.warning(data.error[0].message);
  79. };
  80. } else {
  81. for (let i = 0; i < data.data.list.length; i++) {
  82. let thisdata = data.data.list[i];
  83. theArr.push({
  84. key: i,
  85. interestId: thisdata.id,
  86. id: thisdata.demandtId,
  87. createTime: thisdata.createTime,
  88. keyword: thisdata.keyword,
  89. name: thisdata.name,
  90. status: thisdata.status,
  91. serialNumber: thisdata.serialNumber,
  92. deletedSign: thisdata.deletedSign,
  93. auditStatus: thisdata.auditStatus,
  94. createTimeFormattedDate: thisdata.createTimeFormattedDate
  95. });
  96. };
  97. }
  98. this.state.demandPagination.current = data.data.pageNo;
  99. this.state.demandPagination.total = data.data.totalCount;
  100. this.setState({
  101. demandDataSource: theArr,
  102. demandPagination: this.state.demandPagination
  103. });
  104. }.bind(this),
  105. }).always(function () {
  106. this.setState({
  107. loading: false
  108. });
  109. }.bind(this));
  110. },
  111. getInitialState() {
  112. return {
  113. loading: false,
  114. demandShowDesc: false,
  115. achievementShowDesc: false,
  116. achievementPagination: {
  117. defaultCurrent: 1,
  118. defaultPageSize: 10,
  119. showQuickJumper: true,
  120. pageSize: 10,
  121. onChange: function (page) {
  122. this.achievementLoadData(page);
  123. }.bind(this),
  124. showTotal: function (total) {
  125. return '共' + total + '条数据';
  126. }
  127. },
  128. achievementColumns: [
  129. {
  130. title: '编号',
  131. dataIndex: 'serialNumber',
  132. key: 'serialNumber',
  133. }, {
  134. title: '需求名称',
  135. dataIndex: 'name',
  136. key: 'name',
  137. }, {
  138. title: '关键字',
  139. dataIndex: 'keyword',
  140. key: 'keyword',
  141. }, {
  142. title: '状态',
  143. dataIndex: 'auditStatus',
  144. key: 'auditStatus',
  145. render: (text, record) => {
  146. if (record.deletedSign == 1) {
  147. return "已删除"
  148. } else if (record.auditStatus !== 3) {
  149. return "已下架"
  150. } else {
  151. return "正常"
  152. }
  153. }
  154. }, {
  155. title: '关注时间',
  156. dataIndex: 'createTimeFormattedDate',
  157. key: 'createTimeFormattedDate',
  158. }
  159. ],
  160. achievementDataSource: [],
  161. demandPagination: {
  162. defaultCurrent: 1,
  163. defaultPageSize: 10,
  164. showQuickJumper: true,
  165. pageSize: 10,
  166. onChange: function (page) {
  167. this.demandLoadData(page);
  168. }.bind(this),
  169. showTotal: function (total) {
  170. return '共' + total + '条数据';
  171. }
  172. },
  173. demandColumns: [
  174. {
  175. title: '编号',
  176. dataIndex: 'serialNumber',
  177. key: 'serialNumber',
  178. }, {
  179. title: '需求名称',
  180. dataIndex: 'name',
  181. key: 'name',
  182. }, {
  183. title: '关键字',
  184. dataIndex: 'keyword',
  185. key: 'keyword',
  186. }, {
  187. title: '状态',
  188. dataIndex: 'auditStatus',
  189. key: 'auditStatus',
  190. render: (text, record) => {
  191. if (record.deletedSign == 1) {
  192. return "已删除"
  193. } else if (record.auditStatus !== 3) {
  194. return "已下架"
  195. } else if (record.status == 0) {
  196. return "未解决"
  197. } else if (record.status == 1) {
  198. return "已解决"
  199. }
  200. }
  201. }, {
  202. title: '关注时间',
  203. dataIndex: 'createTimeFormattedDate',
  204. key: 'createTimeFormattedDate',
  205. }
  206. ],
  207. demandDataSource: [],
  208. };
  209. },
  210. componentWillMount() {
  211. this.achievementLoadData();
  212. this.demandLoadData();
  213. },
  214. tabChange(key) {
  215. },
  216. demandRowClick(record, index) {
  217. this.state.demandRowData = record;
  218. if (record.deletedSign !== 1 && record.auditStatus == 3) {
  219. this.setState({
  220. demandShowDesc: true
  221. });
  222. };
  223. },
  224. achievementRowClick(record, index) {
  225. this.state.achievementRowData = record;
  226. if (record.deletedSign !== 1 && record.auditStatus == 3) {
  227. this.setState({
  228. achievementShowDesc: true
  229. });
  230. };
  231. },
  232. demandCloseDesc(e) {
  233. this.setState({
  234. demandShowDesc: e
  235. });
  236. this.demandLoadData();
  237. },
  238. achievementCloseDesc(e) {
  239. this.setState({
  240. achievementShowDesc: e
  241. });
  242. this.achievementLoadData();
  243. },
  244. render() {
  245. return (
  246. <div className="collection">
  247. <Spin spinning={this.state.loading} >
  248. <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  249. <TabPane tab="我感兴趣的成果" key="1">
  250. <Table columns={this.state.achievementColumns}
  251. dataSource={this.state.achievementDataSource}
  252. pagination={this.state.achievementPagination}
  253. onRowClick={this.achievementRowClick} />
  254. </TabPane>
  255. <TabPane tab="我感兴趣的需求" key="2">
  256. <Table columns={this.state.demandColumns}
  257. dataSource={this.state.demandDataSource}
  258. pagination={this.state.demandPagination}
  259. onRowClick={this.demandRowClick} />
  260. </TabPane>
  261. </Tabs>
  262. </Spin>
  263. <DemandDesc data={this.state.demandRowData}
  264. showDesc={this.state.demandShowDesc}
  265. closeDesc={this.demandCloseDesc} />
  266. <AchievementDesc data={this.state.achievementRowData}
  267. showDesc={this.state.achievementShowDesc}
  268. closeDesc={this.achievementCloseDesc} />
  269. </div>
  270. )
  271. }
  272. });
  273. export default Content;