index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <Header
  3. v-if="
  4. ((!getShowFullHeader && !currentRoute.path.endsWith('home')) || currentRoute.path.startsWith('/micro-vent-3dModal/modelchannel/')) &&
  5. !noHeadeLink.includes(currentRoute.path)
  6. "
  7. :class="[
  8. ...getHeaderClass,
  9. {
  10. 'vent-header': currentRoute.path.startsWith('/monitorChannel/monitor-'),
  11. 'normal-header': !currentRoute.path.startsWith('/monitorChannel/monitor-'),
  12. 'no-header': currentRoute.path.endsWith('home'),
  13. },
  14. ]"
  15. style="z-index: 1"
  16. >
  17. <!-- left start -->
  18. <div :class="`${prefixCls}-left`">
  19. <!-- logo -->
  20. <!-- <AppLogo v-if="getShowHeaderLogo || getIsMobile" :class="`${prefixCls}-logo`" :theme="getHeaderTheme" :style="getLogoWidth" /> -->
  21. <AppLogo :class="`${prefixCls}-logo`" :theme="getHeaderTheme" :style="getLogoWidth" />
  22. <div v-if="!currentRoute.path.startsWith('/monitorChannel/monitor-')" style="margin-top: 5px; color: #aaa; margin-left: 10px; font-weight: 600"
  23. >/{{ currentRoute.meta.title }}</div
  24. >
  25. <!-- <LayoutTrigger
  26. v-if="(getShowContent && getShowHeaderTrigger && !getSplit && !getIsMixSidebar) || getIsMobile"
  27. :theme="getHeaderTheme"
  28. :sider="false"
  29. />
  30. <LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" />
  31. <span v-if="getShowContent && getShowBreadTitle" :class="[prefixCls, `${prefixCls}--${getHeaderTheme}`, 'headerIntroductionClass']">
  32. 欢迎进入 {{ title }}
  33. </span> -->
  34. </div>
  35. <!-- left end -->
  36. <!-- menu start -->
  37. <div v-if="currentRoute.path.startsWith('/monitorChannel/monitor-')" :class="`${prefixCls}-vent`">
  38. <!-- <div>主通风机监测控制</div> -->
  39. <div class="header-nav-title">{{ currentRoute.meta.title }} </div>
  40. </div>
  41. <div :class="`${prefixCls}-menu`" v-else-if="getShowTopMenu && !getIsMobile">
  42. <LayoutMenu :isHorizontal="true" :theme="getHeaderTheme" :splitType="getSplitType" :menuMode="getMenuMode" />
  43. </div>
  44. <!-- menu-end -->
  45. <!-- action -->
  46. <div :class="`${prefixCls}-action`">
  47. <!-- <div class="right-position">
  48. <VoiceBroadcast />
  49. <UserDropDown v-if="showUserDropdown" :theme="getHeaderTheme" />
  50. </div>
  51. <LoginSelect ref="loginSelectRef" @success="loginSelectOk" /> -->
  52. </div>
  53. </Header>
  54. <div :class="`${prefixCls}-action`" style="position: fixed; top: 30px; right: 20px; z-index: 999999">
  55. <div class="right-position">
  56. <!-- 公司端不显示语音播报功能 -->
  57. <VoiceBroadcast v-if="sysOrgCode != 'sdmtjtgsd'" />
  58. <UserDropDown v-if="showUserDropdown" :theme="getHeaderTheme" />
  59. <LoginSelect ref="loginSelectRef" @success="loginSelectOk" />
  60. </div>
  61. </div>
  62. </template>
  63. <script lang="ts">
  64. import { defineComponent, unref, computed, ref, onMounted, toRaw } from 'vue';
  65. import { useGlobSetting } from '/@/hooks/setting';
  66. import { propTypes } from '/@/utils/propTypes';
  67. import { Layout } from 'ant-design-vue';
  68. import { AppLogo } from '/@/components/Application';
  69. import LayoutMenu from '../menu/index.vue';
  70. import LayoutTrigger from '../trigger/index.vue';
  71. import { AppSearch } from '/@/components/Application';
  72. import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
  73. import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
  74. import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  75. import { MenuModeEnum, MenuSplitTyeEnum } from '/@/enums/menuEnum';
  76. import { SettingButtonPositionEnum } from '/@/enums/appEnum';
  77. import { AppLocalePicker } from '/@/components/Application';
  78. import { UserDropDown, LayoutBreadcrumb, FullScreen, Notify, ErrorAction, LockScreen } from './components';
  79. import { useAppInject } from '/@/hooks/web/useAppInject';
  80. import { useDesign } from '/@/hooks/web/useDesign';
  81. import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
  82. import { useLocale } from '/@/locales/useLocale';
  83. import VoiceBroadcast from './components/VoiceBroadcast.vue';
  84. import LoginSelect from '/@/views/sys/login/LoginSelect.vue';
  85. import { useUserStore } from '/@/store/modules/user';
  86. import { useRouter } from 'vue-router';
  87. import { noHeadeLink } from '../layout.data';
  88. export default defineComponent({
  89. name: 'LayoutHeader',
  90. components: {
  91. Header: Layout.Header,
  92. AppLogo,
  93. LayoutTrigger,
  94. LayoutBreadcrumb,
  95. LayoutMenu,
  96. UserDropDown,
  97. AppLocalePicker,
  98. FullScreen,
  99. Notify,
  100. AppSearch,
  101. ErrorAction,
  102. LockScreen,
  103. LoginSelect,
  104. VoiceBroadcast,
  105. SettingDrawer: createAsyncComponent(() => import('/@/layouts/default/setting/index.vue'), {
  106. loading: true,
  107. }),
  108. },
  109. props: {
  110. fixed: propTypes.bool,
  111. },
  112. setup(props) {
  113. const { prefixCls } = useDesign('layout-header');
  114. const userStore = useUserStore();
  115. const { currentRoute } = useRouter();
  116. console.log(currentRoute);
  117. const { getShowTopMenu, getShowHeaderTrigger, getSplit, getIsMixMode, getMenuWidth, getIsMixSidebar } = useMenuSetting();
  118. const { getUseErrorHandle, getShowSettingButton, getSettingButtonPosition } = useRootSetting();
  119. const { title, sysOrgCode } = useGlobSetting();
  120. const {
  121. getHeaderTheme,
  122. getShowFullScreen,
  123. getShowNotice,
  124. getShowContent,
  125. getShowBread,
  126. getShowHeaderLogo,
  127. getShowHeader,
  128. getShowSearch,
  129. getUseLockPage,
  130. getShowBreadTitle,
  131. getShowFullHeaderRef,
  132. } = useHeaderSetting();
  133. const { getShowLocalePicker } = useLocale();
  134. const { getIsMobile } = useAppInject();
  135. const getHeaderClass = computed(() => {
  136. const theme = unref(getHeaderTheme);
  137. return [
  138. prefixCls,
  139. {
  140. [`${prefixCls}--fixed`]: props.fixed,
  141. [`${prefixCls}--mobile`]: unref(getIsMobile),
  142. [`${prefixCls}--${theme}`]: theme,
  143. },
  144. ];
  145. });
  146. const getShowFullHeader = computed(() => {
  147. const route = unref(currentRoute);
  148. return getShowFullHeaderRef && route.path.startsWith('/micro-');
  149. });
  150. const getShowSetting = computed(() => {
  151. if (!unref(getShowSettingButton)) {
  152. return false;
  153. }
  154. const settingButtonPosition = unref(getSettingButtonPosition);
  155. if (settingButtonPosition === SettingButtonPositionEnum.AUTO) {
  156. return unref(getShowHeader);
  157. }
  158. return settingButtonPosition === SettingButtonPositionEnum.HEADER;
  159. });
  160. const getLogoWidth = computed(() => {
  161. if (!unref(getIsMixMode) || unref(getIsMobile)) {
  162. return {};
  163. }
  164. const width = unref(getMenuWidth) < 180 ? 180 : unref(getMenuWidth);
  165. return { width: `${width}px` };
  166. });
  167. const getSplitType = computed(() => {
  168. return unref(getSplit) ? MenuSplitTyeEnum.TOP : MenuSplitTyeEnum.NONE;
  169. });
  170. const getMenuMode = computed(() => {
  171. return unref(getSplit) ? MenuModeEnum.HORIZONTAL : null;
  172. });
  173. // /**
  174. // * 首页多租户部门弹窗逻辑
  175. // */
  176. const loginSelectRef = ref();
  177. function showLoginSelect() {
  178. //update-begin---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
  179. //判断是否是登陆进来
  180. const loginInfo = toRaw(userStore.getLoginInfo) || {};
  181. if (!!loginInfo.isLogin) {
  182. loginSelectRef.value.show(loginInfo);
  183. }
  184. //update-end---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
  185. }
  186. function loginSelectOk() {
  187. console.log('成功。。。。。');
  188. }
  189. // 用户下拉框应该在以下情况中隐藏:
  190. // 1. 本页面是由其他页面的 iframe 嵌入的页面
  191. const showUserDropdown = computed(() => {
  192. return window.self === window.top;
  193. });
  194. onMounted(() => {
  195. showLoginSelect();
  196. });
  197. return {
  198. prefixCls,
  199. getHeaderClass,
  200. getShowHeaderLogo,
  201. getHeaderTheme,
  202. getShowHeaderTrigger,
  203. getIsMobile,
  204. getShowBreadTitle,
  205. getShowBread,
  206. getShowContent,
  207. getSplitType,
  208. getSplit,
  209. getMenuMode,
  210. getShowTopMenu,
  211. getShowLocalePicker,
  212. getShowFullScreen,
  213. getShowNotice,
  214. getUseErrorHandle,
  215. getLogoWidth,
  216. getIsMixSidebar,
  217. getShowSettingButton,
  218. getShowSetting,
  219. getShowSearch,
  220. getUseLockPage,
  221. loginSelectOk,
  222. loginSelectRef,
  223. currentRoute,
  224. title,
  225. getShowFullHeader,
  226. noHeadeLink,
  227. showUserDropdown,
  228. sysOrgCode,
  229. };
  230. },
  231. });
  232. </script>
  233. <style lang="less">
  234. @import './index.less';
  235. //update-begin---author:scott ---date:2022-09-30 for:默认隐藏顶部菜单面包屑-----------
  236. //顶部欢迎语展示样式
  237. @prefix-cls: ~'@{namespace}-layout-header';
  238. .@{prefix-cls} {
  239. display: flex;
  240. padding: 0 8px;
  241. // align-items: center;
  242. .headerIntroductionClass {
  243. margin-right: 4px;
  244. margin-bottom: 2px;
  245. border-bottom: 0px;
  246. border-left: 0px;
  247. }
  248. &--light {
  249. .headerIntroductionClass {
  250. color: @breadcrumb-item-normal-color;
  251. }
  252. }
  253. &--dark {
  254. .headerIntroductionClass {
  255. color: rgba(255, 255, 255, 0.6);
  256. }
  257. .anticon {
  258. color: rgba(255, 255, 255, 0.8);
  259. }
  260. }
  261. //update-end---author:scott ---date::2022-09-30 for:默认隐藏顶部菜单面包屑--------------
  262. }
  263. // background: linear-gradient(#003f77, #0a134c);
  264. // // background: linear-gradient(#02050c 0%, #03114c 100%);
  265. // // border: none;
  266. // border-bottom: 1px solid #81aabf01;
  267. // padding-bottom: 2px;
  268. // box-shadow: 0 0 20px #44caff55 inset;
  269. .normal-header {
  270. height: 52px !important;
  271. line-height: 52px !important;
  272. background: var(--vent-header-bg-color) !important;
  273. // background: linear-gradient(#005177,#0a344c) !important;
  274. border-bottom: 1px solid #81aabf01 !important;
  275. padding-bottom: 2px !important;
  276. box-shadow: 0 0 20px #44caff55 inset !important;
  277. padding: 0 8px !important;
  278. }
  279. .no-header {
  280. height: 0px !important;
  281. display: none !important;
  282. }
  283. .header-nav-title {
  284. background-image: linear-gradient(#ffffff 50%, #60f4ff);
  285. -webkit-background-clip: text;
  286. color: transparent;
  287. font-weight: 600;
  288. }
  289. </style>