|
@@ -1,6 +1,6 @@
|
|
|
<script lang="ts" setup generic="T">
|
|
<script lang="ts" setup generic="T">
|
|
|
import { type TableColumnCtx } from 'element-plus'
|
|
import { type TableColumnCtx } from 'element-plus'
|
|
|
-import { computed, inject, nextTick, ref, useAttrs, watch } from 'vue'
|
|
|
|
|
|
|
+import { computed, inject, nextTick, ref, useAttrs, useSlots, watch } from 'vue'
|
|
|
import { TableContextKey } from './token'
|
|
import { TableContextKey } from './token'
|
|
|
import ZmTableColumnSettingTree from './ZmTableColumnSettingTree.vue'
|
|
import ZmTableColumnSettingTree from './ZmTableColumnSettingTree.vue'
|
|
|
import type { ColumnAlign, ColumnSettingItem, SortChangePayload, SortOrder } from './token'
|
|
import type { ColumnAlign, ColumnSettingItem, SortChangePayload, SortOrder } from './token'
|
|
@@ -35,6 +35,7 @@ const emits = defineEmits<{
|
|
|
|
|
|
|
|
const props = defineProps<Props>()
|
|
const props = defineProps<Props>()
|
|
|
const attrs = useAttrs()
|
|
const attrs = useAttrs()
|
|
|
|
|
+const slots = useSlots()
|
|
|
|
|
|
|
|
const tableContext = inject(TableContextKey, {
|
|
const tableContext = inject(TableContextKey, {
|
|
|
data: ref([]),
|
|
data: ref([]),
|
|
@@ -52,6 +53,10 @@ const innerSortOrder = ref<SortOrder | null>(props.defaultSortOrder ?? null)
|
|
|
const filterVisible = ref(false)
|
|
const filterVisible = ref(false)
|
|
|
const settingVisible = ref(false)
|
|
const settingVisible = ref(false)
|
|
|
const hasHeaderAction = computed(() => props.action || props.zmSortable || props.zmFilterable)
|
|
const hasHeaderAction = computed(() => props.action || props.zmSortable || props.zmFilterable)
|
|
|
|
|
+const forwardedSlots = computed(() => {
|
|
|
|
|
+ const { header: _header, ...restSlots } = slots
|
|
|
|
|
+ return restSlots
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
const defaultOptions = ref<Partial<Props>>({
|
|
const defaultOptions = ref<Partial<Props>>({
|
|
|
align: 'center',
|
|
align: 'center',
|
|
@@ -236,8 +241,8 @@ watch(
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
|
<el-table-column ref="columnRef" v-bind="bindProps">
|
|
<el-table-column ref="columnRef" v-bind="bindProps">
|
|
|
- <template v-for="(_, name) in $slots" :key="name" #[name]="slotData">
|
|
|
|
|
- <slot v-if="name !== 'header'" :name="name" v-bind="slotData || {}"></slot>
|
|
|
|
|
|
|
+ <template v-for="(_, name) in forwardedSlots" :key="name" #[name]="slotData">
|
|
|
|
|
+ <slot :name="name" v-bind="slotData || {}"></slot>
|
|
|
</template>
|
|
</template>
|
|
|
<template #header="scope">
|
|
<template #header="scope">
|
|
|
<slot name="header" v-bind="scope">
|
|
<slot name="header" v-bind="scope">
|