topTab.jsx 18 KB

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