@byteluck-fe/model-driven-engine 2.9.0-beta.1 → 2.9.0-beta.3
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/esm/common/ActionManager.js +3 -3
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +112 -95
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +27 -43
- package/dist/esm/common/Store.js +12 -9
- package/dist/esm/common/checkerValue.js +39 -59
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +38 -34
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +21 -17
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +7 -7
- package/dist/esm/plugins/StylePlugin.js +5 -5
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +3 -3
- package/dist/index.umd.js +7 -12
- package/dist/types/common/Engine.d.ts +2 -0
- package/package.json +2 -2
|
@@ -179,7 +179,7 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
import { error, logerror } from
|
|
182
|
+
import { error, logerror } from '@byteluck-fe/model-driven-shared';
|
|
183
183
|
export var ActionManager = /*#__PURE__*/ function() {
|
|
184
184
|
"use strict";
|
|
185
185
|
function ActionManager() {
|
|
@@ -255,7 +255,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
255
255
|
key: "addAction",
|
|
256
256
|
value: function addAction(name, func) {
|
|
257
257
|
if (this.actionMap.has(name)) {
|
|
258
|
-
error(
|
|
258
|
+
error('duplicated action key');
|
|
259
259
|
}
|
|
260
260
|
var action = new Action(name, func);
|
|
261
261
|
this.actionMap.set(name, action);
|
|
@@ -268,7 +268,7 @@ var Action = function Action(id, func) {
|
|
|
268
268
|
"use strict";
|
|
269
269
|
_class_call_check(this, Action);
|
|
270
270
|
_define_property(this, "func", void 0);
|
|
271
|
-
_define_property(this, "id",
|
|
271
|
+
_define_property(this, "id", '');
|
|
272
272
|
this.id = id;
|
|
273
273
|
this.func = func;
|
|
274
274
|
};
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { JSONCopy, logerror } from
|
|
157
|
+
import { JSONCopy, logerror } from '@byteluck-fe/model-driven-shared';
|
|
158
158
|
export var DataManager = /*#__PURE__*/ function() {
|
|
159
159
|
"use strict";
|
|
160
160
|
function DataManager(callbackExecuter) {
|
|
@@ -190,7 +190,7 @@ export var DataManager = /*#__PURE__*/ function() {
|
|
|
190
190
|
return _async_to_generator(function() {
|
|
191
191
|
return _ts_generator(this, function(_state) {
|
|
192
192
|
if (_this.executer === undefined) {
|
|
193
|
-
logerror(
|
|
193
|
+
logerror('未初始化executer');
|
|
194
194
|
return [
|
|
195
195
|
2,
|
|
196
196
|
[]
|
|
@@ -44,6 +44,10 @@ function _async_to_generator(fn) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
function _call_super(_this, derived, args) {
|
|
48
|
+
derived = _get_prototype_of(derived);
|
|
49
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
50
|
+
}
|
|
47
51
|
function _class_call_check(instance, Constructor) {
|
|
48
52
|
if (!(instance instanceof Constructor)) {
|
|
49
53
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -222,28 +226,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
222
226
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
223
227
|
}
|
|
224
228
|
function _is_native_reflect_construct() {
|
|
225
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
226
|
-
if (Reflect.construct.sham) return false;
|
|
227
|
-
if (typeof Proxy === "function") return true;
|
|
228
229
|
try {
|
|
229
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function _create_super(Derived) {
|
|
236
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
237
|
-
return function _createSuperInternal() {
|
|
238
|
-
var Super = _get_prototype_of(Derived), result;
|
|
239
|
-
if (hasNativeReflectConstruct) {
|
|
240
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
241
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
242
|
-
} else {
|
|
243
|
-
result = Super.apply(this, arguments);
|
|
244
|
-
}
|
|
245
|
-
return _possible_constructor_return(this, result);
|
|
246
|
-
};
|
|
230
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
231
|
+
} catch (_) {}
|
|
232
|
+
return (_is_native_reflect_construct = function() {
|
|
233
|
+
return !!result;
|
|
234
|
+
})();
|
|
247
235
|
}
|
|
248
236
|
function _ts_generator(thisArg, body) {
|
|
249
237
|
var f, y, t, g, _ = {
|
|
@@ -340,50 +328,35 @@ function _ts_generator(thisArg, body) {
|
|
|
340
328
|
};
|
|
341
329
|
}
|
|
342
330
|
}
|
|
343
|
-
import { isDataBind } from
|
|
344
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from
|
|
345
|
-
import { Runtime } from
|
|
346
|
-
import { Store } from
|
|
347
|
-
import { findItem, proxyState } from
|
|
348
|
-
import { ActionManager } from
|
|
349
|
-
import { DataManager } from
|
|
350
|
-
import { checkerSubtableValue, checkerValue } from
|
|
351
|
-
import { buildUUID } from
|
|
352
|
-
if (typeof window !==
|
|
331
|
+
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
332
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
333
|
+
import { Runtime } from './Runtime';
|
|
334
|
+
import { Store } from './Store';
|
|
335
|
+
import { findItem, proxyState } from './proxyState';
|
|
336
|
+
import { ActionManager } from './ActionManager';
|
|
337
|
+
import { DataManager } from './DataManager';
|
|
338
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
339
|
+
import { buildUUID } from '../utils/runtimeUtils';
|
|
340
|
+
if (typeof window !== 'undefined') {
|
|
353
341
|
// @ts-ignore
|
|
354
342
|
window.engines = {};
|
|
355
343
|
}
|
|
356
344
|
// setState的时候,存储options中转变量
|
|
357
345
|
var eventOptionsTemp = null;
|
|
358
346
|
// 当前正在注册的插件名称
|
|
359
|
-
var applyingPluginName =
|
|
347
|
+
var applyingPluginName = '';
|
|
360
348
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
361
349
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
362
350
|
"use strict";
|
|
363
351
|
_inherits(Engine, Watcher);
|
|
364
|
-
var _super = _create_super(Engine);
|
|
365
352
|
function Engine(props) {
|
|
366
353
|
_class_call_check(this, Engine);
|
|
367
354
|
var _this;
|
|
368
|
-
_this =
|
|
369
|
-
_define_property(
|
|
370
|
-
_define_property(_assert_this_initialized(_this), "rawStore", {});
|
|
371
|
-
_define_property(_assert_this_initialized(_this), "parent", void 0);
|
|
372
|
-
// 提供注册运行态控件以及实例化控件的能力
|
|
373
|
-
_define_property(_assert_this_initialized(_this), "runtime", void 0);
|
|
374
|
-
// 提供子线程处理脚本以及修改数据的能力
|
|
355
|
+
_this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
|
|
356
|
+
_define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
|
|
375
357
|
// public worker: OkWorker
|
|
376
|
-
_define_property(
|
|
377
|
-
_define_property(
|
|
378
|
-
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
379
|
-
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
380
|
-
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
381
|
-
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
382
|
-
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
383
|
-
_define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
|
|
384
|
-
_define_property(_assert_this_initialized(_this), "dataManager", void 0);
|
|
385
|
-
_define_property(_assert_this_initialized(_this), "_jobTasks", []);
|
|
386
|
-
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
358
|
+
_define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
359
|
+
_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);
|
|
387
360
|
_this.$options = Object.freeze(props);
|
|
388
361
|
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
362
|
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;
|
|
@@ -397,7 +370,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
397
370
|
_this.store = new Store({
|
|
398
371
|
instance: _this.runtime.instance
|
|
399
372
|
});
|
|
400
|
-
_this.debugLog(
|
|
373
|
+
_this.debugLog('engine is Instantiation complete');
|
|
401
374
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
402
375
|
autoMount && _this.mount();
|
|
403
376
|
return _this;
|
|
@@ -444,7 +417,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
444
417
|
// 触发所有控件的默认值的change事件
|
|
445
418
|
this.setStates(this.getState());
|
|
446
419
|
this.debugLog("engine的mount方法调用结束");
|
|
447
|
-
if (this.debug && typeof window !==
|
|
420
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
448
421
|
// @ts-ignore
|
|
449
422
|
window.engines[this.id] = this;
|
|
450
423
|
}
|
|
@@ -453,7 +426,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
453
426
|
{
|
|
454
427
|
key: "destroy",
|
|
455
428
|
value: function destroy() {
|
|
456
|
-
if (this.debug && typeof window !==
|
|
429
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
457
430
|
// @ts-ignore
|
|
458
431
|
delete window.engines[this.id];
|
|
459
432
|
}
|
|
@@ -494,7 +467,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
467
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
468
|
});
|
|
496
469
|
}
|
|
497
|
-
var keys = key.split(
|
|
470
|
+
var keys = key.split('.');
|
|
498
471
|
var lastKey = keys[keys.length - 1];
|
|
499
472
|
try {
|
|
500
473
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -520,7 +493,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
520
493
|
var _this = this;
|
|
521
494
|
var instanceItem = findItem(key, this);
|
|
522
495
|
var subtable = instanceItem.instance;
|
|
523
|
-
debugger;
|
|
524
496
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
525
497
|
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
526
498
|
// 新增多行方法
|
|
@@ -529,7 +501,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
529
501
|
var newRows = [];
|
|
530
502
|
for(var i = 0; i < len; i++){
|
|
531
503
|
// @ts-ignore
|
|
532
|
-
var row = _this.listControlCreateRow(subtable,
|
|
504
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
533
505
|
row && newRows.push(row);
|
|
534
506
|
}
|
|
535
507
|
// @ts-ignore
|
|
@@ -544,8 +516,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
544
516
|
if (type && args) {
|
|
545
517
|
// const subtableOldLength = subtable.children.length
|
|
546
518
|
switch(type){
|
|
547
|
-
case
|
|
548
|
-
case
|
|
519
|
+
case 'push':
|
|
520
|
+
case 'unshift':
|
|
549
521
|
var _subtable_children;
|
|
550
522
|
var newRowLengths = args.length;
|
|
551
523
|
createdNewRows = createRows(newRowLengths);
|
|
@@ -553,7 +525,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
553
525
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
554
526
|
this.runtime.getFlatInstances();
|
|
555
527
|
break;
|
|
556
|
-
case
|
|
528
|
+
case 'splice':
|
|
557
529
|
if (args.length > 2) {
|
|
558
530
|
var // @ts-ignore
|
|
559
531
|
_subtable_children1;
|
|
@@ -595,11 +567,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
595
567
|
this.runtime.getFlatInstances();
|
|
596
568
|
break;
|
|
597
569
|
}
|
|
598
|
-
if (type ===
|
|
570
|
+
if (type === 'splice') {
|
|
599
571
|
deleted = result;
|
|
600
572
|
} else if ([
|
|
601
|
-
|
|
602
|
-
|
|
573
|
+
'pop',
|
|
574
|
+
'shift'
|
|
603
575
|
].includes(type)) {
|
|
604
576
|
deleted = [
|
|
605
577
|
result
|
|
@@ -607,7 +579,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
607
579
|
}
|
|
608
580
|
var subtableData = this.getState(subtable.id);
|
|
609
581
|
this._handlerSubtableUpdateUid(subtableData);
|
|
610
|
-
this.emit(
|
|
582
|
+
this.emit('list-change', {
|
|
611
583
|
instance: subtable,
|
|
612
584
|
value: subtableData,
|
|
613
585
|
options: Object.assign({}, options, {
|
|
@@ -628,10 +600,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
628
600
|
{
|
|
629
601
|
key: "_handlerSubtableUpdateUid",
|
|
630
602
|
value: function _handlerSubtableUpdateUid(subtableData) {
|
|
603
|
+
;
|
|
631
604
|
subtableData.forEach(function(item) {
|
|
632
605
|
if (!item.uid) {
|
|
633
606
|
Object.assign(item, {
|
|
634
|
-
uid:
|
|
607
|
+
uid: 'new:' + buildUUID('uid')
|
|
635
608
|
});
|
|
636
609
|
}
|
|
637
610
|
});
|
|
@@ -656,7 +629,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
656
629
|
var newRows = [];
|
|
657
630
|
for(var i = 0; i < newValue.length; i++){
|
|
658
631
|
// @ts-ignore
|
|
659
|
-
var row = this.listControlCreateRow(instance,
|
|
632
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
660
633
|
row && newRows.push(row);
|
|
661
634
|
}
|
|
662
635
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -670,7 +643,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
670
643
|
deleted = [];
|
|
671
644
|
}
|
|
672
645
|
this._handlerSubtableUpdateUid(newValue);
|
|
673
|
-
this.emit(
|
|
646
|
+
this.emit('list-change', {
|
|
674
647
|
instance: instance,
|
|
675
648
|
value: value,
|
|
676
649
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -679,12 +652,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
679
652
|
data: newValue,
|
|
680
653
|
deleted: deleted,
|
|
681
654
|
// deleted: oldValue ?? [],
|
|
682
|
-
type:
|
|
655
|
+
type: 'push',
|
|
683
656
|
jsonValue: JSON.stringify(newValue)
|
|
684
657
|
})
|
|
685
658
|
});
|
|
686
659
|
} else {
|
|
687
|
-
this.emit(
|
|
660
|
+
this.emit('change', {
|
|
688
661
|
instance: instance,
|
|
689
662
|
value: this.getState(instance.id, index),
|
|
690
663
|
rowIndex: index,
|
|
@@ -708,7 +681,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
708
681
|
} catch (e) {
|
|
709
682
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
710
683
|
} finally{
|
|
711
|
-
applyingPluginName =
|
|
684
|
+
applyingPluginName = '';
|
|
712
685
|
}
|
|
713
686
|
});
|
|
714
687
|
this.__pluginsApplied = true;
|
|
@@ -718,20 +691,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
718
691
|
key: "listControlCreateRow",
|
|
719
692
|
value: function listControlCreateRow(instance, rowType) {
|
|
720
693
|
var row;
|
|
721
|
-
if (rowType ===
|
|
694
|
+
if (rowType === 'subtable-row') {
|
|
722
695
|
row = {
|
|
723
696
|
children: [],
|
|
724
697
|
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
725
698
|
id: genNonDuplicateId(),
|
|
726
|
-
type:
|
|
699
|
+
type: 'subtable-row',
|
|
727
700
|
props: {
|
|
728
|
-
caption:
|
|
701
|
+
caption: '',
|
|
729
702
|
isHide: false,
|
|
730
703
|
style: {
|
|
731
|
-
height:
|
|
732
|
-
heightConfig:
|
|
733
|
-
width:
|
|
734
|
-
widthConfig:
|
|
704
|
+
height: '',
|
|
705
|
+
heightConfig: 'fill',
|
|
706
|
+
width: '',
|
|
707
|
+
widthConfig: 'fill'
|
|
735
708
|
}
|
|
736
709
|
},
|
|
737
710
|
fieldType: undefined,
|
|
@@ -785,7 +758,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
785
758
|
key: "listControlAddRow",
|
|
786
759
|
value: function listControlAddRow(instance) {
|
|
787
760
|
var // @ts-ignore
|
|
788
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
761
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
789
762
|
var row = this.listControlCreateRow(instance, rowType);
|
|
790
763
|
if (!row) return;
|
|
791
764
|
instance.children.push(row);
|
|
@@ -804,12 +777,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
804
777
|
return _ts_generator(this, function(_state) {
|
|
805
778
|
switch(_state.label){
|
|
806
779
|
case 0:
|
|
807
|
-
if (!(eventKey ===
|
|
780
|
+
if (!(eventKey === 'engine-mounted')) return [
|
|
808
781
|
3,
|
|
809
782
|
3
|
|
810
783
|
];
|
|
811
784
|
if (_this1.isMounted) {
|
|
812
|
-
warn(
|
|
785
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
813
786
|
return [
|
|
814
787
|
2,
|
|
815
788
|
Promise.resolve([])
|
|
@@ -819,7 +792,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
819
792
|
3,
|
|
820
793
|
2
|
|
821
794
|
];
|
|
822
|
-
console.time(
|
|
795
|
+
console.time('engine-mounted need wait');
|
|
823
796
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
824
797
|
return [
|
|
825
798
|
4,
|
|
@@ -827,7 +800,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
827
800
|
];
|
|
828
801
|
case 1:
|
|
829
802
|
_state.sent();
|
|
830
|
-
console.timeEnd(
|
|
803
|
+
console.timeEnd('engine-mounted need wait');
|
|
831
804
|
_state.label = 2;
|
|
832
805
|
case 2:
|
|
833
806
|
_this1.isMounted = true;
|
|
@@ -992,9 +965,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
992
965
|
key: "setState",
|
|
993
966
|
value: function setState(controlId, value, rowIndex, options) {
|
|
994
967
|
eventOptionsTemp = options;
|
|
995
|
-
this.debugLog(
|
|
968
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
996
969
|
this.store.setState(controlId, value, rowIndex);
|
|
997
|
-
this.debugLog(
|
|
970
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
998
971
|
eventOptionsTemp = null;
|
|
999
972
|
}
|
|
1000
973
|
},
|
|
@@ -1027,6 +1000,50 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1027
1000
|
});
|
|
1028
1001
|
}
|
|
1029
1002
|
},
|
|
1003
|
+
{
|
|
1004
|
+
//理想-获取表单头部信息
|
|
1005
|
+
key: "getTitleField",
|
|
1006
|
+
value: function getTitleField(key) {
|
|
1007
|
+
var titleData = Object.values(this.store.state).filter(function(a) {
|
|
1008
|
+
return a.submit_user;
|
|
1009
|
+
})[0];
|
|
1010
|
+
if (key) {
|
|
1011
|
+
return titleData[key];
|
|
1012
|
+
} else {
|
|
1013
|
+
return titleData;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
//理想-获取系统字段
|
|
1019
|
+
key: "getSystemField",
|
|
1020
|
+
value: function getSystemField(key) {
|
|
1021
|
+
var _this_externalParams;
|
|
1022
|
+
var systemCodesMap = [
|
|
1023
|
+
'creator',
|
|
1024
|
+
'process_location',
|
|
1025
|
+
'create_time',
|
|
1026
|
+
'uid',
|
|
1027
|
+
'update_time',
|
|
1028
|
+
'process_status',
|
|
1029
|
+
'process_instance_id',
|
|
1030
|
+
'process_key'
|
|
1031
|
+
];
|
|
1032
|
+
var arr = ((_this_externalParams = this.externalParams) === null || _this_externalParams === void 0 ? void 0 : _this_externalParams.data.data_set.values.filter(function(a) {
|
|
1033
|
+
return systemCodesMap.some(function(k) {
|
|
1034
|
+
return k == a.code;
|
|
1035
|
+
});
|
|
1036
|
+
})) || [];
|
|
1037
|
+
if (key) {
|
|
1038
|
+
var _arr_filter_;
|
|
1039
|
+
return (_arr_filter_ = arr.filter(function(a) {
|
|
1040
|
+
return a.code == key;
|
|
1041
|
+
})[0]) === null || _arr_filter_ === void 0 ? void 0 : _arr_filter_.value;
|
|
1042
|
+
} else {
|
|
1043
|
+
return arr;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1030
1047
|
{
|
|
1031
1048
|
/**
|
|
1032
1049
|
* 通过dataCode和fieldCode来获取控件的值
|
|
@@ -1081,7 +1098,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1081
1098
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1082
1099
|
var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
|
|
1083
1100
|
//未绑定字段的控件,直接抛弃
|
|
1084
|
-
if (fieldCode !==
|
|
1101
|
+
if (fieldCode !== '') {
|
|
1085
1102
|
var _controlIdMapping_controlId1;
|
|
1086
1103
|
if (fieldCode) {
|
|
1087
1104
|
obj[fieldCode] = item[key];
|
|
@@ -1112,7 +1129,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1112
1129
|
var _controlIdMapping_key_children_keyChi;
|
|
1113
1130
|
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;
|
|
1114
1131
|
//未绑定字段的控件,直接抛弃
|
|
1115
|
-
if (fieldCode !==
|
|
1132
|
+
if (fieldCode !== '') {
|
|
1116
1133
|
if (fieldCode) {
|
|
1117
1134
|
objChi[fieldCode] = item[keyChi];
|
|
1118
1135
|
} else {
|
|
@@ -1333,9 +1350,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1333
1350
|
});
|
|
1334
1351
|
newRow[fieldMapping.controlId] = objValue;
|
|
1335
1352
|
}
|
|
1336
|
-
} else if (fieldCode ===
|
|
1353
|
+
} else if (fieldCode === 'uid' && row.uid !== undefined) {
|
|
1337
1354
|
newRow.uid = row.uid;
|
|
1338
|
-
} else if (fieldCode ===
|
|
1355
|
+
} else if (fieldCode === 'virtualStore' && row.virtualStore !== undefined) {
|
|
1339
1356
|
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1340
1357
|
}
|
|
1341
1358
|
});
|
|
@@ -1387,7 +1404,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1387
1404
|
var _newState_newMapping_controlId;
|
|
1388
1405
|
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1389
1406
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1390
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1407
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1391
1408
|
if (Object.keys(newState).length) {
|
|
1392
1409
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1393
1410
|
} else {
|
|
@@ -1524,14 +1541,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1524
1541
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1525
1542
|
var _this = this;
|
|
1526
1543
|
try {
|
|
1527
|
-
if (typeof instance ===
|
|
1544
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1528
1545
|
//修改明细表整列属性的逻辑
|
|
1529
1546
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1530
1547
|
instances.map(function(_instance) {
|
|
1531
1548
|
if (_instance) {
|
|
1532
1549
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1533
1550
|
updateValueFromKeys(_instance.props, props, value);
|
|
1534
|
-
_this.schemaEvent(
|
|
1551
|
+
_this.schemaEvent('schema-change', {
|
|
1535
1552
|
instance: _instance,
|
|
1536
1553
|
props: props,
|
|
1537
1554
|
value: value,
|
|
@@ -1541,7 +1558,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1541
1558
|
});
|
|
1542
1559
|
} else {
|
|
1543
1560
|
var _instance;
|
|
1544
|
-
if (typeof instance ===
|
|
1561
|
+
if (typeof instance === 'string') {
|
|
1545
1562
|
_instance = this.getInstance(instance, rowIndex);
|
|
1546
1563
|
} else {
|
|
1547
1564
|
_instance = instance;
|
|
@@ -1551,7 +1568,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1551
1568
|
}
|
|
1552
1569
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1553
1570
|
updateValueFromKeys(_instance.props, props, value);
|
|
1554
|
-
this.schemaEvent(
|
|
1571
|
+
this.schemaEvent('schema-change', {
|
|
1555
1572
|
instance: _instance,
|
|
1556
1573
|
props: props,
|
|
1557
1574
|
value: value,
|
|
@@ -1678,7 +1695,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1678
1695
|
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1679
1696
|
if (isColumnChild) {
|
|
1680
1697
|
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1681
|
-
if (Object.prototype.toString.call(instanceList) ===
|
|
1698
|
+
if (Object.prototype.toString.call(instanceList) === '[object Array]') {
|
|
1682
1699
|
var index = instanceList.findIndex(function(item) {
|
|
1683
1700
|
return item === instance;
|
|
1684
1701
|
});
|
|
@@ -1784,7 +1801,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1784
1801
|
key: "register",
|
|
1785
1802
|
value: // 注册外部控件
|
|
1786
1803
|
function register(control) {
|
|
1787
|
-
return Runtime.register(control,
|
|
1804
|
+
return Runtime.register(control, 'Runtime');
|
|
1788
1805
|
}
|
|
1789
1806
|
},
|
|
1790
1807
|
{
|
|
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { log } from
|
|
33
|
+
import { log } from '@byteluck-fe/model-driven-shared';
|
|
34
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
35
35
|
"use strict";
|
|
36
36
|
function OkWorker() {
|
|
@@ -43,7 +43,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
43
43
|
value: function run(initState) {
|
|
44
44
|
this.worker = OkWorker.createWorker();
|
|
45
45
|
this.postMessage({
|
|
46
|
-
action:
|
|
46
|
+
action: 'init',
|
|
47
47
|
payload: initState
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -77,7 +77,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
77
77
|
key: "createWorkerFunction",
|
|
78
78
|
value: function createWorkerFunction() {
|
|
79
79
|
return function() {
|
|
80
|
-
log(
|
|
80
|
+
log('🚀 worker running');
|
|
81
81
|
var _self = self;
|
|
82
82
|
function createHandler(parentKey) {
|
|
83
83
|
return {
|
|
@@ -87,7 +87,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
87
87
|
set: function set(target, key, value) {
|
|
88
88
|
if (parentKey) {
|
|
89
89
|
_self.postMessage({
|
|
90
|
-
action:
|
|
90
|
+
action: 'update',
|
|
91
91
|
key: "".concat(parentKey, ".").concat(key)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -106,7 +106,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
106
106
|
// }
|
|
107
107
|
// return new Proxy(obj, createHandler(parentKey))
|
|
108
108
|
// }
|
|
109
|
-
_self.addEventListener(
|
|
109
|
+
_self.addEventListener('message', function(event) {
|
|
110
110
|
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
111
111
|
log(action, payload);
|
|
112
112
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
@@ -118,10 +118,10 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
118
118
|
//
|
|
119
119
|
// const result = fn(data, schema)
|
|
120
120
|
_self.postMessage({
|
|
121
|
-
action:
|
|
121
|
+
action: 'delete',
|
|
122
122
|
payload: {
|
|
123
|
-
key:
|
|
124
|
-
value:
|
|
123
|
+
key: 'key3[0].key1',
|
|
124
|
+
value: 'index'
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|