Skip to content

Commit

Permalink
fix: sort and types and columns props
Browse files Browse the repository at this point in the history
  • Loading branch information
notbucai committed Nov 23, 2021
1 parent 4ad6ea9 commit 4c4be8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/components/table-data-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineComponent({
},
setup (props) {
const filterMethod = (value: any, row: any, column: any) => {
// todo: 释放到 loadMethod,交给开发者处理
const property = column['property']
return row[property] === value
}
Expand All @@ -39,6 +40,9 @@ export default defineComponent({
formatter={column.formatter}
sortable={column.sortable}
filters={column.filters}
align={column.align}
headerAlign={column.headerAlign}
showOverflowTooltip={column.showOverflowTooltip}
filter-method={column.filterMethod || (column.filters ? filterMethod : undefined)}
// slots
v-slots={{
Expand Down
5 changes: 3 additions & 2 deletions src/components/table-data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default {
const loading = ref(false)
const tableRef = ref(null)
const sortData = ref({})
// todo: 分页props传递
const pagination = reactive({
currentPage: 1,
pageSize: 20,
Expand Down Expand Up @@ -221,7 +221,8 @@ export default {
private_handleSortChange ({ column, prop, order }) {
const sort: { [key: string]: any; } = {}
if (prop) {
sort.prop = order
sort.order = order
sort.prop = prop
}
sortData.value = sort
emit('sort-change', { column, prop, order })
Expand Down
7 changes: 5 additions & 2 deletions src/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
* @Author: bucai<[email protected]>
* @Date: 2021-08-20 09:43:59
* @LastEditors: bucai<[email protected]>
* @LastEditTime: 2021-08-27 09:38:28
* @LastEditTime: 2021-11-23 16:17:42
* @Description: 1
*/
export type objAny = { [key: string]: any; };
export interface ColumnType {
prop?: string
label?: string
width?: string | number
fixed?: boolean
fixed?: boolean | 'left' | 'right'
showOverflowTooltip?: boolean
type?: string
filters?: objAny
align?: 'left' | 'right' | 'center'
headerAlign?: 'left' | 'right' | 'center'
index?: (index?: number) => any
filterMethod?: (value?: any, row?: any, column?: any) => boolean
sortable?: string | boolean
Expand Down

0 comments on commit 4c4be8e

Please sign in to comment.