-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: 1. added search for table. 2.limiting scale range
Signed-off-by: Arvin Huang <[email protected]>
- Loading branch information
Showing
10 changed files
with
215 additions
and
111 deletions.
There are no files selected for viewing
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
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
213 changes: 112 additions & 101 deletions
213
resources-front-end/packages/fate-ui-component/lib/components/Table/columns/index.vue
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 |
---|---|---|
@@ -1,101 +1,112 @@ | ||
<template> | ||
<FBTable></FBTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ElTable } from 'element-plus'; | ||
import { isFunction } from 'lodash'; | ||
import { h, watch } from 'vue'; | ||
import { classExplain } from '../cellExplain'; | ||
import { columnExplain } from './explain'; | ||
const props = defineProps([ | ||
'data', | ||
'header', | ||
'rowClassName', | ||
'cellClassName', | ||
'index', | ||
'currentPage', | ||
'pageSize', | ||
'column', | ||
'maxHeight', | ||
'range' | ||
]); | ||
const emits = defineEmits(['sortChange']); | ||
function rowClassName(scope: any) { | ||
const extRow = props.rowClassName | ||
? isFunction(props.rowClassName) | ||
? props.rowClassName(scope) | ||
: props.rowClassName | ||
: []; | ||
return [...classExplain({ row: scope.row }), ...[extRow].flat(Infinity)].join( | ||
' ' | ||
); | ||
} | ||
function cellClassName(scope: any) { | ||
const extCell = props.cellClassName | ||
? isFunction(props.cellClassName) | ||
? props.cellClassName(scope) | ||
: props.cellClassName | ||
: []; | ||
return [...classExplain(scope), ...[extCell].flat(Infinity)].join(' '); | ||
} | ||
function sortChange({ column, order }: any) { | ||
emits('sortChange', { col: column.property, order }); | ||
} | ||
function initing () { | ||
const columns: any[] = []; | ||
let headers: any[] = [...(props.header || [])]; | ||
if (props.index && headers.length > 0) { | ||
headers.unshift({ type: 'index', label: 'index', width: 80 }); | ||
} | ||
const colExplain = (headers: any[]) => { | ||
const columns: any[] = []; | ||
for (const header of headers) { | ||
const col = h( | ||
<any>columnExplain(header), | ||
Object.assign({}, header, { | ||
currentPage: props.currentPage, | ||
pageSize: props.pageSize, | ||
column: props.column, | ||
range: props.range | ||
}) | ||
); | ||
columns.push(col); | ||
} | ||
return columns; | ||
}; | ||
columns.push(...colExplain(headers)); | ||
return h( | ||
ElTable, | ||
{ | ||
data: props.data, | ||
fit: true, | ||
stripe: true, | ||
maxHeight: props.maxHeight, | ||
highlightCurrentRow: true, | ||
emptyText: 'NO DATA', | ||
cellClassName, | ||
rowClassName, | ||
onSortChange: sortChange, | ||
}, | ||
columns | ||
); | ||
} | ||
let FBTable = initing() | ||
watch( | ||
() => props.range, | ||
() => { | ||
console.log('normal col:', props.range) | ||
FBTable = initing() | ||
} | ||
) | ||
</script> | ||
<template> | ||
<FBTable ref="instance"></FBTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ElTable } from 'element-plus'; | ||
import { isFunction } from 'lodash'; | ||
import { h, ref, watch } from 'vue'; | ||
import { classExplain } from '../cellExplain'; | ||
import { columnExplain } from './explain'; | ||
const props = defineProps([ | ||
'data', | ||
'header', | ||
'rowClassName', | ||
'cellClassName', | ||
'index', | ||
'currentPage', | ||
'pageSize', | ||
'column', | ||
'maxHeight', | ||
'range' | ||
]); | ||
const emits = defineEmits(['sortChange']); | ||
// eslint-disable-next-line vue/no-dupe-keys | ||
function rowClassName(scope: any) { | ||
const extRow = props.rowClassName | ||
? isFunction(props.rowClassName) | ||
? props.rowClassName(scope) | ||
: props.rowClassName | ||
: []; | ||
return [...classExplain({ row: scope.row }), ...[extRow].flat(Infinity)].join( | ||
' ' | ||
); | ||
} | ||
// eslint-disable-next-line vue/no-dupe-keys | ||
function cellClassName(scope: any) { | ||
const extCell = props.cellClassName | ||
? isFunction(props.cellClassName) | ||
? props.cellClassName(scope) | ||
: props.cellClassName | ||
: []; | ||
return [...classExplain(scope), ...[extCell].flat(Infinity)].join(' '); | ||
} | ||
function sortChange({ column, order }: any) { | ||
emits('sortChange', { col: column.property, order }); | ||
} | ||
function rowSelection (row: object) { | ||
instance.value.setCurrentRow(row) | ||
} | ||
const instance = ref() | ||
function initing () { | ||
const columns: any[] = []; | ||
let headers: any[] = [...(props.header || [])]; | ||
if (props.index && headers.length > 0) { | ||
headers.unshift({ type: 'index', label: 'index', width: 80 }); | ||
} | ||
const colExplain = (headers: any[]) => { | ||
const columns: any[] = []; | ||
for (const header of headers) { | ||
const col = h( | ||
<any>columnExplain(header), | ||
Object.assign({}, header, { | ||
currentPage: props.currentPage, | ||
pageSize: props.pageSize, | ||
column: props.column, | ||
range: props.range | ||
}) | ||
); | ||
columns.push(col); | ||
} | ||
return columns; | ||
}; | ||
columns.push(...colExplain(headers)); | ||
return h( | ||
ElTable, | ||
{ | ||
data: props.data, | ||
fit: true, | ||
stripe: true, | ||
maxHeight: props.maxHeight, | ||
highlightCurrentRow: true, | ||
emptyText: 'NO DATA', | ||
cellClassName, | ||
rowClassName, | ||
onSortChange: sortChange, | ||
}, | ||
columns | ||
); | ||
} | ||
let FBTable = initing() | ||
watch( | ||
() => props.range, | ||
() => { | ||
console.log('normal col:', props.range) | ||
FBTable = initing() | ||
} | ||
) | ||
defineExpose({ | ||
rowSelection | ||
}) | ||
</script> |
24 changes: 24 additions & 0 deletions
24
...urces-front-end/packages/fate-ui-component/lib/components/Table/component/SearchInput.vue
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,24 @@ | ||
<template> | ||
<ElInput v-model="content" placeholder="Search Input" @keydown.enter.stop="searching"> | ||
<template #append> | ||
<ElButton :icon="Search" @click="searching"/> | ||
</template> | ||
</ElInput> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { Search } from '@element-plus/icons-vue'; | ||
import { ElButton, ElInput } from 'element-plus'; | ||
import { ref } from 'vue'; | ||
const emits = defineEmits(['change']) | ||
const content = ref('') | ||
const searching = () => { | ||
emits('change', content.value) | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> |
Oops, something went wrong.