@byteluck-fe/model-driven-engine 2.2.1-test.2 → 2.2.2-beta.12

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.
@@ -738,6 +738,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
738
738
  _proto.updateInstanceProps = function updateInstanceProps(instance, props, value, rowIndex) {
739
739
  return this.setInstance(instance, props, value, rowIndex);
740
740
  };
741
+ _proto.getAllRules = function getAllRules(controlId) {
742
+ var rules = this.runtime.allRules;
743
+ if (controlId === undefined) {
744
+ return rules;
745
+ } else {
746
+ var _rules_rules_controlId, _rules_antdRules_controlId;
747
+ return {
748
+ rules: (_rules_rules_controlId = rules.rules[controlId]) === null || _rules_rules_controlId === void 0 ? void 0 : _rules_rules_controlId.fields,
749
+ antdRules: (_rules_antdRules_controlId = rules.antdRules[controlId]) === null || _rules_antdRules_controlId === void 0 ? void 0 : _rules_antdRules_controlId.fields
750
+ };
751
+ }
752
+ };
741
753
  _proto.getRules = function getRules(controlId) {
742
754
  if (controlId === undefined) {
743
755
  return this.runtime.rules;
@@ -1138,7 +1150,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1138
1150
  * @param header 明细表内是否获取表头的控件
1139
1151
  */ _proto.getInstances = function getInstances(controlId) {
1140
1152
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1153
+ // const cc = console
1154
+ // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
1155
+ // cc.time(label)
1141
1156
  if (controlId === undefined) {
1157
+ // cc.timeEnd(label)
1142
1158
  return this.runtime.flatInstances;
1143
1159
  }
1144
1160
  var instances = this.runtime.instanceMap[controlId] || [];
@@ -1342,3 +1358,4 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1342
1358
  return Engine;
1343
1359
  }(Watcher);
1344
1360
  export { Engine };
1361
+ console.log("a");
@@ -146,6 +146,31 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
146
146
  return this._instanceMap;
147
147
  }
148
148
  },
149
+ {
150
+ key: "allRules",
151
+ get: function get() {
152
+ var antdRules = {};
153
+ var ruleItems = {};
154
+ loopDataViewControl(this._instance, function(dataView) {
155
+ ruleItems[dataView.id] = dataView.rules[0];
156
+ antdRules[dataView.id] = dataView.rules[0];
157
+ loopFormControl(dataView.children, function(item) {
158
+ // if (
159
+ // item instanceof RuntimeFormControl ||
160
+ // item instanceof RuntimeListControl
161
+ // ) {
162
+ if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
163
+ buildControlRules(ruleItems[dataView.id].fields, item);
164
+ buildControlAntdRules(antdRules[dataView.id].fields, item);
165
+ }
166
+ });
167
+ });
168
+ return {
169
+ rules: ruleItems,
170
+ antdRules: antdRules
171
+ };
172
+ }
173
+ },
149
174
  {
150
175
  key: "rules",
151
176
  get: function get() {
@@ -234,7 +234,7 @@ function flatInstanceForChildren(controls) {
234
234
  return otherKeys.reduce(function(prevItem, key) {
235
235
  var index = Number(key);
236
236
  var isNotIndex = Number.isNaN(index);
237
- if (isNotIndex) {
237
+ if (isNotIndex && prevItem) {
238
238
  var flatChildren = (prevItem === null || prevItem === void 0 ? void 0 : prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
239
239
  var findEndItem = flatChildren === null || flatChildren === void 0 ? void 0 : flatChildren.find(function(item) {
240
240
  return item.id === key;
@@ -12,6 +12,7 @@ export function loopFormControl(control, callback) {
12
12
  callback(item, children);
13
13
  } else if (hasChildrenControl(item)) {
14
14
  loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
15
+ // @ts-ignore
15
16
  } else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
16
17
  callback(item);
17
18
  }