@byteluck-fe/model-driven-engine 2.7.0-alpha.15a → 2.7.0-alpha.17

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.
@@ -159,6 +159,30 @@ function _objectSpread(target) {
159
159
  }
160
160
  return target;
161
161
  }
162
+ function ownKeys(object, enumerableOnly) {
163
+ var keys = Object.keys(object);
164
+ if (Object.getOwnPropertySymbols) {
165
+ var symbols = Object.getOwnPropertySymbols(object);
166
+ if (enumerableOnly) {
167
+ symbols = symbols.filter(function(sym) {
168
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
169
+ });
170
+ }
171
+ keys.push.apply(keys, symbols);
172
+ }
173
+ return keys;
174
+ }
175
+ function _objectSpreadProps(target, source) {
176
+ source = source != null ? source : {};
177
+ if (Object.getOwnPropertyDescriptors) {
178
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
179
+ } else {
180
+ ownKeys(Object(source)).forEach(function(key) {
181
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
182
+ });
183
+ }
184
+ return target;
185
+ }
162
186
  function _possibleConstructorReturn(self, call) {
163
187
  if (call && (_typeof(call) === "object" || typeof call === "function")) {
164
188
  return call;
@@ -221,44 +245,147 @@ function _createSuper(Derived) {
221
245
  return _possibleConstructorReturn(this, result);
222
246
  };
223
247
  }
224
- import regeneratorRuntime from "regenerator-runtime";
225
- import { isDataBind } from '@byteluck-fe/model-driven-core';
226
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from '@byteluck-fe/model-driven-shared';
227
- import { Runtime } from './Runtime';
228
- import { Store } from './Store';
229
- import { findItem, proxyState } from './proxyState';
230
- import { ActionManager } from './ActionManager';
231
- import { DataManager } from './DataManager';
232
- import { checkerSubtableValue, checkerValue } from './checkerValue';
233
- if (typeof window !== 'undefined') {
248
+ var __generator = this && this.__generator || function(thisArg, body) {
249
+ var f, y, t, g, _ = {
250
+ label: 0,
251
+ sent: function() {
252
+ if (t[0] & 1) throw t[1];
253
+ return t[1];
254
+ },
255
+ trys: [],
256
+ ops: []
257
+ };
258
+ return g = {
259
+ next: verb(0),
260
+ "throw": verb(1),
261
+ "return": verb(2)
262
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
263
+ return this;
264
+ }), g;
265
+ function verb(n) {
266
+ return function(v) {
267
+ return step([
268
+ n,
269
+ v
270
+ ]);
271
+ };
272
+ }
273
+ function step(op) {
274
+ if (f) throw new TypeError("Generator is already executing.");
275
+ while(_)try {
276
+ 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;
277
+ if (y = 0, t) op = [
278
+ op[0] & 2,
279
+ t.value
280
+ ];
281
+ switch(op[0]){
282
+ case 0:
283
+ case 1:
284
+ t = op;
285
+ break;
286
+ case 4:
287
+ _.label++;
288
+ return {
289
+ value: op[1],
290
+ done: false
291
+ };
292
+ case 5:
293
+ _.label++;
294
+ y = op[1];
295
+ op = [
296
+ 0
297
+ ];
298
+ continue;
299
+ case 7:
300
+ op = _.ops.pop();
301
+ _.trys.pop();
302
+ continue;
303
+ default:
304
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
305
+ _ = 0;
306
+ continue;
307
+ }
308
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
309
+ _.label = op[1];
310
+ break;
311
+ }
312
+ if (op[0] === 6 && _.label < t[1]) {
313
+ _.label = t[1];
314
+ t = op;
315
+ break;
316
+ }
317
+ if (t && _.label < t[2]) {
318
+ _.label = t[2];
319
+ _.ops.push(op);
320
+ break;
321
+ }
322
+ if (t[2]) _.ops.pop();
323
+ _.trys.pop();
324
+ continue;
325
+ }
326
+ op = body.call(thisArg, _);
327
+ } catch (e) {
328
+ op = [
329
+ 6,
330
+ e
331
+ ];
332
+ y = 0;
333
+ } finally{
334
+ f = t = 0;
335
+ }
336
+ if (op[0] & 5) throw op[1];
337
+ return {
338
+ value: op[0] ? op[1] : void 0,
339
+ done: true
340
+ };
341
+ }
342
+ };
343
+ import { isDataBind } from "@byteluck-fe/model-driven-core";
344
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
345
+ import { Runtime } from "./Runtime";
346
+ import { Store } from "./Store";
347
+ import { findItem, proxyState } from "./proxyState";
348
+ import { ActionManager } from "./ActionManager";
349
+ import { DataManager } from "./DataManager";
350
+ import { checkerSubtableValue, checkerValue } from "./checkerValue";
351
+ if (typeof window !== "undefined") {
234
352
  // @ts-ignore
235
353
  window.engines = {};
236
354
  }
237
355
  // setState的时候,存储options中转变量
238
356
  var eventOptionsTemp = null;
239
357
  // 当前正在注册的插件名称
