@byteluck-fe/model-driven-engine 7.0.0-props.2 → 7.0.0-props.32
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/ActionManager.js +11 -3
- package/dist/esm/common/DataManager.js +11 -3
- package/dist/esm/common/Engine.js +139 -72
- package/dist/esm/common/Store.js +5 -5
- package/dist/esm/common/checkerValue.js +6 -6
- package/dist/esm/common/proxyState.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +5 -6
- package/dist/esm/plugins/ControlsEventPlugin.js +11 -3
- package/dist/esm/plugins/LifecycleEventPlugin.js +11 -3
- package/dist/esm/plugins/StylePlugin.js +2 -2
- package/dist/index.umd.js +25 -24
- package/dist/types/common/Engine.d.ts +9 -2
- package/package.json +4 -4
|
@@ -93,9 +93,17 @@ function _ts_generator(thisArg, body) {
|
|
|
93
93
|
},
|
|
94
94
|
trys: [],
|
|
95
95
|
ops: []
|
|
96
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
97
|
-
return
|
|
98
|
-
|
|
96
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
97
|
+
return d(g, "next", {
|
|
98
|
+
value: verb(0)
|
|
99
|
+
}), d(g, "throw", {
|
|
100
|
+
value: verb(1)
|
|
101
|
+
}), d(g, "return", {
|
|
102
|
+
value: verb(2)
|
|
103
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
104
|
+
value: function() {
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
99
107
|
}), g;
|
|
100
108
|
function verb(n) {
|
|
101
109
|
return function(v) {
|
|
@@ -68,9 +68,17 @@ function _ts_generator(thisArg, body) {
|
|
|
68
68
|
},
|
|
69
69
|
trys: [],
|
|
70
70
|
ops: []
|
|
71
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
-
return
|
|
73
|
-
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
74
82
|
}), g;
|
|
75
83
|
function verb(n) {
|
|
76
84
|
return function(v) {
|
|
@@ -242,9 +242,17 @@ function _ts_generator(thisArg, body) {
|
|
|
242
242
|
},
|
|
243
243
|
trys: [],
|
|
244
244
|
ops: []
|
|
245
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
246
|
-
return
|
|
247
|
-
|
|
245
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
246
|
+
return d(g, "next", {
|
|
247
|
+
value: verb(0)
|
|
248
|
+
}), d(g, "throw", {
|
|
249
|
+
value: verb(1)
|
|
250
|
+
}), d(g, "return", {
|
|
251
|
+
value: verb(2)
|
|
252
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
253
|
+
value: function() {
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
248
256
|
}), g;
|
|
249
257
|
function verb(n) {
|
|
250
258
|
return function(v) {
|
|
@@ -324,7 +332,6 @@ function _ts_generator(thisArg, body) {
|
|
|
324
332
|
};
|
|
325
333
|
}
|
|
326
334
|
}
|
|
327
|
-
import { getLocaleText } from '@byteluck-fe/locale-message';
|
|
328
335
|
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
329
336
|
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
330
337
|
import { Runtime } from './Runtime';
|
|
@@ -407,7 +414,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
407
414
|
key: "mount",
|
|
408
415
|
value: function mount() {
|
|
409
416
|
// @i18n-translate-ignore
|
|
410
|
-
this.debugLog("engine的mount
|
|
417
|
+
this.debugLog("~engine的mount方法开始调用~");
|
|
411
418
|
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
412
419
|
this._handlerProxyState();
|
|
413
420
|
this.__plugins = plugins;
|
|
@@ -494,7 +501,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
501
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
495
502
|
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
496
503
|
// 新增多行方法
|
|
497
|
-
var createRows = function(len) {
|
|
504
|
+
var createRows = function createRows(len) {
|
|
498
505
|
// @ts-ignore
|
|
499
506
|
var newRows = [];
|
|
500
507
|
for(var i = 0; i < len; i++){
|
|
@@ -777,7 +784,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
777
784
|
value: // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
|
|
778
785
|
function emit(eventKey, payload) {
|
|
779
786
|
var _this = this;
|
|
780
|
-
var _this1 = this, _superprop_get_emit = function() {
|
|
787
|
+
var _this1 = this, _superprop_get_emit = function _superprop_get_emit() {
|
|
781
788
|
return _get(_get_prototype_of(Engine.prototype), "emit", _this);
|
|
782
789
|
};
|
|
783
790
|
return _async_to_generator(function() {
|
|
@@ -1260,124 +1267,146 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1260
1267
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1261
1268
|
*/ key: "setData",
|
|
1262
1269
|
value: function setData(dataSet, options) {
|
|
1263
|
-
var _this =
|
|
1264
|
-
|
|
1265
|
-
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1266
|
-
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1267
|
-
var newState = this.store.defaultState;
|
|
1268
|
-
if (onlySetData === true) {
|
|
1269
|
-
newState = {};
|
|
1270
|
-
}
|
|
1271
|
-
Object.keys(dataSet).map(function(dataCode) {
|
|
1270
|
+
var _this, _loop = function(i) {
|
|
1271
|
+
var dataCode = dataCodes[i];
|
|
1272
1272
|
var entity = dataSet[dataCode];
|
|
1273
1273
|
if (Array.isArray(entity)) {
|
|
1274
|
-
var
|
|
1274
|
+
var _storeEmptyState_dataViewId;
|
|
1275
|
+
var mapping = dataBindMapping[dataCode];
|
|
1275
1276
|
if (!mapping) {
|
|
1276
|
-
return;
|
|
1277
|
+
return "continue";
|
|
1277
1278
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1279
|
+
var dataViewId = mapping.dataViewId, controlId = mapping.controlId, fields = mapping.fields;
|
|
1280
|
+
if (!newState[dataViewId]) {
|
|
1281
|
+
newState[dataViewId] = {};
|
|
1280
1282
|
}
|
|
1281
1283
|
if (!entity.length) {
|
|
1282
|
-
var
|
|
1283
|
-
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 : [];
|
|
1284
1286
|
} else {
|
|
1285
|
-
newState[
|
|
1287
|
+
newState[dataViewId][controlId] = [];
|
|
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
|
+
}
|
|
1286
1300
|
}
|
|
1301
|
+
var emptyRowTemplate = (_storeEmptyState_dataViewId = storeEmptyState[dataViewId]) === null || _storeEmptyState_dataViewId === void 0 ? void 0 : _storeEmptyState_dataViewId[controlId];
|
|
1287
1302
|
var cacheEmptyState = {};
|
|
1288
1303
|
var cacheFieldMapping = {};
|
|
1289
|
-
entity.
|
|
1290
|
-
var
|
|
1291
|
-
var
|
|
1292
|
-
;
|
|
1293
|
-
Object.keys(row)
|
|
1294
|
-
|
|
1295
|
-
|
|
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;
|
|
1296
1314
|
}
|
|
1297
|
-
if (
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
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
|
+
}
|
|
1302
1323
|
}
|
|
1303
1324
|
var fieldMapping = cacheFieldMapping[fieldCode];
|
|
1304
1325
|
if (fieldMapping) {
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1308
|
-
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1326
|
+
if (isDataBind(fieldMapping.dataBind) && rowValue !== undefined) {
|
|
1327
|
+
newRow[fieldMapping.controlId] = rowValue;
|
|
1309
1328
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
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 : {});
|
|
1313
1333
|
}
|
|
1314
|
-
var objValue = JSONCopy(cacheEmptyState[
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
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;
|
|
1319
1343
|
}
|
|
1320
|
-
skipKey.
|
|
1321
|
-
}
|
|
1322
|
-
newRow[
|
|
1344
|
+
skipKey.add(bindInfo.fieldCode);
|
|
1345
|
+
}
|
|
1346
|
+
newRow[fieldControlId] = objValue;
|
|
1323
1347
|
}
|
|
1324
|
-
} else if (fieldCode === 'uid' &&
|
|
1325
|
-
newRow.uid =
|
|
1326
|
-
} else if (fieldCode === 'virtualStore' &&
|
|
1327
|
-
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);
|
|
1328
1352
|
}
|
|
1329
|
-
}
|
|
1330
|
-
newState[
|
|
1331
|
-
}
|
|
1353
|
+
}
|
|
1354
|
+
newState[dataViewId][controlId].push(newRow);
|
|
1355
|
+
}
|
|
1332
1356
|
} else if (entity) {
|
|
1333
1357
|
var _Object_keys;
|
|
1334
|
-
var
|
|
1335
|
-
;
|
|
1358
|
+
var skipKey1 = [];
|
|
1336
1359
|
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1337
1360
|
if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
|
|
1338
|
-
//
|
|
1361
|
+
// 空对象,不做处理
|
|
1339
1362
|
} else {
|
|
1340
1363
|
Object.keys(entity).map(function(fieldCode) {
|
|
1341
|
-
if (
|
|
1364
|
+
if (skipKey1.includes(fieldCode)) {
|
|
1342
1365
|
return;
|
|
1343
1366
|
}
|
|
1344
|
-
var mapping =
|
|
1367
|
+
var mapping = _this1.getDataBindMapping(dataCode, fieldCode);
|
|
1345
1368
|
if (mapping) {
|
|
1346
1369
|
if (!newState[mapping.dataViewId[0]]) {
|
|
1347
1370
|
newState[mapping.dataViewId[0]] = {};
|
|
1348
1371
|
}
|
|
1349
|
-
if (
|
|
1350
|
-
isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1372
|
+
if (isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1351
1373
|
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1352
|
-
// } else if (mapping.dataBind instanceof ObjectDataBind) {
|
|
1353
1374
|
} else if (!isDataBind(mapping.dataBind)) {
|
|
1354
1375
|
var _this_getEmptyState;
|
|
1355
|
-
var objValue = (_this_getEmptyState =
|
|
1376
|
+
var objValue = (_this_getEmptyState = _this1.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
|
|
1356
1377
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1357
1378
|
var dataBind = mapping.dataBind[key];
|
|
1358
|
-
//金额及计算公式控件在赋值时会经过两次 且当控件值不为同一个模型时,会赋值两次 会导致前后覆盖行为。
|
|
1359
1379
|
if (dataSet[dataBind.dataCode]) {
|
|
1360
1380
|
var extendEntity = dataSet[dataBind.dataCode];
|
|
1361
1381
|
if (extendEntity[dataBind.fieldCode] !== undefined) {
|
|
1362
1382
|
objValue[key] = extendEntity[dataBind.fieldCode];
|
|
1363
1383
|
}
|
|
1364
1384
|
}
|
|
1365
|
-
|
|
1385
|
+
skipKey1.push(dataBind.fieldCode);
|
|
1366
1386
|
});
|
|
1367
1387
|
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1368
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
|
+
}
|
|
1369
1398
|
}
|
|
1370
1399
|
});
|
|
1371
1400
|
}
|
|
1372
1401
|
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1373
1402
|
if (newMapping) {
|
|
1403
|
+
var _ref;
|
|
1374
1404
|
var _newMapping_fields;
|
|
1375
1405
|
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
|
|
1376
1406
|
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1377
1407
|
});
|
|
1378
1408
|
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1379
|
-
var
|
|
1380
|
-
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1409
|
+
var mainStateKeys = Object.keys((_ref = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _ref !== void 0 ? _ref : {});
|
|
1381
1410
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1382
1411
|
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1383
1412
|
if (Object.keys(newState).length) {
|
|
@@ -1391,7 +1420,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1391
1420
|
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1392
1421
|
}
|
|
1393
1422
|
}
|
|
1394
|
-
}
|
|
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);
|
|
1395
1436
|
// @i18n-translate-ignore
|
|
1396
1437
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1397
1438
|
this.setStates(newState, undefined, _object_spread({
|
|
@@ -1399,7 +1440,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1399
1440
|
}, options));
|
|
1400
1441
|
this.runtime.getFlatInstances();
|
|
1401
1442
|
// @i18n-translate-ignore
|
|
1402
|
-
this.debugLog(
|
|
1443
|
+
this.debugLog("engine setData方法执行完成。");
|
|
1403
1444
|
}
|
|
1404
1445
|
},
|
|
1405
1446
|
{
|
|
@@ -1571,6 +1612,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1571
1612
|
return this.store.controlIdMapping;
|
|
1572
1613
|
}
|
|
1573
1614
|
},
|
|
1615
|
+
{
|
|
1616
|
+
/**
|
|
1617
|
+
* 根据字段获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1618
|
+
* @param dataCode 模型code
|
|
1619
|
+
* @param fieldCode 字段code
|
|
1620
|
+
*/ key: "getFieldInstance",
|
|
1621
|
+
value: function getFieldInstance(dataCode, fieldCode, rowIndex) {
|
|
1622
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
1623
|
+
if (dataBindMapping) {
|
|
1624
|
+
var _instance = this.getInstance(dataBindMapping.controlId, rowIndex);
|
|
1625
|
+
return _instance;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
key: "setFieldInstance",
|
|
1631
|
+
value: function setFieldInstance(dataCode, fieldCode, props, value, rowIndex) {
|
|
1632
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
1633
|
+
if (dataBindMapping) {
|
|
1634
|
+
var _instance = this.getInstance(dataBindMapping.controlId, rowIndex);
|
|
1635
|
+
this.debugLog("调用了setFieldInstance[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1636
|
+
this.setInstance(_instance.id, props, value, rowIndex);
|
|
1637
|
+
return _instance;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1574
1641
|
{
|
|
1575
1642
|
key: "getDataBindMapping",
|
|
1576
1643
|
value: function getDataBindMapping(dataCode, fieldCode) {
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -135,10 +135,10 @@ var Store = /*#__PURE__*/ function() {
|
|
|
135
135
|
} else {
|
|
136
136
|
var controlInfo = this.controlIdMapping[controlId];
|
|
137
137
|
if (controlInfo !== undefined) {
|
|
138
|
+
var _ref;
|
|
138
139
|
var data = this.state[controlInfo.dataView][controlId];
|
|
139
|
-
var _controlInfo_children;
|
|
140
140
|
// 只有明细表key,再通过rowIndex获取行数据
|
|
141
|
-
if (rowIndex !== undefined && Object.keys((
|
|
141
|
+
if (rowIndex !== undefined && Object.keys((_ref = controlInfo === null || controlInfo === void 0 ? void 0 : controlInfo.children) !== null && _ref !== void 0 ? _ref : {}).length > 0) {
|
|
142
142
|
return data[rowIndex];
|
|
143
143
|
} else {
|
|
144
144
|
return data;
|
|
@@ -287,11 +287,11 @@ item) {
|
|
|
287
287
|
dataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
288
288
|
emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
289
289
|
} else {
|
|
290
|
+
var _fill_map, _item_props_defaultRows;
|
|
290
291
|
var emptyTemplate = {};
|
|
291
292
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
292
293
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
293
294
|
});
|
|
294
|
-
var _item_props_defaultRows, _fill_map;
|
|
295
295
|
dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
296
296
|
return _object_spread({
|
|
297
297
|
uid: 'new:' + buildUUID('uid')
|
|
@@ -419,9 +419,9 @@ item) {
|
|
|
419
419
|
options: []
|
|
420
420
|
};
|
|
421
421
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
422
|
+
var _ref;
|
|
422
423
|
var _data_item_id;
|
|
423
|
-
|
|
424
|
-
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {}, _define_property({}, formControl.id, {
|
|
424
|
+
Object.assign((_ref = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _ref !== void 0 ? _ref : {}, _define_property({}, formControl.id, {
|
|
425
425
|
dataBind: formControl.props.dataBind
|
|
426
426
|
}));
|
|
427
427
|
});
|
|
@@ -249,7 +249,7 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
249
249
|
if (Array.isArray(newValue)) {
|
|
250
250
|
return getStringValueArray(newValue);
|
|
251
251
|
}
|
|
252
|
-
} catch (
|
|
252
|
+
} catch (unused) {}
|
|
253
253
|
}
|
|
254
254
|
return [
|
|
255
255
|
String(value)
|
|
@@ -295,7 +295,7 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
295
295
|
if (isArray(newValue)) {
|
|
296
296
|
return getNumberValueArray(newValue);
|
|
297
297
|
}
|
|
298
|
-
} catch (
|
|
298
|
+
} catch (unused) {}
|
|
299
299
|
}
|
|
300
300
|
var newValue1 = Number(value);
|
|
301
301
|
if (Number.isNaN(newValue1)) {
|
|
@@ -340,7 +340,7 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
340
340
|
try {
|
|
341
341
|
var newValue = JSON.parse(value);
|
|
342
342
|
result = new AmountValue(_object_spread({}, oldValue, newValue));
|
|
343
|
-
} catch (
|
|
343
|
+
} catch (unused) {}
|
|
344
344
|
}
|
|
345
345
|
if (result) {
|
|
346
346
|
var numberChecker = new NumberValueChecker();
|
|
@@ -388,7 +388,7 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
388
388
|
try {
|
|
389
389
|
var newValue = JSON.parse(value);
|
|
390
390
|
result = new RangeDateValue(_object_spread({}, oldValue, newValue));
|
|
391
|
-
} catch (
|
|
391
|
+
} catch (unused) {}
|
|
392
392
|
}
|
|
393
393
|
if (result) {
|
|
394
394
|
var stringChecker = new StringValueChecker();
|
|
@@ -437,7 +437,7 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
437
437
|
try {
|
|
438
438
|
var newValue = JSON.parse(value);
|
|
439
439
|
result = new CalcValue(_object_spread({}, oldValue, newValue));
|
|
440
|
-
} catch (
|
|
440
|
+
} catch (unused) {}
|
|
441
441
|
}
|
|
442
442
|
if (result) {
|
|
443
443
|
var numberChecker = new NumberValueChecker();
|
|
@@ -495,7 +495,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
495
495
|
try {
|
|
496
496
|
var newValue = JSON.parse(value);
|
|
497
497
|
result = new AddressValue(_object_spread({}, oldValue, camelizeKeys(newValue)));
|
|
498
|
-
} catch (
|
|
498
|
+
} catch (unused) {}
|
|
499
499
|
}
|
|
500
500
|
if (result) {
|
|
501
501
|
var stringChecker = new StringValueChecker();
|
|
@@ -129,6 +129,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
129
129
|
return Reflect.get(target, propertyKey, receiver);
|
|
130
130
|
},
|
|
131
131
|
set: function set(target, propertyKey, value, receiver) {
|
|
132
|
+
var _reProxyState;
|
|
132
133
|
var newValue = JSONCopy(value);
|
|
133
134
|
// @ts-ignore
|
|
134
135
|
var oldValue = target[propertyKey];
|
|
@@ -145,7 +146,6 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
var _reProxyState;
|
|
149
149
|
newValue = (_reProxyState = reProxyState(newValue)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
|
|
150
150
|
// 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
|
|
151
151
|
var setResult;
|
|
@@ -248,10 +248,10 @@ function flatInstanceForChildren(controls) {
|
|
|
248
248
|
// 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
|
|
249
249
|
return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
|
|
250
250
|
} else {
|
|
251
|
+
var _ref;
|
|
251
252
|
var _prevItem_children;
|
|
252
|
-
var _prevItem_children_index;
|
|
253
253
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
254
|
-
return (
|
|
254
|
+
return (_ref = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _ref !== void 0 ? _ref : prevItem;
|
|
255
255
|
}
|
|
256
256
|
}, initInstance);
|
|
257
257
|
}
|
|
@@ -296,19 +296,18 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
296
296
|
* */ function watchSubtableChange() {
|
|
297
297
|
var _this = this;
|
|
298
298
|
this.engine.on('list-change', function(payload) {
|
|
299
|
+
var _ref, _this_dependenciesTriggerMap_get;
|
|
299
300
|
var _payload_options;
|
|
300
301
|
// 初始化前是批量操作。不做处理
|
|
301
302
|
if (_this.engine.isMounted === false) return;
|
|
302
303
|
_this.resetDependencies();
|
|
303
|
-
var
|
|
304
|
-
var changedRows = (_payload_options_changed = (_payload_options = payload.options) === null || _payload_options === void 0 ? void 0 : _payload_options.changed) !== null && _payload_options_changed !== void 0 ? _payload_options_changed : [];
|
|
304
|
+
var changedRows = (_ref = (_payload_options = payload.options) === null || _payload_options === void 0 ? void 0 : _payload_options.changed) !== null && _ref !== void 0 ? _ref : [];
|
|
305
305
|
// 对发生改变的行进行重新计算
|
|
306
306
|
var changedCalc = _this.getCalcControlsFromSubtableRows(changedRows);
|
|
307
307
|
// @ts-ignore
|
|
308
308
|
changedCalc.forEach(function(calcControl) {
|
|
309
309
|
_this.computedCalcValue(calcControl);
|
|
310
310
|
});
|
|
311
|
-
var _this_dependenciesTriggerMap_get;
|
|
312
311
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
313
312
|
// @ts-ignore
|
|
314
313
|
calcControls.forEach(function(calcControl) {
|
|
@@ -324,13 +323,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
324
323
|
* */ function watchControlChange() {
|
|
325
324
|
var _this = this;
|
|
326
325
|
this.engine.on('change', function(payload) {
|
|
326
|
+
var _this_dependenciesTriggerMap_get;
|
|
327
327
|
// 初始化前是批量操作。不做处理
|
|
328
328
|
if (_this.engine.isMounted === false) return;
|
|
329
329
|
var instance = payload.instance;
|
|
330
330
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
|
-
var _this_dependenciesTriggerMap_get;
|
|
334
333
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
335
334
|
// 在明细子表中的控件,如果计算公式也在明细子表,那只触发同一行的计算公式的计算
|
|
336
335
|
if (payload.rowIndex !== undefined && payload.rowIndex > -1) {
|
|
@@ -369,6 +368,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
369
368
|
* */ // @ts-ignore
|
|
370
369
|
function computedCalcValue(control) {
|
|
371
370
|
var _this = this;
|
|
371
|
+
var _ref;
|
|
372
372
|
var scriptEcho = control.props.scriptEcho;
|
|
373
373
|
if (!scriptEcho || scriptEcho.length === 0) {
|
|
374
374
|
return;
|
|
@@ -446,10 +446,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
446
446
|
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
|
-
var _oldValue_unit;
|
|
450
449
|
this.engine.setState(control.id, {
|
|
451
450
|
result: result,
|
|
452
|
-
unit: (
|
|
451
|
+
unit: (_ref = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _ref !== void 0 ? _ref : ''
|
|
453
452
|
}, rowIndex);
|
|
454
453
|
}
|
|
455
454
|
},
|
|
@@ -68,9 +68,17 @@ function _ts_generator(thisArg, body) {
|
|
|
68
68
|
},
|
|
69
69
|
trys: [],
|
|
70
70
|
ops: []
|
|
71
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
-
return
|
|
73
|
-
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
74
82
|
}), g;
|
|
75
83
|
function verb(n) {
|
|
76
84
|
return function(v) {
|
|
@@ -114,9 +114,17 @@ function _ts_generator(thisArg, body) {
|
|
|
114
114
|
},
|
|
115
115
|
trys: [],
|
|
116
116
|
ops: []
|
|
117
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
118
|
-
return
|
|
119
|
-
|
|
117
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
118
|
+
return d(g, "next", {
|
|
119
|
+
value: verb(0)
|
|
120
|
+
}), d(g, "throw", {
|
|
121
|
+
value: verb(1)
|
|
122
|
+
}), d(g, "return", {
|
|
123
|
+
value: verb(2)
|
|
124
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
125
|
+
value: function() {
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
120
128
|
}), g;
|
|
121
129
|
function verb(n) {
|
|
122
130
|
return function(v) {
|
|
@@ -54,10 +54,10 @@ export var StylePlugin = /*#__PURE__*/ function() {
|
|
|
54
54
|
{
|
|
55
55
|
key: "apply",
|
|
56
56
|
value: function apply(engine) {
|
|
57
|
+
var _ref;
|
|
57
58
|
var _this_config;
|
|
58
59
|
this.engine = engine;
|
|
59
|
-
var
|
|
60
|
-
var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
|
|
60
|
+
var compiledStyle = (_ref = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _ref !== void 0 ? _ref : '';
|
|
61
61
|
var style = document.createElement('style');
|
|
62
62
|
style.className = 'edit-css-' + engine.id;
|
|
63
63
|
var dom = document.querySelector('head');
|