content.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. console.log(record);
  168. ids=7;
  169. let rid = this.finId(ids) || "";
  170. var urls='',
  171. dataJson={};
  172. switch (ids) {
  173. case 1:
  174. urls = "/admin/demand.html?rid=" + rid +"#techDemandAudit";
  175. dataJson = {
  176. "id":record.uid,
  177. //"id":"3f93588b-332e-4353-bbfd-f1451b4b390c",
  178. "dataCategory":"0"
  179. };
  180. break;
  181. case 2:
  182. urls = "/admin/demand.html?rid=" + rid+ "#techDemandPublish";
  183. dataJson = {
  184. "id":record.uid,
  185. //"id":"40f77e32-29fa-4a85-a6f0-7c4986bdc5e3",
  186. "dataCategory":'1'
  187. };
  188. break ;
  189. case 3:
  190. urls = "/admin/achievement.html?rid=" + rid +"#techAchievementAudit";
  191. dataJson = {
  192. "id":record.uid,
  193. //"id":"f09d5c08-4a8b-48a6-9753-86006f1a53cb",
  194. "ownerType":'1'
  195. };
  196. break ;
  197. case 4:
  198. urls = "/admin/achievement.html?rid=" + rid + "#techAchievementPublish";
  199. dataJson = {
  200. "id":record.uid,
  201. //"id":"953c9ef7-6cf6-4ab7-af89-c01521998fed",
  202. "ownerType":'1'
  203. };
  204. break ;
  205. case 5:
  206. urls = "/admin/order.html?rid=" + rid + "#myService";
  207. dataJson = {
  208. "orderNo":record.orderNo
  209. //"orderNo":"175557414077480960"
  210. };
  211. break ;
  212. case 6:
  213. urls = "/admin/order.html?rid=" + rid + "#mySettlement";
  214. dataJson = {
  215. "orderNo":record.orderNo
  216. //"orderNo":"180714111314051072"
  217. };
  218. break ;
  219. case 7:
  220. urls = "/admin/servicesManage/projectOrder.html?rid=" + rid + "#projectManage";
  221. dataJson = {
  222. //"id":record.id,
  223. "id":"69e2d8ca984240a4b9c90daac69fe5e3",
  224. "buyerType":"1"
  225. };
  226. break ;
  227. default :
  228. urls:'#';
  229. dataJson = {};
  230. };
  231. console.log(rid);
  232. if(rid){
  233. var data = dataJson;
  234. var newData = JSON.stringify(data);
  235. localStorage.setItem('newData',newData);
  236. window.location.href = globalConfig.context +urls;
  237. }
  238. },
  239. loadReaded(pageNo) {
  240. this.state.data = [];
  241. this.setState({
  242. loading: true
  243. });
  244. $.ajax({
  245. method: "get",
  246. dataType: "json",
  247. crossDomain: false,
  248. url: globalConfig.context + "/api/admin/notice/readed",
  249. data: {
  250. pageNo: pageNo || 1,
  251. pageSize: this.state.pagination.pageSize,
  252. }
  253. }).done((data) => {
  254. if (!data.data) {
  255. if (data.error && data.error.length) {
  256. message.warning(data.error[0].message);
  257. return;
  258. };
  259. };
  260. this.state.data = [];
  261. for (let i = 0; i < data.data.list.length; i++) {
  262. let thisdata = data.data.list[i];
  263. this.state.data.push({
  264. key: i + 1,
  265. id: thisdata.id,
  266. rid: thisdata.rid,
  267. uid: thisdata.uid,
  268. aid: thisdata.aid,
  269. noticeType: thisdata.noticeType,
  270. year: thisdata.year,
  271. noticeTypeName: thisdata.noticeTypeName,
  272. content: thisdata.content,
  273. createTime: thisdata.createTime,
  274. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  275. principle: thisdata.principle,
  276. unitName: thisdata.unitName
  277. });
  278. };
  279. this.state.pagination.current = data.data.pageNo;
  280. this.state.pagination.total = data.data.totalCount;
  281. this.setState({
  282. dataSource: this.state.data,
  283. pagination: this.state.pagination
  284. });
  285. }).always(function () {
  286. this.setState({
  287. loading: false
  288. });
  289. }.bind(this));
  290. },
  291. loadUnread(pageNo) {
  292. this.state.data = [];
  293. this.setState({
  294. loading: true
  295. });
  296. $.ajax({
  297. method: "get",
  298. dataType: "json",
  299. crossDomain: false,
  300. url: globalConfig.context + "/api/admin/notice/unread",
  301. data: {
  302. pageNo: pageNo || 1,
  303. pageSize: this.state.UnreadPagination.pageSize,
  304. }
  305. }).done((data) => {
  306. if (!data.data) {
  307. if (data.error && data.error.length) {
  308. message.warning(data.error[0].message);
  309. return;
  310. };
  311. };
  312. this.state.data = [];
  313. for (let i = 0; i < data.data.list.length; i++) {
  314. let thisdata = data.data.list[i];
  315. this.state.data.push({
  316. key: i + 1,
  317. id: thisdata.id,
  318. rid: thisdata.rid,
  319. uid: thisdata.uid,
  320. aid: thisdata.aid,
  321. noticeType: thisdata.noticeType,
  322. year: thisdata.year,
  323. noticeTypeName: thisdata.noticeTypeName,
  324. content: thisdata.content,
  325. createTime: thisdata.createTime,
  326. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  327. principle: thisdata.principle,
  328. unitName: thisdata.unitName
  329. });
  330. };
  331. this.state.UnreadPagination.current = data.data.pageNo;
  332. this.state.UnreadPagination.total = data.data.totalCount;
  333. this.setState({
  334. unreadData: this.state.data,
  335. UnreadPagination: this.state.UnreadPagination
  336. });
  337. }).always(function () {
  338. this.setState({
  339. loading: false
  340. });
  341. }.bind(this));
  342. },
  343. componentWillMount() {
  344. this.loadReaded();
  345. this.loadUnread();
  346. this.mainMenu();
  347. },
  348. render() {
  349. return (
  350. <div className="set-content">
  351. <div className="set-title">
  352. <span>管理员中心</span>
  353. </div>
  354. <Spin spinning={this.state.loading} className='spin-box'>
  355. <Tabs defaultActiveKey="1">
  356. <Tabs.TabPane tab="新信息" key="1">
  357. <Table columns={this.state.columns}
  358. dataSource={this.state.unreadData}
  359. pagination={this.state.UnreadPagination} />
  360. </Tabs.TabPane>
  361. <Tabs.TabPane tab="已读信息" key="2">
  362. <Table columns={this.state.columns}
  363. dataSource={this.state.dataSource}
  364. pagination={this.state.pagination} />
  365. </Tabs.TabPane>
  366. </Tabs>
  367. </Spin>
  368. </div>
  369. );
  370. }
  371. });
  372. const Content = React.createClass({
  373. getInitialState() {
  374. return {
  375. loading: false
  376. };
  377. },
  378. render() {
  379. return (
  380. <div className="manage-content">
  381. <LeftTab handlekey={this.handlekey} />
  382. <div className="content-right">
  383. <Spin spinning={this.state.loading} className='spin-box'>
  384. <div className="index-content">
  385. <MessageModal />
  386. </div>
  387. </Spin>
  388. </div>
  389. </div>
  390. )
  391. }
  392. });
  393. export default Content;
  394. // <div className="index-content">
  395. // <div className="index-userdata clearfix">
  396. // <p className="acc-title">{this.state.number}</p>
  397. // <div className="userdata-img">
  398. // <img src={globalConfig.staticHost + "/upload" + this.state.personPortraitUrl} alt="" />
  399. // </div>
  400. // <div className="userdata-content">
  401. // {(() => {
  402. // switch (userData.lvl || this.state.userlvl) {
  403. // case '0':
  404. // return <p className="userdata-lvl">等级:<span>LV1</span> 普通用户</p>;
  405. // case '1':
  406. // return <p className="userdata-lvl">等级:<span>LV2</span> 已认证用户</p>;
  407. // };
  408. // })()}
  409. // <p>完善资料 {this.state.per}% ,<a href="./set.html">继续完善</a>,有助于提高您的资信</p>
  410. // <p className="userdata-relate" style={{ 'display': 'none' }}>
  411. // <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  412. // <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  413. // <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  414. // </p>
  415. // <div className="userdata-follow">已有<a href="">{this.state.follow}</a>人关注你</div>
  416. // </div>
  417. // </div>
  418. // <div className="index-record">
  419. // <p className="acc-title">我的轨迹</p>
  420. // <ul className="record-list clearfix">
  421. // <li>技术成果:<a href="">{this.state.chengguo}</a>项</li>
  422. // <li>技术开发:<a href="">{this.state.kaifa}</a>项</li>
  423. // <li>科技服务:<a href="">{this.state.fuwu}</a>项</li>
  424. // <li>发布需求:<a href="">{this.state.xuqiu}</a>项</li>
  425. // </ul>
  426. // </div>
  427. // <div className="index-activity">
  428. // <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  429. // <TabPane tab="活动" key="1">
  430. // <p className="acc-title">即将举办的活动</p>
  431. // <ul className="activity-list">
  432. // {
  433. // this.state.activityArr.map(function (item, i) {
  434. // return <li key={i}>
  435. // <span className="list-type">[{item.type}]</span>
  436. // <span className="list-title">{item.title}</span>
  437. // <a href={item.link}>报名</a>
  438. // <span className="list-time">{item.time}</span>
  439. // </li>;
  440. // })
  441. // }
  442. // </ul>
  443. // </TabPane>
  444. // <TabPane tab="其他" key="2">Content of Tab Pane 2</TabPane>
  445. // </Tabs>
  446. // </div>
  447. // </div>