@byteluck-fe/model-driven-engine 2.1.0-beta.1 → 2.1.0-sourcemap.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.
|
@@ -333,7 +333,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
335
|
};
|
|
336
|
-
import { DataBind, ObjectDataBind, RuntimeFormControl, RuntimeListControl } from "@byteluck-fe/model-driven-core";
|
|
336
|
+
import { DataBind, ObjectDataBind, RuntimeFormControl, RuntimeLayoutControl, RuntimeListControl } from "@byteluck-fe/model-driven-core";
|
|
337
337
|
import { CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
338
338
|
import { Runtime } from "./Runtime";
|
|
339
339
|
import { Store } from "./Store";
|
|
@@ -341,7 +341,6 @@ import { findItem, proxyState } from "./proxyState";
|
|
|
341
341
|
import { ActionManager } from "./ActionManager";
|
|
342
342
|
import { DataManager } from "./DataManager";
|
|
343
343
|
import { checkerSubtableValue, checkerValue } from "./checkerValue";
|
|
344
|
-
import { genSubTableRowInstanceFromHeaders } from "./SubTableSpeedUp";
|
|
345
344
|
if (typeof window !== "undefined") {
|
|
346
345
|
// @ts-ignore
|
|
347
346
|
window.engines = {};
|
|
@@ -431,6 +430,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
431
430
|
this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
|
|
432
431
|
};
|
|
433
432
|
_proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
|
|
433
|
+
var _this = this;
|
|
434
434
|
var instance = findItem(this.runtime.flatInstances, key);
|
|
435
435
|
// 找不到控件说明不是改动控件上的字段,直接通过
|
|
436
436
|
if (!instance) {
|
|
@@ -438,9 +438,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
438
438
|
}
|
|
439
439
|
// @ts-ignore
|
|
440
440
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
441
|
-
if (newValue === null) {
|
|
442
|
-
return [];
|
|
443
|
-
}
|
|
444
441
|
// @ts-ignore
|
|
445
442
|
var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
|
|
446
443
|
var formInstance = column.children[0];
|
|
@@ -449,11 +446,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
449
446
|
}
|
|
450
447
|
return result;
|
|
451
448
|
}, {});
|
|
452
|
-
|
|
453
|
-
|
|
449
|
+
if (newValue === null) {
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
454
452
|
return newValue.map(function(row) {
|
|
455
453
|
return(// @ts-ignore
|
|
456
|
-
checkerSubtableValue(fieldTypeMap, row,
|
|
454
|
+
checkerSubtableValue(fieldTypeMap, row, _this.getEmptyState(instance.id)));
|
|
457
455
|
});
|
|
458
456
|
}
|
|
459
457
|
var keys = key.split(".");
|
|
@@ -473,12 +471,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
473
471
|
}
|
|
474
472
|
};
|
|
475
473
|
_proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
|
|
474
|
+
var _this = this;
|
|
476
475
|
var subtable = findItem(this.runtime.flatInstances, key);
|
|
477
476
|
if (!_instanceof(subtable, RuntimeListControl)) return;
|
|
478
477
|
// 新增多行方法
|
|
479
|
-
// JUTODO 这里已经直接删除了创建instance 的逻辑,或许以后连这个函数都不需要调用了
|
|
480
478
|
var createRows = function(len) {
|
|
481
|
-
|
|
479
|
+
// @ts-ignore
|
|
480
|
+
var newRows = [];
|
|
481
|
+
for(var i = 0; i < len; i++){
|
|
482
|
+
// @ts-ignore
|
|
483
|
+
var row = _this.listControlCreateRow(subtable, "subtable-row");
|
|
484
|
+
row && newRows.push(row);
|
|
485
|
+
}
|
|
486
|
+
// @ts-ignore
|
|
487
|
+
return newRows;
|
|
482
488
|
};
|
|
483
489
|
var options = eventOptionsTemp;
|
|
484
490
|
// @ts-ignore
|
|
@@ -563,10 +569,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
563
569
|
var index = this.getInstanceRowIndex(instance);
|
|
564
570
|
var options = eventOptionsTemp || {};
|
|
565
571
|
if (_instanceof(instance, RuntimeListControl)) {
|
|
572
|
+
var // @ts-ignore
|
|
573
|
+
_instance_children;
|
|
566
574
|
instance.children.length = 0;
|
|
567
575
|
var newValue = value;
|
|
568
576
|
// @ts-ignore
|
|
569
577
|
var newRows = [];
|
|
578
|
+
for(var i = 0; i < newValue.length; i++){
|
|
579
|
+
// @ts-ignore
|
|
580
|
+
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
581
|
+
row && newRows.push(row);
|
|
582
|
+
}
|
|
583
|
+
(_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
|
|
584
|
+
this.runtime.getFlatInstances();
|
|
570
585
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
571
586
|
// for (let i = 0; i < newValue.length; i++) {
|
|
572
587
|
// this.setStates(newValue[i], i, options)
|
|
@@ -609,13 +624,23 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
609
624
|
this.__pluginsApplied = true;
|
|
610
625
|
};
|
|
611
626
|
_proto.listControlCreateRow = function listControlCreateRow(instance, rowType) {
|
|
612
|
-
|
|
627
|
+
var row = this.runtime.createControlInstance(rowType);
|
|
628
|
+
if (!row) return;
|
|
629
|
+
if (_instanceof(row, RuntimeLayoutControl)) {
|
|
630
|
+
var _row_children;
|
|
631
|
+
var template = JSONCopy(instance.props.headers);
|
|
632
|
+
// @ts-ignore
|
|
633
|
+
var columns = this.createControl(template);
|
|
634
|
+
(_row_children = row.children).push.apply(_row_children, _toConsumableArray(columns));
|
|
635
|
+
}
|
|
636
|
+
return row;
|
|
613
637
|
};
|
|
614
638
|
_proto.listControlAddRow = function listControlAddRow(instance) {
|
|
615
639
|
var // @ts-ignore
|
|
616
640
|
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
|
|
617
|
-
|
|
618
|
-
|
|
641
|
+
var row = this.listControlCreateRow(instance, rowType);
|
|
642
|
+
if (!row) return;
|
|
643
|
+
instance.children.push(row);
|
|
619
644
|
};
|
|
620
645
|
// payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
|
|
621
646
|
_proto.emit = function emit(eventKey, payload) {
|
|
@@ -1288,27 +1313,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1288
1313
|
_proto.getControlConfig = function getControlConfig(control) {
|
|
1289
1314
|
return this.runtime.getControlConfig(control);
|
|
1290
1315
|
};
|
|
1291
|
-
_proto.initSubTableRowPropsFromInstanceHeaders = function initSubTableRowPropsFromInstanceHeaders(instance) {
|
|
1292
|
-
var cc = console;
|
|
1293
|
-
var now = Date.now();
|
|
1294
|
-
var timeLabel = "\uD83D\uDC2E initSubTableRowPropsFromInstanceHeaders " + now;
|
|
1295
|
-
cc.time(timeLabel);
|
|
1296
|
-
/**headers实际 是 SubTableColumnControl的数组 */ Object.assign(instance.rowProps, genSubTableRowInstanceFromHeaders(instance.props.headers));
|
|
1297
|
-
cc.timeEnd(timeLabel);
|
|
1298
|
-
};
|
|
1299
|
-
_proto.initSubTableRowPropsFromProxySetNewValue = function initSubTableRowPropsFromProxySetNewValue(instance, value) {
|
|
1300
|
-
var cc = console;
|
|
1301
|
-
var now = Date.now();
|
|
1302
|
-
var timeLabel = "\uD83D\uDC37 initSubTableRowPropsFromProxySetNewValue " + now;
|
|
1303
|
-
cc.time(timeLabel);
|
|
1304
|
-
value.forEach(function(item) {
|
|
1305
|
-
Object.assign(instance.rowProps, {
|
|
1306
|
-
// 这里只是做个性能测试,实际上需要merge rowProps,并且还需要一个恰当的key
|
|
1307
|
-
now: genSubTableRowInstanceFromHeaders(instance.props.headers)
|
|
1308
|
-
});
|
|
1309
|
-
});
|
|
1310
|
-
cc.timeEnd(timeLabel);
|
|
1311
|
-
};
|
|
1312
1316
|
// 注册外部控件
|
|
1313
1317
|
Engine.register = function register() {
|
|
1314
1318
|
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -1323,3 +1327,4 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1323
1327
|
return Engine;
|
|
1324
1328
|
}(Watcher);
|
|
1325
1329
|
export { Engine };
|
|
1330
|
+
console.log("a");
|