@byteluck-fe/model-driven-engine 2.5.1 → 2.5.3

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.
@@ -1,15 +1,15 @@
1
- function _arrayLikeToArray(arr, len) {
1
+ function _array_like_to_array(arr, len) {
2
2
  if (len == null || len > arr.length) len = arr.length;
3
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
4
  return arr2;
5
5
  }
6
- function _arrayWithHoles(arr) {
6
+ function _array_with_holes(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
- function _arrayWithoutHoles(arr) {
10
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
11
  }
12
- function _assertThisInitialized(self) {
12
+ function _assert_this_initialized(self) {
13
13
  if (self === void 0) {
14
14
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
15
15
  }
@@ -29,7 +29,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
29
29
  Promise.resolve(value).then(_next, _throw);
30
30
  }
31
31
  }
32
- function _asyncToGenerator(fn) {
32
+ function _async_to_generator(fn) {
33
33
  return function() {
34
34
  var self = this, args = arguments;
35
35
  return new Promise(function(resolve, reject) {
@@ -44,7 +44,7 @@ function _asyncToGenerator(fn) {
44
44
  });
45
45
  };
46
46
  }
47
- function _classCallCheck(instance, Constructor) {
47
+ function _class_call_check(instance, Constructor) {
48
48
  if (!(instance instanceof Constructor)) {
49
49
  throw new TypeError("Cannot call a class as a function");
50
50
  }
@@ -58,12 +58,12 @@ function _defineProperties(target, props) {
58
58
  Object.defineProperty(target, descriptor.key, descriptor);
59
59
  }
60
60
  }
61
- function _createClass(Constructor, protoProps, staticProps) {
61
+ function _create_class(Constructor, protoProps, staticProps) {
62
62
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
63
63
  if (staticProps) _defineProperties(Constructor, staticProps);
64
64
  return Constructor;
65
65
  }
66
- function _defineProperty(obj, key, value) {
66
+ function _define_property(obj, key, value) {
67
67
  if (key in obj) {
68
68
  Object.defineProperty(obj, key, {
69
69
  value: value,
@@ -80,23 +80,23 @@ function _get(target, property, receiver) {
80
80
  if (typeof Reflect !== "undefined" && Reflect.get) {
81
81
  _get = Reflect.get;
82
82
  } else {
83
- _get = function _get(target, property, receiver) {
84
- var base = _superPropBase(target, property);
83
+ _get = function get(target, property, receiver) {
84
+ var base = _super_prop_base(target, property);
85
85
  if (!base) return;
86
86
  var desc = Object.getOwnPropertyDescriptor(base, property);
87
87
  if (desc.get) {
88
- return desc.get.call(receiver);
88
+ return desc.get.call(receiver || target);
89
89
  }
90
90
  return desc.value;
91
91
  };
92
92
  }
93
93
  return _get(target, property, receiver || target);
94
94
  }
95
- function _getPrototypeOf(o) {
96
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
95
+ function _get_prototype_of(o) {
96
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
97
97
  return o.__proto__ || Object.getPrototypeOf(o);
98
98
  };
99
- return _getPrototypeOf(o);
99
+ return _get_prototype_of(o);
100
100
  }
101
101
  function _inherits(subClass, superClass) {
102
102
  if (typeof superClass !== "function" && superClass !== null) {
@@ -109,7 +109,7 @@ function _inherits(subClass, superClass) {
109
109
  configurable: true
110
110
  }
111
111
  });
112
- if (superClass) _setPrototypeOf(subClass, superClass);
112
+ if (superClass) _set_prototype_of(subClass, superClass);
113
113
  }
114
114
  function _instanceof(left, right) {
115
115
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
@@ -118,10 +118,10 @@ function _instanceof(left, right) {
118
118
  return left instanceof right;
119
119
  }
120
120
  }
121
- function _iterableToArray(iter) {
121
+ function _iterable_to_array(iter) {
122
122
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
123
123
  }
124
- function _iterableToArrayLimit(arr, i) {
124
+ function _iterable_to_array_limit(arr, i) {
125
125
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
126
126
  if (_i == null) return;
127
127
  var _arr = [];
@@ -145,13 +145,13 @@ function _iterableToArrayLimit(arr, i) {
145
145
  }
146
146
  return _arr;
147
147
  }
148
- function _nonIterableRest() {
148
+ function _non_iterable_rest() {
149
149
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
150
150
  }
151
- function _nonIterableSpread() {
151
+ function _non_iterable_spread() {
152
152
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
153
153
  }
154
- function _objectSpread(target) {
154
+ function _object_spread(target) {
155
155
  for(var i = 1; i < arguments.length; i++){
156
156
  var source = arguments[i] != null ? arguments[i] : {};
157
157
  var ownKeys = Object.keys(source);
@@ -161,7 +161,7 @@ function _objectSpread(target) {
161
161
  }));
162
162
  }
163
163
  ownKeys.forEach(function(key) {
164
- _defineProperty(target, key, source[key]);
164
+ _define_property(target, key, source[key]);
165
165
  });
166
166
  }
167
167
  return target;
@@ -179,7 +179,7 @@ function ownKeys(object, enumerableOnly) {
179
179
  }
180
180
  return keys;
181
181
  }
182
- function _objectSpreadProps(target, source) {
182
+ function _object_spread_props(target, source) {
183
183
  source = source != null ? source : {};
184
184
  if (Object.getOwnPropertyDescriptors) {
185
185
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
@@ -190,45 +190,45 @@ function _objectSpreadProps(target, source) {
190
190
  }
191
191
  return target;
192
192
  }
193
- function _possibleConstructorReturn(self, call) {
194
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
193
+ function _possible_constructor_return(self, call) {
194
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
195
195
  return call;
196
196
  }
197
- return _assertThisInitialized(self);
197
+ return _assert_this_initialized(self);
198
198
  }
199
- function _setPrototypeOf(o, p) {
200
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
199
+ function _set_prototype_of(o, p) {
200
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
201
201
  o.__proto__ = p;
202
202
  return o;
203
203
  };
204
- return _setPrototypeOf(o, p);
204
+ return _set_prototype_of(o, p);
205
205
  }
206
- function _slicedToArray(arr, i) {
207
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
206
+ function _sliced_to_array(arr, i) {
207
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
208
208
  }
209
- function _superPropBase(object, property) {
209
+ function _super_prop_base(object, property) {
210
210
  while(!Object.prototype.hasOwnProperty.call(object, property)){
211
- object = _getPrototypeOf(object);
211
+ object = _get_prototype_of(object);
212
212
  if (object === null) break;
213
213
  }
214
214
  return object;
215
215
  }
216
- function _toConsumableArray(arr) {
217
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
216
+ function _to_consumable_array(arr) {
217
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
218
218
  }
219
- var _typeof = function(obj) {
219
+ function _type_of(obj) {
220
220
  "@swc/helpers - typeof";
221
221
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
222
- };
223
- function _unsupportedIterableToArray(o, minLen) {
222
+ }
223
+ function _unsupported_iterable_to_array(o, minLen) {
224
224
  if (!o) return;
225
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
225
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
226
226
  var n = Object.prototype.toString.call(o).slice(8, -1);
227
227
  if (n === "Object" && o.constructor) n = o.constructor.name;
228
228
  if (n === "Map" || n === "Set") return Array.from(n);
229
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
229
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
230
230
  }
231
- function _isNativeReflectConstruct() {
231
+ function _is_native_reflect_construct() {
232
232
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
233
233
  if (Reflect.construct.sham) return false;
234
234
  if (typeof Proxy === "function") return true;
@@ -239,20 +239,20 @@ function _isNativeReflectConstruct() {
239
239
  return false;
240
240
  }
241
241
  }
242
- function _createSuper(Derived) {
243
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
242
+ function _create_super(Derived) {
243
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
244
244
  return function _createSuperInternal() {
245
- var Super = _getPrototypeOf(Derived), result;
245
+ var Super = _get_prototype_of(Derived), result;
246
246
  if (hasNativeReflectConstruct) {
247
- var NewTarget = _getPrototypeOf(this).constructor;
247
+ var NewTarget = _get_prototype_of(this).constructor;
248
248
  result = Reflect.construct(Super, arguments, NewTarget);
249
249
  } else {
250
250
  result = Super.apply(this, arguments);
251
251
  }
252
- return _possibleConstructorReturn(this, result);
252
+ return _possible_constructor_return(this, result);
253
253
  };
254
254
  }
255
- var __generator = this && this.__generator || function(thisArg, body) {
255
+ function _ts_generator(thisArg, body) {
256
256
  var f, y, t, g, _ = {
257
257
  label: 0,
258
258
  sent: function() {
@@ -346,7 +346,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
346
346
  done: true
347
347
  };
348
348
  }
349
- };
349
+ }
350
350
  import { DataBind, ObjectDataBind, RuntimeListControl } from "@byteluck-fe/model-driven-core";
351
351
  import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
352
352
  import { Runtime } from "./Runtime";
@@ -355,6 +355,7 @@ import { findItem, proxyState } from "./proxyState";
355
355
  import { ActionManager } from "./ActionManager";
356
356
  import { DataManager } from "./DataManager";
357
357
  import { checkerSubtableValue, checkerValue } from "./checkerValue";
358
+ import { buildUUID } from "../utils/runtimeUtils";
358
359
  if (typeof window !== "undefined") {
359
360
  // @ts-ignore
360
361
  window.engines = {};
@@ -367,29 +368,29 @@ var applyingPluginName = "";
367
368
  var Engine = /*#__PURE__*/ function(Watcher) {
368
369
  "use strict";
369
370
  _inherits(Engine, Watcher);
370
- var _super = _createSuper(Engine);
371
+ var _super = _create_super(Engine);
371
372
  function Engine(props) {
372
- _classCallCheck(this, Engine);
373
+ _class_call_check(this, Engine);
373
374
  var _this;
374
375
  _this = _super.call(this);
375
- _defineProperty(_assertThisInitialized(_this), "store", void 0);
376
- _defineProperty(_assertThisInitialized(_this), "rawStore", {});
377
- _defineProperty(_assertThisInitialized(_this), "parent", void 0);
376
+ _define_property(_assert_this_initialized(_this), "store", void 0);
377
+ _define_property(_assert_this_initialized(_this), "rawStore", {});
378
+ _define_property(_assert_this_initialized(_this), "parent", void 0);
378
379
  // 提供注册运行态控件以及实例化控件的能力
379
- _defineProperty(_assertThisInitialized(_this), "runtime", void 0);
380
+ _define_property(_assert_this_initialized(_this), "runtime", void 0);
380
381
  // 提供子线程处理脚本以及修改数据的能力
381
382
  // public worker: OkWorker
382
- _defineProperty(_assertThisInitialized(_this), "isMounted", false);
383
- _defineProperty(_assertThisInitialized(_this), "id", genNonDuplicateId(8));
384
- _defineProperty(_assertThisInitialized(_this), "externalParams", void 0);
383
+ _define_property(_assert_this_initialized(_this), "isMounted", false);
384
+ _define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
385
+ _define_property(_assert_this_initialized(_this), "externalParams", void 0);
385
386
  // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
386
- _defineProperty(_assertThisInitialized(_this), "__plugins", void 0);
387
- _defineProperty(_assertThisInitialized(_this), "__pluginsApplied", false);
388
- _defineProperty(_assertThisInitialized(_this), "$options", void 0);
389
- _defineProperty(_assertThisInitialized(_this), "actionManager", new ActionManager());
390
- _defineProperty(_assertThisInitialized(_this), "dataManager", void 0);
391
- _defineProperty(_assertThisInitialized(_this), "_jobTasks", []);
392
- _defineProperty(_assertThisInitialized(_this), "createControlInstance", _this.createInstance);
387
+ _define_property(_assert_this_initialized(_this), "__plugins", void 0);
388
+ _define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
389
+ _define_property(_assert_this_initialized(_this), "$options", void 0);
390
+ _define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
391
+ _define_property(_assert_this_initialized(_this), "dataManager", void 0);
392
+ _define_property(_assert_this_initialized(_this), "_jobTasks", []);
393
+ _define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
393
394
  _this.$options = Object.freeze(props);
394
395
  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,
395
396
  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;
@@ -408,14 +409,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
408
409
  autoMount && _this.mount();
409
410
  return _this;
410
411
  }
411
- _createClass(Engine, [
412
+ _create_class(Engine, [
412
413
  {
413
414
  key: "debugLog",
414
415
  value: function debugLog() {
415
416
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
416
417
  args[_key] = arguments[_key];
417
418
  }
418
- this.debug && log.apply(void 0, _toConsumableArray(args));
419
+ this.debug && log.apply(void 0, _to_consumable_array(args));
419
420
  }
420
421
  },
421
422
  {
@@ -435,7 +436,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
435
436
  arg[_key] = arguments[_key];
436
437
  }
437
438
  var _this_runtime;
438
- (_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
439
+ (_this_runtime = this.runtime).register.apply(_this_runtime, _to_consumable_array(arg));
439
440
  return this;
440
441
  }
441
442
  },
@@ -552,7 +553,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
552
553
  var newRowLengths = args.length;
553
554
  createdNewRows = createRows(newRowLengths);
554
555
  createdNewRowsData = args;
555
- (_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
556
+ (_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
556
557
  this.runtime.getFlatInstances();
557
558
  break;
558
559
  case "splice":
@@ -570,7 +571,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
570
571
  (_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
571
572
  start,
572
573
  replace
573
- ].concat(_toConsumableArray(createdNewRows)));
574
+ ].concat(_to_consumable_array(createdNewRows)));
574
575
  this.runtime.getFlatInstances();
575
576
  // newValues.forEach((item: any, index) => {
576
577
  // let newIndex = start + index
@@ -579,14 +580,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
579
580
  } else {
580
581
  var // @ts-ignore
581
582
  _subtable_children2;
582
- (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
583
+ (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
583
584
  this.runtime.getFlatInstances();
584
585
  }
585
586
  break;
586
587
  default:
587
588
  var // @ts-ignore
588
589
  _subtable_children3;
589
- (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
590
+ (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
590
591
  this.runtime.getFlatInstances();
591
592
  break;
592
593
  }
@@ -600,14 +601,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
600
601
  result
601
602
  ];
602
603
  }
604
+ var subtableData = this.getState(subtable.id);
605
+ this._handlerSubtableUpdateUid(subtableData);
603
606
  this.emit("list-change", {
604
607
  instance: subtable,
605
- value: this.getState(subtable.id),
608
+ value: subtableData,
606
609
  options: Object.assign({}, options, {
607
610
  changed: createdNewRows,
608
611
  data: createdNewRowsData,
609
612
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
610
- jsonValue: JSON.stringify(this.getState(subtable.id))
613
+ jsonValue: JSON.stringify(subtableData)
611
614
  })
612
615
  });
613
616
  // 主动清空本次任务中的options
@@ -615,6 +618,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
615
618
  }
616
619
  }
617
620
  },
621
+ {
622
+ key: "_handlerSubtableUpdateUid",
623
+ value: function _handlerSubtableUpdateUid(subtableData) {
624
+ subtableData.forEach(function(item) {
625
+ if (!item.uid) {
626
+ Object.assign(item, {
627
+ uid: "new:" + buildUUID("uid")
628
+ });
629
+ }
630
+ });
631
+ }
632
+ },
618
633
  {
619
634
  key: "_handlerObjectUpdate",
620
635
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
@@ -637,20 +652,28 @@ var Engine = /*#__PURE__*/ function(Watcher) {
637
652
  var row = this.listControlCreateRow(instance, "subtable-row");
638
653
  row && newRows.push(row);
639
654
  }
640
- (_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
655
+ (_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
641
656
  this.runtime.getFlatInstances();
642
657
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
643
658
  // for (let i = 0; i < newValue.length; i++) {
644
659
  // this.setStates(newValue[i], i, options)
645
660
  // }
661
+ var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
662
+ if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
663
+ deleted = [];
664
+ }
665
+ this._handlerSubtableUpdateUid(newValue);
646
666
  this.emit("list-change", {
647
667
  instance: instance,
648
668
  value: value,
649
- options: _objectSpreadProps(_objectSpread({}, options), {
669
+ options: _object_spread_props(_object_spread({}, options), {
650
670
  // @ts-ignore
651
671
  changed: newRows,
652
672
  data: newValue,
653
- deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
673
+ deleted: deleted,
674
+ // deleted: oldValue ?? [],
675
+ type: "push",
676
+ jsonValue: JSON.stringify(newValue)
654
677
  })
655
678
  });
656
679
  } else {
@@ -658,7 +681,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
658
681
  instance: instance,
659
682
  value: this.getState(instance.id, index),
660
683
  rowIndex: index,
661
- options: _objectSpreadProps(_objectSpread({}, options), {
684
+ options: _object_spread_props(_object_spread({}, options), {
662
685
  oldValue: oldValue
663
686
  })
664
687
  });
@@ -697,7 +720,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
697
720
  var template = JSONCopy(instance.props.headers);
698
721
  // @ts-ignore
699
722
  var columns = this.createControl(template);
700
- (_inst_children = inst.children).push.apply(_inst_children, _toConsumableArray(columns));
723
+ (_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
701
724
  }
702
725
  return row;
703
726
  }
@@ -718,11 +741,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
718
741
  function emit(eventKey, payload) {
719
742
  var _this = this;
720
743
  var _this1 = this, _superprop_get_emit = function() {
721
- return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
744
+ return _get(_get_prototype_of(Engine.prototype), "emit", _this);
722
745
  };
723
- return _asyncToGenerator(function() {
746
+ return _async_to_generator(function() {
724
747
  var needWait, promiseResolver, promise, results;
725
- return __generator(this, function(_state) {
748
+ return _ts_generator(this, function(_state) {
726
749
  switch(_state.label){
727
750
  case 0:
728
751
  if (!(eventKey === "engine-mounted")) return [
@@ -741,7 +764,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
741
764
  2
742
765
  ];
743
766
  console.time("engine-mounted need wait");
744
- needWait = _toConsumableArray(_this1._jobTasks);
767
+ needWait = _to_consumable_array(_this1._jobTasks);
745
768
  return [
746
769
  4,
747
770
  Promise.all(needWait)
@@ -787,7 +810,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
787
810
  if (applyingPluginName) {
788
811
  callback.applyingPluginName = applyingPluginName;
789
812
  }
790
- return _get(_getPrototypeOf(Engine.prototype), "on", this).call(this, key, callback);
813
+ return _get(_get_prototype_of(Engine.prototype), "on", this).call(this, key, callback);
791
814
  }
792
815
  },
793
816
  {
@@ -797,7 +820,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
797
820
  args[_key] = arguments[_key];
798
821
  }
799
822
  var _this_runtime;
800
- return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
823
+ return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _to_consumable_array(args));
801
824
  }
802
825
  },
803
826
  {
@@ -904,7 +927,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
904
927
  var newStates = states !== null && states !== void 0 ? states : {};
905
928
  Object.keys(newStates).forEach(function(stateId) {
906
929
  Object.entries(_this.store.controlIdMapping).forEach(function(param) {
907
- var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
930
+ var _param = _sliced_to_array(param, 2), controlId = _param[0], controlIdMapping = _param[1];
908
931
  if (controlIdMapping.dataView === stateId) {
909
932
  // state对象是dataView包裹的
910
933
  var value = newStates[stateId][controlId];
@@ -947,7 +970,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
947
970
  var state = this.getState(controlId1, rowIndex);
948
971
  if (_instanceof(dataBind, ObjectDataBind)) {
949
972
  return Object.entries(dataBind).reduce(function(result, param) {
950
- var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
973
+ var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
951
974
  // objectDataBind的元素,跳过下一次赋值
952
975
  if (dataBind.fieldCode === fieldCode) {
953
976
  return result[key];
@@ -973,8 +996,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
973
996
  var data = getFieldData.map(function(item) {
974
997
  var obj = {};
975
998
  for(var key in item){
976
- var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind;
977
- 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;
999
+ var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
1000
+ var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _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;
978
1001
  //未绑定字段的控件,直接抛弃
979
1002
  if (fieldCode !== "") {
980
1003
  var _controlIdMapping_controlId1;
@@ -984,7 +1007,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
984
1007
  // 兼容一个控件需要绑定多个字段的情况
985
1008
  for(var keyChi in item[key]){
986
1009
  var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
987
- 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];
1010
+ obj[(_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : (_controlIdMapping_controlId_children_key1 = _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
988
1011
  }
989
1012
  }
990
1013
  }
@@ -994,7 +1017,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
994
1017
  return data;
995
1018
  } else {
996
1019
  var _loop = function(key) {
997
- var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
1020
+ var _controlIdMapping_key_dataBind, _controlIdMapping_key, _controlIdMapping_key_dataBind1, _controlIdMapping_key1;
998
1021
  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) {
999
1022
  var _controlIdMapping_key2;
1000
1023
  obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
@@ -1024,7 +1047,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1024
1047
  // 兼容一个控件需要绑定多个字段的情况
1025
1048
  for(var keyChi in getFieldData[key]){
1026
1049
  var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
1027
- 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];
1050
+ obj[(_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : (_controlIdMapping_key_dataBind_keyChi = _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
1028
1051
  }
1029
1052
  }
1030
1053
  };
@@ -1057,7 +1080,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1057
1080
  var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
1058
1081
  // fieldCode不代表是key,所以需要找到对应的key
1059
1082
  var newState = Object.entries(dataBind).reduce(function(result, param) {
1060
- var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1083
+ var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
1061
1084
  // objectDataBind的元素,跳过下一次赋值
1062
1085
  if (dataBind.fieldCode === fieldCode) {
1063
1086
  result[key] = value;
@@ -1099,7 +1122,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1099
1122
  var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
1100
1123
  // fieldCode不代表是key,所以需要找到对应的key
1101
1124
  var newState = Object.entries(dataBind).reduce(function(result, param) {
1102
- var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1125
+ var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
1103
1126
  // objectDataBind的元素,跳过下一次赋值
1104
1127
  skipKeys.push(dataBind.fieldCode);
1105
1128
  var value = state[dataBind.fieldCode];
@@ -1142,7 +1165,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1142
1165
  var oldState = _this.getEmptyState(controlId);
1143
1166
  // fieldCode不代表是key,所以需要找到对应的key
1144
1167
  result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
1145
- var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
1168
+ var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
1146
1169
  // objectDataBind的元素,跳过下一次赋值
1147
1170
  skipKeys.push(dataBind.fieldCode);
1148
1171
  var value = state[dataBind.fieldCode];
@@ -1189,7 +1212,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1189
1212
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1190
1213
  ;
1191
1214
  Object.keys(row).map(function(fieldCode) {
1192
- var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
1215
+ var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
1193
1216
  if (skipKey.includes(fieldCode)) {
1194
1217
  return;
1195
1218
  }
@@ -1261,9 +1284,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1261
1284
  mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1262
1285
  if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1263
1286
  if (Object.keys(newState).length) {
1264
- Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
1287
+ Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
1265
1288
  } else {
1266
- Object.assign(newState, _defineProperty({}, newMapping.controlId, _defineProperty({}, key, mappingValue[key])));
1289
+ Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
1267
1290
  }
1268
1291
  }
1269
1292
  });
@@ -1327,36 +1350,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1327
1350
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1328
1351
  if (instances.length) {
1329
1352
  var instance = instances[0];
1330
- if (this.inList(instance.id) !== undefined) {
1331
- var headerInstance = this.getInstanceInSubtableHeader(instance);
1332
- if (headerInstance) {
1333
- instances.unshift(headerInstance);
1334
- }
1335
- }
1336
- } else {
1337
- var _this_getControlIdMapping;
1338
- var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
1339
- var _Object_entries_find;
1340
- var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1341
- var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
1342
- return mapping.children && controlId in mapping.children;
1343
- })) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
1344
- if (subtableId) {
1345
- var subtable = this.getInstance(subtableId);
1346
- // @ts-ignore
1347
- var headerColumn = subtable.props.headers.find(function(column) {
1348
- return column.children.find(function(item) {
1349
- return item.id === controlId;
1350
- });
1351
- });
1352
- if (headerColumn) {
1353
- var headerInstance1 = headerColumn.children.find(function(item) {
1354
- return item.id === controlId;
1355
- });
1356
- if (headerInstance1) {
1357
- instances.unshift(headerInstance1);
1358
- }
1359
- }
1353
+ var headerInstance = this.findSubtableHeadersControl(instance.id);
1354
+ if (headerInstance !== undefined) {
1355
+ instances.unshift(headerInstance);
1360
1356
  }
1361
1357
  }
1362
1358
  }
@@ -1548,7 +1544,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1548
1544
  args[_key] = arguments[_key];
1549
1545
  }
1550
1546
  var _this_runtime;
1551
- return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
1547
+ return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _to_consumable_array(args));
1552
1548
  }
1553
1549
  },
1554
1550
  {
@@ -1560,18 +1556,29 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1560
1556
  {
1561
1557
  key: "inList",
1562
1558
  value: function inList(controlId) {
1563
- var _this_store_controlIdMapping;
1564
- var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
1565
- var listKey = undefined;
1566
- Object.keys(mapping).some(function(key) {
1567
- var _mapping_key, _mapping_key_children;
1568
- 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);
1569
- if (matched) {
1570
- listKey = key;
1559
+ var mapping = this.store.subtableHeadersControlIdMapping;
1560
+ var subtableId = undefined;
1561
+ for(var key in mapping){
1562
+ if (controlId in mapping[key]) {
1563
+ subtableId = key;
1564
+ break;
1571
1565
  }
1572
- return matched;
1573
- });
1574
- return listKey;
1566
+ }
1567
+ return subtableId;
1568
+ }
1569
+ },
1570
+ {
1571
+ key: "findSubtableHeadersControl",
1572
+ value: function findSubtableHeadersControl(controlId) {
1573
+ var mapping = this.store.subtableHeadersControlIdMapping;
1574
+ var instance = undefined;
1575
+ for(var key in mapping){
1576
+ if (controlId in mapping[key]) {
1577
+ instance = mapping[key][controlId];
1578
+ break;
1579
+ }
1580
+ }
1581
+ return instance;
1575
1582
  }
1576
1583
  }
1577
1584
  ], [
@@ -1583,7 +1590,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1583
1590
  arg[_key] = arguments[_key];
1584
1591
  }
1585
1592
  var _Runtime;
1586
- return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
1593
+ return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
1587
1594
  }
1588
1595
  },
1589
1596
  {