|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
<!-- eslint-disable no-useless-call --> |
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
<script lang="ts" setup generic="T extends Recordable = Recordable"> |
|
|
|
|
import { computed, inject, ref, toRaw, unref, useAttrs, useSlots, watchEffect } from 'vue' |
|
|
|
|
import { Table } from 'ant-design-vue' |
|
|
|
|
import { omit } from 'lodash-es' |
|
|
|
|
import type { BasicTableProps, ColumnChangeParam, InnerHandlers, SizeType, TableActionType } from './types/table' |
|
|
|
|
import type { BasicTableProps, ColumnChangeParam, InnerHandlers, SizeType, SlotBodyCellProps, TableActionType } from './types/table' |
|
|
|
|
import HeaderCell from './components/HeaderCell.vue' |
|
|
|
|
import { usePagination } from './hooks/usePagination' |
|
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ import { useTableExpand } from './hooks/useTableExpand'
|
|
|
|
|
import { createTableContext } from './hooks/useTableContext' |
|
|
|
|
import { useTableFooter } from './hooks/useTableFooter' |
|
|
|
|
import { useTableForm } from './hooks/useTableForm' |
|
|
|
|
import { basicProps } from './props' |
|
|
|
|
import { defineTableProps } from './props' |
|
|
|
|
import { useDesign } from '@/hooks/web/useDesign' |
|
|
|
|
|
|
|
|
|
import { PageWrapperFixedHeightKey } from '@/enums/pageEnum' |
|
|
|
@ -30,7 +30,7 @@ import { warn } from '@/utils/log'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'BasicTable' }) |
|
|
|
|
|
|
|
|
|
const props = defineProps(basicProps) |
|
|
|
|
const props = defineProps(defineTableProps<T>()) |
|
|
|
|
|
|
|
|
|
const emit = defineEmits([ |
|
|
|
|
'fetch-success', |
|
|
|
@ -109,7 +109,7 @@ const {
|
|
|
|
|
reload, |
|
|
|
|
getAutoCreateKey, |
|
|
|
|
updateTableData, |
|
|
|
|
} = useDataSource( |
|
|
|
|
} = useDataSource<T>( |
|
|
|
|
getProps, |
|
|
|
|
{ |
|
|
|
|
tableData, |
|
|
|
@ -239,7 +239,7 @@ function setProps(props: Partial<BasicTableProps>) {
|
|
|
|
|
innerPropsRef.value = { ...unref(innerPropsRef), ...props } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const tableAction: TableActionType = { |
|
|
|
|
const tableAction: TableActionType<T> = { |
|
|
|
|
reload: async params => void reload(params), |
|
|
|
|
getSelectRows, |
|
|
|
|
setSelectedRows, |
|
|
|
@ -312,7 +312,8 @@ emit('register', tableAction, formActions)
|
|
|
|
|
@resize-column="setColumnWidth" |
|
|
|
|
> |
|
|
|
|
<template v-for="item in Object.keys($slots)" #[item]="data" :key="item"> |
|
|
|
|
<slot :name="item" v-bind="data || {}" /> |
|
|
|
|
<!-- eslint-disable-next-line vue/no-extra-parens --> |
|
|
|
|
<slot :name="item" v-bind="((data || {}) as SlotBodyCellProps<T>)" /> |
|
|
|
|
</template> |
|
|
|
|
<template #headerCell="{ column }"> |
|
|
|
|
<slot name="headerCell" v-bind="{ column }"> |
|
|
|
@ -321,7 +322,8 @@ emit('register', tableAction, formActions)
|
|
|
|
|
</template> |
|
|
|
|
<!-- 增加对antdv3.x兼容 --> |
|
|
|
|
<template #bodyCell="data"> |
|
|
|
|
<slot name="bodyCell" v-bind="data || {}" /> |
|
|
|
|
<!-- eslint-disable-next-line vue/no-extra-parens --> |
|
|
|
|
<slot name="bodyCell" v-bind="((data || {}) as SlotBodyCellProps<T>)" /> |
|
|
|
|
</template> |
|
|
|
|
<!-- <template #[`header-${column.dataIndex}`] v-for="(column, index) in columns" :key="index"> --> |
|
|
|
|
<!-- <HeaderCell :column="column" /> --> |
|
|
|
|