@yidun/antd-super-table 0.0.4 → 0.0.6

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,318 @@
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 = 'text' | 'link' | 'button' | 'tag' | 'image' | 'component' | 'sort'
6
+
7
+ /** 查询表单项对应的type类型 */
8
+ export type SuperTableFormItemType =
9
+ | 'input'
10
+ | 'inputGroup'
11
+ | 'inputNumber'
12
+ | 'inputNumberRange'
13
+ | 'select'
14
+ | 'treeSelect'
15
+ | 'cascader'
16
+ | 'datePicker'
17
+ | 'rangePicker'
18
+ | 'component'
19
+
20
+ /* 查询条件配置 */
21
+ export interface SuperTableFormItem {
22
+ /** 查询详类型 */
23
+ type: SuperTableFormItemType
24
+
25
+ /** 查询项对应的字段名称 */
26
+ name: string
27
+
28
+ /** 绑定数据时v-model对应的name,默认value */
29
+ modelPropName?: string
30
+
31
+ /** 查询项label */
32
+ label: string
33
+
34
+ /** 传递给查询详的props */
35
+ props?: Record<string, any>
36
+
37
+ /** 选项值 */
38
+ value?: any
39
+
40
+ /** 自定义组件 */
41
+ component?: Component
42
+
43
+ /** 查询项宽度系数 */
44
+ span?: number
45
+
46
+ /** 是否显示 */
47
+ visible?: boolean
48
+
49
+ /** 带select前缀的组合输入框配置 */
50
+ addonBeforeProps?: SelectProps
51
+
52
+ /** 改变时保持静默,不要触发搜索*/
53
+ quiet?: boolean
54
+
55
+ /** 是否展示label,默认展示 */
56
+ showLabel?: boolean
57
+
58
+ /** 固定选项,不允许删除,高级搜索时一定会默认展示 */
59
+ fixed?: boolean
60
+
61
+ /**
62
+ * 默认选中,开启后表现为
63
+ * 1. 高级搜索弹窗打开时会默认选中对应的搜索项
64
+ * 2. 没有配置默认场景时,会根据选中的项目生成一个默认场景 */
65
+ selected?: boolean
66
+
67
+ // 以下为内置属性,不允许修改
68
+
69
+ /** 默认值 */
70
+ _defaultValue?: any
71
+
72
+ /** 排序 */
73
+ _order?: number
74
+
75
+ /** 是否选中 */
76
+ _selected?: boolean
77
+
78
+ /** 在选中场景中的排序 */
79
+ _orderInScene?: number
80
+
81
+ [key: string]: any
82
+ }
83
+
84
+ /** 表格单条数据 */
85
+ export type TableDataItem = Record<string, any>
86
+
87
+ /** 表格列吸附方式 */
88
+ export type TableColumnFixedType = 'left' | 'right'
89
+
90
+ /** 排序方式 */
91
+ export type SortOrders = 'ascending' | 'descending' | null
92
+
93
+ /** 表格表头配置 */
94
+ export interface SuperTableColumn {
95
+ /** 列对应key */
96
+ key: string
97
+
98
+ /** 展示类型 text: 文本 button: 按钮 link: 链接 tag: 标签 component:自定义组件 */
99
+ type?: SuperTableColumnType | ((row: TableDataItem, index: number) => SuperTableColumnType)
100
+
101
+ /** 标题 */
102
+ title: string
103
+
104
+ /** 标题对应的提示信息 */
105
+ titleTooltip?: string | ((row: TableDataItem, index: number) => string)
106
+
107
+ /** 表格内容 */
108
+ content?: string | ((row: TableDataItem, index: number) => any)
109
+
110
+ /** 表格内容对应的提示信息 */
111
+ tooltip?: string | boolean | ((row: TableDataItem, index: number) => string)
112
+
113
+ /** 表格内容解析自定义组件 */
114
+ component?: Component
115
+
116
+ /** 表格内容解析用到的组件组件对应的props */
117
+ props?: Record<string, any> | ((row: TableDataItem, index: number) => Record<string, any>)
118
+
119
+ /** 是否可复制 */
120
+ copyable?: boolean
121
+
122
+ /** 是否超出显示省略号 */
123
+ ellipsis?: boolean
124
+
125
+ /** 是否可见 */
126
+ visible?: boolean
127
+
128
+ /** 宽度 */
129
+ width?: number
130
+
131
+ [key: string]: any
132
+ }
133
+
134
+ /**
135
+ * 查询场景 https://docs.popo.netease.com/lingxi/1f2fdcb62291477f8056457f63fa3fcd?appVersion=4.15.0&deviceType=4&popo_hidenativebar=1&popo_noindicator=1&disposable_login_token=1
136
+ * */
137
+ export interface SuperTableQueryScene {
138
+ /** 场景唯一标识 */
139
+ code: string
140
+
141
+ /** 场景名称 */
142
+ name: string
143
+
144
+ /** 配置类型 */
145
+ type?: string
146
+
147
+ /** 配置详情 */
148
+ value?: string
149
+
150
+ /** 查询项列表 */
151
+ items: SuperTableQuerySceneItem[]
152
+
153
+ /** 是否是私有配置 */
154
+ asPrivate?: boolean
155
+
156
+ /** 是否是自定义场景 */
157
+ isCustom?: boolean
158
+ }
159
+
160
+ /** 场景中保存的查询条件配置 */
161
+ export interface SuperTableQuerySceneItem {
162
+ /** 字段名称 */
163
+ name: string
164
+
165
+ /** 字段类型 */
166
+ type: string
167
+
168
+ /** 字段值 */
169
+ value: any
170
+ }
171
+
172
+ /** 默认场景配置 */
173
+ export interface DefaultSceneConfig {
174
+ /** 场景名称 */
175
+ name?: string
176
+
177
+ /** 场景唯一表示,多个自定义场景时必填 */
178
+ code?: string
179
+
180
+ /** 查询项列表 */
181
+ items: {
182
+ /** 字段名称 */
183
+ name: string
184
+ /** 字段值 */
185
+ value: any
186
+ }[]
187
+ }
188
+
189
+ /** 场景状态 */
190
+ export interface SuperTableSceneState {
191
+ /** 查询场景列表 */
192
+ list: SuperTableQueryScene[]
193
+
194
+ /** 是否正在加载场景 */
195
+ loading: boolean
196
+
197
+ /** 是否正在保存场景 */
198
+ submiting: boolean
199
+
200
+ /** 是否已经加载过场景 */
201
+ loaded: boolean
202
+ }
203
+
204
+ /** 提供给弹窗使用的表格全局状态 */
205
+ export interface SuperTableContext {
206
+ /** 场景类型 */
207
+ sceneType: string
208
+
209
+ /** 场景状态 */
210
+ sceneState: Reactive<SuperTableSceneState>
211
+
212
+ /** 查询场景 */
213
+ queryScene(): void
214
+
215
+ /** 新增/更新场景 */
216
+ updateScene(scene: SuperTableQueryScene | SuperTableQueryScene[]): void
217
+
218
+ /** 删除场景 */
219
+ deleteScene(sceneCode: string): void
220
+
221
+ /** 当前生效中的查询参数 */
222
+ selectedFormItems: SuperTableQuerySceneItem[]
223
+
224
+ /** 禁用添加场景功能 */
225
+ allowCreateScene: Ref<boolean>
226
+ }
227
+
228
+ /** 数据请求方法 */
229
+ export type PropTableRequestFunction = (options: {
230
+ /** 查询参数 */
231
+ params: Record<string, any>
232
+
233
+ /** 分页大小 */
234
+ pageSize?: number
235
+
236
+ /** 当前页码 */
237
+ pageNum?: number
238
+
239
+ [key: string]: any
240
+ }) => Promise<{ total: number; data: Record<string, any>[] }>
241
+
242
+ export interface AntdTableProps extends TableProps {
243
+ pagination: PaginationProps
244
+ columns: SuperTableColumn[]
245
+ dataSource: Record<string, any>[]
246
+ }
247
+
248
+ /** 表单操作方法接口 */
249
+ export interface FormOperations {
250
+ /**
251
+ * 获取表单项配置
252
+ * @param {string} name - 表单项名称
253
+ * @returns {SuperTableFormItem | undefined} 表单项配置
254
+ */
255
+ getFormItem(name: string): SuperTableFormItem | undefined
256
+
257
+ /**
258
+ * 设置表单项配置
259
+ * @param {string} name - 表单项名称
260
+ * @param {string} keyPath - 配置路径
261
+ * @param {any} newConfig - 新的配置值
262
+ * @returns {void}
263
+ */
264
+ setFormItem(name: string, keyPath: string, newConfig: any): void
265
+
266
+ /**
267
+ * 获取表单值
268
+ * @param {string | string[]} [name] - 表单项名称或名称数组,不传则获取所有值
269
+ * @returns {Record<string, any>} 表单值对象
270
+ */
271
+ getFormValues(name?: string | string[]): Record<string, any>
272
+
273
+ /**
274
+ * 设置表单值
275
+ * @param {Record<string, any>} values - 要设置的表单值对象
276
+ * @returns {void}
277
+ */
278
+ setFormValues(values: Record<string, any>): void
279
+
280
+ /**
281
+ * 获取单个表单项值
282
+ * @param {string} name - 表单项名称
283
+ * @returns {any} 表单项值
284
+ */
285
+ getFormValue(name: string): any
286
+
287
+ /**
288
+ * 设置单个表单项值
289
+ * @param {string} name - 表单项名称
290
+ * @param {any} value - 要设置的值
291
+ * @returns {void}
292
+ */
293
+ setFormValue(name: string, value: any): void
294
+ }
295
+
296
+ /** 表格操作方法接口 */
297
+ export interface TableOperations {
298
+ /**
299
+ * 获取表格数据
300
+ * @returns {any[]} 表格数据数组
301
+ */
302
+ getTableData(): any[]
303
+
304
+ /**
305
+ * 设置表格数据
306
+ * @param {any[]} data - 要设置的表格数据
307
+ * @returns {void}
308
+ */
309
+ setTableData(data: any[]): void
310
+
311
+ /**
312
+ * 设置表格数据项
313
+ * @param {number} index - 数据项索引
314
+ * @param {Record<string, any>} data - 要设置的数据项
315
+ * @returns {void}
316
+ */
317
+ setTableDataItem(index: number, data: Record<string, any>): void
318
+ }
@@ -15,7 +15,7 @@ export declare const initFormItems: (formItems: SuperTableFormItem[]) => {
15
15
  visible: boolean;
16
16
  _order: number;
17
17
  _defaultValue: any;
18
- type: import("../typings").SuperTableFormItemType;
18
+ type: import("..").SuperTableFormItemType;
19
19
  name: string;
20
20
  modelPropName?: string;
21
21
  label: string;
@@ -46,12 +46,12 @@ export declare const initTableColumns: (columns: SuperTableColumn[]) => {
46
46
  }> | undefined;
47
47
  index: number;
48
48
  key: string;
49
- type?: import("../typings").SuperTableColumnType | ((row: import("../typings").TableDataItem, index: number) => import("../typings").SuperTableColumnType);
49
+ type?: import("..").SuperTableColumnType | ((row: import("..").TableDataItem, index: number) => import("..").SuperTableColumnType);
50
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>);
51
+ titleTooltip?: string | ((row: import("..").TableDataItem, index: number) => string);
52
+ content?: string | ((row: import("..").TableDataItem, index: number) => any);
53
+ tooltip?: string | boolean | ((row: import("..").TableDataItem, index: number) => string);
54
+ props?: Record<string, any> | ((row: import("..").TableDataItem, index: number) => Record<string, any>);
55
55
  copyable?: boolean;
56
56
  }[];
57
57
  /**
package/example.png ADDED
Binary file
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@yidun/antd-super-table",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
+ "example.png",
9
10
  "README.md"
10
11
  ],
11
12
  "scripts": {
12
13
  "dev": "vite",
13
- "build": "vite build --mode lib && tsc --emitDeclarationOnly && cp src/typings.d.ts dist/",
14
+ "build": "vite build --mode lib && tsc --emitDeclarationOnly && cp src/typings.ts dist/",
14
15
  "preview": "vite preview",
15
16
  "tsc": "tsc --noEmit --project tsconfig.json",
16
17
  "lint": "eslint src --fix",
@@ -49,6 +50,7 @@
49
50
  "sass": "^1.87.0",
50
51
  "typescript": "~5.8.0",
51
52
  "vite": "^6.2.4",
53
+ "vite-plugin-css-injected-by-js": "^3.5.2",
52
54
  "vite-plugin-vue-devtools": "^7.7.2",
53
55
  "vue-tsc": "^2.2.8"
54
56
  }