side.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. import { useEnterpriseStore } from '@/store/enterprise'
  49. const enterpriseStore = useEnterpriseStore()
  50. const list = computed(() => {
  51. return getList(enterpriseStore.enterpriseMenu)
  52. })
  53. // console.log(import.meta.env.VITE_NODE_ENV, '当前环境变量============')
  54. // const isAdmin = localStorage.getItem('isAdmin') === '1'
  55. // const info = localStorage.getItem('entBaseInfo') ? JSON.parse(localStorage.getItem('entBaseInfo')) : {}
  56. const getList = (arr, obj = [], root = '') => {
  57. // 是否为企业管理员
  58. arr.forEach(element => {
  59. if (!element.alwaysShow) return
  60. let data = {}
  61. // const path = element.path[0] === '/' ? element.path : '/' + element.path
  62. const path = root + element.path
  63. data = {
  64. title: element.name,
  65. enName: element?.meta?.enName,
  66. icon: element.icon,
  67. name: element.name,
  68. path: enterpriseStore.menuType.CATALOGUE === element.type ? path + '/index' : path,
  69. children: []
  70. }
  71. // if (element?.meta?.isAdmin) {
  72. // data.isAdmin = true
  73. // }
  74. // 人才地图
  75. // if (element?.meta?.isPersonMap) data.isPersonMap = true
  76. // 全员猎寻
  77. // if (element?.meta?.hireJob) data.hireJob = true
  78. if (element?.children) {
  79. getList(element.children, data.children, path + '/')
  80. }
  81. obj.push(data)
  82. })
  83. // if (!isAdmin) {
  84. // obj = obj.filter(e => !e.isAdmin)
  85. // obj.map(e => {
  86. // e.children = e.children.filter(val => !val.isAdmin)
  87. // })
  88. // }
  89. // 人才地图是否可看
  90. // if (info && Object.keys(info).length && !info?.entitlement?.personMap) obj = obj.filter(e => !e.isPersonMap)
  91. // 全员猎寻是否可看
  92. // if (info && Object.keys(info).length && !info?.entitlement?.hireJob) obj = obj.filter(e => !e.hireJob)
  93. // 生产环境隐藏门墩儿新任命
  94. if (import.meta.env.VITE_NODE_ENV === 'production') obj = obj.filter(e => !e.path.includes('/recruit/enterprise/newlyAppointed'))
  95. return obj
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .side-box {
  100. width: 230px;
  101. height: 100%;
  102. }
  103. </style>