content.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 '../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={globalConfig.context + "/admin/achievement.html?rid=" + record.rid + "#orgTechAchievement"}> {record.noticeTypeName} </a >;
  69. case 11:
  70. return <a href={globalConfig.context + "/admin/achievement.html?rid=" + record.rid + "#userTechAchievement"}> {record.noticeTypeName} </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. loadReaded(pageNo) {
  95. this.state.data = [];
  96. this.setState({
  97. loading: true
  98. });
  99. $.ajax({
  100. method: "get",
  101. dataType: "json",
  102. crossDomain: false,
  103. url: globalConfig.context + "/api/admin/notice/readed",
  104. data: {
  105. pageNo: pageNo || 1,
  106. pageSize: this.state.pagination.pageSize,
  107. }
  108. }).done((data) => {
  109. if (!data.data) {
  110. if (data.error && data.error.length) {
  111. message.warning(data.error[0].message);
  112. return;
  113. };
  114. };
  115. this.state.data = [];
  116. for (let i = 0; i < data.data.list.length; i++) {
  117. let thisdata = data.data.list[i];
  118. this.state.data.push({
  119. key: i + 1,
  120. id: thisdata.id,
  121. rid: thisdata.rid,
  122. uid: thisdata.uid,
  123. aid: thisdata.aid,
  124. noticeType: thisdata.noticeType,
  125. year: thisdata.year,
  126. noticeTypeName: thisdata.noticeTypeName,
  127. content: thisdata.content,
  128. createTime: thisdata.createTime,
  129. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  130. principle: thisdata.principle,
  131. unitName: thisdata.unitName
  132. });
  133. };
  134. this.state.pagination.current = data.data.pageNo;
  135. this.state.pagination.total = data.data.totalCount;
  136. this.setState({
  137. dataSource: this.state.data,
  138. pagination: this.state.pagination
  139. });
  140. }).always(function () {
  141. this.setState({
  142. loading: false
  143. });
  144. }.bind(this));
  145. },
  146. loadUnread(pageNo) {
  147. this.state.data = [];
  148. this.setState({
  149. loading: true
  150. });
  151. $.ajax({
  152. method: "get",
  153. dataType: "json",
  154. crossDomain: false,
  155. url: globalConfig.context + "/api/admin/notice/unread",
  156. data: {
  157. pageNo: pageNo || 1,
  158. pageSize: this.state.UnreadPagination.pageSize,
  159. }
  160. }).done((data) => {
  161. if (!data.data) {
  162. if (data.error && data.error.length) {
  163. message.warning(data.error[0].message);
  164. return;
  165. };
  166. };
  167. this.state.data = [];
  168. for (let i = 0; i < data.data.list.length; i++) {
  169. let thisdata = data.data.list[i];
  170. this.state.data.push({
  171. key: i + 1,
  172. id: thisdata.id,
  173. rid: thisdata.rid,
  174. uid: thisdata.uid,
  175. aid: thisdata.aid,
  176. noticeType: thisdata.noticeType,
  177. year: thisdata.year,
  178. noticeTypeName: thisdata.noticeTypeName,
  179. content: thisdata.content,
  180. createTime: thisdata.createTime,
  181. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  182. principle: thisdata.principle,
  183. unitName: thisdata.unitName
  184. });
  185. };
  186. this.state.UnreadPagination.current = data.data.pageNo;
  187. this.state.UnreadPagination.total = data.data.totalCount;
  188. this.setState({
  189. unreadData: this.state.data,
  190. UnreadPagination: this.state.UnreadPagination
  191. });
  192. }).always(function () {
  193. this.setState({
  194. loading: false
  195. });
  196. }.bind(this));
  197. },
  198. componentWillMount() {
  199. this.loadReaded();
  200. this.loadUnread();
  201. },
  202. render() {
  203. return (
  204. <div className="set-content">
  205. <div className="set-title">
  206. <span>管理员中心</span>
  207. </div>
  208. <Spin spinning={this.state.loading} className='spin-box'>
  209. <Tabs defaultActiveKey="1">
  210. <Tabs.TabPane tab="新信息" key="1">
  211. <Table columns={this.state.columns}
  212. dataSource={this.state.unreadData}
  213. pagination={this.state.UnreadPagination} />
  214. </Tabs.TabPane>
  215. <Tabs.TabPane tab="已读信息" key="2">
  216. <Table columns={this.state.columns}
  217. dataSource={this.state.dataSource}
  218. pagination={this.state.pagination} />
  219. </Tabs.TabPane>
  220. </Tabs>
  221. </Spin>
  222. </div>
  223. );
  224. }
  225. });
  226. const Content = React.createClass({
  227. getInitialState() {
  228. return {
  229. loading: false
  230. };
  231. },
  232. render() {
  233. return (
  234. <div className="manage-content">
  235. <LeftTab handlekey={this.handlekey} />
  236. <div className="content-right">
  237. <Spin spinning={this.state.loading} className='spin-box'>
  238. <div className="index-content">
  239. <MessageModal />
  240. </div>
  241. </Spin>
  242. </div>
  243. </div>
  244. )
  245. }
  246. });
  247. export default Content;
  248. // <div className="index-content">
  249. // <div className="index-userdata clearfix">
  250. // <p className="acc-title">{this.state.number}</p>
  251. // <div className="userdata-img">
  252. // <img src={globalConfig.staticHost + "/upload" + this.state.personPortraitUrl} alt="" />
  253. // </div>
  254. // <div className="userdata-content">
  255. // {(() => {
  256. // switch (userData.lvl || this.state.userlvl) {
  257. // case '0':
  258. // return <p className="userdata-lvl">等级:<span>LV1</span> 普通用户</p>;
  259. // case '1':
  260. // return <p className="userdata-lvl">等级:<span>LV2</span> 已认证用户</p>;
  261. // };
  262. // })()}
  263. // <p>完善资料 {this.state.per}% ,<a href="./set.html">继续完善</a>,有助于提高您的资信</p>
  264. // <p className="userdata-relate" style={{ 'display': 'none' }}>
  265. // <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  266. // <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  267. // <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  268. // </p>
  269. // <div className="userdata-follow">已有<a href="">{this.state.follow}</a>人关注你</div>
  270. // </div>
  271. // </div>
  272. // <div className="index-record">
  273. // <p className="acc-title">我的轨迹</p>
  274. // <ul className="record-list clearfix">
  275. // <li>技术成果:<a href="">{this.state.chengguo}</a>项</li>
  276. // <li>技术开发:<a href="">{this.state.kaifa}</a>项</li>
  277. // <li>科技服务:<a href="">{this.state.fuwu}</a>项</li>
  278. // <li>发布需求:<a href="">{this.state.xuqiu}</a>项</li>
  279. // </ul>
  280. // </div>
  281. // <div className="index-activity">
  282. // <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  283. // <TabPane tab="活动" key="1">
  284. // <p className="acc-title">即将举办的活动</p>
  285. // <ul className="activity-list">
  286. // {
  287. // this.state.activityArr.map(function (item, i) {
  288. // return <li key={i}>
  289. // <span className="list-type">[{item.type}]</span>
  290. // <span className="list-title">{item.title}</span>
  291. // <a href={item.link}>报名</a>
  292. // <span className="list-time">{item.time}</span>
  293. // </li>;
  294. // })
  295. // }
  296. // </ul>
  297. // </TabPane>
  298. // <TabPane tab="其他" key="2">Content of Tab Pane 2</TabPane>
  299. // </Tabs>
  300. // </div>
  301. // </div>