@byteluck-fe/model-driven-engine 2.0.1 → 2.1.0-beta.0

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.
@@ -238,8 +238,102 @@ function _createSuper(Derived) {
238
238
  return _possibleConstructorReturn(this, result);
239
239
  };
240
240
  }
241
- import regeneratorRuntime from "regenerator-runtime";
242
- import { DataBind, ObjectDataBind, RuntimeFormControl, RuntimeLayoutControl, RuntimeListControl } from "@byteluck-fe/model-driven-core";
241
+ var __generator = this && this.__generator || function(thisArg, body) {
242
+ var f, y, t, g, _ = {
243
+ label: 0,
244
+ sent: function() {
245
+ if (t[0] & 1) throw t[1];
246
+ return t[1];
247
+ },
248
+ trys: [],
249
+ ops: []
250
+ };
251
+ return g = {
252
+ next: verb(0),
253
+ "throw": verb(1),
254
+ "return": verb(2)
255
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
256
+ return this;
257
+ }), g;
258
+ function verb(n) {
259
+ return function(v) {
260
+ return step([
261
+ n,
262
+ v
263
+ ]);
264
+ };
265
+ }
266
+ function step(op) {
267
+ if (f) throw new TypeError("Generator is already executing.");
268
+ while(_)try {
269
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
270
+ if (y = 0, t) op = [
271
+ op[0] & 2,
272
+ t.value
273
+ ];
274
+ switch(op[0]){
275
+ case 0:
276
+ case 1:
277
+ t = op;
278
+ break;
279
+ case 4:
280
+ _.label++;
281
+ return {
282
+ value: op[1],
283
+ done: false
284
+ };
285
+ case 5:
286
+ _.label++;
287
+ y = op[1];
288
+ op = [
289
+ 0
290
+ ];
291
+ continue;
292
+ case 7:
293
+ op = _.ops.pop();
294
+ _.trys.pop();
295
+ continue;
296
+ default:
297
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
298
+ _ = 0;
299
+ continue;
300
+ }
301
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
302
+ _.label = op[1];
303
+ break;
304
+ }
305
+ if (op[0] === 6 && _.label < t[1]) {
306
+ _.label = t[1];
307
+ t = op;
308
+ break;
309
+ }
310
+ if (t && _.label < t[2]) {
311
+ _.label = t[2];
312
+ _.ops.push(op);
313
+ break;
314
+ }
315
+ if (t[2]) _.ops.pop();
316
+ _.trys.pop();
317
+ continue;
318
+ }
319
+ op = body.call(thisArg, _);
320
+ } catch (e) {
321
+ op = [
322
+ 6,
323
+ e
324
+ ];
325
+ y = 0;
326
+ } finally{
327
+ f = t = 0;
328
+ }
329
+ if (op[0] & 5) throw op[1];
330
+ return {
331
+ value: op[0] ? op[1] : void 0,
332
+ done: true
333
+ };
334
+ }
335
+ };
336
+ import { DataBind, ObjectDataBind, RuntimeFormControl, RuntimeListControl } from "@byteluck-fe/model-driven-core";
243
337
  import { CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
244
338
  import { Runtime } from "./Runtime";
245
339
  import { Store } from "./Store";
@@ -247,6 +341,7 @@ import { findItem, proxyState } from "./proxyState";
247
341
  import { ActionManager } from "./ActionManager";
248
342
  import { DataManager } from "./DataManager";
249
343
  import { checkerSubtableValue, checkerValue } from "./checkerValue";
344
+ import { genSubTableRowInstanceFromHeaders } from "./SubTableSpeedUp";
250
345
  if (typeof window !== "undefined") {
251
346
  // @ts-ignore
252
347
  window.engines = {};
@@ -273,8 +368,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
273
368
  _this._jobTasks = [];
274
369
  _this.createControlInstance = _this.createInstance;
275
370
  _this.$options = Object.freeze(props);
276
- var _$options = _this.$options, _autoMount = _$options.autoMount, autoMount = _autoMount === void 0 ? true : _autoMount, schema = _$options.schema, beforeCreateInstance = _$options.beforeCreateInstance, externalParams = _$options.externalParams, _language = _$options.// fieldModel,
277
- language, language = _language === void 0 ? DEFAULT_LOCALE : _language, _debug = _$options.debug, debug = _debug === void 0 ? false : _debug;
371
+ 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,
372
+ 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;
278
373
  RulesMessage.setLocale(language);
279
374
  _this.debug = debug;
280
375
  _this.runtime = new Runtime({
@@ -308,13 +403,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
308
403
  for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
309
404
  arg[_key] = arguments[_key];
310
405
  }
311
- var _runtime;
312
- (_runtime = this.runtime).register.apply(_runtime, _toConsumableArray(arg));
406
+ var _this_runtime;
407
+ (_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
313
408
  return this;
314
409
  };
315
410
  _proto.mount = function mount() {
316
411
  this.debugLog("engine的mount方法开始调用");
317
- var _$options = this.$options, _plugins = _$options.plugins, plugins = _plugins === void 0 ? [] : _plugins;
412
+ var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
318
413
  this._handlerProxyState();
319
414
  this.__plugins = plugins;
320
415
  this.applyPlugins();
@@ -336,7 +431,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
336
431
  this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
337
432
  };
338
433
  _proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
339
- var _this = this;
340
434
  var instance = findItem(this.runtime.flatInstances, key);
341
435
  // 找不到控件说明不是改动控件上的字段,直接通过
342
436
  if (!instance) {
@@ -344,6 +438,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
344
438
  }
345
439
  // @ts-ignore
346
440
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
441
+ if (newValue === null) {
442
+ return [];
443
+ }
347
444
  // @ts-ignore
348
445
  var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
349
446
  var formInstance = column.children[0];
@@ -352,12 +449,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
352
449
  }
353
450
  return result;
354
451
  }, {});
