@byteluck-fe/model-driven-engine 1.7.6-bete.20 → 1.7.6-bete.21

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.
@@ -341,6 +341,7 @@ 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";
344
345
  if (typeof window !== "undefined") {
345
346
  // @ts-ignore
346
347
  window.engines = {};
@@ -434,7 +435,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
434
435
  this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
435
436
  };
436
437
  _proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
437
- var _this = this;
438
438
  var cc = console;
439
439
  var now = Date.now();
440
440
  cc.log("㊗️_proxyStateBeforeSetCallback findItem " + key, newValue, oldValue);
@@ -447,6 +447,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
447
447
  }
448
448
  // @ts-ignore
449
449
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
450
+ if (newValue === null) {
451
+ return [];
452
+ }
450
453
  // @ts-ignore
451
454
  var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
452
455
  var formInstance = column.children[0];
@@ -455,12 +458,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
455
458
  }
456
459
  return result;
457
460
  }, {});
458
- if (newValue === null) {
459
- return [];
460
- }
461
+ // @ts-ignore
462
+ var emptyState = this.getEmptyState(instance.id);
461
463
  return newValue.map(function(row) {
462
- return(// @ts-ignore
463
- checkerSubtableValue(fieldTypeMap, row, _this.getEmptyState(instance.id)));
464
+ return checkerSubtableValue(fieldTypeMap, row, emptyState);
464
465
  });
465
466
  }
466
467
  var keys = key.split(".");
@@ -592,30 +593,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
592
593
  var index = this.getInstanceRowIndex(instance);
593
594
  var options = eventOptionsTemp || {};
594
595
  if (_instanceof(instance, RuntimeListControl)) {
595
- // const hasValue = Object.keys(instance.rowProps).length > 0
596
- // debugger
597
- // if (!hasValue) {
598
- // instance.children = instance.props.headers.map((header) => {
599
- // // instance.rowProps[header.id] = (this.createInstance as any)(
600
- // // header.controlType
601
- // // )
602
- // return (this.createInstance as any)(
603
- // header.controlType
604
- // )
605
- // })
606
- // }
607
596
  // instance.children.length = 0
597
+ this.initSubTableRowPropsFromInstanceHeaders(instance);
608
598
  var newValue = value;
609
599
  // @ts-ignore
610
600
  var newRows = [];
611
- // JUTODO 这里template就是headers对应的 subtable-columns
612
- // JUTODO 需要新增一种 subtableRow 的数据结构
613
- // 同时,可以以其中一行进行缓存,作为 subtable-headers-columns 的公共列的instance
614
- // 究竟要去 subtableRow 中取 props 还是 去 公共header instance 取?
615
- // 答:始终应该取 subtableRow 的props,因为它是从 subtable-headers-columns 里copy下来的,并且可能会被同行的其他列修改
616
- // const rowID =
617
- // const subtableRow = genSubTableRowInstanceFromHeaders(instance.props.headers)
618
- // instance.setRowProps()
601
+ this.initSubTableRowPropsFromProxySetNewValue(instance, value);
619
602
  // for (let i = 0; i < newValue.length; i++) {
620
603
  // // @ts-ignore
621
604
  // const row = this.listControlCreateRow(instance, 'subtable-row')
@@ -624,10 +607,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
624
607
  // @ts-ignore
625
608
  // instance.children.push(...newRows)
626
609
  this.runtime.getFlatInstances();
627
- // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
628
- // for (let i = 0; i < newValue.length; i++) {
629
- // this.setStates(newValue[i], i, options)
630
- // }
631
610
  this.emit("list-change", {
632
611
  instance: instance,
633
612
  value: value,
@@ -1064,7 +1043,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1064
1043
  var _this = this;
1065
1044
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1066
1045
  var newState = {};
1067
- debugger;
1046
+ // debugger
1068
1047
  Object.keys(dataSet).map(function(dataCode) {
1069
1048
  var entity = dataSet[dataCode];
1070
1049
  if (Array.isArray(entity)) {
@@ -1362,6 +1341,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1362
1341
  _proto.getControlConfig = function getControlConfig(control) {
1363
1342
  return this.runtime.getControlConfig(control);
1364
1343
  };
1344
+ _proto.initSubTableRowPropsFromInstanceHeaders = function initSubTableRowPropsFromInstanceHeaders(instance) {
1345
+ var cc = console;
1346
+ var now = Date.now();
1347
+ var timeLabel = "\uD83D\uDC2E initSubTableRowPropsFromInstanceHeaders " + now;
1348
+ cc.time(timeLabel);
1349
+ /**headers实际 是 SubTableColumnControl的数组 */ Object.assign(instance.rowProps, genSubTableRowInstanceFromHeaders(instance.props.headers));
1350
+ cc.timeEnd(timeLabel);
1351
+ };
1352
+ _proto.initSubTableRowPropsFromProxySetNewValue = function initSubTableRowPropsFromProxySetNewValue(instance, value) {
1353
+ var cc = console;
1354
+ var now = Date.now();
1355
+ var timeLabel = "\uD83D\uDC37 initSubTableRowPropsFromProxySetNewValue " + now;
1356
+ cc.time(timeLabel);
1357
+ value.forEach(function(item) {
1358
+ Object.assign(instance.rowProps, {
1359
+ // 这里只是做个性能测试,实际上需要merge rowProps,并且还需要一个恰当的key
1360
+ now: genSubTableRowInstanceFromHeaders(instance.props.headers)
1361
+ });
1362
+ });
1363
+ cc.timeEnd(timeLabel);
1364
+ };
1365
1365
  // 注册外部控件
1366
1366
  Engine.register = function register() {
1367
1367
  for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
@@ -6,9 +6,12 @@ headers) {
6
6
  var subtableRow = headers.reduce(function(pre, cur) {
7
7
  var children = cur.children;
8
8
  children.forEach(function(control) {
9
- pre[control.id] = cloneDeep(control.props);
9
+ pre[control.id] = copyPropsFromControlInstance(control);
10
10
  });
11
11
  return pre;
12
12
  }, {});
13
13
  return subtableRow;
14
14
  }
15
+ function copyPropsFromControlInstance(control) {
16
+ return cloneDeep(control.props);
17
+ }