zzz-pc-view 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.
Files changed (71) hide show
  1. package/package.json +29 -0
  2. package/src/api/org/list +96 -0
  3. package/src/api/org/type/list +18 -0
  4. package/src/api/own +3831 -0
  5. package/src/decorators/CurdKey/CurdApi.d.ts +221 -0
  6. package/src/decorators/CurdKey/RequestUtil.d.ts +55 -0
  7. package/src/decorators/CurdKey/index.d.ts +752 -0
  8. package/src/decorators/DeclareType.d.ts +35 -0
  9. package/src/decorators/Decorators.d.ts +5 -0
  10. package/src/decorators/FilterKey/index.d.ts +283 -0
  11. package/src/decorators/Loader/index.d.ts +179 -0
  12. package/src/decorators/NameKey/index.d.ts +68 -0
  13. package/src/decorators/PrimaryKey/index.d.ts +68 -0
  14. package/src/decorators/api.d.ts +21 -0
  15. package/src/decorators/decoratorStoreUtil.d.ts +68 -0
  16. package/src/decorators/index.d.ts +6 -0
  17. package/src/decorators/loadStore.d.ts +6 -0
  18. package/src/decorators/loadUtil.d.ts +25 -0
  19. package/src/decorators/util.d.ts +27 -0
  20. package/src/favicon.ico +0 -0
  21. package/src/index-decorators.d.ts +3 -0
  22. package/src/index.d.ts +10 -0
  23. package/src/index.es.js +10035 -0
  24. package/src/index.umd.js +2 -0
  25. package/src/pcViews/components/curd/CurdTableView.vue.d.ts +18 -0
  26. package/src/pcViews/components/curd/CurdView.vue.d.ts +22 -0
  27. package/src/pcViews/components/curd/CurdViewHandler.d.ts +1208 -0
  28. package/src/pcViews/components/curd/FilterView.vue.d.ts +19 -0
  29. package/src/pcViews/components/curd/FilterViewHandler.d.ts +6 -0
  30. package/src/pcViews/components/curd/index.d.ts +2 -0
  31. package/src/pcViews/components/forms/RadioButtonGroupView.vue.d.ts +19 -0
  32. package/src/pcViews/components/forms/SelectView.vue.d.ts +19 -0
  33. package/src/pcViews/components/forms/VModelView.vue.d.ts +20 -0
  34. package/src/pcViews/components/forms/index.d.ts +3 -0
  35. package/src/pcViews/components/index.d.ts +5 -0
  36. package/src/pcViews/components/layout/DataWrapperView.vue.d.ts +23 -0
  37. package/src/pcViews/components/layout/LayoutHeader.vue.d.ts +2 -0
  38. package/src/pcViews/components/layout/LayoutMainView.vue.d.ts +2 -0
  39. package/src/pcViews/components/layout/index.d.ts +2 -0
  40. package/src/pcViews/components/slots/VSlotView.vue.d.ts +20 -0
  41. package/src/pcViews/components/slots/index.d.ts +1 -0
  42. package/src/pcViews/components/utils.d.ts +33 -0
  43. package/src/pcViews/index.d.ts +1 -0
  44. package/src/utils/Date/ZDate.d.ts +557 -0
  45. package/src/utils/DeclareType.d.ts +39 -0
  46. package/src/utils/class/bind.d.ts +43 -0
  47. package/src/utils/class/combine.d.ts +109 -0
  48. package/src/utils/crypto/index.d.ts +44 -0
  49. package/src/utils/empty/index.d.ts +18 -0
  50. package/src/utils/httpRequest/HttpRequestError.d.ts +14 -0
  51. package/src/utils/httpRequest/httpRequestCreator.d.ts +61 -0
  52. package/src/utils/httpRequest/httpRequestUtil.d.ts +24 -0
  53. package/src/utils/httpRequest/index.d.ts +3 -0
  54. package/src/utils/index.d.ts +11 -0
  55. package/src/utils/math/toFixed.d.ts +11 -0
  56. package/src/utils/math/unitConvertor.d.ts +34 -0
  57. package/src/utils/mock/HttpResponse.d.ts +30 -0
  58. package/src/utils/mock/createDataTimes.d.ts +20 -0
  59. package/src/utils/mock/index.d.ts +2 -0
  60. package/src/utils/reduce/completeByDate.d.ts +51 -0
  61. package/src/utils/reduce/index.d.ts +9 -0
  62. package/src/utils/reduce/mappingBuilder.d.ts +69 -0
  63. package/src/utils/reduce/ratio.d.ts +104 -0
  64. package/src/utils/reduce/sort.d.ts +12 -0
  65. package/src/utils/reduce/sumByGroup.d.ts +53 -0
  66. package/src/utils/reduce/toGroup.d.ts +79 -0
  67. package/src/utils/reduce/tree.d.ts +570 -0
  68. package/src/utils/reduce/util.d.ts +14 -0
  69. package/src/utils/reduce/valueConvertor.d.ts +65 -0
  70. package/src/utils/reduce/verticalToHorizontal.d.ts +80 -0
  71. package/src/zzz-frame.css +7 -0
