topTab.jsx 24 KB

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