gi-component 0.0.2 → 0.0.4
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/dist/gi.css +1 -1
- package/dist/index.d.ts +749 -0
- package/dist/index.es.js +109 -99
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/packages/components/dialog/src/dialog.ts +1 -1
- package/packages/components/edit-table/src/edit-table.vue +193 -207
- package/packages/components/edit-table/src/type.ts +71 -69
- package/packages/components/table/src/TableColumn.vue +49 -49
- package/packages/components/table/src/table.vue +89 -85
- package/packages/components/table/src/type.ts +22 -22
- package/packages/hooks/useTable.ts +3 -0
- package/packages/utils/createSelectDialog.ts +5 -6
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-table-column v-bind="columnProps">
|
|
3
|
-
<!-- 处理render函数 -->
|
|
4
|
-
<template v-if="column.render" v-slot="scope">
|
|
5
|
-
<component :is="column.render(scope)" />
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<!-- 处理插槽内容 -->
|
|
9
|
-
<template v-else-if="column.slotName" #default="scope">
|
|
10
|
-
<slot :name="column.slotName" v-bind="scope" />
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<!-- 递归渲染子列 -->
|
|
14
|
-
<template v-if="column.children && column.children.length > 0">
|
|
15
|
-
<TableColumn
|
|
16
|
-
v-for="child in column.children"
|
|
17
|
-
:key="child.prop || child.label"
|
|
18
|
-
:column="child"
|
|
19
|
-
>
|
|
20
|
-
<!-- 将所有插槽传递给子组件 -->
|
|
21
|
-
<template
|
|
22
|
-
v-for="(_, slotName) in $slots"
|
|
23
|
-
:key="slotName"
|
|
24
|
-
#[slotName]="scope"
|
|
25
|
-
>
|
|
26
|
-
<slot :name="slotName" v-bind="scope" />
|
|
27
|
-
</template>
|
|
28
|
-
</TableColumn>
|
|
29
|
-
</template>
|
|
30
|
-
</el-table-column>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script lang="ts" setup>
|
|
34
|
-
import type { TableColumnItem } from './type';
|
|
35
|
-
import { computed } from 'vue';
|
|
36
|
-
import TableColumn from './TableColumn.vue';
|
|
37
|
-
|
|
38
|
-
const props = defineProps<{
|
|
39
|
-
column: TableColumnItem;
|
|
40
|
-
}>();
|
|
41
|
-
|
|
42
|
-
// 计算el-table-column需要的属性
|
|
43
|
-
const columnProps = computed(() => {
|
|
44
|
-
const { slotName, render, children, ...restProps } = props.column;
|
|
45
|
-
return restProps;
|
|
46
|
-
});
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<style scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-table-column v-bind="columnProps">
|
|
3
|
+
<!-- 处理render函数 -->
|
|
4
|
+
<template v-if="column.render" v-slot="scope">
|
|
5
|
+
<component :is="column.render(scope)" />
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<!-- 处理插槽内容 -->
|
|
9
|
+
<template v-else-if="column.slotName" #default="scope">
|
|
10
|
+
<slot :name="column.slotName" v-bind="scope" />
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<!-- 递归渲染子列 -->
|
|
14
|
+
<template v-if="column.children && column.children.length > 0">
|
|
15
|
+
<TableColumn
|
|
16
|
+
v-for="child in column.children"
|
|
17
|
+
:key="child.prop || child.label"
|
|
18
|
+
:column="child"
|
|
19
|
+
>
|
|
20
|
+
<!-- 将所有插槽传递给子组件 -->
|
|
21
|
+
<template
|
|
22
|
+
v-for="(_, slotName) in $slots"
|
|
23
|
+
:key="slotName"
|
|
24
|
+
#[slotName]="scope"
|
|
25
|
+
>
|
|
26
|
+
<slot :name="slotName" v-bind="scope" />
|
|
27
|
+
</template>
|
|
28
|
+
</TableColumn>
|
|
29
|
+
</template>
|
|
30
|
+
</el-table-column>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script lang="ts" setup>
|
|
34
|
+
import type { TableColumnItem } from './type';
|
|
35
|
+
import { computed } from 'vue';
|
|
36
|
+
import TableColumn from './TableColumn.vue';
|
|
37
|
+
|
|
38
|
+
const props = defineProps<{
|
|
39
|
+
column: TableColumnItem;
|
|
40
|
+
}>();
|
|
41
|
+
|
|
42
|
+
// 计算el-table-column需要的属性
|
|
43
|
+
const columnProps = computed(() => {
|
|
44
|
+
const { slotName, render, children, ...restProps } = props.column;
|
|
45
|
+
return restProps;
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style scoped></style>
|
|
@@ -1,85 +1,89 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<el-table v-bind="tableProps" :data="props.data as any[]">
|
|
4
|
-
<TableColumn
|
|
5
|
-
|
|
6
|
-
:key="
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
...props
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
:
|
|
79
|
-
flex:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="b('table')">
|
|
3
|
+
<el-table v-bind="tableProps" ref="tableRef" :data="props.data as any[]">
|
|
4
|
+
<TableColumn v-for="item in props.columns" :key="item.prop || item.label" :column="item">
|
|
5
|
+
<!-- 将所有插槽传递给子组件 -->
|
|
6
|
+
<template v-for="(_, slotName) in $slots" :key="slotName" #[slotName]="scope">
|
|
7
|
+
<slot :name="slotName" v-bind="scope" />
|
|
8
|
+
</template>
|
|
9
|
+
</TableColumn>
|
|
10
|
+
</el-table>
|
|
11
|
+
|
|
12
|
+
<el-row justify="end" :class="b('table-pagination')">
|
|
13
|
+
<el-pagination v-bind="paginationProps" v-model:current-page="paginationProps.currentPage"
|
|
14
|
+
v-model:page-size="paginationProps.pageSize" @size-change="handleSizeChange"
|
|
15
|
+
@current-change="handleCurrentChange" />
|
|
16
|
+
</el-row>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import type { TableProps } from './type';
|
|
22
|
+
import { computed, useAttrs, useTemplateRef } from 'vue';
|
|
23
|
+
import { useBemClass } from '../../../hooks';
|
|
24
|
+
import TableColumn from './TableColumn.vue';
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<TableProps>(), {
|
|
27
|
+
columns: () => [],
|
|
28
|
+
pagination: () => ({})
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const attrs = useAttrs();
|
|
32
|
+
const { b } = useBemClass();
|
|
33
|
+
const tableRef = useTemplateRef('tableRef');
|
|
34
|
+
|
|
35
|
+
const tableProps = computed(() => {
|
|
36
|
+
return {
|
|
37
|
+
...attrs,
|
|
38
|
+
...props,
|
|
39
|
+
columns: undefined,
|
|
40
|
+
pagination: undefined
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const paginationProps = computed(() => {
|
|
45
|
+
return {
|
|
46
|
+
background: true,
|
|
47
|
+
layout: 'prev, pager, next, sizes, total',
|
|
48
|
+
pageSizes: [10, 20, 50, 100],
|
|
49
|
+
...props.pagination
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function handleSizeChange(size: number) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
props.pagination.pageSize = size;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function handleCurrentChange(page: number) {
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
props.pagination.currentPage = page;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
defineExpose({
|
|
64
|
+
tableRef
|
|
65
|
+
})
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<style lang="scss" scoped>
|
|
69
|
+
@use '../../../styles/var.scss' as a;
|
|
70
|
+
|
|
71
|
+
:deep(.el-pagination__rightwrapper) {
|
|
72
|
+
flex: auto;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.#{a.$prefix}-table {
|
|
76
|
+
height: 100%;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
|
|
81
|
+
:deep(.el-table) {
|
|
82
|
+
flex: 1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.#{a.$prefix}-table-pagination {
|
|
87
|
+
margin-top: 10px;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TableProps as ElTableProps,
|
|
3
|
-
PaginationProps,
|
|
4
|
-
TableColumnCtx,
|
|
5
|
-
TableColumnInstance
|
|
6
|
-
} from 'element-plus';
|
|
7
|
-
import type { ExtractPropTypes, VNode } from 'vue';
|
|
8
|
-
|
|
9
|
-
export interface TableColumnItem
|
|
10
|
-
extends Omit<TableColumnInstance['$props'], never> {
|
|
11
|
-
slotName?: string;
|
|
12
|
-
children?: TableColumnItem[];
|
|
13
|
-
render?: (scope: TableColumnCtx<any>) => VNode | VNode[] | string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface TableProps
|
|
17
|
-
extends ExtractPropTypes<
|
|
18
|
-
ElTableProps<Record<string | number | symbol, any>>
|
|
19
|
-
> {
|
|
20
|
-
columns?: TableColumnItem[];
|
|
21
|
-
pagination?: Partial<PaginationProps>;
|
|
22
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
TableProps as ElTableProps,
|
|
3
|
+
PaginationProps,
|
|
4
|
+
TableColumnCtx,
|
|
5
|
+
TableColumnInstance
|
|
6
|
+
} from 'element-plus';
|
|
7
|
+
import type { ExtractPropTypes, VNode } from 'vue';
|
|
8
|
+
|
|
9
|
+
export interface TableColumnItem
|
|
10
|
+
extends Omit<TableColumnInstance['$props'], never> {
|
|
11
|
+
slotName?: string;
|
|
12
|
+
children?: TableColumnItem[];
|
|
13
|
+
render?: (scope: TableColumnCtx<any>) => VNode | VNode[] | string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TableProps
|
|
17
|
+
extends ExtractPropTypes<
|
|
18
|
+
ElTableProps<Record<string | number | symbol, any>>
|
|
19
|
+
> {
|
|
20
|
+
columns?: TableColumnItem[];
|
|
21
|
+
pagination?: Partial<PaginationProps>;
|
|
22
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
2
|
import { ElMessage } from 'element-plus';
|
|
3
3
|
import { h, ref } from 'vue';
|
|
4
|
-
import { Dialog } from '../index';
|
|
4
|
+
import { Dialog, type DialogOptions } from '../index';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
title: string;
|
|
6
|
+
interface CreateSelectDialogParams extends Omit<DialogOptions, 'content' | 'onOk' | 'onBeforeOk'> {
|
|
8
7
|
component: Component;
|
|
9
8
|
componentProps?: Record<string, any>;
|
|
10
9
|
tip?: string;
|
|
11
|
-
bodyClass?: string;
|
|
12
10
|
};
|
|
13
11
|
|
|
14
12
|
interface DefOption {
|
|
@@ -35,6 +33,8 @@ export const createSelectDialog = <T, Q extends DefOption = DefOption>(
|
|
|
35
33
|
const DialogTableRef = ref<any>();
|
|
36
34
|
|
|
37
35
|
Dialog.open({
|
|
36
|
+
bodyClass: 'gi-p0',
|
|
37
|
+
...{ ...params, component: undefined, componentProps: undefined, tip: undefined },
|
|
38
38
|
title: params.title || options.title,
|
|
39
39
|
content: () =>
|
|
40
40
|
h(params.component, {
|
|
@@ -43,8 +43,7 @@ export const createSelectDialog = <T, Q extends DefOption = DefOption>(
|
|
|
43
43
|
queryParams,
|
|
44
44
|
...params.componentProps
|
|
45
45
|
}),
|
|
46
|
-
style: { maxWidth: '
|
|
47
|
-
bodyClass: params.bodyClass,
|
|
46
|
+
style: { maxWidth: '1000px', ...params.style },
|
|
48
47
|
onBeforeOk: async () => {
|
|
49
48
|
if (!DialogTableRef.value.getSelectedData) {
|
|
50
49
|
ElMessage.error('组件必须暴露getSelectedData方法');
|