index.jsx 5.0 KB

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