topTab.jsx 19 KB

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