gi-component 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -39,12 +39,12 @@ const obj: Record<string, { btnProps: Partial<ButtonProps>, btnText: string }>
|
|
|
39
39
|
delete: { btnProps: { icon: Delete, type: 'danger' }, btnText: '删除' },
|
|
40
40
|
search: { btnProps: { icon: Search, type: 'primary' }, btnText: '搜索' },
|
|
41
41
|
reset: { btnProps: { type: undefined }, btnText: '重置' },
|
|
42
|
-
upload: { btnProps: { icon: Upload
|
|
42
|
+
upload: { btnProps: { icon: Upload }, btnText: '上传' },
|
|
43
43
|
download: {
|
|
44
|
-
btnProps: { icon: Download
|
|
44
|
+
btnProps: { icon: Download },
|
|
45
45
|
btnText: '下载'
|
|
46
46
|
},
|
|
47
|
-
print: { btnProps: { icon: Printer
|
|
47
|
+
print: { btnProps: { icon: Printer }, btnText: '打印' }
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const bindProps = computed(() => {
|
|
@@ -16,21 +16,28 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script lang="ts" setup>
|
|
20
|
-
import type { TableProps } from './type'
|
|
19
|
+
<script lang="ts" setup generic="T extends DefaultRow">
|
|
20
|
+
import type { DefaultRow, TableProps, TableSlotScope } from './type'
|
|
21
21
|
import { ElPagination, ElRow, ElTable } from 'element-plus'
|
|
22
22
|
import { computed, useAttrs, useTemplateRef } from 'vue'
|
|
23
23
|
import { useBemClass } from '../../../hooks'
|
|
24
24
|
import TableColumn from './TableColumn.vue'
|
|
25
25
|
|
|
26
|
-
const props = withDefaults(defineProps<TableProps
|
|
26
|
+
const props = withDefaults(defineProps<TableProps<T>>(), {
|
|
27
27
|
fit: true,
|
|
28
28
|
showHeader: true,
|
|
29
29
|
selectOnIndeterminate: true,
|
|
30
|
+
data: () => [],
|
|
30
31
|
columns: () => [],
|
|
31
32
|
pagination: () => ({})
|
|
32
33
|
})
|
|
33
34
|
|
|
35
|
+
defineSlots<{
|
|
36
|
+
append: () => void
|
|
37
|
+
empty: () => void
|
|
38
|
+
[propsName: string]: (props: TableSlotScope<T>) => void
|
|
39
|
+
}>()
|
|
40
|
+
|
|
34
41
|
const attrs = useAttrs()
|
|
35
42
|
const { b } = useBemClass()
|
|
36
43
|
const tableRef = useTemplateRef('tableRef')
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import type { TableProps as ElTableProps, PaginationProps, TableColumnInstance } from 'element-plus'
|
|
2
2
|
import type { ExtractPropTypes, VNode } from 'vue'
|
|
3
3
|
|
|
4
|
-
type DefaultRow = Record<PropertyKey, any>
|
|
5
|
-
|
|
4
|
+
export type DefaultRow = Record<PropertyKey, any>
|
|
5
|
+
|
|
6
|
+
export interface TableColumnItem<T extends DefaultRow = any> extends Omit<TableColumnInstance['$props'], never> {
|
|
6
7
|
slotName?: string
|
|
7
8
|
children?: TableColumnItem[]
|
|
8
|
-
render?: (scope:
|
|
9
|
+
render?: (scope: TableSlotScope<T>) => VNode | VNode[] | string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TableSlotScope<T extends DefaultRow = any> = {
|
|
13
|
+
$index: number
|
|
14
|
+
cellIndex: number
|
|
15
|
+
column: TableColumnInstance['$props']
|
|
16
|
+
row: T
|
|
17
|
+
expanded: boolean
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
export interface TableProps extends ExtractPropTypes<ElTableProps<Record<string | number | symbol, any>>> {
|
|
20
|
+
export interface TableProps<T extends DefaultRow = any> extends ExtractPropTypes<ElTableProps<Record<string | number | symbol, any>>> {
|
|
21
|
+
data?: T[]
|
|
12
22
|
columns?: TableColumnItem[]
|
|
13
23
|
pagination?: Partial<PaginationProps> | boolean
|
|
14
24
|
}
|