68 lines
1.4 KiB
Vue
68 lines
1.4 KiB
Vue
<script>
|
|
import AiDvPanel from "./layout/AiDvPanel/AiDvPanel.vue";
|
|
|
|
export default {
|
|
name: "AiDvTabs",
|
|
components: {AiDvPanel},
|
|
props: {
|
|
config: Object,
|
|
},
|
|
data() {
|
|
return {activeTab: '0'}
|
|
},
|
|
computed: {
|
|
values: v => v.config?.[v.config?.dataType] || {},
|
|
tabs: v => Object.keys(v.values),
|
|
layers() {
|
|
return this.values[this.activeTab].map(e => ({dataType: "staticData", ...e, staticData: e.data})) || []
|
|
}
|
|
},
|
|
watch: {
|
|
tabs: {
|
|
immediate: true, deep: true,
|
|
handler(v) {
|
|
this.activeTab = v[0]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<section class="AiDvTabs">
|
|
<ai-dv-panel :padding="config.padding" :title="config.title" :theme="$attrs.theme" :border="config.border || ''">
|
|
<div slot="right" class="flex">
|
|
<div class="tabItem" v-for="(tab,i) in tabs" :key="i" v-text="tab" @click="activeTab=tab" :class="{active:activeTab==tab}"/>
|
|
</div>
|
|
<ai-dv-render class="fill" v-for="(e,i) in layers" :key="i" :data="layers[i]" :index="i"/>
|
|
</ai-dv-panel>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
.AiDvTabs {
|
|
height: 100%;
|
|
|
|
:deep(.content) {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
}
|
|
|
|
.tabItem {
|
|
color: #1FBECC;
|
|
background: #1f9ecc29;
|
|
padding: 0 10px;
|
|
line-height: 20px;
|
|
margin-left: 4px;
|
|
font-size: 12px;
|
|
user-select: none;
|
|
|
|
&.active {
|
|
border: 1px solid #20B4C5;
|
|
color: #02FEFF;
|
|
}
|
|
}
|
|
}
|
|
</style>
|