@qin-ui/antdv-next-pro 1.1.15 → 1.2.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/AI-CONTEXT.md +35 -24
- package/LICENSE +9 -0
- package/README.md +61 -61
- package/api.json +42 -28
- package/es/antdv-next-pro.css +9 -9
- package/es/component-provider/{index-Daiw7IxY.js → index-Tesc9NuK.js} +2 -1
- package/es/component-provider/index-Tesc9NuK.js.map +1 -0
- package/es/component-provider/index.js +2 -1
- package/es/component-provider/index.js.map +1 -0
- package/es/components/component-provider/components/index.vue.d.ts +27 -0
- package/es/components/component-provider/components/index.vue.d.ts.map +1 -0
- package/es/components/component-provider/constants/index.d.ts +16 -0
- package/es/components/component-provider/constants/index.d.ts.map +1 -0
- package/es/components/component-provider/index.d.ts +4 -0
- package/es/components/component-provider/index.d.ts.map +1 -0
- package/es/components/component-provider/types/index.d.ts +26 -0
- package/es/components/component-provider/types/index.d.ts.map +1 -0
- package/es/components/form/components/BaseField/index.vue.d.ts +13 -0
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -0
- package/es/components/form/components/BaseField/utils/index.d.ts +3 -0
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +9 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts +23 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +31 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +1 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts +24 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ProForm/index.vue.d.ts +36 -0
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts +7 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
- package/es/components/form/components/index.d.ts +12 -0
- package/es/components/form/components/index.d.ts.map +1 -0
- package/es/components/form/constants/index.d.ts +81 -0
- package/es/components/form/constants/index.d.ts.map +1 -0
- package/es/components/form/hooks/index.d.ts +5 -0
- package/es/components/form/hooks/index.d.ts.map +1 -0
- package/es/components/form/hooks/useFields.d.ts +57 -0
- package/es/components/form/hooks/useFields.d.ts.map +1 -0
- package/es/components/form/hooks/useForm.d.ts +93 -0
- package/es/components/form/hooks/useForm.d.ts.map +1 -0
- package/es/components/form/hooks/useFormRef.d.ts +30 -0
- package/es/components/form/hooks/useFormRef.d.ts.map +1 -0
- package/es/components/form/index.d.ts +7 -0
- package/es/components/form/index.d.ts.map +1 -0
- package/es/components/form/types/index.d.ts +251 -0
- package/es/components/form/types/index.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts +9 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/ProTable.vue.d.ts +118 -0
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -0
- package/es/components/table/components/SearchForm.vue.d.ts +48 -0
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -0
- package/es/components/table/components/SizeControl.vue.d.ts +12 -0
- package/es/components/table/components/SizeControl.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/index.d.ts +5 -0
- package/es/components/table/components/index.d.ts.map +1 -0
- package/es/components/table/index.d.ts +8 -0
- package/es/components/table/index.d.ts.map +1 -0
- package/es/components/table/types/index.d.ts +48 -0
- package/es/components/table/types/index.d.ts.map +1 -0
- package/es/components/table/useTable.d.ts +111 -0
- package/es/components/table/useTable.d.ts.map +1 -0
- package/es/form/{index-7clzY8ZD.js → index-CcP5OaUd.js} +12 -6
- package/es/form/index-CcP5OaUd.js.map +1 -0
- package/es/form/index.js +4 -3
- package/es/form/index.js.map +1 -0
- package/es/index.d.ts +76 -1543
- package/es/index.d.ts.map +1 -0
- package/es/index.js +14 -23
- package/es/index.js.map +1 -0
- package/es/shared/core/index.d.ts +6 -0
- package/es/shared/core/index.d.ts.map +1 -0
- package/es/shared/ui/index.d.ts +9 -0
- package/es/shared/ui/index.d.ts.map +1 -0
- package/es/table/index.js +11 -9
- package/es/table/index.js.map +1 -0
- package/package.json +10 -11
- package/src/components/component-provider/components/index.vue +67 -0
- package/src/components/component-provider/constants/index.ts +177 -0
- package/src/components/component-provider/index.ts +6 -0
- package/src/components/component-provider/types/index.ts +59 -0
- package/src/components/form/components/BaseField/index.vue +181 -0
- package/src/components/form/components/BaseField/utils/index.ts +16 -0
- package/src/components/form/components/BaseFormItem/index.vue +158 -0
- package/src/components/form/components/ContainerFragment/index.vue +24 -0
- package/src/components/form/components/GroupedFieldAttrs/index.vue +119 -0
- package/src/components/form/components/PathProvider/index.vue +19 -0
- package/src/components/form/components/ProForm/index.vue +104 -0
- package/src/components/form/components/SlotComponent/index.vue +26 -0
- package/src/components/form/components/index.ts +15 -0
- package/src/components/form/constants/index.ts +140 -0
- package/src/components/form/hooks/index.ts +5 -0
- package/src/components/form/hooks/useFields.ts +67 -0
- package/src/components/form/hooks/useForm.ts +110 -0
- package/src/components/form/hooks/useFormRef.ts +35 -0
- package/src/components/form/index.ts +29 -0
- package/src/components/form/types/index.ts +317 -0
- package/src/components/table/components/ColumnControl.vue +142 -0
- package/src/components/table/components/DefaultSearchFormContainer.vue +22 -0
- package/src/components/table/components/DefaultTableContainer.vue +19 -0
- package/src/components/table/components/ProTable.vue +372 -0
- package/src/components/table/components/SearchForm.vue +296 -0
- package/src/components/table/components/SizeControl.vue +54 -0
- package/src/components/table/components/icons/ColumnHeightOutlined.vue +4 -0
- package/src/components/table/components/icons/DownOutlined.vue +4 -0
- package/src/components/table/components/icons/FilterOutlined.vue +4 -0
- package/src/components/table/components/index.ts +4 -0
- package/src/components/table/index.ts +14 -0
- package/src/components/table/types/index.ts +52 -0
- package/src/components/table/useTable.ts +129 -0
- package/src/index.ts +81 -0
- package/src/shared/core/index.ts +37 -0
- package/src/shared/ui/index.ts +55 -0
- package/es/core/index-ghYuQ3Sy.js +0 -360
- package/es/vendor/utils/lodash-es-p6jau26B.js +0 -1120
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FormItemProps,
|
|
3
|
+
GridProps,
|
|
4
|
+
GridItemProps,
|
|
5
|
+
FormInstance,
|
|
6
|
+
} from '../../../shared/ui';
|
|
7
|
+
import { FormItem } from '../../../shared/ui';
|
|
8
|
+
import type {
|
|
9
|
+
ComponentProps,
|
|
10
|
+
ComponentSlots,
|
|
11
|
+
} from 'vue-component-type-helpers';
|
|
12
|
+
import {
|
|
13
|
+
type CSSProperties,
|
|
14
|
+
type Component,
|
|
15
|
+
type Raw,
|
|
16
|
+
type MaybeRef,
|
|
17
|
+
type ComputedRef,
|
|
18
|
+
VNode,
|
|
19
|
+
VNodeProps,
|
|
20
|
+
} from 'vue';
|
|
21
|
+
import type { Data, Path } from '../../../shared/core';
|
|
22
|
+
import { ComponentName, GetComponentType } from '../constants';
|
|
23
|
+
|
|
24
|
+
export type { FormInstance };
|
|
25
|
+
|
|
26
|
+
export type PathProps = { path?: string } & Data;
|
|
27
|
+
|
|
28
|
+
export type VModelProps<T = any> = {
|
|
29
|
+
value?: T;
|
|
30
|
+
'onUpdate:value'?: (val: T) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ValueFormatter =
|
|
34
|
+
| { (val: any, oldVal: any): any }
|
|
35
|
+
| { get?: (val: any) => any; set?: (val: any, oldVal: any) => any };
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @description 自定义组件
|
|
39
|
+
* @example (p, ctx) => h('div', ctx.attrs)
|
|
40
|
+
*/
|
|
41
|
+
export type RenderComponentType = Component<VModelProps & PathProps>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @description 插槽组件类型
|
|
45
|
+
*/
|
|
46
|
+
export type SlotComponentType =
|
|
47
|
+
| Component<PathProps>
|
|
48
|
+
| VNode
|
|
49
|
+
| string
|
|
50
|
+
| number
|
|
51
|
+
| boolean
|
|
52
|
+
| null
|
|
53
|
+
| undefined
|
|
54
|
+
| ((...args: any[]) => SlotComponentType);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @description 容器组件类型
|
|
58
|
+
*/
|
|
59
|
+
export type ContainerComponent = Component<PathProps>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @description 插槽对象类型
|
|
63
|
+
*/
|
|
64
|
+
export type Slots = {
|
|
65
|
+
[name: string]: SlotComponentType;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type Option = { label: string; value: any; [x: string]: any };
|
|
69
|
+
export type Options = Array<Option>;
|
|
70
|
+
|
|
71
|
+
export type Grid = boolean | (GridProps & {});
|
|
72
|
+
|
|
73
|
+
type BaseCommon<D extends Data = Data> = {
|
|
74
|
+
/**
|
|
75
|
+
* @description 字段标识namePath, 同name
|
|
76
|
+
* @example 'name' | 'age' | 'sex' | ...
|
|
77
|
+
*/
|
|
78
|
+
path?: Path<D>;
|
|
79
|
+
/**
|
|
80
|
+
* @description 字段是否隐藏
|
|
81
|
+
*/
|
|
82
|
+
hidden?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* @description 字段是否禁用
|
|
85
|
+
*/
|
|
86
|
+
disabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* @description 字段中文名称,支持字符串或组件
|
|
89
|
+
* @example '姓名' | '年龄' | '性别' | () => h('span', '自定义标签')
|
|
90
|
+
*/
|
|
91
|
+
label?: SlotComponentType;
|
|
92
|
+
/**
|
|
93
|
+
* @description 字段插槽配置,可包含formItem插槽和component插槽
|
|
94
|
+
* @example
|
|
95
|
+
* ```js
|
|
96
|
+
* slots: {
|
|
97
|
+
* label: () => h('div', { style: { fontSize: '12px' } }, '年龄'),
|
|
98
|
+
* addonAfter: '岁',
|
|
99
|
+
* suffix: () => h('span', '元')
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
slots?: Partial<ComponentSlots<typeof FormItem>>;
|
|
104
|
+
/**
|
|
105
|
+
* @description 字段formItem样式属性
|
|
106
|
+
* @example { marginBottom: '8px', padding: '12px' }
|
|
107
|
+
*/
|
|
108
|
+
formItemStyle?: CSSProperties;
|
|
109
|
+
/**
|
|
110
|
+
* @description 字段formItem样式类名
|
|
111
|
+
* @example 'custom-form-item' | 'required-field'
|
|
112
|
+
*/
|
|
113
|
+
formItemClass?: string;
|
|
114
|
+
/**
|
|
115
|
+
* @description 字段formItem容器包裹组件
|
|
116
|
+
* @example (props, ctx) => h('div', { class: 'custom-container' }, ctx.slots.default?.())
|
|
117
|
+
*/
|
|
118
|
+
formItemContainer?: ContainerComponent;
|
|
119
|
+
/**
|
|
120
|
+
* @description 将属性附加到 FormItem 的 DOM 节点
|
|
121
|
+
* @example { 'data-form-item-test': 'test-value', 'aria-label': 'name' }
|
|
122
|
+
*/
|
|
123
|
+
formItemDataAttrs?: Record<string, string>;
|
|
124
|
+
/**
|
|
125
|
+
* @description 额外的自定义属性,不会被当作组件参数,仅用做给字段添加标识属性等功能
|
|
126
|
+
* @example { group: 'group-1' }
|
|
127
|
+
*/
|
|
128
|
+
extraProps?: Record<string, any>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type BaseWithFields<D extends Data = Data> = BaseCommon<D> & {
|
|
132
|
+
/**
|
|
133
|
+
* @description 嵌套子字段配置
|
|
134
|
+
* @example [{ key: 'firstName', label: '名' }, { key: 'lastName', label: '姓' }]
|
|
135
|
+
*/
|
|
136
|
+
fields: Fields<D>;
|
|
137
|
+
/**
|
|
138
|
+
* @description 网格布局属性,true表示使用默认网格布局,针对具有嵌套字段的字段
|
|
139
|
+
* @example boolean | { gutter: 24 }
|
|
140
|
+
*/
|
|
141
|
+
grid?: Grid;
|
|
142
|
+
component?: never;
|
|
143
|
+
/**
|
|
144
|
+
* @description 字段component样式属性
|
|
145
|
+
* @example { width: '100%', borderColor: '#d9d9d9' }
|
|
146
|
+
*/
|
|
147
|
+
componentStyle?: never;
|
|
148
|
+
/**
|
|
149
|
+
* @description 字段component样式类名
|
|
150
|
+
* @example 'custom-input' | 'error-input'
|
|
151
|
+
*/
|
|
152
|
+
componentClass?: never;
|
|
153
|
+
/**
|
|
154
|
+
* @description 字段component容器包裹组件
|
|
155
|
+
* @example (props, ctx) => h('div', { class: 'input-wrapper' }, ctx.slots.default?.())
|
|
156
|
+
*/
|
|
157
|
+
componentContainer?: never;
|
|
158
|
+
/**
|
|
159
|
+
* @description 将属性附加到表单组件的 DOM 节点
|
|
160
|
+
* @example { 'data-test': 'input-value', 'aria-label': 'name' }
|
|
161
|
+
*/
|
|
162
|
+
componentDataAttrs?: never;
|
|
163
|
+
/**
|
|
164
|
+
* @description 字段值处理函数,在onUpdateValue前执行,函数返回值将作为更新值,也可设置get和set函数,用于处理字段值
|
|
165
|
+
* @example (val) => val?.trim()
|
|
166
|
+
*/
|
|
167
|
+
valueFormatter?: never;
|
|
168
|
+
/**
|
|
169
|
+
* @description 组件v-model双向绑定更新属性名,默认'value'
|
|
170
|
+
*/
|
|
171
|
+
modelProp?: never;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
type BaseWithoutFields<D extends Data = Data> = BaseCommon<D> & {
|
|
175
|
+
fields?: undefined;
|
|
176
|
+
grid?: never;
|
|
177
|
+
/**
|
|
178
|
+
* @description 字段component样式属性
|
|
179
|
+
* @example { width: '100%', borderColor: '#d9d9d9' }
|
|
180
|
+
*/
|
|
181
|
+
componentStyle?: CSSProperties;
|
|
182
|
+
/**
|
|
183
|
+
* @description 字段component样式类名
|
|
184
|
+
* @example 'custom-input' | 'error-input'
|
|
185
|
+
*/
|
|
186
|
+
componentClass?: string;
|
|
187
|
+
/**
|
|
188
|
+
* @description 字段component容器包裹组件
|
|
189
|
+
* @example (props, ctx) => h('div', { class: 'input-wrapper' }, ctx.slots.default?.())
|
|
190
|
+
*/
|
|
191
|
+
componentContainer?: ContainerComponent;
|
|
192
|
+
/**
|
|
193
|
+
* @description 将属性附加到表单组件的 DOM 节点
|
|
194
|
+
* @example { 'data-test': 'input-value', 'aria-label': 'name' }
|
|
195
|
+
*/
|
|
196
|
+
componentDataAttrs?: Record<string, string>;
|
|
197
|
+
/**
|
|
198
|
+
* @description 字段值处理函数,在onUpdateValue前执行,函数返回值将作为更新值,也可设置get和set函数,用于处理字段值
|
|
199
|
+
* @example (val) => val?.trim()
|
|
200
|
+
*/
|
|
201
|
+
valueFormatter?: ValueFormatter;
|
|
202
|
+
/**
|
|
203
|
+
* @description 组件v-model双向绑定更新属性名,默认'value'
|
|
204
|
+
*/
|
|
205
|
+
modelProp?: string;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 字段配置的基础公共类型
|
|
210
|
+
* @description 定义了 ProForm 字段配置的**保留属性**(由 ProForm 自身消费,不会透传给底层组件):
|
|
211
|
+
* - path, label, component - 字段标识与渲染
|
|
212
|
+
* - hidden, disabled, rules - 字段状态与校验
|
|
213
|
+
* - span, slots, grid, fields - 布局与嵌套
|
|
214
|
+
* - modelProp, valueFormatter - 双向绑定与值转换
|
|
215
|
+
* - formItemStyle/Class/Container/DataAttrs - FormItem 容器样式
|
|
216
|
+
* - componentStyle/Class/Container/DataAttrs - 输入组件样式
|
|
217
|
+
* - extraProps - 自定义扩展属性
|
|
218
|
+
*
|
|
219
|
+
* **重要:所有未在此列出的属性将直接 v-bind 透传到底层 antdv-next 组件。**
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export type Base<D extends Data = Data> =
|
|
224
|
+
| BaseWithFields<D>
|
|
225
|
+
| BaseWithoutFields<D>;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 字段类型映射集合
|
|
229
|
+
* @description 将每个 component 字符串映射到其对应的 antdv-next 组件 Props 类型。
|
|
230
|
+
* 例如 `component: 'select'` 时,Field 获得 Select 组件的所有 Props(options, mode, showSearch 等)作为类型提示。
|
|
231
|
+
* `component: 'custom'` 支持通过渲染函数或直接传入 Vue 组件进行完全自定义渲染。
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
export type FieldTypeMap<D extends Data = Data> = {
|
|
236
|
+
[K in ComponentName]: K extends 'custom'
|
|
237
|
+
? WithCommon<{ slots?: Slots; [x: string]: any }, D> & {
|
|
238
|
+
component?: RenderComponentType | Raw<RenderComponentType>;
|
|
239
|
+
}
|
|
240
|
+
: WithComponent<GetComponentType<K>, D> & { component?: K };
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @description 不支持响应式的属性名
|
|
245
|
+
*/
|
|
246
|
+
type NotSupportedRefOrGetterProps =
|
|
247
|
+
| 'component'
|
|
248
|
+
| 'formItemContainer'
|
|
249
|
+
| 'componentContainer'
|
|
250
|
+
| 'valueFormatter'
|
|
251
|
+
| 'fields'
|
|
252
|
+
| 'slots'
|
|
253
|
+
| 'modelProp';
|
|
254
|
+
|
|
255
|
+
type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @description 为对象属性添加响应式支持的类型
|
|
259
|
+
* @template T - 原始类型
|
|
260
|
+
*/
|
|
261
|
+
export type WithRef<T> = {
|
|
262
|
+
[P in keyof T]: P extends NotSupportedRefOrGetterProps
|
|
263
|
+
? T[P]
|
|
264
|
+
: T[P] extends (...args: any[]) => any
|
|
265
|
+
? T[P]
|
|
266
|
+
: MaybeRefOrComputedRef<T[P]>;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
type WithCommonBase<T = unknown> = T &
|
|
270
|
+
Omit<FormItemProps, 'label'> &
|
|
271
|
+
GridItemProps;
|
|
272
|
+
|
|
273
|
+
type WithCommon<T, D extends Data = Data> = WithRef<
|
|
274
|
+
WithCommonBase<T> & BaseWithoutFields<D>
|
|
275
|
+
>;
|
|
276
|
+
|
|
277
|
+
type WithFields<D extends Data = Data> = WithRef<
|
|
278
|
+
WithCommonBase & BaseWithFields<D>
|
|
279
|
+
>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
|
|
283
|
+
* @template T - Vue 组件类型
|
|
284
|
+
* @template D - 数据对象类型
|
|
285
|
+
*/
|
|
286
|
+
type WithComponent<
|
|
287
|
+
T extends abstract new (...args: any) => any,
|
|
288
|
+
D extends Data = Data,
|
|
289
|
+
> = WithCommon<
|
|
290
|
+
{ slots?: Partial<ComponentSlots<T>> } & Partial<
|
|
291
|
+
Omit<ComponentProps<T>, keyof VNodeProps>
|
|
292
|
+
>,
|
|
293
|
+
D
|
|
294
|
+
>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @description 字段配置类型,包含所有字段属性和响应式支持
|
|
298
|
+
* @template D - 数据对象类型
|
|
299
|
+
|
|
300
|
+
* @public
|
|
301
|
+
*/
|
|
302
|
+
export type Field<
|
|
303
|
+
C extends ComponentName = ComponentName,
|
|
304
|
+
D extends Data = Data,
|
|
305
|
+
> =
|
|
306
|
+
| (FieldTypeMap<D>[C] & {
|
|
307
|
+
component?: C extends 'custom' ? FieldTypeMap<D>[C]['component'] : C;
|
|
308
|
+
})
|
|
309
|
+
| WithFields<D>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @description 字段数组类型
|
|
313
|
+
* @template D - 数据对象类型
|
|
314
|
+
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
export type Fields<D extends Data = Data> = Array<Field<ComponentName, D>>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Button, Dropdown, Checkbox } from '../../../shared/ui';
|
|
3
|
+
import { computed, h, ref, watch } from 'vue';
|
|
4
|
+
import type { Columns } from '../types';
|
|
5
|
+
import { type Table } from '../useTable';
|
|
6
|
+
import FilterOutlined from './icons/FilterOutlined.vue';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
columns: Columns;
|
|
10
|
+
table?: Table;
|
|
11
|
+
};
|
|
12
|
+
const { columns, table = undefined } = defineProps<Props>();
|
|
13
|
+
|
|
14
|
+
const open = ref(false);
|
|
15
|
+
|
|
16
|
+
const checkAll = ref(false);
|
|
17
|
+
const indeterminate = ref(false);
|
|
18
|
+
|
|
19
|
+
const checkedColumnsOptions = computed<
|
|
20
|
+
Array<{ label: string; value: string; checked: boolean }>
|
|
21
|
+
>(() =>
|
|
22
|
+
columns.flatMap(item =>
|
|
23
|
+
item.key && item.title
|
|
24
|
+
? {
|
|
25
|
+
label: item.title as string,
|
|
26
|
+
value: item.key,
|
|
27
|
+
checked: !item.hidden,
|
|
28
|
+
}
|
|
29
|
+
: []
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const checkedColumnKeys = computed({
|
|
34
|
+
get() {
|
|
35
|
+
return (
|
|
36
|
+
checkedColumnsOptions.value.flatMap(item =>
|
|
37
|
+
item.checked ? item.value : []
|
|
38
|
+
) || []
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
set(val) {
|
|
42
|
+
checkedColumnsOptions.value?.forEach(item => {
|
|
43
|
+
table?.setColumn?.(item.value, {
|
|
44
|
+
hidden: !val.includes(item.value),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const onCheckAllChange = (e: any) => {
|
|
51
|
+
checkedColumnKeys.value = e.target.checked
|
|
52
|
+
? checkedColumnsOptions.value.map(item => item.value)
|
|
53
|
+
: [];
|
|
54
|
+
indeterminate.value = false;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const checkColumnsMenuItemClick = (val: string) => {
|
|
58
|
+
if (checkedColumnKeys.value.includes(val)) {
|
|
59
|
+
checkedColumnKeys.value = checkedColumnKeys.value.filter(
|
|
60
|
+
item => item !== val
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
checkedColumnKeys.value = [...checkedColumnKeys.value, val];
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
watch(
|
|
68
|
+
checkedColumnKeys,
|
|
69
|
+
val => {
|
|
70
|
+
indeterminate.value =
|
|
71
|
+
!!val.length && val.length < checkedColumnsOptions.value.length;
|
|
72
|
+
checkAll.value =
|
|
73
|
+
val.length > 0 && val.length === checkedColumnsOptions.value.length;
|
|
74
|
+
},
|
|
75
|
+
{ immediate: true }
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const items = computed<any>(() => [
|
|
79
|
+
{
|
|
80
|
+
key: 'all',
|
|
81
|
+
label: h(
|
|
82
|
+
Checkbox,
|
|
83
|
+
{
|
|
84
|
+
style: { width: '100%' },
|
|
85
|
+
checked: checkAll.value,
|
|
86
|
+
indeterminate: indeterminate.value,
|
|
87
|
+
onChange: onCheckAllChange,
|
|
88
|
+
},
|
|
89
|
+
() => '全选'
|
|
90
|
+
),
|
|
91
|
+
},
|
|
92
|
+
{ type: 'divider' },
|
|
93
|
+
...checkedColumnsOptions.value.map(item => ({
|
|
94
|
+
key: item.value,
|
|
95
|
+
label: h(
|
|
96
|
+
Checkbox,
|
|
97
|
+
{
|
|
98
|
+
style: { width: '100%' },
|
|
99
|
+
checked: item.checked,
|
|
100
|
+
onChange: () => checkColumnsMenuItemClick(item.value),
|
|
101
|
+
},
|
|
102
|
+
() => item.label
|
|
103
|
+
),
|
|
104
|
+
})),
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
function handleOpenChange(
|
|
108
|
+
nextOpen: boolean,
|
|
109
|
+
info: { source: 'trigger' | 'menu' }
|
|
110
|
+
) {
|
|
111
|
+
if (info.source === 'trigger' || nextOpen) {
|
|
112
|
+
open.value = nextOpen;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<template>
|
|
118
|
+
<Dropdown
|
|
119
|
+
:open="open"
|
|
120
|
+
arrow
|
|
121
|
+
placement="bottomRight"
|
|
122
|
+
:menu="{ items }"
|
|
123
|
+
@open-change="handleOpenChange"
|
|
124
|
+
>
|
|
125
|
+
<Button type="text" class="pro-table_column-control_button">
|
|
126
|
+
<FilterOutlined />
|
|
127
|
+
</Button>
|
|
128
|
+
</Dropdown>
|
|
129
|
+
</template>
|
|
130
|
+
|
|
131
|
+
<style scoped lang="less">
|
|
132
|
+
.pro-table_column-control_button {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
padding-right: 12px;
|
|
136
|
+
padding-left: 12px;
|
|
137
|
+
|
|
138
|
+
:deep(svg) {
|
|
139
|
+
transform: scale(1.2, 1.4);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { theme } from '../../../shared/ui';
|
|
4
|
+
const { token } = theme.useToken();
|
|
5
|
+
const bgColor = computed(() => token.value?.colorBgContainer);
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div
|
|
10
|
+
class="pro-table_search-form-container"
|
|
11
|
+
:style="{ backgroundColor: bgColor }"
|
|
12
|
+
>
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<style scoped lang="less">
|
|
18
|
+
.pro-table_search-form-container {
|
|
19
|
+
margin-bottom: 24px;
|
|
20
|
+
padding: 24px;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { theme } from '../../../shared/ui';
|
|
4
|
+
const { token } = theme.useToken();
|
|
5
|
+
const bgColor = computed(() => token.value?.colorBgContainer);
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div class="pro-table_table-container" :style="{ backgroundColor: bgColor }">
|
|
10
|
+
<slot />
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<style scoped lang="less">
|
|
15
|
+
.pro-table_table-container {
|
|
16
|
+
flex: 1;
|
|
17
|
+
padding: 24px 24px 0;
|
|
18
|
+
}
|
|
19
|
+
</style>
|