zzz-pc-view 0.0.22 → 0.0.25
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { httpRequest,
|
|
2
|
+
import { httpRequest, KeyMatch } from '../../utils';
|
|
3
3
|
import { TypeWithPrototype, TypeWithPrototypeWithoutNew } from '../DeclareType';
|
|
4
4
|
import { Reactive } from 'vue';
|
|
5
5
|
/**
|
|
@@ -78,15 +78,15 @@ export interface PaginationResponse<T> {
|
|
|
78
78
|
* 定义分页响应构造函数的接口。
|
|
79
79
|
* @template T - 响应中列表项的类型。
|
|
80
80
|
*/
|
|
81
|
-
export interface PaginationResponseConstructor<T> extends TypeWithPrototypeWithoutNew {
|
|
82
|
-
new (data:
|
|
81
|
+
export interface PaginationResponseConstructor<T, P extends PaginationResponse<T> = PaginationResponse<T>> extends TypeWithPrototypeWithoutNew {
|
|
82
|
+
new (data: any): P;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 定义 CURD(创建、读取、更新、删除)操作的 API 类。
|
|
86
86
|
* @template T - 表示操作的数据类型,默认为 `object`。
|
|
87
87
|
* @template P - 表示分页响应的构造函数类型,默认为 `PaginationResponseConstructor<T>`。
|
|
88
88
|
*/
|
|
89
|
-
export declare class CurdApi<T extends object = object, P extends
|
|
89
|
+
export declare class CurdApi<T extends object = object, P extends PaginationResponse<T> = PaginationResponse<T>> {
|
|
90
90
|
/**
|
|
91
91
|
* 目标类的构造函数。
|
|
92
92
|
* @protected
|
|
@@ -122,7 +122,7 @@ export declare class CurdApi<T extends object = object, P extends PaginationResp
|
|
|
122
122
|
* @protected
|
|
123
123
|
* @type {P}
|
|
124
124
|
*/
|
|
125
|
-
protected readonly PaginationResponseClass?: P
|
|
125
|
+
protected readonly PaginationResponseClass?: PaginationResponseConstructor<T, P>;
|
|
126
126
|
get hasServerPagination(): boolean;
|
|
127
127
|
/**
|
|
128
128
|
* 是否使用文件上传保存数据。
|
|
@@ -144,9 +144,9 @@ export declare class CurdApi<T extends object = object, P extends PaginationResp
|
|
|
144
144
|
* 分页获取列表数据。
|
|
145
145
|
* @param {object} pagination - 分页参数。
|
|
146
146
|
* @param {T | Reactive<T>} [query] - 查询参数。
|
|
147
|
-
* @returns {Promise<
|
|
147
|
+
* @returns {Promise<P>} - 返回一个包含分页数据的 Promise。
|
|
148
148
|
*/
|
|
149
|
-
getListByPage(pagination: object, query?: T | Reactive<T>): httpRequest.HttpRequestPromise<Awaited<
|
|
149
|
+
getListByPage(pagination: object, query?: T | Reactive<T>): httpRequest.HttpRequestPromise<Awaited<P>>;
|
|
150
150
|
/**
|
|
151
151
|
* 获取指定数据的详细信息。
|
|
152
152
|
* 这个方法会根据传入的数据对象的ID,从API获取该数据的详细信息,并将其绑定到目标类。
|
|
@@ -208,7 +208,7 @@ export declare class CurdApi<T extends object = object, P extends PaginationResp
|
|
|
208
208
|
TargetPrototye: T;
|
|
209
209
|
basePath: string;
|
|
210
210
|
treeKey?: CurdApi<T, P>['treeKey'];
|
|
211
|
-
PaginationResponseClass?: P
|
|
211
|
+
PaginationResponseClass?: PaginationResponseConstructor<T, P>;
|
|
212
212
|
saveWithUploadFile?: boolean;
|
|
213
213
|
});
|
|
214
214
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { httpRequest, CombineClass, CombineInstanceType, KeyMatch, WithoutFirst } from '../../utils';
|
|
2
2
|
import { BasePropertyConfig, ComponentProps, EventHandlerMap, TypeWithPrototype } from '../DeclareType';
|
|
3
3
|
import { FilterHandler } from '../FilterKey';
|
|
4
|
-
import { EditTypeEnum, CurdApi, EditType,
|
|
4
|
+
import { EditTypeEnum, CurdApi, EditType, PaginationResponse } from './CurdApi';
|
|
5
5
|
import { Config as PrimaryKeyConfig } from './../PrimaryKey';
|
|
6
6
|
import { Config as NameKeyConfig } from './../NameKey';
|
|
7
7
|
import { RequestUtilResponse } from '../useRequestUtil';
|
|
@@ -131,11 +131,11 @@ interface FormParam extends ComponentParam {
|
|
|
131
131
|
* @property {PaginationRequest} [pagination] - 可选的分页请求。
|
|
132
132
|
* @property {(this: CurdHandler<T>) => { tableParam?: ComponentParam; formParam?: FormParam }} [componentCreator] - 可选的组件创建器函数,用于创建表格和表单的参数。
|
|
133
133
|
*/
|
|
134
|
-
export interface CurdHandlerParam<T extends object = object> {
|
|
134
|
+
export interface CurdHandlerParam<T extends object = object, P extends PaginationResponse<T> = PaginationResponse<T>> {
|
|
135
135
|
label: string;
|
|
136
|
-
api: CurdApi<T>;
|
|
136
|
+
api: CurdApi<T, P>;
|
|
137
137
|
pagination?: PaginationRequest;
|
|
138
|
-
componentCreator?(this: CurdHandler<T>): {
|
|
138
|
+
componentCreator?(this: CurdHandler<T, P>): {
|
|
139
139
|
tableParam?: TableParam;
|
|
140
140
|
formParam?: FormParam;
|
|
141
141
|
};
|
|
@@ -185,11 +185,11 @@ export declare enum CreateTypeEnum {
|
|
|
185
185
|
* @property {new (createType: CreateTypeEnum, ...args: any[]): T} - 一个新的构造函数,接受一个 CreateTypeEnum 类型的参数和任意数量的参数,并返回一个 T 类型的实例。
|
|
186
186
|
* @property {CurdHandler<T>} [classCurdKey] - 一个可选的属性,用于存储 CurdHandler 实例。
|
|
187
187
|
*/
|
|
188
|
-
export interface CurdModelConstructor<T extends object = object> extends TypeWithPrototype, CombineClass {
|
|
188
|
+
export interface CurdModelConstructor<T extends object = object, P extends PaginationResponse<T> = PaginationResponse<T>> extends TypeWithPrototype, CombineClass {
|
|
189
189
|
new (createType: CreateTypeEnum, ...args: any[]): T;
|
|
190
|
-
[classCurdKey]?: CurdHandler<T>;
|
|
190
|
+
[classCurdKey]?: CurdHandler<T, P>;
|
|
191
191
|
}
|
|
192
|
-
export declare abstract class CurdHandler<T extends object = object> extends FilterHandler<T> {
|
|
192
|
+
export declare abstract class CurdHandler<T extends object = object, P extends PaginationResponse<T> = PaginationResponse<T>> extends FilterHandler<T> {
|
|
193
193
|
readonly curdTargetPrototype: T;
|
|
194
194
|
/**
|
|
195
195
|
* 定义一个只读属性,用于存储 CURD 操作的目标模型构造函数。
|
|
@@ -198,7 +198,7 @@ export declare abstract class CurdHandler<T extends object = object> extends Fil
|
|
|
198
198
|
* @description 这个属性是只读的,意味着它不能被直接修改。
|
|
199
199
|
* @description 它会在组件初始化时被设置,并且在组件的整个生命周期中保持不变。
|
|
200
200
|
*/
|
|
201
|
-
protected readonly CurdTarget: CurdModelConstructor<T>;
|
|
201
|
+
protected readonly CurdTarget: CurdModelConstructor<T, P>;
|
|
202
202
|
/**
|
|
203
203
|
* 定义一个只读属性,用于存储表单项的标签。
|
|
204
204
|
* 这个属性将用于在组件中显示表单项的标签。
|
|
@@ -306,7 +306,7 @@ export declare abstract class CurdHandler<T extends object = object> extends Fil
|
|
|
306
306
|
* @description 这个属性是只读的,意味着它不能被直接修改。
|
|
307
307
|
* @description 它会在组件初始化时被设置,并且在组件的整个生命周期中保持不变。
|
|
308
308
|
*/
|
|
309
|
-
protected readonly api: CurdApi<T,
|
|
309
|
+
protected readonly api: CurdApi<T, P>;
|
|
310
310
|
/**
|
|
311
311
|
* 定义一个可选的只读属性,用于存储分页配置。
|
|
312
312
|
* 这个属性将用于在组件中控制分页行为。
|
|
@@ -725,7 +725,7 @@ export declare abstract class CurdHandler<T extends object = object> extends Fil
|
|
|
725
725
|
* @param {CurdHandlerParam<T>} param - 包含API和分页配置的参数对象。
|
|
726
726
|
* @param {...WithoutFirst<ConstructorParameters<typeof FilterHandler<T>>>} args - 传递给父类构造函数的参数。
|
|
727
727
|
*/
|
|
728
|
-
constructor(curdTargetPrototype: T, param: CurdHandlerParam<T>, ...args: WithoutFirst<ConstructorParameters<typeof FilterHandler<T>>>);
|
|
728
|
+
constructor(curdTargetPrototype: T, param: CurdHandlerParam<T, P>, ...args: WithoutFirst<ConstructorParameters<typeof FilterHandler<T>>>);
|
|
729
729
|
/**
|
|
730
730
|
* 根据目标对象的原型获取对应的 CURD 实例。
|
|
731
731
|
* 这个静态方法会通过目标对象的构造函数来获取其原型上的 CURD 实例。
|
|
@@ -733,7 +733,7 @@ export declare abstract class CurdHandler<T extends object = object> extends Fil
|
|
|
733
733
|
* @returns {CurdHandler<T> | undefined} - 返回 CURD 实例,如果不存在则返回 undefined。
|
|
734
734
|
* @template T - 目标对象的类型。
|
|
735
735
|
*/
|
|
736
|
-
static getCurdInstance<T extends object>(curdTargetPrototype: T): CurdHandler<T
|
|
736
|
+
static getCurdInstance<T extends object>(curdTargetPrototype: T): CurdHandler<T, PaginationResponse<T>> | undefined;
|
|
737
737
|
}
|
|
738
738
|
/**
|
|
739
739
|
* 定义一个装饰器,用于设置对象原型的配置。
|
package/src/index.es.js
CHANGED
|
@@ -3063,7 +3063,7 @@ class CurdApi {
|
|
|
3063
3063
|
* 分页获取列表数据。
|
|
3064
3064
|
* @param {object} pagination - 分页参数。
|
|
3065
3065
|
* @param {T | Reactive<T>} [query] - 查询参数。
|
|
3066
|
-
* @returns {Promise<
|
|
3066
|
+
* @returns {Promise<P>} - 返回一个包含分页数据的 Promise。
|
|
3067
3067
|
*/
|
|
3068
3068
|
getListByPage(pagination, query) {
|
|
3069
3069
|
const { PaginationResponseClass } = this;
|