@byteluck-fe/model-driven-engine 2.8.0-alpha.2 → 2.8.0-alpha.21
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 +35 -48
- package/dist/esm/common/Store.js +27 -2
- package/dist/esm/plugins/ControlsEventPlugin.js +2 -2
- package/dist/esm/plugins/LifecycleEventPlugin.js +2 -2
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +4 -3
- package/dist/types/common/Store.d.ts +6 -2
- package/package.json +3 -3
|
@@ -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;
|
|
@@ -1285,7 +1285,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1285
1285
|
var _this_getEmptyState;
|
|
1286
1286
|
cacheEmptyState[fieldMapping.controlId] = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1287
1287
|
}
|
|
1288
|
-
var objValue = cacheEmptyState[fieldMapping.controlId];
|
|
1288
|
+
var objValue = JSONCopy(cacheEmptyState[fieldMapping.controlId]);
|
|
1289
1289
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1290
1290
|
var dataBind = fieldMapping.dataBind[key];
|
|
1291
1291
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1295,8 +1295,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1295
1295
|
});
|
|
1296
1296
|
newRow[fieldMapping.controlId] = objValue;
|
|
1297
1297
|
}
|
|
1298
|
-
} else if (fieldCode === "uid" && row
|
|
1299
|
-
newRow
|
|
1298
|
+
} else if (fieldCode === "uid" && row.uid !== undefined) {
|
|
1299
|
+
newRow.uid = row.uid;
|
|
1300
|
+
} else if (fieldCode === "virtualStore" && row.virtualStore !== undefined) {
|
|
1301
|
+
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1300
1302
|
}
|
|
1301
1303
|
});
|
|
1302
1304
|
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
@@ -1469,37 +1471,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1469
1471
|
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1470
1472
|
if (instances.length) {
|
|
1471
1473
|
var instance = instances[0];
|
|
1472
|
-
|
|
1473
|
-
if (
|
|
1474
|
-
|
|
1475
|
-
if (headerInstance) {
|
|
1476
|
-
instances.unshift(headerInstance);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
} else {
|
|
1480
|
-
var _this_getControlIdMapping;
|
|
1481
|
-
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1482
|
-
var _Object_entries_find;
|
|
1483
|
-
var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1484
|
-
var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
|
|
1485
|
-
return mapping.children && controlId in mapping.children;
|
|
1486
|
-
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1487
|
-
if (subtableId) {
|
|
1488
|
-
var subtable = this.getInstance(subtableId);
|
|
1489
|
-
// @ts-ignore
|
|
1490
|
-
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1491
|
-
return column.children.find(function(item) {
|
|
1492
|
-
return item.id === controlId;
|
|
1493
|
-
});
|
|
1494
|
-
});
|
|
1495
|
-
if (headerColumn) {
|
|
1496
|
-
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1497
|
-
return item.id === controlId;
|
|
1498
|
-
});
|
|
1499
|
-
if (headerInstance1) {
|
|
1500
|
-
instances.unshift(headerInstance1);
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1474
|
+
var headerInstance = this.findSubtableHeadersControl(instance.id);
|
|
1475
|
+
if (headerInstance !== undefined) {
|
|
1476
|
+
instances.unshift(headerInstance);
|
|
1503
1477
|
}
|
|
1504
1478
|
}
|
|
1505
1479
|
}
|
|
@@ -1656,8 +1630,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1656
1630
|
return;
|
|
1657
1631
|
}
|
|
1658
1632
|
var rowIndex;
|
|
1659
|
-
// @ts-ignore
|
|
1660
|
-
|
|
1633
|
+
var isHeaders = // @ts-ignore
|
|
1634
|
+
this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE_COLUMN) && // @ts-ignore
|
|
1635
|
+
this.assertInstance(instance.parent.parent, CONTROL_TYPE.SUBTABLE);
|
|
1636
|
+
if (isHeaders) {
|
|
1661
1637
|
rowIndex = -1;
|
|
1662
1638
|
} else {
|
|
1663
1639
|
var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
|
|
@@ -1740,18 +1716,29 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1740
1716
|
{
|
|
1741
1717
|
key: "inList",
|
|
1742
1718
|
value: function inList(controlId) {
|
|
1743
|
-
var
|
|
1744
|
-
var
|
|
1745
|
-
var
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
if (matched) {
|
|
1750
|
-
listKey = key;
|
|
1719
|
+
var mapping = this.store.subtableHeadersControlIdMapping;
|
|
1720
|
+
var subtableId = undefined;
|
|
1721
|
+
for(var key in mapping){
|
|
1722
|
+
if (controlId in mapping[key]) {
|
|
1723
|
+
subtableId = key;
|
|
1724
|
+
break;
|
|
1751
1725
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1726
|
+
}
|
|
1727
|
+
return subtableId;
|
|
1728
|
+
}
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
key: "findSubtableHeadersControl",
|
|
1732
|
+
value: function findSubtableHeadersControl(controlId) {
|
|
1733
|
+
var mapping = this.store.subtableHeadersControlIdMapping;
|
|
1734
|
+
var instance = undefined;
|
|
1735
|
+
for(var key in mapping){
|
|
1736
|
+
if (controlId in mapping[key]) {
|
|
1737
|
+
instance = mapping[key][controlId];
|
|
1738
|
+
break;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return instance;
|
|
1755
1742
|
}
|
|
1756
1743
|
}
|
|
1757
1744
|
], [
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -57,13 +57,15 @@ var Store = /*#__PURE__*/ function() {
|
|
|
57
57
|
_define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
58
58
|
);
|
|
59
59
|
_define_property(this, "controlIdMapping", void 0);
|
|
60
|
+
_define_property(this, "subtableHeadersControlIdMapping", void 0);
|
|
60
61
|
_define_property(this, "defaultState", void 0);
|
|
61
|
-
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
|
|
62
|
+
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState, subtableHeadersControlIdMapping = _init.subtableHeadersControlIdMapping;
|
|
62
63
|
this.emptyState = emptyState;
|
|
63
64
|
this.state = state;
|
|
64
65
|
this.dataBindMapping = databindMapping;
|
|
65
66
|
this.controlIdMapping = controlidMapping;
|
|
66
67
|
this.defaultState = defaultState;
|
|
68
|
+
this.subtableHeadersControlIdMapping = subtableHeadersControlIdMapping;
|
|
67
69
|
}
|
|
68
70
|
_create_class(Store, [
|
|
69
71
|
{
|
|
@@ -121,7 +123,14 @@ var Store = /*#__PURE__*/ function() {
|
|
|
121
123
|
} else {
|
|
122
124
|
var controlInfo = this.controlIdMapping[controlId];
|
|
123
125
|
if (controlInfo !== undefined) {
|
|
124
|
-
|
|
126
|
+
var data = this.state[controlInfo.dataView][controlId];
|
|
127
|
+
var _controlInfo_children;
|
|
128
|
+
// 只有明细表key,再通过rowIndex获取行数据
|
|
129
|
+
if (rowIndex !== undefined && Object.keys((_controlInfo_children = controlInfo === null || controlInfo === void 0 ? void 0 : controlInfo.children) !== null && _controlInfo_children !== void 0 ? _controlInfo_children : {}).length > 0) {
|
|
130
|
+
return data[rowIndex];
|
|
131
|
+
} else {
|
|
132
|
+
return data;
|
|
133
|
+
}
|
|
125
134
|
} else {
|
|
126
135
|
if (rowIndex !== undefined) {
|
|
127
136
|
var state;
|
|
@@ -226,6 +235,7 @@ function init(instance) {
|
|
|
226
235
|
var emptyState = {};
|
|
227
236
|
var databindMapping = {};
|
|
228
237
|
var controlidMapping = {};
|
|
238
|
+
var subtableHeadersControlIdMapping = {};
|
|
229
239
|
var defaultState = {};
|
|
230
240
|
// loopFormControl(instance, (item, children) => {
|
|
231
241
|
// })
|
|
@@ -241,6 +251,7 @@ function init(instance) {
|
|
|
241
251
|
buildState(dataViewState, emptyDataViewState, item);
|
|
242
252
|
buildDataBindMapping(databindMapping, dvId, item);
|
|
243
253
|
buildControlIdMapping(controlidMapping, dvId, item);
|
|
254
|
+
buildSubtableHeadersControlIdMapping(subtableHeadersControlIdMapping, item);
|
|
244
255
|
});
|
|
245
256
|
state[dvId] = {};
|
|
246
257
|
defaultState[dvId] = dataViewState;
|
|
@@ -249,6 +260,7 @@ function init(instance) {
|
|
|
249
260
|
return {
|
|
250
261
|
state: state,
|
|
251
262
|
defaultState: defaultState,
|
|
263
|
+
subtableHeadersControlIdMapping: subtableHeadersControlIdMapping,
|
|
252
264
|
emptyState: emptyState,
|
|
253
265
|
databindMapping: databindMapping,
|
|
254
266
|
controlidMapping: controlidMapping
|
|
@@ -393,4 +405,17 @@ item) {
|
|
|
393
405
|
});
|
|
394
406
|
}
|
|
395
407
|
}
|
|
408
|
+
function buildSubtableHeadersControlIdMapping(data, // @ts-ignore
|
|
409
|
+
item) {
|
|
410
|
+
if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
411
|
+
var headersInstances = {};
|
|
412
|
+
item.props.headers.map(// @ts-ignore
|
|
413
|
+
function(item) {
|
|
414
|
+
item.children.map(function(item) {
|
|
415
|
+
Object.assign(headersInstances, _define_property({}, item.id, item));
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
Object.assign(data, _define_property({}, item.id, headersInstances));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
396
421
|
export { Store };
|
|
@@ -69,13 +69,13 @@ function _ts_generator(thisArg, body) {
|
|
|
69
69
|
trys: [],
|
|
70
70
|
ops: []
|
|
71
71
|
};
|
|
72
|
-
return
|
|
72
|
+
return g = {
|
|
73
73
|
next: verb(0),
|
|
74
74
|
"throw": verb(1),
|
|
75
75
|
"return": verb(2)
|
|
76
76
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
77
77
|
return this;
|
|
78
|
-
}), g
|
|
78
|
+
}), g;
|
|
79
79
|
function verb(n) {
|
|
80
80
|
return function(v) {
|
|
81
81
|
return step([
|
|
@@ -115,13 +115,13 @@ function _ts_generator(thisArg, body) {
|
|
|
115
115
|
trys: [],
|
|
116
116
|
ops: []
|
|
117
117
|
};
|
|
118
|
-
return
|
|
118
|
+
return g = {
|
|
119
119
|
next: verb(0),
|
|
120
120
|
"throw": verb(1),
|
|
121
121
|
"return": verb(2)
|
|
122
122
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
123
123
|
return this;
|
|
124
|
-
}), g
|
|
124
|
+
}), g;
|
|
125
125
|
function verb(n) {
|
|
126
126
|
return function(v) {
|
|
127
127
|
return step([
|