@byteluck-fe/model-driven-engine 2.7.0-alpha.27 → 2.7.0-alpha.29a
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 +128 -94
- package/dist/esm/common/Runtime.js +69 -30
- package/dist/esm/common/Store.js +1 -2
- package/dist/esm/common/checkerValue.js +2 -4
- package/dist/esm/common/proxyState.js +4 -5
- package/dist/esm/plugins/CalcPlugin.js +3 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +47 -18
- package/dist/esm/utils/runtimeUtils.js +2 -4
- package/dist/index.umd.js +7 -8
- package/dist/types/common/Engine.d.ts +4 -3
- package/dist/types/common/Runtime.d.ts +1 -0
- package/dist/types/plugins/ES6ModulePlugin.d.ts +2 -1
- package/package.json +4 -4
|
@@ -474,7 +474,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
474
474
|
}
|
|
475
475
|
// @ts-ignore
|
|
476
476
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
477
|
-
var _newValue;
|
|
478
477
|
if (newValue === null) {
|
|
479
478
|
return [];
|
|
480
479
|
}
|
|
@@ -489,7 +488,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
489
488
|
}, {});
|
|
490
489
|
// @ts-ignore
|
|
491
490
|
var emptyState = this.getEmptyState(instance.id);
|
|
492
|
-
return
|
|
491
|
+
return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
|
|
493
492
|
return(// @ts-ignore
|
|
494
493
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
494
|
});
|
|
@@ -518,10 +517,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
518
517
|
key: "_handlerArrayUpdate",
|
|
519
518
|
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
520
519
|
var _this = this;
|
|
521
|
-
var _subtable;
|
|
522
520
|
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
523
521
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
524
|
-
if (!((
|
|
522
|
+
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
525
523
|
// 新增多行方法
|
|
526
524
|
var createRows = function(len) {
|
|
527
525
|
// @ts-ignore
|
|
@@ -704,6 +702,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
704
702
|
var columns = this.createControl(template);
|
|
705
703
|
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
706
704
|
}
|
|
705
|
+
//@ts-ignore
|
|
706
|
+
row.parent = instance;
|
|
707
707
|
return row;
|
|
708
708
|
}
|
|
709
709
|
},
|
|
@@ -823,6 +823,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
823
823
|
return this.setInstance(instance, props, value, rowIndex);
|
|
824
824
|
}
|
|
825
825
|
},
|
|
826
|
+
{
|
|
827
|
+
key: "getRule",
|
|
828
|
+
value: function getRule(controlType, props) {
|
|
829
|
+
return Runtime.staticGetRules(controlType, props);
|
|
830
|
+
}
|
|
831
|
+
},
|
|
826
832
|
{
|
|
827
833
|
key: "getAllRules",
|
|
828
834
|
value: function getAllRules(controlId) {
|
|
@@ -1132,7 +1138,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1132
1138
|
value: function buildFields(dataCode, state) {
|
|
1133
1139
|
var _this = this;
|
|
1134
1140
|
var mapping = this.getDataBindMapping(dataCode);
|
|
1135
|
-
if (!mapping) {
|
|
1141
|
+
if (!mapping || !mapping.fields) {
|
|
1136
1142
|
return;
|
|
1137
1143
|
}
|
|
1138
1144
|
var skipKeys = [];
|
|
@@ -1264,20 +1270,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1264
1270
|
}
|
|
1265
1271
|
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1266
1272
|
if (newMapping) {
|
|
1267
|
-
var _newMapping_fields
|
|
1268
|
-
var mappingKeys =
|
|
1269
|
-
|
|
1270
|
-
return (_item = item) === null || _item === void 0 ? void 0 : _item.controlId;
|
|
1273
|
+
var _newMapping_fields;
|
|
1274
|
+
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
|
|
1275
|
+
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1271
1276
|
});
|
|
1272
|
-
var mappingValue = _this.getEmptyState(
|
|
1277
|
+
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1273
1278
|
var _newState_newMapping_controlId;
|
|
1274
|
-
var mainStateKeys = Object.keys((_newState_newMapping_controlId =
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (!mainStateKeys.includes(key) && key !== "uid" && newState[(_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : _newMapping.controlId]) {
|
|
1279
|
+
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1280
|
+
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1281
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1278
1282
|
if (Object.keys(newState).length) {
|
|
1279
|
-
|
|
1280
|
-
Object.assign(newState[(_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId], _define_property({}, key, mappingValue[key]));
|
|
1283
|
+
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1281
1284
|
} else {
|
|
1282
1285
|
Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
|
|
1283
1286
|
}
|
|
@@ -1328,7 +1331,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1328
1331
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1329
1332
|
* @param controlId
|
|
1330
1333
|
* @param header 明细表内是否获取表头的控件
|
|
1331
|
-
*/
|
|
1334
|
+
*/ // getInstances(
|
|
1335
|
+
// controlId?: string,
|
|
1336
|
+
// header: boolean = false
|
|
1337
|
+
// ): ControlRuntimeInstance<ControlsKeys>[] {
|
|
1338
|
+
// // const cc = console
|
|
1339
|
+
// // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1340
|
+
// // cc.time(label)
|
|
1341
|
+
//
|
|
1342
|
+
// if (controlId === undefined) {
|
|
1343
|
+
// // cc.timeEnd(label)
|
|
1344
|
+
// return this.runtime.flatInstances
|
|
1345
|
+
// }
|
|
1346
|
+
// const instances = Array.from(this.runtime.instanceMap[controlId] || [])
|
|
1347
|
+
// if (header) {
|
|
1348
|
+
// // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1349
|
+
// if (instances.length) {
|
|
1350
|
+
// const instance: RuntimeControl = instances[0]
|
|
1351
|
+
// // if (this.inList(instance.id) === true) {
|
|
1352
|
+
// if (this.inList(instance.id) !== undefined) {
|
|
1353
|
+
// const headerInstance = this.getInstanceInSubtableHeader(instance)
|
|
1354
|
+
// if (headerInstance) {
|
|
1355
|
+
// instances.unshift(headerInstance)
|
|
1356
|
+
// }
|
|
1357
|
+
// }
|
|
1358
|
+
// } else {
|
|
1359
|
+
// const controlIdMapping = this.getControlIdMapping()
|
|
1360
|
+
// const [subtableId] =
|
|
1361
|
+
// Object.entries(controlIdMapping).find(
|
|
1362
|
+
// ([_, mapping]) => mapping.children && controlId in mapping.children
|
|
1363
|
+
// ) ?? []
|
|
1364
|
+
// if (subtableId) {
|
|
1365
|
+
// const subtable = this.getInstance(subtableId)
|
|
1366
|
+
// // @ts-ignore
|
|
1367
|
+
// const headerColumn = subtable.props.headers.find((column: any) =>
|
|
1368
|
+
// column.children.find((item: any) => item.id === controlId)
|
|
1369
|
+
// )
|
|
1370
|
+
// if (headerColumn) {
|
|
1371
|
+
// const headerInstance = headerColumn.children.find(
|
|
1372
|
+
// (item: any) => item.id === controlId
|
|
1373
|
+
// )
|
|
1374
|
+
// if (headerInstance) {
|
|
1375
|
+
// instances.unshift(
|
|
1376
|
+
// headerInstance as ControlRuntimeInstance<ControlsKeys>
|
|
1377
|
+
// )
|
|
1378
|
+
// }
|
|
1379
|
+
// }
|
|
1380
|
+
// }
|
|
1381
|
+
// }
|
|
1382
|
+
// }
|
|
1383
|
+
// // @ts-ignore
|
|
1384
|
+
// return instances
|
|
1385
|
+
// }
|
|
1386
|
+
key: "getInstances",
|
|
1332
1387
|
value: function getInstances(controlId) {
|
|
1333
1388
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1334
1389
|
// const cc = console
|
|
@@ -1338,42 +1393,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1338
1393
|
// cc.timeEnd(label)
|
|
1339
1394
|
return this.runtime.flatInstances;
|
|
1340
1395
|
}
|
|
1341
|
-
var instances =
|
|
1396
|
+
var instances = this.runtime.instanceMap[controlId] || [];
|
|
1342
1397
|
if (header) {
|
|
1343
|
-
|
|
1344
|
-
if (
|
|
1345
|
-
var
|
|
1346
|
-
//
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
instances.unshift(headerInstance);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
} else {
|
|
1354
|
-
var _this_getControlIdMapping;
|
|
1355
|
-
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1356
|
-
var _Object_entries_find;
|
|
1357
|
-
var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1358
|
-
var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
|
|
1359
|
-
return mapping.children && controlId in mapping.children;
|
|
1360
|
-
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1361
|
-
if (subtableId) {
|
|
1362
|
-
var subtable = this.getInstance(subtableId);
|
|
1363
|
-
// @ts-ignore
|
|
1364
|
-
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1365
|
-
return column.children.find(function(item) {
|
|
1366
|
-
return item.id === controlId;
|
|
1367
|
-
});
|
|
1368
|
-
});
|
|
1369
|
-
if (headerColumn) {
|
|
1370
|
-
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1371
|
-
return item.id === controlId;
|
|
1372
|
-
});
|
|
1373
|
-
if (headerInstance1) {
|
|
1374
|
-
instances.unshift(headerInstance1);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1398
|
+
var instance = instances[0];
|
|
1399
|
+
if (instance) {
|
|
1400
|
+
var _instance_parent;
|
|
1401
|
+
// @ts-ignore
|
|
1402
|
+
var parentId = (_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.id;
|
|
1403
|
+
if (parentId) {
|
|
1404
|
+
instances = this.runtime.instanceMap[parentId] || [];
|
|
1377
1405
|
}
|
|
1378
1406
|
}
|
|
1379
1407
|
}
|
|
@@ -1488,55 +1516,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1488
1516
|
* 如果控件在表头内,则返回-1
|
|
1489
1517
|
* 如果控件在表内,则返回行下标
|
|
1490
1518
|
* 如果控件不在明细表内,则返回undefined
|
|
1491
|
-
* */
|
|
1519
|
+
* */ // public getInstanceRowIndex(
|
|
1520
|
+
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1521
|
+
// ) {
|
|
1522
|
+
// if (!instance.parent) {
|
|
1523
|
+
// return
|
|
1524
|
+
// }
|
|
1525
|
+
// let rowIndex: number | undefined
|
|
1526
|
+
// // @ts-ignore
|
|
1527
|
+
// if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1528
|
+
// // 表头内的控件
|
|
1529
|
+
// // @ts-ignore
|
|
1530
|
+
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1531
|
+
// rowIndex = -1
|
|
1532
|
+
// } else {
|
|
1533
|
+
// // @ts-ignore
|
|
1534
|
+
// // const index = instance.parent.children.findIndex(
|
|
1535
|
+
// // (item: any) => item === instance
|
|
1536
|
+
// // )
|
|
1537
|
+
// let instances = this.runtime.instanceMap[instance.id] || []
|
|
1538
|
+
// const index = instances.findIndex((item: any) => item === instance)
|
|
1539
|
+
// if (index > -1) {
|
|
1540
|
+
// rowIndex = index
|
|
1541
|
+
// }
|
|
1542
|
+
// }
|
|
1543
|
+
// } else {
|
|
1544
|
+
// rowIndex = this.getInstanceRowIndex(instance.parent)
|
|
1545
|
+
// }
|
|
1546
|
+
// return rowIndex
|
|
1547
|
+
// }
|
|
1548
|
+
function getInstanceRowIndex(instance) {
|
|
1492
1549
|
if (!instance.parent) {
|
|
1493
1550
|
return;
|
|
1494
1551
|
}
|
|
1495
1552
|
var rowIndex;
|
|
1496
1553
|
// @ts-ignore
|
|
1497
|
-
if (this.assertInstance(instance
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1554
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1555
|
+
rowIndex = -1;
|
|
1556
|
+
} else {
|
|
1557
|
+
var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1558
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1559
|
+
if (isColumnChild) {
|
|
1560
|
+
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1561
|
+
if (Object.prototype.toString.call(instanceList) === "[object Array]") {
|
|
1562
|
+
var index = instanceList.findIndex(function(item) {
|
|
1563
|
+
return item === instance;
|
|
1564
|
+
});
|
|
1565
|
+
if (index > -1) {
|
|
1566
|
+
rowIndex = index;
|
|
1567
|
+
}
|
|
1509
1568
|
}
|
|
1510
1569
|
}
|
|
1511
|
-
} else {
|
|
1512
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1513
1570
|
}
|
|
1514
1571
|
return rowIndex;
|
|
1515
1572
|
}
|
|
1516
1573
|
},
|
|
1517
1574
|
{
|
|
1518
1575
|
key: "getInstanceParentControl",
|
|
1519
|
-
value:
|
|
1520
|
-
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1521
|
-
// ) {
|
|
1522
|
-
// let rowIndex: number | undefined
|
|
1523
|
-
// // @ts-ignore
|
|
1524
|
-
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1525
|
-
// rowIndex = -1
|
|
1526
|
-
// }else{
|
|
1527
|
-
// const instanceList = this.runtime.instanceMap[instance.id]
|
|
1528
|
-
// if(Object.prototype.toString.call(instanceList) === '[object Array]'){
|
|
1529
|
-
// const index = instanceList.findIndex(
|
|
1530
|
-
// (item: any) => item === instance
|
|
1531
|
-
// )
|
|
1532
|
-
// if (index > -1) {
|
|
1533
|
-
// rowIndex = index
|
|
1534
|
-
// }
|
|
1535
|
-
// }
|
|
1536
|
-
// }
|
|
1537
|
-
// return rowIndex
|
|
1538
|
-
// }
|
|
1539
|
-
function getInstanceParentControl(instance, controlType) {
|
|
1576
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1540
1577
|
if (!instance.parent) {
|
|
1541
1578
|
return;
|
|
1542
1579
|
}
|
|
@@ -1615,12 +1652,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1615
1652
|
{
|
|
1616
1653
|
key: "register",
|
|
1617
1654
|
value: // 注册外部控件
|
|
1618
|
-
function register() {
|
|
1619
|
-
|
|
1620
|
-
arg[_key] = arguments[_key];
|
|
1621
|
-
}
|
|
1622
|
-
var _Runtime;
|
|
1623
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
|
|
1655
|
+
function register(control) {
|
|
1656
|
+
return Runtime.register(control, "Runtime");
|
|
1624
1657
|
}
|
|
1625
1658
|
},
|
|
1626
1659
|
{
|
|
@@ -1632,4 +1665,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1632
1665
|
]);
|
|
1633
1666
|
return Engine;
|
|
1634
1667
|
}(Watcher);
|
|
1668
|
+
// @ts-ignore
|
|
1635
1669
|
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.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
|
@@ -200,7 +200,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
200
200
|
{
|
|
201
201
|
key: "getDataBind",
|
|
202
202
|
value: function getDataBind(controlId) {
|
|
203
|
-
var _result;
|
|
204
203
|
var result = this.controlIdMapping[controlId];
|
|
205
204
|
if (result) {
|
|
206
205
|
return result.dataBind;
|
|
@@ -216,7 +215,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
|
-
return
|
|
218
|
+
return result === null || result === void 0 ? void 0 : result.dataBind;
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
]);
|
|
@@ -345,9 +345,8 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
345
345
|
key: "transform",
|
|
346
346
|
value: function transform(value, oldValue) {
|
|
347
347
|
if (value === undefined || value === null || value === "") {
|
|
348
|
-
var _oldValue;
|
|
349
348
|
return new AmountValue({
|
|
350
|
-
currency:
|
|
349
|
+
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
351
350
|
});
|
|
352
351
|
}
|
|
353
352
|
var result;
|
|
@@ -445,9 +444,8 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
445
444
|
key: "transform",
|
|
446
445
|
value: function transform(value, oldValue) {
|
|
447
446
|
if (value === undefined || value === null || value === "") {
|
|
448
|
-
var _oldValue;
|
|
449
447
|
return new CalcValue({
|
|
450
|
-
unit:
|
|
448
|
+
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
451
449
|
});
|
|
452
450
|
}
|
|
453
451
|
var result;
|
|
@@ -237,18 +237,17 @@ function flatInstanceForChildren(controls) {
|
|
|
237
237
|
var index = Number(key);
|
|
238
238
|
var isNotIndex = Number.isNaN(index);
|
|
239
239
|
if (isNotIndex && prevItem) {
|
|
240
|
-
var
|
|
241
|
-
var
|
|
242
|
-
var findEndItem = (_flatChildren = flatChildren) === null || _flatChildren === void 0 ? void 0 : _flatChildren.find(function(item) {
|
|
240
|
+
var flatChildren = (prevItem === null || prevItem === void 0 ? void 0 : prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
|
|
241
|
+
var findEndItem = flatChildren === null || flatChildren === void 0 ? void 0 : flatChildren.find(function(item) {
|
|
243
242
|
return item.id === key;
|
|
244
243
|
});
|
|
245
244
|
// 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
|
|
246
245
|
return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
|
|
247
246
|
} else {
|
|
248
|
-
var _prevItem_children
|
|
247
|
+
var _prevItem_children;
|
|
249
248
|
var _prevItem_children_index;
|
|
250
249
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
251
|
-
return (_prevItem_children_index =
|
|
250
|
+
return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
|
|
252
251
|
}
|
|
253
252
|
}, initInstance);
|
|
254
253
|
}
|
|
@@ -156,7 +156,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
156
156
|
if (control.props.isHide) {
|
|
157
157
|
return true;
|
|
158
158
|
}
|
|
159
|
-
if (control.parent === null) {
|
|
159
|
+
if (control.parent === null || control.parent === undefined) {
|
|
160
160
|
return false;
|
|
161
161
|
}
|
|
162
162
|
return this.getControlIsHide(control.parent);
|
|
@@ -355,7 +355,6 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
355
355
|
* */ // @ts-ignore
|
|
356
356
|
function computedCalcValue(control) {
|
|
357
357
|
var _this = this;
|
|
358
|
-
var _oldValue, _oldValue1;
|
|
359
358
|
var scriptEcho = control.props.scriptEcho;
|
|
360
359
|
if (!scriptEcho || scriptEcho.length === 0) {
|
|
361
360
|
return;
|
|
@@ -430,13 +429,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
430
429
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
431
430
|
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
|
|
432
431
|
// 如果值没变的话,不触发修改
|
|
433
|
-
if (result === (
|
|
432
|
+
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
434
433
|
return;
|
|
435
434
|
}
|
|
436
435
|
var _oldValue_unit;
|
|
437
436
|
this.engine.setState(control.id, {
|
|
438
437
|
result: result,
|
|
439
|
-
unit: (_oldValue_unit =
|
|
438
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
|
|
440
439
|
}, rowIndex);
|
|
441
440
|
}
|
|
442
441
|
},
|