|
@@ -1,15 +1,10 @@
|
|
|
<template>
|
|
|
- <el-tabs type="card" v-if="history&&history.length>0"
|
|
|
- :value="currentPath"
|
|
|
- @tab-click="tabClick"
|
|
|
- @tab-remove="tabRemove"
|
|
|
- closable class="content">
|
|
|
- <el-tab-pane v-for="item in history"
|
|
|
- :key="item.path"
|
|
|
- :label="item.name"
|
|
|
- :name="item.path">
|
|
|
- </el-tab-pane>
|
|
|
- </el-tabs>
|
|
|
+ <div class="tabs">
|
|
|
+ <div class="tab-header">
|
|
|
+ <div v-for="item in history" :key="item.path" @click="tabClick(item)" :class="['tab_item',item.path==currentPath?'tab_item_active':'']">{{ item.name }} <span @click.stop="tabRemove(item.path)" class="el-icon-close"></span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -27,7 +22,8 @@ export default {
|
|
|
mounted(){
|
|
|
},
|
|
|
methods:{
|
|
|
- tabClick({name}){
|
|
|
+ tabClick(item){
|
|
|
+ var name = item.path
|
|
|
this.$store.commit('addHistoryPath',name);
|
|
|
if(name!==this.$route.path){
|
|
|
//跳转历史的路由
|
|
@@ -44,53 +40,57 @@ export default {
|
|
|
tabRemove(path){
|
|
|
this.$store.commit('removeHistoryPath',path);
|
|
|
this.$store.commit('removeHistory',path);
|
|
|
- this.tabClick({name:this.currentPath})
|
|
|
+ if(this.currentPath == path){
|
|
|
+ this.tabClick(this.history[this.history.length-1])
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-.content{
|
|
|
- margin-top: 5px;
|
|
|
- /* height: 35px; */
|
|
|
- user-select: none;
|
|
|
-}
|
|
|
-:deep(.el-tabs__nav-wrap){
|
|
|
- height: 35px !important;
|
|
|
- line-height: 35px !important;
|
|
|
-}
|
|
|
-:deep(.el-tabs__nav-next) , :deep(.el-tabs__nav-prev){
|
|
|
- line-height: 35px !important;
|
|
|
-}
|
|
|
-:deep(.el-tabs__header){
|
|
|
- height: 35px !important;
|
|
|
- margin: 0;
|
|
|
- border: none;
|
|
|
-}
|
|
|
-:deep(.el-tabs__item){
|
|
|
- height: 30px;
|
|
|
- margin-top: 2px;
|
|
|
- margin-bottom: 2px;
|
|
|
- border: 1px solid grey !important;
|
|
|
- line-height: 30px;
|
|
|
- padding: 0 10px 0 10px !important;
|
|
|
- border-radius: 2px;
|
|
|
-}
|
|
|
-
|
|
|
-:deep(.el-tabs__item:not(:last-child)){
|
|
|
- margin-right: 10px;
|
|
|
-}
|
|
|
-
|
|
|
-:deep(.is-active){
|
|
|
- border-bottom:inherit;
|
|
|
- background-color: lightcyan;
|
|
|
-}
|
|
|
-:deep(.el-tabs__nav){
|
|
|
- border: none !important;
|
|
|
- /*height: 35px;*/
|
|
|
- /*1px solid #E4E7ED*/
|
|
|
-}
|
|
|
-
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .tabs{
|
|
|
+ overflow-x: auto;
|
|
|
+ overflow-y: hidden;
|
|
|
+ width: 100%;
|
|
|
+ color: #303133;
|
|
|
+ font-size: 14px;
|
|
|
+ .tab-header::after{
|
|
|
+ content: "";
|
|
|
+ display: block;
|
|
|
+ width: 100%;
|
|
|
+ height: 1px;
|
|
|
+ background: #e4e7ed;
|
|
|
+ margin-top: -1px;
|
|
|
+ }
|
|
|
+ .tab_item{
|
|
|
+ padding: 0 13px;
|
|
|
+ line-height: 35px;
|
|
|
+ text-align: center;
|
|
|
+ height: 35px;
|
|
|
+ min-width: 80px;
|
|
|
+ border-right: 1px solid #e4e7ed;
|
|
|
+ display: inline-block;
|
|
|
+ position: relative;
|
|
|
+ cursor: pointer;
|
|
|
+ z-index: 9999;
|
|
|
+ .el-icon-close{
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .tab_item:hover{
|
|
|
+ .el-icon-close{
|
|
|
+ display: inline;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .tab_item_active{
|
|
|
+ border-bottom: 1px solid #b6b6d7;
|
|
|
+ font-weight: bold;
|
|
|
+ .el-icon-close{
|
|
|
+ display: inline;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
</style>
|
|
|
|