355
- if (newValue === null) {
356
- return [];
357
- }
452
+ // @ts-ignore
453
+ var emptyState = this.getEmptyState(instance.id);
358
454
  return newValue.map(function(row) {
359
455
  return(// @ts-ignore
360
- checkerSubtableValue(fieldTypeMap, row, _this.getEmptyState(instance.id)));
456
+ checkerSubtableValue(fieldTypeMap, row, emptyState));
361
457
  });
362
458
  }
363
459
  var keys = key.split(".");
@@ -377,20 +473,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
377
473
  }
378
474
  };
379
475
  _proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
380
- var _this = this;
381
476
  var subtable = findItem(this.runtime.flatInstances, key);
382
477
  if (!_instanceof(subtable, RuntimeListControl)) return;
383
478
  // 新增多行方法
479
+ // JUTODO 这里已经直接删除了创建instance 的逻辑,或许以后连这个函数都不需要调用了
384
480
  var createRows = function(len) {
385
- // @ts-ignore
386
- var newRows = [];
387
- for(var i = 0; i < len; i++){
388
- // @ts-ignore
389
- var row = _this.listControlCreateRow(subtable, "subtable-row");
390
- row && newRows.push(row);
391
- }
392
- // @ts-ignore
393
- return newRows;
481
+ return [];
394
482
  };
395
483
  var options = eventOptionsTemp;
396
484
  // @ts-ignore
