-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Table): TD和TH组件从body、header中抽离,解决一个文件定义多个组件的eslint报错 (#342)
* feat(Table): 使用Rem规范修改Table组件样式命名 * refactor(Table): TD和TH组件从body、header中抽离,解决一个文件定义多个组件的eslint报错
- Loading branch information
Showing
6 changed files
with
83 additions
and
90 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/devui-vue/devui/table/src/components/body-td/body-td.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { defineComponent, toRef } from 'vue'; | ||
import type { PropType } from 'vue'; | ||
import { Column } from '../column/column-types'; | ||
import { useFixedColumn } from '../../composable/use-table'; | ||
|
||
export default defineComponent({ | ||
name: 'DTableBodyTd', | ||
props: { | ||
column: { | ||
type: Object as PropType<Column>, | ||
default: () => ({}), | ||
}, | ||
row: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
index: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}, | ||
setup(props: { column: Column; row: any; index: number }) { | ||
const column = toRef(props, 'column'); | ||
|
||
// 固定列 | ||
const { stickyCell, offsetStyle } = useFixedColumn(column); | ||
|
||
return () => ( | ||
<td class={stickyCell.value} style={offsetStyle.value}> | ||
{column.value.renderCell?.(props.row, props.index)} | ||
</td> | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/devui-vue/devui/table/src/components/header-th/header-th.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { defineComponent, inject, toRefs } from 'vue'; | ||
import { PropType } from 'vue'; | ||
import { Column } from '../column/column-types'; | ||
import { TABLE_TOKEN } from '../../table-types'; | ||
import { Sort } from '../sort'; | ||
import { Filter } from '../filter'; | ||
import { useFixedColumn } from '../../composable/use-table'; | ||
import { useSort, useFilter } from './use-header-th'; | ||
|
||
export default defineComponent({ | ||
name: 'DTableHeaderTh', | ||
props: { | ||
column: { | ||
type: Object as PropType<Column>, | ||
required: true, | ||
}, | ||
}, | ||
setup(props: { column: Column }) { | ||
const table = inject(TABLE_TOKEN); | ||
const { column } = toRefs(props); | ||
const directionRef = useSort(table.store, column); | ||
const filteredRef = useFilter(table.store, column); | ||
const { stickyCell, offsetStyle } = useFixedColumn(column); | ||
|
||
return () => ( | ||
<th class={stickyCell.value} style={offsetStyle.value}> | ||
<div class="header-container"> | ||
{props.column.renderHeader?.()} | ||
{props.column.filterable && ( | ||
<Filter v-model={filteredRef.value} filterList={props.column.filterList} customTemplate={props.column.customFilterTemplate} /> | ||
)} | ||
</div> | ||
{props.column.sortable && <Sort v-model={directionRef.value} />} | ||
</th> | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters