enterprise.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 :key="key"></router-view>
  20. </div>
  21. <div v-else class="full">
  22. <router-view :key="key"></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, computed } from 'vue'
  37. const router = useRouter()
  38. const route = useRoute()
  39. const key = computed(() => {
  40. return route.path + Math.random()
  41. })
  42. const whiteList = [
  43. '/recruit/enterprise/talentPool/details',
  44. '/recruit/enterprise/position/details',
  45. '/recruit/enterprise/purchasePackage',
  46. '/recruit/enterprise/systemManagement/groupAccount/invite/0',
  47. '/recruit/enterprise/systemManagement/groupAccount/invite/1'
  48. ]
  49. // 查询是否在白名单内,在则不展示面包屑
  50. const isInWhiteList = (url, whiteList)=> {
  51. const path = url.split('?')[0]
  52. for (const item of whiteList) {
  53. if (path.startsWith(item)) {
  54. return true
  55. }
  56. }
  57. return false
  58. }
  59. const breadcrumbs = ref([])
  60. const getTitle = (list) => {
  61. const arr = list.map((item, index) => {
  62. if (item.path === list[index - 1]?.path) return false
  63. const text = item.meta.title
  64. const obj = { text, to: item.path }
  65. return obj
  66. }).filter(e => e)
  67. arr[arr.length - 1].disabled = true
  68. arr[arr.length - 1].link = true
  69. breadcrumbs.value = arr
  70. }
  71. watch(
  72. () => route.matched,
  73. (val) => {
  74. getTitle(val)
  75. },
  76. { immediate: true },
  77. { deep: true }
  78. )
  79. const toPath = ({ disabled, to }) => {
  80. if (disabled) {
  81. event.preventDefault()
  82. return
  83. }
  84. router.push(to)
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. $top: 50px;
  89. .parent {
  90. background-color: var(--default-bgc);
  91. }
  92. .headers {
  93. position: sticky;
  94. top: 0;
  95. z-index: 999;
  96. }
  97. .box {
  98. height: 0;
  99. flex: 1;
  100. height: calc(100vh - 50px);
  101. &-content {
  102. width: 100%;
  103. min-height: 100%;
  104. position: relative;
  105. overflow-y: auto;
  106. overflow-x: hidden;
  107. }
  108. }
  109. .full {
  110. height: calc(100vh - $top);
  111. width: 100%;
  112. flex: 1;
  113. position: relative;
  114. overflow-y: auto;
  115. overflow-x: hidden;
  116. }
  117. .slider {
  118. position: fixed;
  119. bottom: 50%;
  120. right: 24px;
  121. translate: 0 50%;
  122. z-index: 999;
  123. }
  124. .content {
  125. height: 0;
  126. flex: 1;
  127. &-sticky {
  128. position: sticky;
  129. top: $top;
  130. height: calc(100vh - $top);
  131. }
  132. }
  133. .breadcrumbs_sticky {
  134. position: sticky;
  135. top: $top;
  136. background: #FFF;
  137. z-index: var(--zIndex-breadcrumbs);
  138. border-left: 1px solid #eaecef;
  139. }
  140. .text {
  141. color: var(--color-999);
  142. font-size: 14px;
  143. &.active {
  144. color: var(--v-primary-base);
  145. cursor: pointer;
  146. }
  147. }
  148. /* 滚动条样式 */
  149. ::-webkit-scrollbar {
  150. -webkit-appearance: none;
  151. width: 0px;
  152. height: 0px;
  153. }
  154. /* 滚动条内的轨道 */
  155. ::-webkit-scrollbar-track {
  156. background: rgba(0, 0, 0, 0.1);
  157. border-radius: 0;
  158. }
  159. /* 滚动条内的滑块 */
  160. ::-webkit-scrollbar-thumb {
  161. cursor: pointer;
  162. border-radius: 5px;
  163. background: rgba(0, 0, 0, 0.15);
  164. transition: color 0.2s ease;
  165. }
  166. </style>