side.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div>
  3. <v-list class="side-box" color="primary">
  4. <template v-for="(item, index) in list">
  5. <template v-if="!item.children.length">
  6. <v-list-item
  7. :key="`${item.name}_${index}`"
  8. active-class="active"
  9. color="primary"
  10. :href="item.path"
  11. :to="item.path"
  12. rounded="shaped"
  13. :prepend-icon="item.icon"
  14. :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"
  15. >
  16. </v-list-item>
  17. </template>
  18. <v-list-group
  19. v-else
  20. color="primary"
  21. rounded="shaped"
  22. :key="`${item.path}_${item.title}`"
  23. :prepend-icon="item.icon"
  24. >
  25. <template v-slot:activator="{ props }">
  26. <v-list-item v-bind="props" :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"></v-list-item>
  27. </template>
  28. <v-list-item
  29. v-for="(val, i) in item.children"
  30. :key="i"
  31. color="primary"
  32. :href="val.path"
  33. style="padding-left: 40px;"
  34. :to="val.path"
  35. :title="getCurrentLocaleLang() === 'zh_CN' ? val.title : val.enName"
  36. rounded="shaped"
  37. ></v-list-item>
  38. </v-list-group>
  39. </template>
  40. </v-list>
  41. </div>
  42. </template>
  43. <script setup>
  44. defineOptions({ name: 'enterprise-side'})
  45. import { computed } from 'vue'
  46. import { getCurrentLocaleLang } from '@/utils/lang.js'
  47. import enterpriseRoute from '@/router/modules/components/recruit/enterprise'
  48. const list = computed(() => {
  49. return getList(enterpriseRoute)
  50. })
  51. const getList = (arr, obj = []) => {
  52. // 是否为企业管理员
  53. const isAdmin = localStorage.getItem('isAdmin')
  54. arr.forEach(element => {
  55. if (element.show) return
  56. let data = {}
  57. data = {
  58. title: element?.meta?.title,
  59. enName: element?.meta?.enName,
  60. icon: element?.meta?.icon,
  61. name: element?.name,
  62. path: element?.path,
  63. children: []
  64. }
  65. if (element?.meta?.isAdmin) {
  66. data.isAdmin = true
  67. }
  68. if (element?.children) {
  69. getList(element.children, data.children)
  70. }
  71. obj.push(data)
  72. })
  73. if (isAdmin === 'false') {
  74. obj = obj.filter(e => !e.isAdmin)
  75. obj.map(e => {
  76. e.children = e.children.filter(val => !val.isAdmin)
  77. })
  78. }
  79. return obj
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .side-box {
  84. width: 230px;
  85. height: 100%;
  86. }
  87. </style>