topTab.jsx 24 KB

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