@byteluck-fe/model-driven-engine 2.7.0-alpha.37 → 2.7.0-alpha.38a
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 +140 -79
- package/dist/esm/common/Runtime.js +69 -30
- package/dist/esm/plugins/CalcPlugin.js +11 -18
- package/dist/esm/plugins/ES6ModulePlugin.js +47 -18
- package/dist/index.umd.js +7 -7
- 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
|
@@ -700,8 +700,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
700
700
|
var template = JSONCopy(instance.props.headers);
|
|
701
701
|
// @ts-ignore
|
|
702
702
|
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
|
+
}
|
|
703
725
|
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
704
726
|
}
|
|
727
|
+
//@ts-ignore
|
|
728
|
+
row.parent = instance;
|
|
705
729
|
return row;
|
|
706
730
|
}
|
|
707
731
|
},
|
|
@@ -821,6 +845,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
821
845
|
return this.setInstance(instance, props, value, rowIndex);
|
|
822
846
|
}
|
|
823
847
|
},
|
|
848
|
+
{
|
|
849
|
+
key: "getRule",
|
|
850
|
+
value: function getRule(controlType, props) {
|
|
851
|
+
return Runtime.staticGetRules(controlType, props);
|
|
852
|
+
}
|
|
853
|
+
},
|
|
824
854
|
{
|
|
825
855
|
key: "getAllRules",
|
|
826
856
|
value: function getAllRules(controlId) {
|
|
@@ -1130,7 +1160,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1130
1160
|
value: function buildFields(dataCode, state) {
|
|
1131
1161
|
var _this = this;
|
|
1132
1162
|
var mapping = this.getDataBindMapping(dataCode);
|
|
1133
|
-
if (!mapping) {
|
|
1163
|
+
if (!mapping || !mapping.fields) {
|
|
1134
1164
|
return;
|
|
1135
1165
|
}
|
|
1136
1166
|
var skipKeys = [];
|
|
@@ -1323,7 +1353,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1323
1353
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1324
1354
|
* @param controlId
|
|
1325
1355
|
* @param header 明细表内是否获取表头的控件
|
|
1326
|
-
*/
|
|
1356
|
+
*/ // getInstances(
|
|
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",
|
|
1327
1409
|
value: function getInstances(controlId) {
|
|
1328
1410
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1329
1411
|
// const cc = console
|
|
@@ -1333,42 +1415,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1333
1415
|
// cc.timeEnd(label)
|
|
1334
1416
|
return this.runtime.flatInstances;
|
|
1335
1417
|
}
|
|
1336
|
-
var instances =
|
|
1418
|
+
var instances = this.runtime.instanceMap[controlId] || [];
|
|
1337
1419
|
if (header) {
|
|
1338
|
-
|
|
1339
|
-
if (
|
|
1340
|
-
var
|
|
1341
|
-
//
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
instances.unshift(headerInstance);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
} else {
|
|
1349
|
-
var _this_getControlIdMapping;
|
|
1350
|
-
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1351
|
-
var _Object_entries_find;
|
|
1352
|
-
var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1353
|
-
var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
|
|
1354
|
-
return mapping.children && controlId in mapping.children;
|
|
1355
|
-
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1356
|
-
if (subtableId) {
|
|
1357
|
-
var subtable = this.getInstance(subtableId);
|
|
1358
|
-
// @ts-ignore
|
|
1359
|
-
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1360
|
-
return column.children.find(function(item) {
|
|
1361
|
-
return item.id === controlId;
|
|
1362
|
-
});
|
|
1363
|
-
});
|
|
1364
|
-
if (headerColumn) {
|
|
1365
|
-
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1366
|
-
return item.id === controlId;
|
|
1367
|
-
});
|
|
1368
|
-
if (headerInstance1) {
|
|
1369
|
-
instances.unshift(headerInstance1);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1420
|
+
var instance = instances[0];
|
|
1421
|
+
if (instance) {
|
|
1422
|
+
var _instance_parent;
|
|
1423
|
+
// @ts-ignore
|
|
1424
|
+
var parentId = (_instance_parent = instance.parent) === null || _instance_parent === void 0 ? void 0 : _instance_parent.id;
|
|
1425
|
+
if (parentId) {
|
|
1426
|
+
instances = this.runtime.instanceMap[parentId] || [];
|
|
1372
1427
|
}
|
|
1373
1428
|
}
|
|
1374
1429
|
}
|
|
@@ -1491,55 +1546,64 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1491
1546
|
* 如果控件在表头内,则返回-1
|
|
1492
1547
|
* 如果控件在表内,则返回行下标
|
|
1493
1548
|
* 如果控件不在明细表内,则返回undefined
|
|
1494
|
-
* */
|
|
1549
|
+
* */ // public getInstanceRowIndex(
|
|
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) {
|
|
1495
1579
|
if (!instance.parent) {
|
|
1496
1580
|
return;
|
|
1497
1581
|
}
|
|
1498
1582
|
var rowIndex;
|
|
1499
1583
|
// @ts-ignore
|
|
1500
|
-
if (this.assertInstance(instance
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1584
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1585
|
+
rowIndex = -1;
|
|
1586
|
+
} else {
|
|
1587
|
+
var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1588
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1589
|
+
if (isColumnChild) {
|
|
1590
|
+
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1591
|
+
if (Object.prototype.toString.call(instanceList) === "[object Array]") {
|
|
1592
|
+
var index = instanceList.findIndex(function(item) {
|
|
1593
|
+
return item === instance;
|
|
1594
|
+
});
|
|
1595
|
+
if (index > -1) {
|
|
1596
|
+
rowIndex = index;
|
|
1597
|
+
}
|
|
1512
1598
|
}
|
|
1513
1599
|
}
|
|
1514
|
-
} else {
|
|
1515
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1516
1600
|
}
|
|
1517
1601
|
return rowIndex;
|
|
1518
1602
|
}
|
|
1519
1603
|
},
|
|
1520
1604
|
{
|
|
1521
1605
|
key: "getInstanceParentControl",
|
|
1522
|
-
value:
|
|
1523
|
-
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1524
|
-
// ) {
|
|
1525
|
-
// let rowIndex: number | undefined
|
|
1526
|
-
// // @ts-ignore
|
|
1527
|
-
// if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1528
|
-
// rowIndex = -1
|
|
1529
|
-
// }else{
|
|
1530
|
-
// const instanceList = this.runtime.instanceMap[instance.id]
|
|
1531
|
-
// if(Object.prototype.toString.call(instanceList) === '[object Array]'){
|
|
1532
|
-
// const index = instanceList.findIndex(
|
|
1533
|
-
// (item: any) => item === instance
|
|
1534
|
-
// )
|
|
1535
|
-
// if (index > -1) {
|
|
1536
|
-
// rowIndex = index
|
|
1537
|
-
// }
|
|
1538
|
-
// }
|
|
1539
|
-
// }
|
|
1540
|
-
// return rowIndex
|
|
1541
|
-
// }
|
|
1542
|
-
function getInstanceParentControl(instance, controlType) {
|
|
1606
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1543
1607
|
if (!instance.parent) {
|
|
1544
1608
|
return;
|
|
1545
1609
|
}
|
|
@@ -1618,12 +1682,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1618
1682
|
{
|
|
1619
1683
|
key: "register",
|
|
1620
1684
|
value: // 注册外部控件
|
|
1621
|
-
function register() {
|
|
1622
|
-
|
|
1623
|
-
arg[_key] = arguments[_key];
|
|
1624
|
-
}
|
|
1625
|
-
var _Runtime;
|
|
1626
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
|
|
1685
|
+
function register(control) {
|
|
1686
|
+
return Runtime.register(control, "Runtime");
|
|
1627
1687
|
}
|
|
1628
1688
|
},
|
|
1629
1689
|
{
|
|
@@ -1635,4 +1695,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1635
1695
|
]);
|
|
1636
1696
|
return Engine;
|
|
1637
1697
|
}(Watcher);
|
|
1698
|
+
// @ts-ignore
|
|
1638
1699
|
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
|
});
|
|
@@ -167,12 +167,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
167
167
|
value: function apply(engine) {
|
|
168
168
|
var _this = this;
|
|
169
169
|
this.engine = engine;
|
|
170
|
-
this.resetDependencies();
|
|
171
170
|
this.watchControlChange();
|
|
172
171
|
this.watchSubtableChange();
|
|
173
172
|
this.watchSchemaHideChange();
|
|
174
173
|
this.engine.on("engine-mounted", function() {
|
|
175
|
-
|
|
174
|
+
requestAnimationFrame(function() {
|
|
175
|
+
_this.resetDependencies();
|
|
176
|
+
_this.allCalcControlComputed();
|
|
177
|
+
});
|
|
176
178
|
});
|
|
177
179
|
}
|
|
178
180
|
},
|
|
@@ -326,25 +328,16 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
326
328
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
327
329
|
// 在明细子表中的控件,如果计算公式也在明细子表,那只触发同一行的计算公式的计算
|
|
328
330
|
if (payload.rowIndex !== undefined && payload.rowIndex > -1) {
|
|
329
|
-
var _payload_instance_parent, _payload_instance;
|
|
330
|
-
// 对发生改变的行进行重新计算
|
|
331
|
-
var changedCalc = _this.getCalcControlsFromSubtableRows([
|
|
332
|
-
(_payload_instance = payload.instance) === null || _payload_instance === void 0 ? void 0 : (_payload_instance_parent = _payload_instance.parent) === null || _payload_instance_parent === void 0 ? void 0 : _payload_instance_parent.parent
|
|
333
|
-
]);
|
|
334
331
|
// @ts-ignore
|
|
335
|
-
|
|
332
|
+
calcControls.forEach(function(calcControl) {
|
|
333
|
+
if (_this.controlInSubtable(calcControl)) {
|
|
334
|
+
var calcIndex = _this.engine.getInstanceRowIndex(calcControl);
|
|
335
|
+
if (calcIndex !== payload.rowIndex) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
336
339
|
_this.computedCalcValue(calcControl);
|
|
337
340
|
});
|
|
338
|
-
// @ts-ignore
|
|
339
|
-
// calcControls.forEach((calcControl: ControlRuntimeInstance<'calc'>) => {
|
|
340
|
-
// if (this.controlInSubtable(calcControl)) {
|
|
341
|
-
// const calcIndex = this.engine.getInstanceRowIndex(calcControl)
|
|
342
|
-
// if (calcIndex !== payload.rowIndex) {
|
|
343
|
-
// return
|
|
344
|
-
// }
|
|
345
|
-
// }
|
|
346
|
-
// this.computedCalcValue(calcControl)
|
|
347
|
-
// })
|
|
348
341
|
} else {
|
|
349
342
|
// @ts-ignore
|
|
350
343
|
calcControls.forEach(function(calcControl) {
|
|
@@ -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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
111
|
-
_didIteratorError = true;
|
|
112
|
-
_iteratorError = err;
|
|
113
|
-
} finally{
|
|
132
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
114
133
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
120
|
-
|
|
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
|
}
|