topTab.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. import React from 'react';
  2. import { Row, Col, Icon, Modal, Button, Spin, Select, Input, message, Badge, Table, Tabs, Tag } from 'antd';
  3. import { getProvince } from '../NewDicProvinceList.js';
  4. import { companySearch ,getActives} from '../tools.js';
  5. import './topTab.less';
  6. import ajax from 'jquery/src/ajax/xhr.js'
  7. import $ from 'jquery/src/ajax';
  8. import logo from '../../../image/acc-logo.png';
  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. return (<span>{record.noticeTypeName}</span>)
  73. }
  74. }, {
  75. title: '时间',
  76. dataIndex: 'createTimeFormattedDate',
  77. key: 'createTimeFormattedDate'
  78. }, {
  79. title: '内容',
  80. dataIndex: 'content',
  81. key: 'content',
  82. }, {
  83. title: '公司',
  84. dataIndex: 'unitName',
  85. key: 'unitName',
  86. }, {
  87. title: '业务员',
  88. dataIndex: 'principle',
  89. key: 'principle',
  90. }
  91. ],
  92. data: []
  93. };
  94. },
  95. loadReaded(pageNo) {
  96. this.state.data = [];
  97. this.setState({
  98. loading: true
  99. });
  100. $.ajax({
  101. method: "get",
  102. dataType: "json",
  103. crossDomain: false,
  104. url: globalConfig.context + "/api/admin/notice/readed",
  105. data: {
  106. pageNo: pageNo || 1,
  107. pageSize: this.state.pagination.pageSize,
  108. }
  109. }).done((data) => {
  110. if (!data.data) {
  111. if (data.error && data.error.length) {
  112. message.warning(data.error[0].message);
  113. return;
  114. };
  115. };
  116. this.state.data = [];
  117. for (let i = 0; i < data.data.list.length; i++) {
  118. let thisdata = data.data.list[i];
  119. this.state.data.push({
  120. key: i + 1,
  121. id: thisdata.id,
  122. rid: thisdata.rid,
  123. uid: thisdata.uid,
  124. aid: thisdata.aid,
  125. noticeType: thisdata.noticeType,
  126. year: thisdata.year,
  127. noticeTypeName: thisdata.noticeTypeName,
  128. content: thisdata.content,
  129. createTime: thisdata.createTime,
  130. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  131. principle: thisdata.principle,
  132. unitName: thisdata.unitName
  133. });
  134. };
  135. this.state.pagination.current = data.data.pageNo;
  136. this.state.pagination.total = data.data.totalCount;
  137. this.setState({
  138. dataSource: this.state.data,
  139. pagination: this.state.pagination
  140. });
  141. }).always(function () {
  142. this.setState({
  143. loading: false
  144. });
  145. }.bind(this));
  146. },
  147. loadUnread(pageNo) {
  148. this.state.data = [];
  149. this.setState({
  150. loading: true
  151. });
  152. $.ajax({
  153. method: "get",
  154. dataType: "json",
  155. crossDomain: false,
  156. url: globalConfig.context + "/api/admin/notice/unread",
  157. data: {
  158. pageNo: pageNo || 1,
  159. pageSize: this.state.UnreadPagination.pageSize,
  160. }
  161. }).done((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.state.data = [];
  169. for (let i = 0; i < data.data.list.length; i++) {
  170. let thisdata = data.data.list[i];
  171. this.state.data.push({
  172. key: i + 1,
  173. id: thisdata.id,
  174. rid: thisdata.rid,
  175. uid: thisdata.uid,
  176. aid: thisdata.aid,
  177. noticeType: thisdata.noticeType,
  178. year: thisdata.year,
  179. noticeTypeName: thisdata.noticeTypeName,
  180. content: thisdata.content,
  181. createTime: thisdata.createTime,
  182. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  183. principle: thisdata.principle,
  184. unitName: thisdata.unitName
  185. });
  186. };
  187. this.state.UnreadPagination.current = data.data.pageNo;
  188. this.state.UnreadPagination.total = data.data.totalCount;
  189. this.setState({
  190. unreadData: this.state.data,
  191. UnreadPagination: this.state.UnreadPagination
  192. });
  193. }).always(function () {
  194. this.setState({
  195. loading: false
  196. });
  197. }.bind(this));
  198. },
  199. componentWillReceiveProps(nextProps) {
  200. if (!this.state.visible && nextProps.showDesc) {
  201. this.loadReaded();
  202. this.loadUnread();
  203. };
  204. this.state.visible = nextProps.showDesc
  205. },
  206. handleOk() {
  207. this.setState({
  208. visible: false,
  209. });
  210. this.props.closeDesc(false, true);
  211. },
  212. handleCancel(e) {
  213. this.setState({
  214. visible: false,
  215. });
  216. this.props.closeDesc(false, true);
  217. },
  218. render() {
  219. return (
  220. <div className="topTab-modal">
  221. <Spin spinning={this.state.loading} className='spin-box'>
  222. <Modal maskClosable={false} title="信息中心" visible={this.state.visible}
  223. onOk={this.handleOk} onCancel={this.handleCancel}
  224. width='800px' footer=''
  225. >
  226. <Tabs defaultActiveKey="1">
  227. <Tabs.TabPane tab="新信息" key="1">
  228. <Table columns={this.state.columns}
  229. dataSource={this.state.unreadData}
  230. pagination={this.state.UnreadPagination} />
  231. </Tabs.TabPane>
  232. <Tabs.TabPane tab="已读信息" key="2">
  233. <Table columns={this.state.columns}
  234. dataSource={this.state.dataSource}
  235. pagination={this.state.pagination} />
  236. </Tabs.TabPane>
  237. </Tabs>
  238. </Modal>
  239. </Spin>
  240. </div>
  241. );
  242. }
  243. });
  244. const UserModal = React.createClass({
  245. getInitialState() {
  246. return {
  247. visible: false,
  248. loading: false,
  249. locations: []
  250. };
  251. },
  252. loadData() {
  253. this.setState({
  254. loading: true
  255. });
  256. $.ajax({
  257. method: "get",
  258. dataType: "json",
  259. crossDomain: false,
  260. url: globalConfig.context + "/api/admin/adminInfo",
  261. success: function (data) {
  262. if (!data.data) {
  263. if (data.error[0] && data.error[0]) {
  264. message.warning(data.error[0].message);
  265. };
  266. return;
  267. };
  268. this.setState({
  269. id: data.data.id,
  270. mobile: data.data.mobile,
  271. contactMobile: data.data.contactMobile,
  272. name: data.data.name,
  273. position: data.data.position,
  274. email: data.data.email,
  275. createTime: data.data.createTime,
  276. number: data.data.number,
  277. createTimeFormattedDate: data.data.createTimeFormattedDate
  278. });
  279. this.loadLocations(data.data.id);
  280. }.bind(this),
  281. }).always(function (data) {
  282. this.setState({
  283. loading: false
  284. });
  285. }.bind(this));
  286. },
  287. loadLocations(id) {
  288. this.setState({
  289. loading: true
  290. });
  291. $.ajax({
  292. url: globalConfig.context + '/api/admin/supervise/adminDetailLocation',
  293. cache: false,
  294. data: {
  295. "id": id
  296. }
  297. }).done((data) => {
  298. if (!data.data) {
  299. if (data.error && data.error.length) {
  300. message.warning(data.error[0].message);
  301. return;
  302. };
  303. };
  304. data.data.map((item) => {
  305. if (item.city) {
  306. item.city = item.city.split(',');
  307. }
  308. });
  309. this.setState({
  310. locations: data.data,
  311. loading: false
  312. });
  313. })
  314. },
  315. componentWillReceiveProps(nextProps) {
  316. if (!this.state.visible && nextProps.showDesc) {
  317. this.loadData();
  318. };
  319. this.state.visible = nextProps.showDesc
  320. },
  321. handleOk() {
  322. this.setState({
  323. loading: true
  324. });
  325. $.ajax({
  326. method: "post",
  327. dataType: "json",
  328. crossDomain: false,
  329. url: globalConfig.context + "/api/admin/updateAdminInfo",
  330. data: {
  331. id: this.state.id,
  332. mobile: this.state.mobile,
  333. contactMobile: this.state.contactMobile,
  334. name: this.state.name,
  335. email: this.state.email,
  336. province: this.state.province,
  337. password: this.state.password,
  338. pwd: this.state.pwd
  339. }
  340. }).always(function (data) {
  341. if (data.error && data.error.length) {
  342. message.warning(data.error[0].message);
  343. this.setState({
  344. loading: false
  345. });
  346. } else {
  347. message.success('保存成功!');
  348. this.props.closeDesc(false, true);
  349. };
  350. }.bind(this));
  351. },
  352. handleCancel(e) {
  353. this.setState({
  354. visible: false,
  355. });
  356. this.props.closeDesc(false);
  357. },
  358. render() {
  359. return (
  360. <div className="topTab-modal">
  361. <Spin spinning={this.state.loading} className='spin-box'>
  362. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  363. onOk={this.handleOk} onCancel={this.handleCancel}
  364. width='380px' >
  365. <ul className="modal-content">
  366. <li>
  367. <span className='modal-text'>名字</span>
  368. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  369. </li>
  370. <li>
  371. <span className='modal-text'>职位</span>
  372. <span>{this.state.position}</span>
  373. </li>
  374. <li>
  375. <span className='modal-text'>登录账号</span>
  376. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  377. </li>
  378. <li>
  379. <span className='modal-text'>联系方式</span>
  380. <Input value={this.state.contactMobile} onChange={(e) => { this.state.contactMobile = e.target.value; this.setState({ contactMobile: this.state.contactMobile }); }} />
  381. </li>
  382. <li>
  383. <span className='modal-text'>省份</span>
  384. <div style={{ display: "inline-block", width: '78%' }}>
  385. {this.state.locations.map((item, i) => {
  386. return <Tag key={i}>{getProvince(item.province) + ' ' + (item.city ? item.city.map((c) => {
  387. return getProvince(c) + ' '
  388. }) : '')}</Tag>
  389. })}
  390. </div>
  391. </li>
  392. <li>
  393. <span className='modal-text'>邮箱</span>
  394. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  395. </li>
  396. <li>
  397. <span className='modal-text'>密码</span>
  398. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  399. </li>
  400. <li>
  401. <span className='modal-text'>原密码</span>
  402. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  403. </li>
  404. </ul>
  405. </Modal>
  406. </Spin>
  407. </div>
  408. );
  409. }
  410. });
  411. const TopTab = React.createClass({
  412. getInitialState() {
  413. return {
  414. username: '请登录!',
  415. };
  416. },
  417. logOut() {
  418. let theActive = this.props.active;
  419. $.ajax({
  420. method: "get",
  421. dataType: "json",
  422. url: globalConfig.context + "/login",
  423. }).done(function (data) {
  424. window.location.href = globalConfig.context + "/admin/login.html"
  425. });
  426. },
  427. componentWillMount() {
  428. if (this.props.active) {
  429. this.loadData();
  430. };
  431. this.mainMenu();
  432. },
  433. //主菜单请求
  434. mainMenu(){
  435. this.setState({
  436. loading:true
  437. });
  438. $.ajax({
  439. method: "get",
  440. dataType: "json",
  441. crossDomain: false,
  442. url: globalConfig.context + "/api/admin/selectNavList",
  443. data: {
  444. },
  445. success:function(data){
  446. if (!data.data) {
  447. if (data.error && data.error.length) {
  448. message.warning(data.error[0].message);
  449. return;
  450. };
  451. };
  452. let menu=data.data;
  453. var htmlMenu=[];
  454. for(var i=0;i<menu.length;i++){
  455. if(menu.length>7){
  456. htmlMenu.push(
  457. <Col key={i} className={this.props.active === getActives(menu[i].name) ? 'active' : ''} span={2}><a href={globalConfig.context + menu[i].url+'?rid='+menu[i].id}>{menu[i].name}</a></Col>
  458. )
  459. }else{
  460. htmlMenu.push(
  461. <Col key={i} className={this.props.active === getActives(menu[i].name) ? 'active' : ''} span={3}><a href={globalConfig.context + menu[i].url+'?rid='+menu[i].id}>{menu[i].name}</a></Col>
  462. )
  463. }
  464. }
  465. this.setState({
  466. htmlMenus:htmlMenu
  467. })
  468. }.bind(this),
  469. }).always(function(data){
  470. this.setState({
  471. loading:false
  472. })
  473. }.bind(this))
  474. },
  475. loadData() {
  476. this.setState({
  477. loading: true
  478. });
  479. $.ajax({
  480. method: "get",
  481. dataType: "json",
  482. crossDomain: false,
  483. url: globalConfig.context + "/api/admin/notice/unreadCount",
  484. success: function (data) {
  485. if (!data.data) {
  486. if (data.error[0] && data.error[0]) {
  487. message.warning(data.error[0].message);
  488. return;
  489. };
  490. };
  491. this.setState({
  492. badge: data.data,
  493. });
  494. }.bind(this),
  495. }).always(function (data) {
  496. this.setState({
  497. loading: false
  498. });
  499. }.bind(this));
  500. },
  501. closeUserModal(e, s) {
  502. this.state.userModalShow = e;
  503. if (s) {
  504. this.loadData();
  505. };
  506. },
  507. closeMessageModal(e, s) {
  508. this.state.messageModalShow = e;
  509. if (s) {
  510. this.loadData();
  511. };
  512. },
  513. render() {
  514. return (
  515. <div className="account-top" >
  516. <div className="acc-top-user">
  517. <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => {
  518. if (window.showPermissionList && window.showRoleList) {
  519. return
  520. };
  521. this.setState({ userModalShow: true });
  522. }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
  523. <span className="acc-top-user-toindex"><a href={globalConfig.context + "/portal/index.html"}>返回首页</a></span>
  524. {this.props.active ? <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
  525. <Icon type="mail" />
  526. {(() => {
  527. if (!window.showSystem && this.state.badge) {
  528. return <Badge status="processing" />
  529. }
  530. })()}
  531. </a> : <div></div>}
  532. </div>
  533. <div className="acc-index">
  534. <div className="acc-index-imgbox">
  535. <img src={logo} alt="" />
  536. </div>
  537. <span><a href={globalConfig.context + "/admin/index.html"}>管理中心首页</a></span>
  538. </div>
  539. <div className="acc-top-tab">
  540. <Row>
  541. {/*<Col style={{ display: window.showUserManage ? 'block' : 'none' }} className={this.props.active === 'userManage' ? 'active' : ''} span={2}><a href={globalConfig.context + "/admin/userManage.html"}>用户管理</a></Col>*/}
  542. {/*<Col style={{ display: window.showCustomer ? 'block' : 'none' }} className={this.props.active === 'myClient' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/customer.html" }>客户管理</a></Col>
  543. <Col style={{ display: window.showServices ? 'block' : 'none' }} className={this.props.active === 'services' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/servicesManage/contract.html"}>科技服务管理</a></Col>
  544. <Col style={{ display: window.showAchievement ? 'block' : 'none' }} className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/achievement.html"}>科技成果管理</a></Col>
  545. <Col style={{ display: window.showDemand ? 'block' : 'none' }} className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/demand.html"}>科技需求管理</a></Col>
  546. <Col style={{ display: window.showIdea ? 'block' : 'none' }} className={this.props.active === 'idea' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/idea.html"}>科技思想管理</a></Col>
  547. <Col style={{ display: window.showUserOrderList ? 'block' : 'none' }} className={this.props.active === 'userOrder' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/userOrder.html"}>用户订单管理</a></Col>
  548. <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
  549. */}
  550. {this.state.htmlMenus}
  551. </Row>
  552. </div>
  553. <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
  554. <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
  555. </div >
  556. )
  557. }
  558. });
  559. export default TopTab;