collection.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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 avatarImg from '../../../../image/avatarImg.png';
  8. import './content.less';
  9. const TabPane = Tabs.TabPane;
  10. const Content = React.createClass({
  11. achievementLoadData(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/portal/achievementInterestList",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.achievementPagination.pageSize
  24. },
  25. success: function (data) {
  26. let theArr = [];
  27. if (!data.data || !data.data.list) {
  28. if (data.error && data.error.length) {
  29. message.warning(data.error[0].message);
  30. };
  31. } else {
  32. for (let i = 0; i < data.data.list.length; i++) {
  33. let thisdata = data.data.list[i];
  34. theArr.push({
  35. key: i,
  36. interestId: thisdata.id,
  37. id: thisdata.achievementId,
  38. createTime: thisdata.createTime,
  39. name: thisdata.name,
  40. serialNumber: thisdata.serialNumber,
  41. keyword: thisdata.keyword,
  42. deletedSign: thisdata.deletedSign,
  43. auditStatus: thisdata.auditStatus,
  44. createTimeFormattedDate: thisdata.createTimeFormattedDate
  45. });
  46. };
  47. }
  48. this.state.achievementPagination.current = data.data.pageNo;
  49. this.state.achievementPagination.total = data.data.totalCount;
  50. this.setState({
  51. achievementDataSource: theArr,
  52. achievementPagination: this.state.achievementPagination
  53. });
  54. }.bind(this),
  55. }).always(function () {
  56. this.setState({
  57. loading: false
  58. });
  59. }.bind(this));
  60. },
  61. demandLoadData(pageNo) {
  62. this.state.data = [];
  63. this.setState({
  64. loading: true
  65. });
  66. $.ajax({
  67. method: "get",
  68. dataType: "json",
  69. crossDomain: false,
  70. url: globalConfig.context + "/api/user/portal/demandInterestList",
  71. data: {
  72. pageNo: pageNo || 1,
  73. pageSize: this.state.demandPagination.pageSize
  74. },
  75. success: function (data) {
  76. let theArr = [];
  77. if (!data.data || !data.data.list) {
  78. if (data.error && data.error.length) {
  79. message.warning(data.error[0].message);
  80. };
  81. } else {
  82. for (let i = 0; i < data.data.list.length; i++) {
  83. let thisdata = data.data.list[i];
  84. theArr.push({
  85. key: i,
  86. interestId: thisdata.id,
  87. id: thisdata.demandId,
  88. createTime: thisdata.createTime,
  89. keyword: thisdata.keyword,
  90. name: thisdata.name,
  91. status: thisdata.status,
  92. serialNumber: thisdata.serialNumber,
  93. deletedSign: thisdata.deletedSign,
  94. auditStatus: thisdata.auditStatus,
  95. createTimeFormattedDate: thisdata.createTimeFormattedDate
  96. });
  97. };
  98. }
  99. this.state.demandPagination.current = data.data.pageNo;
  100. this.state.demandPagination.total = data.data.totalCount;
  101. this.setState({
  102. demandDataSource: theArr,
  103. demandPagination: this.state.demandPagination
  104. });
  105. }.bind(this),
  106. }).always(function () {
  107. this.setState({
  108. loading: false
  109. });
  110. }.bind(this));
  111. },
  112. subscriberLoadData(pageNo) {
  113. this.state.data = [];
  114. this.setState({
  115. loading: true
  116. });
  117. $.ajax({
  118. method: "get",
  119. dataType: "json",
  120. crossDomain: false,
  121. url: globalConfig.context + "/api/user/interest/interestUserList",
  122. data: {
  123. pageNo: pageNo || 1,
  124. pageSize: this.state.subscriberPagination.pageSize
  125. },
  126. success: function (data) {
  127. let theArr = [];
  128. if (!data.data || !data.data.list) {
  129. if (data.error && data.error.length) {
  130. message.warning(data.error[0].message);
  131. };
  132. } else {
  133. for (let i = 0; i < data.data.list.length; i++) {
  134. let thisdata = data.data.list[i];
  135. theArr.push({
  136. key: i,
  137. interestId: thisdata.interestId, //关注ID /api/user/interest/interestUser接口 interestId
  138. uid: thisdata.uid, //被关注人ID
  139. username: thisdata.username, //个人用户名称
  140. unitName: thisdata.unitName, //组织用户名称
  141. name: thisdata.type == 0 ? thisdata.username : thisdata.unitName,
  142. userProvince: thisdata.userProvince, //个人用户省份
  143. orgProvince: thisdata.orgProvince, //组织用户省份
  144. province: thisdata.type == 0 ? thisdata.userProvince : thisdata.orgProvince,
  145. createTime: thisdata.createTime,
  146. type: thisdata.type, //被关注人类型 (0--个人用户,1--组织用户)
  147. demandNum: thisdata.demandNum, //科技需求数量
  148. achievementNum: thisdata.achievementNum, //科技成果数量
  149. personPortraitUrl: thisdata.personPortraitUrl,// 个人用户头像URL
  150. logoUrl: thisdata.logoUrl, //公司LOGO URL
  151. avaterUrl: thisdata.type == 0 ? thisdata.personPortraitUrl : thisdata.logoUrl,
  152. createTimeFormattedDate: thisdata.createTimeFormattedDate, //关注时间
  153. });
  154. };
  155. }
  156. this.state.subscriberPagination.current = data.data.pageNo;
  157. this.state.subscriberPagination.total = data.data.totalCount;
  158. this.setState({
  159. subscriberDataSource: theArr,
  160. subscriberPagination: this.state.subscriberPagination
  161. });
  162. }.bind(this),
  163. }).always(function () {
  164. this.setState({
  165. loading: false
  166. });
  167. }.bind(this));
  168. },
  169. getInitialState() {
  170. return {
  171. loading: false,
  172. achievementShowDesc: false,
  173. achievementPagination: {
  174. defaultCurrent: 1,
  175. defaultPageSize: 10,
  176. showQuickJumper: true,
  177. pageSize: 10,
  178. onChange: function (page) {
  179. this.achievementLoadData(page);
  180. }.bind(this),
  181. showTotal: function (total) {
  182. return '共' + total + '条数据';
  183. }
  184. },
  185. achievementColumns: [
  186. {
  187. title: '编号',
  188. dataIndex: 'serialNumber',
  189. key: 'serialNumber',
  190. }, {
  191. title: '成果名称',
  192. dataIndex: 'name',
  193. key: 'name',
  194. }, {
  195. title: '关键字',
  196. dataIndex: 'keyword',
  197. key: 'keyword',
  198. }, {
  199. title: '状态',
  200. dataIndex: 'auditStatus',
  201. key: 'auditStatus',
  202. render: (text, record) => {
  203. if (record.deletedSign == 1) {
  204. return "已删除"
  205. } else if (record.auditStatus != 3) {
  206. return "已下架"
  207. } else {
  208. return "正常"
  209. }
  210. }
  211. }, {
  212. title: '关注时间',
  213. dataIndex: 'createTimeFormattedDate',
  214. key: 'createTimeFormattedDate',
  215. }
  216. ],
  217. achievementDataSource: [],
  218. demandShowDesc: false,
  219. demandPagination: {
  220. defaultCurrent: 1,
  221. defaultPageSize: 10,
  222. showQuickJumper: true,
  223. pageSize: 10,
  224. onChange: function (page) {
  225. this.demandLoadData(page);
  226. }.bind(this),
  227. showTotal: function (total) {
  228. return '共' + total + '条数据';
  229. }
  230. },
  231. demandColumns: [
  232. {
  233. title: '编号',
  234. dataIndex: 'serialNumber',
  235. key: 'serialNumber',
  236. }, {
  237. title: '需求名称',
  238. dataIndex: 'name',
  239. key: 'name',
  240. }, {
  241. title: '关键字',
  242. dataIndex: 'keyword',
  243. key: 'keyword',
  244. }, {
  245. title: '状态',
  246. dataIndex: 'auditStatus',
  247. key: 'auditStatus',
  248. render: (text, record) => {
  249. if (record.deletedSign == 1) {
  250. return "已删除"
  251. } else if (record.auditStatus != 3) {
  252. return "已下架"
  253. } else if (record.status == 0) {
  254. return "未解决"
  255. } else if (record.status == 1) {
  256. return "已解决"
  257. }
  258. }
  259. }, {
  260. title: '关注时间',
  261. dataIndex: 'createTimeFormattedDate',
  262. key: 'createTimeFormattedDate',
  263. }
  264. ],
  265. demandDataSource: [],
  266. subscriberShowDesc: false,
  267. subscriberPagination: {
  268. defaultCurrent: 1,
  269. defaultPageSize: 10,
  270. showQuickJumper: true,
  271. pageSize: 10,
  272. onChange: function (page) {
  273. this.subscriberLoadData(page);
  274. }.bind(this),
  275. showTotal: function (total) {
  276. return '共' + total + '条数据';
  277. }
  278. },
  279. subscriberColumns: [
  280. {
  281. title: null,
  282. dataIndex: 'avaterUrl',
  283. key: 'avaterUrl',
  284. width: 120,
  285. render: text => {
  286. return <div className="avatar-box">
  287. <img src={text ? (globalConfig.avatarHost + '/upload' + text) : avatarImg} alt="" />
  288. </div>
  289. }
  290. }, {
  291. title: '名称',
  292. dataIndex: 'name',
  293. key: 'name',
  294. }, {
  295. title: '地区',
  296. dataIndex: 'province',
  297. key: 'province',
  298. }, {
  299. title: '类型',
  300. dataIndex: 'type',
  301. key: 'type',
  302. render: (text) => {
  303. if (text == 0) {
  304. return "个人用户"
  305. } else if (text == 1) {
  306. return "组织用户"
  307. }
  308. }
  309. }, {
  310. title: '科技成果数量',
  311. dataIndex: 'achievementNum',
  312. key: 'achievementNum',
  313. }, {
  314. title: '科技需求数量',
  315. dataIndex: 'demandNum',
  316. key: 'demandNum',
  317. }, {
  318. title: '关注时间',
  319. dataIndex: 'createTimeFormattedDate',
  320. key: 'createTimeFormattedDate',
  321. }
  322. ],
  323. subscriberDataSource: [],
  324. };
  325. },
  326. componentWillMount() {
  327. this.achievementLoadData();
  328. },
  329. tabChange(key) {
  330. if (key == 1) {
  331. this.achievementLoadData();
  332. } else if (key == 2) {
  333. this.demandLoadData();
  334. } else if (key == 3) {
  335. this.subscriberLoadData();
  336. }
  337. },
  338. demandRowClick(record, index) {
  339. this.state.demandRowData = record;
  340. if (record.deletedSign !== 1 && record.auditStatus == 3) {
  341. this.setState({
  342. demandShowDesc: true
  343. });
  344. };
  345. },
  346. achievementRowClick(record, index) {
  347. this.state.achievementRowData = record;
  348. if (record.deletedSign !== 1 && record.auditStatus == 3) {
  349. this.setState({
  350. achievementShowDesc: true
  351. });
  352. };
  353. },
  354. demandCloseDesc(e) {
  355. this.setState({
  356. demandShowDesc: e
  357. });
  358. this.demandLoadData();
  359. },
  360. achievementCloseDesc(e) {
  361. this.setState({
  362. achievementShowDesc: e
  363. });
  364. this.achievementLoadData();
  365. },
  366. render() {
  367. return (
  368. <div className="collection">
  369. <Spin spinning={this.state.loading} >
  370. <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  371. <TabPane tab="我感兴趣的成果" key="1">
  372. <Table columns={this.state.achievementColumns}
  373. dataSource={this.state.achievementDataSource}
  374. pagination={this.state.achievementPagination}
  375. onRowClick={this.achievementRowClick} />
  376. </TabPane>
  377. <TabPane tab="我感兴趣的需求" key="2">
  378. <Table columns={this.state.demandColumns}
  379. dataSource={this.state.demandDataSource}
  380. pagination={this.state.demandPagination}
  381. onRowClick={this.demandRowClick} />
  382. </TabPane>
  383. <TabPane tab="我感兴趣的用户" key="3">
  384. <Table columns={this.state.subscriberColumns}
  385. dataSource={this.state.subscriberDataSource}
  386. pagination={this.state.subscriberPagination}
  387. onRowClick={this.subscriberRowClick} />
  388. </TabPane>
  389. </Tabs>
  390. </Spin>
  391. <DemandDesc data={this.state.demandRowData}
  392. showDesc={this.state.demandShowDesc}
  393. closeDesc={this.demandCloseDesc} />
  394. <AchievementDesc data={this.state.achievementRowData}
  395. showDesc={this.state.achievementShowDesc}
  396. closeDesc={this.achievementCloseDesc} />
  397. </div>
  398. )
  399. }
  400. });
  401. export default Content;