content.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. import React from 'react';
  2. import { Spin, Button, Tabs, Table, message, Modal,Tooltip } 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. import FollowDetail from "../customer/NEW/intentionCustomer/followDetail";
  9. const TabPane = Tabs.TabPane;
  10. const MessageModal = React.createClass({
  11. getInitialState() {
  12. return {
  13. newVisible: false,
  14. loading: false,
  15. categoryArr:[],
  16. pagination: {
  17. defaultCurrent: 1,
  18. defaultPageSize: 10,
  19. showQuickJumper: true,
  20. pageSize: 10,
  21. onChange: function (page) {
  22. this.loadReaded(page);
  23. }.bind(this),
  24. showTotal: function (total) {
  25. return '共' + total + '条数据';
  26. }
  27. },
  28. UnreadPagination: {
  29. defaultCurrent: 1,
  30. defaultPageSize: 10,
  31. showQuickJumper: true,
  32. pageSize: 9999,
  33. onChange: function (page) {
  34. this.loadUnread(page);
  35. }.bind(this),
  36. showTotal: function (total) {
  37. return '共' + total + '条数据';
  38. }
  39. },
  40. columns: [
  41. {
  42. title: '编号',
  43. dataIndex: 'key',
  44. key: 'key'
  45. }, {
  46. title: '类型',
  47. dataIndex: 'noticeType',
  48. key: 'noticeType',
  49. render: (text, record) => {
  50. // return <div>{
  51. // text<8?<a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName} </a >:
  52. // <span>{record.noticeTypeName}</span>
  53. // }</div>
  54. //return <a href='#' onClick={(e) =>{ e.stopPropagation(),this.setStore(record)}}> {record.noticeTypeName} </a >
  55. return(<span>{record.noticeTypeName}</span>)
  56. }
  57. }, {
  58. title: '时间',
  59. dataIndex: 'createTimeFormattedDate',
  60. key: 'createTimeFormattedDate'
  61. }, {
  62. title: '内容',
  63. dataIndex: 'content',
  64. key: 'content',
  65. render: (text, record) => {
  66. return(
  67. <Tooltip placement="topLeft" title={text}>
  68. <div style={{
  69. maxWidth: '687px',
  70. textOverflow: "ellipsis",
  71. whiteSpace: "nowrap",
  72. overflow: 'hidden',
  73. }}>
  74. {text}
  75. </div>
  76. </Tooltip>
  77. )
  78. }
  79. },
  80. {
  81. title: "操作",
  82. dataIndex: "abc",
  83. key: "abc",
  84. render: (text, record) => {
  85. return (
  86. record.noticeType === 48 || record.noticeType === 49 ?
  87. <Button type="primary" onClick={()=>{
  88. this.category();
  89. record.id = record.uid;
  90. this.setState({
  91. followData: record,
  92. visitModul: true,
  93. });
  94. }}>立即跟进</Button> : null
  95. )
  96. }
  97. }
  98. // {
  99. // title: '公司',
  100. // dataIndex: 'unitName',
  101. // key: 'unitName',
  102. // }, {
  103. // title: '业务员',
  104. // dataIndex: 'principle',
  105. // key: 'principle',
  106. // }
  107. ],
  108. data: []
  109. };
  110. },
  111. closeDesc(){
  112. this.setState({
  113. categoryArr:[],
  114. followData:'',
  115. visitModul:false
  116. },()=>{
  117. this.loadReaded(this.state.pagination.current);
  118. })
  119. },
  120. category() {
  121. $.ajax({
  122. method: "get",
  123. dataType: "json",
  124. crossDomain: false,
  125. url: globalConfig.context + "/api/admin/Varieties/getSuperList",
  126. data: {},
  127. success: function (data) {
  128. let thedata = data.data;
  129. let theArr = [];
  130. if (!thedata) {
  131. if (data.error && data.error.length) {
  132. message.warning(data.error[0].message);
  133. }
  134. thedata = {};
  135. } else {
  136. thedata.map(function (item, index) {
  137. theArr.push({
  138. value: item.id,
  139. key: item.cname,
  140. });
  141. });
  142. }
  143. this.setState({
  144. categoryArr: theArr,
  145. });
  146. }.bind(this),
  147. });
  148. },
  149. //主菜单请求
  150. mainMenu(){
  151. this.setState({
  152. loading:true
  153. });
  154. $.ajax({
  155. method: "get",
  156. dataType: "json",
  157. crossDomain: false,
  158. url: globalConfig.context + "/api/admin/selectNavList",
  159. data: {
  160. },
  161. success:function(data){
  162. if (!data.data) {
  163. if (data.error && data.error.length) {
  164. message.warning(data.error[0].message);
  165. return;
  166. };
  167. };
  168. this.setState({
  169. menu:data.data
  170. });
  171. }.bind(this),
  172. }).always(function(data){
  173. this.setState({
  174. loading:false
  175. })
  176. }.bind(this))
  177. },
  178. finId(text){
  179. var data=this.state.menu||[];
  180. var rid='';
  181. switch(text) {
  182. case 1:
  183. data.map(function(nub, index) {
  184. if(nub.url.indexOf('demand') != -1) {
  185. rid = nub.id;
  186. }
  187. });
  188. break;
  189. case 2:
  190. data.map(function(nub, index) {
  191. if(nub.url.indexOf('demand') != -1) {
  192. rid = nub.id;
  193. }
  194. });
  195. break;
  196. case 3:
  197. data.map(function(nub, index) {
  198. if(nub.url.indexOf('achievement') != -1) {
  199. rid = nub.id;
  200. }
  201. });
  202. break;
  203. case 4:
  204. data.map(function(nub, index) {
  205. if(nub.url.indexOf('achievement') != -1) {
  206. rid = nub.id;
  207. }
  208. });
  209. break;
  210. case 5:
  211. data.map(function(nub, index) {
  212. if(nub.url.indexOf('order') != -1) {
  213. rid = nub.id;
  214. }
  215. });
  216. break;
  217. case 6:
  218. data.map(function(nub, index) {
  219. if(nub.url.indexOf('order') != -1) {
  220. rid = nub.id;
  221. }
  222. });
  223. break;
  224. case 7:
  225. data.map(function(nub, index) {
  226. if(nub.url.indexOf('servicesManage') != -1) {
  227. rid = nub.id;
  228. }
  229. });
  230. break;
  231. default:
  232. rid='';
  233. }
  234. return rid;
  235. },
  236. //跳转详情
  237. setStore(record){
  238. localStorage.setItem('newData',{});
  239. let ids = record.noticeType;
  240. let rid = this.finId(ids) || "";
  241. var urls='',
  242. dataJson={};
  243. switch (ids) {
  244. case 1:
  245. urls = "/admin/demand.html?rid=" + rid +"#techDemandAudit";
  246. dataJson = {
  247. "id":record.uid,
  248. //"id":"3f93588b-332e-4353-bbfd-f1451b4b390c",
  249. "dataCategory":"0"
  250. };
  251. break;
  252. case 2:
  253. urls = "/admin/demand.html?rid=" + rid+ "#techDemandPublish";
  254. dataJson = {
  255. "id":record.uid,
  256. //"id":"40f77e32-29fa-4a85-a6f0-7c4986bdc5e3",
  257. "dataCategory":'1'
  258. };
  259. break ;
  260. case 3:
  261. urls = "/admin/achievement.html?rid=" + rid +"#techAchievementAudit";
  262. dataJson = {
  263. "id":record.uid,
  264. //"id":"f09d5c08-4a8b-48a6-9753-86006f1a53cb",
  265. "ownerType":'1'
  266. };
  267. break ;
  268. case 4:
  269. urls = "/admin/achievement.html?rid=" + rid + "#techAchievementPublish";
  270. dataJson = {
  271. "id":record.uid,
  272. //"id":"953c9ef7-6cf6-4ab7-af89-c01521998fed",
  273. "ownerType":'1'
  274. };
  275. break ;
  276. case 5:
  277. urls = "/admin/order.html?rid=" + rid + "#myService";
  278. dataJson = {
  279. "orderNo":record.orderNo
  280. //"orderNo":"175557414077480960"
  281. };
  282. break ;
  283. case 6:
  284. urls = "/admin/order.html?rid=" + rid + "#mySettlement";
  285. dataJson = {
  286. "orderNo":record.orderNo
  287. //"orderNo":"180714111314051072"
  288. };
  289. break ;
  290. case 7:
  291. urls = "/admin/servicesManage/projectOrder.html?rid=" + rid + "#projectManage";
  292. dataJson = {
  293. //"id":record.id,
  294. "id":"69e2d8ca984240a4b9c90daac69fe5e3",
  295. "buyerType":"1"
  296. };
  297. break ;
  298. default :
  299. urls:'#';
  300. dataJson = {};
  301. };
  302. console.log(rid);
  303. if(rid){
  304. var data = dataJson;
  305. var newData = JSON.stringify(data);
  306. localStorage.setItem('newData',newData);
  307. window.location.href = globalConfig.context +urls;
  308. }
  309. },
  310. loadReaded(pageNo) {
  311. this.state.data = [];
  312. this.setState({
  313. loading: true
  314. });
  315. $.ajax({
  316. method: "get",
  317. dataType: "json",
  318. crossDomain: false,
  319. url: globalConfig.context + "/api/admin/notice/readed",
  320. data: {
  321. pageNo: pageNo || 1,
  322. pageSize: this.state.pagination.pageSize,
  323. }
  324. }).done((data) => {
  325. if (!data.data) {
  326. if (data.error && data.error.length) {
  327. message.warning(data.error[0].message);
  328. return;
  329. };
  330. };
  331. this.state.data = [];
  332. for (let i = 0; i < data.data.list.length; i++) {
  333. let thisdata = data.data.list[i];
  334. this.state.data.push({
  335. key: i + 1,
  336. id: thisdata.id,
  337. rid: thisdata.rid,
  338. uid: thisdata.uid,
  339. aid: thisdata.aid,
  340. noticeType: thisdata.noticeType,
  341. year: thisdata.year,
  342. noticeTypeName: thisdata.noticeTypeName,
  343. content: thisdata.content,
  344. createTime: thisdata.createTime,
  345. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  346. principle: thisdata.principle,
  347. unitName: thisdata.unitName
  348. });
  349. };
  350. this.state.pagination.current = data.data.pageNo;
  351. this.state.pagination.total = data.data.totalCount;
  352. this.setState({
  353. dataSource: this.state.data,
  354. pagination: this.state.pagination
  355. });
  356. }).always(function () {
  357. this.setState({
  358. loading: false
  359. });
  360. }.bind(this));
  361. },
  362. loadUnread(pageNo) {
  363. this.state.data = [];
  364. this.setState({
  365. loading: true
  366. });
  367. $.ajax({
  368. method: "get",
  369. dataType: "json",
  370. crossDomain: false,
  371. url: globalConfig.context + "/api/admin/notice/unread",
  372. data: {
  373. pageNo: pageNo || 1,
  374. pageSize: this.state.UnreadPagination.pageSize,
  375. }
  376. }).done((data) => {
  377. if (!data.data) {
  378. if (data.error && data.error.length) {
  379. message.warning(data.error[0].message);
  380. return;
  381. };
  382. };
  383. this.state.data = [];
  384. for (let i = 0; i < data.data.list.length; i++) {
  385. let thisdata = data.data.list[i];
  386. this.state.data.push({
  387. key: i + 1,
  388. id: thisdata.id,
  389. rid: thisdata.rid,
  390. uid: thisdata.uid,
  391. aid: thisdata.aid,
  392. noticeType: thisdata.noticeType,
  393. year: thisdata.year,
  394. noticeTypeName: thisdata.noticeTypeName,
  395. content: thisdata.content,
  396. createTime: thisdata.createTime,
  397. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  398. principle: thisdata.principle,
  399. unitName: thisdata.unitName
  400. });
  401. };
  402. this.state.UnreadPagination.current = data.data.pageNo;
  403. this.state.UnreadPagination.total = data.data.totalCount;
  404. if(data.data.list.length) {
  405. this.setState({
  406. newVisible: true
  407. });
  408. }
  409. this.setState({
  410. unreadData: this.state.data,
  411. UnreadPagination: this.state.UnreadPagination
  412. });
  413. }).always(function () {
  414. this.setState({
  415. loading: false,
  416. });
  417. }.bind(this));
  418. },
  419. componentWillMount() {
  420. this.loadReaded();
  421. this.loadUnread();
  422. this.mainMenu();
  423. },
  424. handleOk() {
  425. this.setState({
  426. newVisible: false
  427. });
  428. },
  429. render() {
  430. return (
  431. <div className="set-content">
  432. <div className="set-title">
  433. <span>信息中心</span>
  434. </div>
  435. <Spin spinning={this.state.loading} className="spin-box">
  436. <Tabs defaultActiveKey="1">
  437. <Tabs.TabPane tab="新信息" key="1">
  438. <Table
  439. columns={this.state.columns}
  440. dataSource={this.state.unreadData}
  441. pagination={this.state.UnreadPagination}
  442. />
  443. </Tabs.TabPane>
  444. <Tabs.TabPane tab="已读信息" key="2">
  445. <Table
  446. columns={this.state.columns}
  447. dataSource={this.state.dataSource}
  448. pagination={this.state.pagination}
  449. />
  450. </Tabs.TabPane>
  451. </Tabs>
  452. </Spin>
  453. <Modal
  454. maskClosable={false}
  455. style={{ position: "relative" }}
  456. title="消息提醒"
  457. visible={this.state.newVisible}
  458. width={1000}
  459. closable={false}
  460. footer={null}
  461. >
  462. <Table
  463. columns={this.state.columns}
  464. dataSource={this.state.unreadData}
  465. pagination={false}
  466. />
  467. <Button
  468. onClick={this.handleOk}
  469. type={"primary"}
  470. style={{
  471. position: "relative",
  472. left: "50%",
  473. transform: "translateX(-50%)",
  474. bottom: -10
  475. }}
  476. >
  477. 我已阅读以上信息
  478. </Button>
  479. </Modal>
  480. <FollowDetail
  481. categoryArr={this.state.categoryArr}
  482. followData={this.state.followData}
  483. visitModul={this.state.visitModul}
  484. closeDesc={this.closeDesc}
  485. />
  486. </div>
  487. );
  488. }
  489. });
  490. const Content = React.createClass({
  491. getInitialState() {
  492. return {
  493. loading: false,
  494. component:'<div></div>'
  495. };
  496. },
  497. getKey(key){
  498. switch(key){
  499. case 'normal':
  500. require.ensure([], () => {
  501. this.setState({
  502. component: <MessageModal />,
  503. });
  504. });
  505. break;
  506. case "contacts":
  507. let Module = require('./contacts/index').default;
  508. require.ensure([], () => {
  509. this.setState({
  510. component: <Module />,
  511. });
  512. });
  513. break;
  514. default:
  515. require.ensure([], () => {
  516. let Module = require('../module').default;
  517. this.setState({
  518. component:<Module />
  519. });
  520. });
  521. }
  522. window.location.hash=key;
  523. },
  524. componentWillMount() {
  525. if (window.location.hash) {
  526. this.getKey((window.location.hash).slice(1));
  527. } else {
  528. this.getKey('normal');
  529. };
  530. },
  531. render() {
  532. return (
  533. <div className="manage-content">
  534. <LeftTab handlekey={this.getKey} />
  535. <div className="content-right">
  536. <Spin spinning={this.state.loading} className='spin-box'>
  537. <div className="index-content">
  538. {this.state.component}
  539. </div>
  540. </Spin>
  541. </div>
  542. </div>
  543. )
  544. }
  545. });
  546. export default Content;
  547. // <div className="index-content">
  548. // <div className="index-userdata clearfix">
  549. // <p className="acc-title">{this.state.number}</p>
  550. // <div className="userdata-img">
  551. // <img src={globalConfig.staticHost + "/upload" + this.state.personPortraitUrl} alt="" />
  552. // </div>
  553. // <div className="userdata-content">
  554. // {(() => {
  555. // switch (userData.lvl || this.state.userlvl) {
  556. // case '0':
  557. // return <p className="userdata-lvl">等级:<span>LV1</span> 普通用户</p>;
  558. // case '1':
  559. // return <p className="userdata-lvl">等级:<span>LV2</span> 已认证用户</p>;
  560. // };
  561. // })()}
  562. // <p>完善资料 {this.state.per}% ,<a href="./set.html">继续完善</a>,有助于提高您的资信</p>
  563. // <p className="userdata-relate" style={{ 'display': 'none' }}>
  564. // <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  565. // <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  566. // <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  567. // </p>
  568. // <div className="userdata-follow">已有<a href="">{this.state.follow}</a>人关注你</div>
  569. // </div>
  570. // </div>
  571. // <div className="index-record">
  572. // <p className="acc-title">我的轨迹</p>
  573. // <ul className="record-list clearfix">
  574. // <li>技术成果:<a href="">{this.state.chengguo}</a>项</li>
  575. // <li>技术开发:<a href="">{this.state.kaifa}</a>项</li>
  576. // <li>科技服务:<a href="">{this.state.fuwu}</a>项</li>
  577. // <li>发布需求:<a href="">{this.state.xuqiu}</a>项</li>
  578. // </ul>
  579. // </div>
  580. // <div className="index-activity">
  581. // <Tabs defaultActiveKey="1" onChange={this.tabChange}>
  582. // <TabPane tab="活动" key="1">
  583. // <p className="acc-title">即将举办的活动</p>
  584. // <ul className="activity-list">
  585. // {
  586. // this.state.activityArr.map(function (item, i) {
  587. // return <li key={i}>
  588. // <span className="list-type">[{item.type}]</span>
  589. // <span className="list-title">{item.title}</span>
  590. // <a href={item.link}>报名</a>
  591. // <span className="list-time">{item.time}</span>
  592. // </li>;
  593. // })
  594. // }
  595. // </ul>
  596. // </TabPane>
  597. // <TabPane tab="其他" key="2">Content of Tab Pane 2</TabPane>
  598. // </Tabs>
  599. // </div>
  600. // </div>