@byteluck-fe/model-driven-engine 2.8.1-alpha.0 → 2.8.1-alpha.4

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.
@@ -1471,37 +1471,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1471
1471
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1472
1472
  if (instances.length) {
1473
1473
  var instance = instances[0];
1474
- // if (this.inList(instance.id) === true) {
1475
- if (this.inList(instance.id) !== undefined) {
1476
- var headerInstance = this.getInstanceInSubtableHeader(instance);
1477
- if (headerInstance) {
1478
- instances.unshift(headerInstance);
1479
- }
1480
- }
1481
- } else {
1482
- var _this_getControlIdMapping;
1483
- var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
1484
- var _Object_entries_find;
1485
- var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1486
- var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
1487
- return mapping.children && controlId in mapping.children;
1488
- })) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
1489
- if (subtableId) {
1490
- var subtable = this.getInstance(subtableId);
1491
- // @ts-ignore
1492
- var headerColumn = subtable.props.headers.find(function(column) {
1493
- return column.children.find(function(item) {
1494
- return item.id === controlId;
1495
- });
1496
- });
1497
- if (headerColumn) {
1498
- var headerInstance1 = headerColumn.children.find(function(item) {
1499
- return item.id === controlId;
1500
- });
1501
- if (headerInstance1) {
1502
- instances.unshift(headerInstance1);
1503
- }
1504
- }
1474
+ var headerInstance = this.findSubtableHeadersControl(instance.id);
1475
+ if (headerInstance !== undefined) {
1476
+ instances.unshift(headerInstance);
1505
1477
  }
1506
1478
  }
1507
1479
  }
@@ -1744,18 +1716,29 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1744
1716
  {
1745
1717
  key: "inList",
1746
1718
  value: function inList(controlId) {
1747
- var _this_store_controlIdMapping;
1748
- var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
1749
- var listKey = undefined;
1750
- Object.keys(mapping).some(function(key) {
1751
- var _mapping_key_children, _mapping_key;
1752
- 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);
1753
- if (matched) {
1754
- listKey = key;
1719
+ var mapping = this.store.subtableHeadersControlIdMapping;
1720
+ var subtableId = undefined;
1721
+ for(var key in mapping){
1722
+ if (controlId in mapping[key]) {
1723
+ subtableId = key;
1724
+ break;
1755
1725
  }
1756
- return matched;
1757
- });
1758
- return listKey;
1726
+ }
1727
+ return subtableId;
1728
+ }
1729
+ },
1730
+ {
1731
+ key: "findSubtableHeadersControl",
1732
+ value: function findSubtableHeadersControl(controlId) {
1733
+ var mapping = this.store.subtableHeadersControlIdMapping;
1734
+ var instance = undefined;
1735
+ for(var key in mapping){
1736
+ if (controlId in mapping[key]) {
1737
+ instance = mapping[key][controlId];
1738
+ break;
1739
+ }
1740
+ }
1741
+ return instance;
1759
1742
  }
1760
1743
  }
1761
1744
  ], [
@@ -57,13 +57,15 @@ var Store = /*#__PURE__*/ function() {
57
57
  _define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
58
58
  );
59
59
  _define_property(this, "controlIdMapping", void 0);
60
+ _define_property(this, "subtableHeadersControlIdMapping", void 0);
60
61
  _define_property(this, "defaultState", void 0);
61
- var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
62
+ var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState, subtableHeadersControlIdMapping = _init.subtableHeadersControlIdMapping;
62
63
  this.emptyState = emptyState;
63
64
  this.state = state;
64
65
  this.dataBindMapping = databindMapping;
65
66
  this.controlIdMapping = controlidMapping;
66
67
  this.defaultState = defaultState;
68
+ this.subtableHeadersControlIdMapping = subtableHeadersControlIdMapping;
67
69
  }
68
70
  _create_class(Store, [
69
71
  {
@@ -233,6 +235,7 @@ function init(instance) {
233
235
  var emptyState = {};
234
236
  var databindMapping = {};
235
237
  var controlidMapping = {};
238
+ var subtableHeadersControlIdMapping = {};
236
239
  var defaultState = {};
237
240
  // loopFormControl(instance, (item, children) => {
238
241
  // })
@@ -248,6 +251,7 @@ function init(instance) {
248
251
  buildState(dataViewState, emptyDataViewState, item);
249
252
  buildDataBindMapping(databindMapping, dvId, item);
250
253
  buildControlIdMapping(controlidMapping, dvId, item);
254
+ buildSubtableHeadersControlIdMapping(subtableHeadersControlIdMapping, item);
251
255
  });
252
256
  state[dvId] = {};
253
257
  defaultState[dvId] = dataViewState;
@@ -256,6 +260,7 @@ function init(instance) {
256
260
  return {
257
261
  state: state,
258
262
  defaultState: defaultState,
263
+ subtableHeadersControlIdMapping: subtableHeadersControlIdMapping,
259
264
  emptyState: emptyState,
260
265
  databindMapping: databindMapping,
261
266
  controlidMapping: controlidMapping
@@ -400,4 +405,17 @@ item) {
400
405
  });
401
406
  }
402
407
  }
408
+ function buildSubtableHeadersControlIdMapping(data, // @ts-ignore
409
+ item) {
410
+ if (item.type === CONTROL_TYPE.SUBTABLE) {
411
+ var headersInstances = {};
412
+ item.props.headers.map(// @ts-ignore
413
+ function(item) {
414
+ item.children.map(function(item) {
415
+ Object.assign(headersInstances, _define_property({}, item.id, item));
416
+ });
417
+ });
418
+ Object.assign(data, _define_property({}, item.id, headersInstances));
419
+ }
420
+ }
403
421
  export { Store };
@@ -69,13 +69,13 @@ function _ts_generator(thisArg, body) {
69
69
  trys: [],
70
70
  ops: []
71
71
  };
72
- return(g = {
72
+ return g = {
73
73
  next: verb(0),
74
74
  "throw": verb(1),
75
75
  "return": verb(2)
76
76
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
77
77
  return this;
78
- }), g);
78
+ }), g;
79
79
  function verb(n) {
80
80
  return function(v) {
81
81
  return step([
@@ -115,13 +115,13 @@ function _ts_generator(thisArg, body) {
115
115
  trys: [],
116
116
  ops: []
117
117
  };
118
- return(g = {
118
+ return g = {
119
119
  next: verb(0),
120
120
  "throw": verb(1),
121
121
  "return": verb(2)
122
122
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
123
123
  return this;
124
- }), g);
124
+ }), g;
125
125
  function verb(n) {
126
126
  return function(v) {
127
127
  return step([