@yidun/antd-super-table 0.0.1

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.
@@ -0,0 +1,12 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ vnodes: {
3
+ type: ObjectConstructor;
4
+ required: true;
5
+ };
6
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
7
+ vnodes: {
8
+ type: ObjectConstructor;
9
+ required: true;
10
+ };
11
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { SuperTableColumnType, SuperTableFormItemType } from './typings';
2
+ /** antd 主题配置 */
3
+ export declare const antdSeedToken: import("ant-design-vue/es/theme/interface").MapToken;
4
+ /** 查询项内置的一些字段 */
5
+ export declare enum ReadonlyFormItemKeysEnum {
6
+ /** 排序 */
7
+ order = "_order",
8
+ /** 在查询条件中的排序 */
9
+ orderInScene = "_orderInScene",
10
+ /** 默认值 */
11
+ defaultValue = "_defaultValue",
12
+ /** 是否选中 */
13
+ selected = "_selected"
14
+ }
15
+ export declare const ReadonlyFormItemKeys: string[];
16
+ /** 表格列对应的类型 */
17
+ export declare const SuperTableColumnTypeEnum: Record<string, SuperTableColumnType>;
18
+ /** 查询条件类型 */
19
+ export declare const SuperTableFormItemTypeEnum: Record<string, SuperTableFormItemType>;
20
+ /** 场景弹窗操作类型 */
21
+ export declare const SceneModalActionTypeEnum: {
22
+ /** 新增 */
23
+ create: string;
24
+ /** 更新 */
25
+ update: string;
26
+ /** 设置查询条件 */
27
+ search: string;
28
+ };
29
+ /** 本地缓存需要保存的列配置字段 */
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
+ };
@@ -0,0 +1,8 @@
1
+ import SuperTable from './SuperTable.vue';
2
+ export default SuperTable;
3
+ export { SuperTableColumnTypeEnum, SuperTableFormItemTypeEnum } from './config';
4
+ declare module 'vue' {
5
+ interface GlobalComponents {
6
+ SuperTable: typeof SuperTable;
7
+ }
8
+ }
@@ -0,0 +1,253 @@
1
+ import type { SelectProps, TableProps, PaginationProps } from 'ant-design-vue'
2
+ import type { Component, Reactive, Ref } from 'vue'
3
+
4
+ /** 表格列对应的type类型 */
5
+ export type SuperTableColumnType =
6
+ | 'text'
7
+ | 'link'
8
+ | 'button'
9
+ | 'tag'
10
+ | 'image'
11
+ | 'component'
12
+ | 'sort'
13
+
14
+ /** 查询表单项对应的type类型 */
15
+ export type SuperTableFormItemType =
16
+ | 'input'
17
+ | 'inputGroup'
18
+ | 'inputNumber'
19
+ | 'inputNumberRange'
20
+ | 'select'
21
+ | 'treeSelect'
22
+ | 'cascader'
23
+ | 'datePicker'
24
+ | 'rangePicker'
25
+ | 'component'
26
+
27
+ /* 查询条件配置 */
28
+ export interface SuperTableFormItem {
29
+ /** 查询详类型 */
30
+ type: SuperTableFormItemType
31
+
32
+ /** 查询项对应的字段名称 */
33
+ name: string
34
+
35
+ /** 绑定数据时v-model对应的name,默认value */
36
+ modelPropName?: string
37
+
38
+ /** 查询项label */
39
+ label: string
40
+
41
+ /** 传递给查询详的props */
42
+ props?: Record<string, any>
43
+
44
+ /** 选项值 */
45
+ value?: any
46
+
47
+ /** 自定义组件 */
48
+ component?: Component
49
+
50
+ /** 查询项宽度系数 */
51
+ span?: number
52
+
53
+ /** 是否显示 */
54
+ visible?: boolean
55
+
56
+ /** 带select前缀的组合输入框配置 */
57
+ addonBeforeProps?: SelectProps
58
+
59
+ /** 改变时保持静默,不要触发搜索*/
60
+ quiet?: boolean
61
+
62
+ /** 是否展示label,默认展示 */
63
+ showLabel?: boolean
64
+
65
+ /** 固定选项,不允许删除,高级搜索时一定会默认展示 */
66
+ fixed?: boolean
67
+
68
+ /**
69
+ * 默认选中,开启后表现为
70
+ * 1. 高级搜索弹窗打开时会默认选中对应的搜索项
71
+ * 2. 没有配置默认场景时,会根据选中的项目生成一个默认场景 */
72
+ selected?: boolean
73
+
74
+ // 以下为内置属性,不允许修改
75
+
76
+ /** 默认值 */
77
+ _defaultValue?: any
78
+
79
+ /** 排序 */
80
+ _order?: number
81
+
82
+ /** 是否选中 */
83
+ _selected?: boolean
84
+
85
+ /** 在选中场景中的排序 */
86
+ _orderInScene?: number
87
+
88
+ [key: string]: any
89
+ }
90
+
91
+ /** 表格单条数据 */
92
+ export type TableDataItem = Record<string, any>
93
+
94
+ /** 表格列吸附方式 */
95
+ export type TableColumnFixedType = 'left' | 'right'
96
+
97
+ /** 排序方式 */
98
+ export type SortOrders = 'ascending' | 'descending' | null
99
+
100
+ /** 表格表头配置 */
101
+ export interface SuperTableColumn {
102
+ /** 列对应key */
103
+ key: string
104
+
105
+ /** 展示类型 text: 文本 button: 按钮 link: 链接 tag: 标签 component:自定义组件 */
106
+ type?: SuperTableColumnType | ((row: TableDataItem, index: number) => SuperTableColumnType)
107
+
108
+ /** 标题 */
109
+ title: string
110
+
111
+ /** 标题对应的提示信息 */
112
+ titleTooltip?: string | ((row: TableDataItem, index: number) => string)
113
+
114
+ /** 表格内容 */
115
+ content?: string | ((row: TableDataItem, index: number) => any)
116
+
117
+ /** 表格内容对应的提示信息 */
118
+ tooltip?: string | boolean | ((row: TableDataItem, index: number) => string)
119
+
120
+ /** 表格内容解析自定义组件 */
121
+ component?: Component
122
+
123
+ /** 表格内容解析用到的组件组件对应的props */
124
+ props?: Record<string, any> | ((row: TableDataItem, index: number) => Record<string, any>)
125
+
126
+ /** 是否可复制 */
127
+ copyable?: boolean
128
+
129
+ /** 是否超出显示省略号 */
130
+ ellipsis?: boolean
131
+
132
+ /** 是否可见 */
133
+ visible?: boolean
134
+
135
+ /** 宽度 */
136
+ width?: number
137
+
138
+ [key: string]: any
139
+ }
140
+
141
+ /**
142
+ * 查询场景 https://docs.popo.netease.com/lingxi/1f2fdcb62291477f8056457f63fa3fcd?appVersion=4.15.0&deviceType=4&popo_hidenativebar=1&popo_noindicator=1&disposable_login_token=1
143
+ * */
144
+ export interface SuperTableQueryScene {
145
+ /** 场景唯一标识 */
146
+ code: string
147
+
148
+ /** 场景名称 */
149
+ name: string
150
+
151
+ /** 配置类型 */
152
+ type?: string
153
+
154
+ /** 配置详情 */
155
+ value?: string
156
+
157
+ /** 查询项列表 */
158
+ items: SuperTableQuerySceneItem[]
159
+
160
+ /** 是否是私有配置 */
161
+ asPrivate?: boolean
162
+
163
+ /** 是否是自定义场景 */
164
+ isCustom?: boolean
165
+ }
166
+
167
+ /** 场景中保存的查询条件配置 */
168
+ export interface SuperTableQuerySceneItem {
169
+ /** 字段名称 */
170
+ name: string
171
+
172
+ /** 字段类型 */
173
+ type: string
174
+
175
+ /** 字段值 */
176
+ value: any
177
+ }
178
+
179
+ /** 默认场景配置 */
180
+ export interface DefaultSceneConfig {
181
+ /** 场景名称 */
182
+ name?: string
183
+
184
+ /** 场景唯一表示,多个自定义场景时必填 */
185
+ code?: string
186
+
187
+ /** 查询项列表 */
188
+ items: {
189
+ /** 字段名称 */
190
+ name: string
191
+ /** 字段值 */
192
+ value: any
193
+ }[]
194
+ }
195
+
196
+ /** 场景状态 */
197
+ export interface SuperTableSceneState {
198
+ /** 查询场景列表 */
199
+ list: SuperTableQueryScene[]
200
+
201
+ /** 是否正在加载场景 */
202
+ loading: boolean
203
+
204
+ /** 是否正在保存场景 */
205
+ submiting: boolean
206
+
207
+ /** 是否已经加载过场景 */
208
+ loaded: boolean
209
+ }
210
+
211
+ /** 提供给弹窗使用的表格全局状态 */
212
+ export interface SuperTableContext {
213
+ /** 场景类型 */
214
+ sceneType: string
215
+
216
+ /** 场景状态 */
217
+ sceneState: Reactive<SuperTableSceneState>
218
+
219
+ /** 查询场景 */
220
+ queryScene(): void
221
+
222
+ /** 新增/更新场景 */
223
+ updateScene(scene: SuperTableQueryScene | SuperTableQueryScene[]): void
224
+
225
+ /** 删除场景 */
226
+ deleteScene(sceneCode: string): void
227
+
228
+ /** 当前生效中的查询参数 */
229
+ selectedFormItems: SuperTableQuerySceneItem[]
230
+
231
+ /** 禁用添加场景功能 */
232
+ allowCreateScene: Ref<boolean>
233
+ }
234
+
235
+ /** 数据请求方法 */
236
+ export type PropTableRequestFunction = (options: {
237
+ /** 查询参数 */
238
+ params: Record<string, any>
239
+
240
+ /** 分页大小 */
241
+ pageSize?: number
242
+
243
+ /** 当前页码 */
244
+ pageNum?: number
245
+
246
+ [key: string]: any
247
+ }) => Promise<{ total: number; data: Record<string, any>[] }>
248
+
249
+ export interface AntdTableProps extends TableProps {
250
+ pagination: PaginationProps
251
+ columns: SuperTableColumn[]
252
+ dataSource: Record<string, any>[]
253
+ }
@@ -0,0 +1,17 @@
1
+ import { ComponentOptions } from 'vue';
2
+ import 'dayjs/locale/zh-cn';
3
+ declare class DialogManager {
4
+ currents: any[];
5
+ dialogs: any;
6
+ staticDialogs: any;
7
+ rootVm: any;
8
+ constructor(staticDialogs?: {});
9
+ setRootVm(rootVm: any): void;
10
+ register(name: string, componentOptions: ComponentOptions): void;
11
+ unregister(name: string): void;
12
+ open(name: string, options: any): import("vue").App<Element> | undefined;
13
+ close(): void;
14
+ destroy(): void;
15
+ }
16
+ declare const dialogManager: DialogManager;
17
+ export default dialogManager;
@@ -0,0 +1,113 @@
1
+ import type { SuperTableColumn, SuperTableFormItem, SuperTableQueryScene } from '../typings';
2
+ /**
3
+ * 获取数据类型
4
+ * @param value - 需要获取类型的值
5
+ * @returns 类型名称(小写)
6
+ */
7
+ export declare const getDataType: (value: any) => string;
8
+ /**
9
+ * @description 初始化表单项配置项列表
10
+ * @param { SuperTableFormItem [] } formItems 表单项配置
11
+ * @returns SuperTableFormItem []
12
+ * */
13
+ export declare const initFormItems: (formItems: SuperTableFormItem[]) => {
14
+ props: Record<string, any>;
15
+ visible: boolean;
16
+ _order: number;
17
+ _defaultValue: any;
18
+ type: import("../typings").SuperTableFormItemType;
19
+ name: string;
20
+ modelPropName?: string;
21
+ label: string;
22
+ value?: any;
23
+ component?: import("vue").Component;
24
+ span?: number;
25
+ addonBeforeProps?: import("ant-design-vue").SelectProps;
26
+ quiet?: boolean;
27
+ showLabel?: boolean;
28
+ fixed?: boolean;
29
+ selected?: boolean;
30
+ _selected?: boolean;
31
+ _orderInScene?: number;
32
+ }[];
33
+ /**
34
+ * 初始化表格列配置项列表
35
+ * @param columns - 表格列配置
36
+ * @returns 初始化后的表格列列表
37
+ */
38
+ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
39
+ dataIndex: string | undefined;
40
+ width: number;
41
+ visible: boolean;
42
+ resizable: any;
43
+ ellipsis: boolean;
44
+ component: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
45
+ [key: string]: any;
46
+ }> | undefined;
47
+ index: number;
48
+ key: string;
49
+ type?: import("../typings").SuperTableColumnType | ((row: import("../typings").TableDataItem, index: number) => import("../typings").SuperTableColumnType);
50
+ title: string;
51
+ titleTooltip?: string | ((row: import("../typings").TableDataItem, index: number) => string);
52
+ content?: string | ((row: import("../typings").TableDataItem, index: number) => any);
53
+ tooltip?: string | boolean | ((row: import("../typings").TableDataItem, index: number) => string);
54
+ props?: Record<string, any> | ((row: import("../typings").TableDataItem, index: number) => Record<string, any>);
55
+ copyable?: boolean;
56
+ }[];
57
+ /**
58
+ * 格式化场景配置项数据
59
+ * @param sceneList - 场景配置项
60
+ * @param formConfigMap - 表单项配置列表
61
+ * @param sortCodes - 排序码数组
62
+ * @returns 格式化后的场景数据
63
+ */
64
+ export declare const formatSceneData: (sceneList: SuperTableQueryScene[], formConfigMap: Record<string, SuperTableFormItem>, sortCodes: string[]) => SuperTableQueryScene[];
65
+ /**
66
+ * 错误提示信息
67
+ * @param args - 需要打印的参数
68
+ */
69
+ export declare function logError(...args: any[]): void;
70
+ /**
71
+ * 校验表单项配置
72
+ * @param formItems - 表单项配置
73
+ */
74
+ export declare const validateFormItems: (formItems: SuperTableFormItem[]) => void;
75
+ /**
76
+ * 校验表格列配置
77
+ * @param columns - 表格列配置
78
+ */
79
+ export declare const validateTableColumns: (columns: SuperTableColumn[]) => void;
80
+ /**
81
+ * 获取文本的宽度
82
+ * @param text - 文本内容
83
+ * @param font - 字体设置(包含字号、字体等信息)
84
+ * @returns 文本宽度(像素)
85
+ */
86
+ export declare const getTextWidth: (text: string, font?: {
87
+ fontSize?: number;
88
+ fontFamily?: string;
89
+ fontWeight?: number;
90
+ }) => number;
91
+ /**
92
+ * 安全解析 JSON 字符串
93
+ * @param jsonString - 需要解析的 JSON 字符串
94
+ * @param defaultVal - 解析失败时的默认值
95
+ * @returns 解析后的值或默认值
96
+ */
97
+ export declare const parseJsonSafe: <T = Record<string, any>>(jsonString: string, defaultVal: T) => T;
98
+ /**
99
+ * @description 生成固定输出的32位字符串ID
100
+ * @param {string} input - 需要生成唯一id的值
101
+ * @returns {string} 唯一id
102
+ * */
103
+ export declare const generateID: (input: string) => string;
104
+ /**
105
+ * 获取指定名称的 cookie 值
106
+ * @param {string} sKey - cookie 的键名
107
+ * @returns {string} cookie 的值,如果不存在则返回空字符串
108
+ * @example
109
+ * ```ts
110
+ * const token = getCookie('token');
111
+ * ```
112
+ */
113
+ export declare const getCookie: (sKey: string) => string;
@@ -0,0 +1,63 @@
1
+ import type { SuperTableQueryScene } from '../typings';
2
+ /**
3
+ * 接口响应数据结构
4
+ */
5
+ interface IResponse {
6
+ /** 状态码 */
7
+ code: number;
8
+ /** 响应数据 */
9
+ data: any;
10
+ /** 响应消息 */
11
+ msg: string;
12
+ }
13
+ /**
14
+ * 本地存储策略配置选项
15
+ */
16
+ interface LocalStorageConfig {
17
+ /** 获取场景列表 */
18
+ getScenes: () => SuperTableQueryScene[];
19
+ /** 设置场景列表 */
20
+ setScenes: (newScenes: SuperTableQueryScene[]) => void;
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
+ /**
35
+ * 本地存储场景服务
36
+ */
37
+ export declare const localStorageSceneService: (config: LocalStorageConfig) => {
38
+ querySceneList: (params: {
39
+ type: string;
40
+ }) => Promise<IResponse>;
41
+ createScene: (params: any) => Promise<IResponse>;
42
+ updateScene: (params: any) => Promise<IResponse>;
43
+ deleteScene: (params: string[]) => Promise<IResponse>;
44
+ };
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
+ /** 不启用场景时,返回的场景服务 */
57
+ export declare const disabledSceneService: () => {
58
+ querySceneList: () => Promise<IResponse>;
59
+ createScene: () => Promise<IResponse>;
60
+ updateScene: () => Promise<IResponse>;
61
+ deleteScene: () => Promise<IResponse>;
62
+ };
63
+ export {};
@@ -0,0 +1,15 @@
1
+ import { defineComponent } from 'vue';
2
+ /**
3
+ * 用于管理对话框组件的组合式函数
4
+ * @param {ReturnType<typeof defineComponent>} vm - Vue 组件实例
5
+ * @param {any} [config] - 对话框的可选配置对象
6
+ * @returns {Object} 包含对话框控制方法的对象
7
+ */
8
+ export default function useDialog(vm: ReturnType<typeof defineComponent>, config?: any): {
9
+ open: () => void;
10
+ close: () => void;
11
+ openByConfig: (dialogConfig: {
12
+ props?: any;
13
+ [key: string]: any;
14
+ }) => void;
15
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@yidun/antd-super-table",
3
+ "version": "0.0.1",
4
+ "description": "基于 Ant Design Vue 的高级表格组件,提供丰富的查询条件配置、表格列配置和场景管理功能",
5
+ "keywords": ["vue", "ant-design-vue", "table", "super-table", "typescript"],
6
+ "author": "Yidun",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "main": "./dist/antd-super-table.es.js",
10
+ "module": "./dist/antd-super-table.es.js",
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "dev": "vite",
18
+ "build": "vite build --mode lib && tsc --emitDeclarationOnly && cp src/typings.d.ts dist/",
19
+ "preview": "vite preview",
20
+ "tsc": "tsc --noEmit --project tsconfig.json",
21
+ "lint": "eslint src --fix",
22
+ "format": "prettier --write src/"
23
+ },
24
+ "dependencies": {
25
+ "@ant-design/icons-vue": "^7.0.1",
26
+ "@vueuse/core": "^13.1.0",
27
+ "ant-design-vue": "^4.2.6",
28
+ "dayjs": "^1.11.13",
29
+ "jsonpath-plus": "^10.3.0",
30
+ "lodash-es": "^4.17.21",
31
+ "sortablejs": "^1.15.6",
32
+ "uuid": "^11.1.0",
33
+ "vue": "^3.5.13",
34
+ "vuedraggable": "^4.0.1"
35
+ },
36
+ "devDependencies": {
37
+ "@tsconfig/node22": "^22.0.1",
38
+ "@types/lodash-es": "^4.17.12",
39
+ "@types/node": "^22.14.0",
40
+ "@types/sortablejs": "^1.15.8",
41
+ "@types/spark-md5": "^3.0.5",
42
+ "@vitejs/plugin-vue": "^5.2.3",
43
+ "@vitejs/plugin-vue-jsx": "^4.1.2",
44
+ "@vue/eslint-config-prettier": "^10.2.0",
45
+ "@vue/eslint-config-typescript": "^14.5.0",
46
+ "@vue/tsconfig": "^0.7.0",
47
+ "eslint": "^9.22.0",
48
+ "eslint-plugin-prettier": "^5.2.6",
49
+ "eslint-plugin-vue": "~10.0.0",
50
+ "jiti": "^2.4.2",
51
+ "mockjs": "^1.1.0",
52
+ "npm-run-all2": "^7.0.2",
53
+ "prettier": "^3.5.3",
54
+ "sass": "^1.87.0",
55
+ "typescript": "~5.8.0",
56
+ "vite": "^6.2.4",
57
+ "vite-plugin-vue-devtools": "^7.7.2",
58
+ "vue-tsc": "^2.2.8"
59
+ }
60
+ }