@airpower/web 0.2.29 → 0.2.31

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.
@@ -13,14 +13,8 @@ export declare function Form<M extends RootModel>(config?: FieldConfigOptionalKe
13
13
  * @param field 属性名
14
14
  */
15
15
  export declare function getFormConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFormField;
16
- /**
17
- * ### 获取标记了表单配置的字段列表
18
- * @param Class 目标类
19
- */
20
- export declare function getFormFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
16
  /**
22
17
  * ### 获取指定类的表单字段配置项列表
23
18
  * @param Class 目标类
24
- * @param fieldList 选择字段列表
25
19
  */
26
- export declare function getFormConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): IFormField[];
20
+ export declare function getFormConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): IFormField[];
@@ -13,14 +13,8 @@ export declare function Search<M extends RootModel>(config?: FieldConfigOptional
13
13
  * @param field 属性名
14
14
  */
15
15
  export declare function getSearchConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ISearchField;
16
- /**
17
- * ### 获取标记了搜索配置的字段列表
18
- * @param Class 目标类
19
- */
20
- export declare function getSearchFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
16
  /**
22
17
  * ### 获取指定类的搜索字段配置项列表
23
18
  * @param Class 目标类
24
- * @param fieldList 选择字段列表
25
19
  */
26
- export declare function getSearchConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): ISearchField[];
20
+ export declare function getSearchConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): ISearchField[];
@@ -13,14 +13,8 @@ export declare function Table<M extends RootModel>(config?: FieldConfigOptionalK
13
13
  * @param field 属性名
14
14
  */
15
15
  export declare function getTableConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ITableColumn;
16
- /**
17
- * ### 获取标记了表格配置的字段列表
18
- * @param Class 目标类
19
- */
20
- export declare function getTableFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
16
  /**
22
17
  * ### 获取字段标记的表格字段配置列表
23
18
  * @param Class 目标类
24
- * @param fieldList 字段列表
25
19
  */
26
- export declare function getTableConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): Array<ITableColumn>;
20
+ export declare function getTableConfigList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<ITableColumn>;
package/dist/main.js CHANGED
@@ -685,128 +685,6 @@ __publicField(WebConfig, "treeProps", {
685
685
  children: "children",
686
686
  label: "name"
687
687
  });
