Commit 05b76f73 by xinla

新增 扩展<el-tabs></el-tabs> 缓存当前激活索引和组件

1 parent a56d3420
<!-- 扩展<el-tabs></el-tabs> 缓存当前激活索引和组件 -->
<script>
export default {
components: {},
data() {
return {
active: 0,
opened: [],
}
},
computed: {},
watch: {},
created() {
if (this.$route.path != sessionStorage.activeTabPagePath) {
sessionStorage.activeTabIndex = ''
}
this.active = sessionStorage.activeTabIndex = this.$route.query.index || sessionStorage.activeTabIndex || '0'
sessionStorage.activeTabPagePath = this.$route.path
this.opened.push(this.active)
},
mounted() {},
methods: {
tabClick(v) {
this.active = sessionStorage.activeTabIndex = v.paneName
this.opened.includes(v.paneName) || this.opened.push(v.paneName)
},
},
}
</script>
<template>
<el-tabs v-model="active" @tab-click="tabClick">
<slot v-bind="{ active, opened }"></slot>
</el-tabs>
</template>
<style lang="scss" scoped>
.el-tabs--top {
z-index: 99;
position: sticky !important;
top: 0;
::v-deep .el-tabs__header {
z-index: 99;
position: sticky !important;
top: 0;
background: var(--bg-white);
border-radius: var(--border-radius);
box-shadow: 0px 4px 20px 0px var(--bg-black-10);
overflow: hidden;
}
::v-deep .el-tabs__item.is-top:nth-child(2) {
padding-left: 20px;
}
::v-deep .el-tabs__item.is-top:last-child {
padding-right: 20px;
}
}
</style>
...@@ -47,6 +47,7 @@ let components = { ...@@ -47,6 +47,7 @@ let components = {
RequestChartTable: () => import('./components/RequestChartTable.vue'), RequestChartTable: () => import('./components/RequestChartTable.vue'),
SearchResetButton: () => import('./components/SearchResetButton.vue'), SearchResetButton: () => import('./components/SearchResetButton.vue'),
CustomerRangeForm: () => import('./components/CustomerRangeForm.vue'), CustomerRangeForm: () => import('./components/CustomerRangeForm.vue'),
CacheElTabs: () => import('./components/CacheElTabs.vue'),
} }
for (const c in components) { for (const c in components) {
app.component(c, defineAsyncComponent(components[c])) app.component(c, defineAsyncComponent(components[c]))
......
...@@ -406,22 +406,6 @@ ...@@ -406,22 +406,6 @@
overflow: initial; overflow: initial;
} }
.el-tabs--top.sticky-t {
z-index: 99;
.el-tabs__header {
background: var(--bg-white);
border-radius: var(--border-radius);
box-shadow: 0px 4px 20px 0px var(--bg-black-10);
overflow: hidden;
}
.el-tabs__item.is-top:nth-child(2) {
padding-left: 20px;
}
.el-tabs__item.is-top:last-child {
padding-right: 20px;
}
}
// .diy-theme { // .diy-theme {
// .el-date-table td.in-range div { // .el-date-table td.in-range div {
// background-color: #e6f8ef; // background-color: #e6f8ef;
......
...@@ -6,9 +6,7 @@ export default { ...@@ -6,9 +6,7 @@ export default {
statistics: defineAsyncComponent(() => import('./statistics')), statistics: defineAsyncComponent(() => import('./statistics')),
}, },
data() { data() {
return { return {}
active: this.$route.query.index || '0',
}
}, },
computed: {}, computed: {},
watch: {}, watch: {},
...@@ -19,12 +17,14 @@ export default { ...@@ -19,12 +17,14 @@ export default {
</script> </script>
<template> <template>
<el-tabs class="sticky-t" v-model="active"> <CacheElTabs #="{ opened }">
<el-tab-pane label="活码信息"></el-tab-pane> <el-tab-pane label="活码信息">
<el-tab-pane label="拉群统计"></el-tab-pane> <aev />
</el-tabs> </el-tab-pane>
<aev v-show="active == 0" /> <el-tab-pane label="拉群统计">
<statistics v-show="active == 1" /> <statistics v-if="opened.includes('1')" />
</el-tab-pane>
</CacheElTabs>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>
...@@ -174,7 +174,7 @@ function getDataDetail(query) { ...@@ -174,7 +174,7 @@ function getDataDetail(query) {
return api.getDataDetail(query) return api.getDataDetail(query)
} }
/** 获取详情 */ /** 获取详情中客群列表 */
;(function getDetail() { ;(function getDetail() {
api.getDetail(id).then(({ data }) => { api.getDetail(id).then(({ data }) => {
groups = data.groups groups = data.groups
......
...@@ -6,9 +6,7 @@ export default { ...@@ -6,9 +6,7 @@ export default {
statistics: defineAsyncComponent(() => import('./statistics')), statistics: defineAsyncComponent(() => import('./statistics')),
}, },
data() { data() {
return { return {}
active: this.$route.query.index || '0',
}
}, },
computed: {}, computed: {},
watch: {}, watch: {},
...@@ -19,14 +17,14 @@ export default { ...@@ -19,14 +17,14 @@ export default {
</script> </script>
<template> <template>
<el-tabs v-model="active"> <CacheElTabs #="{ opened }">
<el-tab-pane label="任务信息"> <el-tab-pane label="任务信息">
<aev /> <aev />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="拉群统计"> <el-tab-pane label="拉群统计">
<statistics /> <statistics v-if="opened.includes('1')" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </CacheElTabs>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!