topTab.jsx 20 KB

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