688
- class DecoratorUtil {
689
- /**
690
- * ### 设置一个类配置项
691
- * @param Class 目标类
692
- * @param classConfigKey 配置项索引键值
693
- * @param classConfig 配置的参数
694
- */
695
- static setClassConfig(Class, classConfigKey, classConfig) {
696
- this.setProperty(Class.prototype, classConfigKey, classConfig);
697
- }
698
- /**
699
- * ### 递归获取指定类的配置项
700
- * @param Class 目标类
701
- * @param classConfigKey 配置项的Key
702
- * @param defaultValue `可选` 类装饰器请传入配置项实例
703
- * @param isObject `可选` 是否是对象配置
704
- */
705
- static getClassConfig(Class, classConfigKey, defaultValue = void 0, isObject = false) {
706
- let classConfig = Reflect.get(Class, classConfigKey);
707
- if (!isObject) {
708
- if (classConfig) {
709
- return classConfig;
710
- }
711
- const SuperClass2 = Reflect.getPrototypeOf(Class);
712
- if (!SuperClass2 || SuperClass2.prototype.constructor.name === Transformer.name) {
713
- return void 0;
714
- }
715
- return this.getClassConfig(SuperClass2, classConfigKey);
716
- }
717
- classConfig = classConfig || {};
718
- const SuperClass = Reflect.getPrototypeOf(Class);
719
- if (!SuperClass || SuperClass.constructor.name === Transformer.name) {
720
- return defaultValue;
721
- }
722
- return {
723
- ...this.getClassConfig(SuperClass, classConfigKey, defaultValue, isObject),
724
- ...classConfig
725
- };
726
- }
727
- /**
728
- * ### 设置一个属性配置项
729
- * @param instance 目标实例
730
- * @param field 属性
731
- * @param fieldConfigKey 配置项索引键值
732
- * @param fieldConfig 配置的参数
733
- * @param fieldListKey `可选` 类配置项列表索引值
734
- */
735
- static setFieldConfig(instance, field, fieldConfigKey, fieldConfig, fieldListKey) {
736
- if (fieldListKey) {
737
- this.addFieldDecoratorKey(instance, field, fieldListKey);
738
- }
739
- this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
740
- }
741
- /**
742
- * ### 获取类指定属性的指定类型的配置
743
- * @param Class 目标类
744
- * @param field 属性
745
- * @param fieldConfigKey FieldConfigKey
746
- * @param isObject `可选` 是否对象配置
747
- */
748
- static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
749
- let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
750
- const SuperClass = Reflect.getPrototypeOf(Class);
751
- if (!isObject) {
752
- if (fieldConfig !== void 0) {
753
- return fieldConfig;
754
- }
755
- if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
756
- return void 0;
757
- }
758
- return this.getFieldConfig(SuperClass, field, fieldConfigKey);
759
- }
760
- fieldConfig = fieldConfig || {};
761
- if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
762
- return {};
763
- }
764
- return {
765
- ...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
766
- ...fieldConfig
767
- };
768
- }
769
- /**
770
- * ### 获取类标记了装饰器的属性列表
771
- * @param Class 目标类
772
- * @param fieldConfigKey FieldConfigKey
773
- * @param list `递归参数` 无需传入
774
- */
775
- static getFieldList(Class, fieldConfigKey, list = []) {
776
- const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
777
- fieldList.forEach((item) => list.includes(item) || list.push(item));
778
- const SuperClass = Reflect.getPrototypeOf(Class);
779
- if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
780
- return list;
781
- }
782
- return this.getFieldList(SuperClass, fieldConfigKey, list);
783
- }
784
- /**
785
- * ### 反射添加属性
786
- * @param instance 目标属性
787
- * @param propertyKey 配置key
788
- * @param value 配置值
789
- */
790
- static setProperty(instance, propertyKey, value) {
791
- Reflect.defineProperty(instance, propertyKey, {
792
- enumerable: false,
793
- value,
794
- writable: false,
795
- configurable: true
796
- });
797
- }
798
- /**
799
- * ### 设置一个属性的包含装饰器索引
800
- * @param instance 目标类
801
- * @param field 属性
802
- * @param propertyKey 类配置项列表索引值
803
- */
804
- static addFieldDecoratorKey(instance, field, propertyKey) {
805
- const list = Reflect.get(instance, propertyKey) || [];
806
- list.push(field);
807
- this.setProperty(instance, propertyKey, list);
808
- }
809
- }
810
688
  class Transformer {
811
689
  /**
812
690
  * ### 从 `JSON` 转换到当前类的对象
@@ -1014,6 +892,97 @@ class Transformer {
1014
892
  return json;
1015
893
  }
1016
894
  }
895
+ class DecoratorUtil {
896
+ /**
897
+ * ### 设置一个类配置项
898
+ * @param Class 目标类
899
+ * @param classConfigKey 配置项索引键值
900
+ * @param classConfig 配置的参数
901
+ */
902
+ static setClassConfig(Class, classConfigKey, classConfig) {
903
+ this.setProperty(Class.prototype, classConfigKey, classConfig);
904
+ }
905
+ /**
906
+ * ### 递归获取指定类的配置项
907
+ * @param Class 目标类
908
+ * @param classConfigKey 配置项的Key
909
+ * @param isObject `可选` 是否是对象配置
910
+ */
911
+ static getClassConfig(Class, classConfigKey, isObject = false) {
912
+ let classConfig = Reflect.get(Class, classConfigKey);
913
+ if (!isObject) {
914
+ if (classConfig) {
915
+ return classConfig;
916
+ }
917
+ const SuperClass2 = Reflect.getPrototypeOf(Class);
918
+ if (!SuperClass2 || SuperClass2.prototype.constructor.name === Transformer.name) {
919
+ return void 0;
920
+ }
921
+ return this.getClassConfig(SuperClass2, classConfigKey);
922
+ }
923
+ classConfig = classConfig || {};
924
+ const SuperClass = Reflect.getPrototypeOf(Class);
925
+ if (!SuperClass || SuperClass.constructor.name === Transformer.name) {
926
+ return classConfig;
927
+ }
928
+ return {
929
+ ...this.getClassConfig(SuperClass, classConfigKey, isObject),
930
+ ...classConfig
931
+ };
932
+ }
933
+ /**
934
+ * ### 设置一个属性配置项
935
+ * @param instance 目标实例
936
+ * @param field 属性
937
+ * @param fieldConfigKey 配置项索引键值
938
+ * @param fieldConfig 配置的参数
939
+ */
940
+ static setFieldConfig(instance, field, fieldConfigKey, fieldConfig) {
941
+ this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
942
+ }
943
+ /**
944
+ * ### 获取类指定属性的指定类型的配置
945
+ * @param Class 目标类
946
+ * @param field 属性
947
+ * @param fieldConfigKey FieldConfigKey
948
+ * @param isObject `可选` 是否对象配置
949
+ */
950
+ static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
951
+ let fieldConfig = Reflect.get(new Class(), `${fieldConfigKey}[${field.toString()}]`);
952
+ const SuperClass = Reflect.getPrototypeOf(Class);
953
+ if (!isObject) {
954
+ if (fieldConfig !== void 0) {
955
+ return fieldConfig;
956
+ }
957
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
958
+ return void 0;
959
+ }
960
+ return this.getFieldConfig(SuperClass, field, fieldConfigKey);
961
+ }
962
+ fieldConfig = fieldConfig || {};
963
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
964
+ return fieldConfig;
965
+ }
966
+ return {
967
+ ...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
968
+ ...fieldConfig
969
+ };
970
+ }
971
+ /**
972
+ * ### 反射添加属性
973
+ * @param instance 目标属性
974
+ * @param propertyKey 配置key
975
+ * @param value 配置值
976
+ */
977
+ static setProperty(instance, propertyKey, value) {
978
+ Reflect.defineProperty(instance, propertyKey, {
979
+ enumerable: false,
980
+ value,
981
+ writable: false,
982
+ configurable: true
983
+ });
984
+ }
985
+ }
1017
986
  const KEY$5 = "[Alias]";
