2025-05-06 22:32:09 +08:00
|
|
|
|
<!-- add by puhui999:vxe table 工具栏二次封装,提供给 vxe 原生列表使用 -->
|
2025-04-27 18:13:08 +08:00
|
|
|
|
<script setup lang="ts">
|
2025-05-09 13:09:24 +08:00
|
|
|
|
import type { VxeToolbarInstance } from '#/adapter/vxe-table';
|
2025-04-27 18:13:08 +08:00
|
|
|
|
|
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
import { useContentMaximize, useRefresh } from '@vben/hooks';
|
2025-06-17 20:22:24 +08:00
|
|
|
|
import { IconifyIcon } from '@vben/icons';
|
2025-04-27 18:13:08 +08:00
|
|
|
|
|
2025-05-09 15:47:36 +08:00
|
|
|
|
import { Button, Tooltip } from 'ant-design-vue';
|
2025-05-09 13:09:24 +08:00
|
|
|
|
|
|
|
|
|
|
import { VxeToolbar } from '#/adapter/vxe-table';
|
2025-04-27 18:13:08 +08:00
|
|
|
|
|
|
|
|
|
|
/** 列表工具栏封装 */
|
|
|
|
|
|
defineOptions({ name: 'TableToolbar' });
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
hiddenSearch: boolean;
|
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['update:hiddenSearch']);
|
|
|
|
|
|
|
|
|
|
|
|
const toolbarRef = ref<VxeToolbarInstance>();
|
2025-05-09 15:47:36 +08:00
|
|
|
|
const { toggleMaximizeAndTabbarHidden, contentIsMaximize } =
|
|
|
|
|
|
useContentMaximize();
|
2025-04-27 18:13:08 +08:00
|
|
|
|
const { refresh } = useRefresh();
|
|
|
|
|
|
|
|
|
|
|
|
/** 隐藏搜索栏 */
|
|
|
|
|
|
function onHiddenSearchBar() {
|
|
|
|
|
|
emits('update:hiddenSearch', !props.hiddenSearch);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
|
getToolbarRef: () => toolbarRef.value,
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<VxeToolbar ref="toolbarRef" custom>
|
|
|
|
|
|
<template #toolPrefix>
|
|
|
|
|
|
<slot></slot>
|
2025-05-09 15:47:36 +08:00
|
|
|
|
<Tooltip placement="bottom">
|
|
|
|
|
|
<template #title>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<div class="max-w-52">搜索</div>
|
2025-05-09 15:47:36 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<Button
|
2025-06-17 20:22:24 +08:00
|
|
|
|
class="ml-2 font-normal"
|
2025-05-09 15:47:36 +08:00
|
|
|
|
shape="circle"
|
|
|
|
|
|
@click="onHiddenSearchBar"
|
|
|
|
|
|
>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<IconifyIcon icon="lucide:search" :size="15" />
|
2025-05-09 15:47:36 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
<Tooltip placement="bottom">
|
|
|
|
|
|
<template #title>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<div class="max-w-52">刷新</div>
|
2025-05-09 15:47:36 +08:00
|
|
|
|
</template>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<Button class="ml-2 font-medium" shape="circle" @click="refresh">
|
|
|
|
|
|
<IconifyIcon icon="lucide:refresh-cw" :size="15" />
|
2025-05-09 15:47:36 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
<Tooltip placement="bottom">
|
|
|
|
|
|
<template #title>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<div class="max-w-52">
|
2025-05-09 15:47:36 +08:00
|
|
|
|
{{ contentIsMaximize ? '还原' : '全屏' }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<Button
|
2025-06-17 20:22:24 +08:00
|
|
|
|
class="ml-2 font-medium"
|
2025-05-09 15:47:36 +08:00
|
|
|
|
shape="circle"
|
|
|
|
|
|
@click="toggleMaximizeAndTabbarHidden"
|
|
|
|
|
|
>
|
2025-06-17 20:22:24 +08:00
|
|
|
|
<IconifyIcon
|
|
|
|
|
|
:icon="contentIsMaximize ? 'lucide:minimize' : 'lucide:maximize'"
|
|
|
|
|
|
:size="15"
|
|
|
|
|
|
/>
|
2025-05-09 15:47:36 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Tooltip>
|
2025-04-27 18:13:08 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</VxeToolbar>
|
|
|
|
|
|
</template>
|