topTab.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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. if(this.state.contactMobile){
  326. if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(this.state.contactMobile))){
  327. message.warning("不是完整的11位手机号或者正确的手机号前七位");
  328. this.setState({
  329. loading: false
  330. });
  331. return false;
  332. }
  333. }
  334. $.ajax({
  335. method: "post",
  336. dataType: "json",
  337. crossDomain: false,
  338. url: globalConfig.context + "/api/admin/updateAdminInfo",
  339. data: {
  340. id: this.state.id,
  341. mobile: this.state.mobile,
  342. contactMobile: this.state.contactMobile,
  343. name: this.state.name,
  344. email: this.state.email,
  345. province: this.state.province,
  346. password: this.state.password,
  347. pwd: this.state.pwd
  348. }
  349. }).always(function (data) {
  350. if (data.error && data.error.length) {
  351. message.warning(data.error[0].message);
  352. } else {
  353. this.setState({
  354. loading: false
  355. });
  356. message.success('保存成功!');
  357. this.props.closeDesc(false, true);
  358. };
  359. }.bind(this));
  360. },
  361. handleCancel(e) {
  362. this.setState({
  363. visible: false,
  364. });
  365. this.props.closeDesc(false);
  366. },
  367. render() {
  368. return (
  369. <div className="topTab-modal">
  370. <Spin spinning={this.state.loading} className='spin-box'>
  371. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  372. onOk={this.handleOk} onCancel={this.handleCancel}
  373. width='380px' >
  374. <ul className="modal-content">
  375. <li>
  376. <span className='modal-text'>名字</span>
  377. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  378. </li>
  379. <li>
  380. <span className='modal-text'>职位</span>
  381. <span>{this.state.position}</span>
  382. </li>
  383. <li>
  384. <span className='modal-text'>登录账号</span>
  385. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  386. </li>
  387. <li>
  388. <span className='modal-text'>联系方式</span>
  389. <Input value={this.state.contactMobile} onChange={(e) => { this.state.contactMobile = e.target.value; this.setState({ contactMobile: this.state.contactMobile }); }} />
  390. </li>
  391. <li>
  392. <span className='modal-text'>省份</span>
  393. <div style={{ display: "inline-block", width: '78%' }}>
  394. {this.state.locations.map((item, i) => {
  395. return <Tag key={i}>{getProvince(item.province) + ' ' + (item.city ? item.city.map((c) => {
  396. return getProvince(c) + ' '
  397. }) : '')}</Tag>
  398. })}
  399. </div>
  400. </li>
  401. <li>
  402. <span className='modal-text'>邮箱</span>
  403. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  404. </li>
  405. <li>
  406. <span className='modal-text'>密码</span>
  407. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  408. </li>
  409. <li>
  410. <span className='modal-text'>原密码</span>
  411. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  412. </li>
  413. </ul>
  414. </Modal>
  415. </Spin>
  416. </div>
  417. );
  418. }
  419. });
  420. const TopTab = React.createClass({
  421. getInitialState() {
  422. return {
  423. username: '请登录!',
  424. };
  425. },
  426. logOut() {
  427. let theActive = this.props.active;
  428. $.ajax({
  429. method: "get",
  430. dataType: "json",
  431. url: globalConfig.context + "/login",
  432. }).done(function (data) {
  433. window.location.href = globalConfig.context + "/admin/login.html"
  434. });
  435. },
  436. componentWillMount() {
  437. if (this.props.active) {
  438. this.loadData();
  439. };
  440. this.mainMenu();
  441. },
  442. //主菜单请求
  443. mainMenu(){
  444. this.setState({
  445. loading:true
  446. });
  447. $.ajax({
  448. method: "get",
  449. dataType: "json",
  450. crossDomain: false,
  451. url: globalConfig.context + "/api/admin/selectNavList",
  452. data: {
  453. },
  454. success:function(data){
  455. if (!data.data) {
  456. if (data.error && data.error.length) {
  457. message.warning(data.error[0].message);
  458. return;
  459. };
  460. };
  461. let menu=data.data;
  462. var htmlMenu=[];
  463. for(var i=0;i<menu.length;i++){
  464. if(menu.length>7){
  465. htmlMenu.push(
  466. <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>
  467. )
  468. }else{
  469. htmlMenu.push(
  470. <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>
  471. )
  472. }
  473. }
  474. this.setState({
  475. htmlMenus:htmlMenu
  476. })
  477. }.bind(this),
  478. }).always(function(data){
  479. this.setState({
  480. loading:false
  481. })
  482. }.bind(this))
  483. },
  484. loadData() {
  485. this.setState({
  486. loading: true
  487. });
  488. $.ajax({
  489. method: "get",
  490. dataType: "json",
  491. crossDomain: false,
  492. url: globalConfig.context + "/api/admin/notice/unreadCount",
  493. success: function (data) {
  494. if (!data.data) {
  495. if (data.error[0] && data.error[0]) {
  496. message.warning(data.error[0].message);
  497. return;
  498. };
  499. };
  500. this.setState({
  501. badge: data.data,
  502. });
  503. }.bind(this),
  504. }).always(function (data) {
  505. this.setState({
  506. loading: false
  507. });
  508. }.bind(this));
  509. },
  510. closeUserModal(e, s) {
  511. this.state.userModalShow = e;
  512. if (s) {
  513. this.loadData();
  514. };
  515. },
  516. closeMessageModal(e, s) {
  517. this.state.messageModalShow = e;
  518. if (s) {
  519. this.loadData();
  520. };
  521. },
  522. render() {
  523. return (
  524. <div className="account-top" >
  525. <div className="acc-top-user">
  526. <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => {
  527. if (window.showPermissionList && window.showRoleList) {
  528. return
  529. };
  530. this.setState({ userModalShow: true });
  531. }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
  532. <span className="acc-top-user-toindex"><a href={globalConfig.context + "/portal/index.html"}>返回首页</a></span>
  533. {this.props.active ? <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
  534. <Icon type="mail" />
  535. {(() => {
  536. if (!window.showSystem && this.state.badge) {
  537. return <Badge status="processing" />
  538. }
  539. })()}
  540. </a> : <div></div>}
  541. </div>
  542. <div className="acc-index">
  543. <div className="acc-index-imgbox">
  544. <img src={logo} alt="" />
  545. </div>
  546. <span><a href={globalConfig.context + "/admin/index.html"}>管理中心首页</a></span>
  547. </div>
  548. <div className="acc-top-tab">
  549. <Row>
  550. {/*<Col style={{ display: window.showUserManage ? 'block' : 'none' }} className={this.props.active === 'userManage' ? 'active' : ''} span={2}><a href={globalConfig.context + "/admin/userManage.html"}>用户管理</a></Col>*/}
  551. {/*<Col style={{ display: window.showCustomer ? 'block' : 'none' }} className={this.props.active === 'myClient' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/customer.html" }>客户管理</a></Col>
  552. <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>
  553. <Col style={{ display: window.showAchievement ? 'block' : 'none' }} className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/achievement.html"}>科技成果管理</a></Col>
  554. <Col style={{ display: window.showDemand ? 'block' : 'none' }} className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/demand.html"}>科技需求管理</a></Col>
  555. <Col style={{ display: window.showIdea ? 'block' : 'none' }} className={this.props.active === 'idea' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/idea.html"}>科技思想管理</a></Col>
  556. <Col style={{ display: window.showUserOrderList ? 'block' : 'none' }} className={this.props.active === 'userOrder' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/userOrder.html"}>用户订单管理</a></Col>
  557. <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
  558. */}
  559. {this.state.htmlMenus}
  560. </Row>
  561. </div>
  562. <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
  563. <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
  564. </div >
  565. )
  566. }
  567. });
  568. export default TopTab;