panoramaDetails.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. <!--
  22. 全景视图相关页面
  23. 根据菜单配置显示传入 panorama 参数为全景打开 (非必须,根据自己需要使用)
  24. onMounted默认允许子页面内onInitPanorama方法(必须配置)传入两个参数为机构id和员工id
  25. -->
  26. <component
  27. :is="componentsPath"
  28. :key="$route.fullPath"
  29. :panorama="true"
  30. ref="panorama"
  31. @hook:mounted="onMounted"
  32. ></component>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { mapGetters } from 'vuex'
  38. import PanoramaDetailsMenu from './panoramaDetailsMenu.vue'
  39. import {
  40. findPath
  41. } from '@/utils/panorama'
  42. import qs from 'qs'
  43. const DEFAULT_COMPONENT = {
  44. 基础信息: 'humanResources/panorama/dynamic/panoramaDetailsBaseInfo'
  45. }
  46. export default {
  47. name: 'panorama-details',
  48. components: { PanoramaDetailsMenu },
  49. data () {
  50. return {
  51. activeIndex: '',
  52. breadcrumbs: [],
  53. componentsPath: null,
  54. defaultItems: []
  55. }
  56. },
  57. computed: {
  58. ...mapGetters(['routes', 'organizationTree']),
  59. menuList () {
  60. return [
  61. ...this.defaultItems,
  62. ...this.filterRoute(JSON.parse(JSON.stringify(this.routes)))
  63. ]
  64. },
  65. menuPath () {
  66. return findPath(this.menuList, this.activeIndex, [], {
  67. children: 'children',
  68. value: 'component',
  69. label: 'label'
  70. })
  71. }
  72. },
  73. watch: {
  74. '$route.fullPath': function () {
  75. this.getDept()
  76. }
  77. },
  78. created () {
  79. this.defaultItems = Object.keys(DEFAULT_COMPONENT).map(key => {
  80. return {
  81. label: key,
  82. component: DEFAULT_COMPONENT[key]
  83. }
  84. })
  85. this.activeIndex = this.$route.query.path || this.defaultItems[0].component
  86. this.getDept()
  87. this.runPanorama()
  88. },
  89. methods: {
  90. async getDept () {
  91. this.breadcrumbs = findPath(this.organizationTree, this.$route.query.organizationNo)
  92. if (this.$route.query.employeeName && this.$route.query.employeeNo) {
  93. this.breadcrumbs.push({ value: this.$route.query.employeeNo, label: this.$route.query.employeeName })
  94. }
  95. },
  96. // 使用原菜单页面,通过ref调用开启页面内部的onInitPanorama方法开启全景页面
  97. runPanorama () {
  98. this.componentsPath = () => import(`@/views/${this.activeIndex}`)
  99. },
  100. onMounted () {
  101. if (!this.$refs.panorama.onInitPanorama) {
  102. this.$message.error('尚未配置实例化方法')
  103. return
  104. }
  105. this.$refs.panorama.onInitPanorama(this.$route.query.organizationNo, this.$route.query.employeeNo)
  106. },
  107. filterRoute (items) {
  108. return items.filter(item => {
  109. if (item.children && item.children.length) {
  110. item.children = this.filterRoute(item.children)
  111. }
  112. return item.meta.panorama
  113. })
  114. },
  115. onSelect (v) {
  116. this.activeIndex = v
  117. const query = { ...this.$route.query }
  118. query.path = v
  119. this.$router.push(`${this.$route.path}?${qs.stringify(query)}`)
  120. this.runPanorama()
  121. },
  122. onRun (path) {
  123. window.open(this.$route.path + '?organizationNo=' + path)
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .content {
  130. width: 100%;
  131. height: 100%;
  132. box-sizing: border-box;
  133. display: flex;
  134. flex-direction: column;
  135. &-body {
  136. height: 0;
  137. flex: 1;
  138. }
  139. }
  140. ::v-deep .el-menu-demo {
  141. &>.el-submenu {
  142. overflow: hidden;
  143. }
  144. &>.is-active {
  145. background-color: unset !important;
  146. color: #303133 !important;
  147. }
  148. }
  149. </style>