topTab.jsx 24 KB

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