@byteluck-fe/model-driven-engine 4.37.0-lx1 → 5.3.0-1-beta2
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/DataManager.js +1 -0
- package/dist/esm/common/Engine.js +121 -185
- package/dist/esm/common/Runtime.js +9 -5
- package/dist/esm/common/Store.js +15 -13
- package/dist/esm/common/checkerValue.js +1 -1
- package/dist/esm/common/proxyState.js +52 -45
- package/dist/esm/plugins/CalcPlugin.js +43 -43
- package/dist/esm/plugins/ControlsEventPlugin.js +11 -1
- package/dist/esm/plugins/StylePlugin.js +32 -10
- package/dist/esm/utils/runtimeUtils.js +2 -1
- package/dist/index.umd.js +40 -6
- 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 -209
- 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 -33
- 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 -15
- 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 -12
- 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 +10 -6
|
@@ -325,7 +325,7 @@ function _ts_generator(thisArg, body) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
328
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log,
|
|
328
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
329
329
|
import { Runtime } from './Runtime';
|
|
330
330
|
import { Store } from './Store';
|
|
331
331
|
import { findItem, proxyState } from './proxyState';
|
|
@@ -351,18 +351,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
351
351
|
_this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
|
|
352
352
|
_define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
|
|
353
353
|
// public worker: OkWorker
|
|
354
|
-
_define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
354
|
+
_define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), _define_property(_this, "children", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
355
355
|
_define_property(_this, "__plugins", void 0), _define_property(_this, "__pluginsApplied", false), _define_property(_this, "$options", void 0), _define_property(_this, "actionManager", new ActionManager()), _define_property(_this, "dataManager", void 0), _define_property(_this, "_jobTasks", []), _define_property(_this, "createControlInstance", _this.createInstance);
|
|
356
356
|
_this.$options = Object.freeze(props);
|
|
357
357
|
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,
|
|
358
|
-
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;
|
|
359
|
-
RulesMessage.setLocale(language);
|
|
358
|
+
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;
|
|
360
359
|
_this.debug = debug;
|
|
361
360
|
_this.runtime = new Runtime({
|
|
362
361
|
schema: schema,
|
|
363
362
|
beforeCreateInstance: beforeCreateInstance
|
|
364
363
|
});
|
|
365
364
|
_this.externalParams = externalParams;
|
|
365
|
+
_this.children = children;
|
|
366
366
|
_this.store = new Store({
|
|
367
367
|
instance: _this.runtime.instance
|
|
368
368
|
});
|
|
@@ -405,6 +405,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
405
405
|
{
|
|
406
406
|
key: "mount",
|
|
407
407
|
value: function mount() {
|
|
408
|
+
// @i18n-translate-ignore
|
|
408
409
|
this.debugLog("engine的mount方法开始调用");
|
|
409
410
|
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
410
411
|
this._handlerProxyState();
|
|
@@ -412,6 +413,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
412
413
|
this.applyPlugins();
|
|
413
414
|
// 触发所有控件的默认值的change事件
|
|
414
415
|
this.setStates(this.getState());
|
|
416
|
+
// @i18n-translate-ignore
|
|
415
417
|
this.debugLog("engine的mount方法调用结束");
|
|
416
418
|
if (this.debug && typeof window !== 'undefined') {
|
|
417
419
|
// @ts-ignore
|
|
@@ -437,7 +439,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
437
439
|
{
|
|
438
440
|
key: "_proxyStateBeforeSetCallback",
|
|
439
441
|
value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
|
|
440
|
-
var
|
|
442
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
441
443
|
// 找不到控件说明不是改动控件上的字段,直接通过
|
|
442
444
|
if (!instance) {
|
|
443
445
|
return newValue;
|
|
@@ -487,8 +489,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
487
489
|
key: "_handlerArrayUpdate",
|
|
488
490
|
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
489
491
|
var _this = this;
|
|
490
|
-
var
|
|
491
|
-
var subtable = instanceItem.instance;
|
|
492
|
+
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
492
493
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
493
494
|
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
494
495
|
// 新增多行方法
|
|
@@ -519,7 +520,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
519
520
|
createdNewRows = createRows(newRowLengths);
|
|
520
521
|
createdNewRowsData = args;
|
|
521
522
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
522
|
-
this.runtime.getFlatInstances();
|
|
523
523
|
break;
|
|
524
524
|
case 'splice':
|
|
525
525
|
if (args.length > 2) {
|
|
@@ -537,7 +537,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
537
537
|
start,
|
|
538
538
|
replace
|
|
539
539
|
].concat(_to_consumable_array(createdNewRows)));
|
|
540
|
-
this.runtime.getFlatInstances();
|
|
541
540
|
// newValues.forEach((item: any, index) => {
|
|
542
541
|
// let newIndex = start + index
|
|
543
542
|
// this.setStates(item, newIndex, options)
|
|
@@ -553,14 +552,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
553
552
|
isDeleteLastOne = true;
|
|
554
553
|
}
|
|
555
554
|
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
|
|
556
|
-
this.runtime.getFlatInstances();
|
|
557
555
|
}
|
|
558
556
|
break;
|
|
559
557
|
default:
|
|
560
558
|
var // @ts-ignore
|
|
561
559
|
_subtable_children3;
|
|
562
560
|
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
|
|
563
|
-
this.runtime.getFlatInstances();
|
|
564
561
|
break;
|
|
565
562
|
}
|
|
566
563
|
if (type === 'splice') {
|
|
@@ -575,12 +572,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
575
572
|
}
|
|
576
573
|
var subtableData = this.getState(subtable.id);
|
|
577
574
|
this._handlerSubtableUpdateUid(subtableData);
|
|
575
|
+
this.runtime.getFlatInstances();
|
|
576
|
+
var rowIndexs = createdNewRows.map(function(item) {
|
|
577
|
+
var _item_children_, _item_children;
|
|
578
|
+
var subControl = item === null || item === void 0 ? void 0 : (_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.children[0];
|
|
579
|
+
return _this.getInstanceRowIndex(subControl);
|
|
580
|
+
});
|
|
578
581
|
this.emit('list-change', {
|
|
579
582
|
instance: subtable,
|
|
580
583
|
value: subtableData,
|
|
581
584
|
options: Object.assign({}, options, {
|
|
582
585
|
changed: createdNewRows,
|
|
583
586
|
data: createdNewRowsData,
|
|
587
|
+
rowIndexs: rowIndexs,
|
|
584
588
|
deleted: deleted !== null && deleted !== void 0 ? deleted : [],
|
|
585
589
|
jsonValue: JSON.stringify(subtableData),
|
|
586
590
|
isDeleteLastOne: isDeleteLastOne,
|
|
@@ -609,11 +613,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
609
613
|
{
|
|
610
614
|
key: "_handlerObjectUpdate",
|
|
611
615
|
value: function _handlerObjectUpdate(state, key, value, oldValue) {
|
|
612
|
-
var
|
|
616
|
+
var _this = this;
|
|
617
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
613
618
|
if (!instance) {
|
|
614
619
|
return;
|
|
615
620
|
}
|
|
616
|
-
var index =
|
|
621
|
+
var index = this.getInstanceRowIndex(instance);
|
|
617
622
|
var options = eventOptionsTemp || {};
|
|
618
623
|
// if (instance instanceof RuntimeListControl) {
|
|
619
624
|
if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
|
|
@@ -629,7 +634,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
629
634
|
row && newRows.push(row);
|
|
630
635
|
}
|
|
631
636
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
632
|
-
this.runtime.getFlatInstances();
|
|
633
637
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
634
638
|
// for (let i = 0; i < newValue.length; i++) {
|
|
635
639
|
// this.setStates(newValue[i], i, options)
|
|
@@ -637,8 +641,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
637
641
|
var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
|
|
638
642
|
if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
|
|
639
643
|
deleted = [];
|
|
640
|
-
}
|
|
644
|
+
} else {}
|
|
645
|
+
this.runtime.getFlatInstances();
|
|
641
646
|
this._handlerSubtableUpdateUid(newValue);
|
|
647
|
+
var rowIndexs = newRows.map(function(item) {
|
|
648
|
+
var _item_children_, _item_children;
|
|
649
|
+
var subControl = item === null || item === void 0 ? void 0 : (_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.children[0];
|
|
650
|
+
return _this.getInstanceRowIndex(subControl);
|
|
651
|
+
});
|
|
642
652
|
this.emit('list-change', {
|
|
643
653
|
instance: instance,
|
|
644
654
|
value: value,
|
|
@@ -646,6 +656,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
646
656
|
// @ts-ignore
|
|
647
657
|
changed: newRows,
|
|
648
658
|
data: newValue,
|
|
659
|
+
rowIndexs: rowIndexs,
|
|
649
660
|
deleted: deleted,
|
|
650
661
|
// deleted: oldValue ?? [],
|
|
651
662
|
type: 'push',
|
|
@@ -949,9 +960,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
949
960
|
}
|
|
950
961
|
},
|
|
951
962
|
{
|
|
952
|
-
/**
|
|
953
|
-
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
954
|
-
* @param options 需要携带的options
|
|
963
|
+
/**
|
|
964
|
+
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
965
|
+
* @param options 需要携带的options
|
|
955
966
|
* */ key: "setPayloadOptions",
|
|
956
967
|
value: function setPayloadOptions(options) {
|
|
957
968
|
eventOptionsTemp = options;
|
|
@@ -961,16 +972,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
961
972
|
key: "setState",
|
|
962
973
|
value: function setState(controlId, value, rowIndex, options) {
|
|
963
974
|
eventOptionsTemp = options;
|
|
975
|
+
// @i18n-translate-ignore
|
|
964
976
|
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
965
977
|
this.store.setState(controlId, value, rowIndex);
|
|
978
|
+
// @i18n-translate-ignore
|
|
966
979
|
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
967
980
|
eventOptionsTemp = null;
|
|
968
981
|
}
|
|
969
982
|
},
|
|
970
983
|
{
|
|
971
|
-
/**
|
|
972
|
-
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
973
|
-
* @param states
|
|
984
|
+
/**
|
|
985
|
+
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
986
|
+
* @param states
|
|
974
987
|
*/ key: "setStates",
|
|
975
988
|
value: function setStates(states, rowIndex, options) {
|
|
976
989
|
var _this = this;
|
|
@@ -997,55 +1010,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
997
1010
|
}
|
|
998
1011
|
},
|
|
999
1012
|
{
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
})[0];
|
|
1006
|
-
if (key) {
|
|
1007
|
-
return titleData[key];
|
|
1008
|
-
} else {
|
|
1009
|
-
return titleData;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
//理想-获取系统字段
|
|
1015
|
-
key: "getSystemField",
|
|
1016
|
-
value: function getSystemField(key) {
|
|
1017
|
-
var _this_externalParams;
|
|
1018
|
-
var systemCodesMap = [
|
|
1019
|
-
'creator',
|
|
1020
|
-
'process_location',
|
|
1021
|
-
'create_time',
|
|
1022
|
-
'uid',
|
|
1023
|
-
'update_time',
|
|
1024
|
-
'process_status',
|
|
1025
|
-
'process_instance_id',
|
|
1026
|
-
'process_key'
|
|
1027
|
-
];
|
|
1028
|
-
var arr = ((_this_externalParams = this.externalParams) === null || _this_externalParams === void 0 ? void 0 : _this_externalParams.data.data_set.values.filter(function(a) {
|
|
1029
|
-
return systemCodesMap.some(function(k) {
|
|
1030
|
-
return k == a.code;
|
|
1031
|
-
});
|
|
1032
|
-
})) || [];
|
|
1033
|
-
if (key) {
|
|
1034
|
-
var _arr_filter_;
|
|
1035
|
-
return (_arr_filter_ = arr.filter(function(a) {
|
|
1036
|
-
return a.code == key;
|
|
1037
|
-
})[0]) === null || _arr_filter_ === void 0 ? void 0 : _arr_filter_.value;
|
|
1038
|
-
} else {
|
|
1039
|
-
return arr;
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
/**
|
|
1045
|
-
* 通过dataCode和fieldCode来获取控件的值
|
|
1046
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1047
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1048
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1013
|
+
/**
|
|
1014
|
+
* 通过dataCode和fieldCode来获取控件的值
|
|
1015
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1016
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1017
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1049
1018
|
* */ key: "getField",
|
|
1050
1019
|
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
1051
1020
|
if (!fieldCode) {
|
|
@@ -1117,27 +1086,31 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1117
1086
|
var _controlIdMapping_key2;
|
|
1118
1087
|
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
1119
1088
|
} 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) {
|
|
1120
|
-
|
|
1121
|
-
//
|
|
1122
|
-
|
|
1123
|
-
var
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
var
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1089
|
+
if (!Array.isArray(getFieldData[key])) {
|
|
1090
|
+
// obj[controlIdMapping[key]?.dataBind.dataCode] = ''
|
|
1091
|
+
} else {
|
|
1092
|
+
var _controlIdMapping_key3, _getFieldData_key;
|
|
1093
|
+
// 明细字表只循环一层明细子表未递归
|
|
1094
|
+
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) {
|
|
1095
|
+
var objChi = {};
|
|
1096
|
+
for(var keyChi in item){
|
|
1097
|
+
var _controlIdMapping_key_children_keyChi;
|
|
1098
|
+
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;
|
|
1099
|
+
//未绑定字段的控件,直接抛弃
|
|
1100
|
+
if (fieldCode !== '') {
|
|
1101
|
+
if (fieldCode) {
|
|
1102
|
+
objChi[fieldCode] = item[keyChi];
|
|
1103
|
+
} else {
|
|
1104
|
+
for(var keyChi1 in item[keyChi]){
|
|
1105
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
1106
|
+
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];
|
|
1107
|
+
}
|
|
1135
1108
|
}
|
|
1136
1109
|
}
|
|
1137
1110
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
}
|
|
1111
|
+
return objChi;
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1141
1114
|
} else if (controlIdMapping[key]) {
|
|
1142
1115
|
// 兼容一个控件需要绑定多个字段的情况
|
|
1143
1116
|
for(var keyChi in getFieldData[key]){
|
|
@@ -1156,13 +1129,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1156
1129
|
}
|
|
1157
1130
|
},
|
|
1158
1131
|
{
|
|
1159
|
-
/**
|
|
1160
|
-
* 通过dataCode和fieldCode来设置控件的值
|
|
1161
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1162
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1163
|
-
* @param value 修改的值
|
|
1164
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1165
|
-
* @param options 触发事件携带的参数
|
|
1132
|
+
/**
|
|
1133
|
+
* 通过dataCode和fieldCode来设置控件的值
|
|
1134
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1135
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1136
|
+
* @param value 修改的值
|
|
1137
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1138
|
+
* @param options 触发事件携带的参数
|
|
1166
1139
|
* */ key: "setField",
|
|
1167
1140
|
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
1168
1141
|
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
@@ -1190,12 +1163,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1190
1163
|
}
|
|
1191
1164
|
},
|
|
1192
1165
|
{
|
|
1193
|
-
/**
|
|
1194
|
-
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1195
|
-
* @param dataCode 需要赋值的目标模型
|
|
1196
|
-
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1197
|
-
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1198
|
-
* @param options 触发事件携带的参数
|
|
1166
|
+
/**
|
|
1167
|
+
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1168
|
+
* @param dataCode 需要赋值的目标模型
|
|
1169
|
+
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1170
|
+
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1171
|
+
* @param options 触发事件携带的参数
|
|
1199
1172
|
* */ key: "setFields",
|
|
1200
1173
|
value: function setFields(dataCode, state, rowIndex, options) {
|
|
1201
1174
|
var _this = this;
|
|
@@ -1236,10 +1209,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1236
1209
|
}
|
|
1237
1210
|
},
|
|
1238
1211
|
{
|
|
1239
|
-
/**
|
|
1240
|
-
* 通过dataCode来将state转化为标准的state结构
|
|
1241
|
-
* @param dataCode 需要转换的目标模型code
|
|
1242
|
-
* @param state 值对象,以fieldCode为key组成的对象
|
|
1212
|
+
/**
|
|
1213
|
+
* 通过dataCode来将state转化为标准的state结构
|
|
1214
|
+
* @param dataCode 需要转换的目标模型code
|
|
1215
|
+
* @param state 值对象,以fieldCode为key组成的对象
|
|
1243
1216
|
* */ key: "buildFields",
|
|
1244
1217
|
value: function buildFields(dataCode, state) {
|
|
1245
1218
|
var _this = this;
|
|
@@ -1280,13 +1253,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1280
1253
|
}
|
|
1281
1254
|
},
|
|
1282
1255
|
{
|
|
1283
|
-
/**
|
|
1284
|
-
* 向Store设置一组值,并触发事件携带options
|
|
1285
|
-
* @param dataSet
|
|
1286
|
-
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1256
|
+
/**
|
|
1257
|
+
* 向Store设置一组值,并触发事件携带options
|
|
1258
|
+
* @param dataSet
|
|
1259
|
+
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1287
1260
|
*/ key: "setData",
|
|
1288
1261
|
value: function setData(dataSet, options) {
|
|
1289
1262
|
var _this = this;
|
|
1263
|
+
// @i18n-translate-ignore
|
|
1290
1264
|
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1291
1265
|
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1292
1266
|
var newState = this.store.defaultState;
|
|
@@ -1408,31 +1382,35 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1408
1382
|
}
|
|
1409
1383
|
}
|
|
1410
1384
|
});
|
|
1385
|
+
// @i18n-translate-ignore
|
|
1411
1386
|
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1412
1387
|
}
|
|
1413
1388
|
}
|
|
1414
1389
|
});
|
|
1390
|
+
// @i18n-translate-ignore
|
|
1415
1391
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1416
1392
|
this.setStates(newState, undefined, _object_spread({
|
|
1417
1393
|
setData: true
|
|
1418
1394
|
}, options));
|
|
1395
|
+
this.runtime.getFlatInstances();
|
|
1396
|
+
// @i18n-translate-ignore
|
|
1419
1397
|
this.debugLog("engine setData方法执行完成。");
|
|
1420
1398
|
}
|
|
1421
1399
|
},
|
|
1422
1400
|
{
|
|
1423
|
-
/**
|
|
1424
|
-
* 获取控件的dataBind
|
|
1425
|
-
* @param controlId
|
|
1401
|
+
/**
|
|
1402
|
+
* 获取控件的dataBind
|
|
1403
|
+
* @param controlId
|
|
1426
1404
|
* */ key: "getDataBind",
|
|
1427
1405
|
value: function getDataBind(controlId) {
|
|
1428
1406
|
return this.store.getDataBind(controlId);
|
|
1429
1407
|
}
|
|
1430
1408
|
},
|
|
1431
1409
|
{
|
|
1432
|
-
/**
|
|
1433
|
-
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1434
|
-
* @param controlId
|
|
1435
|
-
* @param rowIndex
|
|
1410
|
+
/**
|
|
1411
|
+
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1412
|
+
* @param controlId
|
|
1413
|
+
* @param rowIndex
|
|
1436
1414
|
*/ key: "getInstance",
|
|
1437
1415
|
value: function getInstance(controlId, rowIndex) {
|
|
1438
1416
|
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
@@ -1451,10 +1429,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1451
1429
|
}
|
|
1452
1430
|
},
|
|
1453
1431
|
{
|
|
1454
|
-
/**
|
|
1455
|
-
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1456
|
-
* @param controlId
|
|
1457
|
-
* @param header 明细表内是否获取表头的控件
|
|
1432
|
+
/**
|
|
1433
|
+
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1434
|
+
* @param controlId
|
|
1435
|
+
* @param header 明细表内是否获取表头的控件
|
|
1458
1436
|
*/ // getInstances(
|
|
1459
1437
|
// controlId?: string,
|
|
1460
1438
|
// header: boolean = false
|
|
@@ -1520,12 +1498,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1520
1498
|
var instances = Array.from(this.runtime.instanceMap[controlId] || []);
|
|
1521
1499
|
if (header) {
|
|
1522
1500
|
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1523
|
-
if (instances.length) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1501
|
+
// if (instances.length) {
|
|
1502
|
+
// const instance: RuntimeControl = instances[0]
|
|
1503
|
+
// const headerInstance = this.findSubtableHeadersControl(instance.id)
|
|
1504
|
+
// if (headerInstance !== undefined) {
|
|
1505
|
+
// instances.unshift(headerInstance)
|
|
1506
|
+
// }
|
|
1507
|
+
// }
|
|
1508
|
+
var headerInstance = this.findSubtableHeadersControl(controlId);
|
|
1509
|
+
if (headerInstance !== undefined) {
|
|
1510
|
+
instances.unshift(headerInstance);
|
|
1529
1511
|
}
|
|
1530
1512
|
}
|
|
1531
1513
|
// @ts-ignore
|
|
@@ -1542,6 +1524,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1542
1524
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1543
1525
|
instances.map(function(_instance) {
|
|
1544
1526
|
if (_instance) {
|
|
1527
|
+
// @i18n-translate-ignore
|
|
1545
1528
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1546
1529
|
updateValueFromKeys(_instance.props, props, value);
|
|
1547
1530
|
_this.schemaEvent('schema-change', {
|
|
@@ -1562,6 +1545,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1562
1545
|
if (!_instance) {
|
|
1563
1546
|
return;
|
|
1564
1547
|
}
|
|
1548
|
+
// @i18n-translate-ignore
|
|
1565
1549
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1566
1550
|
updateValueFromKeys(_instance.props, props, value);
|
|
1567
1551
|
this.schemaEvent('schema-change', {
|
|
@@ -1576,54 +1560,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1576
1560
|
}
|
|
1577
1561
|
}
|
|
1578
1562
|
},
|
|
1579
|
-
{
|
|
1580
|
-
/**
|
|
1581
|
-
* 前端二开新增方法,支持给多选控件动态赋值选项和默认值
|
|
1582
|
-
* ctx.setInstance('zQX4ViR3c0', 'options', [{ label:'初级:N<2年', value: '初级' },{ label:'高级:N>2年', value: '高级' }]);
|
|
1583
|
-
* ctx.setState('zQX4ViR3c0',['初级'])
|
|
1584
|
-
* 将以上两个方法封装成一个新的方法setInstanceAndState
|
|
1585
|
-
* ctx.setInstanceAndState('uexLafJeGH', 'options', [{ label:'初级:N<2年', value: '初级' ,checked: true},{ label:'初级:N>2年', value: '高级' }]);
|
|
1586
|
-
* 可同时设置选项和默认值
|
|
1587
|
-
* @param instance
|
|
1588
|
-
* @param props
|
|
1589
|
-
* @param value
|
|
1590
|
-
* @param rowIndex
|
|
1591
|
-
*/ key: "setInstanceAndState",
|
|
1592
|
-
value: function setInstanceAndState(instance, props, value, rowIndex) {
|
|
1593
|
-
this.setInstance(instance, props, value, rowIndex);
|
|
1594
|
-
if (value && Array.isArray(value)) {
|
|
1595
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1596
|
-
try {
|
|
1597
|
-
for(var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1598
|
-
var item = _step.value;
|
|
1599
|
-
if (item.checked) {
|
|
1600
|
-
var instanceId = '';
|
|
1601
|
-
if (typeof instance !== 'string') {
|
|
1602
|
-
instanceId = instance.id;
|
|
1603
|
-
} else {
|
|
1604
|
-
instanceId = instance;
|
|
1605
|
-
}
|
|
1606
|
-
this.setState(instanceId, item.value, rowIndex);
|
|
1607
|
-
break;
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
} catch (err) {
|
|
1611
|
-
_didIteratorError = true;
|
|
1612
|
-
_iteratorError = err;
|
|
1613
|
-
} finally{
|
|
1614
|
-
try {
|
|
1615
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1616
|
-
_iterator.return();
|
|
1617
|
-
}
|
|
1618
|
-
} finally{
|
|
1619
|
-
if (_didIteratorError) {
|
|
1620
|
-
throw _iteratorError;
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
},
|
|
1627
1563
|
{
|
|
1628
1564
|
key: "getControlIdMapping",
|
|
1629
1565
|
value: function getControlIdMapping() {
|
|
@@ -1638,7 +1574,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1638
1574
|
}
|
|
1639
1575
|
var mapping = this.store.dataBindMapping[dataCode];
|
|
1640
1576
|
if (!mapping) {
|
|
1641
|
-
warn(
|
|
1577
|
+
// warn(`No corresponding dataCode=${dataCode} was found`)
|
|
1642
1578
|
return;
|
|
1643
1579
|
}
|
|
1644
1580
|
if (!fieldCode) {
|
|
@@ -1648,7 +1584,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1648
1584
|
return item.fieldCode === fieldCode;
|
|
1649
1585
|
});
|
|
1650
1586
|
if (!dataBindMapping) {
|
|
1651
|
-
warn(
|
|
1587
|
+
// warn(`No corresponding fieldCode=${fieldCode} was found`)
|
|
1652
1588
|
return;
|
|
1653
1589
|
}
|
|
1654
1590
|
return dataBindMapping;
|
|
@@ -1674,27 +1610,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1674
1610
|
},
|
|
1675
1611
|
{
|
|
1676
1612
|
key: "assertInstance",
|
|
1677
|
-
value: /**
|
|
1678
|
-
* 判断控件的类型,返回当前控件的正确类型
|
|
1613
|
+
value: /**
|
|
1614
|
+
* 判断控件的类型,返回当前控件的正确类型
|
|
1679
1615
|
* */ function assertInstance(instance, types) {
|
|
1680
1616
|
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1681
1617
|
}
|
|
1682
1618
|
},
|
|
1683
1619
|
{
|
|
1684
1620
|
key: "assertInstanceIsCustomControl",
|
|
1685
|
-
value: /**
|
|
1686
|
-
* 判断控件或控件类型是一个自定义控件
|
|
1621
|
+
value: /**
|
|
1622
|
+
* 判断控件或控件类型是一个自定义控件
|
|
1687
1623
|
* */ function assertInstanceIsCustomControl(instance) {
|
|
1688
1624
|
return !isBuiltInControls(isString(instance) ? instance : instance.type);
|
|
1689
1625
|
}
|
|
1690
1626
|
},
|
|
1691
1627
|
{
|
|
1692
1628
|
key: "getInstanceRowIndex",
|
|
1693
|
-
value: /**
|
|
1694
|
-
* 获取控件在明细子表中的行下标,
|
|
1695
|
-
* 如果控件在表头内,则返回-1
|
|
1696
|
-
* 如果控件在表内,则返回行下标
|
|
1697
|
-
* 如果控件不在明细表内,则返回undefined
|
|
1629
|
+
value: /**
|
|
1630
|
+
* 获取控件在明细子表中的行下标,
|
|
1631
|
+
* 如果控件在表头内,则返回-1
|
|
1632
|
+
* 如果控件在表内,则返回行下标
|
|
1633
|
+
* 如果控件不在明细表内,则返回undefined
|
|
1698
1634
|
* */ // public getInstanceRowIndex(
|
|
1699
1635
|
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1700
1636
|
// ) {
|
|
@@ -110,6 +110,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
110
110
|
var instanceMap = {};
|
|
111
111
|
var controlParentIdMap = {};
|
|
112
112
|
loop(this._instance, '', function(item, parentId) {
|
|
113
|
+
var _item_parent;
|
|
113
114
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
114
115
|
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
115
116
|
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
@@ -129,6 +130,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
instances.push(item);
|
|
133
|
+
if (((_item_parent = item.parent) === null || _item_parent === void 0 ? void 0 : _item_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN && item.parent.parent === undefined) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
132
136
|
instanceMap[item.id].push(item);
|
|
133
137
|
});
|
|
134
138
|
this._flatInstances = instances;
|
|
@@ -277,16 +281,16 @@ function loop(control, parentId, callback) {
|
|
|
277
281
|
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
278
282
|
loop(item.props.headers, item.id, callback);
|
|
279
283
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
284
|
+
// if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
285
|
+
// loop((item.props as any).footers, item.id, callback)
|
|
286
|
+
// }
|
|
283
287
|
});
|
|
284
288
|
}
|
|
285
289
|
function hasHeaderOrFooterControl(control, checkType) {
|
|
286
290
|
return checkType in control.props && isArray(control.props[checkType]);
|
|
287
291
|
}
|
|
288
|
-
/**
|
|
289
|
-
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
292
|
+
/**
|
|
293
|
+
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
290
294
|
* */ function getControlIsHide(control) {
|
|
291
295
|
if (control.props.isHide) {
|
|
292
296
|
return true;
|