@qin-ui/element-plus-pro 1.2.4 → 1.3.0
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/README.md +5 -5
- package/api.json +1 -25
- package/es/__tests__/BaseField.spec.d.ts +2 -0
- package/es/__tests__/BaseField.spec.d.ts.map +1 -0
- package/es/__tests__/BaseFormItem.spec.d.ts +2 -0
- package/es/__tests__/BaseFormItem.spec.d.ts.map +1 -0
- package/es/__tests__/ProForm.spec.d.ts +2 -0
- package/es/__tests__/ProForm.spec.d.ts.map +1 -0
- package/es/__tests__/ProTable.spec.d.ts +2 -0
- package/es/__tests__/ProTable.spec.d.ts.map +1 -0
- package/es/__tests__/SearchForm.spec.d.ts +2 -0
- package/es/__tests__/SearchForm.spec.d.ts.map +1 -0
- package/es/__tests__/controls.spec.d.ts +2 -0
- package/es/__tests__/controls.spec.d.ts.map +1 -0
- package/es/__tests__/helpers/fixtures.d.ts +15 -0
- package/es/__tests__/helpers/fixtures.d.ts.map +1 -0
- package/es/__tests__/helpers/mount.d.ts +38 -0
- package/es/__tests__/helpers/mount.d.ts.map +1 -0
- package/es/__tests__/hooks-locale.spec.d.ts +2 -0
- package/es/__tests__/hooks-locale.spec.d.ts.map +1 -0
- package/es/__tests__/index.spec.d.ts +2 -0
- package/es/__tests__/index.spec.d.ts.map +1 -0
- package/es/__tests__/integration.spec.d.ts +2 -0
- package/es/__tests__/integration.spec.d.ts.map +1 -0
- package/es/__tests__/setup.d.ts +14 -0
- package/es/__tests__/setup.d.ts.map +1 -0
- package/es/element-plus-pro.css +14 -14
- package/es/index.js +415 -274
- package/es/index.js.map +1 -1
- package/es/{components → src/components}/component-provider/components/index.vue.d.ts +5 -1
- package/es/src/components/component-provider/components/index.vue.d.ts.map +1 -0
- package/es/src/components/component-provider/constants/index.d.ts.map +1 -0
- package/es/src/components/component-provider/index.d.ts.map +1 -0
- package/es/{components → src/components}/component-provider/types/index.d.ts +9 -5
- package/es/src/components/component-provider/types/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/components/BaseField/index.vue.d.ts +4 -1
- package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/BaseField/utils/index.d.ts +5 -0
- package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/components/BaseFormItem/index.vue.d.ts +4 -2
- package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/ProForm/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/index.d.ts.map +1 -0
- package/es/src/components/form/constants/index.d.ts.map +1 -0
- package/es/src/components/form/hooks/index.d.ts.map +1 -0
- package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
- package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
- package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
- package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
- package/es/src/components/form/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/types/index.d.ts +26 -2
- package/es/src/components/form/types/index.d.ts.map +1 -0
- package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
- package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
- package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
- package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
- package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
- package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
- package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
- package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
- package/es/src/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/index.d.ts.map +1 -0
- package/es/src/components/table/index.d.ts.map +1 -0
- package/es/src/components/table/types/index.d.ts.map +1 -0
- package/es/src/components/table/useTable.d.ts.map +1 -0
- package/es/{index.d.ts → src/index.d.ts} +1 -1
- package/es/src/index.d.ts.map +1 -0
- package/es/src/locale/en-US.d.ts.map +1 -0
- package/es/src/locale/index.d.ts.map +1 -0
- package/es/src/locale/zh-CN.d.ts.map +1 -0
- package/es/src/locale/zh-TW.d.ts.map +1 -0
- package/es/src/shared/core/index.d.ts +6 -0
- package/es/src/shared/core/index.d.ts.map +1 -0
- package/es/{shared → src/shared}/ui/index.d.ts +2 -0
- package/es/src/shared/ui/index.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/components/component-provider/components/index.vue +37 -8
- package/src/components/component-provider/constants/index.ts +2 -2
- package/src/components/component-provider/types/index.ts +9 -5
- package/src/components/form/components/BaseField/index.vue +67 -35
- package/src/components/form/components/BaseField/utils/index.ts +6 -11
- package/src/components/form/components/BaseFormItem/index.vue +47 -41
- package/src/components/form/components/ProForm/index.vue +72 -18
- package/src/components/form/hooks/useGroupFieldAttrs.ts +8 -4
- package/src/components/form/types/index.ts +26 -2
- package/src/components/table/components/ColumnControl.vue +18 -24
- package/src/components/table/components/ProTable.vue +112 -57
- package/src/components/table/components/SearchForm.vue +85 -60
- package/src/components/table/components/SizeControl.vue +2 -2
- package/src/components/table/components/TableColumnRenderer.vue +12 -9
- package/src/components/table/useTable.ts +12 -7
- package/src/index.ts +1 -1
- package/src/locale/index.ts +6 -2
- package/src/shared/core/index.ts +4 -2
- package/src/shared/ui/index.ts +11 -5
- package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
- package/es/components/component-provider/constants/index.d.ts.map +0 -1
- package/es/components/component-provider/index.d.ts.map +0 -1
- package/es/components/component-provider/types/index.d.ts.map +0 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
- package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
- package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
- package/es/components/form/components/index.d.ts.map +0 -1
- package/es/components/form/constants/index.d.ts.map +0 -1
- package/es/components/form/hooks/index.d.ts.map +0 -1
- package/es/components/form/hooks/useFields.d.ts.map +0 -1
- package/es/components/form/hooks/useForm.d.ts.map +0 -1
- package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +0 -1
- package/es/components/form/index.d.ts.map +0 -1
- package/es/components/form/types/index.d.ts.map +0 -1
- package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
- package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/index.d.ts.map +0 -1
- package/es/components/table/index.d.ts.map +0 -1
- package/es/components/table/types/index.d.ts.map +0 -1
- package/es/components/table/useTable.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/locale/en-US.d.ts.map +0 -1
- package/es/locale/index.d.ts.map +0 -1
- package/es/locale/zh-CN.d.ts.map +0 -1
- package/es/locale/zh-TW.d.ts.map +0 -1
- package/es/shared/core/index.d.ts +0 -6
- package/es/shared/core/index.d.ts.map +0 -1
- package/es/shared/ui/index.d.ts.map +0 -1
- /package/es/{components → src/components}/component-provider/constants/index.d.ts +0 -0
- /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
- /package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +0 -0
- /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
- /package/es/{components → src/components}/form/components/SlotComponent/index.vue.d.ts +0 -0
- /package/es/{components → src/components}/form/components/index.d.ts +0 -0
- /package/es/{components → src/components}/form/constants/index.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useGroupFieldAttrs.d.ts +0 -0
- /package/es/{components → src/components}/form/index.d.ts +0 -0
- /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/ProTable.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/TableColumnRenderer.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/index.d.ts +0 -0
- /package/es/{components → src/components}/table/index.d.ts +0 -0
- /package/es/{components → src/components}/table/types/index.d.ts +0 -0
- /package/es/{components → src/components}/table/useTable.d.ts +0 -0
- /package/es/{locale → src/locale}/en-US.d.ts +0 -0
- /package/es/{locale → src/locale}/index.d.ts +0 -0
- /package/es/{locale → src/locale}/zh-CN.d.ts +0 -0
- /package/es/{locale → src/locale}/zh-TW.d.ts +0 -0
|
@@ -11,28 +11,27 @@ import type { Column, Columns, ColumnControlConfig } from '../types';
|
|
|
11
11
|
import { type Table } from '../useTable';
|
|
12
12
|
import FilterOutlined from './icons/FilterOutlined.vue';
|
|
13
13
|
import { useLocale } from '../../../locale';
|
|
14
|
+
import { normalizePathKey } from '../../../shared/core';
|
|
14
15
|
|
|
15
16
|
type Props = {
|
|
16
17
|
columns: Columns;
|
|
17
18
|
table?: Table;
|
|
18
19
|
columnControl?: ColumnControlConfig;
|
|
19
20
|
};
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = defineProps<Props>();
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
table: undefined,
|
|
23
|
+
columnControl: undefined,
|
|
24
|
+
});
|
|
25
25
|
|
|
26
26
|
const { t } = useLocale();
|
|
27
27
|
|
|
28
|
-
const open = ref(false);
|
|
29
28
|
const checkAll = ref(false);
|
|
30
29
|
const indeterminate = ref(false);
|
|
31
30
|
|
|
32
31
|
const getColumnKey = (column: Column, index: number) => {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
32
|
+
const rawKey = column.key ?? column.prop;
|
|
33
|
+
if (rawKey === undefined || rawKey === null) return `__col_${index}`;
|
|
34
|
+
return normalizePathKey(rawKey);
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
const checkedColumnsOptions = computed<
|
|
@@ -44,13 +43,13 @@ const checkedColumnsOptions = computed<
|
|
|
44
43
|
column: Column;
|
|
45
44
|
}>
|
|
46
45
|
>(() =>
|
|
47
|
-
columns
|
|
46
|
+
props.columns
|
|
48
47
|
.map((item, index) => {
|
|
49
48
|
const key = getColumnKey(item, index);
|
|
50
|
-
const excluded = columnControl?.excludedKeys?.some(
|
|
49
|
+
const excluded = props.columnControl?.excludedKeys?.some(
|
|
51
50
|
ek => String(ek) === key
|
|
52
51
|
);
|
|
53
|
-
const disabled = columnControl?.disabledKeys?.some(
|
|
52
|
+
const disabled = props.columnControl?.disabledKeys?.some(
|
|
54
53
|
dk => String(dk) === key
|
|
55
54
|
);
|
|
56
55
|
const label = String(
|
|
@@ -85,7 +84,7 @@ const checkedColumnKeys = computed({
|
|
|
85
84
|
set(val: string[]) {
|
|
86
85
|
checkedColumnsOptions.value.forEach(item => {
|
|
87
86
|
if (item.disabled) return;
|
|
88
|
-
table?.setColumn(item.value as any, {
|
|
87
|
+
props.table?.setColumn(item.value as any, {
|
|
89
88
|
hidden: !val.includes(item.value),
|
|
90
89
|
});
|
|
91
90
|
});
|
|
@@ -130,16 +129,16 @@ watch(
|
|
|
130
129
|
|
|
131
130
|
// 强制 disabledKeys 列始终展示
|
|
132
131
|
onMounted(() => {
|
|
133
|
-
columnControl?.disabledKeys?.forEach(key => {
|
|
134
|
-
table?.setColumn(String(key), { hidden: false });
|
|
132
|
+
props.columnControl?.disabledKeys?.forEach(key => {
|
|
133
|
+
props.table?.setColumn(String(key), { hidden: false });
|
|
135
134
|
});
|
|
136
135
|
});
|
|
137
136
|
|
|
138
137
|
watch(
|
|
139
|
-
() => columnControl?.disabledKeys,
|
|
138
|
+
() => props.columnControl?.disabledKeys,
|
|
140
139
|
keys => {
|
|
141
140
|
keys?.forEach(key => {
|
|
142
|
-
table?.setColumn(String(key), { hidden: false });
|
|
141
|
+
props.table?.setColumn(String(key), { hidden: false });
|
|
143
142
|
});
|
|
144
143
|
},
|
|
145
144
|
{ deep: true }
|
|
@@ -147,19 +146,14 @@ watch(
|
|
|
147
146
|
</script>
|
|
148
147
|
|
|
149
148
|
<template>
|
|
150
|
-
<Dropdown
|
|
151
|
-
trigger="click"
|
|
152
|
-
:hide-on-click="false"
|
|
153
|
-
:visible="open"
|
|
154
|
-
@visible-change="val => (open = val)"
|
|
155
|
-
>
|
|
149
|
+
<Dropdown trigger="click" :hide-on-click="false">
|
|
156
150
|
<Button text class="pro-table_column-control_button">
|
|
157
151
|
<FilterOutlined />
|
|
158
152
|
</Button>
|
|
159
153
|
<template #dropdown>
|
|
160
154
|
<DropdownMenu>
|
|
161
155
|
<DropdownItem
|
|
162
|
-
v-if="!columnControl?.disableCheckAll"
|
|
156
|
+
v-if="!props.columnControl?.disableCheckAll"
|
|
163
157
|
:disabled="true"
|
|
164
158
|
:divided="false"
|
|
165
159
|
>
|
|
@@ -40,12 +40,14 @@ import {
|
|
|
40
40
|
tableProps,
|
|
41
41
|
paginationProps,
|
|
42
42
|
} from '../../../shared/ui';
|
|
43
|
+
import { ElLoading } from 'element-plus';
|
|
43
44
|
import {
|
|
44
45
|
computed,
|
|
45
46
|
nextTick,
|
|
46
47
|
useAttrs,
|
|
47
48
|
onMounted,
|
|
48
49
|
inject,
|
|
50
|
+
toValue,
|
|
49
51
|
type Slot,
|
|
50
52
|
useSlots,
|
|
51
53
|
} from 'vue';
|
|
@@ -60,6 +62,8 @@ import {
|
|
|
60
62
|
camelizeProperties,
|
|
61
63
|
getObject,
|
|
62
64
|
pick,
|
|
65
|
+
isPromise,
|
|
66
|
+
isPlainObject,
|
|
63
67
|
Path,
|
|
64
68
|
} from '../../../shared/core';
|
|
65
69
|
import {
|
|
@@ -71,7 +75,13 @@ import {
|
|
|
71
75
|
import type { Columns, ColumnControlConfig } from '../types';
|
|
72
76
|
import TableColumnRenderer from './TableColumnRenderer.vue';
|
|
73
77
|
|
|
74
|
-
defineOptions({
|
|
78
|
+
defineOptions({
|
|
79
|
+
name: 'ProTable',
|
|
80
|
+
directives: {
|
|
81
|
+
loading: ElLoading.directive,
|
|
82
|
+
},
|
|
83
|
+
inheritAttrs: false,
|
|
84
|
+
});
|
|
75
85
|
|
|
76
86
|
type Control = {
|
|
77
87
|
sizeControl: boolean;
|
|
@@ -108,23 +118,24 @@ type Props = {
|
|
|
108
118
|
pagination?: false | Partial<PaginationProps>;
|
|
109
119
|
} & Omit<TableProps, 'data'>;
|
|
110
120
|
|
|
111
|
-
const {
|
|
112
|
-
table
|
|
113
|
-
search
|
|
114
|
-
addIndexColumn
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
columns
|
|
120
|
-
data
|
|
121
|
-
pagination
|
|
122
|
-
}
|
|
121
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
122
|
+
table: undefined,
|
|
123
|
+
search: undefined,
|
|
124
|
+
addIndexColumn: undefined,
|
|
125
|
+
immediateSearch: undefined,
|
|
126
|
+
control: undefined,
|
|
127
|
+
searchFormConfig: undefined,
|
|
128
|
+
tableContainer: undefined,
|
|
129
|
+
columns: undefined,
|
|
130
|
+
data: undefined,
|
|
131
|
+
pagination: undefined,
|
|
132
|
+
});
|
|
123
133
|
|
|
124
134
|
const { t } = useLocale();
|
|
125
135
|
|
|
126
136
|
const config = INJECT_CONFIG['pro-table'];
|
|
127
|
-
const
|
|
137
|
+
const injectPropsRaw = inject(config.injectionKey, config.default);
|
|
138
|
+
const injectProps = computed(() => toValue(injectPropsRaw) || {});
|
|
128
139
|
|
|
129
140
|
const tableProperties = Object.keys(tableProps());
|
|
130
141
|
const paginationProperties = Object.keys(paginationProps());
|
|
@@ -132,7 +143,7 @@ const paginationProperties = Object.keys(paginationProps());
|
|
|
132
143
|
const attrs = useAttrs() as Record<string, any>;
|
|
133
144
|
|
|
134
145
|
const injectTableAttrs = computed(() => {
|
|
135
|
-
return pick(injectProps, tableProperties) as Partial<TableProps>;
|
|
146
|
+
return pick(injectProps.value, tableProperties) as Partial<TableProps>;
|
|
136
147
|
});
|
|
137
148
|
|
|
138
149
|
const attrsTableProps = computed(() => {
|
|
@@ -142,30 +153,25 @@ const attrsTableProps = computed(() => {
|
|
|
142
153
|
) as Partial<TableProps>;
|
|
143
154
|
});
|
|
144
155
|
|
|
145
|
-
const {
|
|
146
|
-
columns: tableColumns,
|
|
147
|
-
data: tableData,
|
|
148
|
-
searchForm,
|
|
149
|
-
pageParam,
|
|
150
|
-
setPageParam,
|
|
151
|
-
} = table || {};
|
|
152
|
-
|
|
153
156
|
const size = defineModel<TableProps['size']>('size');
|
|
154
|
-
const loading = defineModel<boolean>('loading');
|
|
157
|
+
const loading = defineModel<boolean>('loading', { default: false });
|
|
155
158
|
|
|
156
159
|
// 核心搜索方法:设置 loading 状态,调用外部 search 函数
|
|
157
160
|
const _search = async () => {
|
|
158
|
-
|
|
161
|
+
const searchPromise = (props.search || attrs.onSearch)?.();
|
|
162
|
+
if (isPromise(searchPromise)) {
|
|
159
163
|
loading.value = true;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
try {
|
|
165
|
+
await searchPromise;
|
|
166
|
+
} finally {
|
|
167
|
+
loading.value = false;
|
|
168
|
+
}
|
|
163
169
|
}
|
|
164
170
|
};
|
|
165
171
|
|
|
166
172
|
// 重置:恢复查询参数到初始值,重新搜索
|
|
167
173
|
const reset = () => {
|
|
168
|
-
table?.resetQueryParams();
|
|
174
|
+
props.table?.resetQueryParams?.();
|
|
169
175
|
nextTick(() => {
|
|
170
176
|
_search();
|
|
171
177
|
});
|
|
@@ -196,37 +202,51 @@ const tableSlots = computed(() => {
|
|
|
196
202
|
const tableSlotNames = computed(() => Object.keys(tableSlots.value));
|
|
197
203
|
|
|
198
204
|
const searchPage1st = () => {
|
|
199
|
-
setPageParam?.({ current: 1 });
|
|
205
|
+
props.table?.setPageParam?.({ current: 1 });
|
|
200
206
|
_search();
|
|
201
207
|
};
|
|
202
208
|
|
|
203
209
|
const computedSearchFormConfig = computed(() => {
|
|
204
210
|
const container =
|
|
205
|
-
searchFormConfig?.container ??
|
|
206
|
-
injectProps.searchFormConfig?.container ??
|
|
211
|
+
props.searchFormConfig?.container ??
|
|
212
|
+
(injectProps.value.searchFormConfig as any)?.container ??
|
|
207
213
|
DefaultSearchFormContainer;
|
|
208
214
|
return {
|
|
209
|
-
...injectProps.searchFormConfig,
|
|
210
|
-
...getObject(searchFormConfig),
|
|
215
|
+
...injectProps.value.searchFormConfig,
|
|
216
|
+
...getObject(props.searchFormConfig),
|
|
211
217
|
container: container ? container : undefined,
|
|
212
218
|
};
|
|
213
219
|
});
|
|
214
220
|
|
|
215
221
|
const computedTableContainer = computed(() => {
|
|
216
222
|
const container =
|
|
217
|
-
|
|
223
|
+
props.tableContainer ??
|
|
224
|
+
injectProps.value.tableContainer ??
|
|
225
|
+
DefaultTableContainer;
|
|
218
226
|
return container ? container : undefined;
|
|
219
227
|
});
|
|
220
228
|
|
|
229
|
+
const getIndex = (i: number) => {
|
|
230
|
+
if (props.table?.pageParam && computedPagination.value !== false) {
|
|
231
|
+
const current = props.table.pageParam.current ?? 1;
|
|
232
|
+
const pageSize = props.table.pageParam.pageSize ?? 10;
|
|
233
|
+
return (current - 1) * pageSize + i + 1;
|
|
234
|
+
}
|
|
235
|
+
return i + 1;
|
|
236
|
+
};
|
|
237
|
+
|
|
221
238
|
const normalizedRawColumns = computed(() => {
|
|
222
|
-
const source = (columns ??
|
|
223
|
-
|
|
239
|
+
const source = (props.columns ??
|
|
240
|
+
toValue(props.table?.columns) ??
|
|
241
|
+
[]) as any[];
|
|
242
|
+
if (props.addIndexColumn ?? injectProps.value.addIndexColumn) {
|
|
224
243
|
return [
|
|
225
244
|
{
|
|
226
245
|
key: '_index',
|
|
227
246
|
type: 'index',
|
|
228
247
|
label: t('table.index'),
|
|
229
248
|
width: 80,
|
|
249
|
+
index: getIndex,
|
|
230
250
|
},
|
|
231
251
|
...source,
|
|
232
252
|
];
|
|
@@ -236,7 +256,13 @@ const normalizedRawColumns = computed(() => {
|
|
|
236
256
|
|
|
237
257
|
const computedDataSource = computed<any[]>(() => {
|
|
238
258
|
const attrsData = attrsTableProps.value.data as any[] | undefined;
|
|
239
|
-
return
|
|
259
|
+
return (
|
|
260
|
+
props.data ??
|
|
261
|
+
attrsData ??
|
|
262
|
+
toValue((props.table as any)?.dataSource) ??
|
|
263
|
+
toValue(props.table?.data) ??
|
|
264
|
+
[]
|
|
265
|
+
);
|
|
240
266
|
});
|
|
241
267
|
|
|
242
268
|
const computedTableProps = computed<TableProps>(() => {
|
|
@@ -248,40 +274,69 @@ const computedTableProps = computed<TableProps>(() => {
|
|
|
248
274
|
return merged;
|
|
249
275
|
});
|
|
250
276
|
|
|
277
|
+
// 分页优先级:tableAttrs 显式配置 > provider 全局配置 > 默认合成
|
|
251
278
|
const computedPagination = computed<false | Partial<PaginationProps>>(() => {
|
|
252
|
-
|
|
253
|
-
|
|
279
|
+
const attrsPagination = (attrsTableProps.value as any).pagination;
|
|
280
|
+
if (props.pagination === false || attrsPagination === false) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
const hasUserPagination =
|
|
284
|
+
isPlainObject(props.pagination) || isPlainObject(attrsPagination);
|
|
285
|
+
if (hasUserPagination) {
|
|
286
|
+
const pageConfig = (props.pagination ??
|
|
287
|
+
attrsPagination ??
|
|
288
|
+
{}) as Partial<PaginationProps>;
|
|
289
|
+
const globalPagination =
|
|
290
|
+
(injectProps.value.pagination as any) === false
|
|
291
|
+
? {}
|
|
292
|
+
: (injectProps.value.pagination as Partial<PaginationProps>) || {};
|
|
293
|
+
const pageParam = props.table?.pageParam;
|
|
294
|
+
return {
|
|
295
|
+
...globalPagination,
|
|
296
|
+
...pick(pageConfig as Record<string, any>, paginationProperties),
|
|
297
|
+
currentPage: pageParam?.current ?? (pageConfig as any).currentPage ?? 1,
|
|
298
|
+
pageSize: pageParam?.pageSize ?? (pageConfig as any).pageSize ?? 10,
|
|
299
|
+
total: pageParam?.total ?? (pageConfig as any).total ?? 0,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if ((injectProps.value.pagination as any) === false) return false;
|
|
304
|
+
|
|
305
|
+
const pageParam = props.table?.pageParam;
|
|
254
306
|
return {
|
|
255
|
-
...injectProps.pagination,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
total: (pageConfig as any).total ?? pageParam?.total ?? 0,
|
|
307
|
+
...(injectProps.value.pagination as Partial<PaginationProps>),
|
|
308
|
+
currentPage: pageParam?.current ?? 1,
|
|
309
|
+
pageSize: pageParam?.pageSize ?? 10,
|
|
310
|
+
total: pageParam?.total ?? 0,
|
|
260
311
|
};
|
|
261
312
|
});
|
|
262
313
|
|
|
263
314
|
const showPagination = computed(() => computedPagination.value !== false);
|
|
264
315
|
|
|
265
316
|
const onCurrentChange = (current: number) => {
|
|
266
|
-
setPageParam?.({ current });
|
|
317
|
+
props.table?.setPageParam?.({ current });
|
|
267
318
|
_search();
|
|
268
319
|
};
|
|
269
320
|
|
|
270
321
|
const onSizeChange = (pageSize: number) => {
|
|
271
|
-
setPageParam?.({ pageSize, current: 1 });
|
|
322
|
+
props.table?.setPageParam?.({ pageSize, current: 1 });
|
|
272
323
|
_search();
|
|
273
324
|
};
|
|
274
325
|
|
|
275
326
|
const onPaginationChange = (currentPage: number, pageSize: number) => {
|
|
327
|
+
// 透传 el-pagination change 回调
|
|
276
328
|
attrs.onChange?.(currentPage, pageSize);
|
|
277
329
|
};
|
|
278
330
|
|
|
279
331
|
const showSearch = computed(() => {
|
|
332
|
+
const searchFields = props.table?.searchForm?.fields;
|
|
333
|
+
const fieldList =
|
|
334
|
+
(Array.isArray(searchFields) ? searchFields : searchFields?.value) ?? [];
|
|
280
335
|
return !!(
|
|
281
336
|
searchFormSlot ||
|
|
282
|
-
(computedSearchFormConfig.value?.hidden !== true &&
|
|
283
|
-
searchForm &&
|
|
284
|
-
|
|
337
|
+
((computedSearchFormConfig.value as any)?.hidden !== true &&
|
|
338
|
+
props.table?.searchForm &&
|
|
339
|
+
fieldList.filter((item: any) => !item.hidden)?.length > 0)
|
|
285
340
|
);
|
|
286
341
|
});
|
|
287
342
|
|
|
@@ -289,13 +344,13 @@ const computedControl = computed<{
|
|
|
289
344
|
sizeControl: boolean;
|
|
290
345
|
columnControl: boolean | ColumnControlConfig<Path<RecordType>>;
|
|
291
346
|
}>(() => {
|
|
292
|
-
const mergedControl = control ?? injectProps.control;
|
|
347
|
+
const mergedControl = props.control ?? injectProps.value.control;
|
|
293
348
|
if (typeof mergedControl === 'boolean') {
|
|
294
349
|
return { sizeControl: mergedControl, columnControl: mergedControl };
|
|
295
350
|
}
|
|
296
351
|
const c = mergedControl as Control;
|
|
297
|
-
const sizeControl = c
|
|
298
|
-
const columnControl = c
|
|
352
|
+
const sizeControl = c?.sizeControl ?? false;
|
|
353
|
+
const columnControl = c?.columnControl ?? false;
|
|
299
354
|
return { sizeControl: !!sizeControl, columnControl };
|
|
300
355
|
});
|
|
301
356
|
|
|
@@ -313,7 +368,7 @@ const resolvedSize = computed(() => {
|
|
|
313
368
|
});
|
|
314
369
|
|
|
315
370
|
onMounted(() => {
|
|
316
|
-
if (immediateSearch ?? injectProps.immediateSearch) {
|
|
371
|
+
if (props.immediateSearch ?? injectProps.value.immediateSearch) {
|
|
317
372
|
_search();
|
|
318
373
|
}
|
|
319
374
|
});
|
|
@@ -327,8 +382,8 @@ onMounted(() => {
|
|
|
327
382
|
>
|
|
328
383
|
<slot name="search-form">
|
|
329
384
|
<SearchForm
|
|
330
|
-
v-if="searchForm"
|
|
331
|
-
:form="searchForm"
|
|
385
|
+
v-if="props.table?.searchForm"
|
|
386
|
+
:form="props.table.searchForm"
|
|
332
387
|
v-bind="computedSearchFormConfig"
|
|
333
388
|
@search="searchPage1st"
|
|
334
389
|
@reset="reset"
|
|
@@ -358,7 +413,7 @@ onMounted(() => {
|
|
|
358
413
|
:columns="
|
|
359
414
|
normalizedRawColumns.filter(item => item.key !== '_index')
|
|
360
415
|
"
|
|
361
|
-
:table="table"
|
|
416
|
+
:table="props.table"
|
|
362
417
|
:column-control="columnControlConfig"
|
|
363
418
|
/>
|
|
364
419
|
</div>
|