@byteluck-fe/model-driven-engine 2.8.0-alpha.1 → 2.8.0-alpha.1b

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.
@@ -693,7 +693,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
693
693
  {
694
694
  key: "listControlCreateRow",
695
695
  value: function listControlCreateRow(instance, rowType) {
696
- var row = this.runtime.createControlInstance(rowType);
696
+ var row;
697
+ if (rowType === "subtable-row") {
698
+ row = {
699
+ children: [],
700
+ controlType: CONTROL_BASE_TYPE.LAYOUT,
701
+ id: genNonDuplicateId(),
702
+ type: "subtable-row",
703
+ props: {
704
+ caption: "",
705
+ isHide: false,
706
+ style: {
707
+ height: "",
708
+ heightConfig: "fill",
709
+ width: "",
710
+ widthConfig: "fill"
711
+ }
712
+ },
713
+ fieldType: undefined,
714
+ customEvents: [],
715
+ pageStatus: 0,
716
+ rules: [],
717
+ parent: undefined
718
+ };
719
+ } else {
720
+ row = this.runtime.createControlInstance(rowType);
721
+ }
697
722
  if (!row) return;
698
723
  // if (row instanceof RuntimeLayoutControl) {
699
724
  // @ts-ignore
@@ -703,8 +728,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
703
728
  var template = JSONCopy(instance.props.headers);
704
729
  // @ts-ignore
705
730
  var columns = this.createControl(template);
731
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
732
+ try {
733
+ for(var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
734
+ var column = _step.value;
735
+ if (!column.parent) {
736
+ this.runtime.resetInstanceParent(column, inst);
737
+ }
738
+ }
739
+ } catch (err) {
740
+ _didIteratorError = true;
741
+ _iteratorError = err;
742
+ } finally{
743
+ try {
744
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
745
+ _iterator.return();
746
+ }
747
+ } finally{
748
+ if (_didIteratorError) {
749
+ throw _iteratorError;
750
+ }
751
+ }
752
+ }
706
753
  (_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
707
754
  }
755
+ //@ts-ignore
756
+ row.parent = instance;
708
757
  return row;
709
758
  }
710
759
  },
@@ -824,6 +873,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
824
873
  return this.setInstance(instance, props, value, rowIndex);
825
874
  }
826
875
  },
