feat(projects): feat(projects): TableColumnCheck title support VNode (#716)
This commit is contained in:
parent
be6080ba0f
commit
a1a5c74c74
@ -1,5 +1,5 @@
|
|||||||
import { computed, reactive, ref } from 'vue';
|
import { computed, reactive, ref } from 'vue';
|
||||||
import type { Ref } from 'vue';
|
import type { Ref, VNodeChild } from 'vue';
|
||||||
import { jsonClone } from '@sa/utils';
|
import { jsonClone } from '@sa/utils';
|
||||||
import useBoolean from './use-boolean';
|
import useBoolean from './use-boolean';
|
||||||
import useLoading from './use-loading';
|
import useLoading from './use-loading';
|
||||||
@ -8,9 +8,11 @@ export type MaybePromise<T> = T | Promise<T>;
|
|||||||
|
|
||||||
export type ApiFn = (args: any) => Promise<unknown>;
|
export type ApiFn = (args: any) => Promise<unknown>;
|
||||||
|
|
||||||
|
export type TableColumnCheckTitle = string | ((...args: any) => VNodeChild);
|
||||||
|
|
||||||
export type TableColumnCheck = {
|
export type TableColumnCheck = {
|
||||||
key: string;
|
key: string;
|
||||||
title: string;
|
title: TableColumnCheckTitle;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,10 @@ const columns = defineModel<NaiveUI.TableColumnCheck[]>('columns', {
|
|||||||
<div v-for="item in columns" :key="item.key" class="h-36px flex-y-center rd-4px hover:(bg-primary bg-opacity-20)">
|
<div v-for="item in columns" :key="item.key" class="h-36px flex-y-center rd-4px hover:(bg-primary bg-opacity-20)">
|
||||||
<icon-mdi-drag class="mr-8px h-full cursor-move text-icon" />
|
<icon-mdi-drag class="mr-8px h-full cursor-move text-icon" />
|
||||||
<NCheckbox v-model:checked="item.checked" class="none_draggable flex-1">
|
<NCheckbox v-model:checked="item.checked" class="none_draggable flex-1">
|
||||||
{{ item.title }}
|
<template v-if="typeof item.title === 'function'">
|
||||||
|
<component :is="item.title" />
|
||||||
|
</template>
|
||||||
|
<template v-else>{{ item.title }}</template>
|
||||||
</NCheckbox>
|
</NCheckbox>
|
||||||
</div>
|
</div>
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
|
@ -64,7 +64,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
if (isTableColumnHasKey(column)) {
|
if (isTableColumnHasKey(column)) {
|
||||||
checks.push({
|
checks.push({
|
||||||
key: column.key as string,
|
key: column.key as string,
|
||||||
title: column.title as string,
|
title: column.title!,
|
||||||
checked: true
|
checked: true
|
||||||
});
|
});
|
||||||
} else if (column.type === 'selection') {
|
} else if (column.type === 'selection') {
|
||||||
|
Loading…
Reference in New Issue
Block a user