topTab.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. import React from 'react';
  2. import { Row, Col, Icon, Modal, Button, Spin, Select, Input, message, Badge, Table, Tabs } from 'antd';
  3. import { getProvince } from '../NewDicProvinceList.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. };
  249. },
  250. loadData() {
  251. this.setState({
  252. loading: true
  253. });
  254. $.ajax({
  255. method: "get",
  256. dataType: "json",
  257. crossDomain: false,
  258. url: globalConfig.context + "/api/admin/adminInfo",
  259. success: function (data) {
  260. if (!data.data) {
  261. if (data.error[0] && data.error[0]) {
  262. message.warning(data.error[0].message);
  263. };
  264. return;
  265. };
  266. this.setState({
  267. id: data.data.id,
  268. mobile: data.data.mobile,
  269. name: data.data.name,
  270. position: data.data.position,
  271. email: data.data.email,
  272. createTime: data.data.createTime,
  273. number: data.data.number,
  274. province: data.data.province,
  275. createTimeFormattedDate: data.data.createTimeFormattedDate
  276. });
  277. }.bind(this),
  278. }).always(function (data) {
  279. this.setState({
  280. loading: false
  281. });
  282. }.bind(this));
  283. },
  284. componentWillReceiveProps(nextProps) {
  285. if (!this.state.visible && nextProps.showDesc) {
  286. this.loadData();
  287. };
  288. this.state.visible = nextProps.showDesc
  289. },
  290. handleOk() {
  291. this.setState({
  292. loading: true
  293. });
  294. $.ajax({
  295. method: "post",
  296. dataType: "json",
  297. crossDomain: false,
  298. url: globalConfig.context + "/api/admin/updateAdminInfo",
  299. data: {
  300. id: this.state.id,
  301. mobile: this.state.mobile,
  302. name: this.state.name,
  303. email: this.state.email,
  304. province: this.state.province,
  305. password: this.state.password,
  306. pwd: this.state.pwd
  307. }
  308. }).always(function (data) {
  309. if (data.error && data.error.length) {
  310. message.warning(data.error[0].message);
  311. this.setState({
  312. loading: false
  313. });
  314. } else {
  315. message.success('保存成功!');
  316. this.props.closeDesc(false, true);
  317. };
  318. }.bind(this));
  319. },
  320. handleCancel(e) {
  321. this.setState({
  322. visible: false,
  323. });
  324. this.props.closeDesc(false);
  325. },
  326. render() {
  327. return (
  328. <div className="topTab-modal">
  329. <Spin spinning={this.state.loading} className='spin-box'>
  330. <Modal maskClosable={false} title="用户设置" visible={this.state.visible}
  331. onOk={this.handleOk} onCancel={this.handleCancel}
  332. width='380px'
  333. >
  334. <ul className="modal-content">
  335. <li>
  336. <span className='modal-text'>名字</span>
  337. <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
  338. </li>
  339. <li>
  340. <span className='modal-text'>职位</span>
  341. <span>{this.state.position}</span>
  342. </li>
  343. <li>
  344. <span className='modal-text'>登录账号</span>
  345. <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
  346. </li>
  347. <li>
  348. <span className='modal-text'>省份</span>
  349. <span>{getProvince(this.state.province)}</span>
  350. </li>
  351. <li>
  352. <span className='modal-text'>邮箱</span>
  353. <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
  354. </li>
  355. <li>
  356. <span className='modal-text'>密码</span>
  357. <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
  358. </li>
  359. <li>
  360. <span className='modal-text'>原密码</span>
  361. <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
  362. </li>
  363. </ul>
  364. </Modal>
  365. </Spin>
  366. </div>
  367. );
  368. }
  369. });
  370. const TopTab = React.createClass({
  371. getInitialState() {
  372. return {
  373. username: '请登录!',
  374. };
  375. },
  376. logOut() {
  377. let theActive = this.props.active;
  378. $.ajax({
  379. method: "get",
  380. dataType: "json",
  381. url: globalConfig.context + "/login",
  382. }).done(function (data) {
  383. window.location.href = globalConfig.context + "/admin/login.html"
  384. });
  385. },
  386. componentWillMount() {
  387. this.loadData();
  388. },
  389. loadData() {
  390. this.setState({
  391. loading: true
  392. });
  393. $.ajax({
  394. method: "get",
  395. dataType: "json",
  396. crossDomain: false,
  397. url: globalConfig.context + "/api/admin/notice/unreadCount",
  398. success: function (data) {
  399. if (!data.data) {
  400. if (data.error[0] && data.error[0]) {
  401. message.warning(data.error[0].message);
  402. return;
  403. };
  404. };
  405. this.setState({
  406. badge: data.data,
  407. });
  408. }.bind(this),
  409. }).always(function (data) {
  410. this.setState({
  411. loading: false
  412. });
  413. }.bind(this));
  414. },
  415. closeUserModal(e, s) {
  416. this.state.userModalShow = e;
  417. if (s) {
  418. this.loadData();
  419. };
  420. },
  421. closeMessageModal(e, s) {
  422. this.state.messageModalShow = e;
  423. if (s) {
  424. this.loadData();
  425. };
  426. },
  427. render() {
  428. return (
  429. <div className="account-top" >
  430. <div className="acc-top-user">
  431. <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => {
  432. if (window.showPermissionList && window.showRoleList) {
  433. return
  434. };
  435. this.setState({ userModalShow: true });
  436. }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
  437. <span className="acc-top-user-toindex"><a href={globalConfig.context + "/portal/index.html"}>返回首页</a></span>
  438. <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
  439. <Icon type="mail" />
  440. {(() => {
  441. if (!window.showSystem && this.state.badge) {
  442. return <Badge status="processing" />
  443. }
  444. })()}
  445. </a>
  446. </div>
  447. <div className="acc-index">
  448. <div className="acc-index-imgbox">
  449. <img src={logo} alt="" />
  450. </div>
  451. <span><a href={globalConfig.context + "/admin/index.html"}>管理中心首页</a></span>
  452. </div>
  453. <div className="acc-top-tab">
  454. <Row>
  455. <Col style={{ display: window.showUserManage ? 'block' : 'none' }} className={this.props.active === 'userManage' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/userManage.html"}>用户管理</a></Col>
  456. <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>
  457. <Col style={{ display: window.showAchievement ? 'block' : 'none' }} className={this.props.active === 'achievement' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/achievement.html"}>科技成果管理</a></Col>
  458. <Col style={{ display: window.showDemand ? 'block' : 'none' }} className={this.props.active === 'demand' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/demand.html"}>科技需求管理</a></Col>
  459. <Col style={{ display: window.showIdea ? 'block' : 'none' }} className={this.props.active === 'idea' ? 'active' : ''} span={3}><a href="">科技思想管理</a></Col>
  460. <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
  461. </Row>
  462. </div>
  463. <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
  464. <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
  465. </div >
  466. )
  467. }
  468. });
  469. export default TopTab;