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

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,12 +569,12 @@ 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
  }
705
579
  return row;
706
580
  }
@@ -709,7 +583,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
709
583
  key: "listControlAddRow",
710
584
  value: function listControlAddRow(instance) {
711
585
  var // @ts-ignore
712
- rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
586
+ rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
713
587
  var row = this.listControlCreateRow(instance, rowType);
714
588
  if (!row) return;
715
589
  instance.children.push(row);
@@ -723,40 +597,37 @@ var Engine = /*#__PURE__*/ function(Watcher) {
723
597
  var _this1 = this, _superprop_get_emit = function() {
724
598
  return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
725
599
  };
726
- return _asyncToGenerator(function() {
600
+ return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
727
601
  var needWait, promiseResolver, promise, results;
728
- return __generator(this, function(_state) {
729
- switch(_state.label){
602
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
603
+ while(1)switch(_ctx.prev = _ctx.next){
730
604
  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
- ];
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;
741
619
  }
742
- if (!_this1._jobTasks.length) return [
743
- 3,
744
- 2
745
- ];
746
- console.time("engine-mounted need wait");
620
+ console.time('engine-mounted need wait');
747
621
  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:
622
+ _ctx.next = 9;
623
+ return Promise.all(needWait);
624
+ case 9:
625
+ console.timeEnd('engine-mounted need wait');
626
+ case 10:
757
627
  _this1.isMounted = true;
758
- _state.label = 3;
759
- case 3:
628
+ case 11:
629
+ ;
630
+ ;
760
631
  // 如果没有挂载的话,需要记录在挂载之前触发的所有任务
761
632
  if (!_this1.isMounted) {
762
633
  promise = new Promise(function(resolve) {
@@ -764,24 +635,22 @@ var Engine = /*#__PURE__*/ function(Watcher) {
764
635
  });
765
636
  _this1._jobTasks.push(promise);
766
637
  }
767
- return [
768
- 4,
769
- _superprop_get_emit().call(_this1, eventKey, payload)
770
- ];
771
- case 4:
772
- results = _state.sent();
638
+ _ctx.next = 16;
639
+ return _superprop_get_emit().call(_this1, eventKey, payload);
640
+ case 16:
641
+ results = _ctx.sent;
773
642
  if (promiseResolver && promise) {
774
643
  // 每一个任务完成的时候,都把自己从task中去掉
775
644
  promiseResolver();
776
645
  _this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
777
646
  }
778
- return [
779
- 2,
780
- results
781
- ];
647
+ return _ctx.abrupt("return", results);
648
+ case 19:
649
+ case "end":
650
+ return _ctx.stop();
782
651
  }
783
- });
784
- })();
652
+ }, _callee);
653
+ }))();
785
654
  }
786
655
  },
787
656
  {
@@ -799,8 +668,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
799
668
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
800
669
  args[_key] = arguments[_key];
801
670
  }
802
- var _this_runtime;
803
- return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
671
+ var _runtime;
672
+ return (_runtime = this.runtime).createControl.apply(_runtime, _toConsumableArray(args));
804
673
  }
805
674
  },
806
675
  {
@@ -821,6 +690,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
821
690
  return this.setInstance(instance, props, value, rowIndex);
822
691
  }
823
692
  },
693
+ {
694
+ key: "getRule",
695
+ value: function getRule(controlType, props) {
696
+ return Runtime.staticGetRules(controlType, props);
697
+ }
698
+ },
824
699
  {
825
700
  key: "getAllRules",
826
701
  value: function getAllRules(controlId) {
@@ -828,10 +703,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
828
703
  if (controlId === undefined) {
829
704
  return rules;
830
705
  } else {
831
- var _rules_rules_controlId, _rules_antdRules_controlId;
706
+ var ref, ref1;
832
707
  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
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
835
710
  };
836
711
  }
837
712
  }
@@ -842,8 +717,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
842
717
  if (controlId === undefined) {
843
718
  return this.runtime.rules;
844
719
  } 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;
720
+ var ref;
721
+ return (ref = this.runtime.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
847
722
  }
848
723
  }
849
724
  },
@@ -853,8 +728,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
853
728
  if (controlId === undefined) {
854
729
  return this.runtime.antdRules;
855
730
  } 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;
731
+ var ref;
732
+ return (ref = this.runtime.antdRules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
858
733
  }
859
734
  }
860
735
  },
@@ -891,9 +766,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
891
766
  key: "setState",