876
+ {
877
+ key: "getRule",
878
+ value: function getRule(controlType, props) {
879
+ return Runtime.staticGetRules(controlType, props);
880
+ }
881
+ },
827
882
  {
828
883
  key: "getAllRules",
829
884
  value: function getAllRules(controlId) {
@@ -1133,7 +1188,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1133
1188
  value: function buildFields(dataCode, state) {
1134
1189
  var _this = this;
1135
1190
  var mapping = this.getDataBindMapping(dataCode);
1136
- if (!mapping) {
1191
+ if (!mapping || !mapping.fields) {
1137
1192
  return;
1138
1193
  }
1139
1194
  var skipKeys = [];
@@ -1194,26 +1249,34 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1194
1249
  } else {
1195
1250
  newState[mapping.dataViewId][mapping.controlId] = [];
1196
1251
  }
1252
+ var cacheEmptyState = {};
1253
+ var cacheFieldMapping = {};
1197
1254
  entity.map(function(row) {
1198
1255
  var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
1199
1256
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1200
1257
  ;
1201
1258
  Object.keys(row).map(function(fieldCode) {
1202
- var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
1203
1259
  if (skipKey.includes(fieldCode)) {
1204
1260
  return;
1205
1261
  }
1206
- 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) {
1207
- return i.fieldCode === fieldCode;
1208
- });
1262
+ if (cacheFieldMapping.hasOwnProperty(fieldCode) === false) {
1263
+ var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
1264
+ cacheFieldMapping[fieldCode] = (_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) {
1265
+ return i.fieldCode === fieldCode;
1266
+ });
1267
+ }
1268
+ var fieldMapping = cacheFieldMapping[fieldCode];
1209
1269
  if (fieldMapping) {
1210
1270
  if (// fieldMapping.dataBind instanceof DataBind &&
1211
1271
  isDataBind(fieldMapping.dataBind) && row[fieldCode] !== undefined) {
1212
1272
  newRow[fieldMapping.controlId] = row[fieldCode];
1213
1273
  // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1214
1274
  } else if (!isDataBind(fieldMapping.dataBind)) {
1215
- var _this_getEmptyState;
1216
- var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1275
+ if (cacheEmptyState.hasOwnProperty(fieldMapping.controlId) === false) {
1276
+ var _this_getEmptyState;
1277
+ cacheEmptyState[fieldMapping.controlId] = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1278
+ }
1279
+ var objValue = cacheEmptyState[fieldMapping.controlId];
1217
1280
  Object.keys(fieldMapping.dataBind).map(function(key) {
1218
1281
  var dataBind = fieldMapping.dataBind[key];
1219
1282
  if (row[dataBind.fieldCode] !== undefined) {
@@ -1326,7 +1389,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1326
1389
  * 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
1327
1390
  * @param controlId
1328
1391
  * @param header 明细表内是否获取表头的控件
1329
- */ key: "getInstances",
1392
+ */ // getInstances(
1393
+ // controlId?: string,
1394
+ // header: boolean = false
1395
+ // ): ControlRuntimeInstance<ControlsKeys>[] {
1396
+ // // const cc = console
1397
+ // // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
1398
+ // // cc.time(label)
1399
+ //
1400
+ // if (controlId === undefined) {
1401
+ // // cc.timeEnd(label)
1402
+ // return this.runtime.flatInstances
1403
+ // }
1404
+ // const instances = Array.from(this.runtime.instanceMap[controlId] || [])
1405
+ // if (header) {
1406
+ // // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1407
+ // if (instances.length) {
1408
+ // const instance: RuntimeControl = instances[0]
1409
+ // // if (this.inList(instance.id) === true) {
1410
+ // if (this.inList(instance.id) !== undefined) {
1411
+ // const headerInstance = this.getInstanceInSubtableHeader(instance)
1412
+ // if (headerInstance) {
1413
+ // instances.unshift(headerInstance)
1414
+ // }
1415
+ // }
1416
+ // } else {
1417
+ // const controlIdMapping = this.getControlIdMapping()
1418
+ // const [subtableId] =
1419
+ // Object.entries(controlIdMapping).find(
1420
+ // ([_, mapping]) => mapping.children && controlId in mapping.children
1421
+ // ) ?? []
1422
+ // if (subtableId) {
1423
+ // const subtable = this.getInstance(subtableId)
1424
+ // // @ts-ignore
1425
+ // const headerColumn = subtable.props.headers.find((column: any) =>
1426
+ // column.children.find((item: any) => item.id === controlId)
1427
+ // )
1428
+ // if (headerColumn) {
1429
+ // const headerInstance = headerColumn.children.find(
1430
+ // (item: any) => item.id === controlId
1431
+ // )
1432
+ // if (headerInstance) {
1433
+ // instances.unshift(
1434
+ // headerInstance as ControlRuntimeInstance<ControlsKeys>
1435
+ // )
1436
+ // }
1437
+ // }
1438
+ // }
1439
+ // }
1440
+ // }
1441
+ // // @ts-ignore
1442
+ // return instances
1443
+ // }
1444
+ key: "getInstances",
1330
1445
  value: function getInstances(controlId) {
1331
1446
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1332
1447
  // const cc = console
@@ -1336,42 +1451,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1336
1451
  // cc.timeEnd(label)
1337
1452
  return this.runtime.flatInstances;
1338
1453
  }
1339
- var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1454
+ var instances = this.runtime.instanceMap[controlId] || [];
1340
1455
  if (header) {
1341
- // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1342
- if (instances.length) {
1343
- var instance = instances[0];
1344
- // if (this.inList(instance.id) === true) {
1345
- if (this.inList(instance.id) !== undefined) {
1346
- var headerInstance = this.getInstanceInSubtableHeader(instance);
1347
- if (headerInstance) {
1348
- instances.unshift(headerInstance);
1349
- }
1350
- }
1351
- } else {
1352
- var _this_getControlIdMapping;
1353
- var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
1354
- var _Object_entries_find;
1355
- var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1356
- var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
1357
- return mapping.children && controlId in mapping.children;
1358
- })) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
1359
- if (subtableId) {
1360
- var subtable = this.getInstance(subtableId);
1361
- // @ts-ignore
1362
- var headerColumn = subtable.props.headers.find(function(column) {
1363
- return column.children.find(function(item) {
1364
- return item.id === controlId;
1365
- });
1366
- });
1367
- if (headerColumn) {
1368
- var headerInstance1 = headerColumn.children.find(function(item) {
1369
- return item.id === controlId;
1370
- });
1371
- if (headerInstance1) {
1372
- instances.unshift(headerInstance1);
1373
- }
1374
- }
1456
+ var instance = instances[0];
1457
+ if (instance) {
1458
+ var _instance_parent;
1459
+ // @ts-ignore
1460
+ var parentId = (_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.id;
1461
+ if (parentId) {
1462
+ instances = this.runtime.instanceMap[parentId] || [];
1375
1463
  }
1376
1464
  }
1377
1465
  }
@@ -1494,55 +1582,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1494
1582
  * 如果控件在表头内,则返回-1
1495
1583
  * 如果控件在表内,则返回行下标
1496
1584
  * 如果控件不在明细表内,则返回undefined
1497
- * */ function getInstanceRowIndex(instance) {
1585
+ * */ // public getInstanceRowIndex(
1586
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1587
+ // ) {
1588
+ // if (!instance.parent) {
1589
+ // return
1590
+ // }
1591
+ // let rowIndex: number | undefined
1592
+ // // @ts-ignore
1593
+ // if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1594
+ // // 表头内的控件
1595
+ // // @ts-ignore
1596
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1597
+ // rowIndex = -1
1598
+ // } else {
1599
+ // // @ts-ignore
1600
+ // // const index = instance.parent.children.findIndex(
1601
+ // // (item: any) => item === instance
1602
+ // // )
1603
+ // let instances = this.runtime.instanceMap[instance.id] || []
1604
+ // const index = instances.findIndex((item: any) => item === instance)
1605
+ // if (index > -1) {
1606
+ // rowIndex = index
1607
+ // }
1608
+ // }
1609
+ // } else {
1610
+ // rowIndex = this.getInstanceRowIndex(instance.parent)
1611
+ // }
1612
+ // return rowIndex
1613
+ // }
1614
+ function getInstanceRowIndex(instance) {
1498
1615
  if (!instance.parent) {
1499
1616
  return;
1500
1617
  }
1501
1618
  var rowIndex;
1502
1619
  // @ts-ignore
1503
- if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1504
- // 表头内的控件
1505
- // @ts-ignore
1506
- if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1507
- rowIndex = -1;
1508
- } else {
1509
- // @ts-ignore
1510
- var index = instance.parent.children.findIndex(function(item) {
1511
- return item === instance;
1512
- });
1513
- if (index > -1) {
1514
- rowIndex = index;
1620
+ if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1621
+ rowIndex = -1;
1622
+ } else {
1623
+ var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
1624
+ CONTROL_TYPE.SUBTABLE_COLUMN);
1625
+ if (isColumnChild) {
1626
+ var instanceList = this.runtime.instanceMap[instance.id];
1627
+ if (Object.prototype.toString.call(instanceList) === "[object Array]") {
1628
+ var index = instanceList.findIndex(function(item) {
1629
+ return item === instance;
1630
+ });
1631
+ if (index > -1) {
1632
+ rowIndex = index;
1633
+ }
1515
1634
  }
1516
1635
  }
1517
- } else {
1518
- rowIndex = this.getInstanceRowIndex(instance.parent);
1519
1636
  }
1520
1637
  return rowIndex;
1521
1638
  }
1522
1639
  },
1523
1640
  {
1524
1641
  key: "getInstanceParentControl",
1525
- value: // public getInstanceRowIndex(
1526
- // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1527
- // ) {
1528
- // let rowIndex: number | undefined
1529
- // // @ts-ignore
1530
- // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1531
- // rowIndex = -1
1532
- // }else{
1533
- // const instanceList = this.runtime.instanceMap[instance.id]
1534
- // if(Object.prototype.toString.call(instanceList) === '[object Array]'){
1535
- // const index = instanceList.findIndex(
1536
- // (item: any) => item === instance
1537
- // )
1538
- // if (index > -1) {
1539
- // rowIndex = index
1540
- // }
1541
- // }
1542
- // }
1543
- // return rowIndex
1544
- // }
1545
- function getInstanceParentControl(instance, controlType) {
1642
+ value: function getInstanceParentControl(instance, controlType) {
1546
1643
  if (!instance.parent) {
1547
1644
  return;
1548
1645
  }
@@ -1621,12 +1718,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1621
1718
  {
1622
1719
  key: "register",
1623
1720
  value: // 注册外部控件
1624
- function register() {
1625
- for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
1626
- arg[_key] = arguments[_key];
1627
- }
1628
- var _Runtime;
1629
- return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
1721
+ function register(control) {
1722
+ return Runtime.register(control, "Runtime");
1630
1723
  }
1631
1724
  },
1632
1725
  {
@@ -1638,4 +1731,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1638
1731
  ]);
1639
1732
  return Engine;
1640
1733
  }(Watcher);
1734
+ // @ts-ignore
1641
1735
  export { Engine };
@@ -97,7 +97,7 @@ function _create_super(Derived) {
97
97
  };
98
98
  }
99
99
  import { RegisterControls } from "@byteluck-fe/model-driven-core";
100
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from "@byteluck-fe/model-driven-shared";
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) {
103
103
  "use strict";
@@ -111,6 +111,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
111
111
  _define_property(_assert_this_initialized(_this), "_instance", void 0);
112
112
  _define_property(_assert_this_initialized(_this), "_flatInstances", []);
113
113
  _define_property(_assert_this_initialized(_this), "_instanceMap", {});
114
+ _define_property(_assert_this_initialized(_this), "_controlParentIdMap", {});
114
115
  var schema = props.schema;
115
116
  _this._schema = schema;
116
117
  _this._instance = _this.createControl(schema, props.beforeCreateInstance);
@@ -123,19 +124,32 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
123
124
  value: function getFlatInstances() {
124
125
  var instances = [];
125
126
  var instanceMap = {};
126
- loop(this._instance, function(item) {
127
+ var controlParentIdMap = {};
128
+ loop(this._instance, "", function(item, parentId) {
127
129
  // 3.4.1 避免将subtable-row 放到 _flatInstances 中
128
- if (item.type === "subtable-row" || item.type === "subtable-column") {
129
- return;
130
+ //4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
131
+ // if (item.type === 'subtable-row' || item.type === 'subtable-column') {
132
+ // return
133
+ // }
134
+ if (parentId) {
135
+ // @ts-ignore
136
+ controlParentIdMap[item.id] = parentId;
130
137
  }
131
- instances.push(item);
132
138
  if (!instanceMap[item.id]) {
133
139
  instanceMap[item.id] = [];
134
140
  }
141
+ //不知为何subtable-column会多存一次
142
+ if (item.type === "subtable-column") {
143
+ if (instanceMap[item.id].length > 0) {
144
+ return;
145
+ }
146
+ }
147
+ instances.push(item);
135
148
  instanceMap[item.id].push(item);
136
149
  });
137
150
  this._flatInstances = instances;
138
151
  this._instanceMap = instanceMap;
152
+ this._controlParentIdMap = controlParentIdMap;
139
153
  return this._flatInstances;
140
154
  }
141
155
  },
@@ -169,8 +183,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
169
183
  var antdRules = {};
170
184
  var ruleItems = {};
171
185
  loopDataViewControl(this._instance, function(dataView) {
172
- ruleItems[dataView.id] = dataView.rules[0];
173
- antdRules[dataView.id] = dataView.rules[0];
186
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
187
+ ruleItems[dataView.id] = JSONCopy(result[0]);
188
+ antdRules[dataView.id] = JSONCopy(result[0]);
174
189
  loopFormControl(dataView.children, function(item) {
175
190
  // if (
176
191
  // item instanceof RuntimeFormControl ||
@@ -193,7 +208,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
193
208
  get: function get() {
194
209
  var ruleItems = {};
195
210
  loopDataViewControl(this._instance, function(dataView) {
196
- ruleItems[dataView.id] = dataView.rules[0];
211
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
212
+ // ruleItems[dataView.id] = dataView.rules[0]
213
+ ruleItems[dataView.id] = result[0];
197
214
  loopFormControl(dataView.children, function(item) {
198
215
  // if (
199
216
  // item instanceof RuntimeFormControl ||
@@ -212,7 +229,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
212
229
  get: function get() {
213
230
  var antdRules = {};
214
231
  loopDataViewControl(this._instance, function(dataView) {
215
- antdRules[dataView.id] = dataView.rules[0];
232
+ var result = Runtime.staticGetRules(dataView.type, dataView.props);
233
+ // antdRules[dataView.id] = dataView.rules[0]
234
+ antdRules[dataView.id] = result[0];
216
235
  loopFormControl(dataView.children, function(item) {
217
236
  // if (
218
237
  // item instanceof RuntimeFormControl ||
@@ -229,22 +248,30 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
229
248
  ]);
230
249
  return Runtime;
231
250
  }(RegisterControls);
232
- function loop(control, callback) {
233
- if (Array.isArray(control)) {
234
- control.map(function(item) {
235
- callback(item);
236
- if (hasChildrenControl(item)) {
237
- var ctl = item;
238
- if (!ctl.children) {
239
- ctl.children = [];
240
- }
241
- // @ts-ignore
242
- loop(ctl.children, callback);
251
+ function loop(control, parentId, callback) {
252
+ var _instances = Array.isArray(control) ? control : [
253
+ control
254
+ ];
255
+ _instances.map(function(item) {
256
+ callback(item, parentId);
257
+ if (hasChildrenControl(item)) {
258
+ var ctl = item;
259
+ if (!ctl.children) {
260
+ ctl.children = [];
243
261
  }
244
- });
245
- } else {
246
- callback(control);
247
- }
262
+ // @ts-ignore
263
+ loop(ctl.children, ctl.id, callback);
264
+ }
265
+ if (hasHeaderOrFooterControl(item, "headers")) {
266
+ loop(item.props.headers, item.id, callback);
267
+ }
268
+ if (hasHeaderOrFooterControl(item, "footers")) {
269
+ loop(item.props.footers, item.id, callback);
270
+ }
271
+ });
272
+ }
273
+ function hasHeaderOrFooterControl(control, checkType) {
274
+ return checkType in control.props && isArray(control.props[checkType]);
248
275
  }
249
276
  /**
250
277
  * 控件是否在视图中隐藏,遍历查找所有parent
@@ -252,7 +279,7 @@ function loop(control, callback) {
252
279
  if (control.props.isHide) {
253
280
  return true;
254
281
  }
255
- if (control.parent === null) {
282
+ if (control.parent === null || control.parent === undefined) {
256
283
  return false;
257
284
  }
258
285
  return getControlIsHide(control.parent);
@@ -262,11 +289,14 @@ item) {
262
289
  if (getControlIsHide(item)) {
263
290
  return;
264
291
  }
292
+ var result = Runtime.staticGetRules(item.type, item.props);
265
293
  // if (item instanceof RuntimeFormControl) {
266
294
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
267
- data[item.id] = item.rules;
295
+ // data[item.id] = item.rules
296
+ data[item.id] = result;
268
297
  } else if (item.type === CONTROL_TYPE.SUBTABLE) {
269
- data[item.id] = item.rules;
298
+ // data[item.id] = item.rules
299
+ data[item.id] = result;
270
300
  var itemRules = {
271
301
  type: "array",
272
302
  fields: {}
@@ -281,8 +311,13 @@ item) {
281
311
  fields: {}
282
312
  };
283
313
  }
314
+ // // @ts-ignore
315
+ // itemRules.fields[index].fields[formControl.id] = (
316
+ // formControl as RuntimeFormControl
317
+ // ).rules
318
+ var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
284
319
  // @ts-ignore
285
- itemRules.fields[index].fields[formControl.id] = formControl.rules;
320
+ itemRules.fields[index].fields[formControl.id] = childResult;
286
321
  }
287
322
  });
288
323
  });
@@ -294,15 +329,19 @@ item) {
294
329
  if (getControlIsHide(item)) {
295
330
  return;
296
331
  }
332
+ var result = Runtime.staticGetRules(item.type, item.props);
297
333
  // if (item instanceof RuntimeFormControl) {
298
334
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
299
- antdRules[item.id] = item.rules;
335
+ // antdRules[item.id] = item.rules
336
+ antdRules[item.id] = result;
300
337
  } else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
301
338
  antdRules[item.id] = [];
302
339
  item.children.forEach(function(row) {
303
340
  var rules = {};
304
341
  loopFormSchema(row.children, function(formControl) {
305
- rules[formControl.id] = formControl.rules;
342
+ // rules[formControl.id] = (formControl as RuntimeFormControl).rules
343
+ var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
344
+ rules[formControl.id] = childResult;
306
345
  });
307
346
  antdRules[item.id].push(rules);
308
347
  });
@@ -79,13 +79,15 @@ function _unsupported_iterable_to_array(o, minLen) {
79
79
  import { error } from "@byteluck-fe/model-driven-shared";
80
80
  export var ES6ModulePlugin = /*#__PURE__*/ function() {
81
81
  "use strict";
82
- function ES6ModulePlugin(config, env) {
82
+ function ES6ModulePlugin(config, env, eventJs) {
83
83
  _class_call_check(this, ES6ModulePlugin);
84
84
  _define_property(this, "config", void 0);
85
85
  _define_property(this, "engine", void 0);
86
86
  _define_property(this, "env", void 0);
87
+ _define_property(this, "eventJs", void 0);
87
88
  this.config = config;
88
89
  this.env = env;
90
+ this.eventJs = eventJs;
89
91
  }
90
92
  _create_class(ES6ModulePlugin, [
91
93
  {
@@ -96,28 +98,55 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
96
98
  if (!action) {
97
99
  return;
98
100
  }
99
- var res = parseModule(action, engine, this.env);
100
- if (!res) {
101
- return;
102
- }
103
101
  var actionManager = engine.getAction();
104
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
105
- try {
106
- for(var _iterator = Object.entries(res.funcMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
107
- var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
108
- actionManager.addAction(key, value);
102
+ if (this.eventJs) {
103
+ this.eventJs.exportsFun({
104
+ ctx: engine,
105
+ utils: actionManager.actionUtils
106
+ });
107
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
108
+ try {
109
+ for(var _iterator = Object.entries(this.eventJs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
110
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
111
+ actionManager.addAction(key, value);
112
+ }
113
+ } catch (err) {
114
+ _didIteratorError = true;
115
+ _iteratorError = err;
116
+ } finally{
117
+ try {
118
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
119
+ _iterator.return();
120
+ }
121
+ } finally{
122
+ if (_didIteratorError) {
123
+ throw _iteratorError;
124
+ }
125
+ }
126
+ }
127
+ } else {
128
+ var res = parseModule(action, engine, this.env);
129
+ if (!res) {
130
+ return;
109
131
  }
110
- } catch (err) {
111
- _didIteratorError = true;
112
- _iteratorError = err;
113
- } finally{
132
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
114
133
  try {
115
- if (!_iteratorNormalCompletion && _iterator.return != null) {
116
- _iterator.return();
134
+ for(var _iterator1 = Object.entries(res.funcMap)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
135
+ var _step_value1 = _sliced_to_array(_step1.value, 2), key1 = _step_value1[0], value1 = _step_value1[1];
136
+ actionManager.addAction(key1, value1);
117
137
  }
138
+ } catch (err) {
139
+ _didIteratorError1 = true;
140
+ _iteratorError1 = err;
118
141
  } finally{
119
- if (_didIteratorError) {
120
- throw _iteratorError;
142
+ try {
143
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
144
+ _iterator1.return();
145
+ }
146
+ } finally{
147
+ if (_didIteratorError1) {
148
+ throw _iteratorError1;
149
+ }
121
150
  }
122
151
  }
123
152
  }