index.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import React, { useState, useEffect } from 'react';
  2. import { useModel, useLocation, history } from 'umi';
  3. import styles from './index.less';
  4. import { MenuFoldOutlined, SmileOutlined } from '@ant-design/icons';
  5. import Icon from '@/tenants-ui/SgIcon';
  6. import { Drawer, notification } from 'antd';
  7. import NavMenu from '@/sagacare_components/navMenu';
  8. import Head from '@/sagacare_components/head';
  9. export default (props) => {
  10. const { menuVisible, closeMenu, toggleMenu } = useModel('controller');
  11. const { initialState, setInitialState } = useModel('@@initialState');
  12. const { changeLastBuildId, changeLastFloorId } = useModel('sagacare_buildFloor');
  13. //todo
  14. const [notifyList] = useState([
  15. {
  16. title: '管理员操作指南',
  17. id: 'notify1',
  18. content: '具体介绍管理员权限下的管理功能及相关操作说明。',
  19. name: '行政端操作指南.pdf',
  20. url: 'http://10.100.28.79/image-service/common/file_get?systemId=dataPlatform&key=%E8%A1%8C%E6%94%BF%E7%AB%AF%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C20220419.pdf',
  21. iconName: 'book',
  22. },
  23. {
  24. title: 'sagacare介绍',
  25. id: 'notify2',
  26. content: '环境健康主动管理服务',
  27. name: 'saga销售手册.pdf',
  28. url: 'http://10.100.28.79/image-service/common/file_get?systemId=dataPlatform&key=sagacare%E4%BB%8B%E7%BB%8D.pdf',
  29. iconName: 'introduce',
  30. },
  31. ]);
  32. const showMenuClick = () => {
  33. toggleMenu();
  34. };
  35. const openNotification = () => {
  36. //打开通知框
  37. notifyList.map((item, index) => {
  38. notification.open({
  39. key: item.id,
  40. message: item.title,
  41. description: item.content,
  42. duration: 0,
  43. className: 'custom-class',
  44. onClick: () => {
  45. console.log('Notification Clicked!', item);
  46. // 下载pdf 需产品给出
  47. //const downLoadUrl = '';
  48. const a = document.createElement('a');
  49. a.href = item.url;
  50. a.target = '_blank';
  51. a.download = item.name;
  52. a.click();
  53. },
  54. icon: <Icon type={item.iconName} style={{ fontSize: 32, color: '#108ee9' }}></Icon>,
  55. style: {
  56. width: 400,
  57. borderRadius: 30,
  58. cursor: 'pointer',
  59. },
  60. closeIcon: <></>,
  61. });
  62. });
  63. };
  64. //关闭提醒框
  65. const closeNotify = () => {
  66. //console.log('close-notify');
  67. notifyList.map((item, index) => {
  68. notification.close(item.id);
  69. });
  70. };
  71. useEffect(async () => {
  72. //关闭
  73. document.querySelector('#root').addEventListener('click', closeNotify, true);
  74. const { REACT_APP_ENV } = process.env;
  75. console.log('REACT_APP_ENV', REACT_APP_ENV);
  76. //读取缓存的 楼层id 建筑id
  77. var lastBuildId = sessionStorage.getItem('lastBuildId') || '';
  78. var lastFloorId = sessionStorage.getItem('lastFloorId') || '';
  79. changeLastBuildId(lastBuildId);
  80. changeLastFloorId(lastFloorId);
  81. return () => {
  82. document.querySelector('#root').removeEventListener('click', closeNotify, true);
  83. };
  84. }, []);
  85. const location = useLocation();
  86. useEffect(() => {
  87. //console.log('location', location);
  88. }, [location]);
  89. return (
  90. <div className={styles.layout}>
  91. <div className={styles.header}>
  92. <div className={styles.title}>
  93. <span
  94. className={styles.project}
  95. onClick={() => {
  96. history.push('/home');
  97. }}
  98. >
  99. 之江项目
  100. </span>
  101. <Head></Head>
  102. </div>
  103. {location.pathname.indexOf('home') == -1 && (
  104. <div className={styles.right}>
  105. <div className={styles.picture}>
  106. <Icon type="person" style={{ fontSize: 28 }}></Icon>
  107. </div>
  108. <div
  109. className={styles.notify}
  110. onClick={(event) => {
  111. event.stopPropagation();
  112. openNotification();
  113. }}
  114. >
  115. <Icon className={styles.notify} type="notify" style={{ fontSize: 21 }}></Icon>
  116. </div>
  117. <MenuFoldOutlined style={{ fontSize: 24 }} onClick={showMenuClick} />
  118. </div>
  119. )}
  120. </div>
  121. {props.children}
  122. <Drawer
  123. title=""
  124. placement="right"
  125. closable={false}
  126. onClose={closeMenu}
  127. open={menuVisible}
  128. drawerStyle={
  129. {
  130. // height: 340,
  131. // width: 380,
  132. // background: 'transparent',
  133. // transform: 'translate(-50px,20px)',
  134. // top: 100,
  135. //right: 20,
  136. }
  137. }
  138. maskStyle={{ background: 'transparent' }}
  139. contentWrapperStyle={{ boxShadow: 'none' }}
  140. bodyStyle={{ transform: 'translate(-20px,20px)' }}
  141. >
  142. <NavMenu></NavMenu>
  143. </Drawer>
  144. </div>
  145. );
  146. };