collection.jsx 17 KB

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