feat: add table toolbar comp

pull/99/head^2
xingyu4j 2025-05-09 16:16:57 +08:00
parent 7d4eec1ced
commit 684d564ea1
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1 @@
export { default as TableToolbar } from './table-toolbar.vue';

View File

@ -0,0 +1,60 @@
<!-- add by puhui999vxe table 工具栏二次封装提供给 vxe 原生列表使用 -->
<script setup lang="ts">
import type { VxeToolbarInstance } from 'vxe-table';
import { ref } from 'vue';
import { useContentMaximize, useRefresh } from '@vben/hooks';
import { Fullscreen, RefreshCw, Search } from '@vben/icons';
import { NButton } from 'naive-ui';
import { VxeToolbar } from 'vxe-table';
/** 列表工具栏封装 */
defineOptions({ name: 'TableToolbar' });
const props = defineProps<{
hiddenSearch: boolean;
}>();
const emits = defineEmits(['update:hiddenSearch']);
const toolbarRef = ref<VxeToolbarInstance>();
const { toggleMaximizeAndTabbarHidden } = useContentMaximize();
const { refresh } = useRefresh();
/** 隐藏搜索栏 */
function onHiddenSearchBar() {
emits('update:hiddenSearch', !props.hiddenSearch);
}
defineExpose({
getToolbarRef: () => toolbarRef.value,
});
</script>
<template>
<VxeToolbar ref="toolbarRef" custom>
<template #toolPrefix>
<slot></slot>
<!-- TODO @puhui999貌似 icon 没和 vxe 对上可以考虑用 /Users/yunai/Java/yudao-ui-admin-vben-v5/packages/icons/src/iconify -->
<NButton
class="ml-2 font-[8px]"
shape="circle"
@click="onHiddenSearchBar"
>
<Search :size="15" />
</NButton>
<NButton class="ml-2 font-[8px]" shape="circle" @click="refresh">
<RefreshCw :size="15" />
</NButton>
<NButton
class="ml-2 font-[8px]"
shape="circle"
@click="toggleMaximizeAndTabbarHidden"
>
<Fullscreen :size="15" />
</NButton>
</template>
</VxeToolbar>
</template>