@@ -0,0 +1,221 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { httpRequest, CombineInstanceType, KeyMatch } from '../../utils';
3
+ import { TypeWithPrototype, TypeWithPrototypeWithoutNew } from '../DeclareType';
4
+ import { Reactive } from 'vue';
5
+ /**
6
+ * 定义编辑类型的枚举。
7
+ * @enum {number}
8
+ */
9
+ export declare enum EditTypeEnum {
10
+ CREATE = 1,
11
+ DETAIL = 2,
12
+ UPDATE = 6
13
+ }
14
+ /**
15
+ * 定义编辑类型映射的常量对象。
16
+ * @const
17
+ * @type {Object}
18
+ */
19
+ export declare const editTypeMap: {
20
+ /**
21
+ * 创建操作的配置。
22
+ * @type {Object}
23
+ * @property {EditTypeEnum.CREATE} id - 操作的ID,对应EditTypeEnum.CREATE。
24
+ * @property {() => string} getLabel - 获取操作标签的函数,返回'新增'。
25
+ * @property {string} method - 操作的HTTP方法,为'POST'。
26
+ */
27
+ readonly 1: {
28
+ readonly id: EditTypeEnum.CREATE;
29
+ readonly getLabel: () => string;
30
+ readonly method: "POST";
31
+ };
32
+ /**
33
+ * 详情操作的配置。
34
+ * @type {Object}
35
+ * @property {EditTypeEnum.DETAIL} id - 操作的ID,对应EditTypeEnum.DETAIL。
36
+ * @property {string} label - 操作的标签,为'详情'。
37
+ * @property {string} method - 操作的HTTP方法,为'GET'。
38
+ */
39
+ readonly 2: {
40
+ readonly id: EditTypeEnum.DETAIL;
41
+ readonly label: "详情";
42
+ readonly method: "GET";
43
+ };
44
+ /**
45
+ * 更新操作的配置。
46
+ * @type {Object}
47
+ * @property {EditTypeEnum.UPDATE} id - 操作的ID,对应EditTypeEnum.UPDATE。
48
+ * @property {string} label - 操作的标签,为'修改'。
49
+ * @property {string} method - 操作的HTTP方法,为'PUT'。
50
+ */
51
+ readonly 6: {
52
+ readonly id: EditTypeEnum.UPDATE;
53
+ readonly label: "修改";
54
+ readonly method: "PUT";
55
+ };
56
+ };
57
+ /**
58
+ * 定义保存类型映射的类型。
59
+ */
60
+ export type EditTypeMap = typeof editTypeMap;
61
+ /**
62
+ * 定义保存类型的类型。
63
+ */
64
+ export type EditType = EditTypeMap[EditTypeEnum];
65
+ /**
66
+ * 定义保存类型的键类型。
67
+ */
68
+ export type EditTypeId = keyof EditTypeMap;
69
+ /**
70
+ * 定义分页响应的接口。
71
+ * @template T - 响应中列表项的类型。
72
+ */
73
+ export interface PaginationResponse<T> {
74
+ list: T[];
75
+ total: number;
76
+ }
77
+ /**
78
+ * 定义分页响应构造函数的接口。
79
+ * @template T - 响应中列表项的类型。
80
+ */
81
+ export interface PaginationResponseConstructor<T> extends TypeWithPrototypeWithoutNew {
82
+ new (data: PaginationResponse<T>): PaginationResponse<T>;
83
+ }
84
+ /**
85
+ * 定义 CURD(创建、读取、更新、删除)操作的 API 类。
86
+ * @template T - 表示操作的数据类型,默认为 `object`。
87
+ * @template P - 表示分页响应的构造函数类型,默认为 `PaginationResponseConstructor<T>`。
88
+ */
89
+ export declare class CurdApi<T extends object = object, P extends PaginationResponseConstructor<T> = PaginationResponseConstructor<T>> {
90
+ /**
91
+ * 目标类的构造函数。
92
+ * @protected
93
+ * @type {TypeWithPrototype}
94
+ */
95
+ protected readonly Target: TypeWithPrototype;
96
+ /**
97
+ * API 的基础路径。
98
+ * @protected
99
+ * @type {string}
100
+ */
101
+ protected readonly basePath: string;
102
+ /**
103
+ * 树形结构的键配置。
104
+ * @description 这个属性是可选的,如果提供了树形结构的键配置,则在处理树形数据时会使用它。
105
+ * @description 树形结构的键配置包含三个属性:
106
+ * @description - `childrenKey`:用于获取子节点的键匹配函数。
107
+ * @description - `parentIdKey`:用于获取父节点ID的键匹配函数。
108
+ * @description - `sortKey`:用于排序节点的键匹配函数(可选)。
109
+ * @type {Object}
110
+ * @property {KeyMatch<T, undefined | T[]>} childrenKey - 用于获取子节点的键匹配函数。
111
+ * @property {KeyMatch<T, undefined | null | PropertyKey>} parentIdKey - 用于获取父节点ID的键匹配函数。
112
+ * @property {KeyMatch<T, undefined | number>} [sortKey] - 用于排序节点的键匹配函数(可选)。
113
+ * @optional
114
+ */
115
+ protected readonly treeKey?: {
116
+ childrenKey: KeyMatch<T, undefined | T[]>;
117
+ parentIdKey: KeyMatch<T, undefined | null | PropertyKey>;
118
+ sortKey?: KeyMatch<T, undefined | number>;
119
+ };
120
+ /**
121
+ * 分页响应的类。
122
+ * @protected
123
+ * @type {P}
124
+ */
125
+ protected readonly PaginationResponseClass?: P;
126
+ get hasServerPagination(): boolean;
127
+ /**
128
+ * 是否使用文件上传保存数据。
129
+ * @protected
130
+ * @type {boolean}
131
+ */
132
+ protected readonly saveWithUploadFile: boolean;
133
+ /**
134
+ * 获取列表数据。
135
+ * @description 该方法用于从API获取列表数据,并根据需要进行数据绑定和树形结构处理。
136
+ * @description 如果提供了查询参数,则会将其作为查询字符串附加到URL中。
137
+ * @description 如果API返回的数据是数组,则会将其绑定到目标类,并根据树形结构配置进行处理。
138
+ * @description 最后,返回一个包含处理后数据的Promise。
139
+ * @param {T | Reactive<T>} [query] - 查询参数,可以是普通对象或Vue的响应式对象。
140
+ * @returns {Promise<T[]>} - 返回一个包含列表数据的Promise。
141
+ */
142
+ getList(query?: T | Reactive<T>): httpRequest.HttpRequestPromise<T[]>;
143
+ /**
144
+ * 分页获取列表数据。
145
+ * @param {object} pagination - 分页参数。
146
+ * @param {T | Reactive<T>} [query] - 查询参数。
147
+ * @returns {Promise<CombineInstanceType<P>>} - 返回一个包含分页数据的 Promise。
148
+ */
149
+ getListByPage(pagination: object, query?: T | Reactive<T>): httpRequest.HttpRequestPromise<Awaited<CombineInstanceType<P>>>;
150
+ /**
151
+ * 获取指定数据的详细信息。
152
+ * 这个方法会根据传入的数据对象的ID,从API获取该数据的详细信息,并将其绑定到目标类。
153
+ * @param {T} data - 包含ID的数据对象。
154
+ * @returns {Promise<T>} - 返回一个包含详细信息的Promise。
155
+ */
156
+ getDetail(data: T): httpRequest.HttpRequestPromise<Awaited<T>>;
157
+ /**
158
+ * 保存数据。
159
+ * @param {T} data - 要保存的数据对象。
160
+ * @param {EditTypeId} saveTypeId - 保存类型的 ID。
161
+ * @returns {Promise<any>} - 返回一个包含保存结果的 Promise。
162
+ */
163
+ save(data: T, saveTypeId: EditTypeId): httpRequest.HttpRequestPromise<unknown>;
164
+ /**
165
+ * 删除数据。
166
+ * @param {T} data - 包含 ID 的数据对象。
167
+ * @returns {Promise<any>} - 返回一个包含删除结果的 Promise。
168
+ */
169
+ delete(data: T): httpRequest.HttpRequestPromise<unknown>;
170
+ /**
171
+ * 更改数据状态。
172
+ * @param {T} data - 包含 ID 的数据对象。
173
+ * @param {number | boolean} state - 新的状态值。
174
+ * @returns {Promise<any>} - 返回一个包含更改结果的 Promise。
175
+ */
176
+ changeState(data: T, state: number | boolean): httpRequest.HttpRequestPromise<unknown>;
177
+ /**
178
+ * 导出数据。
179
+ * 该方法用于从API导出数据,并将其作为Blob对象返回。
180
+ * 如果提供了查询参数,则会将其作为请求体发送到API。
181
+ * 最后,返回一个包含导出结果的Promise。
182
+ * @param {T | Reactive<T>} [query] - 查询参数,可以是普通对象或Vue的响应式对象。
183
+ * @returns {Promise<any>} - 返回一个包含导出结果的Promise。
184
+ */
185
+ export(query?: T | Reactive<T>): httpRequest.HttpRequestPromise<void>;
186
+ /**
187
+ * 获取数据对象的ID。
188
+ * @param {T} data - 包含ID的数据对象。
189
+ * @returns {any} - 返回数据对象的ID。
190
+ */
191
+ protected getId(data: T): never;
192
+ /**
193
+ * 获取目标类的主键。
194
+ * @returns {string} - 返回主键的属性名。
195
+ * @throws {Error} - 如果主键未定义,则抛出错误。
196
+ */
197
+ protected getPrimaryKey(): never;
198
+ /**
199
+ * 构造函数,用于初始化 CurdApi 实例。
200
+ * @param {Object} options - 构造函数的参数对象。
201
+ * @param {T} options.TargetPrototye - 目标原型,即要操作的数据类型。
202
+ * @param {string} options.basePath - API 的基础路径。
203
+ * @param {CurdApi<T, P>['treeKey']} [options.treeKey] - 树形结构的键配置。
204
+ * @param {P} [options.PaginationResponseClass] - 分页响应的类。
205
+ * @param {boolean} [options.saveWithUploadFile] - 是否使用文件上传保存数据。
206
+ */
207
+ constructor(options: {
208
+ TargetPrototye: T;
209
+ basePath: string;
210
+ treeKey?: CurdApi<T, P>['treeKey'];
211
+ PaginationResponseClass?: P;
212
+ saveWithUploadFile?: boolean;
213
+ });
214
+ /**
215
+ * 从API响应中下载文件。
216
+ * 这个静态方法会从API响应中提取文件名,并创建一个下载链接,然后模拟点击下载链接来下载文件。
217
+ * @param {AxiosResponse} response - 包含文件数据的API响应。
218
+ * @returns {void}
219
+ */
220
+ static downloadReponse(response: AxiosResponse): void;
221
+ }
@@ -0,0 +1,55 @@
1
+ import { httpRequest } from '../../utils';
2
+ import { LoadUtilResponse } from '../loadUtil';
3
+ /**
4
+ * 定义一个接口,描述请求工具的方法。
5
+ * 这个接口包含取消请求和发送请求的方法。
6
+ * @interface RequestUtil
7
+ */
8
+ interface RequestUtil {
9
+ /**
10
+ * 定义一个方法,用于取消当前的请求。
11
+ * 这个方法会检查是否存在当前的请求对象,如果存在,则取消请求并将请求对象重置为 undefined。
12
+ * @method abort
13
+ * @returns {void}
14
+ * @description 这个方法通常在加载新的数据之前调用,以避免重复请求。
15
+ */
16
+ abort(): void;
17
+ /**
18
+ * 定义一个方法,用于发送请求并处理响应。
19
+ * 这个方法会发送一个 HTTP 请求,并根据请求的结果调用相应的回调函数。
20
+ * @method requestData
21
+ * @param {T} httpRequest - 一个继承自 httpRequest.HttpRequestPromise 的泛型类型,表示 HTTP 请求对象。
22
+ * @param {Function} [final] - 一个可选的函数,用于在请求完成后执行最终操作。
23
+ * @returns {Promise<T extends httpRequest.HttpRequestPromise<infer R> ? R : never>} - 一个返回值为请求结果的 Promise。
24
+ * @description 这个方法会在请求开始时调用 abort 方法,以取消之前的请求。
25
+ * @description 它会在请求过程中更新加载状态,并在请求完成后重置加载状态。
26
+ * @description 如果请求成功,它会返回请求的结果。
27
+ * @description 如果请求失败,它会抛出错误。
28
+ * @description 在请求完成后,它会调用 final 方法,并传递一个布尔值表示请求是否被取消。
29
+ */
30
+ requestData<T extends httpRequest.HttpRequestPromise>(httpRequest: T, final?: (isAbort: boolean) => void): Promise<T extends httpRequest.HttpRequestPromise<infer R> ? R : never>;
31
+ }
32
+ /**
33
+ * 定义一个类型别名,用于描述请求工具的响应。
34
+ * 这个类型别名根据泛型参数 E 的值来决定是否包含加载状态的方法。
35
+ * @type {RequestUtilResponse}
36
+ * @description 如果 E 为 true,则返回一个包含加载状态方法的对象。
37
+ * @description 如果 E 为 false,则返回一个只包含请求工具方法的对象。
38
+ */
39
+ export type RequestUtilResponse<T extends boolean = true> = T extends false ? RequestUtil : LoadUtilResponse & RequestUtil;
40
+ /**
41
+ * 定义一个自定义 Hook,用于创建请求工具。
42
+ * 这个 Hook 会返回一个对象,包含取消请求和发送请求的方法。
43
+ * @param {boolean} [endableLoadStatus] - 一个可选的布尔值,用于启用加载状态。
44
+ * @returns {RequestUtilResponse<E>} - 一个返回值为请求工具响应的对象。
45
+ * @description 这个 Hook 会根据 endableLoadStatus 的值来决定是否启用加载状态。
46
+ * @description 如果 endableLoadStatus 为 true,则返回一个包含加载状态方法的对象。
47
+ * @description 如果 endableLoadStatus 为 false,则返回一个只包含请求工具方法的对象。
48
+ * @description 这个 Hook 会在请求开始时调用 abort 方法,以取消之前的请求。
49
+ * @description 它会在请求过程中更新加载状态,并在请求完成后重置加载状态。
50
+ * @description 如果请求成功,它会返回请求的结果。
51
+ * @description 如果请求失败,它会抛出错误。
52
+ * @description 在请求完成后,它会调用 final 方法,并传递一个布尔值表示请求是否被取消。
53
+ */
54
+ export declare const useRequestUtil: <E extends boolean = true>(endableLoadStatus?: E) => RequestUtilResponse<E>;
55
+ export {};