@byteluck-fe/model-driven-engine 7.0.0-props.27 → 7.0.0-props.35
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 +100 -67
- package/dist/index.umd.js +25 -25
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
|
@@ -332,9 +332,8 @@ function _ts_generator(thisArg, body) {
|
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
import { getLocaleText } from '@byteluck-fe/locale-message';
|
|
336
335
|
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
337
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher,
|
|
336
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
338
337
|
import { Runtime } from './Runtime';
|
|
339
338
|
import { Store } from './Store';
|
|
340
339
|
import { findItem, proxyState } from './proxyState';
|
|
@@ -415,7 +414,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
415
414
|
key: "mount",
|
|
416
415
|
value: function mount() {
|
|
417
416
|
// @i18n-translate-ignore
|
|
418
|
-
this.debugLog("engine的mount
|
|
417
|
+
this.debugLog("~engine的mount方法开始调用~");
|
|
419
418
|
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
420
419
|
this._handlerProxyState();
|
|
421
420
|
this.__plugins = plugins;
|
|
@@ -1268,112 +1267,134 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1268
1267
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1269
1268
|
*/ key: "setData",
|
|
1270
1269
|
value: function setData(dataSet, options) {
|
|
1271
|
-
var _this =
|
|
1272
|
-
|
|
1273
|
-
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1274
|
-
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1275
|
-
var newState = this.store.defaultState;
|
|
1276
|
-
if (onlySetData === true) {
|
|
1277
|
-
newState = {};
|
|
1278
|
-
}
|
|
1279
|
-
Object.keys(dataSet).map(function(dataCode) {
|
|
1270
|
+
var _this, _loop = function(i) {
|
|
1271
|
+
var dataCode = dataCodes[i];
|
|
1280
1272
|
var entity = dataSet[dataCode];
|
|
1281
1273
|
if (Array.isArray(entity)) {
|
|
1282
|
-
var
|
|
1274
|
+
var _storeEmptyState_dataViewId;
|
|
1275
|
+
var mapping = dataBindMapping[dataCode];
|
|
1283
1276
|
if (!mapping) {
|
|
1284
|
-
return;
|
|
1277
|
+
return "continue";
|
|
1285
1278
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1279
|
+
var dataViewId = mapping.dataViewId, controlId = mapping.controlId, fields = mapping.fields;
|
|
1280
|
+
if (!newState[dataViewId]) {
|
|
1281
|
+
newState[dataViewId] = {};
|
|
1288
1282
|
}
|
|
1289
1283
|
if (!entity.length) {
|
|
1290
|
-
var
|
|
1291
|
-
newState[
|
|
1284
|
+
var _newState_dataViewId_controlId;
|
|
1285
|
+
newState[dataViewId][controlId] = (_newState_dataViewId_controlId = newState[dataViewId][controlId]) !== null && _newState_dataViewId_controlId !== void 0 ? _newState_dataViewId_controlId : [];
|
|
1292
1286
|
} else {
|
|
1293
|
-
newState[
|
|
1287
|
+
newState[dataViewId][controlId] = [];
|
|
1294
1288
|
}
|
|
1289
|
+
var fieldMap = new Map();
|
|
1290
|
+
for(var j = 0; j < fields.length; j++){
|
|
1291
|
+
var field = fields[j];
|
|
1292
|
+
fieldMap.set(field.fieldCode, field);
|
|
1293
|
+
}
|
|
1294
|
+
var unboundFields = new Set();
|
|
1295
|
+
for(var j1 = 0; j1 < fields.length; j1++){
|
|
1296
|
+
var field1 = fields[j1];
|
|
1297
|
+
if (field1.fieldCode) {
|
|
1298
|
+
unboundFields.add(field1.fieldCode);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
var emptyRowTemplate = (_storeEmptyState_dataViewId = storeEmptyState[dataViewId]) === null || _storeEmptyState_dataViewId === void 0 ? void 0 : _storeEmptyState_dataViewId[controlId];
|
|
1295
1302
|
var cacheEmptyState = {};
|
|
1296
1303
|
var cacheFieldMapping = {};
|
|
1297
|
-
entity.
|
|
1298
|
-
var
|
|
1299
|
-
var
|
|
1300
|
-
;
|
|
1301
|
-
Object.keys(row)
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
+
for(var j2 = 0; j2 < entity.length; j2++){
|
|
1305
|
+
var row = entity[j2];
|
|
1306
|
+
var newRow = JSONCopy(emptyRowTemplate);
|
|
1307
|
+
var skipKey = new Set();
|
|
1308
|
+
var rowKeys = Object.keys(row);
|
|
1309
|
+
for(var k = 0; k < rowKeys.length; k++){
|
|
1310
|
+
var fieldCode = rowKeys[k];
|
|
1311
|
+
var rowValue = row[fieldCode];
|
|
1312
|
+
if (!unboundFields.has(fieldCode) && fieldCode in newRow && rowValue !== undefined) {
|
|
1313
|
+
newRow[fieldCode] = rowValue;
|
|
1304
1314
|
}
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1315
|
+
if (skipKey.has(fieldCode)) {
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
if (!cacheFieldMapping[fieldCode]) {
|
|
1319
|
+
var mappedField = fieldMap.get(fieldCode);
|
|
1320
|
+
if (mappedField) {
|
|
1321
|
+
cacheFieldMapping[fieldCode] = mappedField;
|
|
1322
|
+
}
|
|
1310
1323
|
}
|
|
1311
1324
|
var fieldMapping = cacheFieldMapping[fieldCode];
|
|
1312
1325
|
if (fieldMapping) {
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1315
|
-
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1316
|
-
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1326
|
+
if (isDataBind(fieldMapping.dataBind) && rowValue !== undefined) {
|
|
1327
|
+
newRow[fieldMapping.controlId] = rowValue;
|
|
1317
1328
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1329
|
+
var fieldControlId = fieldMapping.controlId;
|
|
1330
|
+
if (!cacheEmptyState[fieldControlId]) {
|
|
1331
|
+
var _this_store_getEmptyState;
|
|
1332
|
+
cacheEmptyState[fieldControlId] = JSONCopy((_this_store_getEmptyState = _this.store.getEmptyState(fieldControlId)) !== null && _this_store_getEmptyState !== void 0 ? _this_store_getEmptyState : {});
|
|
1321
1333
|
}
|
|
1322
|
-
var objValue = JSONCopy(cacheEmptyState[
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1334
|
+
var objValue = JSONCopy(cacheEmptyState[fieldControlId]);
|
|
1335
|
+
var dataBind = fieldMapping.dataBind;
|
|
1336
|
+
var bindKeys = Object.keys(dataBind);
|
|
1337
|
+
for(var m = 0; m < bindKeys.length; m++){
|
|
1338
|
+
var key = bindKeys[m];
|
|
1339
|
+
var bindInfo = dataBind[key];
|
|
1340
|
+
var fieldCodeValue = row[bindInfo.fieldCode];
|
|
1341
|
+
if (fieldCodeValue !== undefined) {
|
|
1342
|
+
objValue[key] = fieldCodeValue;
|
|
1327
1343
|
}
|
|
1328
|
-
skipKey.
|
|
1329
|
-
}
|
|
1330
|
-
newRow[
|
|
1344
|
+
skipKey.add(bindInfo.fieldCode);
|
|
1345
|
+
}
|
|
1346
|
+
newRow[fieldControlId] = objValue;
|
|
1331
1347
|
}
|
|
1332
|
-
} else if (fieldCode === 'uid' &&
|
|
1333
|
-
newRow.uid =
|
|
1334
|
-
} else if (fieldCode === 'virtualStore' &&
|
|
1335
|
-
newRow.virtualStore = Object.freeze(
|
|
1348
|
+
} else if (fieldCode === 'uid' && rowValue !== undefined) {
|
|
1349
|
+
newRow.uid = rowValue;
|
|
1350
|
+
} else if (fieldCode === 'virtualStore' && rowValue !== undefined) {
|
|
1351
|
+
newRow.virtualStore = Object.freeze(rowValue);
|
|
1336
1352
|
}
|
|
1337
|
-
}
|
|
1338
|
-
newState[
|
|
1339
|
-
}
|
|
1353
|
+
}
|
|
1354
|
+
newState[dataViewId][controlId].push(newRow);
|
|
1355
|
+
}
|
|
1340
1356
|
} else if (entity) {
|
|
1341
1357
|
var _Object_keys;
|
|
1342
|
-
var
|
|
1343
|
-
;
|
|
1358
|
+
var skipKey1 = [];
|
|
1344
1359
|
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1345
1360
|
if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
|
|
1346
|
-
//
|
|
1361
|
+
// 空对象,不做处理
|
|
1347
1362
|
} else {
|
|
1348
1363
|
Object.keys(entity).map(function(fieldCode) {
|
|
1349
|
-
if (
|
|
1364
|
+
if (skipKey1.includes(fieldCode)) {
|
|
1350
1365
|
return;
|
|
1351
1366
|
}
|
|
1352
|
-
var mapping =
|
|
1367
|
+
var mapping = _this1.getDataBindMapping(dataCode, fieldCode);
|
|
1353
1368
|
if (mapping) {
|
|
1354
1369
|
if (!newState[mapping.dataViewId[0]]) {
|
|
1355
1370
|
newState[mapping.dataViewId[0]] = {};
|
|
1356
1371
|
}
|
|
1357
|
-
if (
|
|
1358
|
-
isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1372
|
+
if (isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1359
1373
|
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1360
|
-
// } else if (mapping.dataBind instanceof ObjectDataBind) {
|
|
1361
1374
|
} else if (!isDataBind(mapping.dataBind)) {
|
|
1362
1375
|
var _this_getEmptyState;
|
|
1363
|
-
var objValue = (_this_getEmptyState =
|
|
1376
|
+
var objValue = (_this_getEmptyState = _this1.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
|
|
1364
1377
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1365
1378
|
var dataBind = mapping.dataBind[key];
|
|
1366
|
-
//金额及计算公式控件在赋值时会经过两次 且当控件值不为同一个模型时,会赋值两次 会导致前后覆盖行为。
|
|
1367
1379
|
if (dataSet[dataBind.dataCode]) {
|
|
1368
1380
|
var extendEntity = dataSet[dataBind.dataCode];
|
|
1369
1381
|
if (extendEntity[dataBind.fieldCode] !== undefined) {
|
|
1370
1382
|
objValue[key] = extendEntity[dataBind.fieldCode];
|
|
1371
1383
|
}
|
|
1372
1384
|
}
|
|
1373
|
-
|
|
1385
|
+
skipKey1.push(dataBind.fieldCode);
|
|
1374
1386
|
});
|
|
1375
1387
|
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1376
1388
|
}
|
|
1389
|
+
} else {
|
|
1390
|
+
var mapping1 = _this1.getDataBindMapping(dataCode);
|
|
1391
|
+
if ((mapping1 === null || mapping1 === void 0 ? void 0 : mapping1.dataViewId) && entity[fieldCode] !== undefined) {
|
|
1392
|
+
var dataViweId = mapping1 === null || mapping1 === void 0 ? void 0 : mapping1.dataViewId;
|
|
1393
|
+
var isInDataView = fieldCode in (emptyState[dataViweId] || {});
|
|
1394
|
+
if (isInDataView) {
|
|
1395
|
+
newState[dataViweId][fieldCode] = entity[fieldCode];
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1377
1398
|
}
|
|
1378
1399
|
});
|
|
1379
1400
|
}
|
|
@@ -1399,7 +1420,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1399
1420
|
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1400
1421
|
}
|
|
1401
1422
|
}
|
|
1402
|
-
}
|
|
1423
|
+
};
|
|
1424
|
+
var _this1 = this;
|
|
1425
|
+
// @i18n-translate-ignore
|
|
1426
|
+
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1427
|
+
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1428
|
+
var newState = this.store.defaultState;
|
|
1429
|
+
if (onlySetData === true) {
|
|
1430
|
+
newState = {};
|
|
1431
|
+
}
|
|
1432
|
+
var dataBindMapping = this.store.dataBindMapping;
|
|
1433
|
+
var storeEmptyState = this.store.emptyState;
|
|
1434
|
+
var dataCodes = Object.keys(dataSet);
|
|
1435
|
+
for(var i = 0; i < dataCodes.length; i++)_this = this, _loop(i);
|
|
1403
1436
|
// @i18n-translate-ignore
|
|
1404
1437
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1405
1438
|
this.setStates(newState, undefined, _object_spread({
|
|
@@ -1407,7 +1440,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1407
1440
|
}, options));
|
|
1408
1441
|
this.runtime.getFlatInstances();
|
|
1409
1442
|
// @i18n-translate-ignore
|
|
1410
|
-
this.debugLog(
|
|
1443
|
+
this.debugLog("engine setData方法执行完成。");
|
|
1411
1444
|
}
|
|
1412
1445
|
},
|
|
1413
1446
|
{
|
|
@@ -1601,7 +1634,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1601
1634
|
var _instance = this.getInstance(dataBindMapping.controlId, rowIndex);
|
|
1602
1635
|
this.debugLog("调用了setFieldInstance[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1603
1636
|
this.setInstance(_instance.id, props, value, rowIndex);
|
|
1604
|
-
return
|
|
1637
|
+
return _instance;
|
|
1605
1638
|
}
|
|
1606
1639
|
}
|
|
1607
1640
|
},
|