@@ -402,17 +490,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
402
490
  switch(type){
403
491
  case "push":
404
492
  case "unshift":
405
- var _children;
493
+ var _subtable_children;
406
494
  var newRowLengths = args.length;
407
495
  createdNewRows = createRows(newRowLengths);
408
496
  createdNewRowsData = args;
409
- (_children = subtable.children)[type].apply(_children, _toConsumableArray(createdNewRows));
497
+ (_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
410
498
  this.runtime.getFlatInstances();
411
499
  break;
412
500
  case "splice":
413
501
  if (args.length > 2) {
414
502
  var // @ts-ignore
415
- _children1;
503
+ _subtable_children1;
416
504
  var newRowLengths1 = args.length - 2;
417
505
  var newValues = args.slice(2);
418
506
  createdNewRows = createRows(newRowLengths1);
@@ -421,7 +509,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
421
509
  var start = args[0];
422
510
  // 替换几个
423
511
  var replace = args[1];
424
- (_children1 = subtable.children)[type].apply(_children1, [
512
+ (_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
425
513
  start,
426
514
  replace
427
515
  ].concat(_toConsumableArray(createdNewRows)));
@@ -432,15 +520,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
432
520
  // })
433
521
  } else {
434
522
  var // @ts-ignore
435
- _children2;
436
- (_children2 = subtable.children)[type].apply(_children2, _toConsumableArray(args));
523
+ _subtable_children2;
524
+ (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
437
525
  this.runtime.getFlatInstances();
438
526
  }
439
527
  break;
440
528
  default:
441
529
  var // @ts-ignore
442
- _children3;
443
- (_children3 = subtable.children)[type].apply(_children3, _toConsumableArray(args));
530
+ _subtable_children3;
531
+ (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
444
532
  this.runtime.getFlatInstances();
445
533
  break;
446
534
  }
@@ -475,19 +563,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
475
563
  var index = this.getInstanceRowIndex(instance);
476
564
  var options = eventOptionsTemp || {};
477
565
  if (_instanceof(instance, RuntimeListControl)) {
478
- var // @ts-ignore
479
- _children;
480
566
  instance.children.length = 0;
481
567
  var newValue = value;
482
568
  // @ts-ignore
483
569
  var newRows = [];
484
- for(var i = 0; i < newValue.length; i++){
485
- // @ts-ignore
486
- var row = this.listControlCreateRow(instance, "subtable-row");
487
- row && newRows.push(row);
488
- }
489
- (_children = instance.children).push.apply(_children, _toConsumableArray(newRows));
490
- this.runtime.getFlatInstances();
491
570
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
492
571
  // for (let i = 0; i < newValue.length; i++) {
493
572
  // this.setStates(newValue[i], i, options)
@@ -518,8 +597,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
518
597
  if (this.__pluginsApplied) return;
519
598
  this.__plugins.forEach(function(plugin) {
520
599
  try {
521
- var _pluginName;
522
- applyingPluginName = (_pluginName = plugin.pluginName) !== null && _pluginName !== void 0 ? _pluginName : plugin.constructor.name;
600
+ var _plugin_pluginName;
601
+ applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
523
602
  plugin.apply(_this);
524
603
  } catch (e) {
525
604
  error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
@@ -530,23 +609,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
530
609
  this.__pluginsApplied = true;
531
610
  };
532
611
  _proto.listControlCreateRow = function listControlCreateRow(instance, rowType) {
533
- var row = this.runtime.createControlInstance(rowType);
534
- if (!row) return;
535
- if (_instanceof(row, RuntimeLayoutControl)) {
536
- var _children;
537
- var template = JSONCopy(instance.props.headers);
538
- // @ts-ignore
539
- var columns = this.createControl(template);
540
- (_children = row.children).push.apply(_children, _toConsumableArray(columns));
541
- }
542
- return row;
612
+ throw new Error("该api已废弃");
543
613
  };
544
614
  _proto.listControlAddRow = function listControlAddRow(instance) {
545
615
  var // @ts-ignore
546
616
  rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
547
- var row = this.listControlCreateRow(instance, rowType);
548
- if (!row) return;
549
- instance.children.push(row);
617
+ // JUTODO 这似乎是个二开api
618
+ throw new Error("该api已废弃");
550
619
  };
551
620
  // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
552
621
  _proto.emit = function emit(eventKey, payload) {
@@ -554,37 +623,40 @@ var Engine = /*#__PURE__*/ function(Watcher) {
554
623
  var _this1 = this, _superprop_get_emit = function() {
555
624
  return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
556
625
  };
557
- return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
626
+ return _asyncToGenerator(function() {
558
627
  var needWait, promiseResolver, promise, results;
559
- return regeneratorRuntime.wrap(function _callee$(_ctx) {
560
- while(1)switch(_ctx.prev = _ctx.next){
628
+ return __generator(this, function(_state) {
629
+ switch(_state.label){
561
630
  case 0:
562
- if (!(eventKey === "engine-mounted")) {
563
- _ctx.next = 11;
564
- break;
565
- }
566
- if (!_this1.isMounted) {
567
- _ctx.next = 4;
568
- break;
569
- }
570
- warn("The engine-mounted life cycle can only be triggered once");
571
- return _ctx.abrupt("return", Promise.resolve([]));
572
- case 4:
573
- if (!_this1._jobTasks.length) {
574
- _ctx.next = 10;
575
- break;
631
+ if (!(eventKey === "engine-mounted")) return [
632
+ 3,
633
+ 3
634
+ ];
635
+ if (_this1.isMounted) {
636
+ warn("The engine-mounted life cycle can only be triggered once");
637
+ return [
638
+ 2,
639
+ Promise.resolve([])
640
+ ];
576
641
  }
642
+ if (!_this1._jobTasks.length) return [
643
+ 3,
644
+ 2
645
+ ];
577
646
  console.time("engine-mounted need wait");
578
647
  needWait = _toConsumableArray(_this1._jobTasks);
579
- _ctx.next = 9;
580
- return Promise.all(needWait);
581
- case 9:
648
+ return [
649
+ 4,
650
+ Promise.all(needWait)
651
+ ];
652
+ case 1:
653
+ _state.sent();
582
654
  console.timeEnd("engine-mounted need wait");
583
- case 10:
655
+ _state.label = 2;
656
+ case 2:
584
657
  _this1.isMounted = true;
585
- case 11:
586
- ;
587
- ;
658
+ _state.label = 3;
659
+ case 3:
588
660
  // 如果没有挂载的话,需要记录在挂载之前触发的所有任务
589
661
  if (!_this1.isMounted) {
590
662
  promise = new Promise(function(resolve) {
@@ -592,22 +664,24 @@ var Engine = /*#__PURE__*/ function(Watcher) {
592
664
  });
593
665
  _this1._jobTasks.push(promise);
594
666
  }
595
- _ctx.next = 16;
596
- return _superprop_get_emit().call(_this1, eventKey, payload);
597
- case 16:
598
- results = _ctx.sent;
667
+ return [
668
+ 4,
669
+ _superprop_get_emit().call(_this1, eventKey, payload)
670
+ ];
671
+ case 4:
672
+ results = _state.sent();
599
673
  if (promiseResolver && promise) {
600
674
  // 每一个任务完成的时候,都把自己从task中去掉
601
675
  promiseResolver();
602
676
  _this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
603
677
  }
604
- return _ctx.abrupt("return", results);
605
- case 19:
606
- case "end":
607
- return _ctx.stop();
678
+ return [
679
+ 2,
680
+ results
681
+ ];
608
682
  }
609
- }, _callee);
610
- }))();
683
+ });
684
+ })();
611
685
  };
612
686
  _proto.on = function on(key, callback) {
613
687
  if (applyingPluginName) {
@@ -619,8 +693,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
619
693
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
620
694
  args[_key] = arguments[_key];
621
695
  }
622
- var _runtime;
623
- return (_runtime = this.runtime).createControl.apply(_runtime, _toConsumableArray(args));
696
+ var _this_runtime;
697
+ return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
624
698
  };
625
699
  _proto.createInstance = function createInstance(type, initSchema) {
626
700
  return this.runtime.createControlInstance(type, initSchema);
@@ -635,16 +709,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
635
709
  if (controlId === undefined) {
636
710
  return this.runtime.rules;
637
711
  } else {
638
- var ref;
639
- return (ref = this.runtime.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
712
+ var _this_runtime_rules_controlId;
713
+ return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
640
714
  }
641
715
  };
642
716
  _proto.getAntdRules = function getAntdRules(controlId) {
643
717
  if (controlId === undefined) {
644
718
  return this.runtime.antdRules;
645
719
  } else {
646
- var ref;
647
- return (ref = this.runtime.antdRules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
720
+ var _this_runtime_antdRules_controlId;
721
+ return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
648
722
  }
649
723
  };
650
724
  _proto.getState = function getState(controlId, rowIndex) {
@@ -745,15 +819,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
745
819
  var data = getFieldData.map(function(item) {
746
820
  var obj = {};
747
821
  for(var key in item){
748
- var ref, ref1, ref2, ref3;
749
- if ((ref1 = (ref = controlIdMapping[controlId]) === null || ref === void 0 ? void 0 : ref.children[key]) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.dataBind) === null || ref2 === void 0 ? void 0 : ref2.fieldCode) {
750
- var ref4;
751
- obj[(ref4 = controlIdMapping[controlId].children[key]) === null || ref4 === void 0 ? void 0 : ref4.dataBind.fieldCode] = item[key];
752
- } else if ((ref3 = controlIdMapping[controlId]) === null || ref3 === void 0 ? void 0 : ref3.children[key]) {
822
+ var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId1;
823
+ if ((_controlIdMapping_controlId_children_key = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : _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) {
824
+ var _controlIdMapping_controlId_children_key1;
825
+ obj[(_controlIdMapping_controlId_children_key1 = controlIdMapping[controlId].children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind.fieldCode] = item[key];
826
+ } else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
753
827
  // 兼容一个控件需要绑定多个字段的情况
754
828
  for(var keyChi in item[key]){
755
- var ref5, ref6;
756
- obj[(ref6 = (ref5 = controlIdMapping[controlId]) === null || ref5 === void 0 ? void 0 : ref5.children[key]) === null || ref6 === void 0 ? void 0 : ref6.dataBind[keyChi].fieldCode] = item[key][keyChi];
829
+ var _controlIdMapping_controlId_children_key2, _controlIdMapping_controlId2;
830
+ obj[(_controlIdMapping_controlId_children_key2 = (_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key2 === void 0 ? void 0 : _controlIdMapping_controlId_children_key2.dataBind[keyChi].fieldCode] = item[key][keyChi];
757
831
  }
758
832
  }
759
833
  }
@@ -762,25 +836,25 @@ var Engine = /*#__PURE__*/ function(Watcher) {
762
836
  return data;
763
837
  } else {
764
838
  var _loop = function(key) {
765
- var ref, ref1, ref2, ref3;
766
- if ((ref = controlIdMapping[key]) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.fieldCode) {
767
- var ref4;
768
- obj[(ref4 = controlIdMapping[key]) === null || ref4 === void 0 ? void 0 : ref4.dataBind.fieldCode] = getFieldData[key];
769
- } else if ((ref2 = controlIdMapping[key]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.dataBind) === null || ref3 === void 0 ? void 0 : ref3.dataCode) {
770
- var ref5;
839
+ var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
840
+ if ((_controlIdMapping_key = controlIdMapping[key]) === null || _controlIdMapping_key === void 0 ? void 0 : (_controlIdMapping_key_dataBind = _controlIdMapping_key.dataBind) === null || _controlIdMapping_key_dataBind === void 0 ? void 0 : _controlIdMapping_key_dataBind.fieldCode) {
841
+ var _controlIdMapping_key2;
842
+ obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
843
+ } else if ((_controlIdMapping_key1 = controlIdMapping[key]) === null || _controlIdMapping_key1 === void 0 ? void 0 : (_controlIdMapping_key_dataBind1 = _controlIdMapping_key1.dataBind) === null || _controlIdMapping_key_dataBind1 === void 0 ? void 0 : _controlIdMapping_key_dataBind1.dataCode) {
844
+ var _controlIdMapping_key3;
771
845
  // 明细字表只循环一层明细子表未递归
772
- obj[(ref5 = controlIdMapping[key]) === null || ref5 === void 0 ? void 0 : ref5.dataBind.dataCode] = getFieldData[key].map(function(item) {
846
+ obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
773
847
  var objChi = {};
774
848
  for(var keyChi in item){
775
- var ref;
776
- if ((ref = controlIdMapping[key].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode) {
777
- var ref1;
778
- objChi[(ref1 = controlIdMapping[key].children[keyChi]) === null || ref1 === void 0 ? void 0 : ref1.dataBind.fieldCode] = item[keyChi];
849
+ var _controlIdMapping_key_children_keyChi;
850
+ if ((_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode) {
851
+ var _controlIdMapping_key_children_keyChi1;
852
+ objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind.fieldCode] = item[keyChi];
779
853
  } else {
780
854
  for(var keyChi1 in item[keyChi]){
781
- var ref2;
782
- objChi[(ref2 = controlIdMapping[key].children[keyChi]) === null || ref2 === void 0 ? void 0 : ref2.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
783
- //
855
+ var _controlIdMapping_key_children_keyChi2;
856
+ 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];
857
+ //
784
858
  }
785
859
  }
786
860
  }
@@ -789,8 +863,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
789
863
  } else if (controlIdMapping[key]) {
790
864
  // 兼容一个控件需要绑定多个字段的情况
791
865
  for(var keyChi in getFieldData[key]){
792
- var ref6, ref7;
793
- obj[(ref7 = (ref6 = controlIdMapping[key]) === null || ref6 === void 0 ? void 0 : ref6.dataBind[keyChi]) === null || ref7 === void 0 ? void 0 : ref7.fieldCode] = getFieldData[key][keyChi];
866
+ var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
867
+ obj[(_controlIdMapping_key_dataBind_keyChi = (_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
794
868
  }
795
869
  }
796
870
  };
@@ -816,8 +890,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
816
890
  }
817
891
  var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
818
892
  if (_instanceof(dataBind, ObjectDataBind)) {
819
- var ref;
820
- var oldState = (ref = JSONCopy(this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : this.getEmptyState(controlId);
893
+ var _JSONCopy;
894
+ var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
821
895
  // fieldCode不代表是key,所以需要找到对应的key
822
896
  var newState = Object.entries(dataBind).reduce(function(result, param) {
823
897
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
@@ -855,8 +929,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
855
929
  }
856
930
  // 对象类型的值
857
931
  if (_instanceof(dataBind, ObjectDataBind)) {
858
- var ref;
859
- var oldState = (ref = JSONCopy(_this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : _this.getEmptyState(controlId);
932
+ var _JSONCopy;
933
+ var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
860
934
  // fieldCode不代表是key,所以需要找到对应的key
861
935
  var newState = Object.entries(dataBind).reduce(function(result, param) {
862
936
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
@@ -934,19 +1008,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
934
1008
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
935
1009
  ;
936
1010
  Object.keys(row).map(function(fieldCode) {
937
- var ref, ref1;
1011
+ var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
938
1012
  if (skipKey.includes(fieldCode)) {
939
1013
  return;
940
1014
  }
941
- var fieldMapping = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (ref1 = ref.fields) === null || ref1 === void 0 ? void 0 : ref1.find(function(i) {
1015
+ var fieldMapping = (_this_store_dataBindMapping_dataCode = _this.store.dataBindMapping[dataCode]) === null || _this_store_dataBindMapping_dataCode === void 0 ? void 0 : (_this_store_dataBindMapping_dataCode_fields = _this_store_dataBindMapping_dataCode.fields) === null || _this_store_dataBindMapping_dataCode_fields === void 0 ? void 0 : _this_store_dataBindMapping_dataCode_fields.find(function(i) {
942
1016
  return i.fieldCode === fieldCode;
943
1017
  });
944
1018
  if (fieldMapping) {
945
1019
  if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
946
1020
  newRow[fieldMapping.controlId] = row[fieldCode];
947
1021
  } else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
948
- var ref2;
949
- var objValue = JSONCopy((ref2 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref2 !== void 0 ? ref2 : {});
1022
+ var _this_getEmptyState;
1023
+ var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
950
1024
  Object.keys(fieldMapping.dataBind).map(function(key) {
951
1025
  var dataBind = fieldMapping.dataBind[key];
952
1026
  if (row[dataBind.fieldCode] !== undefined) {
@@ -981,8 +1055,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
981
1055
  if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
982
1056
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode];
983
1057
  } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
984
- var ref;
985
- var objValue = JSONCopy((ref = _this.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {});
1058
+ var _this_getEmptyState;
1059
+ var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
986
1060
  Object.keys(mapping.dataBind).map(function(key) {
987
1061
  var dataBind = mapping.dataBind[key];
988
1062
  if (entity[dataBind.fieldCode] !== undefined) {
@@ -1050,11 +1124,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1050
1124
  }
1051
1125
  } else {
1052
1126
  var controlIdMapping = this.getControlIdMapping();
1053
- var ref;
1054
- var ref1 = _slicedToArray((ref = Object.entries(controlIdMapping).find(function(param) {
1127
+ var _Object_entries_find;
1128
+ var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1055
1129
  var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
1056
1130
  return mapping.children && controlId in mapping.children;
1057
- })) !== null && ref !== void 0 ? ref : [], 1), subtableId = ref1[0];
1131
+ })) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
1058
1132
  if (subtableId) {
1059
1133
  var subtable = this.getInstance(subtableId);
1060
1134
  // @ts-ignore
@@ -1208,12 +1282,33 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1208
1282
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1209
1283
  args[_key] = arguments[_key];
1210
1284
  }
1211
- var _runtime;
1212
- return (_runtime = this.runtime).registerControlConfig.apply(_runtime, _toConsumableArray(args));
1285
+ var _this_runtime;
1286
+ return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
1213
1287
  };
1214
1288
  _proto.getControlConfig = function getControlConfig(control) {
1215
1289
  return this.runtime.getControlConfig(control);
1216
1290
  };
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
+ };
1217
1312
  // 注册外部控件
1218
1313
  Engine.register = function register() {
1219
1314
  for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
@@ -18,12 +18,12 @@ var OkWorker = /*#__PURE__*/ function() {
18
18
  });
19
19
  };
20
20
  _proto.destroy = function destroy() {
21
- var ref;
22
- (ref = this.worker) === null || ref === void 0 ? void 0 : ref.terminate();
21
+ var _this_worker;
22
+ (_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.terminate();
23
23
  };
24
24
  _proto.postMessage = function postMessage(message) {
25
- var ref;
26
- (ref = this.worker) === null || ref === void 0 ? void 0 : ref.postMessage(message);
25
+ var _this_worker;
26
+ (_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.postMessage(message);
27
27
  };
28
28
  OkWorker.createWorker = function createWorker() {
29
29
  var blob = new Blob([
@@ -64,7 +64,7 @@ var OkWorker = /*#__PURE__*/ function() {
64
64
  // return new Proxy(obj, createHandler(parentKey))
65
65
  // }
66
66
  _self.addEventListener("message", function(event) {
67
- var _data = event.data, action = _data.action, payload = _data.payload, fn = _data.fn;
67
+ var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
68
68
  log(action, payload);
69
69
  // 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
70
70
  // data.key1 = 1