topTab.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. import React from 'react';
  2. import { Row, Col, Icon, Modal, Button, Spin, Select, Input, message, Badge, Table, Tabs } from 'antd';
  3. import { provinceArr } from '../dataDic.js';
  4. import { companySearch } 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. }
  64. }
  65. }, {
  66. title: '时间',
  67. dataIndex: 'createTimeFormattedDate',
  68. key: 'createTimeFormattedDate'
  69. }, {
  70. title: '内容',
  71. dataIndex: 'content',
  72. key: 'content',
  73. }, {
  74. title: '公司',
  75. dataIndex: 'unitName',
  76. key: 'unitName',
  77. }, {
  78. title: '业务员',
  79. dataIndex: 'principle',
  80. key: 'principle',
  81. }
  82. ],
  83. data: []
  84. };
  85. },
  86. loadReaded(pageNo) {
  87. this.state.data = [];
  88. this.setState({
  89. loading: true
  90. });
  91. $.ajax({
  92. method: "get",
  93. dataType: "json",
  94. crossDomain: false,
  95. url: globalConfig.context + "/api/admin/notice/readed",
  96. data: {
  97. pageNo: pageNo || 1,
  98. pageSize: this.state.pagination.pageSize,
  99. }
  100. }).done((data) => {
  101. if (!data.data) {
  102. if (data.error && data.error.length) {
  103. message.warning(data.error[0].message);
  104. return;
  105. };
  106. };
  107. this.state.data = [];
  108. for (let i = 0; i < data.data.list.length; i++) {
  109. let thisdata = data.data.list[i];
  110. this.state.data.push({
  111. key: i + 1,
  112. id: thisdata.id,
  113. rid: thisdata.rid,
  114. uid: thisdata.uid,
  115. aid: thisdata.aid,
  116. noticeType: thisdata.noticeType,
  117. year: thisdata.year,
  118. noticeTypeName: thisdata.noticeTypeName,
  119. content: thisdata.content,
  120. createTime: thisdata.createTime,
  121. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  122. principle: thisdata.principle,
  123. unitName: thisdata.unitName
  124. });
  125. };
  126. this.state.pagination.current = data.data.pageNo;
  127. this.state.pagination.total = data.data.totalCount;
  128. this.setState({
  129. dataSource: this.state.data,
  130. pagination: this.state.pagination
  131. });
  132. }).always(function () {
  133. this.setState({
  134. loading: false
  135. });
  136. }.bind(this));
  137. },
  138. loadUnread(pageNo) {
  139. this.state.data = [];
  140. this.setState({
  141. loading: true
  142. });
  143. $.ajax({
  144. method: "get",
  145. dataType: "json",
  146. crossDomain: false,
  147. url: globalConfig.context + "/api/admin/notice/unread",
  148. data: {
  149. pageNo: pageNo || 1,
  150. pageSize: this.state.UnreadPagination.pageSize,
  151. }
  152. }).done((data) => {
  153. if (!data.data) {
  154. if (data.error && data.error.length) {
  155. message.warning(data.error[0].message);
  156. return;
  157. };
  158. };
  159. this.state.data = [];
  160. for (let i = 0; i < data.data.list.length; i++) {
  161. let thisdata = data.data.list[i];
  162. this.state.data.push({
  163. key: i + 1,
  164. id: thisdata.id,
  165. rid: thisdata.rid,
  166. uid: thisdata.uid,
  167. aid: thisdata.aid,
  168. noticeType: thisdata.noticeType,
  169. year: thisdata.year,
  170. noticeTypeName: thisdata.noticeTypeName,
  171. content: thisdata.content,
  172. createTime: thisdata.createTime,
  173. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  174. principle: thisdata.principle,
  175. unitName: thisdata.unitName
  176. });
  177. };
  178. this.state.UnreadPagination.current = data.data.pageNo;
  179. this.state.UnreadPagination.total = data.data.totalCount;
  180. this.setState({
  181. unreadData: this.state.data,
  182. UnreadPagination: this.state.UnreadPagination
  183. });
  184. }).always(function () {
  185. this.setState({
  186. loading: false
  187. });
  188. }.bind(this));
  189. },
  190. componentWillReceiveProps(nextProps) {
  191. if (!this.state.visible && nextProps.showDesc) {
  192. this.loadReaded();
  193. this.loadUnread();
  194. };
  195. this.state.visible = nextProps.showDesc
  196. },
  197. handleOk() {
  198. this.setState({
  199. visible: false,
  200. });
  201. this.props.closeDesc(false, true);
  202. },
  203. handleCancel(e) {
  204. this.setState({
  205. visible: false,
  206. });
  207. this.props.closeDesc(false, true);
  208. },
  209. render() {
  210. return (
  211. <div className="topTab-modal">
  212. <Spin spinning={this.state.loading} className='spin-box'>
  213. <Modal maskClosable={false} title="信息中心" visible={this.state.visible}
  214. onOk={this.handleOk} onCancel={this.handleCancel}
  215. width='800px' footer=''
  216. >
  217. <Tabs defaultActiveKey="1">
  218. <Tabs.TabPane tab="新信息" key="1">
  219. <Table columns={this.state.columns}
  220. dataSource={this.state.unreadData}
  221. pagination={this.state.UnreadPagination} />
  222. </Tabs.TabPane>
  223. <Tabs.TabPane tab="已读信息" key="2">
  224. <Table columns={this.state.columns}
  225. dataSource={this.state.dataSource}
  226. pagination={this.state.pagination} />
  227. </Tabs.TabPane>
  228. </Tabs>
  229. </Modal>
  230. </Spin>
  231. </div>
  232. );
  233. }
  234. });
  235. const UserModal = React.createClass({
  236. getInitialState() {
  237. return {
  238. visible: false,
  239. loading: false,
  240. provinceOption: []
  241. };
  242. },
  243. componentWillMount() {
  244. let _me = this;
  245. provinceArr.map(function (item) {
  246. _me.state.provinceOption.push(
  247. <Select.Option value={item} key={item}>{item}</Select.Option>
  248. )
  249. });
  250. },
  251. loadData() {
  252. this.setState({
  253. loading: true
  254. });
  255. $.ajax({
  256. method: "get",
  257. dataType: "json",
  258. crossDomain: false,
  259. url: globalConfig.context + "/api/admin/adminInfo",
  260. success: function (data) {
  261. if (!data.data) {
  262. if (data.error[0] && data.error[0]) {
  263. message.warning(data.error[0].message);
  264. };
  265. return;
  266. };
  267. this.setState({
  268. id: data.data.id,
  269. mobile: data.data.mobile,
  270. name: data.data.name,
  271. position: data.data.position,
  272. email: data.data.email,
  273. createTime: data.data.createTime,
  274. number: data.data.number,
  275. province: data.data.province,
  276. createTimeFormattedDate: data.data.createTimeFormattedDate
  277. });
  278. }.bind(this),
  279. }).always(function (data) {
  280. this.setState({
  281. loading: false
  282. });
  283. }.bind(this));
  284. },
  285. componentWillReceiveProps(nextProps) {
  286. if (!this.state.visible && nextProps.showDesc) {
  287. this.loadData();
  288. };
  289. this.state.visible = nextProps.showDesc
  290. },
  291. handleOk() {
  292. this.setState({
  293. loading: true
  294. });
  295. $.ajax({
  296. method: "post",
  297. dataType: "json",
  298. crossDomain: false,
  299. url: globalConfig.context + "/api/admin/updateAdminInfo",
  300. data: {
  301. id: this.state.id,
  302. mobile: this.state.mobile,
  303. name: this.state.name,
  304. email: this.state.email,
  305. province: this.state.province,
  306. password: this.state.password,
  307. pwd: this.state.pwd
  308. }
  309. }).always(function (data) {
  310. if (data.error && data.error.length) {
  311. message.warning(data.error[0].message);
  312. this.setState({
  313. loading: false
  314. });
  315. } else {
  316. message.success('保存成功!');
  317. this.props.closeDesc(false, true);
  318. };
  319. }.bind(this));
  320. },
  321. handleCancel(e) {
  322. this.setState({
  323. visible: false,
  324. });
  325. this.props.closeDesc(false);
  326. },
  327. render() {
  328. return (
  329. <div className="topTab-modal">
  330. <Spin spinning={this.state.loading} className='spin-box'>
  331. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  332. onOk={this.handleOk} onCancel={this.handleCancel}
  333. width='380px'
  334. >
  335. <ul className="modal-content">
  336. <li>
  337. <span className='modal-text'>名字</span>
  338. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  339. </li>
  340. <li>
  341. <span className='modal-text'>职位</span>
  342. <span>{this.state.position}</span>
  343. </li>
  344. <li>
  345. <span className='modal-text'>登录账号</span>
  346. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  347. </li>
  348. <li>
  349. <span className='modal-text'>省份</span>
  350. <span>{this.state.province}</span>
  351. </li>
  352. <li>
  353. <span className='modal-text'>邮箱</span>
  354. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  355. </li>
  356. <li>
  357. <span className='modal-text'>密码</span>
  358. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  359. </li>
  360. <li>
  361. <span className='modal-text'>原密码</span>
  362. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  363. </li>
  364. </ul>
  365. </Modal>
  366. </Spin>
  367. </div>
  368. );
  369. }
  370. });
  371. const TopTab = React.createClass({
  372. getInitialState() {
  373. return {
  374. username: '请登录!',
  375. };
  376. },
  377. logOut() {
  378. let theActive = this.props.active;
  379. $.ajax({
  380. method: "get",
  381. dataType: "json",
  382. url: globalConfig.context + "/login",
  383. }).done(function (data) {
  384. window.location.href = globalConfig.context + "/admin/login.html"
  385. });
  386. },
  387. componentWillMount() {
  388. this.loadData();
  389. },
  390. loadData() {
  391. this.setState({
  392. loading: true
  393. });
  394. $.ajax({
  395. method: "get",
  396. dataType: "json",
  397. crossDomain: false,
  398. url: globalConfig.context + "/api/admin/notice/unreadCount",
  399. success: function (data) {
  400. if (!data.data) {
  401. if (data.error[0] && data.error[0]) {
  402. message.warning(data.error[0].message);
  403. return;
  404. };
  405. };
  406. this.setState({
  407. badge: data.data,
  408. });
  409. }.bind(this),
  410. }).always(function (data) {
  411. this.setState({
  412. loading: false
  413. });
  414. }.bind(this));
  415. },
  416. closeUserModal(e, s) {
  417. this.state.userModalShow = e;
  418. if (s) {
  419. this.loadData();
  420. };
  421. },
  422. closeMessageModal(e, s) {
  423. this.state.messageModalShow = e;
  424. if (s) {
  425. this.loadData();
  426. };
  427. },
  428. render() {
  429. return (
  430. <div className="account-top" >
  431. <div className="acc-top-user">
  432. <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => {
  433. if (window.showPermissionList && window.showRoleList) {
  434. return
  435. };
  436. this.setState({ userModalShow: true });
  437. }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
  438. <span className="acc-top-user-toindex"><a href={globalConfig.avatarHost + "/html/index.html"}>返回首页</a></span>
  439. <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
  440. <Icon type="mail" />
  441. {(() => {
  442. if (!window.showSystem && this.state.badge) {
  443. return <Badge status="processing" />
  444. }
  445. })()}
  446. </a>
  447. </div>
  448. <div className="acc-index">
  449. <div className="acc-index-imgbox">
  450. <img src={logo} alt="" />
  451. </div>
  452. <span><a href={globalConfig.context + "/admin/index.html"}>管理中心首页</a></span>
  453. </div>
  454. <div className="acc-top-tab">
  455. <Row>
  456. <Col style={{ display: window.showUserManage ? 'block' : 'none' }} className={this.props.active === 'userManage' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/userManage.html"}>用户管理</a></Col>
  457. <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>
  458. <Col style={{ display: window.showAchievement ? 'block' : 'none' }} className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href="">科技成果管理</a></Col>
  459. <Col style={{ display: window.showDemand ? 'block' : 'none' }} className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/demand.html"}>科技需求管理</a></Col>
  460. <Col style={{ display: window.showIdea ? 'block' : 'none' }} className={this.props.active === 'idea' ? 'active' : ''} span={3}><a href="">科技思想管理</a></Col>
  461. <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
  462. </Row>
  463. </div>
  464. <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
  465. <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
  466. </div >
  467. )
  468. }
  469. });
  470. export default TopTab;