topTab.jsx 25 KB

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