Files
dvcp_v2_webapp/ui/dv/AiDvTabs.vue

68 lines
1.4 KiB
Vue
Raw Permalink Normal View History

2024-04-15 14:31:13 +08:00
<script>
2024-04-16 17:42:57 +08:00
import AiDvPanel from "./layout/AiDvPanel/AiDvPanel.vue";
2024-04-15 14:31:13 +08:00
export default {
name: "AiDvTabs",
2024-04-16 17:42:57 +08:00
components: {AiDvPanel},
2024-04-15 14:31:13 +08:00
props: {
config: Object,
2024-04-16 17:42:57 +08:00
},
data() {
return {activeTab: '0'}
2024-04-15 14:31:13 +08:00
},
computed: {
2024-04-16 17:42:57 +08:00
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]
2024-04-15 15:35:57 +08:00
}
2024-04-15 14:31:13 +08:00
}
}
}
</script>
<template>
<section class="AiDvTabs">
2024-04-16 17:42:57 +08:00
<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>
2024-04-15 14:31:13 +08:00
</section>
</template>
<style scoped lang="scss">
.AiDvTabs {
2024-04-15 15:35:57 +08:00
height: 100%;
2024-04-16 17:42:57 +08:00
2024-04-16 17:51:49 +08:00
:deep(.content) {
display: flex;
flex-direction: column;
gap: 16px;
}
2024-04-16 17:42:57 +08:00
.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;
}
}
2024-04-15 14:31:13 +08:00
}
</style>