panoramaDetails.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="white pa-3 content">
  3. <el-menu :default-active="activeIndex" unique-opened class="el-menu-demo" mode="horizontal" @select="onSelect">
  4. <template v-for="_menu in menuList">
  5. <PanoramaDetailsMenu :key="_menu.id" :item="_menu"></PanoramaDetailsMenu>
  6. </template>
  7. </el-menu>
  8. <div class="py-5">
  9. <el-breadcrumb>
  10. <el-breadcrumb-item
  11. v-for="(_path, i) in breadcrumbs"
  12. :key="_path.value"
  13. :to="i < breadcrumbs.length - 1 ? $route.path + '?organizationNo=' + _path.value : undefined"
  14. >
  15. {{ _path.label }}
  16. </el-breadcrumb-item>
  17. <el-breadcrumb-item v-for="MP in menuPath" :key="MP.value">{{ MP.label }}</el-breadcrumb-item>
  18. </el-breadcrumb>
  19. </div>
  20. <div class="content-body">
  21. <component :is="componentsPath" :key="$route.fullPath" ref="panorama" @hook:mounted="onMounted"></component>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { mapGetters } from 'vuex'
  27. import PanoramaDetailsMenu from './panoramaDetailsMenu.vue'
  28. import { getOrganizationTree } from '@/utils/dict'
  29. import {
  30. findPath
  31. } from '@/utils/panorama'
  32. export default {
  33. name: 'panorama-details',
  34. components: { PanoramaDetailsMenu },
  35. data () {
  36. return {
  37. activeIndex: 'humanResources/payroll',
  38. breadcrumbs: [],
  39. componentsPath: null
  40. }
  41. },
  42. computed: {
  43. ...mapGetters(['routes']),
  44. menuList () {
  45. return this.filterRoute(JSON.parse(JSON.stringify(this.routes)))
  46. },
  47. menuPath () {
  48. return findPath(this.menuList, this.activeIndex, [], {
  49. children: 'children',
  50. value: 'component',
  51. label: 'label'
  52. })
  53. }
  54. },
  55. watch: {
  56. '$route.fullPath': function () {
  57. this.getDept()
  58. }
  59. },
  60. created () {
  61. this.getDept()
  62. this.runPanorama()
  63. },
  64. methods: {
  65. async getDept () {
  66. const data = await getOrganizationTree()
  67. if (!data) {
  68. return
  69. }
  70. this.breadcrumbs = findPath(data, this.$route.query.organizationNo)
  71. if (this.$route.query.employeeName && this.$route.query.employeeNo) {
  72. this.breadcrumbs.push({ value: this.$route.query.employeeNo, label: this.$route.query.employeeName })
  73. }
  74. },
  75. // 使用原菜单页面,通过ref调用开启页面内部的onInitPanorama方法开启全景页面
  76. runPanorama () {
  77. this.componentsPath = () => import(`@/views/${this.activeIndex}`)
  78. },
  79. onMounted () {
  80. if (!this.$refs.panorama.onInitPanorama) {
  81. this.$message.error('当前页面不支持全景功能')
  82. return
  83. }
  84. this.$refs.panorama.onInitPanorama(this.$route.query.organizationNo, this.$route.query.employeeNo)
  85. },
  86. filterRoute (items) {
  87. return items.filter(item => {
  88. if (item.children && item.children.length) {
  89. item.children = this.filterRoute(item.children)
  90. }
  91. return item.meta.panorama
  92. })
  93. },
  94. onSelect (v) {
  95. this.activeIndex = v
  96. this.runPanorama()
  97. },
  98. onRun (path) {
  99. window.open(this.$route.path + '?organizationNo=' + path)
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .content {
  106. width: 100%;
  107. height: 100%;
  108. box-sizing: border-box;
  109. display: flex;
  110. flex-direction: column;
  111. &-body {
  112. height: 0;
  113. flex: 1;
  114. }
  115. }
  116. </style>