content.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import React from 'react';
  2. import { Spin, Button, Tabs, Table, message } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import '../content.less';
  6. import './content.less';
  7. import LeftTab from './leftTab.jsx';
  8. const TabPane = Tabs.TabPane;
  9. const MessageModal = React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false,
  14. pagination: {
  15. defaultCurrent: 1,
  16. defaultPageSize: 10,
  17. showQuickJumper: true,
  18. pageSize: 10,
  19. onChange: function (page) {
  20. this.loadReaded(page);
  21. }.bind(this),
  22. showTotal: function (total) {
  23. return '共' + total + '条数据';
  24. }
  25. },
  26. UnreadPagination: {
  27. defaultCurrent: 1,
  28. defaultPageSize: 10,
  29. showQuickJumper: true,
  30. pageSize: 10,
  31. onChange: function (page) {
  32. this.loadUnread(page);
  33. }.bind(this),
  34. showTotal: function (total) {
  35. return '共' + total + '条数据';
  36. }
  37. },
  38. columns: [
  39. {
  40. title: '编号',
  41. dataIndex: 'key',
  42. key: 'key'
  43. }, {
  44. title: '类型',
  45. dataIndex: 'noticeType',
  46. key: 'noticeType',
  47. render: (text, record) => {
  48. switch (text) {
  49. case 1:
  50. return <a href={globalConfig.context + "/admin/servicesManage/patent.html?rid=" + record.rid + "&uid=" + record.uid + "#comprehensive"}> {record.noticeTypeName} </a>;
  51. case 3:
  52. return <a href={globalConfig.context + "/admin/servicesManage/copyright.html?rid=" + record.rid + "&uid=" + record.uid + "#copyright"}> {record.noticeTypeName} </a>;
  53. case 2:
  54. return <a href={globalConfig.context + "/admin/servicesManage/highTech.html?rid=" + record.rid + "&uid=" + record.uid + "&year=" + record.year + "#highTechApply"}> {record.noticeTypeName} </a>;
  55. case 4:
  56. return <a href={globalConfig.context + "/admin/servicesManage/technology.html?rid=" + record.rid + "&uid=" + record.uid + "#applyManage"}> {record.noticeTypeName} </a>;
  57. case 5:
  58. return <a href={globalConfig.context + "/admin/userManage.html?id=" + record.uid + "&type=0" + (window.showUserList ? "#userList" : "#customerList")}> {record.noticeTypeName} </a>;
  59. case 6:
  60. return <a href={globalConfig.context + "/admin/userManage.html?id=" + record.uid + "&type=1" + (window.showOrgList ? "#orgList" : "#customerList")}> {record.noticeTypeName} </a >;
  61. case 7:
  62. return <a href={globalConfig.context + "/admin/servicesManage/contract.html?rid=" + record.rid + "&uid=" + record.uid + "#contract"}> {record.noticeTypeName} </a >;
  63. case 8:
  64. return <a href={globalConfig.context + "/admin/demand.html?rid=" + record.rid + "#techDemandUser"}> {record.noticeTypeName} </a >;
  65. case 9:
  66. return <a href={globalConfig.context + "/admin/demand.html?rid=" + record.rid + "&uid=" + record.uid + "#techDemandOrg"}> {record.noticeTypeName} </a >;
  67. case 10:
  68. return <a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName} </a >;
  69. case 11:
  70. return <a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName+'123'} </a >;
  71. }
  72. }
  73. }, {
  74. title: '时间',
  75. dataIndex: 'createTimeFormattedDate',
  76. key: 'createTimeFormattedDate'
  77. }, {
  78. title: '内容',
  79. dataIndex: 'content',
  80. key: 'content',
  81. }, {
  82. title: '公司',
  83. dataIndex: 'unitName',
  84. key: 'unitName',
  85. }, {
  86. title: '业务员',
  87. dataIndex: 'principle',
  88. key: 'principle',
  89. }
  90. ],
  91. data: []
  92. };
  93. },
  94. setStore(record){
  95. var data = {
  96. "id":"506f0ba0-9c0d-4c98-a8e9-e1323f1974c0",
  97. "ownerType":"1"
  98. };
  99. var newData = JSON.stringify(data);
  100. localStorage.setItem('newData',newData);
  101. window.location.href=globalConfig.context + "/admin/achievement.html?rid=409bf85f-5cd7-459b-9c7c-4865001a87a2#techAchievementManage"
  102. },
  103. loadReaded(pageNo) {
  104. this.state.data = [];
  105. this.setState({
  106. loading: true
  107. });
  108. $.ajax({
  109. method: "get",
  110. dataType: "json",
  111. crossDomain: false,
  112. url: globalConfig.context + "/api/admin/notice/readed",
  113. data: {
  114. pageNo: pageNo || 1,
  115. pageSize: this.state.pagination.pageSize,
  116. }
  117. }).done((data) => {
  118. if (!data.data) {
  119. if (data.error && data.error.length) {
  120. message.warning(data.error[0].message);
  121. return;
  122. };
  123. };
  124. this.state.data = [];
  125. for (let i = 0; i < data.data.list.length; i++) {
  126. let thisdata = data.data.list[i];
  127. this.state.data.push({
  128. key: i + 1,
  129. id: thisdata.id,
  130. rid: thisdata.rid,
  131. uid: thisdata.uid,
  132. aid: thisdata.aid,
  133. noticeType: thisdata.noticeType,
  134. year: thisdata.year,
  135. noticeTypeName: thisdata.noticeTypeName,
  136. content: thisdata.content,
  137. createTime: thisdata.createTime,
  138. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  139. principle: thisdata.principle,
  140. unitName: thisdata.unitName
  141. });
  142. };
  143. this.state.pagination.current = data.data.pageNo;
  144. this.state.pagination.total = data.data.totalCount;
  145. this.setState({
  146. dataSource: this.state.data,
  147. pagination: this.state.pagination
  148. });
  149. }).always(function () {
  150. this.setState({
  151. loading: false
  152. });
  153. }.bind(this));
  154. },
  155. loadUnread(pageNo) {
  156. this.state.data = [];
  157. this.setState({
  158. loading: true
  159. });
  160. $.ajax({
  161. method: "get",
  162. dataType: "json",
  163. crossDomain: false,
  164. url: globalConfig.context + "/api/admin/notice/unread",
  165. data: {
  166. pageNo: pageNo || 1,
  167. pageSize: this.state.UnreadPagination.pageSize,
  168. }
  169. }).done((data) => {
  170. if (!data.data) {
  171. if (data.error && data.error.length) {
  172. message.warning(data.error[0].message);
  173. return;
  174. };
  175. };
  176. this.state.data = [];
  177. for (let i = 0; i < data.data.list.length; i++) {
  178. let thisdata = data.data.list[i];
  179. this.state.data.push({
  180. key: i + 1,
  181. id: thisdata.id,
  182. rid: thisdata.rid,
  183. uid: thisdata.uid,
  184. aid: thisdata.aid,
  185. noticeType: thisdata.noticeType,
  186. year: thisdata.year,
  187. noticeTypeName: thisdata.noticeTypeName,
  188. content: thisdata.content,
  189. createTime: thisdata.createTime,
  190. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  191. principle: thisdata.principle,
  192. unitName: thisdata.unitName
  193. });
  194. };
  195. this.state.UnreadPagination.current = data.data.pageNo;
  196. this.state.UnreadPagination.total = data.data.totalCount;
  197. this.setState({
  198. unreadData: this.state.data,
  199. UnreadPagination: this.state.UnreadPagination
  200. });
  201. }).always(function () {
  202. this.setState({
  203. loading: false
  204. });
  205. }.bind(this));
  206. },
  207. componentWillMount() {
  208. this.loadReaded();
  209. this.loadUnread();
  210. },
  211. render() {
  212. return (
  213. <div className="set-content">
  214. <div className="set-title">
  215. <span>管理员中心</span>
  216. </div>
  217. <Spin spinning={this.state.loading} className='spin-box'>
  218. <Tabs defaultActiveKey="1">
  219. <Tabs.TabPane tab="新信息" key="1">
  220. <Table columns={this.state.columns}
  221. dataSource={this.state.unreadData}
  222. pagination={this.state.UnreadPagination} />
  223. </Tabs.TabPane>
  224. <Tabs.TabPane tab="已读信息" key="2">
  225. <Table columns={this.state.columns}
  226. dataSource={this.state.dataSource}
  227. pagination={this.state.pagination} />
  228. </Tabs.TabPane>
  229. </Tabs>
  230. </Spin>
  231. </div>
  232. );
  233. }
  234. });
  235. const Content = React.createClass({
  236. getInitialState() {
  237. return {
  238. loading: false
  239. };
  240. },
  241. render() {
  242. return (
  243. <div className="manage-content">
  244. <LeftTab handlekey={this.handlekey} />
  245. <div className="content-right">
  246. <Spin spinning={this.state.loading} className='spin-box'>
  247. <div className="index-content">
  248. <MessageModal />
  249. </div>
  250. </Spin>
  251. </div>
  252. </div>
  253. )
  254. }
  255. });
  256. export default Content;
  257. // <div className="index-content">
  258. // <div className="index-userdata clearfix">
  259. // <p className="acc-title">{this.state.number}</p>
  260. // <div className="userdata-img">
  261. // <img src={globalConfig.staticHost + "/upload" + this.state.personPortraitUrl} alt="" />
  262. // </div>
  263. // <div className="userdata-content">
  264. // {(() => {
  265. // switch (userData.lvl || this.state.userlvl) {
  266. // case '0':
  267. // return <p className="userdata-lvl">等级:<span>LV1</span> 普通用户</p>;
  268. // case '1':
  269. // return <p className="userdata-lvl">等级:<span>LV2</span> 已认证用户</p>;
  270. // };
  271. // })()}
  272. // <p>完善资料 {this.state.per}% ,<a href="./set.html">继续完善</a>,有助于提高您的资信</p>
  273. // <p className="userdata-relate" style={{ 'display': 'none' }}>
  274. // <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  275. // <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  276. // <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  277. // </p>
  278. // <div className="userdata-follow">已有<a href="">{this.state.follow}</a>人关注你</div>
  279. // </div>
  280. // </div>
  281. // <div className="index-record">
  282. // <p className="acc-title">我的轨迹</p>
  283. // <ul className="record-list clearfix">
  284. // <li>技术成果:<a href="">{this.state.chengguo}</a>项</li>
  285. // <li>技术开发:<a href="">{this.state.kaifa}</a>项</li>
  286. // <li>科技服务:<a href="">{this.state.fuwu}</a>项</li>
  287. // <li>发布需求:<a href="">{this.state.xuqiu}</a>项</li>
  288. // </ul>
  289. // </div>
  290. // <div className="index-activity">
  291. // <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  292. // <TabPane tab="活动" key="1">
  293. // <p className="acc-title">即将举办的活动</p>
  294. // <ul className="activity-list">
  295. // {
  296. // this.state.activityArr.map(function (item, i) {
  297. // return <li key={i}>
  298. // <span className="list-type">[{item.type}]</span>
  299. // <span className="list-title">{item.title}</span>
  300. // <a href={item.link}>报名</a>
  301. // <span className="list-time">{item.time}</span>
  302. // </li>;
  303. // })
  304. // }
  305. // </ul>
  306. // </TabPane>
  307. // <TabPane tab="其他" key="2">Content of Tab Pane 2</TabPane>
  308. // </Tabs>
  309. // </div>
  310. // </div>