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. 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. name: data.data.name,
  272. position: data.data.position,
  273. email: data.data.email,
  274. createTime: data.data.createTime,
  275. number: data.data.number,
  276. createTimeFormattedDate: data.data.createTimeFormattedDate
  277. });
  278. this.loadLocations(data.data.id);
  279. }.bind(this),
  280. }).always(function (data) {
  281. this.setState({
  282. loading: false
  283. });
  284. }.bind(this));
  285. },
  286. loadLocations(id) {
  287. this.setState({
  288. loading: true
  289. });
  290. $.ajax({
  291. url: globalConfig.context + '/api/admin/supervise/adminDetailLocation',
  292. cache: false,
  293. data: {
  294. "id": id
  295. }
  296. }).done((data) => {
  297. if (!data.data) {
  298. if (data.error && data.error.length) {
  299. message.warning(data.error[0].message);
  300. return;
  301. };
  302. };
  303. data.data.map((item) => {
  304. if (item.city) {
  305. item.city = item.city.split(',');
  306. }
  307. });
  308. this.setState({
  309. locations: data.data,
  310. loading: false
  311. });
  312. })
  313. },
  314. componentWillReceiveProps(nextProps) {
  315. if (!this.state.visible && nextProps.showDesc) {
  316. this.loadData();
  317. };
  318. this.state.visible = nextProps.showDesc
  319. },
  320. handleOk() {
  321. this.setState({
  322. loading: true
  323. });
  324. $.ajax({
  325. method: "post",
  326. dataType: "json",
  327. crossDomain: false,
  328. url: globalConfig.context + "/api/admin/updateAdminInfo",
  329. data: {
  330. id: this.state.id,
  331. mobile: this.state.mobile,
  332. name: this.state.name,
  333. email: this.state.email,
  334. province: this.state.province,
  335. password: this.state.password,
  336. pwd: this.state.pwd
  337. }
  338. }).always(function (data) {
  339. if (data.error && data.error.length) {
  340. message.warning(data.error[0].message);
  341. this.setState({
  342. loading: false
  343. });
  344. } else {
  345. message.success('保存成功!');
  346. this.props.closeDesc(false, true);
  347. };
  348. }.bind(this));
  349. },
  350. handleCancel(e) {
  351. this.setState({
  352. visible: false,
  353. });
  354. this.props.closeDesc(false);
  355. },
  356. render() {
  357. return (
  358. <div className="topTab-modal">
  359. <Spin spinning={this.state.loading} className='spin-box'>
  360. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  361. onOk={this.handleOk} onCancel={this.handleCancel}
  362. width='380px' >
  363. <ul className="modal-content">
  364. <li>
  365. <span className='modal-text'>名字</span>
  366. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  367. </li>
  368. <li>
  369. <span className='modal-text'>职位</span>
  370. <span>{this.state.position}</span>
  371. </li>
  372. <li>
  373. <span className='modal-text'>登录账号</span>
  374. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  375. </li>
  376. <li>
  377. <span className='modal-text'>省份</span>
  378. <div style={{ display: "inline-block", width: '78%' }}>
  379. {this.state.locations.map((item, i) => {
  380. return <Tag key={i}>{getProvince(item.province) + ' ' + (item.city ? item.city.map((c) => {
  381. return getProvince(c) + ' '
  382. }) : '')}</Tag>
  383. })}
  384. </div>
  385. </li>
  386. <li>
  387. <span className='modal-text'>邮箱</span>
  388. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  389. </li>
  390. <li>
  391. <span className='modal-text'>密码</span>
  392. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  393. </li>
  394. <li>
  395. <span className='modal-text'>原密码</span>
  396. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  397. </li>
  398. </ul>
  399. </Modal>
  400. </Spin>
  401. </div>
  402. );
  403. }
  404. });
  405. const TopTab = React.createClass({
  406. getInitialState() {
  407. return {
  408. username: '请登录!',
  409. };
  410. },
  411. logOut() {
  412. let theActive = this.props.active;
  413. $.ajax({
  414. method: "get",
  415. dataType: "json",
  416. url: globalConfig.context + "/login",
  417. }).done(function (data) {
  418. window.location.href = globalConfig.context + "/admin/login.html"
  419. });
  420. },
  421. componentWillMount() {
  422. if (this.props.active) {
  423. this.loadData();
  424. };
  425. this.mainMenu();
  426. },
  427. //主菜单请求
  428. mainMenu(){
  429. this.setState({
  430. loading:true
  431. });
  432. $.ajax({
  433. method: "get",
  434. dataType: "json",
  435. crossDomain: false,
  436. url: globalConfig.context + "/api/admin/selectNavList",
  437. data: {
  438. },
  439. success:function(data){
  440. if (!data.data) {
  441. if (data.error && data.error.length) {
  442. message.warning(data.error[0].message);
  443. return;
  444. };
  445. };
  446. let menu=data.data;
  447. var htmlMenu=[];
  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;