@airpower/web 0.2.28 → 0.2.30

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.
@@ -1,5 +1,5 @@
1
1
  import { EnumKey } from '@airpower/enum/dist/enum/type';
2
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
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>>): (target: DecoratorTarget, key: string) => void;
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 TargetClass 目标类
16
- * @param key 属性名
15
+ * @param Class 目标类
16
+ * @param field 属性名
17
17
  */
18
- export declare function getFieldConfig<M extends RootModel, K extends EnumKey = EnumKey>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): IFieldConfig<K>;
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 TargetClass 目标类
22
- * @param key 属性名
21
+ * @param Class 目标类
22
+ * @param field 属性名
23
23
  */
24
- export declare function getDictionary<M extends RootModel, K extends EnumKey = EnumKey>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): WebEnumConstructor<K> | undefined;
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 TargetClass 目标类
28
- * @param key string 属性名
27
+ * @param Class 目标类
28
+ * @param field string 属性名
29
29
  */
30
- export declare function getFieldLabel<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): string;
30
+ export declare function getFieldLabel<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): string;
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
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,15 @@ import { IFormField } from './IFormField';
6
6
  * ### 标记该字段可用于表单配置
7
7
  * @param config 配置项
8
8
  */
9
- export declare function Form(config?: FieldConfigOptionalKey<IFormField>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Form<M extends RootModel>(config?: FieldConfigOptionalKey<IFormField>): (instance: M, key: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象某个字段标记的表单配置项
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getFormConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): IFormField;
16
- /**
17
- * ### 获取标记了表单配置的字段列表
18
- * @param TargetClass 目标类
19
- */
20
- export declare function getFormFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
15
+ export declare function getFormConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFormField;
21
16
  /**
22
17
  * ### 获取指定类的表单字段配置项列表
23
- * @param TargetClass 目标类
24
- * @param keyList 选择字段列表
18
+ * @param Class 目标类
25
19
  */
26
- export declare function getFormConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): IFormField[];
20
+ export declare function getFormConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): IFormField[];
@@ -1,17 +1,18 @@
1
- import { DecoratorTarget, ITransformerConstructor, Transformer } from '@airpower/transformer';
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): (target: DecoratorTarget) => void;
8
+ export declare function Model<M extends RootModel, T extends IModelConfig = IModelConfig>(config?: T): (Class: ITransformerConstructor<M>) => void;
8
9
  /**
9
10
  * ### 获取模型类配置项
10
- * @param TargetClass 目标类
11
+ * @param Class 目标类
11
12
  */
12
- export declare function getModelConfig<E extends Transformer, T extends IModelConfig = IModelConfig>(TargetClass: ITransformerConstructor<E>): T;
13
+ export declare function getModelConfig<M extends RootModel, T extends IModelConfig = IModelConfig>(Class: ITransformerConstructor<M>): T;
13
14
  /**
14
15
  * ### 获取模型类名称
15
- * @param TargetClass 目标类
16
+ * @param Class 目标类
16
17
  */
17
- export declare function getModelName<E extends Transformer>(TargetClass: ITransformerConstructor<E>): string;
18
+ export declare function getModelName<M extends RootModel>(Class: ITransformerConstructor<M>): string;
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
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,15 @@ import { ISearchField } from './ISearchField';
6
6
  * ### 标记该字段可用于表单配置
7
7
  * @param config 配置项
8
8
  */
9
- export declare function Search(config?: FieldConfigOptionalKey<ISearchField>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Search<M extends RootModel>(config?: FieldConfigOptionalKey<ISearchField>): (instance: M, field: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象某个字段标记的搜索配置项
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getSearchConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): ISearchField;
16
- /**
17
- * ### 获取标记了搜索配置的字段列表
18
- * @param TargetClass 目标类
19
- */
20
- export declare function getSearchFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
15
+ export declare function getSearchConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ISearchField;
21
16
  /**
22
17
  * ### 获取指定类的搜索字段配置项列表
23
- * @param TargetClass 目标类
24
- * @param keyList 选择字段列表
18
+ * @param Class 目标类
25
19
  */
26
- export declare function getSearchConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): ISearchField[];
20
+ export declare function getSearchConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): ISearchField[];
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
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,15 @@ import { ITableColumn } from './ITableColumn';
6
6
  * ### 为属性标记是表格字段
7
7
  * @param config 表格列的配置
