@airpower/web 0.2.27 → 0.2.29
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/dist/decorator/@Field/Field.d.ts +11 -11
- package/dist/decorator/@Form/Form.d.ts +10 -10
- package/dist/decorator/@Form/IFormField.d.ts +0 -1
- package/dist/decorator/@Model/Model.d.ts +7 -6
- package/dist/decorator/@Search/Search.d.ts +10 -10
- package/dist/decorator/@Table/Table.d.ts +10 -10
- package/dist/decorator/@Table/type.d.ts +9 -0
- package/dist/main.js +146 -153
- package/package.json +2 -2
- package/dist/tests/main.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnumKey } from '@airpower/enum/dist/enum/type';
|
|
2
|
-
import {
|
|
2
|
+
import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
|
|
3
3
|
import { WebEnumConstructor } from '../../enum/type';
|
|
4
4
|
import { RootModel } from '../../model/RootModel';
|
|
5
5
|
import { IFieldConfig } from './IFieldConfig';
|
|
@@ -8,23 +8,23 @@ import { FieldConfigOptionalKey } from './type';
|
|
|
8
8
|
* ### 为属性标记配置
|
|
9
9
|
* @param config 配置项
|
|
10
10
|
*/
|
|
11
|
-
export declare function Field<K extends EnumKey = EnumKey>(config?: FieldConfigOptionalKey<IFieldConfig<K>>): (
|
|
11
|
+
export declare function Field<M extends RootModel, K extends EnumKey = EnumKey>(config?: FieldConfigOptionalKey<IFieldConfig<K>>): (instance: M, field: keyof M) => void;
|
|
12
12
|
/**
|
|
13
13
|
* ### 获取属性的配置
|
|
14
14
|
* @returns 配置对象
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
15
|
+
* @param Class 目标类
|
|
16
|
+
* @param field 属性名
|
|
17
17
|
*/
|
|
18
|
-
export declare function getFieldConfig<M extends RootModel, K extends EnumKey = EnumKey>(
|
|
18
|
+
export declare function getFieldConfig<M extends RootModel, K extends EnumKey = EnumKey>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFieldConfig<K>;
|
|
19
19
|
/**
|
|
20
20
|
* ### 获取属性的枚举字典
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
21
|
+
* @param Class 目标类
|
|
22
|
+
* @param field 属性名
|
|
23
23
|
*/
|
|
24
|
-
export declare function getDictionary<M extends RootModel, K extends EnumKey = EnumKey>(
|
|
24
|
+
export declare function getDictionary<M extends RootModel, K extends EnumKey = EnumKey>(Class: ITransformerConstructor<M>, field: TransformerField<M>): WebEnumConstructor<K> | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* ### 获取属性的标题
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
27
|
+
* @param Class 目标类
|
|
28
|
+
* @param field string 属性名
|
|
29
29
|
*/
|
|
30
|
-
export declare function getFieldLabel<M extends RootModel>(
|
|
30
|
+
export declare function getFieldLabel<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
|
|
2
2
|
import { RootModel } from '../../model/RootModel';
|
|
3
3
|
import { FieldConfigOptionalKey } from '../@Field/type';
|
|
4
4
|
import { IFormField } from './IFormField';
|
|
@@ -6,21 +6,21 @@ import { IFormField } from './IFormField';
|
|
|
6
6
|
* ### 标记该字段可用于表单配置
|
|
7
7
|
* @param config 配置项
|
|
8
8
|
*/
|
|
9
|
-
export declare function Form(config?: FieldConfigOptionalKey<IFormField>): (
|
|
9
|
+
export declare function Form<M extends RootModel>(config?: FieldConfigOptionalKey<IFormField>): (instance: M, key: keyof M) => void;
|
|
10
10
|
/**
|
|
11
11
|
* ### 获取对象某个字段标记的表单配置项
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
12
|
+
* @param Class 目标类
|
|
13
|
+
* @param field 属性名
|
|
14
14
|
*/
|
|
15
|
-
export declare function getFormConfig<M extends RootModel>(
|
|
15
|
+
export declare function getFormConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFormField;
|
|
16
16
|
/**
|
|
17
17
|
* ### 获取标记了表单配置的字段列表
|
|
18
|
-
* @param
|
|
18
|
+
* @param Class 目标类
|
|
19
19
|
*/
|
|
20
|
-
export declare function getFormFieldList<M extends RootModel>(
|
|
20
|
+
export declare function getFormFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
|
|
21
21
|
/**
|
|
22
22
|
* ### 获取指定类的表单字段配置项列表
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
23
|
+
* @param Class 目标类
|
|
24
|
+
* @param fieldList 选择字段列表
|
|
25
25
|
*/
|
|
26
|
-
export declare function getFormConfigList<M extends RootModel>(
|
|
26
|
+
export declare function getFormConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): IFormField[];
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITransformerConstructor } from '@airpower/transformer';
|
|
2
|
+
import { RootModel } from '../../model/RootModel';
|
|
2
3
|
import { IModelConfig } from './IModelConfig';
|
|
3
4
|
/**
|
|
4
5
|
* ### 为模型类标记配置项
|
|
5
6
|
* @param config 配置项
|
|
6
7
|
*/
|
|
7
|
-
export declare function Model<T extends IModelConfig = IModelConfig>(config?: T): (
|
|
8
|
+
export declare function Model<M extends RootModel, T extends IModelConfig = IModelConfig>(config?: T): (Class: ITransformerConstructor<M>) => void;
|
|
8
9
|
/**
|
|
9
10
|
* ### 获取模型类配置项
|
|
10
|
-
* @param
|
|
11
|
+
* @param Class 目标类
|
|
11
12
|
*/
|
|
12
|
-
export declare function getModelConfig<
|
|
13
|
+
export declare function getModelConfig<M extends RootModel, T extends IModelConfig = IModelConfig>(Class: ITransformerConstructor<M>): T;
|
|
13
14
|
/**
|
|
14
15
|
* ### 获取模型类名称
|
|
15
|
-
* @param
|
|
16
|
+
* @param Class 目标类
|
|
16
17
|
*/
|
|
17
|
-
export declare function getModelName<
|
|
18
|
+
export declare function getModelName<M extends RootModel>(Class: ITransformerConstructor<M>): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
|
|
2
2
|
import { RootModel } from '../../model/RootModel';
|
|
3
3
|
import { FieldConfigOptionalKey } from '../@Field/type';
|
|
4
4
|
import { ISearchField } from './ISearchField';
|
|
@@ -6,21 +6,21 @@ import { ISearchField } from './ISearchField';
|
|
|
6
6
|
* ### 标记该字段可用于表单配置
|
|
7
7
|
* @param config 配置项
|
|
8
8
|
*/
|
|
9
|
-
export declare function Search(config?: FieldConfigOptionalKey<ISearchField>): (
|
|
9
|
+
export declare function Search<M extends RootModel>(config?: FieldConfigOptionalKey<ISearchField>): (instance: M, field: keyof M) => void;
|
|
10
10
|
/**
|
|
11
11
|
* ### 获取对象某个字段标记的搜索配置项
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
12
|
+
* @param Class 目标类
|
|
13
|
+
* @param field 属性名
|
|
14
14
|
*/
|
|
15
|
-
export declare function getSearchConfig<M extends RootModel>(
|
|
15
|
+
export declare function getSearchConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ISearchField;
|
|
16
16
|
/**
|
|
17
17
|
* ### 获取标记了搜索配置的字段列表
|
|
18
|
-
* @param
|
|
18
|
+
* @param Class 目标类
|
|
19
19
|
*/
|
|
20
|
-
export declare function getSearchFieldList<M extends RootModel>(
|
|
20
|
+
export declare function getSearchFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
|
|
21
21
|
/**
|
|
22
22
|
* ### 获取指定类的搜索字段配置项列表
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
23
|
+
* @param Class 目标类
|
|
24
|
+
* @param fieldList 选择字段列表
|
|
25
25
|
*/
|
|
26
|
-
export declare function getSearchConfigList<M extends RootModel>(
|
|
26
|
+
export declare function getSearchConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): ISearchField[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
|
|
2
2
|
import { RootModel } from '../../model/RootModel';
|
|
3
3
|
import { FieldConfigOptionalKey } from '../@Field/type';
|
|
4
4
|
import { ITableColumn } from './ITableColumn';
|
|
@@ -6,21 +6,21 @@ import { ITableColumn } from './ITableColumn';
|
|
|
6
6
|
* ### 为属性标记是表格字段
|
|
7
7
|
* @param config 表格列的配置
|
|
8
8
|
*/
|
|
9
|
-
export declare function Table(config?: FieldConfigOptionalKey<ITableColumn>): (
|
|
9
|
+
export declare function Table<M extends RootModel>(config?: FieldConfigOptionalKey<ITableColumn>): (instance: M, field: keyof M) => void;
|
|
10
10
|
/**
|
|
11
11
|
* ### 获取对象的属性表格的配置
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
12
|
+
* @param Class 目标类
|
|
13
|
+
* @param field 属性名
|
|
14
14
|
*/
|
|
15
|
-
export declare function getTableConfig<M extends RootModel>(
|
|
15
|
+
export declare function getTableConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ITableColumn;
|
|
16
16
|
/**
|
|
17
17
|
* ### 获取标记了表格配置的字段列表
|
|
18
|
-
* @param
|
|
18
|
+
* @param Class 目标类
|
|
19
19
|
*/
|
|
20
|
-
export declare function getTableFieldList<M extends RootModel>(
|
|
20
|
+
export declare function getTableFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
|
|
21
21
|
/**
|
|
22
22
|
* ### 获取字段标记的表格字段配置列表
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
23
|
+
* @param Class 目标类
|
|
24
|
+
* @param fieldList 字段列表
|
|
25
25
|
*/
|
|
26
|
-
export declare function getTableConfigList<M extends RootModel>(
|
|
26
|
+
export declare function getTableConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): Array<ITableColumn>;
|
package/dist/main.js
CHANGED
|
@@ -685,117 +685,110 @@ __publicField(WebConfig, "treeProps", {
|
|
|
685
685
|
children: "children",
|
|
686
686
|
label: "name"
|
|
687
687
|
});
|
|
688
|
-
var __defProp$7 = Object.defineProperty;
|
|
689
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
690
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "", value);
|
|
691
688
|
class DecoratorUtil {
|
|
692
689
|
/**
|
|
693
690
|
* ### 设置一个类配置项
|
|
694
|
-
* @param
|
|
691
|
+
* @param Class 目标类
|
|
695
692
|
* @param classConfigKey 配置项索引键值
|
|
696
693
|
* @param classConfig 配置的参数
|
|
697
694
|
*/
|
|
698
|
-
static setClassConfig(
|
|
699
|
-
this.setProperty(
|
|
695
|
+
static setClassConfig(Class, classConfigKey, classConfig) {
|
|
696
|
+
this.setProperty(Class.prototype, classConfigKey, classConfig);
|
|
700
697
|
}
|
|
701
698
|
/**
|
|
702
699
|
* ### 递归获取指定类的配置项
|
|
703
|
-
* @param
|
|
700
|
+
* @param Class 目标类
|
|
704
701
|
* @param classConfigKey 配置项的Key
|
|
705
702
|
* @param defaultValue `可选` 类装饰器请传入配置项实例
|
|
706
703
|
* @param isObject `可选` 是否是对象配置
|
|
707
704
|
*/
|
|
708
|
-
static getClassConfig(
|
|
709
|
-
let classConfig = Reflect.get(
|
|
705
|
+
static getClassConfig(Class, classConfigKey, defaultValue = void 0, isObject = false) {
|
|
706
|
+
let classConfig = Reflect.get(Class, classConfigKey);
|
|
710
707
|
if (!isObject) {
|
|
711
708
|
if (classConfig) {
|
|
712
709
|
return classConfig;
|
|
713
710
|
}
|
|
714
|
-
const
|
|
715
|
-
if (!
|
|
711
|
+
const SuperClass2 = Reflect.getPrototypeOf(Class);
|
|
712
|
+
if (!SuperClass2 || SuperClass2.prototype.constructor.name === Transformer.name) {
|
|
716
713
|
return void 0;
|
|
717
714
|
}
|
|
718
|
-
return this.getClassConfig(
|
|
715
|
+
return this.getClassConfig(SuperClass2, classConfigKey);
|
|
719
716
|
}
|
|
720
717
|
classConfig = classConfig || {};
|
|
721
|
-
const
|
|
722
|
-
if (!
|
|
718
|
+
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
719
|
+
if (!SuperClass || SuperClass.constructor.name === Transformer.name) {
|
|
723
720
|
return defaultValue;
|
|
724
721
|
}
|
|
725
722
|
return {
|
|
726
|
-
...this.getClassConfig(
|
|
723
|
+
...this.getClassConfig(SuperClass, classConfigKey, defaultValue, isObject),
|
|
727
724
|
...classConfig
|
|
728
725
|
};
|
|
729
726
|
}
|
|
730
727
|
/**
|
|
731
728
|
* ### 设置一个属性配置项
|
|
732
|
-
* @param
|
|
733
|
-
* @param
|
|
729
|
+
* @param instance 目标实例
|
|
730
|
+
* @param field 属性
|
|
734
731
|
* @param fieldConfigKey 配置项索引键值
|
|
735
732
|
* @param fieldConfig 配置的参数
|
|
736
733
|
* @param fieldListKey `可选` 类配置项列表索引值
|
|
737
734
|
*/
|
|
738
|
-
static setFieldConfig(
|
|
735
|
+
static setFieldConfig(instance, field, fieldConfigKey, fieldConfig, fieldListKey) {
|
|
739
736
|
if (fieldListKey) {
|
|
740
|
-
this.addFieldDecoratorKey(
|
|
737
|
+
this.addFieldDecoratorKey(instance, field, fieldListKey);
|
|
741
738
|
}
|
|
742
|
-
this.setProperty(
|
|
739
|
+
this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
|
|
743
740
|
}
|
|
744
741
|
/**
|
|
745
742
|
* ### 获取类指定属性的指定类型的配置
|
|
746
|
-
* @param
|
|
747
|
-
* @param
|
|
743
|
+
* @param Class 目标类
|
|
744
|
+
* @param field 属性
|
|
748
745
|
* @param fieldConfigKey FieldConfigKey
|
|
749
746
|
* @param isObject `可选` 是否对象配置
|
|
750
747
|
*/
|
|
751
|
-
static getFieldConfig(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
let fieldConfig = Reflect.get(target, `${fieldConfigKey}[${key}]`);
|
|
748
|
+
static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
|
|
749
|
+
let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
|
|
750
|
+
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
756
751
|
if (!isObject) {
|
|
757
752
|
if (fieldConfig !== void 0) {
|
|
758
753
|
return fieldConfig;
|
|
759
754
|
}
|
|
760
|
-
|
|
761
|
-
if (!superClass2 || superClass2.constructor.name === Transformer.name) {
|
|
755
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
762
756
|
return void 0;
|
|
763
757
|
}
|
|
764
|
-
return this.getFieldConfig(
|
|
758
|
+
return this.getFieldConfig(SuperClass, field, fieldConfigKey);
|
|
765
759
|
}
|
|
766
760
|
fieldConfig = fieldConfig || {};
|
|
767
|
-
|
|
768
|
-
if (!superClass || superClass.constructor.name === Transformer.name) {
|
|
761
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
769
762
|
return {};
|
|
770
763
|
}
|
|
771
764
|
return {
|
|
772
|
-
...this.getFieldConfig(
|
|
765
|
+
...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
|
|
773
766
|
...fieldConfig
|
|
774
767
|
};
|
|
775
768
|
}
|
|
776
769
|
/**
|
|
777
770
|
* ### 获取类标记了装饰器的属性列表
|
|
778
|
-
* @param
|
|
771
|
+
* @param Class 目标类
|
|
779
772
|
* @param fieldConfigKey FieldConfigKey
|
|
780
773
|
* @param list `递归参数` 无需传入
|
|
781
774
|
*/
|
|
782
|
-
static getFieldList(
|
|
783
|
-
const fieldList = Reflect.get(
|
|
775
|
+
static getFieldList(Class, fieldConfigKey, list = []) {
|
|
776
|
+
const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
|
|
784
777
|
fieldList.forEach((item) => list.includes(item) || list.push(item));
|
|
785
|
-
const
|
|
786
|
-
if (!
|
|
778
|
+
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
779
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
787
780
|
return list;
|
|
788
781
|
}
|
|
789
|
-
return this.getFieldList(
|
|
782
|
+
return this.getFieldList(SuperClass, fieldConfigKey, list);
|
|
790
783
|
}
|
|
791
784
|
/**
|
|
792
785
|
* ### 反射添加属性
|
|
793
|
-
* @param
|
|
794
|
-
* @param
|
|
786
|
+
* @param instance 目标属性
|
|
787
|
+
* @param propertyKey 配置key
|
|
795
788
|
* @param value 配置值
|
|
796
789
|
*/
|
|
797
|
-
static setProperty(
|
|
798
|
-
Reflect.defineProperty(
|
|
790
|
+
static setProperty(instance, propertyKey, value) {
|
|
791
|
+
Reflect.defineProperty(instance, propertyKey, {
|
|
799
792
|
enumerable: false,
|
|
800
793
|
value,
|
|
801
794
|
writable: false,
|
|
@@ -804,17 +797,16 @@ class DecoratorUtil {
|
|
|
804
797
|
}
|
|
805
798
|
/**
|
|
806
799
|
* ### 设置一个属性的包含装饰器索引
|
|
807
|
-
* @param
|
|
808
|
-
* @param
|
|
809
|
-
* @param
|
|
800
|
+
* @param instance 目标类
|
|
801
|
+
* @param field 属性
|
|
802
|
+
* @param propertyKey 类配置项列表索引值
|
|
810
803
|
*/
|
|
811
|
-
static addFieldDecoratorKey(
|
|
812
|
-
const list = Reflect.get(
|
|
813
|
-
list.push(
|
|
814
|
-
this.setProperty(
|
|
804
|
+
static addFieldDecoratorKey(instance, field, propertyKey) {
|
|
805
|
+
const list = Reflect.get(instance, propertyKey) || [];
|
|
806
|
+
list.push(field);
|
|
807
|
+
this.setProperty(instance, propertyKey, list);
|
|
815
808
|
}
|
|
816
809
|
}
|
|
817
|
-
__publicField$3(DecoratorUtil, "DecoratorKeyPrefix", "[AirPower]");
|
|
818
810
|
class Transformer {
|
|
819
811
|
/**
|
|
820
812
|
* ### 从 `JSON` 转换到当前类的对象
|
|
@@ -862,10 +854,10 @@ class Transformer {
|
|
|
862
854
|
const instance = new Class();
|
|
863
855
|
const fieldList = Object.keys(instance);
|
|
864
856
|
for (const field of fieldList) {
|
|
865
|
-
const jsonKey = this.getJsonKey(
|
|
857
|
+
const jsonKey = this.getJsonKey(Class, field);
|
|
866
858
|
const fieldData = json[jsonKey];
|
|
867
859
|
instance[field] = fieldData;
|
|
868
|
-
const toClass = getToClass(
|
|
860
|
+
const toClass = getToClass(Class, field);
|
|
869
861
|
if (toClass !== void 0) {
|
|
870
862
|
try {
|
|
871
863
|
;
|
|
@@ -875,8 +867,8 @@ class Transformer {
|
|
|
875
867
|
continue;
|
|
876
868
|
}
|
|
877
869
|
}
|
|
878
|
-
const FieldTypeClass = getType(
|
|
879
|
-
const isArray2 = getArray(
|
|
870
|
+
const FieldTypeClass = getType(Class, field);
|
|
871
|
+
const isArray2 = getArray(Class, field);
|
|
880
872
|
if (isArray2) {
|
|
881
873
|
const fieldValueList = [];
|
|
882
874
|
if (typeof fieldData === "object" && Array.isArray(fieldData)) {
|
|
@@ -910,7 +902,7 @@ class Transformer {
|
|
|
910
902
|
}
|
|
911
903
|
}
|
|
912
904
|
for (const fieldKey of fieldList) {
|
|
913
|
-
const alias = getAlias(
|
|
905
|
+
const alias = getAlias(Class, fieldKey) || fieldKey;
|
|
914
906
|
if (alias === fieldKey) {
|
|
915
907
|
continue;
|
|
916
908
|
}
|
|
@@ -920,19 +912,19 @@ class Transformer {
|
|
|
920
912
|
}
|
|
921
913
|
/**
|
|
922
914
|
* ### 获取 JSON 的 key
|
|
923
|
-
* @param
|
|
915
|
+
* @param Class 目标实例
|
|
924
916
|
* @param field 属性 key
|
|
925
917
|
*/
|
|
926
|
-
static getJsonKey(
|
|
927
|
-
const alias = getAlias(
|
|
918
|
+
static getJsonKey(Class, field) {
|
|
919
|
+
const alias = getAlias(Class, field);
|
|
928
920
|
if (alias) {
|
|
929
921
|
return alias;
|
|
930
922
|
}
|
|
931
|
-
const prefix = getPrefix(
|
|
923
|
+
const prefix = getPrefix(Class);
|
|
932
924
|
if (!prefix) {
|
|
933
925
|
return field;
|
|
934
926
|
}
|
|
935
|
-
const ignorePrefix = getIgnorePrefix(
|
|
927
|
+
const ignorePrefix = getIgnorePrefix(Class, field);
|
|
936
928
|
if (!ignorePrefix) {
|
|
937
929
|
return prefix + field;
|
|
938
930
|
}
|
|
@@ -984,6 +976,7 @@ class Transformer {
|
|
|
984
976
|
* 会自动进行数据别名转换
|
|
985
977
|
*/
|
|
986
978
|
toJson() {
|
|
979
|
+
const Class = this.constructor;
|
|
987
980
|
const fieldList = Object.keys(this);
|
|
988
981
|
const json = {};
|
|
989
982
|
for (const field of fieldList) {
|
|
@@ -991,9 +984,9 @@ class Transformer {
|
|
|
991
984
|
if (data === null || data === void 0) {
|
|
992
985
|
continue;
|
|
993
986
|
}
|
|
994
|
-
const jsonKey = Transformer.getJsonKey(
|
|
987
|
+
const jsonKey = Transformer.getJsonKey(Class, field);
|
|
995
988
|
json[jsonKey] = data;
|
|
996
|
-
const toJson = getToJson(
|
|
989
|
+
const toJson = getToJson(Class, field);
|
|
997
990
|
if (toJson !== void 0) {
|
|
998
991
|
try {
|
|
999
992
|
json[jsonKey] = toJson(this);
|
|
@@ -1021,66 +1014,68 @@ class Transformer {
|
|
|
1021
1014
|
return json;
|
|
1022
1015
|
}
|
|
1023
1016
|
}
|
|
1024
|
-
const KEY$5 =
|
|
1017
|
+
const KEY$5 = "[Alias]";
|
|
1025
1018
|
function Alias(alias) {
|
|
1026
|
-
return (
|
|
1019
|
+
return (instance, field) => {
|
|
1020
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$5, alias);
|
|
1021
|
+
};
|
|
1027
1022
|
}
|
|
1028
|
-
function getAlias(
|
|
1029
|
-
return (DecoratorUtil.getFieldConfig(
|
|
1023
|
+
function getAlias(Class, field) {
|
|
1024
|
+
return (DecoratorUtil.getFieldConfig(Class, field, KEY$5) || "").toString();
|
|
1030
1025
|
}
|
|
1031
|
-
const KEY$4$1 =
|
|
1026
|
+
const KEY$4$1 = "[IgnorePrefix]";
|
|
1032
1027
|
function IgnorePrefix() {
|
|
1033
|
-
return (
|
|
1028
|
+
return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$4$1, true);
|
|
1034
1029
|
}
|
|
1035
|
-
function getIgnorePrefix(
|
|
1036
|
-
return !!DecoratorUtil.getFieldConfig(
|
|
1030
|
+
function getIgnorePrefix(Class, field) {
|
|
1031
|
+
return !!DecoratorUtil.getFieldConfig(Class, field, KEY$4$1);
|
|
1037
1032
|
}
|
|
1038
|
-
const KEY$3$1 =
|
|
1033
|
+
const KEY$3$1 = "[Prefix]";
|
|
1039
1034
|
function Prefix(prefix) {
|
|
1040
|
-
return (
|
|
1035
|
+
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
|
|
1041
1036
|
}
|
|
1042
|
-
function getPrefix(
|
|
1043
|
-
return DecoratorUtil.getClassConfig(
|
|
1037
|
+
function getPrefix(Class) {
|
|
1038
|
+
return DecoratorUtil.getClassConfig(Class, KEY$3$1, "");
|
|
1044
1039
|
}
|
|
1045
|
-
const KEY$2$1 =
|
|
1040
|
+
const KEY$2$1 = "[ToClass]";
|
|
1046
1041
|
function ToClass(func) {
|
|
1047
|
-
return (
|
|
1042
|
+
return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$2$1, func);
|
|
1048
1043
|
}
|
|
1049
|
-
function getToClass(target,
|
|
1050
|
-
return DecoratorUtil.getFieldConfig(target,
|
|
1044
|
+
function getToClass(target, field) {
|
|
1045
|
+
return DecoratorUtil.getFieldConfig(target, field, KEY$2$1);
|
|
1051
1046
|
}
|
|
1052
|
-
const KEY$1$1 =
|
|
1047
|
+
const KEY$1$1 = "[ToJson]";
|
|
1053
1048
|
function ToJson(func) {
|
|
1054
|
-
return (
|
|
1049
|
+
return (instance, key) => DecoratorUtil.setFieldConfig(instance, key, KEY$1$1, func);
|
|
1055
1050
|
}
|
|
1056
|
-
function getToJson(
|
|
1057
|
-
return DecoratorUtil.getFieldConfig(
|
|
1051
|
+
function getToJson(Class, field) {
|
|
1052
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY$1$1);
|
|
1058
1053
|
}
|
|
1059
|
-
const KEY$6 =
|
|
1060
|
-
const KEY_ARRAY =
|
|
1054
|
+
const KEY$6 = "[Type]";
|
|
1055
|
+
const KEY_ARRAY = "[Array]";
|
|
1061
1056
|
function Type(type, array = false) {
|
|
1062
|
-
return (
|
|
1063
|
-
DecoratorUtil.setFieldConfig(
|
|
1057
|
+
return (instance, field) => {
|
|
1058
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$6, type);
|
|
1064
1059
|
if (array) {
|
|
1065
|
-
DecoratorUtil.setFieldConfig(
|
|
1060
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY_ARRAY, array);
|
|
1066
1061
|
}
|
|
1067
1062
|
};
|
|
1068
1063
|
}
|
|
1069
|
-
function getType(
|
|
1070
|
-
return DecoratorUtil.getFieldConfig(
|
|
1064
|
+
function getType(Class, field) {
|
|
1065
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY$6) || void 0;
|
|
1071
1066
|
}
|
|
1072
|
-
function getArray(
|
|
1073
|
-
return !!DecoratorUtil.getFieldConfig(
|
|
1067
|
+
function getArray(Class, field) {
|
|
1068
|
+
return !!DecoratorUtil.getFieldConfig(Class, field, KEY_ARRAY);
|
|
1074
1069
|
}
|
|
1075
|
-
const KEY$4 =
|
|
1070
|
+
const KEY$4 = "[MODEL]";
|
|
1076
1071
|
function Model(config = {}) {
|
|
1077
|
-
return (
|
|
1072
|
+
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
|
|
1078
1073
|
}
|
|
1079
|
-
function getModelConfig(
|
|
1080
|
-
return DecoratorUtil.getClassConfig(
|
|
1074
|
+
function getModelConfig(Class) {
|
|
1075
|
+
return DecoratorUtil.getClassConfig(Class, KEY$4, {}, true);
|
|
1081
1076
|
}
|
|
1082
|
-
function getModelName(
|
|
1083
|
-
return getModelConfig(
|
|
1077
|
+
function getModelName(Class) {
|
|
1078
|
+
return getModelConfig(Class).label || Class.name;
|
|
1084
1079
|
}
|
|
1085
1080
|
var PermissionAction = /* @__PURE__ */ ((PermissionAction2) => {
|
|
1086
1081
|
PermissionAction2["ADD"] = "add";
|
|
@@ -10194,23 +10189,23 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10194
10189
|
}
|
|
10195
10190
|
});
|
|
10196
10191
|
const Empty = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-f633fb7c"]]);
|
|
10197
|
-
const KEY$3 =
|
|
10192
|
+
const KEY$3 = "[Field]";
|
|
10198
10193
|
function Field(config = {}) {
|
|
10199
|
-
return (
|
|
10200
|
-
config.key =
|
|
10201
|
-
DecoratorUtil.setFieldConfig(
|
|
10194
|
+
return (instance, field) => {
|
|
10195
|
+
config.key = field.toString();
|
|
10196
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$3, config);
|
|
10202
10197
|
};
|
|
10203
10198
|
}
|
|
10204
|
-
function getFieldConfig(
|
|
10205
|
-
return DecoratorUtil.getFieldConfig(
|
|
10199
|
+
function getFieldConfig(Class, field) {
|
|
10200
|
+
return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$3, true) || {};
|
|
10206
10201
|
}
|
|
10207
|
-
function getDictionary(
|
|
10202
|
+
function getDictionary(Class, field) {
|
|
10208
10203
|
var _a;
|
|
10209
|
-
return (_a = getFieldConfig(
|
|
10204
|
+
return (_a = getFieldConfig(Class, field)) == null ? void 0 : _a.dictionary;
|
|
10210
10205
|
}
|
|
10211
|
-
function getFieldLabel(
|
|
10206
|
+
function getFieldLabel(Class, field) {
|
|
10212
10207
|
var _a;
|
|
10213
|
-
return ((_a = getFieldConfig(
|
|
10208
|
+
return ((_a = getFieldConfig(Class, field)) == null ? void 0 : _a.label) || field.toString();
|
|
10214
10209
|
}
|
|
10215
10210
|
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
10216
10211
|
__name: "FormField",
|
|
@@ -13637,35 +13632,35 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
13637
13632
|
};
|
|
13638
13633
|
}
|
|
13639
13634
|
});
|
|
13640
|
-
const KEY$2 =
|
|
13641
|
-
const LIST_KEY$2 =
|
|
13635
|
+
const KEY$2 = "[Form]";
|
|
13636
|
+
const LIST_KEY$2 = "[FormList]";
|
|
13642
13637
|
function Form(config = {}) {
|
|
13643
|
-
return (
|
|
13644
|
-
config.key = key;
|
|
13645
|
-
DecoratorUtil.setFieldConfig(
|
|
13638
|
+
return (instance, key) => {
|
|
13639
|
+
config.key = key.toString();
|
|
13640
|
+
DecoratorUtil.setFieldConfig(instance, key, KEY$2, config, LIST_KEY$2);
|
|
13646
13641
|
};
|
|
13647
13642
|
}
|
|
13648
|
-
function getFormConfig(
|
|
13649
|
-
const formConfig = DecoratorUtil.getFieldConfig(
|
|
13643
|
+
function getFormConfig(Class, field) {
|
|
13644
|
+
const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true);
|
|
13650
13645
|
if (!formConfig) {
|
|
13651
|
-
return { key:
|
|
13646
|
+
return { key: field.toString() };
|
|
13652
13647
|
}
|
|
13653
13648
|
if (!formConfig.dictionary) {
|
|
13654
|
-
const props = getFieldConfig(
|
|
13649
|
+
const props = getFieldConfig(Class, field);
|
|
13655
13650
|
if (props && props.dictionary) {
|
|
13656
13651
|
formConfig.dictionary = props.dictionary;
|
|
13657
13652
|
}
|
|
13658
13653
|
}
|
|
13659
13654
|
return formConfig;
|
|
13660
13655
|
}
|
|
13661
|
-
function getFormFieldList(
|
|
13662
|
-
return DecoratorUtil.getFieldList(
|
|
13656
|
+
function getFormFieldList(Class) {
|
|
13657
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY$2);
|
|
13663
13658
|
}
|
|
13664
|
-
function getFormConfigList(
|
|
13665
|
-
if (
|
|
13666
|
-
|
|
13659
|
+
function getFormConfigList(Class, fieldList = []) {
|
|
13660
|
+
if (fieldList.length === 0) {
|
|
13661
|
+
fieldList = getFormFieldList(Class);
|
|
13667
13662
|
}
|
|
13668
|
-
const list =
|
|
13663
|
+
const list = fieldList.map((field) => getFormConfig(Class, field));
|
|
13669
13664
|
return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
13670
13665
|
}
|
|
13671
13666
|
var FormTrim = /* @__PURE__ */ ((FormTrim2) => {
|
|
@@ -16761,56 +16756,54 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
16761
16756
|
};
|
|
16762
16757
|
}
|
|
16763
16758
|
});
|
|
16764
|
-
const KEY$1 =
|
|
16765
|
-
const LIST_KEY$1 =
|
|
16759
|
+
const KEY$1 = "[Search]";
|
|
16760
|
+
const LIST_KEY$1 = "[SearchList]";
|
|
16766
16761
|
function Search(config = {}) {
|
|
16767
|
-
return (
|
|
16768
|
-
config.key =
|
|
16769
|
-
DecoratorUtil.setFieldConfig(
|
|
16762
|
+
return (instance, field) => {
|
|
16763
|
+
config.key = field.toString();
|
|
16764
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$1, config, LIST_KEY$1);
|
|
16770
16765
|
};
|
|
16771
16766
|
}
|
|
16772
|
-
function getSearchConfig(
|
|
16773
|
-
const
|
|
16774
|
-
const formConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY$1, true);
|
|
16767
|
+
function getSearchConfig(Class, field) {
|
|
16768
|
+
const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$1, true);
|
|
16775
16769
|
if (!formConfig) {
|
|
16776
|
-
return { key:
|
|
16770
|
+
return { key: field.toString() };
|
|
16777
16771
|
}
|
|
16778
16772
|
return formConfig;
|
|
16779
16773
|
}
|
|
16780
|
-
function getSearchFieldList(
|
|
16781
|
-
return DecoratorUtil.getFieldList(
|
|
16774
|
+
function getSearchFieldList(Class) {
|
|
16775
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY$1);
|
|
16782
16776
|
}
|
|
16783
|
-
function getSearchConfigList(
|
|
16784
|
-
if (
|
|
16785
|
-
|
|
16777
|
+
function getSearchConfigList(Class, fieldList = []) {
|
|
16778
|
+
if (fieldList.length === 0) {
|
|
16779
|
+
fieldList = getSearchFieldList(Class);
|
|
16786
16780
|
}
|
|
16787
|
-
const list =
|
|
16781
|
+
const list = fieldList.map((field) => getSearchConfig(Class, field));
|
|
16788
16782
|
return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
16789
16783
|
}
|
|
16790
|
-
const KEY =
|
|
16791
|
-
const LIST_KEY =
|
|
16784
|
+
const KEY = "[Table]";
|
|
16785
|
+
const LIST_KEY = "[TableList]";
|
|
16792
16786
|
function Table(config = {}) {
|
|
16793
|
-
return (
|
|
16794
|
-
config.key =
|
|
16795
|
-
DecoratorUtil.setFieldConfig(
|
|
16787
|
+
return (instance, field) => {
|
|
16788
|
+
config.key = field.toString();
|
|
16789
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY, config, LIST_KEY);
|
|
16796
16790
|
};
|
|
16797
16791
|
}
|
|
16798
|
-
function getTableConfig(
|
|
16799
|
-
const
|
|
16800
|
-
const tableConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY, true);
|
|
16792
|
+
function getTableConfig(Class, field) {
|
|
16793
|
+
const tableConfig = DecoratorUtil.getFieldConfig(Class, field, KEY, true);
|
|
16801
16794
|
if (!tableConfig) {
|
|
16802
|
-
return { key:
|
|
16795
|
+
return { key: field.toString() };
|
|
16803
16796
|
}
|
|
16804
16797
|
return tableConfig;
|
|
16805
16798
|
}
|
|
16806
|
-
function getTableFieldList(
|
|
16807
|
-
return DecoratorUtil.getFieldList(
|
|
16799
|
+
function getTableFieldList(Class) {
|
|
16800
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY);
|
|
16808
16801
|
}
|
|
16809
|
-
function getTableConfigList(
|
|
16810
|
-
if (
|
|
16811
|
-
|
|
16802
|
+
function getTableConfigList(Class, fieldList = []) {
|
|
16803
|
+
if (fieldList.length === 0) {
|
|
16804
|
+
fieldList = getTableFieldList(Class);
|
|
16812
16805
|
}
|
|
16813
|
-
const list =
|
|
16806
|
+
const list = fieldList.map((field) => getTableConfig(Class, field));
|
|
16814
16807
|
return list.sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
16815
16808
|
}
|
|
16816
16809
|
var __defProp$2 = Object.defineProperty;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airpower/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.29",
|
|
5
5
|
"description": "AirPower-Web",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Hamm",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@airpower/enum": "^0.0.10",
|
|
43
43
|
"@airpower/i18n": "^0.0.4",
|
|
44
|
-
"@airpower/transformer": "^0.1.
|
|
44
|
+
"@airpower/transformer": "^0.1.6",
|
|
45
45
|
"@airpower/util": "^0.1.3",
|
|
46
46
|
"@element-plus/icons-vue": "^2.3.1",
|
|
47
47
|
"axios": "^1.8.4",
|
package/dist/tests/main.d.ts
DELETED
|
File without changes
|