topTab.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. }
  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. componentWillReceiveProps(nextProps) {
  199. if (!this.state.visible && nextProps.showDesc) {
  200. this.loadReaded();
  201. this.loadUnread();
  202. };
  203. this.state.visible = nextProps.showDesc
  204. },
  205. handleOk() {
  206. this.setState({
  207. visible: false,
  208. });
  209. this.props.closeDesc(false, true);
  210. },
  211. handleCancel(e) {
  212. this.setState({
  213. visible: false,
  214. });
  215. this.props.closeDesc(false, true);
  216. },
  217. render() {
  218. return (
  219. <div className="topTab-modal">
  220. <Spin spinning={this.state.loading} className='spin-box'>
  221. <Modal maskClosable={false} title="信息中心" visible={this.state.visible}
  222. onOk={this.handleOk} onCancel={this.handleCancel}
  223. width='800px' footer=''
  224. >
  225. <Tabs defaultActiveKey="1">
  226. <Tabs.TabPane tab="新信息" key="1">
  227. <Table columns={this.state.columns}
  228. dataSource={this.state.unreadData}
  229. pagination={this.state.UnreadPagination} />
  230. </Tabs.TabPane>
  231. <Tabs.TabPane tab="已读信息" key="2">
  232. <Table columns={this.state.columns}
  233. dataSource={this.state.dataSource}
  234. pagination={this.state.pagination} />
  235. </Tabs.TabPane>
  236. </Tabs>
  237. </Modal>
  238. </Spin>
  239. </div>
  240. );
  241. }
  242. });
  243. const UserModal = React.createClass({
  244. getInitialState() {
  245. return {
  246. visible: false,
  247. loading: false,
  248. locations: []
  249. };
  250. },
  251. loadData() {
  252. this.setState({
  253. loading: true
  254. });
  255. $.ajax({
  256. method: "get",
  257. dataType: "json",
  258. crossDomain: false,
  259. url: globalConfig.context + "/api/admin/adminInfo",
  260. success: function (data) {
  261. if (!data.data) {
  262. if (data.error[0] && data.error[0]) {
  263. message.warning(data.error[0].message);
  264. };
  265. return;
  266. };
  267. this.setState({
  268. id: data.data.id,
  269. mobile: data.data.mobile,
  270. name: data.data.name,
  271. position: data.data.position,
  272. email: data.data.email,
  273. createTime: data.data.createTime,
  274. number: data.data.number,
  275. createTimeFormattedDate: data.data.createTimeFormattedDate
  276. });
  277. this.loadLocations(data.data.id);
  278. }.bind(this),
  279. }).always(function (data) {
  280. this.setState({
  281. loading: false
  282. });
  283. }.bind(this));
  284. },
  285. loadLocations(id) {
  286. this.setState({
  287. loading: true
  288. });
  289. $.ajax({
  290. url: globalConfig.context + '/api/admin/supervise/adminDetailLocation',
  291. cache: false,
  292. data: {
  293. "id": id
  294. }
  295. }).done((data) => {
  296. if (!data.data) {
  297. if (data.error && data.error.length) {
  298. message.warning(data.error[0].message);
  299. return;
  300. };
  301. };
  302. data.data.map((item) => {
  303. if (item.city) {
  304. item.city = item.city.split(',');
  305. }
  306. });
  307. this.setState({
  308. locations: data.data,
  309. loading: false
  310. });
  311. })
  312. },
  313. componentWillReceiveProps(nextProps) {
  314. if (!this.state.visible && nextProps.showDesc) {
  315. this.loadData();
  316. };
  317. this.state.visible = nextProps.showDesc
  318. },
  319. handleOk() {
  320. this.setState({
  321. loading: true
  322. });
  323. $.ajax({
  324. method: "post",
  325. dataType: "json",
  326. crossDomain: false,
  327. url: globalConfig.context + "/api/admin/updateAdminInfo",
  328. data: {
  329. id: this.state.id,
  330. mobile: this.state.mobile,
  331. name: this.state.name,
  332. email: this.state.email,
  333. province: this.state.province,
  334. password: this.state.password,
  335. pwd: this.state.pwd
  336. }
  337. }).always(function (data) {
  338. if (data.error && data.error.length) {
  339. message.warning(data.error[0].message);
  340. this.setState({
  341. loading: false
  342. });
  343. } else {
  344. message.success('保存成功!');
  345. this.props.closeDesc(false, true);
  346. };
  347. }.bind(this));
  348. },
  349. handleCancel(e) {
  350. this.setState({
  351. visible: false,
  352. });
  353. this.props.closeDesc(false);
  354. },
  355. render() {
  356. return (
  357. <div className="topTab-modal">
  358. <Spin spinning={this.state.loading} className='spin-box'>
  359. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  360. onOk={this.handleOk} onCancel={this.handleCancel}
  361. width='380px' >
  362. <ul className="modal-content">
  363. <li>
  364. <span className='modal-text'>名字</span>
  365. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  366. </li>
  367. <li>
  368. <span className='modal-text'>职位</span>
  369. <span>{this.state.position}</span>
  370. </li>
  371. <li>
  372. <span className='modal-text'>登录账号</span>
  373. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  374. </li>
  375. <li>
  376. <span className='modal-text'>省份</span>
  377. <div style={{ display: "inline-block", width: '78%' }}>
  378. {this.state.locations.map((item, i) => {
  379. return <Tag key={i}>{getProvince(item.province) + ' ' + (item.city ? item.city.map((c) => {
  380. return getProvince(c) + ' '
  381. }) : '')}</Tag>
  382. })}
  383. </div>
  384. </li>
  385. <li>
  386. <span className='modal-text'>邮箱</span>
  387. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  388. </li>
  389. <li>
  390. <span className='modal-text'>密码</span>
  391. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  392. </li>
  393. <li>
  394. <span className='modal-text'>原密码</span>
  395. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  396. </li>
  397. </ul>
  398. </Modal>
  399. </Spin>
  400. </div>
  401. );
  402. }
  403. });
  404. const TopTab = React.createClass({
  405. getInitialState() {
  406. return {
  407. username: '请登录!',
  408. };
  409. },
  410. logOut() {
  411. let theActive = this.props.active;
  412. $.ajax({
  413. method: "get",
  414. dataType: "json",
  415. url: globalConfig.context + "/login",
  416. }).done(function (data) {
  417. window.location.href = globalConfig.context + "/admin/login.html"
  418. });
  419. },
  420. componentWillMount() {
  421. if (this.props.active) {
  422. this.loadData();
  423. };
  424. this.mainMenu();
  425. },
  426. //主菜单请求
  427. mainMenu(){
  428. this.setState({
  429. loading:true
  430. });
  431. $.ajax({
  432. method: "get",
  433. dataType: "json",
  434. crossDomain: false,
  435. url: globalConfig.context + "/api/admin/selectNavList",
  436. data: {
  437. },
  438. success:function(data){
  439. if (!data.data) {
  440. if (data.error && data.error.length) {
  441. message.warning(data.error[0].message);
  442. return;
  443. };
  444. };
  445. let menu=data.data;
  446. var htmlMenu=[];
  447. console.log(globalConfig.context)
  448. for(var i=0;i<menu.length;i++){
  449. if(menu.length>7){
  450. htmlMenu.push(
  451. <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>
  452. )
  453. }else{
  454. htmlMenu.push(
  455. <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>
  456. )
  457. }
  458. }
  459. this.setState({
  460. htmlMenus:htmlMenu
  461. })
  462. }.bind(this),
  463. }).always(function(data){
  464. this.setState({
  465. loading:false
  466. })
  467. }.bind(this))
  468. },
  469. loadData() {
  470. this.setState({
  471. loading: true
  472. });
  473. $.ajax({
  474. method: "get",
  475. dataType: "json",
  476. crossDomain: false,
  477. url: globalConfig.context + "/api/admin/notice/unreadCount",
  478. success: function (data) {
  479. if (!data.data) {
  480. if (data.error[0] && data.error[0]) {
  481. message.warning(data.error[0].message);
  482. return;
  483. };
  484. };
  485. this.setState({
  486. badge: data.data,
  487. });
  488. }.bind(this),
  489. }).always(function (data) {
  490. this.setState({
  491. loading: false
  492. });
  493. }.bind(this));
  494. },
  495. closeUserModal(e, s) {
  496. this.state.userModalShow = e;
  497. if (s) {
  498. this.loadData();
  499. };
  500. },
  501. closeMessageModal(e, s) {
  502. this.state.messageModalShow = e;
  503. if (s) {
  504. this.loadData();
  505. };
  506. },
  507. render() {
  508. return (
  509. <div className="account-top" >
  510. <div className="acc-top-user">
  511. <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => {
  512. if (window.showPermissionList && window.showRoleList) {
  513. return
  514. };
  515. this.setState({ userModalShow: true });
  516. }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
  517. <span className="acc-top-user-toindex"><a href={globalConfig.context + "/portal/index.html"}>返回首页</a></span>
  518. {this.props.active ? <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
  519. <Icon type="mail" />
  520. {(() => {
  521. if (!window.showSystem && this.state.badge) {
  522. return <Badge status="processing" />
  523. }
  524. })()}
  525. </a> : <div></div>}
  526. </div>
  527. <div className="acc-index">
  528. <div className="acc-index-imgbox">
  529. <img src={logo} alt="" />
  530. </div>
  531. <span><a href={globalConfig.context + "/admin/index.html"}>管理中心首页</a></span>
  532. </div>
  533. <div className="acc-top-tab">
  534. <Row>
  535. {/*<Col style={{ display: window.showUserManage ? 'block' : 'none' }} className={this.props.active === 'userManage' ? 'active' : ''} span={2}><a href={globalConfig.context + "/admin/userManage.html"}>用户管理</a></Col>*/}
  536. {/*<Col style={{ display: window.showCustomer ? 'block' : 'none' }} className={this.props.active === 'myClient' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/customer.html" }>客户管理</a></Col>
  537. <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>
  538. <Col style={{ display: window.showAchievement ? 'block' : 'none' }} className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/achievement.html"}>科技成果管理</a></Col>
  539. <Col style={{ display: window.showDemand ? 'block' : 'none' }} className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/demand.html"}>科技需求管理</a></Col>
  540. <Col style={{ display: window.showIdea ? 'block' : 'none' }} className={this.props.active === 'idea' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/idea.html"}>科技思想管理</a></Col>
  541. <Col style={{ display: window.showUserOrderList ? 'block' : 'none' }} className={this.props.active === 'userOrder' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/userOrder.html"}>用户订单管理</a></Col>
  542. <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
  543. */}
  544. {this.state.htmlMenus}
  545. </Row>
  546. </div>
  547. <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
  548. <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
  549. </div >
  550. )
  551. }
  552. });
  553. export default TopTab;