wip: Table重构中

This commit is contained in:
kailong321200875 2023-06-28 17:37:04 +08:00
parent 6e002b4591
commit 0a273ff8c8
2 changed files with 44 additions and 16 deletions

View File

@ -22,7 +22,7 @@ export default defineComponent({
default: () => []
},
//
expand: propTypes.bool.def(false),
// expand: propTypes.bool.def(false),
//
pagination: {
type: Object as PropType<Pagination>,
@ -168,23 +168,23 @@ export default defineComponent({
) : undefined
}
const renderTableExpand = () => {
const { align, headerAlign, expand } = unref(getProps)
//
return expand ? (
<ElTableColumn type="expand" align={align} headerAlign={headerAlign}>
{{
// @ts-ignore
default: (data: TableSlotDefault) => getSlot(slots, 'expand', data)
}}
</ElTableColumn>
) : undefined
}
// const renderTableExpand = () => {
// const { align, headerAlign, expand } = unref(getProps)
// //
// return expand ? (
// <ElTableColumn type="expand" align={align} headerAlign={headerAlign}>
// {{
// // @ts-ignore
// default: (data: TableSlotDefault) => getSlot(slots, 'expand', data)
// }}
// </ElTableColumn>
// ) : undefined
// }
const renderTreeTableColumn = (columnsChildren: TableColumn[]) => {
const { align, headerAlign, showOverflowTooltip } = unref(getProps)
return columnsChildren.map((v) => {
const props = { ...v }
const props = { ...v } as any
if (props.children) delete props.children
return (
<ElTableColumn
@ -220,7 +220,7 @@ export default defineComponent({
headerAlign,
showOverflowTooltip
} = unref(getProps)
return [...[renderTableExpand()], ...[renderTableSelection()]].concat(
return [renderTableSelection()].concat(
(columnsChildren || columns).map((v) => {
//
if (v.type === 'index') {
@ -239,7 +239,7 @@ export default defineComponent({
></ElTableColumn>
)
} else {
const props = { ...v }
const props = { ...v } as any
if (props.children) delete props.children
return (
<ElTableColumn

View File

@ -2,6 +2,34 @@ export interface TableColumn {
field: string
label?: string
children?: TableColumn[]
slots?: {
defalut?: (...args: any[]) => JSX.Element | null
header?: (...args: any[]) => JSX.Element | null
}
index?: number | ((index: number) => number)
columnKey?: string
width?: string | number
minWidth?: string | number
fixed?: boolean | 'left' | 'right'
renderHeader?: (...args: any[]) => JSX.Element | null
sortable?: boolean | 'custom'
sortMethod?: (...args: any[]) => number
sortBy?: string | string[] | ((...args: any[]) => string | string[])
sortOrders?: (string | null)[]
resizable?: boolean
formatter?: (...args: any[]) => any
showOverflowTooltip?: boolean
align?: 'left' | 'center' | 'right'
headerAlign?: 'left' | 'center' | 'right'
className?: string
labelClassName?: string
selectable?: (...args: any[]) => boolean
reserveSelection?: boolean
filters?: Array<{ text: string; value: string }>
filterPlacement?: string
filterMultiple?: boolean
filterMethod?: (...args: any[]) => boolean
filteredValue?: string[]
[key: string]: any
}