2025-06-13 09:38:37 +00:00
|
|
|
<template>
|
2025-07-15 06:20:53 +00:00
|
|
|
<el-dropdown trigger="click" placement="bottom-start" class="workspace-dropdown" popper-class="workspace-dropdown-popper">
|
2025-06-20 09:02:42 +00:00
|
|
|
<el-button text style="font-size: 14px" class="workspace-dropdown__button">
|
2025-06-26 08:36:08 +00:00
|
|
|
<AppIcon iconName="app-workspace" style="font-size: 18px"></AppIcon>
|
2025-07-10 09:09:19 +00:00
|
|
|
<span class="ellipsis" style="max-width: 155px" :title="currentWorkspace?.name">
|
2025-06-13 09:38:37 +00:00
|
|
|
{{ currentWorkspace?.name }}
|
|
|
|
|
</span>
|
|
|
|
|
<el-icon class="el-icon--right">
|
|
|
|
|
<CaretBottom />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</el-button>
|
|
|
|
|
<template #dropdown>
|
2025-07-07 11:10:55 +00:00
|
|
|
<div class="w-full p-8" style="box-sizing: border-box">
|
|
|
|
|
<el-input v-model="filterText" :placeholder="$t('common.search')" prefix-icon="Search" clearable />
|
|
|
|
|
</div>
|
2025-07-08 08:39:31 +00:00
|
|
|
<el-scrollbar max-height="300">
|
|
|
|
|
<el-dropdown-menu v-loading="loading">
|
|
|
|
|
<el-dropdown-item v-for="item in filterData" :key="item.id"
|
|
|
|
|
:class="`${item.id === currentWorkspace?.id ? 'active' : ''} flex-between`" @click="changeWorkspace(item)">
|
|
|
|
|
<div class="flex align-center">
|
|
|
|
|
<AppIcon class="mr-8" iconName="app-workspace" style="font-size: 16px"></AppIcon>
|
2025-07-10 09:09:19 +00:00
|
|
|
<span class="ellipsis" :title="item.name">
|
2025-07-08 08:39:31 +00:00
|
|
|
{{ item.name }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<el-icon v-show="item.id === currentWorkspace?.id" class="ml-8" style="font-size: 16px; margin-right: 0">
|
|
|
|
|
<Check />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
<div class="no-data color-info" v-if="!filterData.length"> {{ $t('common.noData') }} </div>
|
2025-06-13 09:38:37 +00:00
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-07-07 11:10:55 +00:00
|
|
|
import { watch, ref } from 'vue'
|
2025-06-13 09:38:37 +00:00
|
|
|
import type { WorkspaceItem } from '@/api/type/workspace'
|
2025-07-07 08:20:32 +00:00
|
|
|
import useStore from '@/stores'
|
2025-06-20 10:10:32 +00:00
|
|
|
const props = defineProps({
|
|
|
|
|
data: {
|
2025-07-01 08:21:46 +00:00
|
|
|
type: Array<any>,
|
2025-06-20 10:10:32 +00:00
|
|
|
default: () => [],
|
|
|
|
|
},
|
|
|
|
|
currentWorkspace: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => {},
|
|
|
|
|
},
|
2025-06-13 09:38:37 +00:00
|
|
|
})
|
2025-07-07 08:20:32 +00:00
|
|
|
|
|
|
|
|
const { folder } = useStore()
|
2025-06-20 10:10:32 +00:00
|
|
|
const loading = ref(false)
|
|
|
|
|
const emit = defineEmits(['changeWorkspace'])
|
2025-06-13 09:38:37 +00:00
|
|
|
function changeWorkspace(item: WorkspaceItem) {
|
2025-07-07 08:20:32 +00:00
|
|
|
folder.setCurrentFolder({})
|
2025-06-20 10:10:32 +00:00
|
|
|
emit('changeWorkspace', item)
|
2025-06-13 09:38:37 +00:00
|
|
|
}
|
2025-07-07 11:10:55 +00:00
|
|
|
|
|
|
|
|
const filterText = ref('')
|
|
|
|
|
const filterData = ref<any[]>([])
|
|
|
|
|
|
|
|
|
|
watch([() => props.data, () => filterText.value], () => {
|
|
|
|
|
if (!filterText.value.length) {
|
|
|
|
|
filterData.value = props.data
|
|
|
|
|
}
|
|
|
|
|
filterData.value = props.data.filter((v: any) =>
|
|
|
|
|
v.name.toLowerCase().includes(filterText.value.toLowerCase()),
|
|
|
|
|
)
|
|
|
|
|
}, { immediate: true })
|
2025-06-13 09:38:37 +00:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
2025-06-20 09:02:42 +00:00
|
|
|
.workspace-dropdown {
|
|
|
|
|
&__button {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding: 0 12px !important;
|
|
|
|
|
max-height: 32px;
|
|
|
|
|
}
|
2025-06-13 09:38:37 +00:00
|
|
|
}
|
2025-07-08 08:39:31 +00:00
|
|
|
|
|
|
|
|
.no-data {
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding-bottom: 16px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
2025-06-13 10:31:22 +00:00
|
|
|
</style>
|
2025-07-07 11:10:55 +00:00
|
|
|
<style lang="scss">
|
|
|
|
|
.workspace-dropdown-popper {
|
|
|
|
|
width: 280px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|