123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <Header :class="getHeaderClass">
- <!-- left start -->
- <div :class="`${prefixCls}-left`">
- <!-- logo -->
- <AppLogo v-if="getShowHeaderLogo || getIsMobile" :class="`${prefixCls}-logo`" :theme="getHeaderTheme" :style="getLogoWidth" />
- <LayoutTrigger
- v-if="(getShowContent && getShowHeaderTrigger && !getSplit && !getIsMixSidebar) || getIsMobile"
- :theme="getHeaderTheme"
- :sider="false"
- />
- <LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" />
- <!-- 欢迎语 -->
- <span
- v-if="getShowContent && getShowBreadTitle && !getIsMobile"
- :class="[prefixCls, `${prefixCls}--${getHeaderTheme}`, 'headerIntroductionClass']"
- >
- {{ t('layout.header.welcomeIn') }} {{ title }}
- </span>
- </div>
- <!-- left end -->
- <!-- menu start -->
- <div :class="`${prefixCls}-menu`" v-if="getShowTopMenu && !getIsMobile">
- <LayoutMenu :isHorizontal="true" :theme="getHeaderTheme" :splitType="getSplitType" :menuMode="getMenuMode" />
- </div>
- <!-- menu-end -->
- <!-- action -->
- <div :class="`${prefixCls}-action`">
- <Row>
- <Col :span="24">
- <div class="mr-3" v-if="isShowSelect">
- <Select :options="deptList" :fieldNames="{ label: 'departName', value: 'id' }" v-model:value="currentId"></Select> </div
- ></Col>
- </Row>
- <AppSearch :class="`${prefixCls}-action__item `" v-if="getShowSearch" />
- <ErrorAction v-if="getUseErrorHandle" :class="`${prefixCls}-action__item error-action`" />
- <Notify v-if="getShowNotice" :class="`${prefixCls}-action__item notify-item`" />
- <FullScreen v-if="getShowFullScreen" :class="`${prefixCls}-action__item fullscreen-item`" />
- <LockScreen v-if="getUseLockPage" />
- <UserDropDown :theme="getHeaderTheme" />
- <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" />
- </div>
- </Header>
- <LoginSelect ref="loginSelectRef" @success="loginSelectOk"></LoginSelect>
- </template>
- <script lang="ts">
- import { defineComponent, unref, computed, ref, onMounted, toRaw } from 'vue';
- import { useGlobSetting } from '/@/hooks/setting';
- import { propTypes } from '/@/utils/propTypes';
- import { Layout, Select, Row, Col } from 'ant-design-vue';
- import { AppLogo } from '/@/components/Application';
- import LayoutMenu from '../menu/index.vue';
- import LayoutTrigger from '../trigger/index.vue';
- import { AppSearch } from '/@/components/Application';
- import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
- import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
- import { useRootSetting } from '/@/hooks/setting/useRootSetting';
- import { MenuModeEnum, MenuSplitTyeEnum } from '/@/enums/menuEnum';
- import { SettingButtonPositionEnum } from '/@/enums/appEnum';
- import { UserDropDown, LayoutBreadcrumb, FullScreen, Notify, ErrorAction, LockScreen } from './components';
- import { useAppInject } from '/@/hooks/web/useAppInject';
- import { useDesign } from '/@/hooks/web/useDesign';
- import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
- import { useLocale } from '/@/locales/useLocale';
- import LoginSelect from '/@/views/sys/login/LoginSelect.vue';
- import { useUserStore } from '/@/store/modules/user';
- import { useI18n } from '/@/hooks/web/useI18n';
- const { t } = useI18n();
- import { useShopInfoStore } from '/@/store/modules/shopInfo';
- import { storeToRefs } from 'pinia';
- export default defineComponent({
- name: 'LayoutHeader',
- components: {
- Header: Layout.Header,
- AppLogo,
- LayoutTrigger,
- LayoutBreadcrumb,
- LayoutMenu,
- UserDropDown,
- FullScreen,
- Notify,
- AppSearch,
- ErrorAction,
- LockScreen,
- LoginSelect,
- Select,
- Row,
- Col,
- SettingDrawer: createAsyncComponent(() => import('/@/layouts/default/setting/index.vue'), {
- loading: true,
- }),
- },
- props: {
- fixed: propTypes.bool,
- },
- setup(props) {
- const { prefixCls } = useDesign('layout-header');
- const userStore = useUserStore();
- const { getShowTopMenu, getShowHeaderTrigger, getSplit, getIsMixMode, getMenuWidth, getIsMixSidebar } = useMenuSetting();
- const { getUseErrorHandle, getShowSettingButton, getSettingButtonPosition, getAiIconShow } = useRootSetting();
- const { title } = useGlobSetting();
- const { isShowSelect, deptList, currentId } = storeToRefs(useShopInfoStore());
- const {
- getHeaderTheme,
- getShowFullScreen,
- getShowNotice,
- getShowContent,
- getShowBread,
- getShowHeaderLogo,
- getShowHeader,
- getShowSearch,
- getUseLockPage,
- getShowBreadTitle,
- } = useHeaderSetting();
- const { getShowLocalePicker } = useLocale();
- const { getIsMobile } = useAppInject();
- const getHeaderClass = computed(() => {
- const theme = unref(getHeaderTheme);
- return [
- prefixCls,
- {
- [`${prefixCls}--fixed`]: props.fixed,
- [`${prefixCls}--mobile`]: unref(getIsMobile),
- [`${prefixCls}--${theme}`]: theme,
- },
- ];
- });
- const getShowSetting = computed(() => {
- if (!unref(getShowSettingButton)) {
- return false;
- }
- const settingButtonPosition = unref(getSettingButtonPosition);
- if (settingButtonPosition === SettingButtonPositionEnum.AUTO) {
- return unref(getShowHeader);
- }
- return settingButtonPosition === SettingButtonPositionEnum.HEADER;
- });
- const getLogoWidth = computed(() => {
- if (!unref(getIsMixMode) || unref(getIsMobile)) {
- return {};
- }
- const width = unref(getMenuWidth) < 180 ? 180 : unref(getMenuWidth);
- return { width: `${width}px` };
- });
- const getSplitType = computed(() => {
- return unref(getSplit) ? MenuSplitTyeEnum.TOP : MenuSplitTyeEnum.NONE;
- });
- const getMenuMode = computed(() => {
- return unref(getSplit) ? MenuModeEnum.HORIZONTAL : null;
- });
- /**
- * 首页多租户部门弹窗逻辑
- */
- const loginSelectRef = ref();
- function showLoginSelect() {
- //update-begin---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
- //判断是否是登陆进来
- const loginInfo = toRaw(userStore.getLoginInfo) || {};
- if (!!loginInfo.isLogin) {
- loginSelectRef.value.show(loginInfo);
- }
- //update-end---author:liusq Date:20220101 for:判断登录进来是否需要弹窗选择租户----
- }
- function loginSelectOk() {
- console.log('成功。。。。。');
- }
- onMounted(() => {
- showLoginSelect();
- });
- return {
- prefixCls,
- getHeaderClass,
- getShowHeaderLogo,
- getHeaderTheme,
- getShowHeaderTrigger,
- getIsMobile,
- getShowBreadTitle,
- getShowBread,
- getShowContent,
- getSplitType,
- getSplit,
- getMenuMode,
- getShowTopMenu,
- getShowLocalePicker,
- getShowFullScreen,
- getShowNotice,
- getUseErrorHandle,
- getLogoWidth,
- getIsMixSidebar,
- getShowSettingButton,
- getShowSetting,
- getShowSearch,
- getUseLockPage,
- loginSelectOk,
- loginSelectRef,
- title,
- t,
- getAiIconShow,
- isShowSelect,
- deptList,
- currentId,
- };
- },
- });
- </script>
- <style lang="less">
- @import './index.less';
- //update-begin---author:scott ---date:2022-09-30 for:默认隐藏顶部菜单面包屑-----------
- //顶部欢迎语展示样式
- @prefix-cls: ~'@{namespace}-layout-header';
- .ant-layout .@{prefix-cls} {
- display: flex;
- padding: 0 8px;
- // update-begin--author:liaozhiyang---date:20240407---for:【QQYUN-8762】顶栏高度
- height: @header-height;
- // update-end--author:liaozhiyang---date:20240407---for:【QQYUN-8762】顶栏高度
- align-items: center;
- .headerIntroductionClass {
- margin-right: 4px;
- margin-bottom: 2px;
- border-bottom: 0px;
- border-left: 0px;
- }
- &--light {
- .headerIntroductionClass {
- color: #000;
- }
- }
- &--dark {
- .headerIntroductionClass {
- color: rgba(255, 255, 255, 1);
- }
- .anticon,
- .truncate {
- color: rgba(255, 255, 255, 1);
- }
- }
- //update-end---author:scott ---date::2022-09-30 for:默认隐藏顶部菜单面包屑--------------
- }
- </style>
|