240
- var applyingPluginName = '';
241
- var Engine = // 整体渲染引擎 并且 提供发布订阅能力
242
- /*#__PURE__*/ function(Watcher1) {
358
+ var applyingPluginName = "";
359
+ // 整体渲染引擎 并且 提供发布订阅能力
360
+ var Engine = /*#__PURE__*/ function(Watcher) {
243
361
  "use strict";
244
- _inherits(Engine, Watcher1);
362
+ _inherits(Engine, Watcher);
245
363
  var _super = _createSuper(Engine);
246
364
  function Engine(props) {
247
365
  _classCallCheck(this, Engine);
248
366
  var _this;
249
367
  _this = _super.call(this);
250
- _this.rawStore = {};
368
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
369
+ _defineProperty(_assertThisInitialized(_this), "rawStore", {});
370
+ _defineProperty(_assertThisInitialized(_this), "parent", void 0);
371
+ // 提供注册运行态控件以及实例化控件的能力
372
+ _defineProperty(_assertThisInitialized(_this), "runtime", void 0);
251
373
  // 提供子线程处理脚本以及修改数据的能力
252
374
  // public worker: OkWorker
253
- _this.isMounted = false;
254
- _this.id = genNonDuplicateId(8);
255
- _this.__pluginsApplied = false;
256
- _this.actionManager = new ActionManager();
257
- _this._jobTasks = [];
258
- _this.createControlInstance = _this.createInstance;
375
+ _defineProperty(_assertThisInitialized(_this), "isMounted", false);
376
+ _defineProperty(_assertThisInitialized(_this), "id", genNonDuplicateId(8));
377
+ _defineProperty(_assertThisInitialized(_this), "externalParams", void 0);
378
+ // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
379
+ _defineProperty(_assertThisInitialized(_this), "__plugins", void 0);
380
+ _defineProperty(_assertThisInitialized(_this), "__pluginsApplied", false);
381
+ _defineProperty(_assertThisInitialized(_this), "$options", void 0);
382
+ _defineProperty(_assertThisInitialized(_this), "actionManager", new ActionManager());
383
+ _defineProperty(_assertThisInitialized(_this), "dataManager", void 0);
384
+ _defineProperty(_assertThisInitialized(_this), "_jobTasks", []);
385
+ _defineProperty(_assertThisInitialized(_this), "createControlInstance", _this.createInstance);
259
386
  _this.$options = Object.freeze(props);
260
- 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,
261
- language, language = _language === void 0 ? DEFAULT_LOCALE : _language, _debug = _$options.debug, debug = _debug === void 0 ? false : _debug;
387
+ 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,
388
+ 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;
262
389
  RulesMessage.setLocale(language);
263
390
  _this.debug = debug;
264
391
  _this.runtime = new Runtime({
@@ -269,7 +396,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
269
396
  _this.store = new Store({
270
397
  instance: _this.runtime.instance
271
398
  });
272
- _this.debugLog('engine is Instantiation complete');
399
+ _this.debugLog("engine is Instantiation complete");
273
400
  // 自动执行挂载完成,也可以手动调用mount方法
274
401
  autoMount && _this.mount();
275
402
  return _this;
@@ -300,8 +427,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
300
427
  for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
301
428
  arg[_key] = arguments[_key];
302
429
  }
303
- var _runtime;
304
- (_runtime = this.runtime).register.apply(_runtime, _toConsumableArray(arg));
430
+ var _this_runtime;
431
+ (_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
305
432
  return this;
306
433
  }
307
434
  },
@@ -309,14 +436,14 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
309
436
  key: "mount",
310
437
  value: function mount() {
311
438
  this.debugLog("engine的mount方法开始调用");
312
- var _$options = this.$options, _plugins = _$options.plugins, plugins = _plugins === void 0 ? [] : _plugins;
439
+ var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
313
440
  this._handlerProxyState();
314
441
  this.__plugins = plugins;
315
442
  this.applyPlugins();
316
443
  // 触发所有控件的默认值的change事件
317
444
  this.setStates(this.getState());
318
445
  this.debugLog("engine的mount方法调用结束");
319
- if (this.debug && typeof window !== 'undefined') {
446
+ if (this.debug && typeof window !== "undefined") {
320
447
  // @ts-ignore
321
448
  window.engines[this.id] = this;
322
449
  }
@@ -325,7 +452,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
325
452
  {
326
453
  key: "destroy",
327
454
  value: function destroy() {
328
- if (this.debug && typeof window !== 'undefined') {
455
+ if (this.debug && typeof window !== "undefined") {
329
456
  // @ts-ignore
330
457
  delete window.engines[this.id];
331
458
  }
@@ -347,7 +474,6 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
347
474
  }
348
475
  // @ts-ignore
349
476
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
350
- var ref;
351
477
  if (newValue === null) {
352
478
  return [];
353
479
  }
@@ -362,12 +488,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
362
488
  }, {});
363
489
  // @ts-ignore
364
490
  var emptyState = this.getEmptyState(instance.id);
365
- return (ref = newValue) === null || ref === void 0 ? void 0 : ref.map(function(row) {
366
- // @ts-ignore
367
- return checkerSubtableValue(fieldTypeMap, row, emptyState);
491
+ return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
492
+ return(// @ts-ignore
493
+ checkerSubtableValue(fieldTypeMap, row, emptyState));
368
494
  });
369
495
  }
370
- var keys = key.split('.');
496
+ var keys = key.split(".");
371
497
  var lastKey = keys[keys.length - 1];
372
498
  try {
373
499
  return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
@@ -400,7 +526,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
400
526
  var newRows = [];
401
527
  for(var i = 0; i < len; i++){
402
528
  // @ts-ignore
403
- var row = _this.listControlCreateRow(subtable, 'subtable-row');
529
+ var row = _this.listControlCreateRow(subtable, "subtable-row");
404
530
  row && newRows.push(row);
405
531
  }
406
532
  // @ts-ignore
@@ -415,19 +541,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
415
541
  if (type && args) {
416
542
  // const subtableOldLength = subtable.children.length
417
543
  switch(type){
418
- case 'push':
419
- case 'unshift':
420
- var _children;
544
+ case "push":
545
+ case "unshift":
546
+ var _subtable_children;
421
547
  var newRowLengths = args.length;
422
548
  createdNewRows = createRows(newRowLengths);
423
549
  createdNewRowsData = args;
424
- (_children = subtable.children)[type].apply(_children, _toConsumableArray(createdNewRows));
550
+ (_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
425
551
  this.runtime.getFlatInstances();
426
552
  break;
427
- case 'splice':
553
+ case "splice":
428
554
  if (args.length > 2) {
429
555
  var // @ts-ignore
430
- _children1;
556
+ _subtable_children1;
431
557
  var newRowLengths1 = args.length - 2;
432
558
  var newValues = args.slice(2);
433
559
  createdNewRows = createRows(newRowLengths1);
@@ -436,7 +562,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
436
562
  var start = args[0];
437
563
  // 替换几个
438
564
  var replace = args[1];
439
- (_children1 = subtable.children)[type].apply(_children1, [
565
+ (_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
440
566
  start,
441
567
  replace
442
568
  ].concat(_toConsumableArray(createdNewRows)));
@@ -447,7 +573,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
447
573
  // })
448
574
  } else {
449
575
  var // @ts-ignore
450
- _children2;
576
+ _subtable_children2;
451
577
  // 从哪儿开始
452
578
  var start1 = args[0];
453
579
  // 替换几个
@@ -455,28 +581,28 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
455
581
  if (start1 + replace1 === subtable.children.length - 1) {
456
582
  isDeleteLastOne = true;
457
583
  }
458
- (_children2 = subtable.children)[type].apply(_children2, _toConsumableArray(args));
584
+ (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
459
585
  this.runtime.getFlatInstances();
460
586
  }
461
587
  break;
462
588
  default:
463
589
  var // @ts-ignore
464
- _children3;
465
- (_children3 = subtable.children)[type].apply(_children3, _toConsumableArray(args));
590
+ _subtable_children3;
591
+ (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
466
592
  this.runtime.getFlatInstances();
467
593
  break;
468
594
  }
469
- if (type === 'splice') {
595
+ if (type === "splice") {
470
596
  deleted = result;
471
597
  } else if ([
472
- 'pop',
473
- 'shift'
598
+ "pop",
599
+ "shift"
474
600
  ].includes(type)) {
475
601
  deleted = [
476
602
  result
477
603
  ];
478
604
  }
479
- this.emit('list-change', {
605
+ this.emit("list-change", {
480
606
  instance: subtable,
481
607
  value: this.getState(subtable.id),
482
608
  options: Object.assign({}, options, {
@@ -504,26 +630,26 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
504
630
  // if (instance instanceof RuntimeListControl) {
505
631
  if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
506
632
  var // @ts-ignore
507
- _children;
633
+ _instance_children;
508
634
  instance.children.length = 0;
509
635
  var newValue = value;
510
636
  // @ts-ignore
511
637
  var newRows = [];
512
638
  for(var i = 0; i < newValue.length; i++){
513
639
  // @ts-ignore
514
- var row = this.listControlCreateRow(instance, 'subtable-row');
640
+ var row = this.listControlCreateRow(instance, "subtable-row");
515
641
  row && newRows.push(row);
516
642
  }
517
- (_children = instance.children).push.apply(_children, _toConsumableArray(newRows));
643
+ (_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
518
644
  this.runtime.getFlatInstances();
519
645
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
520
646
  // for (let i = 0; i < newValue.length; i++) {
521
647
  // this.setStates(newValue[i], i, options)
522
648
  // }
523
- this.emit('list-change', {
649
+ this.emit("list-change", {
524
650
  instance: instance,
525
651
  value: value,
526
- options: _objectSpread({}, options, {
652
+ options: _objectSpreadProps(_objectSpread({}, options), {
527
653
  // @ts-ignore
528
654
  changed: newRows,
529
655
  data: newValue,
@@ -531,11 +657,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
531
657
  })
532
658
  });
533
659
  } else {
534
- this.emit('change', {
660
+ this.emit("change", {
535
661
  instance: instance,
536
662
  value: this.getState(instance.id, index),
537
663
  rowIndex: index,
538
- options: _objectSpread({}, options, {
664
+ options: _objectSpreadProps(_objectSpread({}, options), {
539
665
  oldValue: oldValue
540
666
  })
541
667
  });
@@ -549,13 +675,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
549
675
  if (this.__pluginsApplied) return;
550
676
  this.__plugins.forEach(function(plugin) {
551
677
  try {
552
- var _pluginName;
553
- applyingPluginName = (_pluginName = plugin.pluginName) !== null && _pluginName !== void 0 ? _pluginName : plugin.constructor.name;
678
+ var _plugin_pluginName;
679
+ applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
554
680
  plugin.apply(_this);
555
681
  } catch (e) {
556
682
  error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
557
683
  } finally{
558
- applyingPluginName = '';
684
+ applyingPluginName = "";
559
685
  }
560
686
  });
561
687
  this.__pluginsApplied = true;
@@ -569,12 +695,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
569
695
  // if (row instanceof RuntimeLayoutControl) {
570
696
  // @ts-ignore
571
697
  if (row.controlType === CONTROL_BASE_TYPE.LAYOUT) {
572
- var _children;
698
+ var _inst_children;
573
699
  var inst = row;
574
700
  var template = JSONCopy(instance.props.headers);
575
701
  // @ts-ignore
576
702
  var columns = this.createControl(template);
577
- (_children = inst.children).push.apply(_children, _toConsumableArray(columns));
703
+ (_inst_children = inst.children).push.apply(_inst_children, _toConsumableArray(columns));
578
704
  }
579
705
  return row;
580
706
  }
@@ -583,7 +709,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
583
709
  key: "listControlAddRow",
584
710
  value: function listControlAddRow(instance) {
585
711
  var // @ts-ignore
586
- rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
712
+ rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
587
713
  var row = this.listControlCreateRow(instance, rowType);
588
714
  if (!row) return;
589
715
  instance.children.push(row);
@@ -597,37 +723,40 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
597
723
  var _this1 = this, _superprop_get_emit = function() {
598
724
  return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
599
725
  };
600
- return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
726
+ return _asyncToGenerator(function() {
601
727
  var needWait, promiseResolver, promise, results;
602
- return regeneratorRuntime.wrap(function _callee$(_ctx) {
603
- while(1)switch(_ctx.prev = _ctx.next){
728
+ return __generator(this, function(_state) {
729
+ switch(_state.label){
604
730
  case 0:
605
- if (!(eventKey === 'engine-mounted')) {
606
- _ctx.next = 11;
607
- break;
608
- }
609
- if (!_this1.isMounted) {
610
- _ctx.next = 4;
611
- break;
612
- }
613
- warn('The engine-mounted life cycle can only be triggered once');
614
- return _ctx.abrupt("return", Promise.resolve([]));
615
- case 4:
616
- if (!_this1._jobTasks.length) {
617
- _ctx.next = 10;
618
- break;
731
+ if (!(eventKey === "engine-mounted")) return [
732
+ 3,
733
+ 3
734
+ ];
735
+ if (_this1.isMounted) {
736
+ warn("The engine-mounted life cycle can only be triggered once");
737
+ return [
738
+ 2,
739
+ Promise.resolve([])
740
+ ];
619
741
  }
620
- console.time('engine-mounted need wait');
742
+ if (!_this1._jobTasks.length) return [
743
+ 3,
744
+ 2
745
+ ];
746
+ console.time("engine-mounted need wait");
621
747
  needWait = _toConsumableArray(_this1._jobTasks);
622
- _ctx.next = 9;
623
- return Promise.all(needWait);
624
- case 9:
625
- console.timeEnd('engine-mounted need wait');
626
- case 10:
748
+ return [
749
+ 4,
750
+ Promise.all(needWait)
751
+ ];
752
+ case 1:
753
+ _state.sent();
754
+ console.timeEnd("engine-mounted need wait");
755
+ _state.label = 2;
756
+ case 2:
627
757
  _this1.isMounted = true;
628
- case 11:
629
- ;
630
- ;
758
+ _state.label = 3;
759
+ case 3:
631
760
  // 如果没有挂载的话,需要记录在挂载之前触发的所有任务
632
761
  if (!_this1.isMounted) {
633
762
  promise = new Promise(function(resolve) {
@@ -635,22 +764,24 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
635
764
  });
636
765
  _this1._jobTasks.push(promise);
637
766
  }
638
- _ctx.next = 16;
639
- return _superprop_get_emit().call(_this1, eventKey, payload);
640
- case 16:
641
- results = _ctx.sent;
767
+ return [
768
+ 4,
769
+ _superprop_get_emit().call(_this1, eventKey, payload)
770
+ ];
771
+ case 4:
772
+ results = _state.sent();
642
773
  if (promiseResolver && promise) {
643
774
  // 每一个任务完成的时候,都把自己从task中去掉
644
775
  promiseResolver();
645
776
  _this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
646
777
  }
647
- return _ctx.abrupt("return", results);
648
- case 19:
649
- case "end":
650
- return _ctx.stop();
778
+ return [
779
+ 2,
780
+ results
781
+ ];
651
782
  }
652
- }, _callee);
653
- }))();
783
+ });
784
+ })();
654
785
  }
655
786
  },
656
787
  {
@@ -668,8 +799,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
668
799
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
669
800
  args[_key] = arguments[_key];
670
801
  }
671
- var _runtime;
672
- return (_runtime = this.runtime).createControl.apply(_runtime, _toConsumableArray(args));
802
+ var _this_runtime;
803
+ return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
673
804
  }
674
805
  },
675
806
  {
@@ -690,12 +821,6 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
690
821
  return this.setInstance(instance, props, value, rowIndex);
691
822
  }
692
823
  },
693
- {
694
- key: "getRule",
695
- value: function getRule(controlType, props) {
696
- return Runtime.staticGetRules(controlType, props);
697
- }
698
- },
699
824
  {
700
825
  key: "getAllRules",
701
826
  value: function getAllRules(controlId) {
@@ -703,10 +828,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
703
828
  if (controlId === undefined) {
704
829
  return rules;
705
830
  } else {
706
- var ref, ref1;
831
+ var _rules_rules_controlId, _rules_antdRules_controlId;
707
832
  return {
708
- rules: (ref = rules.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields,
709
- antdRules: (ref1 = rules.antdRules[controlId]) === null || ref1 === void 0 ? void 0 : ref1.fields
833
+ rules: (_rules_rules_controlId = rules.rules[controlId]) === null || _rules_rules_controlId === void 0 ? void 0 : _rules_rules_controlId.fields,
834
+ antdRules: (_rules_antdRules_controlId = rules.antdRules[controlId]) === null || _rules_antdRules_controlId === void 0 ? void 0 : _rules_antdRules_controlId.fields
710
835
  };
711
836
  }
712
837
  }
@@ -717,8 +842,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
717
842
  if (controlId === undefined) {
718
843
  return this.runtime.rules;
719
844
  } else {
720
- var ref;
721
- return (ref = this.runtime.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
845
+ var _this_runtime_rules_controlId;
846
+ return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
722
847
  }
723
848
  }
724
849
  },
@@ -728,8 +853,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
728
853
  if (controlId === undefined) {
729
854
  return this.runtime.antdRules;
730
855
  } else {
731
- var ref;
732
- return (ref = this.runtime.antdRules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
856
+ var _this_runtime_antdRules_controlId;
857
+ return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
733
858
  }
734
859
  }
735
860
  },
@@ -766,9 +891,9 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
766
891
  key: "setState",
767
892
  value: function setState(controlId, value, rowIndex, options) {
768
893
  eventOptionsTemp = options;
769
- this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
894
+ this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
770
895
  this.store.setState(controlId, value, rowIndex);
771
- this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
896
+ this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
772
897
  eventOptionsTemp = null;
773
898
  }
774
899
  },
@@ -781,20 +906,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
781
906
  var _this = this;
782
907
  var newStates = states !== null && states !== void 0 ? states : {};
783
908
  Object.keys(newStates).forEach(function(stateId) {
784
- var _this2 = _this;
785
909
  Object.entries(_this.store.controlIdMapping).forEach(function(param) {
786
910
  var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
787
911
  if (controlIdMapping.dataView === stateId) {
788
912
  // state对象是dataView包裹的
789
913
  var value = newStates[stateId][controlId];
790
914
  if (value !== undefined) {
791
- _this2.setState(controlId, value, rowIndex, options);
915
+ _this.setState(controlId, value, rowIndex, options);
792
916
  }
793
917
  } else {
794
918
  // state对象是单独的,没有被dataView包裹的
795
919
  if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
796
920
  if (newStates[stateId] !== undefined) {
797
- _this2.setState(stateId, newStates[stateId], rowIndex, options);
921
+ _this.setState(stateId, newStates[stateId], rowIndex, options);
798
922
  }
799
923
  }
800
924
  }
@@ -822,11 +946,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
822
946
  if (!dataBindMapping1) {
823
947
  return;
824
948
  }
825
- var dataBind1 = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
949
+ var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
826
950
  var state = this.getState(controlId1, rowIndex);
827
951
  //if (dataBind instanceof ObjectDataBind) {
828
- if (!isDataBind(dataBind1)) {
829
- return Object.entries(dataBind1).reduce(function(result, param) {
952
+ if (!isDataBind(dataBind)) {
953
+ return Object.entries(dataBind).reduce(function(result, param) {
830
954
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
831
955
  // objectDataBind的元素,跳过下一次赋值
832
956
  if (dataBind.fieldCode === fieldCode) {
@@ -853,18 +977,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
853
977
  var data = getFieldData.map(function(item) {
854
978
  var obj = {};
855
979
  for(var key in item){
856
- var ref, ref2, ref3;
857
- var fieldCode = (ref2 = (ref = controlIdMapping[controlId]) === null || ref === void 0 ? void 0 : ref.children[key]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.dataBind) === null || ref3 === void 0 ? void 0 : ref3.fieldCode;
980
+ var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind;
981
+ var fieldCode = (_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;
858
982
  //未绑定字段的控件,直接抛弃
859
- if (fieldCode !== '') {
860
- var ref4;
983
+ if (fieldCode !== "") {
984
+ var _controlIdMapping_controlId1;
861
985
  if (fieldCode) {
862
986
  obj[fieldCode] = item[key];
863
- } else if ((ref4 = controlIdMapping[controlId]) === null || ref4 === void 0 ? void 0 : ref4.children[key]) {
987
+ } else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
864
988
  // 兼容一个控件需要绑定多个字段的情况
865
989
  for(var keyChi in item[key]){
866
- var ref5, ref6;
867
- 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];
990
+ var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
991
+ obj[(_controlIdMapping_controlId_children_key1 = (_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
868
992
  }
869
993
  }
870
994
  }
@@ -873,45 +997,45 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
873
997
  });
874
998
  return data;
875
999
  } else {
876
- var _loop = function(key1) {
877
- var ref15, ref7, ref8, ref9;
878
- if ((ref15 = controlIdMapping[key1]) === null || ref15 === void 0 ? void 0 : (ref7 = ref15.dataBind) === null || ref7 === void 0 ? void 0 : ref7.fieldCode) {
879
- var ref10;
880
- obj1[(ref10 = controlIdMapping[key1]) === null || ref10 === void 0 ? void 0 : ref10.dataBind.fieldCode] = getFieldData[key1];
881
- } else if ((ref8 = controlIdMapping[key1]) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.dataBind) === null || ref9 === void 0 ? void 0 : ref9.dataCode) {
882
- var ref11;
1000
+ var _loop = function(key) {
1001
+ var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
1002
+ 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) {
1003
+ var _controlIdMapping_key2;
1004
+ obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
1005
+ } 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) {
1006
+ var _controlIdMapping_key3;
883
1007
  // 明细字表只循环一层明细子表未递归
884
- obj1[(ref11 = controlIdMapping[key1]) === null || ref11 === void 0 ? void 0 : ref11.dataBind.dataCode] = getFieldData[key1].map(function(item) {
1008
+ obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
885
1009
  var objChi = {};
886
1010
  for(var keyChi in item){
887
- var ref;
888
- var fieldCode = (ref = controlIdMapping[key1].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode;
1011
+ var _controlIdMapping_key_children_keyChi;
1012
+ var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
889
1013
  //未绑定字段的控件,直接抛弃
890
- if (fieldCode !== '') {
1014
+ if (fieldCode !== "") {
891
1015
  if (fieldCode) {
892
1016
  objChi[fieldCode] = item[keyChi];
893
1017
  } else {
894
1018
  for(var keyChi1 in item[keyChi]){
895
- var ref14;
896
- objChi[(ref14 = controlIdMapping[key1].children[keyChi]) === null || ref14 === void 0 ? void 0 : ref14.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
1019
+ var _controlIdMapping_key_children_keyChi1;
1020
+ objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
897
1021
  }
898
1022
  }
899
1023
  }
900
1024
  }
901
1025
  return objChi;
902
1026
  });
903
- } else if (controlIdMapping[key1]) {
1027
+ } else if (controlIdMapping[key]) {
904
1028
  // 兼容一个控件需要绑定多个字段的情况
905
- for(var keyChi2 in getFieldData[key1]){
906
- var ref12, ref13;
907
- obj1[(ref13 = (ref12 = controlIdMapping[key1]) === null || ref12 === void 0 ? void 0 : ref12.dataBind[keyChi2]) === null || ref13 === void 0 ? void 0 : ref13.fieldCode] = getFieldData[key1][keyChi2];
1029
+ for(var keyChi in getFieldData[key]){
1030
+ var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
1031
+ 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];
908
1032
  }
909
1033
  }
910
1034
  };
911
1035
  // 主表
912
- var obj1 = {};
913
- for(var key1 in getFieldData)_loop(key1);
914
- return obj1;
1036
+ var obj = {};
1037
+ for(var key in getFieldData)_loop(key);
1038
+ return obj;
915
1039
  }
916
1040
  }
917
1041
  return;
@@ -931,13 +1055,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
931
1055
  if (!dataBindMapping) {
932
1056
  return;
933
1057
  }
934
- var dataBind2 = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
1058
+ var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
935
1059
  // if (dataBind instanceof ObjectDataBind) {
936
- if (!isDataBind(dataBind2)) {
937
- var ref;
938
- var oldState = (ref = JSONCopy(this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : this.getEmptyState(controlId);
1060
+ if (!isDataBind(dataBind)) {
1061
+ var _JSONCopy;
1062
+ var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
939
1063
  // fieldCode不代表是key,所以需要找到对应的key
940
- var newState = Object.entries(dataBind2).reduce(function(result, param) {
1064
+ var newState = Object.entries(dataBind).reduce(function(result, param) {
941
1065
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
942
1066
  // objectDataBind的元素,跳过下一次赋值
943
1067
  if (dataBind.fieldCode === fieldCode) {
@@ -967,7 +1091,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
967
1091
  }
968
1092
  var skipKeys = [];
969
1093
  mapping.fields.forEach(function(item) {
970
- var dataBind3 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1094
+ var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
971
1095
  if (skipKeys.includes(fieldCode)) {
972
1096
  return;
973
1097
  }
@@ -976,11 +1100,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
976
1100
  }
977
1101
  // 对象类型的值
978
1102
  // if (dataBind instanceof ObjectDataBind) {
979
- if (!isDataBind(dataBind3)) {
980
- var ref;
981
- var oldState = (ref = JSONCopy(_this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : _this.getEmptyState(controlId);
1103
+ if (!isDataBind(dataBind)) {
1104
+ var _JSONCopy;
1105
+ var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
982
1106
  // fieldCode不代表是key,所以需要找到对应的key
983
- var newState = Object.entries(dataBind3).reduce(function(result, param) {
1107
+ var newState = Object.entries(dataBind).reduce(function(result, param) {
984
1108
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
985
1109
  // objectDataBind的元素,跳过下一次赋值
986
1110
  skipKeys.push(dataBind.fieldCode);
@@ -1006,13 +1130,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1006
1130
  value: function buildFields(dataCode, state) {
1007
1131
  var _this = this;
1008
1132
  var mapping = this.getDataBindMapping(dataCode);
1009
- if (!mapping || !mapping.fields) {
1133
+ if (!mapping) {
1010
1134
  return;
1011
1135
  }
1012
1136
  var skipKeys = [];
1013
- var result1 = {};
1137
+ var result = {};
1014
1138
  mapping.fields.forEach(function(item) {
1015
- var dataBind4 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1139
+ var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1016
1140
  if (skipKeys.includes(fieldCode)) {
1017
1141
  return;
1018
1142
  }
@@ -1021,10 +1145,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1021
1145
  }
1022
1146
  // 对象类型的值
1023
1147
  // if (dataBind instanceof ObjectDataBind) {
1024
- if (!isDataBind(dataBind4)) {
1148
+ if (!isDataBind(dataBind)) {
1025
1149
  var oldState = _this.getEmptyState(controlId);
1026
1150
  // fieldCode不代表是key,所以需要找到对应的key
1027
- result1[item.controlId] = Object.entries(dataBind4).reduce(function(result, param) {
1151
+ result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
1028
1152
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1029
1153
  // objectDataBind的元素,跳过下一次赋值
1030
1154
  skipKeys.push(dataBind.fieldCode);
@@ -1035,10 +1159,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1035
1159
  return result;
1036
1160
  }, oldState);
1037
1161
  } else {
1038
- result1[controlId] = state[fieldCode];
1162
+ result[controlId] = state[fieldCode];
1039
1163
  }
1040
1164
  });
1041
- return result1;
1165
+ return result;
1042
1166
  }
1043
1167
  },
1044
1168
  {
@@ -1048,14 +1172,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1048
1172
  * @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
1049
1173
  */ key: "setData",
1050
1174
  value: function setData(dataSet, options) {
1051
- var _this6 = this;
1175
+ var _this = this;
1052
1176
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1053
1177
  var newState = this.store.defaultState;
1054
1178
  Object.keys(dataSet).map(function(dataCode) {
1055
1179
  var entity = dataSet[dataCode];
1056
1180
  if (Array.isArray(entity)) {
1057
- var _this4 = _this6;
1058
- var mapping = _this6.getDataBindMapping(dataCode);
1181
+ var mapping = _this.getDataBindMapping(dataCode);
1059
1182
  if (!mapping) {
1060
1183
  return;
1061
1184
  }
@@ -1063,22 +1186,21 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1063
1186
  newState[mapping.dataViewId] = {};
1064
1187
  }
1065
1188
  if (!entity.length) {
1066
- var _controlId;
1067
- newState[mapping.dataViewId][mapping.controlId] = (_controlId = newState[mapping.dataViewId][mapping.controlId]) !== null && _controlId !== void 0 ? _controlId : [];
1189
+ var _newState_mapping_dataViewId_mapping_controlId;
1190
+ newState[mapping.dataViewId][mapping.controlId] = (_newState_mapping_dataViewId_mapping_controlId = newState[mapping.dataViewId][mapping.controlId]) !== null && _newState_mapping_dataViewId_mapping_controlId !== void 0 ? _newState_mapping_dataViewId_mapping_controlId : [];
1068
1191
  } else {
1069
1192
  newState[mapping.dataViewId][mapping.controlId] = [];
1070
1193
  }
1071
1194
  entity.map(function(row) {
1072
- var _this = _this4;
1073
- var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
1195
+ var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
1074
1196
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1075
1197
  ;
1076
1198
  Object.keys(row).map(function(fieldCode) {
1077
- var ref, ref18;
1199
+ var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
1078
1200
  if (skipKey.includes(fieldCode)) {
1079
1201
  return;
1080
1202
  }
1081
- var fieldMapping = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (ref18 = ref.fields) === null || ref18 === void 0 ? void 0 : ref18.find(function(i) {
1203
+ 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) {
1082
1204
  return i.fieldCode === fieldCode;
1083
1205
  });
1084
1206
  if (fieldMapping) {
@@ -1087,8 +1209,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1087
1209
  newRow[fieldMapping.controlId] = row[fieldCode];
1088
1210
  // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1089
1211
  } else if (!isDataBind(fieldMapping.dataBind)) {
1090
- var ref19;
1091
- var objValue = JSONCopy((ref19 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref19 !== void 0 ? ref19 : {});
1212
+ var _this_getEmptyState;
1213
+ var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1092
1214
  Object.keys(fieldMapping.dataBind).map(function(key) {
1093
1215
  var dataBind = fieldMapping.dataBind[key];
1094
1216
  if (row[dataBind.fieldCode] !== undefined) {
@@ -1103,19 +1225,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1103
1225
  newState[mapping.dataViewId][mapping.controlId].push(newRow);
1104
1226
  });
1105
1227
  } else if (entity) {
1106
- var ref20;
1107
- var skipKey1 = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1228
+ var _Object_keys;
1229
+ var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1108
1230
  ;
1109
- var emptyState = JSONCopy(_this6.store.emptyState);
1110
- if (!((ref20 = Object.keys(entity)) === null || ref20 === void 0 ? void 0 : ref20.length)) {
1231
+ var emptyState = JSONCopy(_this.store.emptyState);
1232
+ if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
1111
1233
  // newState = this.store.defaultState
1112
1234
  } else {
1113
- var _this3 = _this6;
1114
1235
  Object.keys(entity).map(function(fieldCode) {
1115
- if (skipKey1.includes(fieldCode)) {
1236
+ if (skipKey.includes(fieldCode)) {
1116
1237
  return;
1117
1238
  }
1118
- var mapping = _this3.getDataBindMapping(dataCode, fieldCode);
1239
+ var mapping = _this.getDataBindMapping(dataCode, fieldCode);
1119
1240
  if (mapping) {
1120
1241
  if (!newState[mapping.dataViewId[0]]) {
1121
1242
  newState[mapping.dataViewId[0]] = {};
@@ -1125,31 +1246,31 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1125
1246
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1126
1247
  // } else if (mapping.dataBind instanceof ObjectDataBind) {
1127
1248
  } else if (!isDataBind(mapping.dataBind)) {
1128
- var ref;
1129
- var objValue = (ref = _this3.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
1249
+ var _this_getEmptyState;
1250
+ var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1130
1251
  Object.keys(mapping.dataBind).map(function(key) {
1131
1252
  var dataBind = mapping.dataBind[key];
1132
1253
  if (entity[dataBind.fieldCode] !== undefined) {
1133
1254
  objValue[key] = entity[dataBind.fieldCode];
1134
1255
  }
1135
- skipKey1.push(dataBind.fieldCode);
1256
+ skipKey.push(dataBind.fieldCode);
1136
1257
  });
1137
1258
  newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
1138
1259
  }
1139
1260
  }
1140
1261
  });
1141
1262
  }
1142
- var newMapping = _this6.getDataBindMapping(dataCode);
1263
+ var newMapping = _this.getDataBindMapping(dataCode);
1143
1264
  if (newMapping) {
1144
- var ref16;
1145
- var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (ref16 = newMapping.fields) === null || ref16 === void 0 ? void 0 : ref16.map(function(item) {
1265
+ var _newMapping_fields;
1266
+ var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
1146
1267
  return item === null || item === void 0 ? void 0 : item.controlId;
1147
1268
  });
1148
- var mappingValue = _this6.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1149
- var ref17;
1150
- var mainStateKeys = Object.keys((ref17 = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && ref17 !== void 0 ? ref17 : {});
1269
+ var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1270
+ var _newState_newMapping_controlId;
1271
+ var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
1151
1272
  mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1152
- if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1273
+ if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1153
1274
  if (Object.keys(newState).length) {
1154
1275
  Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
1155
1276
  } else {
@@ -1157,7 +1278,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1157
1278
  }
1158
1279
  }
1159
1280
  });
1160
- _this6.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1281
+ _this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1161
1282
  }
1162
1283
  }
1163
1284
  });
@@ -1202,59 +1323,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1202
1323
  * 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
1203
1324
  * @param controlId
1204
1325
  * @param header 明细表内是否获取表头的控件
1205
- */ // getInstances(
1206
- // controlId?: string,
1207
- // header: boolean = false
1208
- // ): ControlRuntimeInstance<ControlsKeys>[] {
1209
- // // const cc = console
1210
- // // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
1211
- // // cc.time(label)
1212
- //
1213
- // if (controlId === undefined) {
1214
- // // cc.timeEnd(label)
1215
- // return this.runtime.flatInstances
1216
- // }
1217
- // const instances = Array.from(this.runtime.instanceMap[controlId] || [])
1218
- // if (header) {
1219
- // // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1220
- // if (instances.length) {
1221
- // const instance: RuntimeControl = instances[0]
1222
- // // if (this.inList(instance.id) === true) {
1223
- // if (this.inList(instance.id) !== undefined) {
1224
- // const headerInstance = this.getInstanceInSubtableHeader(instance)
1225
- // if (headerInstance) {
1226
- // instances.unshift(headerInstance)
1227
- // }
1228
- // }
1229
- // } else {
1230
- // const controlIdMapping = this.getControlIdMapping()
1231
- // const [subtableId] =
1232
- // Object.entries(controlIdMapping).find(
1233
- // ([_, mapping]) => mapping.children && controlId in mapping.children
1234
- // ) ?? []
1235
- // if (subtableId) {
1236
- // const subtable = this.getInstance(subtableId)
1237
- // // @ts-ignore
1238
- // const headerColumn = subtable.props.headers.find((column: any) =>
1239
- // column.children.find((item: any) => item.id === controlId)
1240
- // )
1241
- // if (headerColumn) {
1242
- // const headerInstance = headerColumn.children.find(
1243
- // (item: any) => item.id === controlId
1244
- // )
1245
- // if (headerInstance) {
1246
- // instances.unshift(
1247
- // headerInstance as ControlRuntimeInstance<ControlsKeys>
1248
- // )
1249
- // }
1250
- // }
1251
- // }
1252
- // }
1253
- // }
1254
- // // @ts-ignore
1255
- // return instances
1256
- // }
1257
- key: "getInstances",
1326
+ */ key: "getInstances",
1258
1327
  value: function getInstances(controlId) {
1259
1328
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1260
1329
  // const cc = console
@@ -1264,15 +1333,42 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1264
1333
  // cc.timeEnd(label)
1265
1334
  return this.runtime.flatInstances;
1266
1335
  }
1267
- var instances = this.runtime.instanceMap[controlId] || [];
1336
+ var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1268
1337
  if (header) {
1269
- var instance = instances[0];
1270
- if (instance) {
1271
- var ref;
1272
- // @ts-ignore
1273
- var parentId = (ref = instance.parent) === null || ref === void 0 ? void 0 : ref.id;
1274
- if (parentId) {
1275
- instances = this.runtime.instanceMap[parentId] || [];
1338
+ // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1339
+ if (instances.length) {
1340
+ var instance = instances[0];
1341
+ // if (this.inList(instance.id) === true) {
1342
+ if (this.inList(instance.id) !== undefined) {
1343
+ var headerInstance = this.getInstanceInSubtableHeader(instance);
1344
+ if (headerInstance) {
1345
+ instances.unshift(headerInstance);
1346
+ }
1347
+ }
1348
+ } else {
1349
+ var _this_getControlIdMapping;
1350
+ var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
1351
+ var _Object_entries_find;
1352
+ var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1353
+ var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
1354
+ return mapping.children && controlId in mapping.children;
1355
+ })) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
1356
+ if (subtableId) {
1357
+ var subtable = this.getInstance(subtableId);
1358
+ // @ts-ignore
1359
+ var headerColumn = subtable.props.headers.find(function(column) {
1360
+ return column.children.find(function(item) {
1361
+ return item.id === controlId;
1362
+ });
1363
+ });
1364
+ if (headerColumn) {
1365
+ var headerInstance1 = headerColumn.children.find(function(item) {
1366
+ return item.id === controlId;
1367
+ });
1368
+ if (headerInstance1) {
1369
+ instances.unshift(headerInstance1);
1370
+ }
1371
+ }
1276
1372
  }
1277
1373
  }
1278
1374
  }
@@ -1283,16 +1379,16 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1283
1379
  {
1284
1380
  key: "setInstance",
1285
1381
  value: function setInstance(instance, props, value, rowIndex) {
1382
+ var _this = this;
1286
1383
  try {
1287
- if (typeof instance === 'string' && rowIndex === -1) {
1288
- var _this = this;
1384
+ if (typeof instance === "string" && rowIndex === -1) {
1289
1385
  //修改明细表整列属性的逻辑
1290
1386
  var instances = this.getInstances(instance, rowIndex === -1);
1291
1387
  instances.map(function(_instance) {
1292
1388
  if (_instance) {
1293
1389
  _this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1294
1390
  updateValueFromKeys(_instance.props, props, value);
1295
- _this.schemaEvent('schema-change', {
1391
+ _this.schemaEvent("schema-change", {
1296
1392
  instance: _instance,
1297
1393
  props: props,
1298
1394
  value: value,
@@ -1301,19 +1397,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1301
1397
  }
1302
1398
  });
1303
1399
  } else {
1304
- var _instance1;
1305
- if (typeof instance === 'string') {
1306
- _instance1 = this.getInstance(instance, rowIndex);
1400
+ var _instance;
1401
+ if (typeof instance === "string") {
1402
+ _instance = this.getInstance(instance, rowIndex);
1307
1403
  } else {
1308
- _instance1 = instance;
1404
+ _instance = instance;
1309
1405
  }
1310
- if (!_instance1) {
1406
+ if (!_instance) {
1311
1407
  return;
1312
1408
  }
1313
- this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance1.id, _instance1, props, value);
1314
- updateValueFromKeys(_instance1.props, props, value);
1315
- this.schemaEvent('schema-change', {
1316
- instance: _instance1,
1409
+ this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1410
+ updateValueFromKeys(_instance.props, props, value);
1411
+ this.schemaEvent("schema-change", {
1412
+ instance: _instance,
1317
1413
  props: props,
1318
1414
  value: value,
1319
1415
  rowIndex: rowIndex
@@ -1387,64 +1483,55 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1387
1483
  * 如果控件在表头内,则返回-1
1388
1484
  * 如果控件在表内,则返回行下标
1389
1485
  * 如果控件不在明细表内,则返回undefined
1390
- * */ // public getInstanceRowIndex(
1391
- // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1392
- // ) {
1393
- // if (!instance.parent) {
1394
- // return
1395
- // }
1396
- // let rowIndex: number | undefined
1397
- // // @ts-ignore
1398
- // if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1399
- // // 表头内的控件
1400
- // // @ts-ignore
1401
- // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1402
- // rowIndex = -1
1403
- // } else {
1404
- // // @ts-ignore
1405
- // // const index = instance.parent.children.findIndex(
1406
- // // (item: any) => item === instance
1407
- // // )
1408
- // let instances = this.runtime.instanceMap[instance.id] || []
1409
- // const index = instances.findIndex((item: any) => item === instance)
1410
- // if (index > -1) {
1411
- // rowIndex = index
1412
- // }
1413
- // }
1414
- // } else {
1415
- // rowIndex = this.getInstanceRowIndex(instance.parent)
1416
- // }
1417
- // return rowIndex
1418
- // }
1419
- function getInstanceRowIndex(instance) {
1486
+ * */ function getInstanceRowIndex(instance) {
1420
1487
  if (!instance.parent) {
1421
1488
  return;
1422
1489
  }
1423
1490
  var rowIndex;
1424
1491
  // @ts-ignore
1425
- if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1426
- rowIndex = -1;
1427
- } else {
1428
- var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
1429
- CONTROL_TYPE.SUBTABLE_COLUMN);
1430
- if (isColumnChild) {
1431
- var instanceList = this.runtime.instanceMap[instance.id];
1432
- if (Object.prototype.toString.call(instanceList) === '[object Array]') {
1433
- var index = instanceList.findIndex(function(item) {
1434
- return item === instance;
1435
- });
1436
- if (index > -1) {
1437
- rowIndex = index;
1438
- }
1492
+ if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1493
+ // 表头内的控件
1494
+ // @ts-ignore
1495
+ if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1496
+ rowIndex = -1;
1497
+ } else {
1498
+ // @ts-ignore
1499
+ var index = instance.parent.children.findIndex(function(item) {
1500
+ return item === instance;
1501
+ });
1502
+ if (index > -1) {
1503
+ rowIndex = index;
1439
1504
  }
1440
1505
  }
1506
+ } else {
1507
+ rowIndex = this.getInstanceRowIndex(instance.parent);
1441
1508
  }
1442
1509
  return rowIndex;
1443
1510
  }
1444
1511
  },
1445
1512
  {
1446
1513
  key: "getInstanceParentControl",
1447
- value: function getInstanceParentControl(instance, controlType) {
1514
+ value: // public getInstanceRowIndex(
1515
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1516
+ // ) {
1517
+ // let rowIndex: number | undefined
1518
+ // // @ts-ignore
1519
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1520
+ // rowIndex = -1
1521
+ // }else{
1522
+ // const instanceList = this.runtime.instanceMap[instance.id]
1523
+ // if(Object.prototype.toString.call(instanceList) === '[object Array]'){
1524
+ // const index = instanceList.findIndex(
1525
+ // (item: any) => item === instance
1526
+ // )
1527
+ // if (index > -1) {
1528
+ // rowIndex = index
1529
+ // }
1530
+ // }
1531
+ // }
1532
+ // return rowIndex
1533
+ // }
1534
+ function getInstanceParentControl(instance, controlType) {
1448
1535
  if (!instance.parent) {
1449
1536
  return;
1450
1537
  }
@@ -1492,8 +1579,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1492
1579
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1493
1580
  args[_key] = arguments[_key];
1494
1581
  }
1495
- var _runtime;
1496
- return (_runtime = this.runtime).registerControlConfig.apply(_runtime, _toConsumableArray(args));
1582
+ var _this_runtime;
1583
+ return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
1497
1584
  }
1498
1585
  },
1499
1586
  {
@@ -1505,12 +1592,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1505
1592
  {
1506
1593
  key: "inList",
1507
1594
  value: function inList(controlId) {
1508
- var _controlIdMapping;
1509
- var mapping = (_controlIdMapping = this.store.controlIdMapping) !== null && _controlIdMapping !== void 0 ? _controlIdMapping : {};
1595
+ var _this_store_controlIdMapping;
1596
+ var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
1510
1597
  var listKey = undefined;
1511
1598
  Object.keys(mapping).some(function(key) {
1512
- var ref, ref21;
1513
- var matched = (ref = mapping[key]) === null || ref === void 0 ? void 0 : (ref21 = ref.children) === null || ref21 === void 0 ? void 0 : ref21.hasOwnProperty(controlId);
1599
+ var _mapping_key, _mapping_key_children;
1600
+ var matched = (_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);
1514
1601
  if (matched) {
1515
1602
  listKey = key;
1516
1603
  }
@@ -1523,8 +1610,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1523
1610
  {
1524
1611
  key: "register",
1525
1612
  value: // 注册外部控件
1526
- function register(control) {
1527
- return Runtime.register(control, 'Runtime');
1613
+ function register() {
1614
+ for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
1615
+ arg[_key] = arguments[_key];
1616
+ }
1617
+ var _Runtime;
1618
+ return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
1528
1619
  }
1529
1620
  },
1530
1621
  {
@@ -1536,5 +1627,4 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1536
1627
  ]);
1537
1628
  return Engine;
1538
1629
  }(Watcher);
1539
- // @ts-ignore
1540
1630
  export { Engine };