@byteluck-fe/model-driven-engine 2.23.0-beta.1 → 2.23.0-beta.2
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/README.md +30 -30
- package/dist/esm/common/ActionManager.js +4 -4
- package/dist/esm/common/Engine.js +78 -72
- package/dist/esm/common/Runtime.js +2 -2
- package/dist/esm/common/Store.js +4 -4
- package/dist/esm/common/proxyState.js +18 -18
- package/dist/esm/plugins/CalcPlugin.js +43 -43
- package/dist/esm/plugins/StylePlugin.js +6 -6
- package/dist/index.umd.js +49 -7
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +201 -194
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +31 -31
- package/dist/types/common/Store.d.ts +54 -54
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +17 -17
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
- package/dist/types/plugins/StylePlugin.d.ts +13 -13
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# Engine
|
|
2
|
-
运行态引擎
|
|
3
|
-
|
|
4
|
-
```
|
|
5
|
-
│ index.ts // 入口文件
|
|
6
|
-
│
|
|
7
|
-
├─common // 引擎相关
|
|
8
|
-
│ ActionManager.ts // utils操作管理
|
|
9
|
-
│ checkerValue.ts // 表单值校验器
|
|
10
|
-
│ DataManager.ts // 数据源容器
|
|
11
|
-
│ Engine.ts // 引擎
|
|
12
|
-
│ index.ts // 入口
|
|
13
|
-
│ OkWorker.ts // 无用
|
|
14
|
-
│ Plugin.ts // 插件
|
|
15
|
-
│ proxyState.ts // 劫持引擎表单数据
|
|
16
|
-
│ Runtime.ts // 控件注册和创建
|
|
17
|
-
│ Store.ts // 数据管理
|
|
18
|
-
│
|
|
19
|
-
├─plugins
|
|
20
|
-
│ CalcPlugin.ts // 计算公式插件
|
|
21
|
-
│ ControlsEventPlugin.ts // 控件二开事件插件
|
|
22
|
-
│ ES6ModulePlugin.ts //
|
|
23
|
-
│ index.ts
|
|
24
|
-
│ LifecycleEventPlugin.ts // 页面生命周期事件
|
|
25
|
-
│ StylePlugin.ts // css二开
|
|
26
|
-
│
|
|
27
|
-
└─utils
|
|
28
|
-
index.ts
|
|
29
|
-
runtimeUtils.ts // 工具函数
|
|
30
|
-
```
|
|
1
|
+
# Engine
|
|
2
|
+
运行态引擎
|
|
3
|
+
|
|
4
|
+
```
|
|
5
|
+
│ index.ts // 入口文件
|
|
6
|
+
│
|
|
7
|
+
├─common // 引擎相关
|
|
8
|
+
│ ActionManager.ts // utils操作管理
|
|
9
|
+
│ checkerValue.ts // 表单值校验器
|
|
10
|
+
│ DataManager.ts // 数据源容器
|
|
11
|
+
│ Engine.ts // 引擎
|
|
12
|
+
│ index.ts // 入口
|
|
13
|
+
│ OkWorker.ts // 无用
|
|
14
|
+
│ Plugin.ts // 插件
|
|
15
|
+
│ proxyState.ts // 劫持引擎表单数据
|
|
16
|
+
│ Runtime.ts // 控件注册和创建
|
|
17
|
+
│ Store.ts // 数据管理
|
|
18
|
+
│
|
|
19
|
+
├─plugins
|
|
20
|
+
│ CalcPlugin.ts // 计算公式插件
|
|
21
|
+
│ ControlsEventPlugin.ts // 控件二开事件插件
|
|
22
|
+
│ ES6ModulePlugin.ts //
|
|
23
|
+
│ index.ts
|
|
24
|
+
│ LifecycleEventPlugin.ts // 页面生命周期事件
|
|
25
|
+
│ StylePlugin.ts // css二开
|
|
26
|
+
│
|
|
27
|
+
└─utils
|
|
28
|
+
index.ts
|
|
29
|
+
runtimeUtils.ts // 工具函数
|
|
30
|
+
```
|
|
@@ -186,11 +186,11 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
186
186
|
_class_call_check(this, ActionManager);
|
|
187
187
|
_define_property(this, "actionMap", new Map());
|
|
188
188
|
_define_property(this, "buildinActions", {});
|
|
189
|
-
/**
|
|
190
|
-
* 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
|
|
189
|
+
/**
|
|
190
|
+
* 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
|
|
191
191
|
*/ _define_property(this, "actionUtils", {});
|
|
192
|
-
/**
|
|
193
|
-
* 用于存储es module解析出来的源码,CustomVueControlPlugin
|
|
192
|
+
/**
|
|
193
|
+
* 用于存储es module解析出来的源码,CustomVueControlPlugin
|
|
194
194
|
*/ _define_property(this, "sources", {});
|
|
195
195
|
}
|
|
196
196
|
_create_class(ActionManager, [
|
|
@@ -376,6 +376,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
376
376
|
_define_property(_assert_this_initialized(_this), "isMounted", false);
|
|
377
377
|
_define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
|
|
378
378
|
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
379
|
+
_define_property(_assert_this_initialized(_this), "children", void 0);
|
|
379
380
|
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
380
381
|
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
381
382
|
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
@@ -386,14 +387,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
386
387
|
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
387
388
|
_this.$options = Object.freeze(props);
|
|
388
389
|
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? true : _this_$options_autoMount, schema = _this_$options.schema, beforeCreateInstance = _this_$options.beforeCreateInstance, externalParams = _this_$options.externalParams, _this_$options_language = _this_$options.// fieldModel,
|
|
389
|
-
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug;
|
|
390
|
-
RulesMessage.setLocale(language);
|
|
390
|
+
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug, messagesI18n = _this_$options.messagesI18n, children = _this_$options.children;
|
|
391
|
+
RulesMessage.setLocale(language, messagesI18n);
|
|
391
392
|
_this.debug = debug;
|
|
392
393
|
_this.runtime = new Runtime({
|
|
393
394
|
schema: schema,
|
|
394
395
|
beforeCreateInstance: beforeCreateInstance
|
|
395
396
|
});
|
|
396
397
|
_this.externalParams = externalParams;
|
|
398
|
+
_this.children = children;
|
|
397
399
|
_this.store = new Store({
|
|
398
400
|
instance: _this.runtime.instance
|
|
399
401
|
});
|
|
@@ -976,9 +978,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
976
978
|
}
|
|
977
979
|
},
|
|
978
980
|
{
|
|
979
|
-
/**
|
|
980
|
-
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
981
|
-
* @param options 需要携带的options
|
|
981
|
+
/**
|
|
982
|
+
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
983
|
+
* @param options 需要携带的options
|
|
982
984
|
* */ key: "setPayloadOptions",
|
|
983
985
|
value: function setPayloadOptions(options) {
|
|
984
986
|
eventOptionsTemp = options;
|
|
@@ -995,9 +997,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
995
997
|
}
|
|
996
998
|
},
|
|
997
999
|
{
|
|
998
|
-
/**
|
|
999
|
-
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
1000
|
-
* @param states
|
|
1000
|
+
/**
|
|
1001
|
+
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
1002
|
+
* @param states
|
|
1001
1003
|
*/ key: "setStates",
|
|
1002
1004
|
value: function setStates(states, rowIndex, options) {
|
|
1003
1005
|
var _this = this;
|
|
@@ -1024,11 +1026,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1024
1026
|
}
|
|
1025
1027
|
},
|
|
1026
1028
|
{
|
|
1027
|
-
/**
|
|
1028
|
-
* 通过dataCode和fieldCode来获取控件的值
|
|
1029
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1030
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1031
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1029
|
+
/**
|
|
1030
|
+
* 通过dataCode和fieldCode来获取控件的值
|
|
1031
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1032
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1033
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1032
1034
|
* */ key: "getField",
|
|
1033
1035
|
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
1034
1036
|
if (!fieldCode) {
|
|
@@ -1100,27 +1102,31 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1100
1102
|
var _controlIdMapping_key2;
|
|
1101
1103
|
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
1102
1104
|
} else if ((_controlIdMapping_key1 = controlIdMapping[key]) === null || _controlIdMapping_key1 === void 0 ? void 0 : (_controlIdMapping_key_dataBind1 = _controlIdMapping_key1.dataBind) === null || _controlIdMapping_key_dataBind1 === void 0 ? void 0 : _controlIdMapping_key_dataBind1.dataCode) {
|
|
1103
|
-
|
|
1104
|
-
//
|
|
1105
|
-
|
|
1106
|
-
var
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
var
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1105
|
+
if (!Array.isArray(getFieldData[key])) {
|
|
1106
|
+
// obj[controlIdMapping[key]?.dataBind.dataCode] = ''
|
|
1107
|
+
} else {
|
|
1108
|
+
var _controlIdMapping_key3, _getFieldData_key;
|
|
1109
|
+
// 明细字表只循环一层明细子表未递归
|
|
1110
|
+
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = (_getFieldData_key = getFieldData[key]) === null || _getFieldData_key === void 0 ? void 0 : _getFieldData_key.map(function(item) {
|
|
1111
|
+
var objChi = {};
|
|
1112
|
+
for(var keyChi in item){
|
|
1113
|
+
var _controlIdMapping_key_children_keyChi;
|
|
1114
|
+
var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
|
|
1115
|
+
//未绑定字段的控件,直接抛弃
|
|
1116
|
+
if (fieldCode !== '') {
|
|
1117
|
+
if (fieldCode) {
|
|
1118
|
+
objChi[fieldCode] = item[keyChi];
|
|
1119
|
+
} else {
|
|
1120
|
+
for(var keyChi1 in item[keyChi]){
|
|
1121
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
1122
|
+
objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
1123
|
+
}
|
|
1118
1124
|
}
|
|
1119
1125
|
}
|
|
1120
1126
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1127
|
+
return objChi;
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1124
1130
|
} else if (controlIdMapping[key]) {
|
|
1125
1131
|
// 兼容一个控件需要绑定多个字段的情况
|
|
1126
1132
|
for(var keyChi in getFieldData[key]){
|
|
@@ -1139,13 +1145,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1139
1145
|
}
|
|
1140
1146
|
},
|
|
1141
1147
|
{
|
|
1142
|
-
/**
|
|
1143
|
-
* 通过dataCode和fieldCode来设置控件的值
|
|
1144
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1145
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1146
|
-
* @param value 修改的值
|
|
1147
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1148
|
-
* @param options 触发事件携带的参数
|
|
1148
|
+
/**
|
|
1149
|
+
* 通过dataCode和fieldCode来设置控件的值
|
|
1150
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1151
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1152
|
+
* @param value 修改的值
|
|
1153
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1154
|
+
* @param options 触发事件携带的参数
|
|
1149
1155
|
* */ key: "setField",
|
|
1150
1156
|
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
1151
1157
|
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
@@ -1173,12 +1179,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1173
1179
|
}
|
|
1174
1180
|
},
|
|
1175
1181
|
{
|
|
1176
|
-
/**
|
|
1177
|
-
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1178
|
-
* @param dataCode 需要赋值的目标模型
|
|
1179
|
-
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1180
|
-
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1181
|
-
* @param options 触发事件携带的参数
|
|
1182
|
+
/**
|
|
1183
|
+
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1184
|
+
* @param dataCode 需要赋值的目标模型
|
|
1185
|
+
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1186
|
+
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1187
|
+
* @param options 触发事件携带的参数
|
|
1182
1188
|
* */ key: "setFields",
|
|
1183
1189
|
value: function setFields(dataCode, state, rowIndex, options) {
|
|
1184
1190
|
var _this = this;
|
|
@@ -1219,10 +1225,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1219
1225
|
}
|
|
1220
1226
|
},
|
|
1221
1227
|
{
|
|
1222
|
-
/**
|
|
1223
|
-
* 通过dataCode来将state转化为标准的state结构
|
|
1224
|
-
* @param dataCode 需要转换的目标模型code
|
|
1225
|
-
* @param state 值对象,以fieldCode为key组成的对象
|
|
1228
|
+
/**
|
|
1229
|
+
* 通过dataCode来将state转化为标准的state结构
|
|
1230
|
+
* @param dataCode 需要转换的目标模型code
|
|
1231
|
+
* @param state 值对象,以fieldCode为key组成的对象
|
|
1226
1232
|
* */ key: "buildFields",
|
|
1227
1233
|
value: function buildFields(dataCode, state) {
|
|
1228
1234
|
var _this = this;
|
|
@@ -1263,10 +1269,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1263
1269
|
}
|
|
1264
1270
|
},
|
|
1265
1271
|
{
|
|
1266
|
-
/**
|
|
1267
|
-
* 向Store设置一组值,并触发事件携带options
|
|
1268
|
-
* @param dataSet
|
|
1269
|
-
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1272
|
+
/**
|
|
1273
|
+
* 向Store设置一组值,并触发事件携带options
|
|
1274
|
+
* @param dataSet
|
|
1275
|
+
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1270
1276
|
*/ key: "setData",
|
|
1271
1277
|
value: function setData(dataSet, options) {
|
|
1272
1278
|
var _this = this;
|
|
@@ -1404,19 +1410,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1404
1410
|
}
|
|
1405
1411
|
},
|
|
1406
1412
|
{
|
|
1407
|
-
/**
|
|
1408
|
-
* 获取控件的dataBind
|
|
1409
|
-
* @param controlId
|
|
1413
|
+
/**
|
|
1414
|
+
* 获取控件的dataBind
|
|
1415
|
+
* @param controlId
|
|
1410
1416
|
* */ key: "getDataBind",
|
|
1411
1417
|
value: function getDataBind(controlId) {
|
|
1412
1418
|
return this.store.getDataBind(controlId);
|
|
1413
1419
|
}
|
|
1414
1420
|
},
|
|
1415
1421
|
{
|
|
1416
|
-
/**
|
|
1417
|
-
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1418
|
-
* @param controlId
|
|
1419
|
-
* @param rowIndex
|
|
1422
|
+
/**
|
|
1423
|
+
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1424
|
+
* @param controlId
|
|
1425
|
+
* @param rowIndex
|
|
1420
1426
|
*/ key: "getInstance",
|
|
1421
1427
|
value: function getInstance(controlId, rowIndex) {
|
|
1422
1428
|
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
@@ -1435,10 +1441,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1435
1441
|
}
|
|
1436
1442
|
},
|
|
1437
1443
|
{
|
|
1438
|
-
/**
|
|
1439
|
-
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1440
|
-
* @param controlId
|
|
1441
|
-
* @param header 明细表内是否获取表头的控件
|
|
1444
|
+
/**
|
|
1445
|
+
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1446
|
+
* @param controlId
|
|
1447
|
+
* @param header 明细表内是否获取表头的控件
|
|
1442
1448
|
*/ // getInstances(
|
|
1443
1449
|
// controlId?: string,
|
|
1444
1450
|
// header: boolean = false
|
|
@@ -1614,27 +1620,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1614
1620
|
},
|
|
1615
1621
|
{
|
|
1616
1622
|
key: "assertInstance",
|
|
1617
|
-
value: /**
|
|
1618
|
-
* 判断控件的类型,返回当前控件的正确类型
|
|
1623
|
+
value: /**
|
|
1624
|
+
* 判断控件的类型,返回当前控件的正确类型
|
|
1619
1625
|
* */ function assertInstance(instance, types) {
|
|
1620
1626
|
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1621
1627
|
}
|
|
1622
1628
|
},
|
|
1623
1629
|
{
|
|
1624
1630
|
key: "assertInstanceIsCustomControl",
|
|
1625
|
-
value: /**
|
|
1626
|
-
* 判断控件或控件类型是一个自定义控件
|
|
1631
|
+
value: /**
|
|
1632
|
+
* 判断控件或控件类型是一个自定义控件
|
|
1627
1633
|
* */ function assertInstanceIsCustomControl(instance) {
|
|
1628
1634
|
return !isBuiltInControls(isString(instance) ? instance : instance.type);
|
|
1629
1635
|
}
|
|
1630
1636
|
},
|
|
1631
1637
|
{
|
|
1632
1638
|
key: "getInstanceRowIndex",
|
|
1633
|
-
value: /**
|
|
1634
|
-
* 获取控件在明细子表中的行下标,
|
|
1635
|
-
* 如果控件在表头内,则返回-1
|
|
1636
|
-
* 如果控件在表内,则返回行下标
|
|
1637
|
-
* 如果控件不在明细表内,则返回undefined
|
|
1639
|
+
value: /**
|
|
1640
|
+
* 获取控件在明细子表中的行下标,
|
|
1641
|
+
* 如果控件在表头内,则返回-1
|
|
1642
|
+
* 如果控件在表内,则返回行下标
|
|
1643
|
+
* 如果控件不在明细表内,则返回undefined
|
|
1638
1644
|
* */ // public getInstanceRowIndex(
|
|
1639
1645
|
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1640
1646
|
// ) {
|
|
@@ -305,8 +305,8 @@ function loop(control, parentId, callback) {
|
|
|
305
305
|
function hasHeaderOrFooterControl(control, checkType) {
|
|
306
306
|
return checkType in control.props && isArray(control.props[checkType]);
|
|
307
307
|
}
|
|
308
|
-
/**
|
|
309
|
-
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
308
|
+
/**
|
|
309
|
+
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
310
310
|
* */ function getControlIsHide(control) {
|
|
311
311
|
if (control.props.isHide) {
|
|
312
312
|
return true;
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -69,10 +69,10 @@ var Store = /*#__PURE__*/ function() {
|
|
|
69
69
|
}
|
|
70
70
|
_create_class(Store, [
|
|
71
71
|
{
|
|
72
|
-
/**
|
|
73
|
-
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
74
|
-
* @param controlId 组件ID
|
|
75
|
-
* @param value
|
|
72
|
+
/**
|
|
73
|
+
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
74
|
+
* @param controlId 组件ID
|
|
75
|
+
* @param value
|
|
76
76
|
*/ key: "setState",
|
|
77
77
|
value: function setState(controlId, value, rowIndex) {
|
|
78
78
|
var _this = this;
|
|
@@ -105,11 +105,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
/**
|
|
109
|
-
* 返回proxy操作对象
|
|
110
|
-
* @param thisKey 当前对象在上级中的key
|
|
111
|
-
* @param callback 需要在修改的时候,触发的回调函数
|
|
112
|
-
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
108
|
+
/**
|
|
109
|
+
* 返回proxy操作对象
|
|
110
|
+
* @param thisKey 当前对象在上级中的key
|
|
111
|
+
* @param callback 需要在修改的时候,触发的回调函数
|
|
112
|
+
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
113
113
|
* */ function handler(thisKey, callback, beforeSetCallback) {
|
|
114
114
|
return {
|
|
115
115
|
__engineProxy__: true,
|
|
@@ -183,12 +183,12 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
/**
|
|
187
|
-
* 代理state数据
|
|
188
|
-
* @param state 数据对象
|
|
189
|
-
* @param callback 触发set时候的回调函数
|
|
190
|
-
* @param beforeSetCallback
|
|
191
|
-
* @param prevKey 递归对象的key
|
|
186
|
+
/**
|
|
187
|
+
* 代理state数据
|
|
188
|
+
* @param state 数据对象
|
|
189
|
+
* @param callback 触发set时候的回调函数
|
|
190
|
+
* @param beforeSetCallback
|
|
191
|
+
* @param prevKey 递归对象的key
|
|
192
192
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
193
193
|
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
|
|
194
194
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
@@ -216,10 +216,10 @@ function flatInstanceForChildren(controls) {
|
|
|
216
216
|
});
|
|
217
217
|
return result;
|
|
218
218
|
}
|
|
219
|
-
/**
|
|
220
|
-
* 在flatInstance中通过key查找出对应的instance
|
|
221
|
-
* @param flatInstance 拍平的instance数组
|
|
222
|
-
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
|
+
/**
|
|
220
|
+
* 在flatInstance中通过key查找出对应的instance
|
|
221
|
+
* @param flatInstance 拍平的instance数组
|
|
222
|
+
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
223
223
|
* */ export function findItem(flatInstance, key, instanceMap) {
|
|
224
224
|
if (key === '') return undefined;
|
|
225
225
|
var keys = key.split('.');
|
|
@@ -276,9 +276,9 @@ function getArrayNewArgs(type, args, value) {
|
|
|
276
276
|
return args.slice(0, 2).concat(value);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
/**
|
|
280
|
-
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
281
|
-
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
279
|
+
/**
|
|
280
|
+
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
281
|
+
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
282
282
|
* */ function hijackArrayProperty() {
|
|
283
283
|
proxyArrayApi.forEach(function(key) {
|
|
284
284
|
var oldApiHandler = Array.prototype[key];
|
|
@@ -63,11 +63,11 @@ import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe
|
|
|
63
63
|
import { format } from 'mathjs';
|
|
64
64
|
var DisplayType;
|
|
65
65
|
(function(DisplayType) {
|
|
66
|
-
/**
|
|
67
|
-
* 完全等于
|
|
66
|
+
/**
|
|
67
|
+
* 完全等于
|
|
68
68
|
*/ DisplayType["EQ"] = "EQ";
|
|
69
|
-
/**
|
|
70
|
-
* 包含
|
|
69
|
+
/**
|
|
70
|
+
* 包含
|
|
71
71
|
* */ DisplayType["IN"] = "IN";
|
|
72
72
|
})(DisplayType || (DisplayType = {}));
|
|
73
73
|
export var CalcPlugin = /*#__PURE__*/ function() {
|
|
@@ -76,16 +76,16 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
76
76
|
_class_call_check(this, CalcPlugin);
|
|
77
77
|
_define_property(this, "engine", void 0);
|
|
78
78
|
_define_property(this, "options", void 0);
|
|
79
|
-
/**
|
|
80
|
-
* 所有的计算公式控件
|
|
79
|
+
/**
|
|
80
|
+
* 所有的计算公式控件
|
|
81
81
|
* */ // @ts-ignore
|
|
82
82
|
_define_property(this, "calcControls", []);
|
|
83
|
-
/**
|
|
84
|
-
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
85
|
-
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
83
|
+
/**
|
|
84
|
+
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
85
|
+
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
86
86
|
* */ _define_property(this, "dependenciesTriggerMap", new Map());
|
|
87
|
-
/**
|
|
88
|
-
* 隐藏以后需要被计算的控件
|
|
87
|
+
/**
|
|
88
|
+
* 隐藏以后需要被计算的控件
|
|
89
89
|
* */ _define_property(this, "hideNotRememberControlIds", []);
|
|
90
90
|
_define_property(this, "dontHasPermissionControlIds", []);
|
|
91
91
|
_define_property(this, "cacheComputedResult", {});
|
|
@@ -96,8 +96,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
96
96
|
_create_class(CalcPlugin, [
|
|
97
97
|
{
|
|
98
98
|
key: "getNeedHideRememberControlIds",
|
|
99
|
-
value: /**
|
|
100
|
-
* @description 获取显隐控制的需要被记住值的控件id
|
|
99
|
+
value: /**
|
|
100
|
+
* @description 获取显隐控制的需要被记住值的控件id
|
|
101
101
|
* */ function getNeedHideRememberControlIds() {
|
|
102
102
|
var _this_options;
|
|
103
103
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.displayBoList)) {
|
|
@@ -114,8 +114,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
key: "getDontHasPermissionControlIds",
|
|
117
|
-
value: /**
|
|
118
|
-
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
117
|
+
value: /**
|
|
118
|
+
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
119
119
|
* */ function getDontHasPermissionControlIds() {
|
|
120
120
|
var _this_options;
|
|
121
121
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.behavior)) {
|
|
@@ -131,9 +131,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
key: "controlNeedComputedValue",
|
|
134
|
-
value: /**
|
|
135
|
-
* @description 判断控件是否需要被计算
|
|
136
|
-
* @param control 控件
|
|
134
|
+
value: /**
|
|
135
|
+
* @description 判断控件是否需要被计算
|
|
136
|
+
* @param control 控件
|
|
137
137
|
* */ function controlNeedComputedValue(control) {
|
|
138
138
|
if (!control) {
|
|
139
139
|
return false;
|
|
@@ -153,9 +153,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
key: "getControlIsHide",
|
|
156
|
-
value: /**
|
|
157
|
-
* @description 获取控件是否被隐藏
|
|
158
|
-
* @param control 控件
|
|
156
|
+
value: /**
|
|
157
|
+
* @description 获取控件是否被隐藏
|
|
158
|
+
* @param control 控件
|
|
159
159
|
* */ function getControlIsHide(control) {
|
|
160
160
|
if (control.props.isHide) {
|
|
161
161
|
return true;
|
|
@@ -184,8 +184,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
186
|
key: "resetDependencies",
|
|
187
|
-
value: /**
|
|
188
|
-
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
187
|
+
value: /**
|
|
188
|
+
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
189
189
|
* */ function resetDependencies() {
|
|
190
190
|
this.calcControls = [];
|
|
191
191
|
this.dependenciesTriggerMap.clear();
|
|
@@ -195,8 +195,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
197
|
key: "allCalcControlComputed",
|
|
198
|
-
value: /**
|
|
199
|
-
* @description 执行所有计算公式控件的计算
|
|
198
|
+
value: /**
|
|
199
|
+
* @description 执行所有计算公式控件的计算
|
|
200
200
|
* */ function allCalcControlComputed() {
|
|
201
201
|
var _this = this;
|
|
202
202
|
this.calcControls.forEach(function(item) {
|
|
@@ -210,8 +210,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
210
210
|
},
|
|
211
211
|
{
|
|
212
212
|
key: "getAllCalcControl",
|
|
213
|
-
value: /**
|
|
214
|
-
* @description 获取所有的计算公式控件
|
|
213
|
+
value: /**
|
|
214
|
+
* @description 获取所有的计算公式控件
|
|
215
215
|
* */ function getAllCalcControl() {
|
|
216
216
|
this.calcControls = this.engine.runtime.flatInstances.filter(// @ts-ignore
|
|
217
217
|
function(item) {
|
|
@@ -221,8 +221,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
key: "getCalcDependencies",
|
|
224
|
-
value: /**
|
|
225
|
-
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
224
|
+
value: /**
|
|
225
|
+
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
226
226
|
* */ function getCalcDependencies() {
|
|
227
227
|
var _this = this;
|
|
228
228
|
this.calcControls.forEach(function(item) {
|
|
@@ -274,8 +274,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
274
274
|
},
|
|
275
275
|
{
|
|
276
276
|
key: "watchSchemaHideChange",
|
|
277
|
-
value: /**
|
|
278
|
-
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
277
|
+
value: /**
|
|
278
|
+
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
279
279
|
* */ function watchSchemaHideChange() {
|
|
280
280
|
var _this = this;
|
|
281
281
|
this.engine.on('schema-change', function(payload) {
|
|
@@ -291,8 +291,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
key: "watchSubtableChange",
|
|
294
|
-
value: /**
|
|
295
|
-
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
294
|
+
value: /**
|
|
295
|
+
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
296
296
|
* */ function watchSubtableChange() {
|
|
297
297
|
var _this = this;
|
|
298
298
|
this.engine.on('list-change', function(payload) {
|
|
@@ -319,8 +319,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
319
319
|
},
|
|
320
320
|
{
|
|
321
321
|
key: "watchControlChange",
|
|
322
|
-
value: /**
|
|
323
|
-
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
322
|
+
value: /**
|
|
323
|
+
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
324
324
|
* */ function watchControlChange() {
|
|
325
325
|
var _this = this;
|
|
326
326
|
this.engine.on('change', function(payload) {
|
|
@@ -355,8 +355,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
355
355
|
},
|
|
356
356
|
{
|
|
357
357
|
key: "controlInSubtable",
|
|
358
|
-
value: /**
|
|
359
|
-
* @description 控件在明细子表内
|
|
358
|
+
value: /**
|
|
359
|
+
* @description 控件在明细子表内
|
|
360
360
|
* */ function controlInSubtable(control) {
|
|
361
361
|
var _control_parent;
|
|
362
362
|
return ((_control_parent = control.parent) === null || _control_parent === void 0 ? void 0 : _control_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
|
|
@@ -364,8 +364,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
364
364
|
},
|
|
365
365
|
{
|
|
366
366
|
key: "computedCalcValue",
|
|
367
|
-
value: /**
|
|
368
|
-
* @description 执行计算公式的计算
|
|
367
|
+
value: /**
|
|
368
|
+
* @description 执行计算公式的计算
|
|
369
369
|
* */ // @ts-ignore
|
|
370
370
|
function computedCalcValue(control) {
|
|
371
371
|
var _this = this;
|
|
@@ -455,8 +455,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
455
455
|
},
|
|
456
456
|
{
|
|
457
457
|
key: "getNumberValue",
|
|
458
|
-
value: /**
|
|
459
|
-
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
458
|
+
value: /**
|
|
459
|
+
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
460
460
|
* */ function getNumberValue(value) {
|
|
461
461
|
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value) {
|
|
462
462
|
if ('result' in value) {
|
|
@@ -473,8 +473,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
473
473
|
},
|
|
474
474
|
{
|
|
475
475
|
key: "getAggregateTypeValue",
|
|
476
|
-
value: /**
|
|
477
|
-
* 计算明细子表最大值最小值平均值总和
|
|
476
|
+
value: /**
|
|
477
|
+
* 计算明细子表最大值最小值平均值总和
|
|
478
478
|
* */ function getAggregateTypeValue(values, type) {
|
|
479
479
|
if (!type || !values || !values.length) return 0;
|
|
480
480
|
switch(type){
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
-
* @Date: 2022-04-15 14:06:03
|
|
4
|
-
* @LastEditors: SuperLuckyqi
|
|
5
|
-
* @LastEditTime: 2024-07-24 11:38:32
|
|
6
|
-
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
1
|
+
/*
|
|
2
|
+
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
+
* @Date: 2022-04-15 14:06:03
|
|
4
|
+
* @LastEditors: SuperLuckyqi
|
|
5
|
+
* @LastEditTime: 2024-07-24 11:38:32
|
|
6
|
+
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
7
7
|
*/ function _class_call_check(instance, Constructor) {
|
|
8
8
|
if (!(instance instanceof Constructor)) {
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|