@byteluck-fe/model-driven-engine 7.0.0-1-beta9 → 7.0.0-beta.10
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 -71
- 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 +12 -3
- package/dist/esm/plugins/LifecycleEventPlugin.js +11 -3
- package/dist/esm/plugins/StylePlugin.js +2 -2
- package/dist/index.umd.js +24 -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) {
|
|
@@ -407,7 +415,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
407
415
|
key: "mount",
|
|
408
416
|
value: function mount() {
|
|
409
417
|
// @i18n-translate-ignore
|
|
410
|
-
this.debugLog("engine的mount
|
|
418
|
+
this.debugLog("~engine的mount方法开始调用~");
|
|
411
419
|
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
412
420
|
this._handlerProxyState();
|
|
413
421
|
this.__plugins = plugins;
|
|
@@ -494,7 +502,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
502
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
495
503
|
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
496
504
|
// 新增多行方法
|
|
497
|
-
var createRows = function(len) {
|
|
505
|
+
var createRows = function createRows(len) {
|
|
498
506
|
// @ts-ignore
|
|
499
507
|
var newRows = [];
|
|
500
508
|
for(var i = 0; i < len; i++){
|
|
@@ -777,7 +785,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
777
785
|
value: // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
|
|
778
786
|
function emit(eventKey, payload) {
|
|
779
787
|
var _this = this;
|
|
780
|
-
var _this1 = this, _superprop_get_emit = function() {
|
|
788
|
+
var _this1 = this, _superprop_get_emit = function _superprop_get_emit() {
|
|
781
789
|
return _get(_get_prototype_of(Engine.prototype), "emit", _this);
|
|
782
790
|
};
|
|
783
791
|
return _async_to_generator(function() {
|
|
@@ -1260,124 +1268,146 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1260
1268
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1261
1269
|
*/ key: "setData",
|
|
1262
1270
|
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) {
|
|
1271
|
+
var _this, _loop = function(i) {
|
|
1272
|
+
var dataCode = dataCodes[i];
|
|
1272
1273
|
var entity = dataSet[dataCode];
|
|
1273
1274
|
if (Array.isArray(entity)) {
|
|
1274
|
-
var
|
|
1275
|
+
var _storeEmptyState_dataViewId;
|
|
1276
|
+
var mapping = dataBindMapping[dataCode];
|
|
1275
1277
|
if (!mapping) {
|
|
1276
|
-
return;
|
|
1278
|
+
return "continue";
|
|
1277
1279
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
+
var dataViewId = mapping.dataViewId, controlId = mapping.controlId, fields = mapping.fields;
|
|
1281
|
+
if (!newState[dataViewId]) {
|
|
1282
|
+
newState[dataViewId] = {};
|
|
1280
1283
|
}
|
|
1281
1284
|
if (!entity.length) {
|
|
1282
|
-
var
|
|
1283
|
-
newState[
|
|
1285
|
+
var _newState_dataViewId_controlId;
|
|
1286
|
+
newState[dataViewId][controlId] = (_newState_dataViewId_controlId = newState[dataViewId][controlId]) !== null && _newState_dataViewId_controlId !== void 0 ? _newState_dataViewId_controlId : [];
|
|
1284
1287
|
} else {
|
|
1285
|
-
newState[
|
|
1288
|
+
newState[dataViewId][controlId] = [];
|
|
1289
|
+
}
|
|
1290
|
+
var fieldMap = new Map();
|
|
1291
|
+
for(var j = 0; j < fields.length; j++){
|
|
1292
|
+
var field = fields[j];
|
|
1293
|
+
fieldMap.set(field.fieldCode, field);
|
|
1294
|
+
}
|
|
1295
|
+
var unboundFields = new Set();
|
|
1296
|
+
for(var j1 = 0; j1 < fields.length; j1++){
|
|
1297
|
+
var field1 = fields[j1];
|
|
1298
|
+
if (field1.fieldCode) {
|
|
1299
|
+
unboundFields.add(field1.fieldCode);
|
|
1300
|
+
}
|
|
1286
1301
|
}
|
|
1302
|
+
var emptyRowTemplate = (_storeEmptyState_dataViewId = storeEmptyState[dataViewId]) === null || _storeEmptyState_dataViewId === void 0 ? void 0 : _storeEmptyState_dataViewId[controlId];
|
|
1287
1303
|
var cacheEmptyState = {};
|
|
1288
1304
|
var cacheFieldMapping = {};
|
|
1289
|
-
entity.
|
|
1290
|
-
var
|
|
1291
|
-
var
|
|
1292
|
-
;
|
|
1293
|
-
Object.keys(row)
|
|
1294
|
-
|
|
1295
|
-
|
|
1305
|
+
for(var j2 = 0; j2 < entity.length; j2++){
|
|
1306
|
+
var row = entity[j2];
|
|
1307
|
+
var newRow = JSONCopy(emptyRowTemplate);
|
|
1308
|
+
var skipKey = new Set();
|
|
1309
|
+
var rowKeys = Object.keys(row);
|
|
1310
|
+
for(var k = 0; k < rowKeys.length; k++){
|
|
1311
|
+
var fieldCode = rowKeys[k];
|
|
1312
|
+
var rowValue = row[fieldCode];
|
|
1313
|
+
if (!unboundFields.has(fieldCode) && fieldCode in newRow && rowValue !== undefined) {
|
|
1314
|
+
newRow[fieldCode] = rowValue;
|
|
1296
1315
|
}
|
|
1297
|
-
if (
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1316
|
+
if (skipKey.has(fieldCode)) {
|
|
1317
|
+
continue;
|
|
1318
|
+
}
|
|
1319
|
+
if (!cacheFieldMapping[fieldCode]) {
|
|
1320
|
+
var mappedField = fieldMap.get(fieldCode);
|
|
1321
|
+
if (mappedField) {
|
|
1322
|
+
cacheFieldMapping[fieldCode] = mappedField;
|
|
1323
|
+
}
|
|
1302
1324
|
}
|
|
1303
1325
|
var fieldMapping = cacheFieldMapping[fieldCode];
|
|
1304
1326
|
if (fieldMapping) {
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1308
|
-
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1327
|
+
if (isDataBind(fieldMapping.dataBind) && rowValue !== undefined) {
|
|
1328
|
+
newRow[fieldMapping.controlId] = rowValue;
|
|
1309
1329
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1330
|
+
var fieldControlId = fieldMapping.controlId;
|
|
1331
|
+
if (!cacheEmptyState[fieldControlId]) {
|
|
1332
|
+
var _this_store_getEmptyState;
|
|
1333
|
+
cacheEmptyState[fieldControlId] = JSONCopy((_this_store_getEmptyState = _this.store.getEmptyState(fieldControlId)) !== null && _this_store_getEmptyState !== void 0 ? _this_store_getEmptyState : {});
|
|
1313
1334
|
}
|
|
1314
|
-
var objValue = JSONCopy(cacheEmptyState[
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1335
|
+
var objValue = JSONCopy(cacheEmptyState[fieldControlId]);
|
|
1336
|
+
var dataBind = fieldMapping.dataBind;
|
|
1337
|
+
var bindKeys = Object.keys(dataBind);
|
|
1338
|
+
for(var m = 0; m < bindKeys.length; m++){
|
|
1339
|
+
var key = bindKeys[m];
|
|
1340
|
+
var bindInfo = dataBind[key];
|
|
1341
|
+
var fieldCodeValue = row[bindInfo.fieldCode];
|
|
1342
|
+
if (fieldCodeValue !== undefined) {
|
|
1343
|
+
objValue[key] = fieldCodeValue;
|
|
1319
1344
|
}
|
|
1320
|
-
skipKey.
|
|
1321
|
-
}
|
|
1322
|
-
newRow[
|
|
1345
|
+
skipKey.add(bindInfo.fieldCode);
|
|
1346
|
+
}
|
|
1347
|
+
newRow[fieldControlId] = objValue;
|
|
1323
1348
|
}
|
|
1324
|
-
} else if (fieldCode === 'uid' &&
|
|
1325
|
-
newRow.uid =
|
|
1326
|
-
} else if (fieldCode === 'virtualStore' &&
|
|
1327
|
-
newRow.virtualStore = Object.freeze(
|
|
1349
|
+
} else if (fieldCode === 'uid' && rowValue !== undefined) {
|
|
1350
|
+
newRow.uid = rowValue;
|
|
1351
|
+
} else if (fieldCode === 'virtualStore' && rowValue !== undefined) {
|
|
1352
|
+
newRow.virtualStore = Object.freeze(rowValue);
|
|
1328
1353
|
}
|
|
1329
|
-
}
|
|
1330
|
-
newState[
|
|
1331
|
-
}
|
|
1354
|
+
}
|
|
1355
|
+
newState[dataViewId][controlId].push(newRow);
|
|
1356
|
+
}
|
|
1332
1357
|
} else if (entity) {
|
|
1333
1358
|
var _Object_keys;
|
|
1334
|
-
var
|
|
1335
|
-
;
|
|
1359
|
+
var skipKey1 = [];
|
|
1336
1360
|
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1337
1361
|
if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
|
|
1338
|
-
//
|
|
1362
|
+
// 空对象,不做处理
|
|
1339
1363
|
} else {
|
|
1340
1364
|
Object.keys(entity).map(function(fieldCode) {
|
|
1341
|
-
if (
|
|
1365
|
+
if (skipKey1.includes(fieldCode)) {
|
|
1342
1366
|
return;
|
|
1343
1367
|
}
|
|
1344
|
-
var mapping =
|
|
1368
|
+
var mapping = _this1.getDataBindMapping(dataCode, fieldCode);
|
|
1345
1369
|
if (mapping) {
|
|
1346
1370
|
if (!newState[mapping.dataViewId[0]]) {
|
|
1347
1371
|
newState[mapping.dataViewId[0]] = {};
|
|
1348
1372
|
}
|
|
1349
|
-
if (
|
|
1350
|
-
isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1373
|
+
if (isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
|
|
1351
1374
|
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
1375
|
} else if (!isDataBind(mapping.dataBind)) {
|
|
1354
1376
|
var _this_getEmptyState;
|
|
1355
|
-
var objValue = (_this_getEmptyState =
|
|
1377
|
+
var objValue = (_this_getEmptyState = _this1.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
|
|
1356
1378
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1357
1379
|
var dataBind = mapping.dataBind[key];
|
|
1358
|
-
//金额及计算公式控件在赋值时会经过两次 且当控件值不为同一个模型时,会赋值两次 会导致前后覆盖行为。
|
|
1359
1380
|
if (dataSet[dataBind.dataCode]) {
|
|
1360
1381
|
var extendEntity = dataSet[dataBind.dataCode];
|
|
1361
1382
|
if (extendEntity[dataBind.fieldCode] !== undefined) {
|
|
1362
1383
|
objValue[key] = extendEntity[dataBind.fieldCode];
|
|
1363
1384
|
}
|
|
1364
1385
|
}
|
|
1365
|
-
|
|
1386
|
+
skipKey1.push(dataBind.fieldCode);
|
|
1366
1387
|
});
|
|
1367
1388
|
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1368
1389
|
}
|
|
1390
|
+
} else {
|
|
1391
|
+
var mapping1 = _this1.getDataBindMapping(dataCode);
|
|
1392
|
+
if ((mapping1 === null || mapping1 === void 0 ? void 0 : mapping1.dataViewId) && entity[fieldCode] !== undefined) {
|
|
1393
|
+
var dataViweId = mapping1 === null || mapping1 === void 0 ? void 0 : mapping1.dataViewId;
|
|
1394
|
+
var isInDataView = fieldCode in (emptyState[dataViweId] || {});
|
|
1395
|
+
if (isInDataView) {
|
|
1396
|
+
newState[dataViweId][fieldCode] = entity[fieldCode];
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1369
1399
|
}
|
|
1370
1400
|
});
|
|
1371
1401
|
}
|
|
1372
1402
|
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1373
1403
|
if (newMapping) {
|
|
1404
|
+
var _ref;
|
|
1374
1405
|
var _newMapping_fields;
|
|
1375
1406
|
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
1407
|
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1377
1408
|
});
|
|
1378
1409
|
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 : {});
|
|
1410
|
+
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
1411
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1382
1412
|
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1383
1413
|
if (Object.keys(newState).length) {
|
|
@@ -1391,7 +1421,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1391
1421
|
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1392
1422
|
}
|
|
1393
1423
|
}
|
|
1394
|
-
}
|
|
1424
|
+
};
|
|
1425
|
+
var _this1 = this;
|
|
1426
|
+
// @i18n-translate-ignore
|
|
1427
|
+
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1428
|
+
var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
|
|
1429
|
+
var newState = this.store.defaultState;
|
|
1430
|
+
if (onlySetData === true) {
|
|
1431
|
+
newState = {};
|
|
1432
|
+
}
|
|
1433
|
+
var dataBindMapping = this.store.dataBindMapping;
|
|
1434
|
+
var storeEmptyState = this.store.emptyState;
|
|
1435
|
+
var dataCodes = Object.keys(dataSet);
|
|
1436
|
+
for(var i = 0; i < dataCodes.length; i++)_this = this, _loop(i);
|
|
1395
1437
|
// @i18n-translate-ignore
|
|
1396
1438
|
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1397
1439
|
this.setStates(newState, undefined, _object_spread({
|
|
@@ -1399,7 +1441,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1399
1441
|
}, options));
|
|
1400
1442
|
this.runtime.getFlatInstances();
|
|
1401
1443
|
// @i18n-translate-ignore
|
|
1402
|
-
this.debugLog(
|
|
1444
|
+
this.debugLog("engine setData方法执行完成。");
|
|
1403
1445
|
}
|
|
1404
1446
|
},
|
|
1405
1447
|
{
|
|
@@ -1571,6 +1613,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1571
1613
|
return this.store.controlIdMapping;
|
|
1572
1614
|
}
|
|
1573
1615
|
},
|
|
1616
|
+
{
|
|
1617
|
+
/**
|
|
1618
|
+
* 根据字段获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1619
|
+
* @param dataCode 模型code
|
|
1620
|
+
* @param fieldCode 字段code
|
|
1621
|
+
*/ key: "getFieldInstance",
|
|
1622
|
+
value: function getFieldInstance(dataCode, fieldCode, rowIndex) {
|
|
1623
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
1624
|
+
if (dataBindMapping) {
|
|
1625
|
+
var _instance = this.getInstance(dataBindMapping.controlId, rowIndex);
|
|
1626
|
+
return _instance;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
key: "setFieldInstance",
|
|
1632
|
+
value: function setFieldInstance(dataCode, fieldCode, props, value, rowIndex) {
|
|
1633
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
1634
|
+
if (dataBindMapping) {
|
|
1635
|
+
var _instance = this.getInstance(dataBindMapping.controlId, rowIndex);
|
|
1636
|
+
this.debugLog(getLocaleText('CMD.c7371777541576312'), _instance.id, _instance, props, value);
|
|
1637
|
+
this.setInstance(_instance.id, props, value, rowIndex);
|
|
1638
|
+
return _instance;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
},
|
|
1574
1642
|
{
|
|
1575
1643
|
key: "getDataBindMapping",
|
|
1576
1644
|
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) {
|
|
@@ -179,6 +187,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
179
187
|
// input: 'on_input',
|
|
180
188
|
// 'click-finish': 'on_click_finish',
|
|
181
189
|
// 'list-change': 'on_list_change',
|
|
190
|
+
// 'chart-change': 'on_chart_change',
|
|
182
191
|
// 'list-delete': 'on_list_delete',
|
|
183
192
|
// 'list-search': 'on_list_search',
|
|
184
193
|
// 'list-mounted': 'on_list_mounted',
|
|
@@ -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');
|