@byteluck-fe/model-driven-engine 2.6.0-alpha.8 → 2.7.0-alpha.0
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 +97 -87
- package/dist/esm/common/Store.js +25 -4
- package/dist/esm/plugins/CalcPlugin.js +10 -6
- package/dist/esm/utils/runtimeUtils.js +1 -1
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +1 -1
- package/dist/types/common/Store.d.ts +1 -0
- package/package.json +4 -4
|
@@ -354,6 +354,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
354
354
|
}
|
|
355
355
|
// @ts-ignore
|
|
356
356
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
357
|
+
var ref;
|
|
357
358
|
if (newValue === null) {
|
|
358
359
|
return [];
|
|
359
360
|
}
|
|
@@ -368,7 +369,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
368
369
|
}, {});
|
|
369
370
|
// @ts-ignore
|
|
370
371
|
var emptyState = this.getEmptyState(instance.id);
|
|
371
|
-
return newValue.map(function(row) {
|
|
372
|
+
return (ref = newValue) === null || ref === void 0 ? void 0 : ref.map(function(row) {
|
|
372
373
|
// @ts-ignore
|
|
373
374
|
return checkerSubtableValue(fieldTypeMap, row, emptyState);
|
|
374
375
|
});
|
|
@@ -769,7 +770,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
769
770
|
*/ key: "setStates",
|
|
770
771
|
value: function setStates(states, rowIndex, options) {
|
|
771
772
|
var _this = this;
|
|
772
|
-
var newStates = states;
|
|
773
|
+
var newStates = states !== null && states !== void 0 ? states : {};
|
|
773
774
|
Object.keys(newStates).forEach(function(stateId) {
|
|
774
775
|
var _this2 = _this;
|
|
775
776
|
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
@@ -842,15 +843,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
842
843
|
var data = getFieldData.map(function(item) {
|
|
843
844
|
var obj = {};
|
|
844
845
|
for(var key in item){
|
|
845
|
-
var ref, ref2, ref3
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
846
|
+
var ref, ref2, ref3;
|
|
847
|
+
var fieldCode = (ref2 = (ref = controlIdMapping[controlId]) === null || ref === void 0 ? void 0 : ref.children[key]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.dataBind) === null || ref3 === void 0 ? void 0 : ref3.fieldCode;
|
|
848
|
+
//未绑定字段的控件,直接抛弃
|
|
849
|
+
if (fieldCode !== '') {
|
|
850
|
+
var ref4;
|
|
851
|
+
if (fieldCode) {
|
|
852
|
+
obj[fieldCode] = item[key];
|
|
853
|
+
} else if ((ref4 = controlIdMapping[controlId]) === null || ref4 === void 0 ? void 0 : ref4.children[key]) {
|
|
854
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
855
|
+
for(var keyChi in item[key]){
|
|
856
|
+
var ref5, ref6;
|
|
857
|
+
obj[(ref6 = (ref5 = controlIdMapping[controlId]) === null || ref5 === void 0 ? void 0 : ref5.children[key]) === null || ref6 === void 0 ? void 0 : ref6.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
858
|
+
}
|
|
854
859
|
}
|
|
855
860
|
}
|
|
856
861
|
}
|
|
@@ -859,25 +864,27 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
859
864
|
return data;
|
|
860
865
|
} else {
|
|
861
866
|
var _loop = function(key1) {
|
|
862
|
-
var
|
|
863
|
-
if ((
|
|
867
|
+
var ref15, ref7, ref8, ref9;
|
|
868
|
+
if ((ref15 = controlIdMapping[key1]) === null || ref15 === void 0 ? void 0 : (ref7 = ref15.dataBind) === null || ref7 === void 0 ? void 0 : ref7.fieldCode) {
|
|
869
|
+
var ref10;
|
|
870
|
+
obj1[(ref10 = controlIdMapping[key1]) === null || ref10 === void 0 ? void 0 : ref10.dataBind.fieldCode] = getFieldData[key1];
|
|
871
|
+
} else if ((ref8 = controlIdMapping[key1]) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.dataBind) === null || ref9 === void 0 ? void 0 : ref9.dataCode) {
|
|
864
872
|
var ref11;
|
|
865
|
-
obj1[(ref11 = controlIdMapping[key1]) === null || ref11 === void 0 ? void 0 : ref11.dataBind.fieldCode] = getFieldData[key1];
|
|
866
|
-
} else if ((ref9 = controlIdMapping[key1]) === null || ref9 === void 0 ? void 0 : (ref10 = ref9.dataBind) === null || ref10 === void 0 ? void 0 : ref10.dataCode) {
|
|
867
|
-
var ref12;
|
|
868
873
|
// 明细字表只循环一层明细子表未递归
|
|
869
|
-
obj1[(
|
|
874
|
+
obj1[(ref11 = controlIdMapping[key1]) === null || ref11 === void 0 ? void 0 : ref11.dataBind.dataCode] = getFieldData[key1].map(function(item) {
|
|
870
875
|
var objChi = {};
|
|
871
876
|
for(var keyChi in item){
|
|
872
877
|
var ref;
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
878
|
+
var fieldCode = (ref = controlIdMapping[key1].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode;
|
|
879
|
+
//未绑定字段的控件,直接抛弃
|
|
880
|
+
if (fieldCode !== '') {
|
|
881
|
+
if (fieldCode) {
|
|
882
|
+
objChi[fieldCode] = item[keyChi];
|
|
883
|
+
} else {
|
|
884
|
+
for(var keyChi1 in item[keyChi]){
|
|
885
|
+
var ref14;
|
|
886
|
+
objChi[(ref14 = controlIdMapping[key1].children[keyChi]) === null || ref14 === void 0 ? void 0 : ref14.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
887
|
+
}
|
|
881
888
|
}
|
|
882
889
|
}
|
|
883
890
|
}
|
|
@@ -886,8 +893,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
886
893
|
} else if (controlIdMapping[key1]) {
|
|
887
894
|
// 兼容一个控件需要绑定多个字段的情况
|
|
888
895
|
for(var keyChi2 in getFieldData[key1]){
|
|
889
|
-
var
|
|
890
|
-
obj1[(
|
|
896
|
+
var ref12, ref13;
|
|
897
|
+
obj1[(ref13 = (ref12 = controlIdMapping[key1]) === null || ref12 === void 0 ? void 0 : ref12.dataBind[keyChi2]) === null || ref13 === void 0 ? void 0 : ref13.fieldCode] = getFieldData[key1][keyChi2];
|
|
891
898
|
}
|
|
892
899
|
}
|
|
893
900
|
};
|
|
@@ -1030,40 +1037,38 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1030
1037
|
value: function setData(dataSet, options) {
|
|
1031
1038
|
var _this6 = this;
|
|
1032
1039
|
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1033
|
-
var
|
|
1034
|
-
if (isString(value) || Array.isArray(value)) {
|
|
1035
|
-
return value.length === 0;
|
|
1036
|
-
}
|
|
1037
|
-
return false;
|
|
1038
|
-
};
|
|
1039
|
-
var newState = {};
|
|
1040
|
+
var newState = this.store.defaultState;
|
|
1040
1041
|
Object.keys(dataSet).map(function(dataCode) {
|
|
1041
1042
|
var entity = dataSet[dataCode];
|
|
1042
1043
|
if (Array.isArray(entity)) {
|
|
1043
1044
|
var _this4 = _this6;
|
|
1045
|
+
var mapping = _this6.getDataBindMapping(dataCode);
|
|
1046
|
+
if (!mapping) {
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (!newState[mapping.dataViewId]) {
|
|
1050
|
+
newState[mapping.dataViewId] = {};
|
|
1051
|
+
}
|
|
1052
|
+
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1044
1053
|
entity.map(function(row) {
|
|
1045
1054
|
var _this = _this4;
|
|
1046
|
-
var mapping = _this4.getDataBindMapping(dataCode);
|
|
1047
|
-
if (!mapping) {
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
1050
1055
|
var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1051
1056
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1052
1057
|
;
|
|
1053
1058
|
Object.keys(row).map(function(fieldCode) {
|
|
1054
|
-
var ref,
|
|
1059
|
+
var ref, ref18;
|
|
1055
1060
|
if (skipKey.includes(fieldCode)) {
|
|
1056
1061
|
return;
|
|
1057
1062
|
}
|
|
1058
|
-
var fieldMapping = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (
|
|
1063
|
+
var fieldMapping = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (ref18 = ref.fields) === null || ref18 === void 0 ? void 0 : ref18.find(function(i) {
|
|
1059
1064
|
return i.fieldCode === fieldCode;
|
|
1060
1065
|
});
|
|
1061
1066
|
if (fieldMapping) {
|
|
1062
1067
|
if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
|
|
1063
1068
|
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1064
1069
|
} else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
|
|
1065
|
-
var
|
|
1066
|
-
var objValue = JSONCopy((
|
|
1070
|
+
var ref19;
|
|
1071
|
+
var objValue = JSONCopy((ref19 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref19 !== void 0 ? ref19 : {});
|
|
1067
1072
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1068
1073
|
var dataBind = fieldMapping.dataBind[key];
|
|
1069
1074
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1075,56 +1080,55 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1075
1080
|
}
|
|
1076
1081
|
}
|
|
1077
1082
|
});
|
|
1078
|
-
if (!newState[mapping.dataViewId]) {
|
|
1079
|
-
newState[mapping.dataViewId] = {};
|
|
1080
|
-
}
|
|
1081
|
-
if (!newState[mapping.dataViewId][mapping.controlId]) {
|
|
1082
|
-
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1083
|
-
}
|
|
1084
1083
|
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1085
1084
|
});
|
|
1086
1085
|
} else if (entity) {
|
|
1087
|
-
var
|
|
1086
|
+
var ref20;
|
|
1088
1087
|
var skipKey1 = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1089
1088
|
;
|
|
1090
1089
|
var emptyState = JSONCopy(_this6.store.emptyState);
|
|
1091
|
-
Object.keys(entity).
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
newState[mapping.dataViewId[0]] = {};
|
|
1090
|
+
if (!((ref20 = Object.keys(entity)) === null || ref20 === void 0 ? void 0 : ref20.length)) {
|
|
1091
|
+
// newState = this.store.defaultState
|
|
1092
|
+
} else {
|
|
1093
|
+
var _this3 = _this6;
|
|
1094
|
+
Object.keys(entity).map(function(fieldCode) {
|
|
1095
|
+
if (skipKey1.includes(fieldCode)) {
|
|
1096
|
+
return;
|
|
1099
1097
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1098
|
+
var mapping = _this3.getDataBindMapping(dataCode, fieldCode);
|
|
1099
|
+
if (mapping) {
|
|
1100
|
+
if (!newState[mapping.dataViewId[0]]) {
|
|
1101
|
+
newState[mapping.dataViewId[0]] = {};
|
|
1102
|
+
}
|
|
1103
|
+
if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
|
|
1104
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1105
|
+
} else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
|
|
1106
|
+
var ref;
|
|
1107
|
+
var objValue = (ref = _this3.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
|
|
1108
|
+
Object.keys(mapping.dataBind).map(function(key) {
|
|
1109
|
+
var dataBind = mapping.dataBind[key];
|
|
1110
|
+
if (entity[dataBind.fieldCode] !== undefined) {
|
|
1111
|
+
objValue[key] = entity[dataBind.fieldCode];
|
|
1112
|
+
}
|
|
1113
|
+
skipKey1.push(dataBind.fieldCode);
|
|
1114
|
+
});
|
|
1115
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1116
|
+
}
|
|
1113
1117
|
}
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1116
1120
|
var newMapping = _this6.getDataBindMapping(dataCode);
|
|
1117
1121
|
if (newMapping) {
|
|
1118
|
-
var
|
|
1119
|
-
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (
|
|
1122
|
+
var ref16;
|
|
1123
|
+
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (ref16 = newMapping.fields) === null || ref16 === void 0 ? void 0 : ref16.map(function(item) {
|
|
1120
1124
|
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1121
1125
|
});
|
|
1122
1126
|
var mappingValue = _this6.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1123
|
-
var
|
|
1124
|
-
var mainStateKeys = Object.keys((
|
|
1127
|
+
var ref17;
|
|
1128
|
+
var mainStateKeys = Object.keys((ref17 = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && ref17 !== void 0 ? ref17 : {});
|
|
1125
1129
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1126
|
-
if (!mainStateKeys.includes(key) && key !== 'uid') {
|
|
1127
|
-
if (Object.keys(newState).length
|
|
1130
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1131
|
+
if (Object.keys(newState).length) {
|
|
1128
1132
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
|
|
1129
1133
|
} else {
|
|
1130
1134
|
Object.assign(newState, _defineProperty({}, newMapping.controlId, _defineProperty({}, key, mappingValue[key])));
|
|
@@ -1191,19 +1195,20 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1191
1195
|
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1192
1196
|
if (instances.length) {
|
|
1193
1197
|
var instance = instances[0];
|
|
1194
|
-
if (this.inList(instance.id)
|
|
1198
|
+
if (this.inList(instance.id) !== undefined) {
|
|
1195
1199
|
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1196
1200
|
if (headerInstance) {
|
|
1197
1201
|
instances.unshift(headerInstance);
|
|
1198
1202
|
}
|
|
1199
1203
|
}
|
|
1200
1204
|
} else {
|
|
1201
|
-
var controlIdMapping = this.getControlIdMapping();
|
|
1202
1205
|
var ref;
|
|
1203
|
-
var
|
|
1206
|
+
var controlIdMapping = (ref = this.getControlIdMapping()) !== null && ref !== void 0 ? ref : {};
|
|
1207
|
+
var ref21;
|
|
1208
|
+
var ref22 = _slicedToArray((ref21 = Object.entries(controlIdMapping).find(function(param) {
|
|
1204
1209
|
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1205
1210
|
return mapping.children && controlId in mapping.children;
|
|
1206
|
-
})) !== null &&
|
|
1211
|
+
})) !== null && ref21 !== void 0 ? ref21 : [], 1), subtableId = ref22[0];
|
|
1207
1212
|
if (subtableId) {
|
|
1208
1213
|
var subtable = this.getInstance(subtableId);
|
|
1209
1214
|
// @ts-ignore
|
|
@@ -1423,12 +1428,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1423
1428
|
{
|
|
1424
1429
|
key: "inList",
|
|
1425
1430
|
value: function inList(controlId) {
|
|
1426
|
-
var
|
|
1427
|
-
var
|
|
1431
|
+
var _controlIdMapping;
|
|
1432
|
+
var mapping = (_controlIdMapping = this.store.controlIdMapping) !== null && _controlIdMapping !== void 0 ? _controlIdMapping : {};
|
|
1433
|
+
var listKey = undefined;
|
|
1434
|
+
Object.keys(mapping).some(function(key) {
|
|
1428
1435
|
var ref, ref23;
|
|
1429
|
-
|
|
1436
|
+
var matched = (ref = mapping[key]) === null || ref === void 0 ? void 0 : (ref23 = ref.children) === null || ref23 === void 0 ? void 0 : ref23.hasOwnProperty(controlId);
|
|
1437
|
+
if (matched) {
|
|
1438
|
+
listKey = key;
|
|
1439
|
+
}
|
|
1440
|
+
return matched;
|
|
1430
1441
|
});
|
|
1431
|
-
return
|
|
1442
|
+
return listKey;
|
|
1432
1443
|
}
|
|
1433
1444
|
}
|
|
1434
1445
|
], [
|
|
@@ -1453,4 +1464,3 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1453
1464
|
return Engine;
|
|
1454
1465
|
}(Watcher);
|
|
1455
1466
|
export { Engine };
|
|
1456
|
-
console.log('a');
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -37,6 +37,21 @@ function _instanceof(left, right) {
|
|
|
37
37
|
return left instanceof right;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
function _objectSpread(target) {
|
|
41
|
+
for(var i = 1; i < arguments.length; i++){
|
|
42
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
43
|
+
var ownKeys = Object.keys(source);
|
|
44
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
45
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
46
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
ownKeys.forEach(function(key) {
|
|
50
|
+
_defineProperty(target, key, source[key]);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return target;
|
|
54
|
+
}
|
|
40
55
|
import { DataBind, ObjectDataBind } from '@byteluck-fe/model-driven-core';
|
|
41
56
|
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
42
57
|
import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
|
|
@@ -44,11 +59,12 @@ var Store = /*#__PURE__*/ function() {
|
|
|
44
59
|
"use strict";
|
|
45
60
|
function Store(props) {
|
|
46
61
|
_classCallCheck(this, Store);
|
|
47
|
-
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping;
|
|
62
|
+
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
|
|
48
63
|
this.emptyState = emptyState;
|
|
49
64
|
this.state = state;
|
|
50
65
|
this.dataBindMapping = databindMapping;
|
|
51
66
|
this.controlIdMapping = controlidMapping;
|
|
67
|
+
this.defaultState = defaultState;
|
|
52
68
|
}
|
|
53
69
|
_createClass(Store, [
|
|
54
70
|
{
|
|
@@ -214,6 +230,7 @@ function init(instance) {
|
|
|
214
230
|
var emptyState = {};
|
|
215
231
|
var databindMapping = {};
|
|
216
232
|
var controlidMapping = {};
|
|
233
|
+
var defaultState = {};
|
|
217
234
|
// loopFormControl(instance, (item, children) => {
|
|
218
235
|
// })
|
|
219
236
|
// @ts-ignore
|
|
@@ -229,11 +246,13 @@ function init(instance) {
|
|
|
229
246
|
buildDataBindMapping(databindMapping, dvId, item);
|
|
230
247
|
buildControlIdMapping(controlidMapping, dvId, item);
|
|
231
248
|
});
|
|
232
|
-
state[dvId] =
|
|
249
|
+
state[dvId] = {};
|
|
250
|
+
defaultState[dvId] = dataViewState;
|
|
233
251
|
emptyState[dvId] = emptyDataViewState;
|
|
234
252
|
});
|
|
235
253
|
return {
|
|
236
254
|
state: state,
|
|
255
|
+
defaultState: defaultState,
|
|
237
256
|
emptyState: emptyState,
|
|
238
257
|
databindMapping: databindMapping,
|
|
239
258
|
controlidMapping: controlidMapping
|
|
@@ -244,7 +263,7 @@ item) {
|
|
|
244
263
|
//if (item instanceof RuntimeFormControl) {
|
|
245
264
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
246
265
|
// 2023-4-2 jiaqi 首次进入页面去除填充默认值
|
|
247
|
-
|
|
266
|
+
dataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
248
267
|
emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
249
268
|
} else {
|
|
250
269
|
var emptyTemplate = {};
|
|
@@ -253,7 +272,9 @@ item) {
|
|
|
253
272
|
});
|
|
254
273
|
var _defaultRows;
|
|
255
274
|
dataViewState[item.id] = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
|
|
256
|
-
return
|
|
275
|
+
return _objectSpread({
|
|
276
|
+
uid: 'new:' + buildUUID('uid')
|
|
277
|
+
}, JSONCopy(emptyTemplate));
|
|
257
278
|
});
|
|
258
279
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
259
280
|
}
|
|
@@ -350,6 +350,10 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
350
350
|
if (!scriptEcho || scriptEcho.length === 0) {
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
353
|
+
var rowIndex = undefined;
|
|
354
|
+
if (this.controlInSubtable(control)) {
|
|
355
|
+
rowIndex = this.engine.getInstanceRowIndex(control);
|
|
356
|
+
}
|
|
353
357
|
// @ts-ignore
|
|
354
358
|
var scriptText = scriptEcho.reduce(function(result, current) {
|
|
355
359
|
if (current.type === CALC_TOKEN_TYPE.Operator || current.type === CALC_TOKEN_TYPE.Number) {
|
|
@@ -367,7 +371,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
367
371
|
}
|
|
368
372
|
case CALC_TOKEN_TYPE.VariableInCurrentSubTable:
|
|
369
373
|
{
|
|
370
|
-
|
|
374
|
+
//const rowIndex = this.engine.getInstanceRowIndex(control)
|
|
371
375
|
instance = _this.engine.getInstance(current.id, rowIndex);
|
|
372
376
|
var state = _this.engine.getState(current.id, rowIndex);
|
|
373
377
|
var value1 = _this.getNumberValue(state);
|
|
@@ -406,15 +410,15 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
406
410
|
}));
|
|
407
411
|
this.cacheComputedResult[scriptText] = value3;
|
|
408
412
|
}
|
|
409
|
-
|
|
413
|
+
// let rowIndex = undefined
|
|
410
414
|
if (this.controlInSubtable(control)) {
|
|
411
|
-
|
|
415
|
+
// rowIndex = this.engine.getInstanceRowIndex(control)
|
|
412
416
|
// 控件在明细表内,但是没有行下标,说明控件被已经删除了,所以直接return
|
|
413
|
-
if (
|
|
417
|
+
if (rowIndex === undefined) {
|
|
414
418
|
return;
|
|
415
419
|
}
|
|
416
420
|
}
|
|
417
|
-
var oldValue = this.engine.getState(control.id,
|
|
421
|
+
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
418
422
|
var result1 = !value3 || value3 === Infinity || value3 === -Infinity ? 0 : control.props.precision === '' ? value3 : Number(value3.toFixed(control.props.precision));
|
|
419
423
|
// 如果值没变的话,不触发修改
|
|
420
424
|
if (result1 === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
@@ -424,7 +428,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
424
428
|
this.engine.setState(control.id, {
|
|
425
429
|
result: result1,
|
|
426
430
|
unit: (ref = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && ref !== void 0 ? ref : ''
|
|
427
|
-
},
|
|
431
|
+
}, rowIndex);
|
|
428
432
|
}
|
|
429
433
|
},
|
|
430
434
|
{
|