892
767
  value: function setState(controlId, value, rowIndex, options) {
893
768
  eventOptionsTemp = options;
894
- this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
769
+ this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
895
770
  this.store.setState(controlId, value, rowIndex);
896
- this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
771
+ this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
897
772
  eventOptionsTemp = null;
898
773
  }
899
774
  },
@@ -906,19 +781,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
906
781
  var _this = this;
907
782
  var newStates = states !== null && states !== void 0 ? states : {};
908
783
  Object.keys(newStates).forEach(function(stateId) {
784
+ var _this2 = _this;
909
785
  Object.entries(_this.store.controlIdMapping).forEach(function(param) {
910
786
  var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
911
787
  if (controlIdMapping.dataView === stateId) {
912
788
  // state对象是dataView包裹的
913
789
  var value = newStates[stateId][controlId];
914
790
  if (value !== undefined) {
915
- _this.setState(controlId, value, rowIndex, options);
791
+ _this2.setState(controlId, value, rowIndex, options);
916
792
  }
917
793
  } else {
918
794
  // state对象是单独的,没有被dataView包裹的
919
795
  if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
920
796
  if (newStates[stateId] !== undefined) {
921
- _this.setState(stateId, newStates[stateId], rowIndex, options);
797
+ _this2.setState(stateId, newStates[stateId], rowIndex, options);
922
798
  }
923
799
  }
924
800
  }
@@ -946,11 +822,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
946
822
  if (!dataBindMapping1) {
947
823
  return;
948
824
  }
949
- var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
825
+ var dataBind1 = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
950
826
  var state = this.getState(controlId1, rowIndex);
951
827
  //if (dataBind instanceof ObjectDataBind) {
952
- if (!isDataBind(dataBind)) {
953
- return Object.entries(dataBind).reduce(function(result, param) {
828
+ if (!isDataBind(dataBind1)) {
829
+ return Object.entries(dataBind1).reduce(function(result, param) {
954
830
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
955
831
  // objectDataBind的元素,跳过下一次赋值
956
832
  if (dataBind.fieldCode === fieldCode) {
@@ -977,18 +853,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
977
853
  var data = getFieldData.map(function(item) {
978
854
  var obj = {};
979
855
  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;
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;
982
858
  //未绑定字段的控件,直接抛弃
983
- if (fieldCode !== "") {
984
- var _controlIdMapping_controlId1;
859
+ if (fieldCode !== '') {
860
+ var ref4;
985
861
  if (fieldCode) {
986
862
  obj[fieldCode] = item[key];
987
- } else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
863
+ } else if ((ref4 = controlIdMapping[controlId]) === null || ref4 === void 0 ? void 0 : ref4.children[key]) {
988
864
  // 兼容一个控件需要绑定多个字段的情况
989
865
  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];
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];
992
868
  }
993
869
  }
994
870
  }
@@ -997,45 +873,45 @@ var Engine = /*#__PURE__*/ function(Watcher) {
997
873
  });
998
874
  return data;
999
875
  } 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;
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;
1007
883
  // 明细字表只循环一层明细子表未递归
1008
- obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
884
+ obj1[(ref11 = controlIdMapping[key1]) === null || ref11 === void 0 ? void 0 : ref11.dataBind.dataCode] = getFieldData[key1].map(function(item) {
1009
885
  var objChi = {};
1010
886
  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;
887
+ var ref;
888
+ var fieldCode = (ref = controlIdMapping[key1].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode;
1013
889
  //未绑定字段的控件,直接抛弃
1014
- if (fieldCode !== "") {
890
+ if (fieldCode !== '') {
1015
891
  if (fieldCode) {
1016
892
  objChi[fieldCode] = item[keyChi];
1017
893
  } else {
1018
894
  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];
895
+ var ref14;
896
+ objChi[(ref14 = controlIdMapping[key1].children[keyChi]) === null || ref14 === void 0 ? void 0 : ref14.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
1021
897
  }
1022
898
  }
1023
899
  }
1024
900
  }
1025
901
  return objChi;
1026
902
  });
1027
- } else if (controlIdMapping[key]) {
903
+ } else if (controlIdMapping[key1]) {
1028
904
  // 兼容一个控件需要绑定多个字段的情况
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];
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];
1032
908
  }
1033
909
  }
1034
910
  };
1035
911
  // 主表
1036
- var obj = {};
1037
- for(var key in getFieldData)_loop(key);
1038
- return obj;
912
+ var obj1 = {};
913
+ for(var key1 in getFieldData)_loop(key1);
914
+ return obj1;
1039
915
  }
1040
916
  }
