@airpower/web 0.2.30 → 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.
- package/dist/main.js +98 -132
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -685,113 +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
|
-
*/
|
|
734
|
-
static setFieldConfig(instance, field, fieldConfigKey, fieldConfig) {
|
|
735
|
-
this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* ### 获取类指定属性的指定类型的配置
|
|
739
|
-
* @param Class 目标类
|
|
740
|
-
* @param field 属性
|
|
741
|
-
* @param fieldConfigKey FieldConfigKey
|
|
742
|
-
* @param isObject `可选` 是否对象配置
|
|
743
|
-
*/
|
|
744
|
-
static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
|
|
745
|
-
let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
|
|
746
|
-
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
747
|
-
if (!isObject) {
|
|
748
|
-
if (fieldConfig !== void 0) {
|
|
749
|
-
return fieldConfig;
|
|
750
|
-
}
|
|
751
|
-
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
752
|
-
return void 0;
|
|
753
|
-
}
|
|
754
|
-
return this.getFieldConfig(SuperClass, field, fieldConfigKey);
|
|
755
|
-
}
|
|
756
|
-
fieldConfig = fieldConfig || {};
|
|
757
|
-
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
758
|
-
return {};
|
|
759
|
-
}
|
|
760
|
-
return {
|
|
761
|
-
...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
|
|
762
|
-
...fieldConfig
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* ### 获取类标记了装饰器的属性列表
|
|
767
|
-
* @param Class 目标类
|
|
768
|
-
* @param fieldConfigKey FieldConfigKey
|
|
769
|
-
* @param list `递归参数` 无需传入
|
|
770
|
-
*/
|
|
771
|
-
static getFieldList(Class, fieldConfigKey, list = []) {
|
|
772
|
-
const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
|
|
773
|
-
fieldList.forEach((item) => list.includes(item) || list.push(item));
|
|
774
|
-
const SuperClass = Reflect.getPrototypeOf(Class);
|
|
775
|
-
if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
|
|
776
|
-
return list;
|
|
777
|
-
}
|
|
778
|
-
return this.getFieldList(SuperClass, fieldConfigKey, list);
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* ### 反射添加属性
|
|
782
|
-
* @param instance 目标属性
|
|
783
|
-
* @param propertyKey 配置key
|
|
784
|
-
* @param value 配置值
|
|
785
|
-
*/
|
|
786
|
-
static setProperty(instance, propertyKey, value) {
|
|
787
|
-
Reflect.defineProperty(instance, propertyKey, {
|
|
788
|
-
enumerable: false,
|
|
789
|
-
value,
|
|
790
|
-
writable: false,
|
|
791
|
-
configurable: true
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
688
|
class Transformer {
|
|
796
689
|
/**
|
|
797
690
|
* ### 从 `JSON` 转换到当前类的对象
|
|
@@ -999,6 +892,97 @@ class Transformer {
|
|
|
999
892
|
return json;
|
|
1000
893
|
}
|
|
1001
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
|
+
}
|
|
1002
986
|
const KEY$5 = "[Alias]";
|
|
1003
987
|
function Alias(alias) {
|
|
1004
988
|
return (instance, field) => {
|
|
@@ -1020,7 +1004,7 @@ function Prefix(prefix) {
|
|
|
1020
1004
|
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
|
|
1021
1005
|
}
|
|
1022
1006
|
function getPrefix(Class) {
|
|
1023
|
-
return DecoratorUtil.getClassConfig(Class, KEY$3$1
|
|
1007
|
+
return DecoratorUtil.getClassConfig(Class, KEY$3$1) || "";
|
|
1024
1008
|
}
|
|
1025
1009
|
const KEY$2$1 = "[ToClass]";
|
|
1026
1010
|
function ToClass(func) {
|
|
@@ -1057,7 +1041,7 @@ function Model(config = {}) {
|
|
|
1057
1041
|
return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
|
|
1058
1042
|
}
|
|
1059
1043
|
function getModelConfig(Class) {
|
|
1060
|
-
return DecoratorUtil.getClassConfig(Class, KEY$4, {}
|
|
1044
|
+
return DecoratorUtil.getClassConfig(Class, KEY$4, true) || {};
|
|
1061
1045
|
}
|
|
1062
1046
|
function getModelName(Class) {
|
|
1063
1047
|
return getModelConfig(Class).label || Class.name;
|
|
@@ -13625,17 +13609,7 @@ function Form(config = {}) {
|
|
|
13625
13609
|
};
|
|
13626
13610
|
}
|
|
13627
13611
|
function getFormConfig(Class, field) {
|
|
13628
|
-
|
|
13629
|
-
if (!formConfig) {
|
|
13630
|
-
return { key: "" };
|
|
13631
|
-
}
|
|
13632
|
-
if (!formConfig.dictionary) {
|
|
13633
|
-
const props = getFieldConfig(Class, field);
|
|
13634
|
-
if (props && props.dictionary) {
|
|
13635
|
-
formConfig.dictionary = props.dictionary;
|
|
13636
|
-
}
|
|
13637
|
-
}
|
|
13638
|
-
return formConfig;
|
|
13612
|
+
return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true) || {};
|
|
13639
13613
|
}
|
|
13640
13614
|
function getFormConfigList(Class) {
|
|
13641
13615
|
const fieldList = Object.keys(Class.prototype);
|
|
@@ -16743,15 +16717,11 @@ function Search(config = {}) {
|
|
|
16743
16717
|
};
|
|
16744
16718
|
}
|
|
16745
16719
|
function getSearchConfig(Class, field) {
|
|
16746
|
-
|
|
16747
|
-
if (!formConfig) {
|
|
16748
|
-
return { key: "" };
|
|
16749
|
-
}
|
|
16750
|
-
return formConfig;
|
|
16720
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY$1, true) || {};
|
|
16751
16721
|
}
|
|
16752
16722
|
function getSearchConfigList(Class) {
|
|
16753
|
-
const fieldList = Object.keys(Class
|
|
16754
|
-
const list = fieldList.map((field) => getSearchConfig(Class, field));
|
|
16723
|
+
const fieldList = Object.keys(new Class());
|
|
16724
|
+
const list = fieldList.map((field) => getSearchConfig(Class, field)).filter((item) => !!item.key);
|
|
16755
16725
|
return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
|
|
16756
16726
|
}
|
|
16757
16727
|
const KEY = "[Table]";
|
|
@@ -16762,11 +16732,7 @@ function Table(config = {}) {
|
|
|
16762
16732
|
};
|
|
16763
16733
|
}
|
|
16764
16734
|
function getTableConfig(Class, field) {
|
|
16765
|
-
|
|
16766
|
-
if (!tableConfig) {
|
|
16767
|
-
return { key: "" };
|
|
16768
|
-
}
|
|
16769
|
-
return tableConfig;
|
|
16735
|
+
return DecoratorUtil.getFieldConfig(Class, field, KEY, true) || {};
|
|
16770
16736
|
}
|
|
16771
16737
|
function getTableConfigList(Class) {
|
|
16772
16738
|
const fieldList = Object.keys(Class.prototype);
|
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.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.
|
|
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",
|