1018
987
  function Alias(alias) {
1019
988
  return (instance, field) => {
@@ -1035,7 +1004,7 @@ function Prefix(prefix) {
1035
1004
  return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
1036
1005
  }
1037
1006
  function getPrefix(Class) {
1038
- return DecoratorUtil.getClassConfig(Class, KEY$3$1, "");
1007
+ return DecoratorUtil.getClassConfig(Class, KEY$3$1) || "";
1039
1008
  }
1040
1009
  const KEY$2$1 = "[ToClass]";
1041
1010
  function ToClass(func) {
@@ -1072,7 +1041,7 @@ function Model(config = {}) {
1072
1041
  return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
1073
1042
  }
1074
1043
  function getModelConfig(Class) {
1075
- return DecoratorUtil.getClassConfig(Class, KEY$4, {}, true);
1044
+ return DecoratorUtil.getClassConfig(Class, KEY$4, true) || {};
1076
1045
  }
1077
1046
  function getModelName(Class) {
1078
1047
  return getModelConfig(Class).label || Class.name;
@@ -13633,34 +13602,18 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
13633
13602
  }
13634
13603
  });
13635
13604
  const KEY$2 = "[Form]";
13636
- const LIST_KEY$2 = "[FormList]";
13637
13605
  function Form(config = {}) {
13638
13606
  return (instance, key) => {
13639
13607
  config.key = key.toString();
13640
- DecoratorUtil.setFieldConfig(instance, key, KEY$2, config, LIST_KEY$2);
13608
+ DecoratorUtil.setFieldConfig(instance, key, KEY$2, config);
13641
13609
  };
13642
13610
  }
13643
13611
  function getFormConfig(Class, field) {
13644
- const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true);
13645
- if (!formConfig) {
13646
- return { key: field.toString() };
13647
- }
13648
- if (!formConfig.dictionary) {
13649
- const props = getFieldConfig(Class, field);
13650
- if (props && props.dictionary) {
13651
- formConfig.dictionary = props.dictionary;
13652
- }
13653
- }
13654
- return formConfig;
13655
- }
13656
- function getFormFieldList(Class) {
13657
- return DecoratorUtil.getFieldList(Class, LIST_KEY$2);
13612
+ return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true) || {};
13658
13613
  }
13659
- function getFormConfigList(Class, fieldList = []) {
13660
- if (fieldList.length === 0) {
13661
- fieldList = getFormFieldList(Class);
13662
- }
13663
- const list = fieldList.map((field) => getFormConfig(Class, field));
13614
+ function getFormConfigList(Class) {
13615
+ const fieldList = Object.keys(Class.prototype);
13616
+ const list = fieldList.map((field) => getFormConfig(Class, field)).filter((item) => !!item.key);
13664
13617
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
13665
13618
  }
13666
13619
  var FormTrim = /* @__PURE__ */ ((FormTrim2) => {
@@ -16757,53 +16710,33 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
16757
16710
  }
16758
16711
  });
16759
16712
  const KEY$1 = "[Search]";
