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

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