123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <div class="parent d-flex flex-column">
- <Headers class="headers"></Headers>
- <div class="content d-flex">
- <side class="content-sticky" v-if="!router.currentRoute.value?.meta?.hideSide"></side>
- <div class="content-box d-flex flex-column" :style="`width: ${ !isInWhiteList(route.path, whiteList) ? 'calc(100vw - 250px)' : '100%'}`">
- <div v-if="!isInWhiteList(route.path, whiteList)" class="breadcrumbs_sticky">
- <div class=" d-flex align-center justify-space-between">
- <v-breadcrumbs :items="breadcrumbs" elevation="3">
- <template v-slot:item="{ item }">
- <span class="text" :class="{active: !item.disabled}" @click="toPath(item)">{{ item.text }}</span>
- </template>
- </v-breadcrumbs>
- </div>
- <v-divider></v-divider>
- </div>
- <div class="box pa-3">
- <div v-if="!isInWhiteList(route.path, whiteList)" class="box-content">
- <router-view></router-view>
- </div>
- <div v-else class="full">
- <router-view></router-view>
- </div>
- </div>
- </div>
- </div>
- <Slider class="slider"></Slider>
- </div>
- </template>
- <script setup>
- defineOptions({ name: 'enterprise-layout-index' })
- import Headers from './company/navBar.vue'
- import Slider from './company/slider.vue'
- import side from './company/side.vue'
- import { useRouter, useRoute } from 'vue-router'
- import { watch, ref } from 'vue'
- const router = useRouter()
- const route = useRoute()
- const whiteList = [
- '/recruit/enterprise/talentPool/details',
- '/recruit/enterprise/position/details',
- '/recruit/enterprise/purchasePackage'
- ]
- // 查询是否在白名单内,在则不展示面包屑
- const isInWhiteList = (url, whiteList)=> {
- const path = url.split('?')[0]
- for (const item of whiteList) {
- if (path.startsWith(item)) {
- return true
- }
- }
- return false
- }
- const breadcrumbs = ref([])
- const getTitle = (list) => {
- const arr = list.map((item, index) => {
- if (item.path === list[index - 1]?.path) return false
- const text = item.meta.title
- const obj = { text, to: item.path }
- return obj
- }).filter(e => e)
- arr[arr.length - 1].disabled = true
- arr[arr.length - 1].link = true
- breadcrumbs.value = arr
- }
- watch(
- () => route.matched,
- (val) => {
- getTitle(val)
- },
- { immediate: true },
- { deep: true }
- )
- const toPath = ({ disabled, to }) => {
- if (disabled) {
- event.preventDefault()
- return
- }
- router.push(to)
- }
- </script>
- <style lang="scss" scoped>
- $top: 50px;
- .parent {
- background-color: var(--default-bgc);
- }
- .headers {
- position: sticky;
- top: 0;
- z-index: 999;
- }
- .box {
- height: 0;
- flex: 1;
- height: calc(100vh - 50px);
- &-content {
- width: 100%;
- min-height: 100%;
- position: relative;
- overflow-y: auto;
- overflow-x: hidden;
- }
- }
- .full {
- height: calc(100vh - $top);
- width: 100%;
- flex: 1;
- position: relative;
- overflow-y: auto;
- overflow-x: hidden;
- }
- .slider {
- position: fixed;
- bottom: 50%;
- right: 24px;
- translate: 0 50%;
- z-index: 999;
- }
- .content {
- height: 0;
- flex: 1;
- &-sticky {
- position: sticky;
- top: $top;
- height: calc(100vh - $top);
- }
- }
- .breadcrumbs_sticky {
- position: sticky;
- top: $top;
- background: #FFF;
- z-index: var(--zIndex-breadcrumbs);
- border-left: 1px solid #eaecef;
- }
- .text {
- color: var(--color-999);
- font-size: 14px;
- &.active {
- color: var(--v-primary-base);
- cursor: pointer;
- }
- }
- </style>
|