16760
- const LIST_KEY$1 = "[SearchList]";
16761
16713
  function Search(config = {}) {
16762
16714
  return (instance, field) => {
16763
16715
  config.key = field.toString();
16764
- DecoratorUtil.setFieldConfig(instance, field, KEY$1, config, LIST_KEY$1);
16716
+ DecoratorUtil.setFieldConfig(instance, field, KEY$1, config);
16765
16717
  };
16766
16718
  }
16767
16719
  function getSearchConfig(Class, field) {
16768
- const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$1, true);
16769
- if (!formConfig) {
16770
- return { key: field.toString() };
16771
- }
16772
- return formConfig;
16773
- }
16774
- function getSearchFieldList(Class) {
16775
- return DecoratorUtil.getFieldList(Class, LIST_KEY$1);
16720
+ return DecoratorUtil.getFieldConfig(Class, field, KEY$1, true) || {};
16776
16721
  }
16777
- function getSearchConfigList(Class, fieldList = []) {
16778
- if (fieldList.length === 0) {
16779
- fieldList = getSearchFieldList(Class);
16780
- }
16781
- const list = fieldList.map((field) => getSearchConfig(Class, field));
16722
+ function getSearchConfigList(Class) {
16723
+ const fieldList = Object.keys(new Class());
16724
+ const list = fieldList.map((field) => getSearchConfig(Class, field)).filter((item) => !!item.key);
16782
16725
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
16783
16726
  }
16784
16727
  const KEY = "[Table]";
16785
- const LIST_KEY = "[TableList]";
16786
16728
  function Table(config = {}) {
16787
16729
  return (instance, field) => {
16788
16730
  config.key = field.toString();
16789
- DecoratorUtil.setFieldConfig(instance, field, KEY, config, LIST_KEY);
16731
+ DecoratorUtil.setFieldConfig(instance, field, KEY, config);
16790
16732
  };
16791
16733
  }
16792
16734
  function getTableConfig(Class, field) {
16793
- const tableConfig = DecoratorUtil.getFieldConfig(Class, field, KEY, true);
16794
- if (!tableConfig) {
16795
- return { key: field.toString() };
16796
- }
16797
- return tableConfig;
16798
- }
16799
- function getTableFieldList(Class) {
16800
- return DecoratorUtil.getFieldList(Class, LIST_KEY);
16735
+ return DecoratorUtil.getFieldConfig(Class, field, KEY, true) || {};
16801
16736
  }
16802
- function getTableConfigList(Class, fieldList = []) {
16803
- if (fieldList.length === 0) {
16804
- fieldList = getTableFieldList(Class);
16805
- }
16806
- const list = fieldList.map((field) => getTableConfig(Class, field));
16737
+ function getTableConfigList(Class) {
16738
+ const fieldList = Object.keys(Class.prototype);
16739
+ const list = fieldList.map((field) => getTableConfig(Class, field)).filter((item) => !!item.key);
16807
16740
  return list.sort((a, b) => (b.order || 0) - (a.order || 0));
16808
16741
  }
16809
16742
  var __defProp$2 = Object.defineProperty;
@@ -18727,7 +18660,7 @@ class WebValidator {
18727
18660
  */
18728
18661
  static createRules(service, rules = {}) {
18729
18662
  const formRules = rules;
18730
- const formFieldList = getFormFieldList(service.entityClass).map((key) => getFormConfig(service.entityClass, key));
18663
+ const formFieldList = getFormConfigList(service.entityClass);
18731
18664
  for (let i = 0; i < formFieldList.length; i += 1) {
18732
18665
  const config = formFieldList[i];
18733
18666
  const fieldKey = config.key;
@@ -19780,17 +19713,14 @@ export {
19780
19713
  getFieldLabel,
19781
19714
  getFormConfig,
19782
19715
  getFormConfigList,
19783
- getFormFieldList,
19784
19716
  getIgnorePrefix,
19785
19717
  getModelConfig,
19786
19718
  getModelName,
19787
19719
  getPrefix,
19788
19720
  getSearchConfig,
19789
19721
  getSearchConfigList,
19790
- getSearchFieldList,
19791
19722
  getTableConfig,
19792
19723
  getTableConfigList,
19793
- getTableFieldList,
19794
19724
  getToClass,
19795
19725
  getToJson,
19796
19726
  getType,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.2.29",
4
+ "version": "0.2.31",
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.6",
44
+ "@airpower/transformer": "^0.1.10",
45
45
  "@airpower/util": "^0.1.3",
46
46
  "@element-plus/icons-vue": "^2.3.1",
47
47
  "axios": "^1.8.4",