enterprise.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="parent d-flex flex-column">
  3. <Headers class="headers"></Headers>
  4. <div class="content d-flex">
  5. <side class="content-sticky" v-if="!router.currentRoute.value?.meta?.hideSide"></side>
  6. <div class="content-box d-flex flex-column" :style="`width: ${ !isInWhiteList(route.path, whiteList) ? 'calc(100vw - 250px)' : '100%'}`">
  7. <div v-if="!isInWhiteList(route.path, whiteList)" class="breadcrumbs_sticky">
  8. <div class=" d-flex align-center justify-space-between">
  9. <v-breadcrumbs :items="breadcrumbs" elevation="3">
  10. <template v-slot:item="{ item }">
  11. <span class="text" :class="{active: !item.disabled}" @click="toPath(item)">{{ item.text }}</span>
  12. </template>
  13. </v-breadcrumbs>
  14. </div>
  15. <v-divider></v-divider>
  16. </div>
  17. <div class="box pa-3">
  18. <div v-if="!isInWhiteList(route.path, whiteList)" class="box-content">
  19. <router-view></router-view>
  20. </div>
  21. <div v-else class="full">
  22. <router-view></router-view>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <Slider class="slider"></Slider>
  28. </div>
  29. </template>
  30. <script setup>
  31. defineOptions({ name: 'enterprise-layout-index' })
  32. import Headers from './company/navBar.vue'
  33. import Slider from './company/slider.vue'
  34. import side from './company/side.vue'
  35. import { useRouter, useRoute } from 'vue-router'
  36. import { watch, ref } from 'vue'
  37. const router = useRouter()
  38. const route = useRoute()
  39. const whiteList = [
  40. '/recruit/enterprise/talentPool/details',
  41. '/recruit/enterprise/position/details',
  42. '/recruit/enterprise/purchasePackage'
  43. ]
  44. // 查询是否在白名单内,在则不展示面包屑
  45. const isInWhiteList = (url, whiteList)=> {
  46. const path = url.split('?')[0]
  47. for (const item of whiteList) {
  48. if (path.startsWith(item)) {
  49. return true
  50. }
  51. }
  52. return false
  53. }
  54. const breadcrumbs = ref([])
  55. const getTitle = (list) => {
  56. const arr = list.map((item, index) => {
  57. if (item.path === list[index - 1]?.path) return false
  58. const text = item.meta.title
  59. const obj = { text, to: item.path }
  60. return obj
  61. }).filter(e => e)
  62. arr[arr.length - 1].disabled = true
  63. arr[arr.length - 1].link = true
  64. breadcrumbs.value = arr
  65. }
  66. watch(
  67. () => route.matched,
  68. (val) => {
  69. getTitle(val)
  70. },
  71. { immediate: true },
  72. { deep: true }
  73. )
  74. const toPath = ({ disabled, to }) => {
  75. if (disabled) {
  76. event.preventDefault()
  77. return
  78. }
  79. router.push(to)
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. $top: 50px;
  84. .parent {
  85. background-color: var(--default-bgc);
  86. }
  87. .headers {
  88. position: sticky;
  89. top: 0;
  90. z-index: 999;
  91. }
  92. .box {
  93. height: 0;
  94. flex: 1;
  95. height: calc(100vh - 50px);
  96. &-content {
  97. width: 100%;
  98. min-height: 100%;
  99. position: relative;
  100. overflow-y: auto;
  101. overflow-x: hidden;
  102. }
  103. }
  104. .full {
  105. height: calc(100vh - $top);
  106. width: 100%;
  107. flex: 1;
  108. position: relative;
  109. overflow-y: auto;
  110. overflow-x: hidden;
  111. }
  112. .slider {
  113. position: fixed;
  114. bottom: 50%;
  115. right: 24px;
  116. translate: 0 50%;
  117. z-index: 999;
  118. }
  119. .content {
  120. height: 0;
  121. flex: 1;
  122. &-sticky {
  123. position: sticky;
  124. top: $top;
  125. height: calc(100vh - $top);
  126. }
  127. }
  128. .breadcrumbs_sticky {
  129. position: sticky;
  130. top: $top;
  131. background: #FFF;
  132. z-index: var(--zIndex-breadcrumbs);
  133. border-left: 1px solid #eaecef;
  134. }
  135. .text {
  136. color: var(--color-999);
  137. font-size: 14px;
  138. &.active {
  139. color: var(--v-primary-base);
  140. cursor: pointer;
  141. }
  142. }
  143. </style>