@yidun/antd-super-table 0.0.6 → 0.0.8
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 +264 -159
- package/dist/example/formItems.d.ts +325 -0
- package/dist/example/main.d.ts +1 -0
- package/dist/example/tableColumns.d.ts +1116 -0
- package/dist/index.js +1996 -1784
- package/dist/{config.d.ts → src/config.d.ts} +0 -7
- package/dist/{index.d.ts → src/index.d.ts} +4 -0
- package/dist/src/typings.d.ts +358 -0
- package/dist/{utils → src/utils}/index.d.ts +8 -5
- package/dist/{utils → src/utils}/service.d.ts +1 -24
- package/dist/typings.ts +193 -80
- package/package.json +3 -2
- package/dist/typings.d.ts +0 -233
- /package/dist/{components → src/components}/VNodes.d.ts +0 -0
- /package/dist/{utils → src/utils}/dialogManager.d.ts +0 -0
- /package/dist/{utils → src/utils}/useDialog.d.ts +0 -0
|
@@ -28,10 +28,3 @@ export declare const SceneModalActionTypeEnum: {
|
|
|
28
28
|
};
|
|
29
29
|
/** 本地缓存需要保存的列配置字段 */
|
|
30
30
|
export declare const cacheColumnKeys: string[];
|
|
31
|
-
/** 场景管理接口地址 */
|
|
32
|
-
export declare const sceneApiUrls: {
|
|
33
|
-
query: string;
|
|
34
|
-
create: string;
|
|
35
|
-
update: string;
|
|
36
|
-
delete: string;
|
|
37
|
-
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type SuperTableComponent from './SuperTable.vue';
|
|
1
2
|
import SuperTable from './SuperTable.vue';
|
|
3
|
+
import DynamicList from './components/DynamicList.vue';
|
|
2
4
|
export default SuperTable;
|
|
5
|
+
export { DynamicList };
|
|
3
6
|
export { SuperTableColumnTypeEnum, SuperTableFormItemTypeEnum } from './config';
|
|
4
7
|
export * from './typings';
|
|
8
|
+
export type SuperTableInstance = InstanceType<typeof SuperTableComponent>;
|
|
5
9
|
declare module 'vue' {
|
|
6
10
|
interface GlobalComponents {
|
|
7
11
|
SuperTable: typeof SuperTable;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import type { SelectProps, TableProps, PaginationProps } from 'ant-design-vue';
|
|
2
|
+
import type { Component, Reactive, Ref } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* 表格列对应的类型枚举
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type SuperTableColumnType = 'text' | 'link' | 'button' | 'tag' | 'image' | 'component' | 'sort';
|
|
8
|
+
/**
|
|
9
|
+
* 查询表单项对应的类型枚举
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type SuperTableFormItemType = 'input' | 'inputGroup' | 'inputNumber' | 'inputNumberRange' | 'select' | 'treeSelect' | 'cascader' | 'datePicker' | 'rangePicker' | 'component';
|
|
13
|
+
/**
|
|
14
|
+
* 表格列吸附方式类型
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type SuperTableColumnFixedType = 'left' | 'right' | false;
|
|
18
|
+
/**
|
|
19
|
+
* 排序方式类型
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export type SuperTableSortOrders = 'ascend' | 'descend' | null;
|
|
23
|
+
/**
|
|
24
|
+
* 场景存储类型
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export type SuperTableSceneStorageType = 'local' | 'api';
|
|
28
|
+
/**
|
|
29
|
+
* 表格数据项类型
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export type SuperTableDataItem = Record<string, any>;
|
|
33
|
+
/**
|
|
34
|
+
* 查询条件配置接口
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export interface SuperTableFormItem {
|
|
38
|
+
/** 查询项类型 */
|
|
39
|
+
type: SuperTableFormItemType;
|
|
40
|
+
/** 查询项对应的字段名称 */
|
|
41
|
+
name: string;
|
|
42
|
+
/** 绑定数据时v-model对应的name,默认为value */
|
|
43
|
+
modelPropName?: string;
|
|
44
|
+
/** 查询项标签 */
|
|
45
|
+
label: string;
|
|
46
|
+
/** 传递给查询项的props */
|
|
47
|
+
props?: Record<string, any>;
|
|
48
|
+
/** 选项值 */
|
|
49
|
+
value?: any;
|
|
50
|
+
/** 自定义组件 */
|
|
51
|
+
component?: Component;
|
|
52
|
+
/** 查询项宽度系数 */
|
|
53
|
+
span?: number;
|
|
54
|
+
/** 是否显示 */
|
|
55
|
+
visible?: boolean;
|
|
56
|
+
/** 带select前缀的组合输入框配置 */
|
|
57
|
+
addonBeforeProps?: SelectProps;
|
|
58
|
+
/** 改变时保持静默,不要触发搜索 */
|
|
59
|
+
quiet?: boolean;
|
|
60
|
+
/** 是否展示label,默认展示 */
|
|
61
|
+
showLabel?: boolean;
|
|
62
|
+
/** 固定选项,不允许删除,高级搜索时一定会默认展示 */
|
|
63
|
+
fixed?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* 默认选中,开启后表现为:
|
|
66
|
+
* 1. 高级搜索弹窗打开时会默认选中对应的搜索项
|
|
67
|
+
* 2. 没有配置默认场景时,会根据选中的项目生成一个默认场景
|
|
68
|
+
*/
|
|
69
|
+
selected?: boolean;
|
|
70
|
+
/** @internal 以下为内置属性,不允许修改 */
|
|
71
|
+
/** 默认值 */
|
|
72
|
+
_defaultValue?: any;
|
|
73
|
+
/** 排序 */
|
|
74
|
+
_order?: number;
|
|
75
|
+
/** 是否选中 */
|
|
76
|
+
_selected?: boolean;
|
|
77
|
+
/** 在选中场景中的排序 */
|
|
78
|
+
_orderInScene?: number;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 表格列配置接口
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export interface SuperTableColumn {
|
|
86
|
+
/** 列对应的key */
|
|
87
|
+
key: string;
|
|
88
|
+
/** 展示类型:text-文本,button-按钮,link-链接,tag-标签,component-自定义组件 */
|
|
89
|
+
type?: SuperTableColumnType | ((row: SuperTableDataItem, index: number) => SuperTableColumnType);
|
|
90
|
+
/** 标题 */
|
|
91
|
+
title: string;
|
|
92
|
+
/** 标题对应的提示信息 */
|
|
93
|
+
titleTooltip?: string | ((row: SuperTableDataItem, index: number) => string);
|
|
94
|
+
/** 表格内容 */
|
|
95
|
+
content?: string | ((row: SuperTableDataItem, index: number) => any);
|
|
96
|
+
/** 表格内容对应的提示信息 */
|
|
97
|
+
tooltip?: string | boolean | ((row: SuperTableDataItem, index: number) => string);
|
|
98
|
+
/** 表格内容解析自定义组件 */
|
|
99
|
+
component?: Component;
|
|
100
|
+
/** 表格内容解析用到的组件对应的props */
|
|
101
|
+
props?: Record<string, any> | ((row: SuperTableDataItem, index: number) => Record<string, any>);
|
|
102
|
+
/** 是否可复制 */
|
|
103
|
+
copyable?: boolean;
|
|
104
|
+
/** 是否超出显示省略号 */
|
|
105
|
+
ellipsis?: boolean;
|
|
106
|
+
/** 是否可见 */
|
|
107
|
+
visible?: boolean;
|
|
108
|
+
/** 宽度 */
|
|
109
|
+
width?: number;
|
|
110
|
+
/** 固定列位置 */
|
|
111
|
+
fixed?: SuperTableColumnFixedType;
|
|
112
|
+
/** 排序 */
|
|
113
|
+
sorter?: boolean | ((a: SuperTableDataItem, b: SuperTableDataItem) => number);
|
|
114
|
+
/** 默认排序 */
|
|
115
|
+
defaultSortOrder?: SuperTableSortOrders;
|
|
116
|
+
/** 列索引 */
|
|
117
|
+
index?: number;
|
|
118
|
+
[key: string]: any;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 场景中保存的查询条件配置接口
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export interface SuperTableQuerySceneItem {
|
|
125
|
+
/** 字段名称 */
|
|
126
|
+
name: string;
|
|
127
|
+
/** 字段类型 */
|
|
128
|
+
type: SuperTableFormItemType;
|
|
129
|
+
/** 字段值 */
|
|
130
|
+
value: any;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 查询场景接口
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
export interface SuperTableQueryScene {
|
|
137
|
+
/** 场景唯一标识 */
|
|
138
|
+
code: string;
|
|
139
|
+
/** 场景名称 */
|
|
140
|
+
name: string;
|
|
141
|
+
/** 配置类型 */
|
|
142
|
+
type?: string;
|
|
143
|
+
/** 配置详情 */
|
|
144
|
+
value?: string;
|
|
145
|
+
/** 查询项列表 */
|
|
146
|
+
items: SuperTableQuerySceneItem[];
|
|
147
|
+
/** 是否是私有配置 */
|
|
148
|
+
asPrivate?: boolean;
|
|
149
|
+
/** 是否是自定义场景 */
|
|
150
|
+
isCustom?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 默认场景配置接口
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export interface SuperTableDefaultSceneConfig {
|
|
157
|
+
/** 场景名称 */
|
|
158
|
+
name?: string;
|
|
159
|
+
/** 场景唯一标识,多个自定义场景时必填 */
|
|
160
|
+
code?: string;
|
|
161
|
+
/** 查询项列表 */
|
|
162
|
+
items: {
|
|
163
|
+
/** 字段名称 */
|
|
164
|
+
name: string;
|
|
165
|
+
/** 字段值 */
|
|
166
|
+
value: any;
|
|
167
|
+
}[];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 场景状态接口
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
export interface SuperTableSceneState {
|
|
174
|
+
/** 查询场景列表 */
|
|
175
|
+
list: SuperTableQueryScene[];
|
|
176
|
+
/** 是否正在加载场景 */
|
|
177
|
+
loading: boolean;
|
|
178
|
+
/** 是否正在保存场景 */
|
|
179
|
+
submiting: boolean;
|
|
180
|
+
/** 是否已经加载过场景 */
|
|
181
|
+
loaded: boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 提供给弹窗使用的表格全局状态接口
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
export interface SuperTableContext {
|
|
188
|
+
/** 场景类型 */
|
|
189
|
+
sceneType: string;
|
|
190
|
+
/** 场景状态 */
|
|
191
|
+
sceneState: Reactive<SuperTableSceneState>;
|
|
192
|
+
/** 查询场景 */
|
|
193
|
+
queryScene(): void;
|
|
194
|
+
/** 新增/更新场景 */
|
|
195
|
+
updateScene(scene: SuperTableQueryScene | SuperTableQueryScene[]): void;
|
|
196
|
+
/** 删除场景 */
|
|
197
|
+
deleteScene(sceneCode: string): void;
|
|
198
|
+
/** 当前生效中的查询参数 */
|
|
199
|
+
selectedFormItems: SuperTableQuerySceneItem[];
|
|
200
|
+
/** 禁用添加场景功能 */
|
|
201
|
+
allowCreateScene: Ref<boolean>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 场景请求配置接口
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export interface SuperTableSceneRequestConfig {
|
|
208
|
+
/** 查询场景列表 */
|
|
209
|
+
querySceneList: (params: {
|
|
210
|
+
type: string;
|
|
211
|
+
}) => Promise<{
|
|
212
|
+
code: number;
|
|
213
|
+
data: SuperTableQueryScene[];
|
|
214
|
+
msg: string;
|
|
215
|
+
}>;
|
|
216
|
+
/** 创建场景 */
|
|
217
|
+
createScene: (params: {
|
|
218
|
+
type: string;
|
|
219
|
+
name: string;
|
|
220
|
+
value: string;
|
|
221
|
+
asPrivate?: boolean;
|
|
222
|
+
}) => Promise<{
|
|
223
|
+
code: number;
|
|
224
|
+
data: string;
|
|
225
|
+
msg: string;
|
|
226
|
+
}>;
|
|
227
|
+
/** 更新场景 */
|
|
228
|
+
updateScene: (params: {
|
|
229
|
+
code: string;
|
|
230
|
+
name: string;
|
|
231
|
+
value: string;
|
|
232
|
+
}) => Promise<{
|
|
233
|
+
code: number;
|
|
234
|
+
msg: string;
|
|
235
|
+
}>;
|
|
236
|
+
/** 删除场景 */
|
|
237
|
+
deleteScene: (params: string[]) => Promise<{
|
|
238
|
+
code: number;
|
|
239
|
+
msg: string;
|
|
240
|
+
}>;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 数据请求方法类型
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
export type SuperTableRequestFunction = (options: {
|
|
247
|
+
/** 查询参数 */
|
|
248
|
+
params: Record<string, any>;
|
|
249
|
+
/** 分页大小 */
|
|
250
|
+
pageSize?: number;
|
|
251
|
+
/** 当前页码 */
|
|
252
|
+
pageNum?: number;
|
|
253
|
+
[key: string]: any;
|
|
254
|
+
}) => Promise<{
|
|
255
|
+
total: number;
|
|
256
|
+
data: Record<string, any>[];
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Antd表格属性扩展接口
|
|
260
|
+
* @public
|
|
261
|
+
*/
|
|
262
|
+
export interface SuperTableAntdProps extends Omit<TableProps, 'columns' | 'dataSource' | 'pagination'> {
|
|
263
|
+
pagination: PaginationProps;
|
|
264
|
+
columns: SuperTableColumn[];
|
|
265
|
+
dataSource: SuperTableDataItem[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 表单操作方法接口
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export interface SuperTableFormOperations {
|
|
272
|
+
/**
|
|
273
|
+
* 获取表单项配置
|
|
274
|
+
* @param name - 表单项名称
|
|
275
|
+
* @returns 表单项配置
|
|
276
|
+
*/
|
|
277
|
+
getFormItem(name: string): SuperTableFormItem | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* 设置表单项配置
|
|
280
|
+
* @param name - 表单项名称
|
|
281
|
+
* @param keyPath - 配置路径
|
|
282
|
+
* @param newConfig - 新的配置值
|
|
283
|
+
*/
|
|
284
|
+
setFormItem(name: string, keyPath: string, newConfig: any): void;
|
|
285
|
+
/**
|
|
286
|
+
* 获取表单值
|
|
287
|
+
* @param name - 表单项名称或名称数组,不传则获取所有值
|
|
288
|
+
* @returns 表单值对象
|
|
289
|
+
*/
|
|
290
|
+
getFormValues(name?: string | string[]): Record<string, any>;
|
|
291
|
+
/**
|
|
292
|
+
* 设置表单值
|
|
293
|
+
* @param values - 要设置的表单值对象
|
|
294
|
+
*/
|
|
295
|
+
setFormValues(values: Record<string, any>): void;
|
|
296
|
+
/**
|
|
297
|
+
* 获取单个表单项值
|
|
298
|
+
* @param name - 表单项名称
|
|
299
|
+
* @returns 表单项值
|
|
300
|
+
*/
|
|
301
|
+
getFormValue(name: string): any;
|
|
302
|
+
/**
|
|
303
|
+
* 设置单个表单项值
|
|
304
|
+
* @param name - 表单项名称
|
|
305
|
+
* @param value - 要设置的值
|
|
306
|
+
*/
|
|
307
|
+
setFormValue(name: string, value: any): void;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 表格操作方法接口
|
|
311
|
+
* @public
|
|
312
|
+
*/
|
|
313
|
+
export interface SuperTableTableOperations {
|
|
314
|
+
/**
|
|
315
|
+
* 获取表格数据
|
|
316
|
+
* @returns 表格数据数组
|
|
317
|
+
*/
|
|
318
|
+
getTableData(): SuperTableDataItem[];
|
|
319
|
+
/**
|
|
320
|
+
* 设置表格数据
|
|
321
|
+
* @param data - 要设置的表格数据
|
|
322
|
+
*/
|
|
323
|
+
setTableData(data: SuperTableDataItem[]): void;
|
|
324
|
+
/**
|
|
325
|
+
* 设置表格数据项
|
|
326
|
+
* @param index - 数据项索引
|
|
327
|
+
* @param data - 要设置的数据项
|
|
328
|
+
*/
|
|
329
|
+
setTableDataItem(index: number, data: Partial<SuperTableDataItem>): void;
|
|
330
|
+
/**
|
|
331
|
+
* 刷新表格数据
|
|
332
|
+
*/
|
|
333
|
+
onRefresh(): void;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 组件实例类型
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
export interface SuperTableSlots {
|
|
340
|
+
/** 场景选择器前面的插槽 */
|
|
341
|
+
sceneAddonBefore?: () => any;
|
|
342
|
+
/** 场景选择器后面的插槽 */
|
|
343
|
+
sceneAddonAfter?: () => any;
|
|
344
|
+
/** 额外内容插槽 */
|
|
345
|
+
extra?: () => any;
|
|
346
|
+
/** 表格头部插槽 */
|
|
347
|
+
tableHead?: () => any;
|
|
348
|
+
/** 工具栏额外按钮插槽 */
|
|
349
|
+
toolBarExtra?: () => any;
|
|
350
|
+
/** 展开列标题插槽 */
|
|
351
|
+
expandColumnTitle?: () => any;
|
|
352
|
+
/** 表格底部插槽 */
|
|
353
|
+
tableFoot?: () => any;
|
|
354
|
+
/** 展开行内容插槽 */
|
|
355
|
+
expandedRowRender?: (props: {
|
|
356
|
+
record: any;
|
|
357
|
+
}) => any;
|
|
358
|
+
}
|
|
@@ -46,13 +46,16 @@ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
|
|
|
46
46
|
}> | undefined;
|
|
47
47
|
index: number;
|
|
48
48
|
key: string;
|
|
49
|
-
type?: import("..").SuperTableColumnType | ((row: import("..").
|
|
49
|
+
type?: import("..").SuperTableColumnType | ((row: import("..").SuperTableDataItem, index: number) => import("..").SuperTableColumnType);
|
|
50
50
|
title: string;
|
|
51
|
-
titleTooltip?: string | ((row: import("..").
|
|
52
|
-
content?: string | ((row: import("..").
|
|
53
|
-
tooltip?: string | boolean | ((row: import("..").
|
|
54
|
-
props?: Record<string, any> | ((row: import("..").
|
|
51
|
+
titleTooltip?: string | ((row: import("..").SuperTableDataItem, index: number) => string);
|
|
52
|
+
content?: string | ((row: import("..").SuperTableDataItem, index: number) => any);
|
|
53
|
+
tooltip?: string | boolean | ((row: import("..").SuperTableDataItem, index: number) => string);
|
|
54
|
+
props?: Record<string, any> | ((row: import("..").SuperTableDataItem, index: number) => Record<string, any>);
|
|
55
55
|
copyable?: boolean;
|
|
56
|
+
fixed?: import("..").SuperTableColumnFixedType;
|
|
57
|
+
sorter?: boolean | ((a: import("..").SuperTableDataItem, b: import("..").SuperTableDataItem) => number);
|
|
58
|
+
defaultSortOrder?: import("..").SuperTableSortOrders;
|
|
56
59
|
}[];
|
|
57
60
|
/**
|
|
58
61
|
* 格式化场景配置项数据
|
|
@@ -2,7 +2,7 @@ import type { SuperTableQueryScene } from '../typings';
|
|
|
2
2
|
/**
|
|
3
3
|
* 接口响应数据结构
|
|
4
4
|
*/
|
|
5
|
-
interface IResponse {
|
|
5
|
+
export interface IResponse {
|
|
6
6
|
/** 状态码 */
|
|
7
7
|
code: number;
|
|
8
8
|
/** 响应数据 */
|
|
@@ -19,18 +19,6 @@ interface LocalStorageConfig {
|
|
|
19
19
|
/** 设置场景列表 */
|
|
20
20
|
setScenes: (newScenes: SuperTableQueryScene[]) => void;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* API存储策略配置选项
|
|
24
|
-
*/
|
|
25
|
-
interface ApiStorageConfig {
|
|
26
|
-
/** API地址配置 */
|
|
27
|
-
sceneRequestUrls?: {
|
|
28
|
-
query: string;
|
|
29
|
-
create: string;
|
|
30
|
-
update: string;
|
|
31
|
-
delete: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
22
|
/**
|
|
35
23
|
* 本地存储场景服务
|
|
36
24
|
*/
|
|
@@ -42,17 +30,6 @@ export declare const localStorageSceneService: (config: LocalStorageConfig) => {
|
|
|
42
30
|
updateScene: (params: any) => Promise<IResponse>;
|
|
43
31
|
deleteScene: (params: string[]) => Promise<IResponse>;
|
|
44
32
|
};
|
|
45
|
-
/**
|
|
46
|
-
* API存储场景服务
|
|
47
|
-
*/
|
|
48
|
-
export declare const apiSceneService: (config?: ApiStorageConfig) => {
|
|
49
|
-
querySceneList: (params: {
|
|
50
|
-
type: string;
|
|
51
|
-
}) => Promise<IResponse>;
|
|
52
|
-
createScene: (params: any) => Promise<IResponse>;
|
|
53
|
-
updateScene: (params: any) => Promise<IResponse>;
|
|
54
|
-
deleteScene: (params: string[]) => Promise<IResponse>;
|
|
55
|
-
};
|
|
56
33
|
/** 不启用场景时,返回的场景服务 */
|
|
57
34
|
export declare const disabledSceneService: () => {
|
|
58
35
|
querySceneList: () => Promise<IResponse>;
|