@byteluck-fe/model-driven-engine 2.1.0-sourcemap → 2.1.0-sourcemap.10

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.
@@ -358,6 +358,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
358
358
  _classCallCheck(this, Engine);
359
359
  var _this;
360
360
  _this = _super.call(this);
361
+ _this.rawStore = {};
361
362
  // 提供子线程处理脚本以及修改数据的能力
362
363
  // public worker: OkWorker
363
364
  _this.isMounted = false;
@@ -430,14 +431,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
430
431
  this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
431
432
  };
432
433
  _proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
433
- var _this = this;
434
- var instance = findItem(this.runtime.flatInstances, key);
434
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
435
435
  // 找不到控件说明不是改动控件上的字段,直接通过
436
436
  if (!instance) {
437
437
  return newValue;
438
438
  }
439
439
  // @ts-ignore
440
440
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
441
+ if (newValue === null) {
442
+ return [];
443
+ }
441
444
  // @ts-ignore
442
445
  var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
443
446
  var formInstance = column.children[0];
@@ -446,12 +449,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
446
449
  }
447
450
  return result;
448
451
  }, {});
449
- if (newValue === null) {
450
- return [];
451
- }
452
+ // @ts-ignore
453
+ var emptyState = this.getEmptyState(instance.id);
452
454
  return newValue.map(function(row) {
453
455
  return(// @ts-ignore
454
- checkerSubtableValue(fieldTypeMap, row, _this.getEmptyState(instance.id)));
456
+ checkerSubtableValue(fieldTypeMap, row, emptyState));
455
457
  });
456
458
  }
457
459
  var keys = key.split(".");
@@ -472,7 +474,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
472
474
  };
473
475
  _proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
474
476
  var _this = this;
475
- var subtable = findItem(this.runtime.flatInstances, key);
477
+ var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
476
478
  if (!_instanceof(subtable, RuntimeListControl)) return;
477
479
  // 新增多行方法
478
480
  var createRows = function(len) {
@@ -562,7 +564,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
562
564
  }
563
565
  };
564
566
  _proto._handlerObjectUpdate = function _handlerObjectUpdate(state, key, value, oldValue) {
565
- var instance = findItem(this.runtime.flatInstances, key);
567
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
566
568
  if (!instance) {
567
569
  return;
568
570
  }
@@ -879,7 +881,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
879
881
  for(var keyChi1 in item[keyChi]){
880
882
  var _controlIdMapping_key_children_keyChi2;
881
883
  objChi[(_controlIdMapping_key_children_keyChi2 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi2 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi2.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
882
- //
884
+ //
883
885
  }
884
886
  }
885
887
  }
@@ -1130,13 +1132,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1130
1132
  * @param header 明细表内是否获取表头的控件
1131
1133
  */ _proto.getInstances = function getInstances(controlId) {
1132
1134
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1135
+ var cc = console;
1136
+ var label = "\uD83D\uDC11 genInstances " + controlId + " " + Date.now();
1137
+ cc.time(label);
1133
1138
  if (controlId === undefined) {
1139
+ cc.timeEnd(label);
1134
1140
  return this.runtime.flatInstances;
1135
1141
  }
1136
- var instances = this.runtime.flatInstances.filter(// @ts-ignore
1137
- function(item) {
1138
- return item.id === controlId;
1139
- });
1142
+ var instances = this.runtime.instanceMap[controlId] || [];
1140
1143
  if (header) {
1141
1144
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1142
1145
  if (instances.length) {
@@ -1173,6 +1176,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1173
1176
  }
1174
1177
  }
1175
1178
  }
1179
+ cc.timeEnd(label);
1176
1180
  return instances;
1177
1181
  };
1178
1182
  _proto.setInstance = function setInstance(instance, props, value, rowIndex) {
@@ -1327,3 +1331,4 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1327
1331
  return Engine;
1328
1332
  }(Watcher);
1329
1333
  export { Engine };
1334
+ console.log("a");
@@ -114,6 +114,10 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
114
114
  var instances = [];
115
115
  var instanceMap = {};
116
116
  loop(this._instance, function(item) {
117
+ // 3.4.1 避免将 subtable-column 放到 _flatInstances 中
118
+ if (item.type === "subtable-column") {
119
+ return;
120
+ }
117
121
  instances.push(item);
118
122
  if (!instanceMap[item.id]) {
119
123
  instanceMap[item.id] = [];
@@ -32,6 +32,7 @@ function _unsupportedIterableToArray(o, minLen) {
32
32
  }
33
33
  import { RuntimeFormControl } from "@byteluck-fe/model-driven-core";
34
34
  import { error, logerror } from "@byteluck-fe/model-driven-shared";
35
+ var cc = console;
35
36
  var proxyArrayApi = [
36
37
  "splice",
37
38
  "push",
@@ -221,15 +222,21 @@ function flatInstanceForChildren(controls) {
221
222
  * 在flatInstance中通过key查找出对应的instance
222
223
  * @param flatInstance 拍平的instance数组
223
224
  * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
224
- * */ export function findItem(flatInstance, key) {
225
+ * */ export function findItem(flatInstance, key, instanceMap) {
225
226
  if (key === "") return undefined;
226
227
  var keys = key.split(".");
227
228
  if (keys.length === 0) return undefined;
228
229
  var oneKey = keys[0];
229
230
  var otherKeys = keys.slice(1);
230
- var initInstance = flatInstance.find(function(item) {
231
- return item.id === oneKey;
232
- });
231
+ // 3.4.1 优化速度,读取instanceMap
232
+ // cc.time('findItem flatInstance find')
233
+ // const initInstance = flatInstance.find((item) => item.id === oneKey)
234
+ // cc.log('🏠 findItem flatInstance find result', initInstance)
235
+ // cc.timeEnd('findItem flatInstance find')
236
+ // cc.time('findItem instanceMap match')
237
+ var initInstance = instanceMap[oneKey] ? instanceMap[oneKey][0] : undefined;
238
+ // cc.log('🏠 findItem instanceMap match result', initInstance)
239
+ // cc.timeEnd('findItem instanceMap match')
233
240
  if (otherKeys.length === 0) return initInstance;
234
241
  // @ts-ignore
235
242
  return otherKeys.reduce(function(prevItem, key) {