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

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.
@@ -430,16 +430,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
430
430
  this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
431
431
  };
432
432
  _proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
433
- var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
433
+ var _this = this;
434
+ var instance = findItem(this.runtime.flatInstances, key);
434
435
  // 找不到控件说明不是改动控件上的字段,直接通过
435
436
  if (!instance) {
436
437
  return newValue;
437
438
  }
438
439
  // @ts-ignore
439
440
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
440
- if (newValue === null) {
441
- return [];
442
- }
443
441
  // @ts-ignore
444
442
  var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
445
443
  var formInstance = column.children[0];
@@ -448,11 +446,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
448
446
  }
449
447
  return result;
450
448
  }, {});
451
- // @ts-ignore
452
- var emptyState = this.getEmptyState(instance.id);
449
+ if (newValue === null) {
450
+ return [];
451
+ }
453
452
  return newValue.map(function(row) {
454
453
  return(// @ts-ignore
455
- checkerSubtableValue(fieldTypeMap, row, emptyState));
454
+ checkerSubtableValue(fieldTypeMap, row, _this.getEmptyState(instance.id)));
456
455
  });
457
456
  }
458
457
  var keys = key.split(".");
@@ -473,7 +472,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
473
472
  };
474
473
  _proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
475
474
  var _this = this;
476
- var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
475
+ var subtable = findItem(this.runtime.flatInstances, key);
477
476
  if (!_instanceof(subtable, RuntimeListControl)) return;
478
477
  // 新增多行方法
479
478
  var createRows = function(len) {
@@ -563,7 +562,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
563
562
  }
564
563
  };
565
564
  _proto._handlerObjectUpdate = function _handlerObjectUpdate(state, key, value, oldValue) {
566
- var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
565
+ var instance = findItem(this.runtime.flatInstances, key);
567
566
  if (!instance) {
568
567
  return;
569
568
  }
@@ -880,7 +879,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
880
879
  for(var keyChi1 in item[keyChi]){
881
880
  var _controlIdMapping_key_children_keyChi2;
882
881
  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];
883
- //
882
+ //
884
883
  }
885
884
  }
886
885
  }
@@ -1131,22 +1130,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1131
1130
  * @param header 明细表内是否获取表头的控件
1132
1131
  */ _proto.getInstances = function getInstances(controlId) {
1133
1132
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1134
- var cc = console;
1135
- var label = "\uD83D\uDC11 genInstances " + controlId + " " + Date.now();
1136
- cc.time(label);
1137
1133
  if (controlId === undefined) {
1138
- cc.timeEnd(label);
1139
1134
  return this.runtime.flatInstances;
1140
1135
  }
1141
- var instances = this.runtime.flatInstances.filter(// @ts-ignore
1142
- function(item) {
1136
+ var instances = this.runtime.flatInstances.filter(function(item) {
1143
1137
  return item.id === controlId;
1144
1138
  });
1145
1139
  if (header) {
1146
1140
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1147
1141
  if (instances.length) {
1148
1142
  var instance = instances[0];
1149
- if (this.getInstanceRowIndex(instance) !== undefined) {
1143
+ if (this.inList(instance.id) === true) {
1150
1144
  var headerInstance = this.getInstanceInSubtableHeader(instance);
1151
1145
  if (headerInstance) {
1152
1146
  instances.unshift(headerInstance);
@@ -1178,7 +1172,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1178
1172
  }
1179
1173
  }
1180
1174
  }
1181
- cc.timeEnd(label);
1175
+ // @ts-ignore
1182
1176
  return instances;
1183
1177
  };
1184
1178
  _proto.setInstance = function setInstance(instance, props, value, rowIndex) {
@@ -1319,6 +1313,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1319
1313
  _proto.getControlConfig = function getControlConfig(control) {
1320
1314
  return this.runtime.getControlConfig(control);
1321
1315
  };
1316
+ _proto.inList = function inList(controlId) {
1317
+ var mapping = this.store.controlIdMapping;
1318
+ var result = Object.keys(mapping).some(function(key) {
1319
+ var _mapping_key, _mapping_key_children;
1320
+ return (_mapping_key = mapping[key]) === null || _mapping_key === void 0 ? void 0 : (_mapping_key_children = _mapping_key.children) === null || _mapping_key_children === void 0 ? void 0 : _mapping_key_children.hasOwnProperty(controlId);
1321
+ });
1322
+ return result;
1323
+ };
1322
1324
  // 注册外部控件
1323
1325
  Engine.register = function register() {
1324
1326
  for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
@@ -1333,4 +1335,3 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1333
1335
  return Engine;
1334
1336
  }(Watcher);
1335
1337
  export { Engine };
1336
- console.log("a");
@@ -114,10 +114,6 @@ 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
- }
121
117
  instances.push(item);
122
118
  if (!instanceMap[item.id]) {
123
119
  instanceMap[item.id] = [];
@@ -32,7 +32,6 @@ 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;
36
35
  var proxyArrayApi = [
37
36
  "splice",
38
37
  "push",
@@ -222,21 +221,15 @@ function flatInstanceForChildren(controls) {
222
221
  * 在flatInstance中通过key查找出对应的instance
223
222
  * @param flatInstance 拍平的instance数组
224
223
  * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
225
- * */ export function findItem(flatInstance, key, instanceMap) {
224
+ * */ export function findItem(flatInstance, key) {
226
225
  if (key === "") return undefined;
227
226
  var keys = key.split(".");
228
227
  if (keys.length === 0) return undefined;
229
228
  var oneKey = keys[0];
230
229
  var otherKeys = keys.slice(1);
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][0];
238
- // cc.log('🏠 findItem instanceMap match result', initInstance)
239
- // cc.timeEnd('findItem instanceMap match')
230
+ var initInstance = flatInstance.find(function(item) {
231
+ return item.id === oneKey;
232
+ });
240
233
  if (otherKeys.length === 0) return initInstance;
241
234
  // @ts-ignore
242
235
  return otherKeys.reduce(function(prevItem, key) {
@@ -14,15 +14,12 @@ export function loopFormControl(control, callback) {
14
14
  if (Array.isArray(control)) {
15
15
  control.map(function(item) {
16
16
  //TODO 此处需要再抽象一层 datagrid/datalist
17
- // @ts-ignore
18
17
  if (item.type === CONTROL_TYPE.SUBTABLE) {
19
18
  // @ts-ignore
20
19
  var children = item.getChildrenFormControl();
21
20
  callback(item, children);
22
21
  } else if (hasChildrenControl(item)) {
23
- // @ts-ignore
24
22
  loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
25
- // @ts-ignore
26
23
  } else if (_instanceof(item, RuntimeFormControl)) {
27
24
  callback(item);
28
25
  }
@@ -33,9 +30,7 @@ export function loopDataViewControl(control, // @ts-ignore
33
30
  callback) {
34
31
  if (Array.isArray(control)) {
35
32
  control.map(function(item) {
36
- if (// @ts-ignore
37
- item.type === CONTROL_TYPE.DATA_VIEW || // @ts-ignore
38
- item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
33
+ if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
39
34
  callback(item);
40
35
  } else if (hasChildrenControl(item)) {
41
36
  // @ts-ignore