t20-common-lib 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="data.length === 0" class="n20-secondary-tab m-b-s">
|
|
3
|
+
<div class="el-tabs__item is-active" style="padding: 0;">{{ init }}</div>
|
|
4
|
+
</div>
|
|
5
|
+
<div v-else-if="data.length === 1" class="n20-secondary-tab m-b-s">
|
|
6
|
+
<div class="el-tabs__item is-active" style="padding: 0;">
|
|
7
|
+
<span v-if="data[0].icon" :class="data[0].icon"></span>
|
|
8
|
+
<sup v-if="data[0].badge" class="el-tabs__item-badge"></sup>
|
|
9
|
+
{{ data[0].name }}
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<el-tabs v-else :value="init" :class="classes" :tabPosition="tabPosition" :before-leave="beforeFn" @tab-click="clickFn">
|
|
13
|
+
<el-tab-pane
|
|
14
|
+
v-for="item of data"
|
|
15
|
+
:key="item.name"
|
|
16
|
+
:tab-info="item"
|
|
17
|
+
:name="item.name"
|
|
18
|
+
:icon="item.icon"
|
|
19
|
+
:disabled="item.disabled"
|
|
20
|
+
>
|
|
21
|
+
<template slot="label">
|
|
22
|
+
<span v-if="item.icon" :class="item.icon"></span>
|
|
23
|
+
<sup v-if="item.badge" class="el-tabs__item-badge"></sup>
|
|
24
|
+
<span v-if="item.content" v-title="`${item.content}`"> {{ item.name }}</span>
|
|
25
|
+
<span v-else>{{ item.name }}</span>
|
|
26
|
+
<i
|
|
27
|
+
v-if="item.tips"
|
|
28
|
+
v-title="item.tips"
|
|
29
|
+
class="n20-icon-xinxitishi"
|
|
30
|
+
style="color: var(--color-text-secondary); align-self: flex-start;"
|
|
31
|
+
></i>
|
|
32
|
+
</template>
|
|
33
|
+
</el-tab-pane>
|
|
34
|
+
</el-tabs>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
name: 'TabPane',
|
|
41
|
+
props: {
|
|
42
|
+
data: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => []
|
|
45
|
+
},
|
|
46
|
+
init: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: ''
|
|
49
|
+
},
|
|
50
|
+
stop: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
tabPosition: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: 'top'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
computed: {
|
|
60
|
+
classes(){
|
|
61
|
+
return {
|
|
62
|
+
'n20-secondary-tab': true,
|
|
63
|
+
'm-b-s': this.tabPosition == 'top',
|
|
64
|
+
'left-css': this.tabPosition == 'left'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
getTooltip(name, tips) {
|
|
70
|
+
return `<el-tooltip content="${tips}">${name}</el-tooltip>`
|
|
71
|
+
},
|
|
72
|
+
clickFn(C) {
|
|
73
|
+
let item = C.$attrs['tab-info']
|
|
74
|
+
if (this.$listeners['update:init']) {
|
|
75
|
+
!item.disabled && this.$emit('update:init', item.name)
|
|
76
|
+
}
|
|
77
|
+
if (this.$listeners['click']) {
|
|
78
|
+
this.$emit('click', item)
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
beforeFn(name) {
|
|
82
|
+
return !this.stop
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<style>
|
|
89
|
+
.tooltip {
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 100%;
|
|
92
|
+
left: 0;
|
|
93
|
+
z-index: 9999;
|
|
94
|
+
background-color: black;
|
|
95
|
+
color: white;
|
|
96
|
+
padding: 5px;
|
|
97
|
+
font-size: 12px;
|
|
98
|
+
opacity: 0;
|
|
99
|
+
transition: opacity 0.3s;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tooltip::after {
|
|
103
|
+
content: '';
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: -5px;
|
|
106
|
+
left: 50%;
|
|
107
|
+
transform: translateX(-50%);
|
|
108
|
+
border: 5px solid transparent;
|
|
109
|
+
border-bottom-color: black;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.tooltip.show {
|
|
113
|
+
opacity: 1;
|
|
114
|
+
}
|
|
115
|
+
.left-css .el-tabs__item.is-active:after{
|
|
116
|
+
width: 2px;
|
|
117
|
+
height: 20px!important;
|
|
118
|
+
margin-top: -22px!important;
|
|
119
|
+
margin-left: -10px;
|
|
120
|
+
}
|
|
121
|
+
.left-css .el-tabs__item.is-left {
|
|
122
|
+
text-align: left!important;
|
|
123
|
+
}
|
|
124
|
+
.left-css .el-tabs__header.is-left{
|
|
125
|
+
margin-right: 0!important;
|
|
126
|
+
margin-left: 10px!important;
|
|
127
|
+
}
|
|
128
|
+
</style>
|