CCL_QMS检验
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.7 KiB

​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 weeks ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
3 weeks ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <main class="site-content" :class="{ 'site-content--tabs': $route.meta.isTab }">
  3. <!-- 主入口标签页 s -->
  4. <el-tabs
  5. v-if="$route.meta.isTab"
  6. v-model="mainTabsActiveName"
  7. :closable="true"
  8. @tab-click="selectedTabHandle"
  9. @tab-remove="removeTabHandle">
  10. <el-dropdown class="site-tabs__tools" :show-timeout="0">
  11. <i class="el-icon-arrow-down el-icon--right"></i>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item @click.native="tabsCloseCurrentHandle">{{ $t('main.tabs.closeCurrent') }}</el-dropdown-item>
  14. <el-dropdown-item @click.native="tabsCloseOtherHandle">{{ $t('main.tabs.closeOther') }}</el-dropdown-item>
  15. <el-dropdown-item @click.native="tabsCloseAllHandle">{{ $t('main.tabs.closeAll') }}</el-dropdown-item>
  16. <el-dropdown-item @click.native="refresh()">{{ $t('main.tabs.refreshCurrent') }}</el-dropdown-item>
  17. </el-dropdown-menu>
  18. </el-dropdown>
  19. <el-tab-pane
  20. v-for="item in mainTabs"
  21. :key="item.name"
  22. :label="translateTabTitle(item.title)"
  23. :name="item.name">
  24. <el-card :body-style="siteContentViewHeight">
  25. <iframe
  26. v-if="item.type === 'iframe'"
  27. :src="item.iframeUrl"
  28. width="100%" height="100%" frameborder="0" scrolling="yes">
  29. </iframe>
  30. <keep-alive v-else>
  31. <router-view v-if="item.name === mainTabsActiveName" />
  32. </keep-alive>
  33. </el-card>
  34. </el-tab-pane>
  35. </el-tabs>
  36. <!-- 主入口标签页 e -->
  37. <el-card v-else :body-style="siteContentViewHeight">
  38. <keep-alive>
  39. <router-view />
  40. </keep-alive>
  41. </el-card>
  42. </main>
  43. </template>
  44. <script>
  45. import { isURL } from '@/utils/validate'
  46. import { getMenuNameI18nKey } from '@/i18n/menuNameMap'
  47. export default {
  48. inject: ['refresh'],
  49. data () {
  50. return {
  51. }
  52. },
  53. computed: {
  54. documentClientHeight: {
  55. get () { return this.$store.state.common.documentClientHeight }
  56. },
  57. menuActiveName: {
  58. get () { return this.$store.state.common.menuActiveName },
  59. set (val) { this.$store.commit('common/updateMenuActiveName', val) }
  60. },
  61. mainTabs: {
  62. get () { return this.$store.state.common.mainTabs },
  63. set (val) { this.$store.commit('common/updateMainTabs', val) }
  64. },
  65. mainTabsActiveName: {
  66. get () { return this.$store.state.common.mainTabsActiveName },
  67. set (val) { this.$store.commit('common/updateMainTabsActiveName', val) }
  68. },
  69. siteContentViewHeight () {
  70. // 35: 顶栏高度;30: .site-content 上下 padding;2: 边框余量
  71. var height = this.documentClientHeight - 50 - 30 - 2
  72. if (this.$route.meta.isTab) {
  73. height -= 40
  74. return isURL(this.$route.meta.iframeUrl) ? { height: height + 'px' } : { minHeight: height + 'px' }
  75. }
  76. return { minHeight: height + 'px' }
  77. }
  78. },
  79. methods: {
  80. translateTabTitle (title) {
  81. const key = getMenuNameI18nKey(title)
  82. return key ? this.$t(key) : title
  83. },
  84. // tabs, 选中tab
  85. selectedTabHandle (tab) {
  86. tab = this.mainTabs.filter(item => item.name === tab.name)
  87. if (tab.length >= 1) {
  88. this.$router.push({ name: tab[0].name, query: tab[0].query, params: tab[0].params })
  89. }
  90. },
  91. // tabs, 删除tab
  92. removeTabHandle (tabName) {
  93. this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
  94. if (this.mainTabs.length >= 1) {
  95. // 当前选中tab被删除
  96. if (tabName === this.mainTabsActiveName) {
  97. var tab = this.mainTabs[this.mainTabs.length - 1]
  98. this.$router.push({ name: tab.name, query: tab.query, params: tab.params }, () => {
  99. this.mainTabsActiveName = this.$route.name
  100. })
  101. }
  102. } else {
  103. this.menuActiveName = ''
  104. this.$router.push({ name: 'home' })
  105. }
  106. },
  107. // tabs, 关闭当前
  108. tabsCloseCurrentHandle () {
  109. console.log(this.$route.meta.menuId)
  110. this.removeTabHandle(this.mainTabsActiveName)
  111. },
  112. // tabs, 关闭其它
  113. tabsCloseOtherHandle () {
  114. this.mainTabs = this.mainTabs.filter(item => item.name === this.mainTabsActiveName)
  115. },
  116. // tabs, 关闭全部
  117. tabsCloseAllHandle () {
  118. this.mainTabs = []
  119. this.menuActiveName = ''
  120. this.$router.push({ name: 'home' })
  121. },
  122. // tabs, 刷新当前
  123. tabsRefreshCurrentHandle () {
  124. var tab = this.$route
  125. this.removeTabHandle(tab.name)
  126. this.$nextTick(() => {
  127. this.$router.push({ name: tab.name, query: tab.query, params: tab.params })
  128. })
  129. }
  130. }
  131. }
  132. </script>