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.

197 lines
5.5 KiB

8 months ago
  1. <template>
  2. <div>
  3. <main class="site-content" :class="{ 'site-content--tabs': $route.meta.isTab }">
  4. <!-- 主入口标签页 s -->
  5. <el-tabs
  6. v-if="$route.meta.isTab"
  7. v-model="mainTabsActiveName"
  8. :closable="true"
  9. @tab-click="selectedTabHandle"
  10. @tab-remove="removeTabHandle">
  11. <el-dropdown class="site-tabs__tools" :show-timeout="0">
  12. <i class="el-icon-arrow-down el-icon--right"></i>
  13. <el-dropdown-menu slot="dropdown">
  14. <el-dropdown-item @click.native="tabsCloseCurrentHandle">关闭当前标签页</el-dropdown-item>
  15. <el-dropdown-item @click.native="tabsCloseOtherHandle">关闭其它标签页</el-dropdown-item>
  16. <el-dropdown-item @click.native="tabsCloseAllHandle">关闭全部标签页</el-dropdown-item>
  17. <el-dropdown-item @click.native="refresh()">刷新当前标签页</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. <el-tab-pane
  21. v-for="item in mainTabs"
  22. :key="item.name"
  23. :label="item.title"
  24. :name="item.name">
  25. <el-card :body-style="siteContentViewHeight">
  26. <iframe
  27. v-if="item.type === 'iframe'"
  28. :src="item.iframeUrl"
  29. width="100%" height="100%" frameborder="0" scrolling="yes">
  30. </iframe>
  31. <keep-alive v-else>
  32. <router-view v-if="item.name === mainTabsActiveName" />
  33. </keep-alive>
  34. </el-card>
  35. </el-tab-pane>
  36. </el-tabs>
  37. <!-- 主入口标签页 e -->
  38. <el-card v-else :body-style="siteContentViewHeight">
  39. <keep-alive>
  40. <router-view />
  41. </keep-alive>
  42. </el-card>
  43. </main>
  44. </div>
  45. </template>
  46. <script>
  47. import { isURL } from '@/utils/validate'
  48. export default {
  49. inject: ['refresh'],
  50. data () {
  51. return {
  52. cloneSiftList:[],
  53. flag:false,
  54. settingFlag:false,
  55. selectionSiftList:[],
  56. recordList:[],
  57. selectData:{
  58. itemDesc:undefined,
  59. },
  60. querySavedVo:{
  61. menuId:this.$route.meta.menuId,
  62. userId:this.$store.state.user.id,
  63. itemNo:undefined,
  64. itemDesc:undefined,
  65. caseSensitiveFlag:'N'
  66. },
  67. saveQueryHeader:false,
  68. }
  69. },
  70. computed: {
  71. documentClientHeight: {
  72. get () { return this.$store.state.common.documentClientHeight }
  73. },
  74. menuActiveName: {
  75. get () { return this.$store.state.common.menuActiveName },
  76. set (val) { this.$store.commit('common/updateMenuActiveName', val) }
  77. },
  78. mainTabs: {
  79. get () { return this.$store.state.common.mainTabs },
  80. set (val) { this.$store.commit('common/updateMainTabs', val) }
  81. },
  82. mainTabsActiveName: {
  83. get () { return this.$store.state.common.mainTabsActiveName },
  84. set (val) { this.$store.commit('common/updateMainTabsActiveName', val) }
  85. },
  86. siteContentViewHeight () {
  87. var height = this.documentClientHeight - 50 - 2
  88. if (this.$route.meta.isTab) {
  89. height -= 40
  90. return isURL(this.$route.meta.iframeUrl) ? { height: height + 'px' } : { minHeight: height + 'px' }
  91. }
  92. return { minHeight: height + 'px' }
  93. },
  94. siftList:{
  95. get(){
  96. return this.$store.state.sift.siftList.filter(e => e.visible === 'Y'|| this.settingFlag)
  97. },
  98. }
  99. },
  100. methods: {
  101. // tabs, 选中tab
  102. selectedTabHandle (tab) {
  103. tab = this.mainTabs.filter(item => item.name === tab.name)
  104. if (tab.length >= 1) {
  105. this.$router.push({ name: tab[0].name, query: tab[0].query, params: tab[0].params })
  106. }
  107. },
  108. // tabs, 删除tab
  109. removeTabHandle (tabName) {
  110. this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
  111. if (this.mainTabs.length >= 1) {
  112. // 当前选中tab被删除
  113. if (tabName === this.mainTabsActiveName) {
  114. var tab = this.mainTabs[this.mainTabs.length - 1]
  115. this.$router.push({ name: tab.name, query: tab.query, params: tab.params }, () => {
  116. this.mainTabsActiveName = this.$route.name
  117. })
  118. }
  119. } else {
  120. this.menuActiveName = ''
  121. this.$router.push({ name: 'home' })
  122. }
  123. },
  124. // tabs, 关闭当前
  125. tabsCloseCurrentHandle () {
  126. console.log(this.$route.meta.menuId)
  127. this.removeTabHandle(this.mainTabsActiveName)
  128. },
  129. // tabs, 关闭其它
  130. tabsCloseOtherHandle () {
  131. this.mainTabs = this.mainTabs.filter(item => item.name === this.mainTabsActiveName)
  132. },
  133. // tabs, 关闭全部
  134. tabsCloseAllHandle () {
  135. this.mainTabs = []
  136. this.menuActiveName = ''
  137. this.$router.push({ name: 'home' })
  138. },
  139. },
  140. watch:{
  141. // 监听路由变化调用筛选查询
  142. // $route:'flushSift'
  143. },
  144. mounted() {
  145. // this.flushSift()
  146. console.log(this.$store.state.user.id)
  147. }
  148. }
  149. </script>
  150. <style scoped>
  151. /deep/ .el-table .cell{
  152. height: auto;
  153. }
  154. .box-div{
  155. width: 100%;
  156. margin-bottom: 5px;
  157. padding-bottom: 5px;
  158. //border-bottom: 1px solid #eee;
  159. }
  160. .box-div button{
  161. height: 32px;
  162. width: 80px;
  163. background: rgb(22,179,163);
  164. border: none;
  165. border-radius: 5px;
  166. color: #fff;
  167. cursor: pointer;
  168. }
  169. .box-div button:hover{
  170. background: rgb(97, 217, 204);
  171. }
  172. /deep/ .el-input .el-input-group__prepend{
  173. background-color: #fff;
  174. }
  175. /deep/ .el-autocomplete .el-input .el-input-group__append{
  176. background-color: rgb(22,179,163);
  177. color: #fff;
  178. border: 1px solid rgb(22,179,163);
  179. }
  180. .el-input-number /deep/ .el-input__inner{
  181. text-align: right;
  182. padding-right: 5px !important;
  183. }
  184. /deep/ .el-input-number--medium{
  185. line-height: 20px;
  186. }
  187. </style>