update fileTable插槽处理
This commit is contained in:
@@ -24,18 +24,11 @@
|
||||
/>
|
||||
</template>
|
||||
<!-- baseTable插槽 单独处理leftOptions-->
|
||||
<template v-for="(_, name) in $slots" #[name]="slotData">
|
||||
<template v-for="(_, name) in filteredSlots" #[name]="slotData" :key="name">
|
||||
<slot :name="name" v-bind="slotData"></slot>
|
||||
</template>
|
||||
|
||||
<!-- <template
|
||||
v-for="(_, name) in $slots?.filter?.((v: any) => v.name !== 'leftOptions') ?? []"
|
||||
#[name]="slotData"
|
||||
:key="name"
|
||||
>
|
||||
<slot :name="name" v-bind="slotData"></slot>
|
||||
</template> -->
|
||||
<!-- <template #leftOptions>
|
||||
<!-- 单独处理 leftOptions 插槽 -->
|
||||
<template #leftOptions>
|
||||
<div class="left-options-wrapper">
|
||||
<slot name="leftOptions"></slot>
|
||||
<el-button
|
||||
@@ -45,7 +38,7 @@
|
||||
>刷新</el-button
|
||||
>
|
||||
</div>
|
||||
</template> -->
|
||||
</template>
|
||||
</BaseTable>
|
||||
<FilePreview v-model="previewVisible" :fileId="previewFileId" />
|
||||
<!-- 重命名 -->
|
||||
@@ -80,7 +73,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { ref, computed, onMounted, onBeforeUnmount, useSlots } from 'vue';
|
||||
import BaseTable from '@/components/common/table/baseTable.vue';
|
||||
import FilePreview from '@/components/common/filePreview/index.vue';
|
||||
import { downloadFileById } from '@/utils/file';
|
||||
@@ -127,6 +120,19 @@ const fileTableRef = ref();
|
||||
const previewVisible = ref(false);
|
||||
const previewFileId = ref('');
|
||||
|
||||
const slots = useSlots();
|
||||
|
||||
// 计算过滤后的插槽(排除 leftOptions)
|
||||
const filteredSlots = computed(() => {
|
||||
const result: Record<string, any> = {};
|
||||
Object.keys(slots).forEach((name) => {
|
||||
if (name !== 'leftOptions') {
|
||||
result[name] = slots[name];
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
// #region ---------------------------操作栏---------------------------
|
||||
// 默认的操作栏, 如果有业务判断,就在业务组件内部写
|
||||
const { t } = useI18n();
|
||||
|
||||
Reference in New Issue
Block a user