8
8
  */
9
- export declare function Table(config?: FieldConfigOptionalKey<ITableColumn>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Table<M extends RootModel>(config?: FieldConfigOptionalKey<ITableColumn>): (instance: M, field: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象的属性表格的配置
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getTableConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): ITableColumn;
16
- /**
17
- * ### 获取标记了表格配置的字段列表
18
- * @param TargetClass 目标类
19
- */
20
- export declare function getTableFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
15
+ export declare function getTableConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ITableColumn;
21
16
  /**
22
17
  * ### 获取字段标记的表格字段配置列表
23
- * @param TargetClass 目标类
24
- * @param keyList 字段列表
18
+ * @param Class 目标类
25
19
  */
26
- export declare function getTableConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): Array<ITableColumn>;
20
+ export declare function getTableConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<ITableColumn>;
package/dist/main.js CHANGED
@@ -685,148 +685,113 @@ __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 target 目标实体类
691
+ * @param Class 目标类
695
692
  * @param classConfigKey 配置项索引键值
696
693
  * @param classConfig 配置的参数
697
694
  */
698
- static setClassConfig(target, classConfigKey, classConfig) {
699
- this.setProperty(target.prototype, classConfigKey, classConfig);
695
+ static setClassConfig(Class, classConfigKey, classConfig) {
696
+ this.setProperty(Class.prototype, classConfigKey, classConfig);
700
697
  }
701
698
  /**
702
699
  * ### 递归获取指定类的配置项
703
- * @param target 目标类
700
+ * @param Class 目标类
704
701
  * @param classConfigKey 配置项的Key
705
702
  * @param defaultValue `可选` 类装饰器请传入配置项实例
706
703
  * @param isObject `可选` 是否是对象配置
707
704
  */
708
- static getClassConfig(target, classConfigKey, defaultValue = void 0, isObject = false) {
709
- if (typeof target !== "object") {
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 superClass2 = Reflect.getPrototypeOf(target);
718
- if (!superClass2 || superClass2.constructor.name === Transformer.name) {
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(superClass2, classConfigKey);
715
+ return this.getClassConfig(SuperClass2, classConfigKey);
722
716
  }
723
717
  classConfig = classConfig || {};
724
- const superClass = Reflect.getPrototypeOf(target);
725
- if (!superClass || superClass.constructor.name === Transformer.name) {
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(superClass, classConfigKey, defaultValue, isObject),
723
+ ...this.getClassConfig(SuperClass, classConfigKey, defaultValue, isObject),
730
724
  ...classConfig
731
725
  };
732
726
  }
733
727
  /**
734
728
  * ### 设置一个属性配置项
735
- * @param target 目标类
736
- * @param key 属性
729
+ * @param instance 目标实例
730
+ * @param field 属性
737
731
  * @param fieldConfigKey 配置项索引键值
738
732
  * @param fieldConfig 配置的参数
739
- * @param fieldListKey `可选` 类配置项列表索引值
740
733
  */
741
- static setFieldConfig(target, key, fieldConfigKey, fieldConfig, fieldListKey) {
742
- if (fieldListKey) {
743
- this.addFieldDecoratorKey(target, key, fieldListKey);
744
- }
745
- this.setProperty(target, `${fieldConfigKey}[${key}]`, fieldConfig);
734
+ static setFieldConfig(instance, field, fieldConfigKey, fieldConfig) {
735
+ this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
746
736
  }
747
737
  /**
748
738
  * ### 获取类指定属性的指定类型的配置
749
- * @param target 目标类
750
- * @param key 属性
739
+ * @param Class 目标类
740
+ * @param field 属性
751
741
  * @param fieldConfigKey FieldConfigKey
752
742
  * @param isObject `可选` 是否对象配置
753
743
  */
754
- static getFieldConfig(target, key, fieldConfigKey, isObject = false) {
755
- if (typeof target !== "object") {
756
- target = target.prototype;
757
- }
758
- let fieldConfig = Reflect.get(target, `${fieldConfigKey}[${key}]`);
744
+ static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
745
+ let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
746
+ const SuperClass = Reflect.getPrototypeOf(Class);
759
747
  if (!isObject) {
760
748
  if (fieldConfig !== void 0) {
761
749
  return fieldConfig;
762
750
  }
763
- const superClass2 = Reflect.getPrototypeOf(target);
764
- if (!superClass2 || superClass2.constructor.name === Transformer.name) {
751
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
765
752
  return void 0;
766
753
  }
767
- return this.getFieldConfig(superClass2, key, fieldConfigKey);
754
+ return this.getFieldConfig(SuperClass, field, fieldConfigKey);
768
755
  }
769
756
  fieldConfig = fieldConfig || {};
770
- const superClass = Reflect.getPrototypeOf(target);
771
- if (!superClass || superClass.constructor.name === Transformer.name) {
757
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
772
758
  return {};
773
759
  }
774
760
  return {
775
- ...this.getFieldConfig(superClass, key, fieldConfigKey, true),
761
+ ...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
776
762
  ...fieldConfig
777
763
  };
778
764
  }
779
765
  /**
780
766
  * ### 获取类标记了装饰器的属性列表
781
- * @param target 目标类
767
+ * @param Class 目标类
782
768
  * @param fieldConfigKey FieldConfigKey
783
769
  * @param list `递归参数` 无需传入
784
770
  */
785
- static getFieldList(target, fieldConfigKey, list = []) {
786
- if (typeof target !== "object") {
787
- target = target.prototype;
788
- }
789
- const fieldList = Reflect.get(target, fieldConfigKey) || [];
771
+ static getFieldList(Class, fieldConfigKey, list = []) {
772
+ const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
790
773
  fieldList.forEach((item) => list.includes(item) || list.push(item));
791
- const superClass = Reflect.getPrototypeOf(target);
792
- if (!superClass || superClass.constructor.name === Transformer.name) {
774
+ const SuperClass = Reflect.getPrototypeOf(Class);
775
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
793
776
  return list;
794
777
  }
795
- return this.getFieldList(superClass, fieldConfigKey, list);
778
+ return this.getFieldList(SuperClass, fieldConfigKey, list);
796
779
  }
797
780
  /**
798
781
  * ### 反射添加属性
799
- * @param target 目标类
800
- * @param key 配置key
782
+ * @param instance 目标属性
783
+ * @param propertyKey 配置key
801
784
  * @param value 配置值
802
785
  */
803
- static setProperty(target, key, value) {
804
- if (typeof target !== "object") {
805
- target = target.prototype;
806
- }
807
- Reflect.defineProperty(target, key, {
786
+ static setProperty(instance, propertyKey, value) {
787
+ Reflect.defineProperty(instance, propertyKey, {
808
788
  enumerable: false,
809
789
  value,
810
790
  writable: false,
811
791
  configurable: true
812
792
  });
813
793
  }
814
- /**
815
- * ### 设置一个属性的包含装饰器索引
816
- * @param target 目标类
817
- * @param key 属性
818
- * @param fieldListKey 类配置项列表索引值
819
- */
820
- static addFieldDecoratorKey(target, key, fieldListKey) {
821
- if (typeof target !== "object") {
822
- target = target.prototype;
823
- }
824
- const list = Reflect.get(target, fieldListKey) || [];
825
- list.push(key);
826
- this.setProperty(target, fieldListKey, list);
827
- }
828
794
  }
829
- __publicField$3(DecoratorUtil, "DecoratorKeyPrefix", "[AirPower]");
830
795
  class Transformer {
831
796
  /**
832
797
  * ### 从 `JSON` 转换到当前类的对象
@@ -874,10 +839,10 @@ class Transformer {
874
839
  const instance = new Class();
875
840
  const fieldList = Object.keys(instance);
876
841
  for (const field of fieldList) {
877
- const jsonKey = this.getJsonKey(instance, field);
842
+ const jsonKey = this.getJsonKey(Class, field);
878
843
  const fieldData = json[jsonKey];
879
844
  instance[field] = fieldData;
880
- const toClass = getToClass(instance, field);
845
+ const toClass = getToClass(Class, field);
881
846
  if (toClass !== void 0) {
882
847
  try {
883
848
  ;
@@ -887,8 +852,8 @@ class Transformer {
887
852
  continue;
888
853
  }
889
854
  }
890
- const FieldTypeClass = getType(instance, field);
891
- const isArray2 = getArray(instance, field);
855
+ const FieldTypeClass = getType(Class, field);
856
+ const isArray2 = getArray(Class, field);
892
857
  if (isArray2) {
893
858
  const fieldValueList = [];
894
859
  if (typeof fieldData === "object" && Array.isArray(fieldData)) {
@@ -922,7 +887,7 @@ class Transformer {
922
887
  }
923
888
  }
924
889
  for (const fieldKey of fieldList) {
925
- const alias = getAlias(instance, fieldKey) || fieldKey;
890
+ const alias = getAlias(Class, fieldKey) || fieldKey;
926
891
  if (alias === fieldKey) {
927
892
  continue;
928
893
  }
@@ -932,19 +897,19 @@ class Transformer {
932
897
  }
933
898
  /**
934
899
  * ### 获取 JSON 的 key
935
- * @param instance 目标实例
900
+ * @param Class 目标实例
936
901
  * @param field 属性 key
937
902
  */
938
- static getJsonKey(instance, field) {
939
- const alias = getAlias(instance, field);
903
+ static getJsonKey(Class, field) {
904
+ const alias = getAlias(Class, field);
940
905
  if (alias) {
941
906
  return alias;
942
907
  }
943
- const prefix = getPrefix(instance);
908
+ const prefix = getPrefix(Class);
944
909
  if (!prefix) {
945
910
  return field;
946
911
  }
947
- const ignorePrefix = getIgnorePrefix(instance, field);
912
+ const ignorePrefix = getIgnorePrefix(Class, field);
948
913
  if (!ignorePrefix) {
949
914
  return prefix + field;
950
915
  }
@@ -996,6 +961,7 @@ class Transformer {
996
961
  * 会自动进行数据别名转换
997
962
  */
998
963
  toJson() {
964
+ const Class = this.constructor;
999
965
  const fieldList = Object.keys(this);
1000
966
  const json = {};
1001
967
  for (const field of fieldList) {
@@ -1003,9 +969,9 @@ class Transformer {
1003
969
  if (data === null || data === void 0) {
1004
970
  continue;
1005
971
  }
1006
- const jsonKey = Transformer.getJsonKey(this, field);
972
+ const jsonKey = Transformer.getJsonKey(Class, field);
1007
973
  json[jsonKey] = data;
1008
- const toJson = getToJson(this, field);
974
+ const toJson = getToJson(Class, field);
1009
975
  if (toJson !== void 0) {
1010
976
  try {
1011
977
  json[jsonKey] = toJson(this);
@@ -1033,66 +999,68 @@ class Transformer {
1033
999
  return json;
1034
1000
  }
1035
1001
  }
1036
- const KEY$5 = `${DecoratorUtil.DecoratorKeyPrefix}[Alias]`;
1002
+ const KEY$5 = "[Alias]";
1037
1003
  function Alias(alias) {
1038
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$5, alias);
1004
+ return (instance, field) => {
1005
+ DecoratorUtil.setFieldConfig(instance, field, KEY$5, alias);
1006
+ };
1039
1007
  }
1040
- function getAlias(target, key) {
1041
- return (DecoratorUtil.getFieldConfig(target, key.toString(), KEY$5) || "").toString();
1008
+ function getAlias(Class, field) {
1009
+ return (DecoratorUtil.getFieldConfig(Class, field, KEY$5) || "").toString();
1042
1010
  }
1043
- const KEY$4$1 = `${DecoratorUtil.DecoratorKeyPrefix}[IgnorePrefix]`;
1011
+ const KEY$4$1 = "[IgnorePrefix]";
1044
1012
  function IgnorePrefix() {
1045
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$4$1, true);
1013
+ return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$4$1, true);
1046
1014
  }
1047
- function getIgnorePrefix(target, key) {
1048
- return !!DecoratorUtil.getFieldConfig(target, key.toString(), KEY$4$1);
1015
+ function getIgnorePrefix(Class, field) {
1016
+ return !!DecoratorUtil.getFieldConfig(Class, field, KEY$4$1);
1049
1017
  }
1050
- const KEY$3$1 = `${DecoratorUtil.DecoratorKeyPrefix}[Prefix]`;
1018
+ const KEY$3$1 = "[Prefix]";
1051
1019
  function Prefix(prefix) {
1052
- return (target) => DecoratorUtil.setClassConfig(target, KEY$3$1, prefix);
1020
+ return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
1053
1021
  }
1054
- function getPrefix(target) {
1055
- return DecoratorUtil.getClassConfig(target, KEY$3$1, "");
1022
+ function getPrefix(Class) {
1023
+ return DecoratorUtil.getClassConfig(Class, KEY$3$1, "");
1056
1024
  }
1057
- const KEY$2$1 = `${DecoratorUtil.DecoratorKeyPrefix}[ToClass]`;
1025
+ const KEY$2$1 = "[ToClass]";
1058
1026
  function ToClass(func) {
1059
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$2$1, func);
1027
+ return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$2$1, func);
1060
1028
  }
1061
- function getToClass(target, key) {
1062
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$2$1);
1029
+ function getToClass(target, field) {
1030
+ return DecoratorUtil.getFieldConfig(target, field, KEY$2$1);
1063
1031
  }
1064
- const KEY$1$1 = `${DecoratorUtil.DecoratorKeyPrefix}[ToJson]`;
1032
+ const KEY$1$1 = "[ToJson]";
1065
1033
  function ToJson(func) {
1066
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$1$1, func);
1034
+ return (instance, key) => DecoratorUtil.setFieldConfig(instance, key, KEY$1$1, func);
1067
1035
  }
1068
- function getToJson(target, key) {
1069
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$1$1);
1036
+ function getToJson(Class, field) {
1037
+ return DecoratorUtil.getFieldConfig(Class, field, KEY$1$1);
1070
1038
  }
1071
- const KEY$6 = `${DecoratorUtil.DecoratorKeyPrefix}[Type]`;
1072
- const KEY_ARRAY = `${DecoratorUtil.DecoratorKeyPrefix}[Array]`;
1039
+ const KEY$6 = "[Type]";
1040
+ const KEY_ARRAY = "[Array]";
1073
1041
  function Type(type, array = false) {
1074
- return (target, key) => {
1075
- DecoratorUtil.setFieldConfig(target, key, KEY$6, type);
1042
+ return (instance, field) => {
1043
+ DecoratorUtil.setFieldConfig(instance, field, KEY$6, type);
1076
1044
  if (array) {
1077
- DecoratorUtil.setFieldConfig(target, key, KEY_ARRAY, array);
1045
+ DecoratorUtil.setFieldConfig(instance, field, KEY_ARRAY, array);
1078
1046
  }
1079
1047
  };
1080
1048
  }
1081
- function getType(target, key) {
1082
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$6) || void 0;
1049
+ function getType(Class, field) {
1050
+ return DecoratorUtil.getFieldConfig(Class, field, KEY$6) || void 0;
1083
1051
  }
1084
- function getArray(target, key) {
1085
- return !!DecoratorUtil.getFieldConfig(target, key.toString(), KEY_ARRAY);
1052
+ function getArray(Class, field) {
1053
+ return !!DecoratorUtil.getFieldConfig(Class, field, KEY_ARRAY);
1086
1054
  }
1087
- const KEY$4 = `${DecoratorUtil.DecoratorKeyPrefix}[MODEL]`;
1055
+ const KEY$4 = "[MODEL]";
1088
1056
  function Model(config = {}) {
1089
- return (target) => DecoratorUtil.setClassConfig(target, KEY$4, config);
1057
+ return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
1090
1058
  }
1091
- function getModelConfig(TargetClass) {
1092
- return DecoratorUtil.getClassConfig(TargetClass, KEY$4, {}, true);
1059
+ function getModelConfig(Class) {
1060
+ return DecoratorUtil.getClassConfig(Class, KEY$4, {}, true);
1093
1061
  }
1094
- function getModelName(TargetClass) {
1095
- return getModelConfig(TargetClass).label || TargetClass.name;
1062
+ function getModelName(Class) {
1063
+ return getModelConfig(Class).label || Class.name;
1096
1064
  }
1097
1065
  var PermissionAction = /* @__PURE__ */ ((PermissionAction2) => {
1098
1066
  PermissionAction2["ADD"] = "add";
@@ -10206,23 +10174,23 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
10206
10174
  }
10207
10175
  });
10208
10176
  const Empty = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-f633fb7c"]]);
10209
- const KEY$3 = `${DecoratorUtil.DecoratorKeyPrefix}[Field]`;
10177
+ const KEY$3 = "[Field]";
10210
10178
  function Field(config = {}) {
10211
- return (target, key) => {
10212
- config.key = key;
10213
- DecoratorUtil.setFieldConfig(target, key, KEY$3, config);
10179
+ return (instance, field) => {
10180
+ config.key = field.toString();
10181
+ DecoratorUtil.setFieldConfig(instance, field, KEY$3, config);
10214
10182
  };
10215
10183
  }
10216
- function getFieldConfig(TargetClass, key) {
10217
- return DecoratorUtil.getFieldConfig(TargetClass, key.toString(), KEY$3, true) || {};
10184
+ function getFieldConfig(Class, field) {
10185
+ return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$3, true) || {};
10218
10186
  }
10219
- function getDictionary(TargetClass, key) {
10187
+ function getDictionary(Class, field) {
10220
10188
  var _a;
10221
- return (_a = getFieldConfig(TargetClass, key)) == null ? void 0 : _a.dictionary;
10189
+ return (_a = getFieldConfig(Class, field)) == null ? void 0 : _a.dictionary;
10222
10190
  }
10223
- function getFieldLabel(TargetClass, key) {
10191
+ function getFieldLabel(Class, field) {
10224
10192
  var _a;
10225
- return ((_a = getFieldConfig(TargetClass, key)) == null ? void 0 : _a.label) || key.toString();
10193
+ return ((_a = getFieldConfig(Class, field)) == null ? void 0 : _a.label) || field.toString();
10226
10194
  }
10227
10195
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
10228
10196
  __name: "FormField",
@@ -13649,35 +13617,29 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
13649
13617
  };
13650
13618
  }
13651
13619
  });
13652
- const KEY$2 = `${DecoratorUtil.DecoratorKeyPrefix}[Form]`;
13653
- const LIST_KEY$2 = `${DecoratorUtil.DecoratorKeyPrefix}[FormList]`;
13620
+ const KEY$2 = "[Form]";
13654
13621
  function Form(config = {}) {
13655
- return (target, key) => {
13656
- config.key = key;
13657
- DecoratorUtil.setFieldConfig(target, key, KEY$2, config, LIST_KEY$2);
13622
+ return (instance, key) => {
13623
+ config.key = key.toString();
13624
+ DecoratorUtil.setFieldConfig(instance, key, KEY$2, config);
13658
13625
  };
13659
13626
  }
13660
- function getFormConfig(TargetClass, key) {
13661
- const formConfig = DecoratorUtil.getFieldConfig(TargetClass, key.toString(), KEY$2, true);
13627
+ function getFormConfig(Class, field) {
13628
+ const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true);
13662
13629
  if (!formConfig) {
13663
- return { key: key.toString() };
13630
+ return { key: "" };
13664
13631
  }
13665
13632
  if (!formConfig.dictionary) {
13666
- const props = getFieldConfig(TargetClass, key);
13633
+ const props = getFieldConfig(Class, field);
13667
13634
  if (props && props.dictionary) {
13668
13635
  formConfig.dictionary = props.dictionary;
13669
13636
  }
13670
13637
  }
13671
13638
  return formConfig;
13672
13639
  }
13673
- function getFormFieldList(TargetClass) {
13674
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY$2);
13675
- }
13676
- function getFormConfigList(TargetClass, keyList = []) {
13677
- if (keyList.length === 0) {
13678
- keyList = getFormFieldList(TargetClass);
13679
- }
13680
- const list = keyList.map((key) => getFormConfig(TargetClass, key));
13640
+ function getFormConfigList(Class) {
13641
+ const fieldList = Object.keys(Class.prototype);
13642
+ const list = fieldList.map((field) => getFormConfig(Class, field)).filter((item) => !!item.key);
13681
13643
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
13682
13644
  }
13683
13645
  var FormTrim = /* @__PURE__ */ ((FormTrim2) => {
@@ -16773,56 +16735,42 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
16773
16735
  };
16774
16736
  }
16775
16737
  });
16776
- const KEY$1 = `${DecoratorUtil.DecoratorKeyPrefix}[Search]`;
16777
- const LIST_KEY$1 = `${DecoratorUtil.DecoratorKeyPrefix}[SearchList]`;
16738
+ const KEY$1 = "[Search]";
16778
16739
  function Search(config = {}) {
16779
- return (target, key) => {
16780
- config.key = key;
16781
- DecoratorUtil.setFieldConfig(target, key, KEY$1, config, LIST_KEY$1);
16740
+ return (instance, field) => {
16741
+ config.key = field.toString();
16742
+ DecoratorUtil.setFieldConfig(instance, field, KEY$1, config);
16782
16743
  };
16783
16744
  }
16784
- function getSearchConfig(TargetClass, key) {
16785
- const instance = new TargetClass();
16786
- const formConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY$1, true);
16745
+ function getSearchConfig(Class, field) {
16746
+ const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$1, true);
16787
16747
  if (!formConfig) {
16788
- return { key: key.toString() };
16748
+ return { key: "" };
16789
16749
  }
16790
16750
  return formConfig;
16791
16751
  }
16792
- function getSearchFieldList(TargetClass) {
16793
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY$1);
16794
- }
16795
- function getSearchConfigList(TargetClass, keyList = []) {
16796
- if (keyList.length === 0) {
16797
- keyList = getSearchFieldList(TargetClass);
16798
- }
16799
- const list = keyList.map((key) => getSearchConfig(TargetClass, key));
16752
+ function getSearchConfigList(Class) {
16753
+ const fieldList = Object.keys(Class.prototype);
16754
+ const list = fieldList.map((field) => getSearchConfig(Class, field));
16800
16755
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
16801
16756
  }
16802
- const KEY = `${DecoratorUtil.DecoratorKeyPrefix}[Table]`;
16803
- const LIST_KEY = `${DecoratorUtil.DecoratorKeyPrefix}[TableList]`;
16757
+ const KEY = "[Table]";
16804
16758
  function Table(config = {}) {
16805
- return (target, key) => {
16806
- config.key = key;
16807
- DecoratorUtil.setFieldConfig(target, key, KEY, config, LIST_KEY);
16759
+ return (instance, field) => {
16760
+ config.key = field.toString();
16761
+ DecoratorUtil.setFieldConfig(instance, field, KEY, config);
16808
16762
  };
16809
16763
  }
16810
- function getTableConfig(TargetClass, key) {
16811
- const instance = new TargetClass();
16812
- const tableConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY, true);
16764
+ function getTableConfig(Class, field) {
16765
+ const tableConfig = DecoratorUtil.getFieldConfig(Class, field, KEY, true);
16813
16766
  if (!tableConfig) {
16814
- return { key: key.toString() };
16767
+ return { key: "" };
16815
16768
  }
16816
16769
  return tableConfig;
16817
16770
  }
16818
- function getTableFieldList(TargetClass) {
16819
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY);
16820
- }
16821
- function getTableConfigList(TargetClass, keyList = []) {
16822
- if (keyList.length === 0) {
16823
- keyList = getTableFieldList(TargetClass);
16824
- }
16825
- const list = keyList.map((key) => getTableConfig(TargetClass, key));
16771
+ function getTableConfigList(Class) {
16772
+ const fieldList = Object.keys(Class.prototype);
16773
+ const list = fieldList.map((field) => getTableConfig(Class, field)).filter((item) => !!item.key);
16826
16774
  return list.sort((a, b) => (b.order || 0) - (a.order || 0));
16827
16775
  }
16828
16776
  var __defProp$2 = Object.defineProperty;
@@ -18746,7 +18694,7 @@ class WebValidator {
18746
18694
  */
18747
18695
  static createRules(service, rules = {}) {
18748
18696
  const formRules = rules;
18749
- const formFieldList = getFormFieldList(service.entityClass).map((key) => getFormConfig(service.entityClass, key));
18697
+ const formFieldList = getFormConfigList(service.entityClass);
18750
18698
  for (let i = 0; i < formFieldList.length; i += 1) {
18751
18699
  const config = formFieldList[i];
18752
18700
  const fieldKey = config.key;
@@ -19799,17 +19747,14 @@ export {
19799
19747
  getFieldLabel,
19800
19748
  getFormConfig,
19801
19749
  getFormConfigList,
19802
- getFormFieldList,
19803
19750
  getIgnorePrefix,
19804
19751
  getModelConfig,
19805
19752
  getModelName,
19806
19753
  getPrefix,
19807
19754
  getSearchConfig,
19808
19755
  getSearchConfigList,
19809
- getSearchFieldList,
19810
19756
  getTableConfig,
19811
19757
  getTableConfigList,
19812
- getTableFieldList,
19813
19758
  getToClass,
19814
19759
  getToJson,
19815
19760
  getType,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.2.28",
4
+ "version": "0.2.30",
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.3",
44
+ "@airpower/transformer": "^0.1.7",
45
45
  "@airpower/util": "^0.1.3",
46
46
  "@element-plus/icons-vue": "^2.3.1",
47
47
  "axios": "^1.8.4",