@airpower/web 0.2.28 → 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/@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/main.js +146 -165
- package/package.json +2 -2
|
@@ -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,126 +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
|
-
|
|
710
|
-
target = target.prototype;
|
|
711
|
-
}
|
|
712
|
-
let classConfig = Reflect.get(target, classConfigKey);
|
|
705
|
+
static getClassConfig(Class, classConfigKey, defaultValue = void 0, isObject = false) {
|
|
706
|
+
let classConfig = Reflect.get(Class, classConfigKey);
|
|
713
707
|
if (!isObject) {
|
|
714
708
|
if (classConfig) {
|
|
715
709
|
return classConfig;
|
|
716
710
|
}
|
|
717
|
-
const
|
|
718
|
-
if (!
|
|
711
|
+
const SuperClass2 = Reflect.getPrototypeOf(Class);
|
|
712
|
+
if (!SuperClass2 || SuperClass2.prototype.constructor.name === Transformer.name) {
|
|
719
713
|
return void 0;
|
|
720
714
|
}
|
|
721
|
-
return this.getClassConfig(
|
|
715
|
+
return this.getClassConfig(SuperClass2, classConfigKey);
|
|
722
716
|
}
|
|
723
717
|
classConfig = classConfig || {};
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
718
|
+
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
719
|
+
if (!SuperClass || SuperClass.constructor.name === Transformer.name) {
|
|
726
720
|
return defaultValue;
|
|
727
721
|
}
|
|
728
722
|
return {
|
|
729
|
-
...this.getClassConfig(
|
|
723
|
+
...this.getClassConfig(SuperClass, classConfigKey, defaultValue, isObject),
|
|
730
724
|
...classConfig
|
|
731
725
|
};
|
|
732
726
|
}
|
|
733
727
|
/**
|
|
734
728
|
* ### 设置一个属性配置项
|
|
735
|
-
* @param
|
|
736
|
-
* @param
|
|
729
|
+
* @param instance 目标实例
|
|
730
|
+
* @param field 属性
|
|
737
731
|
* @param fieldConfigKey 配置项索引键值
|
|
738
732
|
* @param fieldConfig 配置的参数
|
|
739
733
|
* @param fieldListKey `可选` 类配置项列表索引值
|
|
740
734
|
*/
|
|
741
|
-
static setFieldConfig(
|
|
735
|
+
static setFieldConfig(instance, field, fieldConfigKey, fieldConfig, fieldListKey) {
|
|
742
736
|
if (fieldListKey) {
|
|
743
|
-
this.addFieldDecoratorKey(
|
|
737
|
+
this.addFieldDecoratorKey(instance, field, fieldListKey);
|
|
744
738
|
}
|
|
745
|
-
this.setProperty(
|
|
739
|
+
this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
|
|
746
740
|
}
|
|
747
741
|
/**
|
|
748
742
|
* ### 获取类指定属性的指定类型的配置
|
|
749
|
-
* @param
|
|
750
|
-
* @param
|
|
743
|
+
* @param Class 目标类
|
|
744
|
+
* @param field 属性
|
|
751
745
|
* @param fieldConfigKey FieldConfigKey
|
|
752
746
|
* @param isObject `可选` 是否对象配置
|
|
753
747
|
*/
|
|
754
|
-
static getFieldConfig(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
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);
|
|
759
751
|
if (!isObject) {
|
|
760
752
|
if (fieldConfig !== void 0) {
|
|
761
753
|
return fieldConfig;
|
|
762
754
|
}
|
|
763
|
-
|
|
764
|
-
if (!superClass2 || superClass2.constructor.name === Transformer.name) {
|
|
755
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
765
756
|
return void 0;
|
|
766
757
|
}
|
|
767
|
-
return this.getFieldConfig(
|
|
758
|
+
return this.getFieldConfig(SuperClass, field, fieldConfigKey);
|
|
768
759
|
}
|
|
769
760
|
fieldConfig = fieldConfig || {};
|
|
770
|
-
|
|
771
|
-
if (!superClass || superClass.constructor.name === Transformer.name) {
|
|
761
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
772
762
|
return {};
|
|
773
763
|
}
|
|
774
764
|
return {
|
|
775
|
-
...this.getFieldConfig(
|
|
765
|
+
...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
|
|
776
766
|
...fieldConfig
|
|
777
767
|
};
|
|
778
768
|
}
|
|
779
769
|
/**
|
|
780
770
|
* ### 获取类标记了装饰器的属性列表
|
|
781
|
-
* @param
|
|
771
|
+
* @param Class 目标类
|
|
782
772
|
* @param fieldConfigKey FieldConfigKey
|
|
783
773
|
* @param list `递归参数` 无需传入
|
|
784
774
|
*/
|
|
785
|
-
static getFieldList(
|
|
786
|
-
|
|
787
|
-
target = target.prototype;
|
|
788
|
-
}
|
|
789
|
-
const fieldList = Reflect.get(target, fieldConfigKey) || [];
|
|
775
|
+
static getFieldList(Class, fieldConfigKey, list = []) {
|
|
776
|
+
const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
|
|
790
777
|
fieldList.forEach((item) => list.includes(item) || list.push(item));
|
|
791
|
-
const
|
|
792
|
-
if (!
|
|
778
|
+
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
779
|
+
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
793
780
|
return list;
|
|
794
781
|
}
|
|
795
|
-
return this.getFieldList(
|
|
782
|
+
return this.getFieldList(SuperClass, fieldConfigKey, list);
|
|
796
783
|
}
|
|
797
784
|
/**
|
|
798
785
|
* ### 反射添加属性
|
|
799
|
-
* @param
|
|
800
|
-
* @param
|
|
786
|
+
* @param instance 目标属性
|
|
787
|
+
* @param propertyKey 配置key
|
|
801
788
|
* @param value 配置值
|
|
802
789
|
*/
|
|
803
|
-
static setProperty(
|
|
804
|
-
|
|
805
|
-
target = target.prototype;
|
|
806
|
-
}
|
|
807
|
-
Reflect.defineProperty(target, key, {
|
|
790
|
+
static setProperty(instance, propertyKey, value) {
|
|
791
|
+
Reflect.defineProperty(instance, propertyKey, {
|
|
808
792
|
enumerable: false,
|
|
809
793
|
value,
|
|
810
794
|
writable: false,
|
|
@@ -813,20 +797,16 @@ class DecoratorUtil {
|
|
|
813
797
|
}
|
|
814
798
|
/**
|
|
815
799
|
* ### 设置一个属性的包含装饰器索引
|
|
816
|
-
* @param
|
|
817
|
-
* @param
|
|
818
|
-
* @param
|
|
800
|
+
* @param instance 目标类
|
|
801
|
+
* @param field 属性
|
|
802
|
+
* @param propertyKey 类配置项列表索引值
|
|
819
803
|
*/
|
|
820
|
-
static addFieldDecoratorKey(
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
const list = Reflect.get(target, fieldListKey) || [];
|
|
825
|
-
list.push(key);
|
|
826
|
-
this.setProperty(target, fieldListKey, list);
|
|
804
|
+
static addFieldDecoratorKey(instance, field, propertyKey) {
|
|
805
|
+
const list = Reflect.get(instance, propertyKey) || [];
|
|
806
|
+
list.push(field);
|
|
807
|
+
this.setProperty(instance, propertyKey, list);
|
|
827
808
|
}
|
|
828
809
|
}
|
|
829
|
-
__publicField$3(DecoratorUtil, "DecoratorKeyPrefix", "[AirPower]");
|
|
830
810
|
class Transformer {
|
|
831
811
|
/**
|
|
832
812
|
* ### 从 `JSON` 转换到当前类的对象
|
|
@@ -874,10 +854,10 @@ class Transformer {
|
|
|
874
854
|
const instance = new Class();
|
|
875
855
|
const fieldList = Object.keys(instance);
|
|
876
856
|
for (const field of fieldList) {
|
|
877
|
-
const jsonKey = this.getJsonKey(
|
|
857
|
+
const jsonKey = this.getJsonKey(Class, field);
|
|
878
858
|
const fieldData = json[jsonKey];
|
|
879
859
|
instance[field] = fieldData;
|
|
880
|
-
const toClass = getToClass(
|
|
860
|
+
const toClass = getToClass(Class, field);
|
|
881
861
|
if (toClass !== void 0) {
|
|
882
862
|
try {
|
|
883
863
|
;
|
|
@@ -887,8 +867,8 @@ class Transformer {
|
|
|
887
867
|
continue;
|
|
888
868
|
}
|
|
889
869
|
}
|
|
890
|
-
const FieldTypeClass = getType(
|
|
891
|
-
const isArray2 = getArray(
|
|
870
|
+
const FieldTypeClass = getType(Class, field);
|
|
871
|
+
const isArray2 = getArray(Class, field);
|
|
892
872
|
if (isArray2) {
|
|
893
873
|
const fieldValueList = [];
|
|
894
874
|
if (typeof fieldData === "object" && Array.isArray(fieldData)) {
|
|
@@ -922,7 +902,7 @@ class Transformer {
|
|
|
922
902
|
}
|
|
923
903
|
}
|
|
924
904
|
for (const fieldKey of fieldList) {
|
|
925
|
-
const alias = getAlias(
|
|
905
|
+
const alias = getAlias(Class, fieldKey) || fieldKey;
|
|
926
906
|
if (alias === fieldKey) {
|
|
927
907
|
continue;
|
|
928
908
|
}
|
|
@@ -932,19 +912,19 @@ class Transformer {
|
|
|
932
912
|
}
|
|
933
913
|
/**
|
|
934
914
|
* ### 获取 JSON 的 key
|
|
935
|
-
* @param
|
|
915
|
+
* @param Class 目标实例
|
|
936
916
|
* @param field 属性 key
|
|
937
917
|
*/
|
|
938
|
-
static getJsonKey(
|
|
939
|
-
const alias = getAlias(
|
|
918
|
+
static getJsonKey(Class, field) {
|
|
919
|
+
const alias = getAlias(Class, field);
|
|
940
920
|
if (alias) {
|
|
941
921
|
return alias;
|
|
942
922
|
}
|
|
943
|
-
const prefix = getPrefix(
|
|
923
|
+
const prefix = getPrefix(Class);
|
|
944
924
|
if (!prefix) {
|
|
945
925
|
return field;
|
|
946
926
|
}
|
|
947
|
-
const ignorePrefix = getIgnorePrefix(
|
|
927
|
+
const ignorePrefix = getIgnorePrefix(Class, field);
|
|
948
928
|
if (!ignorePrefix) {
|
|
949
929
|
return prefix + field;
|
|
950
930
|
}
|
|
@@ -996,6 +976,7 @@ class Transformer {
|
|
|
996
976
|
* 会自动进行数据别名转换
|
|
997
977
|
*/
|
|
998
978
|
toJson() {
|
|
979
|
+
const Class = this.constructor;
|
|
999
980
|
const fieldList = Object.keys(this);
|
|
1000
981
|
const json = {};
|
|
1001
982
|
for (const field of fieldList) {
|
|
@@ -1003,9 +984,9 @@ class Transformer {
|
|
|
1003
984
|
if (data === null || data === void 0) {
|
|
1004
985
|
continue;
|
|
1005
986
|
}
|
|
1006
|
-
const jsonKey = Transformer.getJsonKey(
|
|
987
|
+
const jsonKey = Transformer.getJsonKey(Class, field);
|
|
1007
988
|
json[jsonKey] = data;
|
|
1008
|
-
const toJson = getToJson(
|
|
989
|
+
const toJson = getToJson(Class, field);
|
|
1009
990
|
if (toJson !== void 0) {
|
|
1010
991
|
try {
|
|
1011
992
|
json[jsonKey] = toJson(this);
|
|
@@ -1033,66 +1014,68 @@ class Transformer {
|
|
|
1033
1014
|
return json;
|
|
1034
1015
|
}
|
|
1035
1016
|
}
|
|
1036
|
-
const KEY$5 =
|
|
1017
|
+
const KEY$5 = "[Alias]";
|
|
1037
1018
|
function Alias(alias) {
|
|
1038
|
-
return (
|
|
1019
|
+
return (instance, field) => {
|
|
1020
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$5, alias);
|
|
1021
|
+
};
|
|
1039
1022
|
}
|
|
1040
|
-
function getAlias(
|
|
1041
|
-
return (DecoratorUtil.getFieldConfig(
|
|
1023
|
+
function getAlias(Class, field) {
|
|
1024
|
+
return (DecoratorUtil.getFieldConfig(Class, field, KEY$5) || "").toString();
|
|
1042
1025
|
}
|
|
1043
|
-
const KEY$4$1 =
|
|
1026
|
+
const KEY$4$1 = "[IgnorePrefix]";
|
|
1044
1027
|
function IgnorePrefix() {
|
|
1045
|
-
return (
|
|
1028
|
+
return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$4$1, true);
|
|
1046
1029
|
}
|
|
1047
|
-
function getIgnorePrefix(
|
|
1048
|
-
return !!DecoratorUtil.getFieldConfig(
|
|
1030
|
+
function getIgnorePrefix(Class, field) {
|
|
1031
|
+
return !!DecoratorUtil.getFieldConfig(Class, field, KEY$4$1);
|
|
1049
1032
|
}
|
|
1050
|
-
const KEY$3$1 =
|
|
1033
|
+
const KEY$3$1 = "[Prefix]";
|
|
1051
1034
|
function Prefix(prefix) {
|
|
1052
|
-
return (
|
|
1035
|
+
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
|
|
1053
1036
|
}
|
|
1054
|
-
function getPrefix(
|
|
1055
|
-
return DecoratorUtil.getClassConfig(
|
|
1037
|
+
function getPrefix(Class) {
|
|
1038
|
+
return DecoratorUtil.getClassConfig(Class, KEY$3$1, "");
|
|
1056
1039
|
}
|
|
1057
|
-
const KEY$2$1 =
|
|
1040
|
+
const KEY$2$1 = "[ToClass]";
|
|
1058
1041
|
function ToClass(func) {
|
|
1059
|
-
return (
|
|
1042
|
+
return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$2$1, func);
|
|
1060
1043
|
}
|
|
1061
|
-
function getToClass(target,
|
|
1062
|
-
return DecoratorUtil.getFieldConfig(target,
|
|
1044
|
+
function getToClass(target, field) {
|
|
1045
|
+
return DecoratorUtil.getFieldConfig(target, field, KEY$2$1);
|
|
1063
1046
|
}
|
|
1064
|
-
const KEY$1$1 =
|
|
1047
|
+
const KEY$1$1 = "[ToJson]";
|
|
1065
1048
|
function ToJson(func) {
|
|
1066
|
-
return (
|
|
1049
|
+
return (instance, key) => DecoratorUtil.setFieldConfig(instance, key, KEY$1$1, func);
|
|
1067
1050
|
}
|
|
1068
|
-
function getToJson(
|
|
1069
|
-
return DecoratorUtil.getFieldConfig(
|
|
1051
|
+
function getToJson(Class, field) {
|
|
1052
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY$1$1);
|
|
1070
1053
|
}
|
|
1071
|
-
const KEY$6 =
|
|
1072
|
-
const KEY_ARRAY =
|
|
1054
|
+
const KEY$6 = "[Type]";
|
|
1055
|
+
const KEY_ARRAY = "[Array]";
|
|
1073
1056
|
function Type(type, array = false) {
|
|
1074
|
-
return (
|
|
1075
|
-
DecoratorUtil.setFieldConfig(
|
|
1057
|
+
return (instance, field) => {
|
|
1058
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$6, type);
|
|
1076
1059
|
if (array) {
|
|
1077
|
-
DecoratorUtil.setFieldConfig(
|
|
1060
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY_ARRAY, array);
|
|
1078
1061
|
}
|
|
1079
1062
|
};
|
|
1080
1063
|
}
|
|
1081
|
-
function getType(
|
|
1082
|
-
return DecoratorUtil.getFieldConfig(
|
|
1064
|
+
function getType(Class, field) {
|
|
1065
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY$6) || void 0;
|
|
1083
1066
|
}
|
|
1084
|
-
function getArray(
|
|
1085
|
-
return !!DecoratorUtil.getFieldConfig(
|
|
1067
|
+
function getArray(Class, field) {
|
|
1068
|
+
return !!DecoratorUtil.getFieldConfig(Class, field, KEY_ARRAY);
|
|
1086
1069
|
}
|
|
1087
|
-
const KEY$4 =
|
|
1070
|
+
const KEY$4 = "[MODEL]";
|
|
1088
1071
|
function Model(config = {}) {
|
|
1089
|
-
return (
|
|
1072
|
+
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
|
|
1090
1073
|
}
|
|
1091
|
-
function getModelConfig(
|
|
1092
|
-
return DecoratorUtil.getClassConfig(
|
|
1074
|
+
function getModelConfig(Class) {
|
|
1075
|
+
return DecoratorUtil.getClassConfig(Class, KEY$4, {}, true);
|
|
1093
1076
|
}
|
|
1094
|
-
function getModelName(
|
|
1095
|
-
return getModelConfig(
|
|
1077
|
+
function getModelName(Class) {
|
|
1078
|
+
return getModelConfig(Class).label || Class.name;
|
|
1096
1079
|
}
|
|
1097
1080
|
var PermissionAction = /* @__PURE__ */ ((PermissionAction2) => {
|
|
1098
1081
|
PermissionAction2["ADD"] = "add";
|
|
@@ -10206,23 +10189,23 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
10206
10189
|
}
|
|
10207
10190
|
});
|
|
10208
10191
|
const Empty = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-f633fb7c"]]);
|
|
10209
|
-
const KEY$3 =
|
|
10192
|
+
const KEY$3 = "[Field]";
|
|
10210
10193
|
function Field(config = {}) {
|
|
10211
|
-
return (
|
|
10212
|
-
config.key =
|
|
10213
|
-
DecoratorUtil.setFieldConfig(
|
|
10194
|
+
return (instance, field) => {
|
|
10195
|
+
config.key = field.toString();
|
|
10196
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$3, config);
|
|
10214
10197
|
};
|
|
10215
10198
|
}
|
|
10216
|
-
function getFieldConfig(
|
|
10217
|
-
return DecoratorUtil.getFieldConfig(
|
|
10199
|
+
function getFieldConfig(Class, field) {
|
|
10200
|
+
return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$3, true) || {};
|
|
10218
10201
|
}
|
|
10219
|
-
function getDictionary(
|
|
10202
|
+
function getDictionary(Class, field) {
|
|
10220
10203
|
var _a;
|
|
10221
|
-
return (_a = getFieldConfig(
|
|
10204
|
+
return (_a = getFieldConfig(Class, field)) == null ? void 0 : _a.dictionary;
|
|
10222
10205
|
}
|
|
10223
|
-
function getFieldLabel(
|
|
10206
|
+
function getFieldLabel(Class, field) {
|
|
10224
10207
|
var _a;
|
|
10225
|
-
return ((_a = getFieldConfig(
|
|
10208
|
+
return ((_a = getFieldConfig(Class, field)) == null ? void 0 : _a.label) || field.toString();
|
|
10226
10209
|
}
|
|
10227
10210
|
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
10228
10211
|
__name: "FormField",
|
|
@@ -13649,35 +13632,35 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
13649
13632
|
};
|
|
13650
13633
|
}
|
|
13651
13634
|
});
|
|
13652
|
-
const KEY$2 =
|
|
13653
|
-
const LIST_KEY$2 =
|
|
13635
|
+
const KEY$2 = "[Form]";
|
|
13636
|
+
const LIST_KEY$2 = "[FormList]";
|
|
13654
13637
|
function Form(config = {}) {
|
|
13655
|
-
return (
|
|
13656
|
-
config.key = key;
|
|
13657
|
-
DecoratorUtil.setFieldConfig(
|
|
13638
|
+
return (instance, key) => {
|
|
13639
|
+
config.key = key.toString();
|
|
13640
|
+
DecoratorUtil.setFieldConfig(instance, key, KEY$2, config, LIST_KEY$2);
|
|
13658
13641
|
};
|
|
13659
13642
|
}
|
|
13660
|
-
function getFormConfig(
|
|
13661
|
-
const formConfig = DecoratorUtil.getFieldConfig(
|
|
13643
|
+
function getFormConfig(Class, field) {
|
|
13644
|
+
const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true);
|
|
13662
13645
|
if (!formConfig) {
|
|
13663
|
-
return { key:
|
|
13646
|
+
return { key: field.toString() };
|
|
13664
13647
|
}
|
|
13665
13648
|
if (!formConfig.dictionary) {
|
|
13666
|
-
const props = getFieldConfig(
|
|
13649
|
+
const props = getFieldConfig(Class, field);
|
|
13667
13650
|
if (props && props.dictionary) {
|
|
13668
13651
|
formConfig.dictionary = props.dictionary;
|
|
13669
13652
|
}
|
|
13670
13653
|
}
|
|
13671
13654
|
return formConfig;
|
|
13672
13655
|
}
|
|
13673
|
-
function getFormFieldList(
|
|
13674
|
-
return DecoratorUtil.getFieldList(
|
|
13656
|
+
function getFormFieldList(Class) {
|
|
13657
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY$2);
|
|
13675
13658
|
}
|
|
13676
|
-
function getFormConfigList(
|
|
13677
|
-
if (
|
|
13678
|
-
|
|
13659
|
+
function getFormConfigList(Class, fieldList = []) {
|
|
13660
|
+
if (fieldList.length === 0) {
|
|
13661
|
+
fieldList = getFormFieldList(Class);
|
|
13679
13662
|
}
|
|
13680
|
-
const list =
|
|
13663
|
+
const list = fieldList.map((field) => getFormConfig(Class, field));
|
|
13681
13664
|
return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
13682
13665
|
}
|
|
13683
13666
|
var FormTrim = /* @__PURE__ */ ((FormTrim2) => {
|
|
@@ -16773,56 +16756,54 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
16773
16756
|
};
|
|
16774
16757
|
}
|
|
16775
16758
|
});
|
|
16776
|
-
const KEY$1 =
|
|
16777
|
-
const LIST_KEY$1 =
|
|
16759
|
+
const KEY$1 = "[Search]";
|
|
16760
|
+
const LIST_KEY$1 = "[SearchList]";
|
|
16778
16761
|
function Search(config = {}) {
|
|
16779
|
-
return (
|
|
16780
|
-
config.key =
|
|
16781
|
-
DecoratorUtil.setFieldConfig(
|
|
16762
|
+
return (instance, field) => {
|
|
16763
|
+
config.key = field.toString();
|
|
16764
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY$1, config, LIST_KEY$1);
|
|
16782
16765
|
};
|
|
16783
16766
|
}
|
|
16784
|
-
function getSearchConfig(
|
|
16785
|
-
const
|
|
16786
|
-
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);
|
|
16787
16769
|
if (!formConfig) {
|
|
16788
|
-
return { key:
|
|
16770
|
+
return { key: field.toString() };
|
|
16789
16771
|
}
|
|
16790
16772
|
return formConfig;
|
|
16791
16773
|
}
|
|
16792
|
-
function getSearchFieldList(
|
|
16793
|
-
return DecoratorUtil.getFieldList(
|
|
16774
|
+
function getSearchFieldList(Class) {
|
|
16775
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY$1);
|
|
16794
16776
|
}
|
|
16795
|
-
function getSearchConfigList(
|
|
16796
|
-
if (
|
|
16797
|
-
|
|
16777
|
+
function getSearchConfigList(Class, fieldList = []) {
|
|
16778
|
+
if (fieldList.length === 0) {
|
|
16779
|
+
fieldList = getSearchFieldList(Class);
|
|
16798
16780
|
}
|
|
16799
|
-
const list =
|
|
16781
|
+
const list = fieldList.map((field) => getSearchConfig(Class, field));
|
|
16800
16782
|
return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
16801
16783
|
}
|
|
16802
|
-
const KEY =
|
|
16803
|
-
const LIST_KEY =
|
|
16784
|
+
const KEY = "[Table]";
|
|
16785
|
+
const LIST_KEY = "[TableList]";
|
|
16804
16786
|
function Table(config = {}) {
|
|
16805
|
-
return (
|
|
16806
|
-
config.key =
|
|
16807
|
-
DecoratorUtil.setFieldConfig(
|
|
16787
|
+
return (instance, field) => {
|
|
16788
|
+
config.key = field.toString();
|
|
16789
|
+
DecoratorUtil.setFieldConfig(instance, field, KEY, config, LIST_KEY);
|
|
16808
16790
|
};
|
|
16809
16791
|
}
|
|
16810
|
-
function getTableConfig(
|
|
16811
|
-
const
|
|
16812
|
-
const tableConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY, true);
|
|
16792
|
+
function getTableConfig(Class, field) {
|
|
16793
|
+
const tableConfig = DecoratorUtil.getFieldConfig(Class, field, KEY, true);
|
|
16813
16794
|
if (!tableConfig) {
|
|
16814
|
-
return { key:
|
|
16795
|
+
return { key: field.toString() };
|
|
16815
16796
|
}
|
|
16816
16797
|
return tableConfig;
|
|
16817
16798
|
}
|
|
16818
|
-
function getTableFieldList(
|
|
16819
|
-
return DecoratorUtil.getFieldList(
|
|
16799
|
+
function getTableFieldList(Class) {
|
|
16800
|
+
return DecoratorUtil.getFieldList(Class, LIST_KEY);
|
|
16820
16801
|
}
|
|
16821
|
-
function getTableConfigList(
|
|
16822
|
-
if (
|
|
16823
|
-
|
|
16802
|
+
function getTableConfigList(Class, fieldList = []) {
|
|
16803
|
+
if (fieldList.length === 0) {
|
|
16804
|
+
fieldList = getTableFieldList(Class);
|
|
16824
16805
|
}
|
|
16825
|
-
const list =
|
|
16806
|
+
const list = fieldList.map((field) => getTableConfig(Class, field));
|
|
16826
16807
|
return list.sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
16827
16808
|
}
|
|
16828
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",
|