enterprise.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. '/recruit/enterprise/systemManagement/groupAccount/addBranchOffice'
  44. ]
  45. // 查询是否在白名单内,在则不展示面包屑
  46. const isInWhiteList = (url, whiteList)=> {
  47. const path = url.split('?')[0]
  48. for (const item of whiteList) {
  49. if (path.startsWith(item)) {
  50. return true
  51. }
  52. }
  53. return false
  54. }
  55. const breadcrumbs = ref([])
  56. const getTitle = (list) => {
  57. const arr = list.map((item, index) => {
  58. if (item.path === list[index - 1]?.path) return false
  59. const text = item.meta.title
  60. const obj = { text, to: item.path }
  61. return obj
  62. }).filter(e => e)
  63. arr[arr.length - 1].disabled = true
  64. arr[arr.length - 1].link = true
  65. breadcrumbs.value = arr
  66. }
  67. watch(
  68. () => route.matched,
  69. (val) => {
  70. getTitle(val)
  71. },
  72. { immediate: true },
  73. { deep: true }
  74. )
  75. const toPath = ({ disabled, to }) => {
  76. if (disabled) {
  77. event.preventDefault()
  78. return
  79. }
  80. router.push(to)
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. $top: 50px;
  85. .parent {
  86. background-color: var(--default-bgc);
  87. }
  88. .headers {
  89. position: sticky;
  90. top: 0;
  91. z-index: 999;
  92. }
  93. .box {
  94. height: 0;
  95. flex: 1;
  96. height: calc(100vh - 50px);
  97. &-content {
  98. width: 100%;
  99. min-height: 100%;
  100. position: relative;
  101. overflow-y: auto;
  102. overflow-x: hidden;
  103. }
  104. }
  105. .full {
  106. height: calc(100vh - $top);
  107. width: 100%;
  108. flex: 1;
  109. position: relative;
  110. overflow-y: auto;
  111. overflow-x: hidden;
  112. }
  113. .slider {
  114. position: fixed;
  115. bottom: 50%;
  116. right: 24px;
  117. translate: 0 50%;
  118. z-index: 999;
  119. }
  120. .content {
  121. height: 0;
  122. flex: 1;
  123. &-sticky {
  124. position: sticky;
  125. top: $top;
  126. height: calc(100vh - $top);
  127. }
  128. }
  129. .breadcrumbs_sticky {
  130. position: sticky;
  131. top: $top;
  132. background: #FFF;
  133. z-index: var(--zIndex-breadcrumbs);
  134. border-left: 1px solid #eaecef;
  135. }
  136. .text {
  137. color: var(--color-999);
  138. font-size: 14px;
  139. &.active {
  140. color: var(--v-primary-base);
  141. cursor: pointer;
  142. }
  143. }
  144. </style>