@byteluck-fe/model-driven-engine 2.8.0-alpha.1 → 2.8.0-alpha.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.
- package/dist/esm/common/Engine.js +188 -54
- package/dist/esm/common/Runtime.js +69 -30
- package/dist/esm/common/Store.js +6 -1
- package/dist/esm/plugins/CalcPlugin.js +2 -0
- package/dist/esm/plugins/ES6ModulePlugin.js +47 -18
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +5 -4
- package/dist/types/common/Runtime.d.ts +1 -0
- package/dist/types/common/Store.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +2 -1
- package/package.json +4 -4
|
@@ -630,7 +630,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
630
630
|
var index = this.getInstanceRowIndex(instance);
|
|
631
631
|
var options = eventOptionsTemp || {};
|
|
632
632
|
// if (instance instanceof RuntimeListControl) {
|
|
633
|
-
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
633
|
+
if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
|
|
634
634
|
var // @ts-ignore
|
|
635
635
|
_instance_children;
|
|
636
636
|
instance.children.length = 0;
|
|
@@ -648,6 +648,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
648
648
|
// for (let i = 0; i < newValue.length; i++) {
|
|
649
649
|
// this.setStates(newValue[i], i, options)
|
|
650
650
|
// }
|
|
651
|
+
var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
|
|
652
|
+
if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
|
|
653
|
+
deleted = [];
|
|
654
|
+
}
|
|
651
655
|
this.emit("list-change", {
|
|
652
656
|
instance: instance,
|
|
653
657
|
value: value,
|
|
@@ -655,7 +659,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
655
659
|
// @ts-ignore
|
|
656
660
|
changed: newRows,
|
|
657
661
|
data: newValue,
|
|
658
|
-
deleted:
|
|
662
|
+
deleted: deleted,
|
|
663
|
+
// deleted: oldValue ?? [],
|
|
659
664
|
type: "push"
|
|
660
665
|
})
|
|
661
666
|
});
|
|
@@ -693,7 +698,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
693
698
|
{
|
|
694
699
|
key: "listControlCreateRow",
|
|
695
700
|
value: function listControlCreateRow(instance, rowType) {
|
|
696
|
-
var row
|
|
701
|
+
var row;
|
|
702
|
+
if (rowType === "subtable-row") {
|
|
703
|
+
row = {
|
|
704
|
+
children: [],
|
|
705
|
+
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
706
|
+
id: genNonDuplicateId(),
|
|
707
|
+
type: "subtable-row",
|
|
708
|
+
props: {
|
|
709
|
+
caption: "",
|
|
710
|
+
isHide: false,
|
|
711
|
+
style: {
|
|
712
|
+
height: "",
|
|
713
|
+
heightConfig: "fill",
|
|
714
|
+
width: "",
|
|
715
|
+
widthConfig: "fill"
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
fieldType: undefined,
|
|
719
|
+
customEvents: [],
|
|
720
|
+
pageStatus: 0,
|
|
721
|
+
rules: [],
|
|
722
|
+
parent: undefined
|
|
723
|
+
};
|
|
724
|
+
} else {
|
|
725
|
+
row = this.runtime.createControlInstance(rowType);
|
|
726
|
+
}
|
|
697
727
|
if (!row) return;
|
|
698
728
|
// if (row instanceof RuntimeLayoutControl) {
|
|
699
729
|
// @ts-ignore
|
|
@@ -703,8 +733,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
703
733
|
var template = JSONCopy(instance.props.headers);
|
|
704
734
|
// @ts-ignore
|
|
705
735
|
var columns = this.createControl(template);
|
|
736
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
737
|
+
try {
|
|
738
|
+
for(var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
739
|
+
var column = _step.value;
|
|
740
|
+
if (!column.parent) {
|
|
741
|
+
this.runtime.resetInstanceParent(column, inst);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
} catch (err) {
|
|
745
|
+
_didIteratorError = true;
|
|
746
|
+
_iteratorError = err;
|
|
747
|
+
} finally{
|
|
748
|
+
try {
|
|
749
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
750
|
+
_iterator.return();
|
|
751
|
+
}
|
|
752
|
+
} finally{
|
|
753
|
+
if (_didIteratorError) {
|
|
754
|
+
throw _iteratorError;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
706
758
|
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
707
759
|
}
|
|
760
|
+
//@ts-ignore
|
|
761
|
+
row.parent = instance;
|
|
708
762
|
return row;
|
|
709
763
|
}
|
|
710
764
|
},
|
|
@@ -824,6 +878,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
824
878
|
return this.setInstance(instance, props, value, rowIndex);
|
|
825
879
|
}
|
|
826
880
|
},
|
|
881
|
+
{
|
|
882
|
+
key: "getRule",
|
|
883
|
+
value: function getRule(controlType, props) {
|
|
884
|
+
return Runtime.staticGetRules(controlType, props);
|
|
885
|
+
}
|
|
886
|
+
},
|
|
827
887
|
{
|
|
828
888
|
key: "getAllRules",
|
|
829
889
|
value: function getAllRules(controlId) {
|
|
@@ -1133,7 +1193,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1133
1193
|
value: function buildFields(dataCode, state) {
|
|
1134
1194
|
var _this = this;
|
|
1135
1195
|
var mapping = this.getDataBindMapping(dataCode);
|
|
1136
|
-
if (!mapping) {
|
|
1196
|
+
if (!mapping || !mapping.fields) {
|
|
1137
1197
|
return;
|
|
1138
1198
|
}
|
|
1139
1199
|
var skipKeys = [];
|
|
@@ -1177,7 +1237,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1177
1237
|
value: function setData(dataSet, options) {
|
|
1178
1238
|
var _this = this;
|
|
1179
1239
|
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1240
|
+
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1180
1241
|
var newState = this.store.defaultState;
|
|
1242
|
+
if (onlySetData === true) {
|
|
1243
|
+
newState = {};
|
|
1244
|
+
}
|
|
1181
1245
|
Object.keys(dataSet).map(function(dataCode) {
|
|
1182
1246
|
var entity = dataSet[dataCode];
|
|
1183
1247
|
if (Array.isArray(entity)) {
|
|
@@ -1194,26 +1258,34 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1194
1258
|
} else {
|
|
1195
1259
|
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1196
1260
|
}
|
|
1261
|
+
var cacheEmptyState = {};
|
|
1262
|
+
var cacheFieldMapping = {};
|
|
1197
1263
|
entity.map(function(row) {
|
|
1198
1264
|
var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1199
1265
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1200
1266
|
;
|
|
1201
1267
|
Object.keys(row).map(function(fieldCode) {
|
|
1202
|
-
var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
|
|
1203
1268
|
if (skipKey.includes(fieldCode)) {
|
|
1204
1269
|
return;
|
|
1205
1270
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1271
|
+
if (cacheFieldMapping.hasOwnProperty(fieldCode) === false) {
|
|
1272
|
+
var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
|
|
1273
|
+
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) {
|
|
1274
|
+
return i.fieldCode === fieldCode;
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
var fieldMapping = cacheFieldMapping[fieldCode];
|
|
1209
1278
|
if (fieldMapping) {
|
|
1210
1279
|
if (// fieldMapping.dataBind instanceof DataBind &&
|
|
1211
1280
|
isDataBind(fieldMapping.dataBind) && row[fieldCode] !== undefined) {
|
|
1212
1281
|
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1213
1282
|
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1214
1283
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1215
|
-
|
|
1216
|
-
|
|
1284
|
+
if (cacheEmptyState.hasOwnProperty(fieldMapping.controlId) === false) {
|
|
1285
|
+
var _this_getEmptyState;
|
|
1286
|
+
cacheEmptyState[fieldMapping.controlId] = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1287
|
+
}
|
|
1288
|
+
var objValue = JSONCopy(cacheEmptyState[fieldMapping.controlId]);
|
|
1217
1289
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1218
1290
|
var dataBind = fieldMapping.dataBind[key];
|
|
1219
1291
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1223,6 +1295,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1223
1295
|
});
|
|
1224
1296
|
newRow[fieldMapping.controlId] = objValue;
|
|
1225
1297
|
}
|
|
1298
|
+
} else if (fieldCode === "uid" && row["uid"] !== undefined) {
|
|
1299
|
+
newRow["uid"] = row["uid"];
|
|
1226
1300
|
}
|
|
1227
1301
|
});
|
|
1228
1302
|
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
@@ -1286,7 +1360,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1286
1360
|
}
|
|
1287
1361
|
});
|
|
1288
1362
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1289
|
-
this.setStates(newState, undefined,
|
|
1363
|
+
this.setStates(newState, undefined, _object_spread({
|
|
1364
|
+
setData: true
|
|
1365
|
+
}, options));
|
|
1290
1366
|
this.debugLog("engine setData方法执行完成。");
|
|
1291
1367
|
}
|
|
1292
1368
|
},
|
|
@@ -1326,7 +1402,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1326
1402
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1327
1403
|
* @param controlId
|
|
1328
1404
|
* @param header 明细表内是否获取表头的控件
|
|
1329
|
-
*/
|
|
1405
|
+
*/ // getInstances(
|
|
1406
|
+
// controlId?: string,
|
|
1407
|
+
// header: boolean = false
|
|
1408
|
+
// ): ControlRuntimeInstance<ControlsKeys>[] {
|
|
1409
|
+
// // const cc = console
|
|
1410
|
+
// // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1411
|
+
// // cc.time(label)
|
|
1412
|
+
//
|
|
1413
|
+
// if (controlId === undefined) {
|
|
1414
|
+
// // cc.timeEnd(label)
|
|
1415
|
+
// return this.runtime.flatInstances
|
|
1416
|
+
// }
|
|
1417
|
+
// const instances = Array.from(this.runtime.instanceMap[controlId] || [])
|
|
1418
|
+
// if (header) {
|
|
1419
|
+
// // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1420
|
+
// if (instances.length) {
|
|
1421
|
+
// const instance: RuntimeControl = instances[0]
|
|
1422
|
+
// // if (this.inList(instance.id) === true) {
|
|
1423
|
+
// if (this.inList(instance.id) !== undefined) {
|
|
1424
|
+
// const headerInstance = this.getInstanceInSubtableHeader(instance)
|
|
1425
|
+
// if (headerInstance) {
|
|
1426
|
+
// instances.unshift(headerInstance)
|
|
1427
|
+
// }
|
|
1428
|
+
// }
|
|
1429
|
+
// } else {
|
|
1430
|
+
// const controlIdMapping = this.getControlIdMapping()
|
|
1431
|
+
// const [subtableId] =
|
|
1432
|
+
// Object.entries(controlIdMapping).find(
|
|
1433
|
+
// ([_, mapping]) => mapping.children && controlId in mapping.children
|
|
1434
|
+
// ) ?? []
|
|
1435
|
+
// if (subtableId) {
|
|
1436
|
+
// const subtable = this.getInstance(subtableId)
|
|
1437
|
+
// // @ts-ignore
|
|
1438
|
+
// const headerColumn = subtable.props.headers.find((column: any) =>
|
|
1439
|
+
// column.children.find((item: any) => item.id === controlId)
|
|
1440
|
+
// )
|
|
1441
|
+
// if (headerColumn) {
|
|
1442
|
+
// const headerInstance = headerColumn.children.find(
|
|
1443
|
+
// (item: any) => item.id === controlId
|
|
1444
|
+
// )
|
|
1445
|
+
// if (headerInstance) {
|
|
1446
|
+
// instances.unshift(
|
|
1447
|
+
// headerInstance as ControlRuntimeInstance<ControlsKeys>
|
|
1448
|
+
// )
|
|
1449
|
+
// }
|
|
1450
|
+
// }
|
|
1451
|
+
// }
|
|
1452
|
+
// }
|
|
1453
|
+
// }
|
|
1454
|
+
// // @ts-ignore
|
|
1455
|
+
// return instances
|
|
1456
|
+
// }
|
|
1457
|
+
key: "getInstances",
|
|
1330
1458
|
value: function getInstances(controlId) {
|
|
1331
1459
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1332
1460
|
// const cc = console
|
|
@@ -1494,55 +1622,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1494
1622
|
* 如果控件在表头内,则返回-1
|
|
1495
1623
|
* 如果控件在表内,则返回行下标
|
|
1496
1624
|
* 如果控件不在明细表内,则返回undefined
|
|
1497
|
-
* */
|
|
1625
|
+
* */ // public getInstanceRowIndex(
|
|
1626
|
+
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1627
|
+
// ) {
|
|
1628
|
+
// if (!instance.parent) {
|
|
1629
|
+
// return
|
|
1630
|
+
// }
|
|
1631
|
+
// let rowIndex: number | undefined
|
|
1632
|
+
// // @ts-ignore
|
|
1633
|
+
// if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1634
|
+
// // 表头内的控件
|
|
1635
|
+
// // @ts-ignore
|
|
1636
|
+
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1637
|
+
// rowIndex = -1
|
|
1638
|
+
// } else {
|
|
1639
|
+
// // @ts-ignore
|
|
1640
|
+
// // const index = instance.parent.children.findIndex(
|
|
1641
|
+
// // (item: any) => item === instance
|
|
1642
|
+
// // )
|
|
1643
|
+
// let instances = this.runtime.instanceMap[instance.id] || []
|
|
1644
|
+
// const index = instances.findIndex((item: any) => item === instance)
|
|
1645
|
+
// if (index > -1) {
|
|
1646
|
+
// rowIndex = index
|
|
1647
|
+
// }
|
|
1648
|
+
// }
|
|
1649
|
+
// } else {
|
|
1650
|
+
// rowIndex = this.getInstanceRowIndex(instance.parent)
|
|
1651
|
+
// }
|
|
1652
|
+
// return rowIndex
|
|
1653
|
+
// }
|
|
1654
|
+
function getInstanceRowIndex(instance) {
|
|
1498
1655
|
if (!instance.parent) {
|
|
1499
1656
|
return;
|
|
1500
1657
|
}
|
|
1501
1658
|
var rowIndex;
|
|
1502
1659
|
// @ts-ignore
|
|
1503
|
-
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1660
|
+
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE_COLUMN) && this.assertInstance(instance.parent.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1661
|
+
rowIndex = -1;
|
|
1662
|
+
} else {
|
|
1663
|
+
var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1664
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1665
|
+
if (isColumnChild) {
|
|
1666
|
+
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1667
|
+
if (Object.prototype.toString.call(instanceList) === "[object Array]") {
|
|
1668
|
+
var index = instanceList.findIndex(function(item) {
|
|
1669
|
+
return item === instance;
|
|
1670
|
+
});
|
|
1671
|
+
if (index > -1) {
|
|
1672
|
+
rowIndex = index;
|
|
1673
|
+
}
|
|
1515
1674
|
}
|
|
1516
1675
|
}
|
|
1517
|
-
} else {
|
|
1518
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1519
1676
|
}
|
|
1520
1677
|
return rowIndex;
|
|
1521
1678
|
}
|
|
1522
1679
|
},
|
|
1523
1680
|
{
|
|
1524
1681
|
key: "getInstanceParentControl",
|
|
1525
|
-
value:
|
|
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) {
|
|
1682
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1546
1683
|
if (!instance.parent) {
|
|
1547
1684
|
return;
|
|
1548
1685
|
}
|
|
@@ -1621,12 +1758,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1621
1758
|
{
|
|
1622
1759
|
key: "register",
|
|
1623
1760
|
value: // 注册外部控件
|
|
1624
|
-
function register() {
|
|
1625
|
-
|
|
1626
|
-
arg[_key] = arguments[_key];
|
|
1627
|
-
}
|
|
1628
|
-
var _Runtime;
|
|
1629
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
|
|
1761
|
+
function register(control) {
|
|
1762
|
+
return Runtime.register(control, "Runtime");
|
|
1630
1763
|
}
|
|
1631
1764
|
},
|
|
1632
1765
|
{
|
|
@@ -1638,4 +1771,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1638
1771
|
]);
|
|
1639
1772
|
return Engine;
|
|
1640
1773
|
}(Watcher);
|
|
1774
|
+
// @ts-ignore
|
|
1641
1775
|
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
|
-
|
|
127
|
+
var controlParentIdMap = {};
|
|
128
|
+
loop(this._instance, "", function(item, parentId) {
|
|
127
129
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
173
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
234
|
-
control
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
loop(ctl.children, ctl.id, callback);
|
|
264
|
+
}
|
|
265
|
+
// if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
266
|
+
// loop((item.props as any).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] =
|
|
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
|
});
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -121,7 +121,12 @@ var Store = /*#__PURE__*/ function() {
|
|
|
121
121
|
} else {
|
|
122
122
|
var controlInfo = this.controlIdMapping[controlId];
|
|
123
123
|
if (controlInfo !== undefined) {
|
|
124
|
-
|
|
124
|
+
var data = this.state[controlInfo.dataView][controlId];
|
|
125
|
+
if (rowIndex !== undefined) {
|
|
126
|
+
return data[rowIndex];
|
|
127
|
+
} else {
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
125
130
|
} else {
|
|
126
131
|
if (rowIndex !== undefined) {
|
|
127
132
|
var state;
|
|
@@ -196,7 +196,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
196
196
|
* */ function allCalcControlComputed() {
|
|
197
197
|
var _this = this;
|
|
198
198
|
this.calcControls.forEach(function(item) {
|
|
199
|
+
// this.engine.getState(item.id)
|
|
199
200
|
if (item.props.dataBind.result.fieldCode === null || item.props.dataBind.result.fieldCode === undefined) {
|
|
201
|
+
// formEngineModel在custom:beforeEngineMounted时调用二开赋值,表单值 set 了却没有做计算。但这个是正常的
|
|
200
202
|
_this.computedCalcValue(item);
|
|
201
203
|
}
|
|
202
204
|
});
|