@byteluck-fe/model-driven-engine 2.7.0-alpha.38a → 2.7.0-alpha.39
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 +89 -142
- package/dist/esm/common/OkWorker.js +4 -4
- package/dist/esm/common/Runtime.js +30 -69
- package/dist/esm/common/checkerValue.js +8 -8
- package/dist/esm/common/proxyState.js +6 -6
- package/dist/esm/plugins/CalcPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +18 -47
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +3 -4
- package/dist/types/common/Runtime.d.ts +0 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +1 -2
- package/package.json +4 -4
|
@@ -646,6 +646,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
646
646
|
// for (let i = 0; i < newValue.length; i++) {
|
|
647
647
|
// this.setStates(newValue[i], i, options)
|
|
648
648
|
// }
|
|
649
|
+
var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
|
|
650
|
+
if ((eventOptionsTemp === null || eventOptionsTemp === void 0 ? void 0 : eventOptionsTemp.listChange) === "noDelete") {
|
|
651
|
+
deleted = [];
|
|
652
|
+
}
|
|
649
653
|
this.emit("list-change", {
|
|
650
654
|
instance: instance,
|
|
651
655
|
value: value,
|
|
@@ -653,7 +657,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
653
657
|
// @ts-ignore
|
|
654
658
|
changed: newRows,
|
|
655
659
|
data: newValue,
|
|
656
|
-
deleted:
|
|
660
|
+
deleted: deleted,
|
|
661
|
+
// deleted: oldValue ?? [],
|
|
662
|
+
type: "push"
|
|
657
663
|
})
|
|
658
664
|
});
|
|
659
665
|
} else {
|
|
@@ -700,32 +706,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
700
706
|
var template = JSONCopy(instance.props.headers);
|
|
701
707
|
// @ts-ignore
|
|
702
708
|
var columns = this.createControl(template);
|
|
703
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
704
|
-
try {
|
|
705
|
-
for(var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
706
|
-
var column = _step.value;
|
|
707
|
-
if (!column.parent) {
|
|
708
|
-
this.runtime.resetInstanceParent(column, inst);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
} catch (err) {
|
|
712
|
-
_didIteratorError = true;
|
|
713
|
-
_iteratorError = err;
|
|
714
|
-
} finally{
|
|
715
|
-
try {
|
|
716
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
717
|
-
_iterator.return();
|
|
718
|
-
}
|
|
719
|
-
} finally{
|
|
720
|
-
if (_didIteratorError) {
|
|
721
|
-
throw _iteratorError;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
709
|
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
726
710
|
}
|
|
727
|
-
//@ts-ignore
|
|
728
|
-
row.parent = instance;
|
|
729
711
|
return row;
|
|
730
712
|
}
|
|
731
713
|
},
|
|
@@ -845,12 +827,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
845
827
|
return this.setInstance(instance, props, value, rowIndex);
|
|
846
828
|
}
|
|
847
829
|
},
|
|
848
|
-
{
|
|
849
|
-
key: "getRule",
|
|
850
|
-
value: function getRule(controlType, props) {
|
|
851
|
-
return Runtime.staticGetRules(controlType, props);
|
|
852
|
-
}
|
|
853
|
-
},
|
|
854
830
|
{
|
|
855
831
|
key: "getAllRules",
|
|
856
832
|
value: function getAllRules(controlId) {
|
|
@@ -1160,7 +1136,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1160
1136
|
value: function buildFields(dataCode, state) {
|
|
1161
1137
|
var _this = this;
|
|
1162
1138
|
var mapping = this.getDataBindMapping(dataCode);
|
|
1163
|
-
if (!mapping
|
|
1139
|
+
if (!mapping) {
|
|
1164
1140
|
return;
|
|
1165
1141
|
}
|
|
1166
1142
|
var skipKeys = [];
|
|
@@ -1313,7 +1289,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1313
1289
|
}
|
|
1314
1290
|
});
|
|
1315
1291
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1316
|
-
this.setStates(newState, undefined,
|
|
1292
|
+
this.setStates(newState, undefined, _object_spread({
|
|
1293
|
+
listChange: "noDelete"
|
|
1294
|
+
}, options));
|
|
1317
1295
|
this.debugLog("engine setData方法执行完成。");
|
|
1318
1296
|
}
|
|
1319
1297
|
},
|
|
@@ -1353,59 +1331,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1353
1331
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1354
1332
|
* @param controlId
|
|
1355
1333
|
* @param header 明细表内是否获取表头的控件
|
|
1356
|
-
*/
|
|
1357
|
-
// controlId?: string,
|
|
1358
|
-
// header: boolean = false
|
|
1359
|
-
// ): ControlRuntimeInstance<ControlsKeys>[] {
|
|
1360
|
-
// // const cc = console
|
|
1361
|
-
// // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1362
|
-
// // cc.time(label)
|
|
1363
|
-
//
|
|
1364
|
-
// if (controlId === undefined) {
|
|
1365
|
-
// // cc.timeEnd(label)
|
|
1366
|
-
// return this.runtime.flatInstances
|
|
1367
|
-
// }
|
|
1368
|
-
// const instances = Array.from(this.runtime.instanceMap[controlId] || [])
|
|
1369
|
-
// if (header) {
|
|
1370
|
-
// // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1371
|
-
// if (instances.length) {
|
|
1372
|
-
// const instance: RuntimeControl = instances[0]
|
|
1373
|
-
// // if (this.inList(instance.id) === true) {
|
|
1374
|
-
// if (this.inList(instance.id) !== undefined) {
|
|
1375
|
-
// const headerInstance = this.getInstanceInSubtableHeader(instance)
|
|
1376
|
-
// if (headerInstance) {
|
|
1377
|
-
// instances.unshift(headerInstance)
|
|
1378
|
-
// }
|
|
1379
|
-
// }
|
|
1380
|
-
// } else {
|
|
1381
|
-
// const controlIdMapping = this.getControlIdMapping()
|
|
1382
|
-
// const [subtableId] =
|
|
1383
|
-
// Object.entries(controlIdMapping).find(
|
|
1384
|
-
// ([_, mapping]) => mapping.children && controlId in mapping.children
|
|
1385
|
-
// ) ?? []
|
|
1386
|
-
// if (subtableId) {
|
|
1387
|
-
// const subtable = this.getInstance(subtableId)
|
|
1388
|
-
// // @ts-ignore
|
|
1389
|
-
// const headerColumn = subtable.props.headers.find((column: any) =>
|
|
1390
|
-
// column.children.find((item: any) => item.id === controlId)
|
|
1391
|
-
// )
|
|
1392
|
-
// if (headerColumn) {
|
|
1393
|
-
// const headerInstance = headerColumn.children.find(
|
|
1394
|
-
// (item: any) => item.id === controlId
|
|
1395
|
-
// )
|
|
1396
|
-
// if (headerInstance) {
|
|
1397
|
-
// instances.unshift(
|
|
1398
|
-
// headerInstance as ControlRuntimeInstance<ControlsKeys>
|
|
1399
|
-
// )
|
|
1400
|
-
// }
|
|
1401
|
-
// }
|
|
1402
|
-
// }
|
|
1403
|
-
// }
|
|
1404
|
-
// }
|
|
1405
|
-
// // @ts-ignore
|
|
1406
|
-
// return instances
|
|
1407
|
-
// }
|
|
1408
|
-
key: "getInstances",
|
|
1334
|
+
*/ key: "getInstances",
|
|
1409
1335
|
value: function getInstances(controlId) {
|
|
1410
1336
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1411
1337
|
// const cc = console
|
|
@@ -1415,15 +1341,42 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1415
1341
|
// cc.timeEnd(label)
|
|
1416
1342
|
return this.runtime.flatInstances;
|
|
1417
1343
|
}
|
|
1418
|
-
var instances = this.runtime.instanceMap[controlId] || [];
|
|
1344
|
+
var instances = Array.from(this.runtime.instanceMap[controlId] || []);
|
|
1419
1345
|
if (header) {
|
|
1420
|
-
|
|
1421
|
-
if (
|
|
1422
|
-
var
|
|
1423
|
-
//
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1346
|
+
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1347
|
+
if (instances.length) {
|
|
1348
|
+
var instance = instances[0];
|
|
1349
|
+
// if (this.inList(instance.id) === true) {
|
|
1350
|
+
if (this.inList(instance.id) !== undefined) {
|
|
1351
|
+
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1352
|
+
if (headerInstance) {
|
|
1353
|
+
instances.unshift(headerInstance);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
} else {
|
|
1357
|
+
var _this_getControlIdMapping;
|
|
1358
|
+
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1359
|
+
var _Object_entries_find;
|
|
1360
|
+
var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1361
|
+
var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
|
|
1362
|
+
return mapping.children && controlId in mapping.children;
|
|
1363
|
+
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1364
|
+
if (subtableId) {
|
|
1365
|
+
var subtable = this.getInstance(subtableId);
|
|
1366
|
+
// @ts-ignore
|
|
1367
|
+
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1368
|
+
return column.children.find(function(item) {
|
|
1369
|
+
return item.id === controlId;
|
|
1370
|
+
});
|
|
1371
|
+
});
|
|
1372
|
+
if (headerColumn) {
|
|
1373
|
+
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1374
|
+
return item.id === controlId;
|
|
1375
|
+
});
|
|
1376
|
+
if (headerInstance1) {
|
|
1377
|
+
instances.unshift(headerInstance1);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1427
1380
|
}
|
|
1428
1381
|
}
|
|
1429
1382
|
}
|
|
@@ -1546,64 +1499,55 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1546
1499
|
* 如果控件在表头内,则返回-1
|
|
1547
1500
|
* 如果控件在表内,则返回行下标
|
|
1548
1501
|
* 如果控件不在明细表内,则返回undefined
|
|
1549
|
-
* */
|
|
1550
|
-
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1551
|
-
// ) {
|
|
1552
|
-
// if (!instance.parent) {
|
|
1553
|
-
// return
|
|
1554
|
-
// }
|
|
1555
|
-
// let rowIndex: number | undefined
|
|
1556
|
-
// // @ts-ignore
|
|
1557
|
-
// if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1558
|
-
// // 表头内的控件
|
|
1559
|
-
// // @ts-ignore
|
|
1560
|
-
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1561
|
-
// rowIndex = -1
|
|
1562
|
-
// } else {
|
|
1563
|
-
// // @ts-ignore
|
|
1564
|
-
// // const index = instance.parent.children.findIndex(
|
|
1565
|
-
// // (item: any) => item === instance
|
|
1566
|
-
// // )
|
|
1567
|
-
// let instances = this.runtime.instanceMap[instance.id] || []
|
|
1568
|
-
// const index = instances.findIndex((item: any) => item === instance)
|
|
1569
|
-
// if (index > -1) {
|
|
1570
|
-
// rowIndex = index
|
|
1571
|
-
// }
|
|
1572
|
-
// }
|
|
1573
|
-
// } else {
|
|
1574
|
-
// rowIndex = this.getInstanceRowIndex(instance.parent)
|
|
1575
|
-
// }
|
|
1576
|
-
// return rowIndex
|
|
1577
|
-
// }
|
|
1578
|
-
function getInstanceRowIndex(instance) {
|
|
1502
|
+
* */ function getInstanceRowIndex(instance) {
|
|
1579
1503
|
if (!instance.parent) {
|
|
1580
1504
|
return;
|
|
1581
1505
|
}
|
|
1582
1506
|
var rowIndex;
|
|
1583
1507
|
// @ts-ignore
|
|
1584
|
-
if (this.assertInstance(instance, CONTROL_TYPE.
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
rowIndex = index;
|
|
1597
|
-
}
|
|
1508
|
+
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1509
|
+
// 表头内的控件
|
|
1510
|
+
// @ts-ignore
|
|
1511
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1512
|
+
rowIndex = -1;
|
|
1513
|
+
} else {
|
|
1514
|
+
// @ts-ignore
|
|
1515
|
+
var index = instance.parent.children.findIndex(function(item) {
|
|
1516
|
+
return item === instance;
|
|
1517
|
+
});
|
|
1518
|
+
if (index > -1) {
|
|
1519
|
+
rowIndex = index;
|
|
1598
1520
|
}
|
|
1599
1521
|
}
|
|
1522
|
+
} else {
|
|
1523
|
+
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1600
1524
|
}
|
|
1601
1525
|
return rowIndex;
|
|
1602
1526
|
}
|
|
1603
1527
|
},
|
|
1604
1528
|
{
|
|
1605
1529
|
key: "getInstanceParentControl",
|
|
1606
|
-
value:
|
|
1530
|
+
value: // public getInstanceRowIndex(
|
|
1531
|
+
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1532
|
+
// ) {
|
|
1533
|
+
// let rowIndex: number | undefined
|
|
1534
|
+
// // @ts-ignore
|
|
1535
|
+
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1536
|
+
// rowIndex = -1
|
|
1537
|
+
// }else{
|
|
1538
|
+
// const instanceList = this.runtime.instanceMap[instance.id]
|
|
1539
|
+
// if(Object.prototype.toString.call(instanceList) === '[object Array]'){
|
|
1540
|
+
// const index = instanceList.findIndex(
|
|
1541
|
+
// (item: any) => item === instance
|
|
1542
|
+
// )
|
|
1543
|
+
// if (index > -1) {
|
|
1544
|
+
// rowIndex = index
|
|
1545
|
+
// }
|
|
1546
|
+
// }
|
|
1547
|
+
// }
|
|
1548
|
+
// return rowIndex
|
|
1549
|
+
// }
|
|
1550
|
+
function getInstanceParentControl(instance, controlType) {
|
|
1607
1551
|
if (!instance.parent) {
|
|
1608
1552
|
return;
|
|
1609
1553
|
}
|
|
@@ -1682,8 +1626,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1682
1626
|
{
|
|
1683
1627
|
key: "register",
|
|
1684
1628
|
value: // 注册外部控件
|
|
1685
|
-
function register(
|
|
1686
|
-
|
|
1629
|
+
function register() {
|
|
1630
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1631
|
+
arg[_key] = arguments[_key];
|
|
1632
|
+
}
|
|
1633
|
+
var _Runtime;
|
|
1634
|
+
return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
|
|
1687
1635
|
}
|
|
1688
1636
|
},
|
|
1689
1637
|
{
|
|
@@ -1695,5 +1643,4 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1695
1643
|
]);
|
|
1696
1644
|
return Engine;
|
|
1697
1645
|
}(Watcher);
|
|
1698
|
-
// @ts-ignore
|
|
1699
1646
|
export { Engine };
|
|
@@ -77,7 +77,9 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
77
77
|
key: "createWorkerFunction",
|
|
78
78
|
value: function createWorkerFunction() {
|
|
79
79
|
return function() {
|
|
80
|
-
|
|
80
|
+
log("\uD83D\uDE80 worker running");
|
|
81
|
+
var _self = self;
|
|
82
|
+
function createHandler(parentKey) {
|
|
81
83
|
return {
|
|
82
84
|
get: function get(target, key, value) {
|
|
83
85
|
return Reflect.get(target, key, value);
|
|
@@ -92,9 +94,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
92
94
|
return Reflect.set(target, key, value);
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
|
-
}
|
|
96
|
-
log("\uD83D\uDE80 worker running");
|
|
97
|
-
var _self = self;
|
|
97
|
+
}
|
|
98
98
|
// function createProxy(
|
|
99
99
|
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
100
100
|
// parentKey?: string
|
|
@@ -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,
|
|
100
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } 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,7 +111,6 @@ 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", {});
|
|
115
114
|
var schema = props.schema;
|
|
116
115
|
_this._schema = schema;
|
|
117
116
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -124,32 +123,19 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
124
123
|
value: function getFlatInstances() {
|
|
125
124
|
var instances = [];
|
|
126
125
|
var instanceMap = {};
|
|
127
|
-
|
|
128
|
-
loop(this._instance, "", function(item, parentId) {
|
|
126
|
+
loop(this._instance, function(item) {
|
|
129
127
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// return
|
|
133
|
-
// }
|
|
134
|
-
if (parentId) {
|
|
135
|
-
// @ts-ignore
|
|
136
|
-
controlParentIdMap[item.id] = parentId;
|
|
128
|
+
if (item.type === "subtable-row" || item.type === "subtable-column") {
|
|
129
|
+
return;
|
|
137
130
|
}
|
|
131
|
+
instances.push(item);
|
|
138
132
|
if (!instanceMap[item.id]) {
|
|
139
133
|
instanceMap[item.id] = [];
|
|
140
134
|
}
|
|
141
|
-
//不知为何subtable-column会多存一次
|
|
142
|
-
if (item.type === "subtable-column") {
|
|
143
|
-
if (instanceMap[item.id].length > 0) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
instances.push(item);
|
|
148
135
|
instanceMap[item.id].push(item);
|
|
149
136
|
});
|
|
150
137
|
this._flatInstances = instances;
|
|
151
138
|
this._instanceMap = instanceMap;
|
|
152
|
-
this._controlParentIdMap = controlParentIdMap;
|
|
153
139
|
return this._flatInstances;
|
|
154
140
|
}
|
|
155
141
|
},
|
|
@@ -183,9 +169,8 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
183
169
|
var antdRules = {};
|
|
184
170
|
var ruleItems = {};
|
|
185
171
|
loopDataViewControl(this._instance, function(dataView) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
antdRules[dataView.id] = JSONCopy(result[0]);
|
|
172
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
173
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
189
174
|
loopFormControl(dataView.children, function(item) {
|
|
190
175
|
// if (
|
|
191
176
|
// item instanceof RuntimeFormControl ||
|
|
@@ -208,9 +193,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
208
193
|
get: function get() {
|
|
209
194
|
var ruleItems = {};
|
|
210
195
|
loopDataViewControl(this._instance, function(dataView) {
|
|
211
|
-
|
|
212
|
-
// ruleItems[dataView.id] = dataView.rules[0]
|
|
213
|
-
ruleItems[dataView.id] = result[0];
|
|
196
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
214
197
|
loopFormControl(dataView.children, function(item) {
|
|
215
198
|
// if (
|
|
216
199
|
// item instanceof RuntimeFormControl ||
|
|
@@ -229,9 +212,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
229
212
|
get: function get() {
|
|
230
213
|
var antdRules = {};
|
|
231
214
|
loopDataViewControl(this._instance, function(dataView) {
|
|
232
|
-
|
|
233
|
-
// antdRules[dataView.id] = dataView.rules[0]
|
|
234
|
-
antdRules[dataView.id] = result[0];
|
|
215
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
235
216
|
loopFormControl(dataView.children, function(item) {
|
|
236
217
|
// if (
|
|
237
218
|
// item instanceof RuntimeFormControl ||
|
|
@@ -248,30 +229,22 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
248
229
|
]);
|
|
249
230
|
return Runtime;
|
|
250
231
|
}(RegisterControls);
|
|
251
|
-
function loop(control,
|
|
252
|
-
|
|
253
|
-
control
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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);
|
|
261
243
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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]);
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
callback(control);
|
|
247
|
+
}
|
|
275
248
|
}
|
|
276
249
|
/**
|
|
277
250
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -279,7 +252,7 @@ function hasHeaderOrFooterControl(control, checkType) {
|
|
|
279
252
|
if (control.props.isHide) {
|
|
280
253
|
return true;
|
|
281
254
|
}
|
|
282
|
-
if (control.parent === null
|
|
255
|
+
if (control.parent === null) {
|
|
283
256
|
return false;
|
|
284
257
|
}
|
|
285
258
|
return getControlIsHide(control.parent);
|
|
@@ -289,14 +262,11 @@ item) {
|
|
|
289
262
|
if (getControlIsHide(item)) {
|
|
290
263
|
return;
|
|
291
264
|
}
|
|
292
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
293
265
|
// if (item instanceof RuntimeFormControl) {
|
|
294
266
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
295
|
-
|
|
296
|
-
data[item.id] = result;
|
|
267
|
+
data[item.id] = item.rules;
|
|
297
268
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
298
|
-
|
|
299
|
-
data[item.id] = result;
|
|
269
|
+
data[item.id] = item.rules;
|
|
300
270
|
var itemRules = {
|
|
301
271
|
type: "array",
|
|
302
272
|
fields: {}
|
|
@@ -311,13 +281,8 @@ item) {
|
|
|
311
281
|
fields: {}
|
|
312
282
|
};
|
|
313
283
|
}
|
|
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);
|
|
319
284
|
// @ts-ignore
|
|
320
|
-
itemRules.fields[index].fields[formControl.id] =
|
|
285
|
+
itemRules.fields[index].fields[formControl.id] = formControl.rules;
|
|
321
286
|
}
|
|
322
287
|
});
|
|
323
288
|
});
|
|
@@ -329,19 +294,15 @@ item) {
|
|
|
329
294
|
if (getControlIsHide(item)) {
|
|
330
295
|
return;
|
|
331
296
|
}
|
|
332
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
333
297
|
// if (item instanceof RuntimeFormControl) {
|
|
334
298
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
335
|
-
|
|
336
|
-
antdRules[item.id] = result;
|
|
299
|
+
antdRules[item.id] = item.rules;
|
|
337
300
|
} else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
|
|
338
301
|
antdRules[item.id] = [];
|
|
339
302
|
item.children.forEach(function(row) {
|
|
340
303
|
var rules = {};
|
|
341
304
|
loopFormSchema(row.children, function(formControl) {
|
|
342
|
-
|
|
343
|
-
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
344
|
-
rules[formControl.id] = childResult;
|
|
305
|
+
rules[formControl.id] = formControl.rules;
|
|
345
306
|
});
|
|
346
307
|
antdRules[item.id].push(rules);
|
|
347
308
|
});
|
|
@@ -247,13 +247,13 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
247
247
|
{
|
|
248
248
|
key: "transform",
|
|
249
249
|
value: function transform(value) {
|
|
250
|
-
|
|
250
|
+
if (value === undefined || value === null) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
function getStringValueArray(value) {
|
|
251
254
|
return value.map(function(item) {
|
|
252
255
|
return !item ? "" : String(item);
|
|
253
256
|
});
|
|
254
|
-
};
|
|
255
|
-
if (value === undefined || value === null) {
|
|
256
|
-
return [];
|
|
257
257
|
}
|
|
258
258
|
if (isArray(value)) {
|
|
259
259
|
return getStringValueArray(value);
|
|
@@ -292,15 +292,15 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
292
292
|
{
|
|
293
293
|
key: "transform",
|
|
294
294
|
value: function transform(value) {
|
|
295
|
-
|
|
295
|
+
if (value === undefined || value === null) {
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
function getNumberValueArray(value) {
|
|
296
299
|
return value.map(function(item) {
|
|
297
300
|
return !item && item !== 0 ? "" : Number(item);
|
|
298
301
|
}).filter(function(item) {
|
|
299
302
|
return item === "" || !Number.isNaN(item);
|
|
300
303
|
});
|
|
301
|
-
};
|
|
302
|
-
if (value === undefined || value === null) {
|
|
303
|
-
return [];
|
|
304
304
|
}
|
|
305
305
|
if (isArray(value)) {
|
|
306
306
|
return getNumberValueArray(value);
|
|
@@ -125,7 +125,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
125
125
|
return Reflect.get(target, propertyKey, receiver);
|
|
126
126
|
},
|
|
127
127
|
set: function set(target, propertyKey, value, receiver) {
|
|
128
|
-
var
|
|
128
|
+
var newValue = value;
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
var oldValue = target[propertyKey];
|
|
131
|
+
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
132
|
+
function reProxyState(value) {
|
|
129
133
|
if (typeof value === "object" && value !== null) {
|
|
130
134
|
// @ts-ignore
|
|
131
135
|
if (value[engineProxyFlag] !== true) {
|
|
@@ -136,11 +140,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
136
140
|
value[engineTargetKey], callback, beforeSetCallback, concatKey);
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
|
-
}
|
|
140
|
-
var newValue = value;
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
var oldValue = target[propertyKey];
|
|
143
|
-
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
143
|
+
}
|
|
144
144
|
var _reProxyState;
|
|
145
145
|
newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
|
|
146
146
|
// 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
|
|
@@ -59,12 +59,12 @@ import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from "@byteluck-fe
|
|
|
59
59
|
import { format } from "mathjs";
|
|
60
60
|
var DisplayType;
|
|
61
61
|
(function(DisplayType) {
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
63
|
* 完全等于
|
|
64
|
-
*/ "EQ"] = "EQ";
|
|
65
|
-
|
|
64
|
+
*/ DisplayType["EQ"] = "EQ";
|
|
65
|
+
/**
|
|
66
66
|
* 包含
|
|
67
|
-
* */ "IN"] = "IN";
|
|
67
|
+
* */ DisplayType["IN"] = "IN";
|
|
68
68
|
})(DisplayType || (DisplayType = {}));
|
|
69
69
|
export var CalcPlugin = /*#__PURE__*/ function() {
|
|
70
70
|
"use strict";
|