1041
917
  return;
@@ -1055,13 +931,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1055
931
  if (!dataBindMapping) {
1056
932
  return;
1057
933
  }
1058
- var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
934
+ var dataBind2 = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
1059
935
  // 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);
936
+ if (!isDataBind(dataBind2)) {
937
+ var ref;
938
+ var oldState = (ref = JSONCopy(this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : this.getEmptyState(controlId);
1063
939
  // fieldCode不代表是key,所以需要找到对应的key
1064
- var newState = Object.entries(dataBind).reduce(function(result, param) {
940
+ var newState = Object.entries(dataBind2).reduce(function(result, param) {
1065
941
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1066
942
  // objectDataBind的元素,跳过下一次赋值
1067
943
  if (dataBind.fieldCode === fieldCode) {
@@ -1091,7 +967,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1091
967
  }
1092
968
  var skipKeys = [];
1093
969
  mapping.fields.forEach(function(item) {
1094
- var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
970
+ var dataBind3 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1095
971
  if (skipKeys.includes(fieldCode)) {
1096
972
  return;
1097
973
  }
@@ -1100,11 +976,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1100
976
  }
1101
977
  // 对象类型的值
1102
978
  // 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);
979
+ if (!isDataBind(dataBind3)) {
980
+ var ref;
981
+ var oldState = (ref = JSONCopy(_this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : _this.getEmptyState(controlId);
1106
982
  // fieldCode不代表是key,所以需要找到对应的key
1107
- var newState = Object.entries(dataBind).reduce(function(result, param) {
983
+ var newState = Object.entries(dataBind3).reduce(function(result, param) {
1108
984
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1109
985
  // objectDataBind的元素,跳过下一次赋值
1110
986
  skipKeys.push(dataBind.fieldCode);
@@ -1130,13 +1006,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1130
1006
  value: function buildFields(dataCode, state) {
1131
1007
  var _this = this;
1132
1008
  var mapping = this.getDataBindMapping(dataCode);
1133
- if (!mapping) {
1009
+ if (!mapping || !mapping.fields) {
1134
1010
  return;
1135
1011
  }
1136
1012
  var skipKeys = [];
1137
- var result = {};
1013
+ var result1 = {};
1138
1014
  mapping.fields.forEach(function(item) {
1139
- var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1015
+ var dataBind4 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
1140
1016
  if (skipKeys.includes(fieldCode)) {
1141
1017
  return;
1142
1018
  }
@@ -1145,10 +1021,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1145
1021
  }
1146
1022
  // 对象类型的值
1147
1023
  // if (dataBind instanceof ObjectDataBind) {
1148
- if (!isDataBind(dataBind)) {
1024
+ if (!isDataBind(dataBind4)) {
1149
1025
  var oldState = _this.getEmptyState(controlId);
1150
1026
  // fieldCode不代表是key,所以需要找到对应的key
1151
- result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
1027
+ result1[item.controlId] = Object.entries(dataBind4).reduce(function(result, param) {
1152
1028
  var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1153
1029
  // objectDataBind的元素,跳过下一次赋值
1154
1030
  skipKeys.push(dataBind.fieldCode);
@@ -1159,10 +1035,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1159
1035
  return result;
1160
1036
  }, oldState);
1161
1037
  } else {
1162
- result[controlId] = state[fieldCode];
1038
+ result1[controlId] = state[fieldCode];
1163
1039
  }
1164
1040
  });
1165
- return result;
1041
+ return result1;
1166
1042
  }
1167
1043
  },
1168
1044
  {
@@ -1172,13 +1048,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1172
1048
  * @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
1173
1049
  */ key: "setData",
1174
1050
  value: function setData(dataSet, options) {
1175
- var _this = this;
1051
+ var _this6 = this;
1176
1052
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1177
1053
  var newState = this.store.defaultState;
1178
1054
  Object.keys(dataSet).map(function(dataCode) {
1179
1055
  var entity = dataSet[dataCode];
1180
1056
  if (Array.isArray(entity)) {
1181
- var mapping = _this.getDataBindMapping(dataCode);
1057
+ var _this4 = _this6;
1058
+ var mapping = _this6.getDataBindMapping(dataCode);
1182
1059
  if (!mapping) {
1183
1060
  return;
1184
1061
  }
@@ -1186,21 +1063,22 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1186
1063
  newState[mapping.dataViewId] = {};
1187
1064
  }
1188
1065
  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 : [];
1066
+ var _controlId;
1067
+ newState[mapping.dataViewId][mapping.controlId] = (_controlId = newState[mapping.dataViewId][mapping.controlId]) !== null && _controlId !== void 0 ? _controlId : [];
1191
1068
  } else {
1192
1069
  newState[mapping.dataViewId][mapping.controlId] = [];
1193
1070
  }
1194
1071
  entity.map(function(row) {
1195
- var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
1072
+ var _this = _this4;
1073
+ var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
1196
1074
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1197
1075
  ;
1198
1076
  Object.keys(row).map(function(fieldCode) {
1199
- var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
1077
+ var ref, ref18;
1200
1078
  if (skipKey.includes(fieldCode)) {
1201
1079
  return;
1202
1080
  }
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) {
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) {
1204
1082
  return i.fieldCode === fieldCode;
1205
1083
  });
1206
1084
  if (fieldMapping) {
@@ -1209,8 +1087,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1209
1087
  newRow[fieldMapping.controlId] = row[fieldCode];
1210
1088
  // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1211
1089
  } 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 : {});
1090
+ var ref19;
1091
+ var objValue = JSONCopy((ref19 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref19 !== void 0 ? ref19 : {});
1214
1092
  Object.keys(fieldMapping.dataBind).map(function(key) {
1215
1093
  var dataBind = fieldMapping.dataBind[key];
1216
1094
  if (row[dataBind.fieldCode] !== undefined) {
@@ -1225,18 +1103,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1225
1103
  newState[mapping.dataViewId][mapping.controlId].push(newRow);
1226
1104
  });
1227
1105
  } else if (entity) {
1228
- var _Object_keys;
1229
- var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1106
+ var ref20;
1107
+ var skipKey1 = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1230
1108
  ;
1231
- var emptyState = JSONCopy(_this.store.emptyState);
1232
- if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
1109
+ var emptyState = JSONCopy(_this6.store.emptyState);
1110
+ if (!((ref20 = Object.keys(entity)) === null || ref20 === void 0 ? void 0 : ref20.length)) {
1233
1111
  // newState = this.store.defaultState
1234
1112
  } else {
1113
+ var _this3 = _this6;
1235
1114
  Object.keys(entity).map(function(fieldCode) {
1236
- if (skipKey.includes(fieldCode)) {
1115
+ if (skipKey1.includes(fieldCode)) {
1237
1116
  return;
1238
1117
  }
1239
- var mapping = _this.getDataBindMapping(dataCode, fieldCode);
1118
+ var mapping = _this3.getDataBindMapping(dataCode, fieldCode);
1240
1119
  if (mapping) {
1241
1120
  if (!newState[mapping.dataViewId[0]]) {
1242
1121
  newState[mapping.dataViewId[0]] = {};
@@ -1246,31 +1125,31 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1246
1125
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1247
1126
  // } else if (mapping.dataBind instanceof ObjectDataBind) {
1248
1127
  } 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 : {};
1128
+ var ref;
1129
+ var objValue = (ref = _this3.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
1251
1130
  Object.keys(mapping.dataBind).map(function(key) {
1252
1131
  var dataBind = mapping.dataBind[key];
1253
1132
  if (entity[dataBind.fieldCode] !== undefined) {
1254
1133
  objValue[key] = entity[dataBind.fieldCode];
1255
1134
  }
1256
- skipKey.push(dataBind.fieldCode);
1135
+ skipKey1.push(dataBind.fieldCode);
1257
1136
  });
1258
1137
  newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
1259
1138
  }
1260
1139
  }
1261
1140
  });
1262
1141
  }
1263
- var newMapping = _this.getDataBindMapping(dataCode);
1142
+ var newMapping = _this6.getDataBindMapping(dataCode);
1264
1143
  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) {
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) {
1267
1146
  return item === null || item === void 0 ? void 0 : item.controlId;
1268
1147
  });
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 : {});
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 : {});
1272
1151
  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]) {
1152
+ if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1274
1153
  if (Object.keys(newState).length) {
1275
1154
  Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
1276
1155
  } else {
@@ -1278,7 +1157,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1278
1157
  }
1279
1158
  }
1280
1159
  });
1281
- _this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1160
+ _this6.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1282
1161
  }
1283
1162
  }
1284
1163
  });
@@ -1323,7 +1202,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1323
1202
  * 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
1324
1203
  * @param controlId
1325
1204
  * @param header 明细表内是否获取表头的控件
1326
- */ key: "getInstances",
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",
1327
1258
  value: function getInstances(controlId) {
1328
1259
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1329
1260
  // const cc = console
@@ -1333,42 +1264,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1333
1264
  // cc.timeEnd(label)
1334
1265
  return this.runtime.flatInstances;
1335
1266
  }
1336
- var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1267
+ var instances = this.runtime.instanceMap[controlId] || [];
1337
1268
  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
- }
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] || [];
1372
1276
  }
1373
1277
  }
1374
1278
  }
@@ -1379,16 +1283,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1379
1283
  {
1380
1284
  key: "setInstance",
1381
1285
  value: function setInstance(instance, props, value, rowIndex) {
1382
- var _this = this;
1383
1286
  try {
1384
- if (typeof instance === "string" && rowIndex === -1) {
1287
+ if (typeof instance === 'string' && rowIndex === -1) {
1288
+ var _this = this;
1385
1289
  //修改明细表整列属性的逻辑
1386
1290
  var instances = this.getInstances(instance, rowIndex === -1);
1387
1291
  instances.map(function(_instance) {
1388
1292
  if (_instance) {
1389
1293
  _this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1390
1294
  updateValueFromKeys(_instance.props, props, value);
1391
- _this.schemaEvent("schema-change", {
1295
+ _this.schemaEvent('schema-change', {
1392
1296
  instance: _instance,
1393
1297
  props: props,
1394
1298
  value: value,
@@ -1397,19 +1301,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1397
1301
  }
1398
1302
  });
1399
1303
  } else {
1400
- var _instance;
1401
- if (typeof instance === "string") {
1402
- _instance = this.getInstance(instance, rowIndex);
1304
+ var _instance1;
1305
+ if (typeof instance === 'string') {
1306
+ _instance1 = this.getInstance(instance, rowIndex);
1403
1307
  } else {
1404
- _instance = instance;
1308
+ _instance1 = instance;
1405
1309
  }
1406
- if (!_instance) {
1310
+ if (!_instance1) {
1407
1311
  return;
1408
1312
  }
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,
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,
1413
1317
  props: props,
1414
1318
  value: value,
1415
1319
  rowIndex: rowIndex
@@ -1483,55 +1387,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1483
1387
  * 如果控件在表头内,则返回-1
1484
1388
  * 如果控件在表内,则返回行下标
1485
1389
  * 如果控件不在明细表内,则返回undefined
1486
- * */ function getInstanceRowIndex(instance) {
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) {
1487
1420
  if (!instance.parent) {
1488
1421
  return;
1489
1422
  }
1490
1423
  var rowIndex;
1491
1424
  // @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;
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
+ }
1504
1439
  }
1505
1440
  }
1506
- } else {
1507
- rowIndex = this.getInstanceRowIndex(instance.parent);
1508
1441
  }
1509
1442
  return rowIndex;
1510
1443
  }
1511
1444
  },
1512
1445
  {
1513
1446
  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) {
1447
+ value: function getInstanceParentControl(instance, controlType) {
1535
1448
  if (!instance.parent) {
1536
1449
  return;
1537
1450
  }
@@ -1579,8 +1492,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1579
1492
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1580
1493
  args[_key] = arguments[_key];
1581
1494
  }
1582
- var _this_runtime;
1583
- return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
1495
+ var _runtime;
1496
+ return (_runtime = this.runtime).registerControlConfig.apply(_runtime, _toConsumableArray(args));
1584
1497
  }
1585
1498
  },
1586
1499
  {
@@ -1592,12 +1505,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1592
1505
  {
1593
1506
  key: "inList",
1594
1507
  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 : {};
1508
+ var _controlIdMapping;
1509
+ var mapping = (_controlIdMapping = this.store.controlIdMapping) !== null && _controlIdMapping !== void 0 ? _controlIdMapping : {};
1597
1510
  var listKey = undefined;
1598
1511
  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);
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);
1601
1514
  if (matched) {
1602
1515
  listKey = key;
1603
1516
  }
@@ -1610,12 +1523,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1610
1523
  {
1611
1524
  key: "register",
1612
1525
  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));
1526
+ function register(control) {
1527
+ return Runtime.register(control, 'Runtime');
1619
1528
  }
1620
1529
  },
1621
1530
  {
@@ -1627,4 +1536,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1627
1536
  ]);
1628
1537
  return Engine;
1629
1538
  }(Watcher);
1539
+ // @ts-ignore
1630
1540
  export { Engine };