content.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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. // return <div>{
  49. // text<8?<a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName} </a >:
  50. // <span>{record.noticeTypeName}</span>
  51. // }</div>
  52. //return <a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName} </a >
  53. return(<span>{record.noticeTypeName}</span>)
  54. }
  55. }, {
  56. title: '时间',
  57. dataIndex: 'createTimeFormattedDate',
  58. key: 'createTimeFormattedDate'
  59. }, {
  60. title: '内容',
  61. dataIndex: 'content',
  62. key: 'content',
  63. }, {
  64. title: '公司',
  65. dataIndex: 'unitName',
  66. key: 'unitName',
  67. }, {
  68. title: '业务员',
  69. dataIndex: 'principle',
  70. key: 'principle',
  71. }
  72. ],
  73. data: []
  74. };
  75. },
  76. //主菜单请求
  77. mainMenu(){
  78. this.setState({
  79. loading:true
  80. });
  81. $.ajax({
  82. method: "get",
  83. dataType: "json",
  84. crossDomain: false,
  85. url: globalConfig.context + "/api/admin/selectNavList",
  86. data: {
  87. },
  88. success:function(data){
  89. if (!data.data) {
  90. if (data.error && data.error.length) {
  91. message.warning(data.error[0].message);
  92. return;
  93. };
  94. };
  95. this.setState({
  96. menu:data.data
  97. });
  98. }.bind(this),
  99. }).always(function(data){
  100. this.setState({
  101. loading:false
  102. })
  103. }.bind(this))
  104. },
  105. finId(text){
  106. var data=this.state.menu||[];
  107. var rid='';
  108. switch(text) {
  109. case 1:
  110. data.map(function(nub, index) {
  111. if(nub.url.indexOf('demand') != -1) {
  112. rid = nub.id;
  113. }
  114. });
  115. break;
  116. case 2:
  117. data.map(function(nub, index) {
  118. if(nub.url.indexOf('demand') != -1) {
  119. rid = nub.id;
  120. }
  121. });
  122. break;
  123. case 3:
  124. data.map(function(nub, index) {
  125. if(nub.url.indexOf('achievement') != -1) {
  126. rid = nub.id;
  127. }
  128. });
  129. break;
  130. case 4:
  131. data.map(function(nub, index) {
  132. if(nub.url.indexOf('achievement') != -1) {
  133. rid = nub.id;
  134. }
  135. });
  136. break;
  137. case 5:
  138. data.map(function(nub, index) {
  139. if(nub.url.indexOf('order') != -1) {
  140. rid = nub.id;
  141. }
  142. });
  143. break;
  144. case 6:
  145. data.map(function(nub, index) {
  146. if(nub.url.indexOf('order') != -1) {
  147. rid = nub.id;
  148. }
  149. });
  150. break;
  151. case 7:
  152. data.map(function(nub, index) {
  153. if(nub.url.indexOf('servicesManage') != -1) {
  154. rid = nub.id;
  155. }
  156. });
  157. break;
  158. default:
  159. rid='';
  160. }
  161. return rid;
  162. },
  163. //跳转详情
  164. setStore(record){
  165. localStorage.setItem('newData',{});
  166. let ids = record.noticeType;
  167. let rid = this.finId(ids) || "";
  168. var urls='',
  169. dataJson={};
  170. switch (ids) {
  171. case 1:
  172. urls = "/admin/demand.html?rid=" + rid +"#techDemandAudit";
  173. dataJson = {
  174. "id":record.uid,
  175. //"id":"3f93588b-332e-4353-bbfd-f1451b4b390c",
  176. "dataCategory":"0"
  177. };
  178. break;
  179. case 2:
  180. urls = "/admin/demand.html?rid=" + rid+ "#techDemandPublish";
  181. dataJson = {
  182. "id":record.uid,
  183. //"id":"40f77e32-29fa-4a85-a6f0-7c4986bdc5e3",
  184. "dataCategory":'1'
  185. };
  186. break ;
  187. case 3:
  188. urls = "/admin/achievement.html?rid=" + rid +"#techAchievementAudit";
  189. dataJson = {
  190. "id":record.uid,
  191. //"id":"f09d5c08-4a8b-48a6-9753-86006f1a53cb",
  192. "ownerType":'1'
  193. };
  194. break ;
  195. case 4:
  196. urls = "/admin/achievement.html?rid=" + rid + "#techAchievementPublish";
  197. dataJson = {
  198. "id":record.uid,
  199. //"id":"953c9ef7-6cf6-4ab7-af89-c01521998fed",
  200. "ownerType":'1'
  201. };
  202. break ;
  203. case 5:
  204. urls = "/admin/order.html?rid=" + rid + "#myService";
  205. dataJson = {
  206. "orderNo":record.orderNo
  207. //"orderNo":"175557414077480960"
  208. };
  209. break ;
  210. case 6:
  211. urls = "/admin/order.html?rid=" + rid + "#mySettlement";
  212. dataJson = {
  213. "orderNo":record.orderNo
  214. //"orderNo":"180714111314051072"
  215. };
  216. break ;
  217. case 7:
  218. urls = "/admin/servicesManage/projectOrder.html?rid=" + rid + "#projectManage";
  219. dataJson = {
  220. //"id":record.id,
  221. "id":"69e2d8ca984240a4b9c90daac69fe5e3",
  222. "buyerType":"1"
  223. };
  224. break ;
  225. default :
  226. urls:'#';
  227. dataJson = {};
  228. };
  229. console.log(rid);
  230. if(rid){
  231. var data = dataJson;
  232. var newData = JSON.stringify(data);
  233. localStorage.setItem('newData',newData);
  234. window.location.href = globalConfig.context +urls;
  235. }
  236. },
  237. loadReaded(pageNo) {
  238. this.state.data = [];
  239. this.setState({
  240. loading: true
  241. });
  242. $.ajax({
  243. method: "get",
  244. dataType: "json",
  245. crossDomain: false,
  246. url: globalConfig.context + "/api/admin/notice/readed",
  247. data: {
  248. pageNo: pageNo || 1,
  249. pageSize: this.state.pagination.pageSize,
  250. }
  251. }).done((data) => {
  252. if (!data.data) {
  253. if (data.error && data.error.length) {
  254. message.warning(data.error[0].message);
  255. return;
  256. };
  257. };
  258. this.state.data = [];
  259. for (let i = 0; i < data.data.list.length; i++) {
  260. let thisdata = data.data.list[i];
  261. this.state.data.push({
  262. key: i + 1,
  263. id: thisdata.id,
  264. rid: thisdata.rid,
  265. uid: thisdata.uid,
  266. aid: thisdata.aid,
  267. noticeType: thisdata.noticeType,
  268. year: thisdata.year,
  269. noticeTypeName: thisdata.noticeTypeName,
  270. content: thisdata.content,
  271. createTime: thisdata.createTime,
  272. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  273. principle: thisdata.principle,
  274. unitName: thisdata.unitName
  275. });
  276. };
  277. this.state.pagination.current = data.data.pageNo;
  278. this.state.pagination.total = data.data.totalCount;
  279. this.setState({
  280. dataSource: this.state.data,
  281. pagination: this.state.pagination
  282. });
  283. }).always(function () {
  284. this.setState({
  285. loading: false
  286. });
  287. }.bind(this));
  288. },
  289. loadUnread(pageNo) {
  290. this.state.data = [];
  291. this.setState({
  292. loading: true
  293. });
  294. $.ajax({
  295. method: "get",
  296. dataType: "json",
  297. crossDomain: false,
  298. url: globalConfig.context + "/api/admin/notice/unread",
  299. data: {
  300. pageNo: pageNo || 1,
  301. pageSize: this.state.UnreadPagination.pageSize,
  302. }
  303. }).done((data) => {
  304. if (!data.data) {
  305. if (data.error && data.error.length) {
  306. message.warning(data.error[0].message);
  307. return;
  308. };
  309. };
  310. this.state.data = [];
  311. for (let i = 0; i < data.data.list.length; i++) {
  312. let thisdata = data.data.list[i];
  313. this.state.data.push({
  314. key: i + 1,
  315. id: thisdata.id,
  316. rid: thisdata.rid,
  317. uid: thisdata.uid,
  318. aid: thisdata.aid,
  319. noticeType: thisdata.noticeType,
  320. year: thisdata.year,
  321. noticeTypeName: thisdata.noticeTypeName,
  322. content: thisdata.content,
  323. createTime: thisdata.createTime,
  324. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  325. principle: thisdata.principle,
  326. unitName: thisdata.unitName
  327. });
  328. };
  329. this.state.UnreadPagination.current = data.data.pageNo;
  330. this.state.UnreadPagination.total = data.data.totalCount;
  331. this.setState({
  332. unreadData: this.state.data,
  333. UnreadPagination: this.state.UnreadPagination
  334. });
  335. }).always(function () {
  336. this.setState({
  337. loading: false
  338. });
  339. }.bind(this));
  340. },
  341. componentWillMount() {
  342. this.loadReaded();
  343. this.loadUnread();
  344. this.mainMenu();
  345. },
  346. render() {
  347. return (
  348. <div className="set-content">
  349. <div className="set-title">
  350. <span>管理员中心</span>
  351. </div>
  352. <Spin spinning={this.state.loading} className='spin-box'>
  353. <Tabs defaultActiveKey="1">
  354. <Tabs.TabPane tab="新信息" key="1">
  355. <Table columns={this.state.columns}
  356. dataSource={this.state.unreadData}
  357. pagination={this.state.UnreadPagination} />
  358. </Tabs.TabPane>
  359. <Tabs.TabPane tab="已读信息" key="2">
  360. <Table columns={this.state.columns}
  361. dataSource={this.state.dataSource}
  362. pagination={this.state.pagination} />
  363. </Tabs.TabPane>
  364. </Tabs>
  365. </Spin>
  366. </div>
  367. );
  368. }
  369. });
  370. const Content = React.createClass({
  371. getInitialState() {
  372. return {
  373. loading: false
  374. };
  375. },
  376. render() {
  377. return (
  378. <div className="manage-content">
  379. <LeftTab handlekey={this.handlekey} />
  380. <div className="content-right">
  381. <Spin spinning={this.state.loading} className='spin-box'>
  382. <div className="index-content">
  383. <MessageModal />
  384. </div>
  385. </Spin>
  386. </div>
  387. </div>
  388. )
  389. }
  390. });
  391. export default Content;
  392. // <div className="index-content">
  393. // <div className="index-userdata clearfix">
  394. // <p className="acc-title">{this.state.number}</p>
  395. // <div className="userdata-img">
  396. // <img src={globalConfig.staticHost + "/upload" + this.state.personPortraitUrl} alt="" />
  397. // </div>
  398. // <div className="userdata-content">
  399. // {(() => {
  400. // switch (userData.lvl || this.state.userlvl) {
  401. // case '0':
  402. // return <p className="userdata-lvl">等级:<span>LV1</span> 普通用户</p>;
  403. // case '1':
  404. // return <p className="userdata-lvl">等级:<span>LV2</span> 已认证用户</p>;
  405. // };
  406. // })()}
  407. // <p>完善资料 {this.state.per}% ,<a href="./set.html">继续完善</a>,有助于提高您的资信</p>
  408. // <p className="userdata-relate" style={{ 'display': 'none' }}>
  409. // <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  410. // <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  411. // <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  412. // </p>
  413. // <div className="userdata-follow">已有<a href="">{this.state.follow}</a>人关注你</div>
  414. // </div>
  415. // </div>
  416. // <div className="index-record">
  417. // <p className="acc-title">我的轨迹</p>
  418. // <ul className="record-list clearfix">
  419. // <li>技术成果:<a href="">{this.state.chengguo}</a>项</li>
  420. // <li>技术开发:<a href="">{this.state.kaifa}</a>项</li>
  421. // <li>科技服务:<a href="">{this.state.fuwu}</a>项</li>
  422. // <li>发布需求:<a href="">{this.state.xuqiu}</a>项</li>
  423. // </ul>
  424. // </div>
  425. // <div className="index-activity">
  426. // <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  427. // <TabPane tab="活动" key="1">
  428. // <p className="acc-title">即将举办的活动</p>
  429. // <ul className="activity-list">
  430. // {
  431. // this.state.activityArr.map(function (item, i) {
  432. // return <li key={i}>
  433. // <span className="list-type">[{item.type}]</span>
  434. // <span className="list-title">{item.title}</span>
  435. // <a href={item.link}>报名</a>
  436. // <span className="list-time">{item.time}</span>
  437. // </li>;
  438. // })
  439. // }
  440. // </ul>
  441. // </TabPane>
  442. // <TabPane tab="其他" key="2">Content of Tab Pane 2</TabPane>
  443. // </Tabs>
  444. // </div>
  445. // </div>