update
This commit is contained in:
parent
0bb7b761f9
commit
951f4ae1f5
@ -1,31 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<main class="site-content" :class="{ 'site-content--tabs': $route.meta.isTab }">
|
<main
|
||||||
|
class="site-content"
|
||||||
|
:class="{ 'site-content--tabs': $route.meta.isTab }"
|
||||||
|
>
|
||||||
<!-- 主入口标签页 s -->
|
<!-- 主入口标签页 s -->
|
||||||
<el-tabs
|
<el-tabs
|
||||||
v-if="$route.meta.isTab"
|
v-if="$route.meta.isTab"
|
||||||
v-model="mainTabsActiveName"
|
v-model="mainTabsActiveName"
|
||||||
:closable="true"
|
:closable="true"
|
||||||
@tab-click="selectedTabHandle"
|
@tab-click="selectedTabHandle"
|
||||||
@tab-remove="removeTabHandle">
|
@tab-remove="removeTabHandle"
|
||||||
|
>
|
||||||
<el-dropdown class="site-tabs__tools" :show-timeout="0">
|
<el-dropdown class="site-tabs__tools" :show-timeout="0">
|
||||||
<i class="el-icon-arrow-down el-icon--right"></i>
|
<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item @click.native="tabsCloseCurrentHandle">关闭当前标签页</el-dropdown-item>
|
<el-dropdown-item @click.native="tabsCloseCurrentHandle"
|
||||||
<el-dropdown-item @click.native="tabsCloseOtherHandle">关闭其它标签页</el-dropdown-item>
|
>关闭当前标签页</el-dropdown-item
|
||||||
<el-dropdown-item @click.native="tabsCloseAllHandle">关闭全部标签页</el-dropdown-item>
|
>
|
||||||
<el-dropdown-item @click.native="refresh()">刷新当前标签页</el-dropdown-item>
|
<el-dropdown-item @click.native="tabsCloseOtherHandle"
|
||||||
|
>关闭其它标签页</el-dropdown-item
|
||||||
|
>
|
||||||
|
<el-dropdown-item @click.native="tabsCloseAllHandle"
|
||||||
|
>关闭全部标签页</el-dropdown-item
|
||||||
|
>
|
||||||
|
<el-dropdown-item @click.native="refresh()"
|
||||||
|
>刷新当前标签页</el-dropdown-item
|
||||||
|
>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
v-for="item in mainTabs"
|
v-for="item in mainTabs"
|
||||||
:key="item.name"
|
:key="item.name"
|
||||||
:label="item.title"
|
:label="item.title"
|
||||||
:name="item.name">
|
:name="item.name"
|
||||||
|
>
|
||||||
<el-card :body-style="siteContentViewHeight">
|
<el-card :body-style="siteContentViewHeight">
|
||||||
<iframe
|
<iframe
|
||||||
v-if="item.type === 'iframe'"
|
v-if="item.type === 'iframe'"
|
||||||
:src="item.iframeUrl"
|
:src="item.iframeUrl"
|
||||||
width="100%" height="100%" frameborder="0" scrolling="yes">
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
frameborder="0"
|
||||||
|
scrolling="yes"
|
||||||
|
>
|
||||||
</iframe>
|
</iframe>
|
||||||
<keep-alive v-else>
|
<keep-alive v-else>
|
||||||
<router-view v-if="item.name === mainTabsActiveName" />
|
<router-view v-if="item.name === mainTabsActiveName" />
|
||||||
@ -43,85 +60,112 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isURL } from '@/utils/validate'
|
import { isURL } from "@/utils/validate";
|
||||||
export default {
|
export default {
|
||||||
inject: ['refresh'],
|
inject: ["refresh"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
}
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
documentClientHeight: {
|
documentClientHeight: {
|
||||||
get () { return this.$store.state.common.documentClientHeight }
|
get() {
|
||||||
|
return this.$store.state.common.documentClientHeight;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
menuActiveName: {
|
menuActiveName: {
|
||||||
get () { return this.$store.state.common.menuActiveName },
|
get() {
|
||||||
set (val) { this.$store.commit('common/updateMenuActiveName', val) }
|
return this.$store.state.common.menuActiveName;
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit("common/updateMenuActiveName", val);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mainTabs: {
|
mainTabs: {
|
||||||
get () { return this.$store.state.common.mainTabs },
|
get() {
|
||||||
set (val) { this.$store.commit('common/updateMainTabs', val) }
|
return this.$store.state.common.mainTabs;
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit("common/updateMainTabs", val);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mainTabsActiveName: {
|
mainTabsActiveName: {
|
||||||
get () { return this.$store.state.common.mainTabsActiveName },
|
get() {
|
||||||
set (val) { this.$store.commit('common/updateMainTabsActiveName', val) }
|
return this.$store.state.common.mainTabsActiveName;
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit("common/updateMainTabsActiveName", val);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
siteContentViewHeight() {
|
siteContentViewHeight() {
|
||||||
var height = this.documentClientHeight - 50 - 30 - 2
|
var height = this.documentClientHeight - 50 - 30 - 2;
|
||||||
if (this.$route.meta.isTab) {
|
if (this.$route.meta.isTab) {
|
||||||
height -= 40
|
height -= 40;
|
||||||
return isURL(this.$route.meta.iframeUrl) ? { height: height + 'px' } : { minHeight: height + 'px' }
|
return isURL(this.$route.meta.iframeUrl)
|
||||||
}
|
? { height: height + "px" }
|
||||||
return { minHeight: height + 'px' }
|
: { minHeight: height + "px" };
|
||||||
}
|
}
|
||||||
|
return { minHeight: height + "px" };
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// tabs, 选中tab
|
// tabs, 选中tab
|
||||||
selectedTabHandle(tab) {
|
selectedTabHandle(tab) {
|
||||||
tab = this.mainTabs.filter(item => item.name === tab.name)
|
tab = this.mainTabs.filter((item) => item.name === tab.name);
|
||||||
if (tab.length >= 1) {
|
if (tab.length >= 1) {
|
||||||
this.$router.push({ name: tab[0].name, query: tab[0].query, params: tab[0].params })
|
this.$router.push({
|
||||||
|
name: tab[0].name,
|
||||||
|
query: tab[0].query,
|
||||||
|
params: tab[0].params,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// tabs, 删除tab
|
// tabs, 删除tab
|
||||||
removeTabHandle(tabName) {
|
removeTabHandle(tabName) {
|
||||||
this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
|
this.mainTabs = this.mainTabs.filter((item) => item.name !== tabName);
|
||||||
if (this.mainTabs.length >= 1) {
|
if (this.mainTabs.length >= 1) {
|
||||||
// 当前选中tab被删除
|
// 当前选中tab被删除
|
||||||
if (tabName === this.mainTabsActiveName) {
|
if (tabName === this.mainTabsActiveName) {
|
||||||
var tab = this.mainTabs[this.mainTabs.length - 1]
|
var tab = this.mainTabs[this.mainTabs.length - 1];
|
||||||
this.$router.push({ name: tab.name, query: tab.query, params: tab.params }, () => {
|
this.$router.push(
|
||||||
this.mainTabsActiveName = this.$route.name
|
{ name: tab.name, query: tab.query, params: tab.params },
|
||||||
})
|
() => {
|
||||||
|
this.mainTabsActiveName = this.$route.name;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.menuActiveName = ''
|
this.menuActiveName = "";
|
||||||
this.$router.push({ name: 'home' })
|
this.$router.push({ name: "home" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// tabs, 关闭当前
|
// tabs, 关闭当前
|
||||||
tabsCloseCurrentHandle() {
|
tabsCloseCurrentHandle() {
|
||||||
this.removeTabHandle(this.mainTabsActiveName)
|
this.removeTabHandle(this.mainTabsActiveName);
|
||||||
},
|
},
|
||||||
// tabs, 关闭其它
|
// tabs, 关闭其它
|
||||||
tabsCloseOtherHandle() {
|
tabsCloseOtherHandle() {
|
||||||
this.mainTabs = this.mainTabs.filter(item => item.name === this.mainTabsActiveName)
|
this.mainTabs = this.mainTabs.filter(
|
||||||
|
(item) => item.name === this.mainTabsActiveName
|
||||||
|
);
|
||||||
},
|
},
|
||||||
// tabs, 关闭全部
|
// tabs, 关闭全部
|
||||||
tabsCloseAllHandle() {
|
tabsCloseAllHandle() {
|
||||||
this.mainTabs = []
|
this.mainTabs = [];
|
||||||
this.menuActiveName = ''
|
this.menuActiveName = "";
|
||||||
this.$router.push({ name: 'home' })
|
this.$router.push({ name: "home" });
|
||||||
},
|
},
|
||||||
// tabs, 刷新当前
|
// tabs, 刷新当前
|
||||||
tabsRefreshCurrentHandle() {
|
tabsRefreshCurrentHandle() {
|
||||||
var tab = this.$route
|
var tab = this.$route;
|
||||||
this.removeTabHandle(tab.name)
|
this.removeTabHandle(tab.name);
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$router.push({ name: tab.name, query: tab.query, params: tab.params })
|
this.$router.push({
|
||||||
})
|
name: tab.name,
|
||||||
}
|
query: tab.query,
|
||||||
}
|
params: tab.params,
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user