@byteluck-fe/model-driven-engine 2.8.1-alpha.7 → 2.8.1-alpha.9

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.
@@ -96,7 +96,7 @@ function _create_super(Derived) {
96
96
  return _possible_constructor_return(this, result);
97
97
  };
98
98
  }
99
- import { RegisterControls } from "@byteluck-fe/model-driven-core";
99
+ import { RegisterControls, isDataBind } from "@byteluck-fe/model-driven-core";
100
100
  import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from "@byteluck-fe/model-driven-shared";
101
101
  import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
102
102
  export var Runtime = /*#__PURE__*/ function(RegisterControls) {
@@ -353,8 +353,24 @@ item) {
353
353
  var result = Runtime.staticGetRules(item.type, item.props);
354
354
  // if (item instanceof RuntimeFormControl) {
355
355
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
356
- var _item_props_dataBind;
357
- data[((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) || item.id] = result;
356
+ if (isDataBind(item.props.dataBind)) {
357
+ var _item_props_dataBind;
358
+ if (((_item_props_dataBind = item.props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.fieldCode) != "") {
359
+ var _item_props_dataBind1;
360
+ data[(_item_props_dataBind1 = item.props.dataBind) === null || _item_props_dataBind1 === void 0 ? void 0 : _item_props_dataBind1.fieldCode] = result;
361
+ }
362
+ } else {
363
+ for(var dataBindKey in item.props.dataBind){
364
+ var _item_props_dataBind_dataBindKey;
365
+ // @ts-ignore
366
+ if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != "") {
367
+ var // @ts-ignore
368
+ _item_props_dataBind_dataBindKey1, _result_;
369
+ // @ts-ignore
370
+ data[(_item_props_dataBind_dataBindKey1 = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey1 === void 0 ? void 0 : _item_props_dataBind_dataBindKey1.fieldCode] = ((_result_ = result[0]) === null || _result_ === void 0 ? void 0 : _result_.fields[dataBindKey]) || [];
371
+ }
372
+ }
373
+ }
358
374
  } else if (item.type === CONTROL_TYPE.SUBTABLE) {
359
375
  var _item_props_datasourceBind, _item_props_datasourceBind1;
360
376
  data[(_item_props_datasourceBind = item.props.datasourceBind) === null || _item_props_datasourceBind === void 0 ? void 0 : _item_props_datasourceBind.dataCode] = result;
@@ -365,7 +381,6 @@ item) {
365
381
  item.children.forEach(function(row, index) {
366
382
  loopFormSchema(row.children, function(formControl) {
367
383
  if (itemRules.fields) {
368
- var _formControl_props_dataBind;
369
384
  if (!itemRules.fields[index]) {
370
385
  itemRules.fields[index] = {
371
386
  type: "object",
@@ -373,13 +388,26 @@ item) {
373
388
  fields: {}
374
389
  };
375
390
  }
376
- // // @ts-ignore
377
- // itemRules.fields[index].fields[formControl.id] = (
378
- // formControl as RuntimeFormControl
379
- // ).rules
380
391
  var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
381
- // @ts-ignore
382
- itemRules.fields[index].fields[((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) || formControl.id] = childResult;
392
+ if (!isDataBind(formControl.props.dataBind)) {
393
+ for(var dataBindKey in formControl.props.dataBind){
394
+ var _formControl_props_dataBind_dataBindKey;
395
+ // @ts-ignore
396
+ if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != "") {
397
+ var _childResult_;
398
+ // @ts-ignore
399
+ itemRules.fields[index].fields[// @ts-ignore
400
+ formControl.props.dataBind[dataBindKey].fieldCode] = ((_childResult_ = childResult[0]) === null || _childResult_ === void 0 ? void 0 : _childResult_.fields[dataBindKey]) || [];
401
+ }
402
+ }
403
+ } else {
404
+ var _formControl_props_dataBind;
405
+ if (((_formControl_props_dataBind = formControl.props.dataBind) === null || _formControl_props_dataBind === void 0 ? void 0 : _formControl_props_dataBind.fieldCode) != "") {
406
+ var _formControl_props_dataBind1;
407
+ // @ts-ignore
408
+ itemRules.fields[index].fields[(_formControl_props_dataBind1 = formControl.props.dataBind) === null || _formControl_props_dataBind1 === void 0 ? void 0 : _formControl_props_dataBind1.fieldCode] = childResult;
409
+ }
410
+ }
383
411
  }
384
412
  });
385
413
  });