@byteluck-fe/model-driven-engine 2.2.7 → 2.3.1-beta.11
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 +19 -1
- package/dist/esm/common/Runtime.js +25 -0
- package/dist/esm/common/Store.js +2 -1
- package/dist/esm/utils/runtimeUtils.js +1 -0
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +5 -1
- package/dist/types/common/Runtime.d.ts +4 -0
- package/package.json +6 -5
|
@@ -738,6 +738,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
738
738
|
_proto.updateInstanceProps = function updateInstanceProps(instance, props, value, rowIndex) {
|
|
739
739
|
return this.setInstance(instance, props, value, rowIndex);
|
|
740
740
|
};
|
|
741
|
+
_proto.getAllRules = function getAllRules(controlId) {
|
|
742
|
+
var rules = this.runtime.allRules;
|
|
743
|
+
if (controlId === undefined) {
|
|
744
|
+
return rules;
|
|
745
|
+
} else {
|
|
746
|
+
var _rules_rules_controlId, _rules_antdRules_controlId;
|
|
747
|
+
return {
|
|
748
|
+
rules: (_rules_rules_controlId = rules.rules[controlId]) === null || _rules_rules_controlId === void 0 ? void 0 : _rules_rules_controlId.fields,
|
|
749
|
+
antdRules: (_rules_antdRules_controlId = rules.antdRules[controlId]) === null || _rules_antdRules_controlId === void 0 ? void 0 : _rules_antdRules_controlId.fields
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
};
|
|
741
753
|
_proto.getRules = function getRules(controlId) {
|
|
742
754
|
if (controlId === undefined) {
|
|
743
755
|
return this.runtime.rules;
|
|
@@ -1076,6 +1088,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1076
1088
|
} else if (entity) {
|
|
1077
1089
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1078
1090
|
;
|
|
1091
|
+
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1079
1092
|
Object.keys(entity).map(function(fieldCode) {
|
|
1080
1093
|
if (skipKey.includes(fieldCode)) {
|
|
1081
1094
|
return;
|
|
@@ -1086,7 +1099,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1086
1099
|
newState[mapping.dataViewId[0]] = {};
|
|
1087
1100
|
}
|
|
1088
1101
|
if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
|
|
1089
|
-
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode];
|
|
1102
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1090
1103
|
} else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
|
|
1091
1104
|
var _this_getEmptyState;
|
|
1092
1105
|
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
@@ -1138,7 +1151,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1138
1151
|
* @param header 明细表内是否获取表头的控件
|
|
1139
1152
|
*/ _proto.getInstances = function getInstances(controlId) {
|
|
1140
1153
|
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1154
|
+
// const cc = console
|
|
1155
|
+
// const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1156
|
+
// cc.time(label)
|
|
1141
1157
|
if (controlId === undefined) {
|
|
1158
|
+
// cc.timeEnd(label)
|
|
1142
1159
|
return this.runtime.flatInstances;
|
|
1143
1160
|
}
|
|
1144
1161
|
var instances = this.runtime.instanceMap[controlId] || [];
|
|
@@ -1360,3 +1377,4 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1360
1377
|
return Engine;
|
|
1361
1378
|
}(Watcher);
|
|
1362
1379
|
export { Engine };
|
|
1380
|
+
console.log("a");
|
|
@@ -146,6 +146,31 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
146
146
|
return this._instanceMap;
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
|
+
{
|
|
150
|
+
key: "allRules",
|
|
151
|
+
get: function get() {
|
|
152
|
+
var antdRules = {};
|
|
153
|
+
var ruleItems = {};
|
|
154
|
+
loopDataViewControl(this._instance, function(dataView) {
|
|
155
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
156
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
157
|
+
loopFormControl(dataView.children, function(item) {
|
|
158
|
+
// if (
|
|
159
|
+
// item instanceof RuntimeFormControl ||
|
|
160
|
+
// item instanceof RuntimeListControl
|
|
161
|
+
// ) {
|
|
162
|
+
if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
163
|
+
buildControlRules(ruleItems[dataView.id].fields, item);
|
|
164
|
+
buildControlAntdRules(antdRules[dataView.id].fields, item);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
rules: ruleItems,
|
|
170
|
+
antdRules: antdRules
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
},
|
|
149
174
|
{
|
|
150
175
|
key: "rules",
|
|
151
176
|
get: function get() {
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -204,7 +204,8 @@ function buildState(dataViewState, emptyDataViewState, // @ts-ignore
|
|
|
204
204
|
item) {
|
|
205
205
|
//if (item instanceof RuntimeFormControl) {
|
|
206
206
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
207
|
-
|
|
207
|
+
// 2023-3-23 jiaqi 首次进入页面去除填充默认值
|
|
208
|
+
// dataViewState[item.id] = JSONCopy(item.props.defaultValue)
|
|
208
209
|
emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
209
210
|
} else {
|
|
210
211
|
var emptyTemplate = {};
|
|
@@ -12,6 +12,7 @@ export function loopFormControl(control, callback) {
|
|
|
12
12
|
callback(item, children);
|
|
13
13
|
} else if (hasChildrenControl(item)) {
|
|
14
14
|
loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
15
|
+
// @ts-ignore
|
|
15
16
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
16
17
|
callback(item);
|
|
17
18
|
}
|