@byteluck-fe/model-driven-engine 2.6.0-alpha.1 → 2.6.0-alpha.8
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 +72 -154
- package/dist/esm/common/DataManager.js +60 -128
- package/dist/esm/common/Engine.js +1104 -1054
- package/dist/esm/common/OkWorker.js +106 -75
- package/dist/esm/common/Runtime.js +29 -27
- package/dist/esm/common/Store.js +180 -148
- package/dist/esm/common/checkerValue.js +328 -253
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +378 -302
- package/dist/esm/plugins/ControlsEventPlugin.js +141 -225
- package/dist/esm/plugins/ES6ModulePlugin.js +56 -38
- package/dist/esm/plugins/LifecycleEventPlugin.js +107 -190
- package/dist/esm/plugins/StylePlugin.js +31 -13
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +7 -5
- package/dist/index.umd.js +8 -8
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +180 -180
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +25 -25
- package/dist/types/common/Store.d.ts +49 -49
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
- package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -26
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -14
- package/dist/types/plugins/StylePlugin.d.ts +12 -12
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
|
@@ -49,6 +49,20 @@ function _classCallCheck(instance, Constructor) {
|
|
|
49
49
|
throw new TypeError("Cannot call a class as a function");
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
function _defineProperties(target, props) {
|
|
53
|
+
for(var i = 0; i < props.length; i++){
|
|
54
|
+
var descriptor = props[i];
|
|
55
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
56
|
+
descriptor.configurable = true;
|
|
57
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
58
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
62
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
63
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
64
|
+
return Constructor;
|
|
65
|
+
}
|
|
52
66
|
function _defineProperty(obj, key, value) {
|
|
53
67
|
if (key in obj) {
|
|
54
68
|
Object.defineProperty(obj, key, {
|
|
@@ -99,7 +113,7 @@ function _inherits(subClass, superClass) {
|
|
|
99
113
|
}
|
|
100
114
|
function _instanceof(left, right) {
|
|
101
115
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
102
|
-
return
|
|
116
|
+
return right[Symbol.hasInstance](left);
|
|
103
117
|
} else {
|
|
104
118
|
return left instanceof right;
|
|
105
119
|
}
|
|
@@ -152,30 +166,6 @@ function _objectSpread(target) {
|
|
|
152
166
|
}
|
|
153
167
|
return target;
|
|
154
168
|
}
|
|
155
|
-
function ownKeys(object, enumerableOnly) {
|
|
156
|
-
var keys = Object.keys(object);
|
|
157
|
-
if (Object.getOwnPropertySymbols) {
|
|
158
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
159
|
-
if (enumerableOnly) {
|
|
160
|
-
symbols = symbols.filter(function(sym) {
|
|
161
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
keys.push.apply(keys, symbols);
|
|
165
|
-
}
|
|
166
|
-
return keys;
|
|
167
|
-
}
|
|
168
|
-
function _objectSpreadProps(target, source) {
|
|
169
|
-
source = source != null ? source : {};
|
|
170
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
171
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
172
|
-
} else {
|
|
173
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
174
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
return target;
|
|
178
|
-
}
|
|
179
169
|
function _possibleConstructorReturn(self, call) {
|
|
180
170
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
181
171
|
return call;
|
|
@@ -238,121 +228,27 @@ function _createSuper(Derived) {
|
|
|
238
228
|
return _possibleConstructorReturn(this, result);
|
|
239
229
|
};
|
|
240
230
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return g = {
|
|
252
|
-
next: verb(0),
|
|
253
|
-
"throw": verb(1),
|
|
254
|
-
"return": verb(2)
|
|
255
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
256
|
-
return this;
|
|
257
|
-
}), g;
|
|
258
|
-
function verb(n) {
|
|
259
|
-
return function(v) {
|
|
260
|
-
return step([
|
|
261
|
-
n,
|
|
262
|
-
v
|
|
263
|
-
]);
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
function step(op) {
|
|
267
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
268
|
-
while(_)try {
|
|
269
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
270
|
-
if (y = 0, t) op = [
|
|
271
|
-
op[0] & 2,
|
|
272
|
-
t.value
|
|
273
|
-
];
|
|
274
|
-
switch(op[0]){
|
|
275
|
-
case 0:
|
|
276
|
-
case 1:
|
|
277
|
-
t = op;
|
|
278
|
-
break;
|
|
279
|
-
case 4:
|
|
280
|
-
_.label++;
|
|
281
|
-
return {
|
|
282
|
-
value: op[1],
|
|
283
|
-
done: false
|
|
284
|
-
};
|
|
285
|
-
case 5:
|
|
286
|
-
_.label++;
|
|
287
|
-
y = op[1];
|
|
288
|
-
op = [
|
|
289
|
-
0
|
|
290
|
-
];
|
|
291
|
-
continue;
|
|
292
|
-
case 7:
|
|
293
|
-
op = _.ops.pop();
|
|
294
|
-
_.trys.pop();
|
|
295
|
-
continue;
|
|
296
|
-
default:
|
|
297
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
298
|
-
_ = 0;
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
302
|
-
_.label = op[1];
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
306
|
-
_.label = t[1];
|
|
307
|
-
t = op;
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
if (t && _.label < t[2]) {
|
|
311
|
-
_.label = t[2];
|
|
312
|
-
_.ops.push(op);
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
if (t[2]) _.ops.pop();
|
|
316
|
-
_.trys.pop();
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
op = body.call(thisArg, _);
|
|
320
|
-
} catch (e) {
|
|
321
|
-
op = [
|
|
322
|
-
6,
|
|
323
|
-
e
|
|
324
|
-
];
|
|
325
|
-
y = 0;
|
|
326
|
-
} finally{
|
|
327
|
-
f = t = 0;
|
|
328
|
-
}
|
|
329
|
-
if (op[0] & 5) throw op[1];
|
|
330
|
-
return {
|
|
331
|
-
value: op[0] ? op[1] : void 0,
|
|
332
|
-
done: true
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
import { DataBind, ObjectDataBind, RuntimeListControl } from "@byteluck-fe/model-driven-core";
|
|
337
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
338
|
-
import { Runtime } from "./Runtime";
|
|
339
|
-
import { Store } from "./Store";
|
|
340
|
-
import { findItem, proxyState } from "./proxyState";
|
|
341
|
-
import { ActionManager } from "./ActionManager";
|
|
342
|
-
import { DataManager } from "./DataManager";
|
|
343
|
-
import { checkerSubtableValue, checkerValue } from "./checkerValue";
|
|
344
|
-
if (typeof window !== "undefined") {
|
|
231
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
232
|
+
import { DataBind, ObjectDataBind, RuntimeListControl } from '@byteluck-fe/model-driven-core';
|
|
233
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from '@byteluck-fe/model-driven-shared';
|
|
234
|
+
import { Runtime } from './Runtime';
|
|
235
|
+
import { Store } from './Store';
|
|
236
|
+
import { findItem, proxyState } from './proxyState';
|
|
237
|
+
import { ActionManager } from './ActionManager';
|
|
238
|
+
import { DataManager } from './DataManager';
|
|
239
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
240
|
+
if (typeof window !== 'undefined') {
|
|
345
241
|
// @ts-ignore
|
|
346
242
|
window.engines = {};
|
|
347
243
|
}
|
|
348
244
|
// setState的时候,存储options中转变量
|
|
349
245
|
var eventOptionsTemp = null;
|
|
350
246
|
// 当前正在注册的插件名称
|
|
351
|
-
var applyingPluginName =
|
|
352
|
-
// 整体渲染引擎 并且 提供发布订阅能力
|
|
353
|
-
|
|
247
|
+
var applyingPluginName = '';
|
|
248
|
+
var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
249
|
+
/*#__PURE__*/ function(Watcher1) {
|
|
354
250
|
"use strict";
|
|
355
|
-
_inherits(Engine,
|
|
251
|
+
_inherits(Engine, Watcher1);
|
|
356
252
|
var _super = _createSuper(Engine);
|
|
357
253
|
function Engine(props) {
|
|
358
254
|
_classCallCheck(this, Engine);
|
|
@@ -368,8 +264,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
368
264
|
_this._jobTasks = [];
|
|
369
265
|
_this.createControlInstance = _this.createInstance;
|
|
370
266
|
_this.$options = Object.freeze(props);
|
|
371
|
-
var
|
|
372
|
-
language, language =
|
|
267
|
+
var _$options = _this.$options, _autoMount = _$options.autoMount, autoMount = _autoMount === void 0 ? true : _autoMount, schema = _$options.schema, beforeCreateInstance = _$options.beforeCreateInstance, externalParams = _$options.externalParams, _language = _$options.// fieldModel,
|
|
268
|
+
language, language = _language === void 0 ? DEFAULT_LOCALE : _language, _debug = _$options.debug, debug = _debug === void 0 ? false : _debug;
|
|
373
269
|
RulesMessage.setLocale(language);
|
|
374
270
|
_this.debug = debug;
|
|
375
271
|
_this.runtime = new Runtime({
|
|
@@ -380,1027 +276,1181 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
380
276
|
_this.store = new Store({
|
|
381
277
|
instance: _this.runtime.instance
|
|
382
278
|
});
|
|
383
|
-
_this.debugLog(
|
|
279
|
+
_this.debugLog('engine is Instantiation complete');
|
|
384
280
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
385
281
|
autoMount && _this.mount();
|
|
386
282
|
return _this;
|
|
387
283
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (!this.__pluginsApplied) {
|
|
397
|
-
this.__plugins.push(plugin);
|
|
398
|
-
}
|
|
399
|
-
return this;
|
|
400
|
-
};
|
|
401
|
-
// 注册外部控件
|
|
402
|
-
_proto.registerControl = function registerControl() {
|
|
403
|
-
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
404
|
-
arg[_key] = arguments[_key];
|
|
405
|
-
}
|
|
406
|
-
var _this_runtime;
|
|
407
|
-
(_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
|
|
408
|
-
return this;
|
|
409
|
-
};
|
|
410
|
-
_proto.mount = function mount() {
|
|
411
|
-
this.debugLog("engine的mount方法开始调用");
|
|
412
|
-
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
413
|
-
this._handlerProxyState();
|
|
414
|
-
this.__plugins = plugins;
|
|
415
|
-
this.applyPlugins();
|
|
416
|
-
// 触发所有控件的默认值的change事件
|
|
417
|
-
this.setStates(this.getState());
|
|
418
|
-
this.debugLog("engine的mount方法调用结束");
|
|
419
|
-
if (this.debug && typeof window !== "undefined") {
|
|
420
|
-
// @ts-ignore
|
|
421
|
-
window.engines[this.id] = this;
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
_proto.destroy = function destroy() {
|
|
425
|
-
if (this.debug && typeof window !== "undefined") {
|
|
426
|
-
// @ts-ignore
|
|
427
|
-
delete window.engines[this.id];
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
_proto._handlerProxyState = function _handlerProxyState() {
|
|
431
|
-
this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
|
|
432
|
-
};
|
|
433
|
-
_proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
|
|
434
|
-
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
435
|
-
// 找不到控件说明不是改动控件上的字段,直接通过
|
|
436
|
-
if (!instance) {
|
|
437
|
-
return newValue;
|
|
438
|
-
}
|
|
439
|
-
// @ts-ignore
|
|
440
|
-
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
441
|
-
if (newValue === null) {
|
|
442
|
-
return [];
|
|
284
|
+
_createClass(Engine, [
|
|
285
|
+
{
|
|
286
|
+
key: "debugLog",
|
|
287
|
+
value: function debugLog() {
|
|
288
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
289
|
+
args[_key] = arguments[_key];
|
|
290
|
+
}
|
|
291
|
+
this.debug && log.apply(void 0, _toConsumableArray(args));
|
|
443
292
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (
|
|
449
|
-
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
key: "use",
|
|
296
|
+
value: function use(plugin) {
|
|
297
|
+
if (!this.__pluginsApplied) {
|
|
298
|
+
this.__plugins.push(plugin);
|
|
299
|
+
}
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
key: "registerControl",
|
|
305
|
+
value: // 注册外部控件
|
|
306
|
+
function registerControl() {
|
|
307
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
308
|
+
arg[_key] = arguments[_key];
|
|
309
|
+
}
|
|
310
|
+
var _runtime;
|
|
311
|
+
(_runtime = this.runtime).register.apply(_runtime, _toConsumableArray(arg));
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: "mount",
|
|
317
|
+
value: function mount() {
|
|
318
|
+
this.debugLog("engine的mount方法开始调用");
|
|
319
|
+
var _$options = this.$options, _plugins = _$options.plugins, plugins = _plugins === void 0 ? [] : _plugins;
|
|
320
|
+
this._handlerProxyState();
|
|
321
|
+
this.__plugins = plugins;
|
|
322
|
+
this.applyPlugins();
|
|
323
|
+
// 触发所有控件的默认值的change事件
|
|
324
|
+
this.setStates(this.getState());
|
|
325
|
+
this.debugLog("engine的mount方法调用结束");
|
|
326
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
327
|
+
// @ts-ignore
|
|
328
|
+
window.engines[this.id] = this;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
key: "destroy",
|
|
334
|
+
value: function destroy() {
|
|
335
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
336
|
+
// @ts-ignore
|
|
337
|
+
delete window.engines[this.id];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
key: "_handlerProxyState",
|
|
343
|
+
value: function _handlerProxyState() {
|
|
344
|
+
this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
key: "_proxyStateBeforeSetCallback",
|
|
349
|
+
value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
|
|
350
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
351
|
+
// 找不到控件说明不是改动控件上的字段,直接通过
|
|
352
|
+
if (!instance) {
|
|
353
|
+
return newValue;
|
|
450
354
|
}
|
|
451
|
-
return result;
|
|
452
|
-
}, {});
|
|
453
|
-
// @ts-ignore
|
|
454
|
-
var emptyState = this.getEmptyState(instance.id);
|
|
455
|
-
return newValue.map(function(row) {
|
|
456
|
-
return(// @ts-ignore
|
|
457
|
-
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
var keys = key.split(".");
|
|
461
|
-
var lastKey = keys[keys.length - 1];
|
|
462
|
-
try {
|
|
463
|
-
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
464
|
-
} catch (e) {
|
|
465
|
-
warn("the id=".concat(instance.id, "'s instance setState error, %o ").concat(e, "."), newValue);
|
|
466
|
-
throw e;
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
_proto._proxyStateCallback = function _proxyStateCallback(state, key, type, args, result) {
|
|
470
|
-
if (Array.isArray(state)) {
|
|
471
|
-
this._handlerArrayUpdate(state, key, type, args, result);
|
|
472
|
-
} else {
|
|
473
|
-
this._handlerObjectUpdate(state, key, type, args);
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
_proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
|
|
477
|
-
var _this = this;
|
|
478
|
-
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
479
|
-
if (!_instanceof(subtable, RuntimeListControl)) return;
|
|
480
|
-
// 新增多行方法
|
|
481
|
-
var createRows = function(len) {
|
|
482
|
-
// @ts-ignore
|
|
483
|
-
var newRows = [];
|
|
484
|
-
for(var i = 0; i < len; i++){
|
|
485
355
|
// @ts-ignore
|
|
486
|
-
|
|
487
|
-
|
|
356
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
357
|
+
if (newValue === null) {
|
|
358
|
+
return [];
|
|
359
|
+
}
|
|
360
|
+
// @ts-ignore
|
|
361
|
+
var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
|
|
362
|
+
var formInstance = column.children[0];
|
|
363
|
+
// if (formInstance && formInstance instanceof RuntimeFormControl) {
|
|
364
|
+
if (formInstance && formInstance.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
365
|
+
result[formInstance.id] = formInstance.fieldType;
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
368
|
+
}, {});
|
|
369
|
+
// @ts-ignore
|
|
370
|
+
var emptyState = this.getEmptyState(instance.id);
|
|
371
|
+
return newValue.map(function(row) {
|
|
372
|
+
// @ts-ignore
|
|
373
|
+
return checkerSubtableValue(fieldTypeMap, row, emptyState);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
var keys = key.split('.');
|
|
377
|
+
var lastKey = keys[keys.length - 1];
|
|
378
|
+
try {
|
|
379
|
+
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
380
|
+
} catch (e) {
|
|
381
|
+
warn("the id=".concat(instance.id, "'s instance setState error, %o ").concat(e, "."), newValue);
|
|
382
|
+
throw e;
|
|
383
|
+
}
|
|
488
384
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
key: "_proxyStateCallback",
|
|
388
|
+
value: function _proxyStateCallback(state, key, type, args, result) {
|
|
389
|
+
if (Array.isArray(state)) {
|
|
390
|
+
this._handlerArrayUpdate(state, key, type, args, result);
|
|
391
|
+
} else {
|
|
392
|
+
this._handlerObjectUpdate(state, key, type, args);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
key: "_handlerArrayUpdate",
|
|
398
|
+
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
399
|
+
var _this = this;
|
|
400
|
+
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
401
|
+
if (!_instanceof(subtable, RuntimeListControl)) return;
|
|
402
|
+
// 新增多行方法
|
|
403
|
+
var createRows = function(len) {
|
|
404
|
+
// @ts-ignore
|
|
405
|
+
var newRows = [];
|
|
406
|
+
for(var i = 0; i < len; i++){
|
|
407
|
+
// @ts-ignore
|
|
408
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
409
|
+
row && newRows.push(row);
|
|
410
|
+
}
|
|
411
|
+
// @ts-ignore
|
|
412
|
+
return newRows;
|
|
413
|
+
};
|
|
414
|
+
var options = eventOptionsTemp;
|
|
415
|
+
// @ts-ignore
|
|
416
|
+
var createdNewRows = [];
|
|
417
|
+
var createdNewRowsData = [];
|
|
418
|
+
var deleted = [];
|
|
419
|
+
if (type && args) {
|
|
420
|
+
// const subtableOldLength = subtable.children.length
|
|
421
|
+
switch(type){
|
|
422
|
+
case 'push':
|
|
423
|
+
case 'unshift':
|
|
424
|
+
var _children;
|
|
425
|
+
var newRowLengths = args.length;
|
|
426
|
+
createdNewRows = createRows(newRowLengths);
|
|
427
|
+
createdNewRowsData = args;
|
|
428
|
+
(_children = subtable.children)[type].apply(_children, _toConsumableArray(createdNewRows));
|
|
429
|
+
this.runtime.getFlatInstances();
|
|
430
|
+
break;
|
|
431
|
+
case 'splice':
|
|
432
|
+
if (args.length > 2) {
|
|
433
|
+
var // @ts-ignore
|
|
434
|
+
_children1;
|
|
435
|
+
var newRowLengths1 = args.length - 2;
|
|
436
|
+
var newValues = args.slice(2);
|
|
437
|
+
createdNewRows = createRows(newRowLengths1);
|
|
438
|
+
createdNewRowsData = newValues;
|
|
439
|
+
// 从哪儿开始
|
|
440
|
+
var start = args[0];
|
|
441
|
+
// 替换几个
|
|
442
|
+
var replace = args[1];
|
|
443
|
+
(_children1 = subtable.children)[type].apply(_children1, [
|
|
444
|
+
start,
|
|
445
|
+
replace
|
|
446
|
+
].concat(_toConsumableArray(createdNewRows)));
|
|
447
|
+
this.runtime.getFlatInstances();
|
|
448
|
+
// newValues.forEach((item: any, index) => {
|
|
449
|
+
// let newIndex = start + index
|
|
450
|
+
// this.setStates(item, newIndex, options)
|
|
451
|
+
// })
|
|
452
|
+
} else {
|
|
453
|
+
var // @ts-ignore
|
|
454
|
+
_children2;
|
|
455
|
+
(_children2 = subtable.children)[type].apply(_children2, _toConsumableArray(args));
|
|
456
|
+
this.runtime.getFlatInstances();
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
459
|
+
default:
|
|
460
|
+
var // @ts-ignore
|
|
461
|
+
_children3;
|
|
462
|
+
(_children3 = subtable.children)[type].apply(_children3, _toConsumableArray(args));
|
|
463
|
+
this.runtime.getFlatInstances();
|
|
464
|
+
break;
|
|
535
465
|
}
|
|
536
|
-
|
|
537
|
-
|
|
466
|
+
if (type === 'splice') {
|
|
467
|
+
deleted = result;
|
|
468
|
+
} else if ([
|
|
469
|
+
'pop',
|
|
470
|
+
'shift'
|
|
471
|
+
].includes(type)) {
|
|
472
|
+
deleted = [
|
|
473
|
+
result
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
this.emit('list-change', {
|
|
477
|
+
instance: subtable,
|
|
478
|
+
value: this.getState(subtable.id),
|
|
479
|
+
options: Object.assign({}, options, {
|
|
480
|
+
changed: createdNewRows,
|
|
481
|
+
data: createdNewRowsData,
|
|
482
|
+
deleted: deleted !== null && deleted !== void 0 ? deleted : [],
|
|
483
|
+
jsonValue: JSON.stringify(this.getState(subtable.id))
|
|
484
|
+
})
|
|
485
|
+
});
|
|
486
|
+
// 主动清空本次任务中的options
|
|
487
|
+
eventOptionsTemp = null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
key: "_handlerObjectUpdate",
|
|
493
|
+
value: function _handlerObjectUpdate(state, key, value, oldValue) {
|
|
494
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
495
|
+
if (!instance) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
var index = this.getInstanceRowIndex(instance);
|
|
499
|
+
var options = eventOptionsTemp || {};
|
|
500
|
+
// if (instance instanceof RuntimeListControl) {
|
|
501
|
+
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
538
502
|
var // @ts-ignore
|
|
539
|
-
|
|
540
|
-
|
|
503
|
+
_children;
|
|
504
|
+
instance.children.length = 0;
|
|
505
|
+
var newValue = value;
|
|
506
|
+
// @ts-ignore
|
|
507
|
+
var newRows = [];
|
|
508
|
+
for(var i = 0; i < newValue.length; i++){
|
|
509
|
+
// @ts-ignore
|
|
510
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
511
|
+
row && newRows.push(row);
|
|
512
|
+
}
|
|
513
|
+
(_children = instance.children).push.apply(_children, _toConsumableArray(newRows));
|
|
541
514
|
this.runtime.getFlatInstances();
|
|
542
|
-
|
|
515
|
+
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
516
|
+
// for (let i = 0; i < newValue.length; i++) {
|
|
517
|
+
// this.setStates(newValue[i], i, options)
|
|
518
|
+
// }
|
|
519
|
+
this.emit('list-change', {
|
|
520
|
+
instance: instance,
|
|
521
|
+
value: value,
|
|
522
|
+
options: _objectSpread({}, options, {
|
|
523
|
+
// @ts-ignore
|
|
524
|
+
changed: newRows,
|
|
525
|
+
data: newValue,
|
|
526
|
+
deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
|
|
527
|
+
})
|
|
528
|
+
});
|
|
529
|
+
} else {
|
|
530
|
+
this.emit('change', {
|
|
531
|
+
instance: instance,
|
|
532
|
+
value: this.getState(instance.id, index),
|
|
533
|
+
rowIndex: index,
|
|
534
|
+
options: _objectSpread({}, options, {
|
|
535
|
+
oldValue: oldValue
|
|
536
|
+
})
|
|
537
|
+
});
|
|
538
|
+
}
|
|
543
539
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
key: "applyPlugins",
|
|
543
|
+
value: function applyPlugins() {
|
|
544
|
+
var _this = this;
|
|
545
|
+
if (this.__pluginsApplied) return;
|
|
546
|
+
this.__plugins.forEach(function(plugin) {
|
|
547
|
+
try {
|
|
548
|
+
var _pluginName;
|
|
549
|
+
applyingPluginName = (_pluginName = plugin.pluginName) !== null && _pluginName !== void 0 ? _pluginName : plugin.constructor.name;
|
|
550
|
+
plugin.apply(_this);
|
|
551
|
+
} catch (e) {
|
|
552
|
+
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
553
|
+
} finally{
|
|
554
|
+
applyingPluginName = '';
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
this.__pluginsApplied = true;
|
|
553
558
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
jsonValue: JSON.stringify(this.getState(subtable.id))
|
|
562
|
-
})
|
|
563
|
-
});
|
|
564
|
-
// 主动清空本次任务中的options
|
|
565
|
-
eventOptionsTemp = null;
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
_proto._handlerObjectUpdate = function _handlerObjectUpdate(state, key, value, oldValue) {
|
|
569
|
-
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
570
|
-
if (!instance) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
var index = this.getInstanceRowIndex(instance);
|
|
574
|
-
var options = eventOptionsTemp || {};
|
|
575
|
-
// if (instance instanceof RuntimeListControl) {
|
|
576
|
-
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
577
|
-
var // @ts-ignore
|
|
578
|
-
_instance_children;
|
|
579
|
-
instance.children.length = 0;
|
|
580
|
-
var newValue = value;
|
|
581
|
-
// @ts-ignore
|
|
582
|
-
var newRows = [];
|
|
583
|
-
for(var i = 0; i < newValue.length; i++){
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
key: "listControlCreateRow",
|
|
562
|
+
value: function listControlCreateRow(instance, rowType) {
|
|
563
|
+
var row = this.runtime.createControlInstance(rowType);
|
|
564
|
+
if (!row) return;
|
|
565
|
+
// if (row instanceof RuntimeLayoutControl) {
|
|
584
566
|
// @ts-ignore
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
this.runtime.getFlatInstances();
|
|
590
|
-
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
591
|
-
// for (let i = 0; i < newValue.length; i++) {
|
|
592
|
-
// this.setStates(newValue[i], i, options)
|
|
593
|
-
// }
|
|
594
|
-
this.emit("list-change", {
|
|
595
|
-
instance: instance,
|
|
596
|
-
value: value,
|
|
597
|
-
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
567
|
+
if (row.controlType === CONTROL_BASE_TYPE.LAYOUT) {
|
|
568
|
+
var _children;
|
|
569
|
+
var inst = row;
|
|
570
|
+
var template = JSONCopy(instance.props.headers);
|
|
598
571
|
// @ts-ignore
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
});
|
|
604
|
-
} else {
|
|
605
|
-
this.emit("change", {
|
|
606
|
-
instance: instance,
|
|
607
|
-
value: this.getState(instance.id, index),
|
|
608
|
-
rowIndex: index,
|
|
609
|
-
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
610
|
-
oldValue: oldValue
|
|
611
|
-
})
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
_proto.applyPlugins = function applyPlugins() {
|
|
616
|
-
var _this = this;
|
|
617
|
-
if (this.__pluginsApplied) return;
|
|
618
|
-
this.__plugins.forEach(function(plugin) {
|
|
619
|
-
try {
|
|
620
|
-
var _plugin_pluginName;
|
|
621
|
-
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
622
|
-
plugin.apply(_this);
|
|
623
|
-
} catch (e) {
|
|
624
|
-
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
625
|
-
} finally{
|
|
626
|
-
applyingPluginName = "";
|
|
572
|
+
var columns = this.createControl(template);
|
|
573
|
+
(_children = inst.children).push.apply(_children, _toConsumableArray(columns));
|
|
574
|
+
}
|
|
575
|
+
return row;
|
|
627
576
|
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
_this1._jobTasks.push(promise);
|
|
699
|
-
}
|
|
700
|
-
return [
|
|
701
|
-
4,
|
|
702
|
-
_superprop_get_emit().call(_this1, eventKey, payload)
|
|
703
|
-
];
|
|
704
|
-
case 4:
|
|
705
|
-
results = _state.sent();
|
|
706
|
-
if (promiseResolver && promise) {
|
|
707
|
-
// 每一个任务完成的时候,都把自己从task中去掉
|
|
708
|
-
promiseResolver();
|
|
709
|
-
_this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
key: "listControlAddRow",
|
|
580
|
+
value: function listControlAddRow(instance) {
|
|
581
|
+
var // @ts-ignore
|
|
582
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
583
|
+
var row = this.listControlCreateRow(instance, rowType);
|
|
584
|
+
if (!row) return;
|
|
585
|
+
instance.children.push(row);
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
key: "emit",
|
|
590
|
+
value: // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
|
|
591
|
+
function emit(eventKey, payload) {
|
|
592
|
+
var _this = this;
|
|
593
|
+
var _this1 = this, _superprop_get_emit = function() {
|
|
594
|
+
return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
|
|
595
|
+
};
|
|
596
|
+
return _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
597
|
+
var needWait, promiseResolver, promise, results;
|
|
598
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
599
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
600
|
+
case 0:
|
|
601
|
+
if (!(eventKey === 'engine-mounted')) {
|
|
602
|
+
_ctx.next = 11;
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
if (!_this1.isMounted) {
|
|
606
|
+
_ctx.next = 4;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
610
|
+
return _ctx.abrupt("return", Promise.resolve([]));
|
|
611
|
+
case 4:
|
|
612
|
+
if (!_this1._jobTasks.length) {
|
|
613
|
+
_ctx.next = 10;
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
console.time('engine-mounted need wait');
|
|
617
|
+
needWait = _toConsumableArray(_this1._jobTasks);
|
|
618
|
+
_ctx.next = 9;
|
|
619
|
+
return Promise.all(needWait);
|
|
620
|
+
case 9:
|
|
621
|
+
console.timeEnd('engine-mounted need wait');
|
|
622
|
+
case 10:
|
|
623
|
+
_this1.isMounted = true;
|
|
624
|
+
case 11:
|
|
625
|
+
;
|
|
626
|
+
;
|
|
627
|
+
// 如果没有挂载的话,需要记录在挂载之前触发的所有任务
|
|
628
|
+
if (!_this1.isMounted) {
|
|
629
|
+
promise = new Promise(function(resolve) {
|
|
630
|
+
promiseResolver = resolve;
|
|
631
|
+
});
|
|
632
|
+
_this1._jobTasks.push(promise);
|
|
633
|
+
}
|
|
634
|
+
_ctx.next = 16;
|
|
635
|
+
return _superprop_get_emit().call(_this1, eventKey, payload);
|
|
636
|
+
case 16:
|
|
637
|
+
results = _ctx.sent;
|
|
638
|
+
if (promiseResolver && promise) {
|
|
639
|
+
// 每一个任务完成的时候,都把自己从task中去掉
|
|
640
|
+
promiseResolver();
|
|
641
|
+
_this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
|
|
642
|
+
}
|
|
643
|
+
return _ctx.abrupt("return", results);
|
|
644
|
+
case 19:
|
|
645
|
+
case "end":
|
|
646
|
+
return _ctx.stop();
|
|
710
647
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
648
|
+
}, _callee);
|
|
649
|
+
}))();
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
key: "on",
|
|
654
|
+
value: function on(key, callback) {
|
|
655
|
+
if (applyingPluginName) {
|
|
656
|
+
callback.applyingPluginName = applyingPluginName;
|
|
715
657
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
658
|
+
return _get(_getPrototypeOf(Engine.prototype), "on", this).call(this, key, callback);
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
key: "createControl",
|
|
663
|
+
value: function createControl() {
|
|
664
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
665
|
+
args[_key] = arguments[_key];
|
|
666
|
+
}
|
|
667
|
+
var _runtime;
|
|
668
|
+
return (_runtime = this.runtime).createControl.apply(_runtime, _toConsumableArray(args));
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
key: "createInstance",
|
|
673
|
+
value: function createInstance(type, initSchema) {
|
|
674
|
+
return this.runtime.createControlInstance(type, initSchema);
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
key: "schemaEvent",
|
|
679
|
+
value: function schemaEvent(eventKey, payload) {
|
|
680
|
+
this.emit(eventKey, payload);
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
key: "updateInstanceProps",
|
|
685
|
+
value: function updateInstanceProps(instance, props, value, rowIndex) {
|
|
686
|
+
return this.setInstance(instance, props, value, rowIndex);
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
key: "getAllRules",
|
|
691
|
+
value: function getAllRules(controlId) {
|
|
692
|
+
var rules = this.runtime.allRules;
|
|
693
|
+
if (controlId === undefined) {
|
|
694
|
+
return rules;
|
|
695
|
+
} else {
|
|
696
|
+
var ref, ref1;
|
|
697
|
+
return {
|
|
698
|
+
rules: (ref = rules.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields,
|
|
699
|
+
antdRules: (ref1 = rules.antdRules[controlId]) === null || ref1 === void 0 ? void 0 : ref1.fields
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: "getRules",
|
|
706
|
+
value: function getRules(controlId) {
|
|
707
|
+
if (controlId === undefined) {
|
|
708
|
+
return this.runtime.rules;
|
|
709
|
+
} else {
|
|
710
|
+
var ref;
|
|
711
|
+
return (ref = this.runtime.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
key: "getAntdRules",
|
|
717
|
+
value: function getAntdRules(controlId) {
|
|
718
|
+
if (controlId === undefined) {
|
|
719
|
+
return this.runtime.antdRules;
|
|
720
|
+
} else {
|
|
721
|
+
var ref;
|
|
722
|
+
return (ref = this.runtime.antdRules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
key: "getState",
|
|
728
|
+
value: function getState(controlId, rowIndex) {
|
|
729
|
+
if (controlId === undefined) {
|
|
730
|
+
return this.store.state;
|
|
731
|
+
} else {
|
|
732
|
+
return this.store.getState(controlId, rowIndex);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
key: "getEmptyState",
|
|
738
|
+
value: function getEmptyState(controlId) {
|
|
739
|
+
if (controlId === undefined) {
|
|
740
|
+
return JSONCopy(this.store.emptyState);
|
|
741
|
+
} else {
|
|
742
|
+
return JSONCopy(this.store.getEmptyState(controlId));
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
/**
|
|
784
748
|
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
785
749
|
* @param options 需要携带的options
|
|
786
|
-
* */
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
750
|
+
* */ key: "setPayloadOptions",
|
|
751
|
+
value: function setPayloadOptions(options) {
|
|
752
|
+
eventOptionsTemp = options;
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
key: "setState",
|
|
757
|
+
value: function setState(controlId, value, rowIndex, options) {
|
|
758
|
+
eventOptionsTemp = options;
|
|
759
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
760
|
+
this.store.setState(controlId, value, rowIndex);
|
|
761
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
762
|
+
eventOptionsTemp = null;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
/**
|
|
797
767
|
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
798
768
|
* @param states
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
769
|
+
*/ key: "setStates",
|
|
770
|
+
value: function setStates(states, rowIndex, options) {
|
|
771
|
+
var _this = this;
|
|
772
|
+
var newStates = states;
|
|
773
|
+
Object.keys(newStates).forEach(function(stateId) {
|
|
774
|
+
var _this2 = _this;
|
|
775
|
+
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
776
|
+
var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
|
|
777
|
+
if (controlIdMapping.dataView === stateId) {
|
|
778
|
+
// state对象是dataView包裹的
|
|
779
|
+
var value = newStates[stateId][controlId];
|
|
780
|
+
if (value !== undefined) {
|
|
781
|
+
_this2.setState(controlId, value, rowIndex, options);
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
// state对象是单独的,没有被dataView包裹的
|
|
785
|
+
if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
|
|
786
|
+
if (newStates[stateId] !== undefined) {
|
|
787
|
+
_this2.setState(stateId, newStates[stateId], rowIndex, options);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
816
790
|
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
791
|
+
});
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
/**
|
|
823
797
|
* 通过dataCode和fieldCode来获取控件的值
|
|
824
798
|
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
825
799
|
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
826
800
|
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
827
|
-
* */
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
var dataBindMapping1 = this.getDataBindMapping(dataCode, fieldCode);
|
|
837
|
-
if (!dataBindMapping1) {
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
841
|
-
var state = this.getState(controlId1, rowIndex);
|
|
842
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
843
|
-
return Object.entries(dataBind).reduce(function(result, param) {
|
|
844
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
845
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
846
|
-
if (dataBind.fieldCode === fieldCode) {
|
|
847
|
-
return result[key];
|
|
801
|
+
* */ key: "getField",
|
|
802
|
+
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
803
|
+
if (!fieldCode) {
|
|
804
|
+
var dataBindMapping = this.getDataBindMapping(dataCode);
|
|
805
|
+
if (dataBindMapping) {
|
|
806
|
+
var controlId = dataBindMapping.controlId;
|
|
807
|
+
return this.getState(controlId);
|
|
808
|
+
}
|
|
809
|
+
return;
|
|
848
810
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
var getFieldData = this.getField(dataCode);
|
|
862
|
-
// 明细子表值
|
|
863
|
-
if (Array.isArray(getFieldData)) {
|
|
864
|
-
var data = getFieldData.map(function(item) {
|
|
865
|
-
var obj = {};
|
|
866
|
-
for(var key in item){
|
|
867
|
-
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId1;
|
|
868
|
-
if ((_controlIdMapping_controlId_children_key = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode) {
|
|
869
|
-
var _controlIdMapping_controlId_children_key1;
|
|
870
|
-
obj[(_controlIdMapping_controlId_children_key1 = controlIdMapping[controlId].children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind.fieldCode] = item[key];
|
|
871
|
-
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
872
|
-
// 兼容一个控件需要绑定多个字段的情况
|
|
873
|
-
for(var keyChi in item[key]){
|
|
874
|
-
var _controlIdMapping_controlId_children_key2, _controlIdMapping_controlId2;
|
|
875
|
-
obj[(_controlIdMapping_controlId_children_key2 = (_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key2 === void 0 ? void 0 : _controlIdMapping_controlId_children_key2.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
876
|
-
}
|
|
811
|
+
var dataBindMapping1 = this.getDataBindMapping(dataCode, fieldCode);
|
|
812
|
+
if (!dataBindMapping1) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
var dataBind1 = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
816
|
+
var state = this.getState(controlId1, rowIndex);
|
|
817
|
+
if (_instanceof(dataBind1, ObjectDataBind)) {
|
|
818
|
+
return Object.entries(dataBind1).reduce(function(result, param) {
|
|
819
|
+
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
820
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
821
|
+
if (dataBind.fieldCode === fieldCode) {
|
|
822
|
+
return result[key];
|
|
877
823
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
824
|
+
return result;
|
|
825
|
+
}, state);
|
|
826
|
+
} else {
|
|
827
|
+
return state;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
key: "getData",
|
|
833
|
+
value: function getData(dataCode) {
|
|
834
|
+
if (!dataCode) return;
|
|
835
|
+
var dataBindMapping = this.getDataBindMapping(dataCode);
|
|
836
|
+
var controlIdMapping = this.getControlIdMapping();
|
|
837
|
+
if (dataBindMapping) {
|
|
838
|
+
var controlId = dataBindMapping.controlId;
|
|
839
|
+
var getFieldData = this.getField(dataCode);
|
|
840
|
+
// 明细子表值
|
|
841
|
+
if (Array.isArray(getFieldData)) {
|
|
842
|
+
var data = getFieldData.map(function(item) {
|
|
843
|
+
var obj = {};
|
|
844
|
+
for(var key in item){
|
|
845
|
+
var ref, ref2, ref3, ref4;
|
|
846
|
+
if ((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) {
|
|
847
|
+
var ref5;
|
|
848
|
+
obj[(ref5 = controlIdMapping[controlId].children[key]) === null || ref5 === void 0 ? void 0 : ref5.dataBind.fieldCode] = item[key];
|
|
849
|
+
} else if ((ref4 = controlIdMapping[controlId]) === null || ref4 === void 0 ? void 0 : ref4.children[key]) {
|
|
850
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
851
|
+
for(var keyChi in item[key]){
|
|
852
|
+
var ref6, ref7;
|
|
853
|
+
obj[(ref7 = (ref6 = controlIdMapping[controlId]) === null || ref6 === void 0 ? void 0 : ref6.children[key]) === null || ref7 === void 0 ? void 0 : ref7.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
903
854
|
}
|
|
904
855
|
}
|
|
905
856
|
}
|
|
906
|
-
return
|
|
857
|
+
return obj;
|
|
907
858
|
});
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
var
|
|
912
|
-
|
|
913
|
-
|
|
859
|
+
return data;
|
|
860
|
+
} else {
|
|
861
|
+
var _loop = function(key1) {
|
|
862
|
+
var ref17, ref8, ref9, ref10;
|
|
863
|
+
if ((ref17 = controlIdMapping[key1]) === null || ref17 === void 0 ? void 0 : (ref8 = ref17.dataBind) === null || ref8 === void 0 ? void 0 : ref8.fieldCode) {
|
|
864
|
+
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
|
+
// 明细字表只循环一层明细子表未递归
|
|
869
|
+
obj1[(ref12 = controlIdMapping[key1]) === null || ref12 === void 0 ? void 0 : ref12.dataBind.dataCode] = getFieldData[key1].map(function(item) {
|
|
870
|
+
var objChi = {};
|
|
871
|
+
for(var keyChi in item){
|
|
872
|
+
var ref;
|
|
873
|
+
if ((ref = controlIdMapping[key1].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode) {
|
|
874
|
+
var ref15;
|
|
875
|
+
objChi[(ref15 = controlIdMapping[key1].children[keyChi]) === null || ref15 === void 0 ? void 0 : ref15.dataBind.fieldCode] = item[keyChi];
|
|
876
|
+
} else {
|
|
877
|
+
for(var keyChi1 in item[keyChi]){
|
|
878
|
+
var ref16;
|
|
879
|
+
objChi[(ref16 = controlIdMapping[key1].children[keyChi]) === null || ref16 === void 0 ? void 0 : ref16.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
880
|
+
//
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return objChi;
|
|
885
|
+
});
|
|
886
|
+
} else if (controlIdMapping[key1]) {
|
|
887
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
888
|
+
for(var keyChi2 in getFieldData[key1]){
|
|
889
|
+
var ref13, ref14;
|
|
890
|
+
obj1[(ref14 = (ref13 = controlIdMapping[key1]) === null || ref13 === void 0 ? void 0 : ref13.dataBind[keyChi2]) === null || ref14 === void 0 ? void 0 : ref14.fieldCode] = getFieldData[key1][keyChi2];
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
// 主表
|
|
895
|
+
var obj1 = {};
|
|
896
|
+
for(var key1 in getFieldData)_loop(key1);
|
|
897
|
+
return obj1;
|
|
914
898
|
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
var obj = {};
|
|
918
|
-
for(var key in getFieldData)_loop(key);
|
|
919
|
-
return obj;
|
|
899
|
+
}
|
|
900
|
+
return;
|
|
920
901
|
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
/**
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
/**
|
|
925
905
|
* 通过dataCode和fieldCode来设置控件的值
|
|
926
906
|
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
927
907
|
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
928
908
|
* @param value 修改的值
|
|
929
909
|
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
930
910
|
* @param options 触发事件携带的参数
|
|
931
|
-
* */
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
937
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
938
|
-
var _JSONCopy;
|
|
939
|
-
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
940
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
941
|
-
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
942
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
943
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
944
|
-
if (dataBind.fieldCode === fieldCode) {
|
|
945
|
-
result[key] = value;
|
|
911
|
+
* */ key: "setField",
|
|
912
|
+
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
913
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
914
|
+
if (!dataBindMapping) {
|
|
915
|
+
return;
|
|
946
916
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
917
|
+
var dataBind2 = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
918
|
+
if (_instanceof(dataBind2, ObjectDataBind)) {
|
|
919
|
+
var ref;
|
|
920
|
+
var oldState = (ref = JSONCopy(this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : this.getEmptyState(controlId);
|
|
921
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
922
|
+
var newState = Object.entries(dataBind2).reduce(function(result, param) {
|
|
923
|
+
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
924
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
925
|
+
if (dataBind.fieldCode === fieldCode) {
|
|
926
|
+
result[key] = value;
|
|
927
|
+
}
|
|
928
|
+
return result;
|
|
929
|
+
}, oldState);
|
|
930
|
+
this.setState(controlId, newState, rowIndex, options);
|
|
931
|
+
} else {
|
|
932
|
+
this.setState(controlId, value, rowIndex, options);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
/**
|
|
955
938
|
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
956
939
|
* @param dataCode 需要赋值的目标模型
|
|
957
940
|
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
958
941
|
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
959
942
|
* @param options 触发事件携带的参数
|
|
960
|
-
* */
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
// 对象类型的值
|
|
976
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
977
|
-
var _JSONCopy;
|
|
978
|
-
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
979
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
980
|
-
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
981
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
982
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
983
|
-
skipKeys.push(dataBind.fieldCode);
|
|
984
|
-
var value = state[dataBind.fieldCode];
|
|
985
|
-
if (value !== undefined) {
|
|
986
|
-
result[key] = value;
|
|
943
|
+
* */ key: "setFields",
|
|
944
|
+
value: function setFields(dataCode, state, rowIndex, options) {
|
|
945
|
+
var _this = this;
|
|
946
|
+
var mapping = this.getDataBindMapping(dataCode);
|
|
947
|
+
if (!mapping) {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
var skipKeys = [];
|
|
951
|
+
mapping.fields.forEach(function(item) {
|
|
952
|
+
var dataBind3 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
953
|
+
if (skipKeys.includes(fieldCode)) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
if (!Object.hasOwnProperty.call(state, fieldCode)) {
|
|
957
|
+
return;
|
|
987
958
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
959
|
+
// 对象类型的值
|
|
960
|
+
if (_instanceof(dataBind3, ObjectDataBind)) {
|
|
961
|
+
var ref;
|
|
962
|
+
var oldState = (ref = JSONCopy(_this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : _this.getEmptyState(controlId);
|
|
963
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
964
|
+
var newState = Object.entries(dataBind3).reduce(function(result, param) {
|
|
965
|
+
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
966
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
967
|
+
skipKeys.push(dataBind.fieldCode);
|
|
968
|
+
var value = state[dataBind.fieldCode];
|
|
969
|
+
if (value !== undefined) {
|
|
970
|
+
result[key] = value;
|
|
971
|
+
}
|
|
972
|
+
return result;
|
|
973
|
+
}, oldState);
|
|
974
|
+
_this.setState(item.controlId, newState, rowIndex, options);
|
|
975
|
+
} else {
|
|
976
|
+
_this.setState(controlId, state[fieldCode], rowIndex, options);
|
|
977
|
+
}
|
|
978
|
+
});
|
|
993
979
|
}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
/**
|
|
997
983
|
* 通过dataCode来将state转化为标准的state结构
|
|
998
984
|
* @param dataCode 需要转换的目标模型code
|
|
999
985
|
* @param state 值对象,以fieldCode为key组成的对象
|
|
1000
|
-
* */
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
// 对象类型的值
|
|
1017
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
1018
|
-
var oldState = _this.getEmptyState(controlId);
|
|
1019
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
1020
|
-
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1021
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
1022
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
1023
|
-
skipKeys.push(dataBind.fieldCode);
|
|
1024
|
-
var value = state[dataBind.fieldCode];
|
|
1025
|
-
if (value !== undefined) {
|
|
1026
|
-
result[key] = value;
|
|
986
|
+
* */ key: "buildFields",
|
|
987
|
+
value: function buildFields(dataCode, state) {
|
|
988
|
+
var _this = this;
|
|
989
|
+
var mapping = this.getDataBindMapping(dataCode);
|
|
990
|
+
if (!mapping) {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
var skipKeys = [];
|
|
994
|
+
var result1 = {};
|
|
995
|
+
mapping.fields.forEach(function(item) {
|
|
996
|
+
var dataBind4 = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
997
|
+
if (skipKeys.includes(fieldCode)) {
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
if (!Object.hasOwnProperty.call(state, fieldCode)) {
|
|
1001
|
+
return;
|
|
1027
1002
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1003
|
+
// 对象类型的值
|
|
1004
|
+
if (_instanceof(dataBind4, ObjectDataBind)) {
|
|
1005
|
+
var oldState = _this.getEmptyState(controlId);
|
|
1006
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
1007
|
+
result1[item.controlId] = Object.entries(dataBind4).reduce(function(result, param) {
|
|
1008
|
+
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
1009
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
1010
|
+
skipKeys.push(dataBind.fieldCode);
|
|
1011
|
+
var value = state[dataBind.fieldCode];
|
|
1012
|
+
if (value !== undefined) {
|
|
1013
|
+
result[key] = value;
|
|
1014
|
+
}
|
|
1015
|
+
return result;
|
|
1016
|
+
}, oldState);
|
|
1017
|
+
} else {
|
|
1018
|
+
result1[controlId] = state[fieldCode];
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
return result1;
|
|
1032
1022
|
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
/**
|
|
1037
1026
|
* 向Store设置一组值,并触发事件携带options
|
|
1038
1027
|
* @param dataSet
|
|
1039
1028
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1040
|
-
*/
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
return false;
|
|
1048
|
-
};
|
|
1049
|
-
var newState = {};
|
|
1050
|
-
Object.keys(dataSet).map(function(dataCode) {
|
|
1051
|
-
var entity = dataSet[dataCode];
|
|
1052
|
-
if (Array.isArray(entity)) {
|
|
1053
|
-
entity.map(function(row) {
|
|
1054
|
-
var mapping = _this.getDataBindMapping(dataCode);
|
|
1055
|
-
if (!mapping) {
|
|
1056
|
-
return;
|
|
1029
|
+
*/ key: "setData",
|
|
1030
|
+
value: function setData(dataSet, options) {
|
|
1031
|
+
var _this6 = this;
|
|
1032
|
+
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1033
|
+
var isEmpty = function(value) {
|
|
1034
|
+
if (isString(value) || Array.isArray(value)) {
|
|
1035
|
+
return value.length === 0;
|
|
1057
1036
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1037
|
+
return false;
|
|
1038
|
+
};
|
|
1039
|
+
var newState = {};
|
|
1040
|
+
Object.keys(dataSet).map(function(dataCode) {
|
|
1041
|
+
var entity = dataSet[dataCode];
|
|
1042
|
+
if (Array.isArray(entity)) {
|
|
1043
|
+
var _this4 = _this6;
|
|
1044
|
+
entity.map(function(row) {
|
|
1045
|
+
var _this = _this4;
|
|
1046
|
+
var mapping = _this4.getDataBindMapping(dataCode);
|
|
1047
|
+
if (!mapping) {
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1051
|
+
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1052
|
+
;
|
|
1053
|
+
Object.keys(row).map(function(fieldCode) {
|
|
1054
|
+
var ref, ref19;
|
|
1055
|
+
if (skipKey.includes(fieldCode)) {
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
var fieldMapping = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (ref19 = ref.fields) === null || ref19 === void 0 ? void 0 : ref19.find(function(i) {
|
|
1059
|
+
return i.fieldCode === fieldCode;
|
|
1081
1060
|
});
|
|
1082
|
-
|
|
1061
|
+
if (fieldMapping) {
|
|
1062
|
+
if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
|
|
1063
|
+
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1064
|
+
} else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
|
|
1065
|
+
var ref20;
|
|
1066
|
+
var objValue = JSONCopy((ref20 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref20 !== void 0 ? ref20 : {});
|
|
1067
|
+
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1068
|
+
var dataBind = fieldMapping.dataBind[key];
|
|
1069
|
+
if (row[dataBind.fieldCode] !== undefined) {
|
|
1070
|
+
objValue[key] = row[dataBind.fieldCode];
|
|
1071
|
+
}
|
|
1072
|
+
skipKey.push(dataBind.fieldCode);
|
|
1073
|
+
});
|
|
1074
|
+
newRow[fieldMapping.controlId] = objValue;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
if (!newState[mapping.dataViewId]) {
|
|
1079
|
+
newState[mapping.dataViewId] = {};
|
|
1083
1080
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1081
|
+
if (!newState[mapping.dataViewId][mapping.controlId]) {
|
|
1082
|
+
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1083
|
+
}
|
|
1084
|
+
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1085
|
+
});
|
|
1086
|
+
} else if (entity) {
|
|
1087
|
+
var _this3 = _this6;
|
|
1088
|
+
var skipKey1 = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1089
|
+
;
|
|
1090
|
+
var emptyState = JSONCopy(_this6.store.emptyState);
|
|
1091
|
+
Object.keys(entity).map(function(fieldCode) {
|
|
1092
|
+
if (skipKey1.includes(fieldCode)) {
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
var mapping = _this3.getDataBindMapping(dataCode, fieldCode);
|
|
1096
|
+
if (mapping) {
|
|
1097
|
+
if (!newState[mapping.dataViewId[0]]) {
|
|
1098
|
+
newState[mapping.dataViewId[0]] = {};
|
|
1099
|
+
}
|
|
1100
|
+
if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
|
|
1101
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1102
|
+
} else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
|
|
1103
|
+
var ref;
|
|
1104
|
+
var objValue = (ref = _this3.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
|
|
1105
|
+
Object.keys(mapping.dataBind).map(function(key) {
|
|
1106
|
+
var dataBind = mapping.dataBind[key];
|
|
1107
|
+
if (entity[dataBind.fieldCode] !== undefined) {
|
|
1108
|
+
objValue[key] = entity[dataBind.fieldCode];
|
|
1109
|
+
}
|
|
1110
|
+
skipKey1.push(dataBind.fieldCode);
|
|
1111
|
+
});
|
|
1112
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
var newMapping = _this6.getDataBindMapping(dataCode);
|
|
1117
|
+
if (newMapping) {
|
|
1118
|
+
var ref21;
|
|
1119
|
+
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (ref21 = newMapping.fields) === null || ref21 === void 0 ? void 0 : ref21.map(function(item) {
|
|
1120
|
+
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1121
|
+
});
|
|
1122
|
+
var mappingValue = _this6.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1123
|
+
var ref18;
|
|
1124
|
+
var mainStateKeys = Object.keys((ref18 = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && ref18 !== void 0 ? ref18 : {});
|
|
1125
|
+
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1126
|
+
if (!mainStateKeys.includes(key) && key !== 'uid') {
|
|
1127
|
+
if (Object.keys(newState).length && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1128
|
+
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
|
|
1129
|
+
} else {
|
|
1130
|
+
Object.assign(newState, _defineProperty({}, newMapping.controlId, _defineProperty({}, key, mappingValue[key])));
|
|
1131
|
+
}
|
|
1116
1132
|
}
|
|
1117
|
-
skipKey.push(dataBind.fieldCode);
|
|
1118
1133
|
});
|
|
1119
|
-
|
|
1134
|
+
_this6.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1120
1135
|
}
|
|
1121
1136
|
}
|
|
1122
1137
|
});
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
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) {
|
|
1127
|
-
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1128
|
-
});
|
|
1129
|
-
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1130
|
-
var _newState_newMapping_controlId;
|
|
1131
|
-
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 : {});
|
|
1132
|
-
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1133
|
-
if (!mainStateKeys.includes(key) && key !== "uid") {
|
|
1134
|
-
if (Object.keys(newState).length && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1135
|
-
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
|
|
1136
|
-
} else {
|
|
1137
|
-
Object.assign(newState, _defineProperty({}, newMapping.controlId, _defineProperty({}, key, mappingValue[key])));
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
});
|
|
1141
|
-
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1142
|
-
}
|
|
1138
|
+
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1139
|
+
this.setStates(newState, undefined, options);
|
|
1140
|
+
this.debugLog("engine setData方法执行完成。");
|
|
1143
1141
|
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
this.debugLog("engine setData方法执行完成。");
|
|
1148
|
-
};
|
|
1149
|
-
/**
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
/**
|
|
1150
1145
|
* 获取控件的dataBind
|
|
1151
1146
|
* @param controlId
|
|
1152
|
-
* */
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1147
|
+
* */ key: "getDataBind",
|
|
1148
|
+
value: function getDataBind(controlId) {
|
|
1149
|
+
return this.store.getDataBind(controlId);
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
/**
|
|
1156
1154
|
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1157
1155
|
* @param controlId
|
|
1158
1156
|
* @param rowIndex
|
|
1159
|
-
*/
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1157
|
+
*/ key: "getInstance",
|
|
1158
|
+
value: function getInstance(controlId, rowIndex) {
|
|
1159
|
+
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
1160
|
+
if (instances.length > 0) {
|
|
1161
|
+
if (rowIndex !== undefined) {
|
|
1162
|
+
if (rowIndex === -1) {
|
|
1163
|
+
return instances[0];
|
|
1164
|
+
}
|
|
1165
|
+
return instances[rowIndex];
|
|
1166
|
+
} else {
|
|
1167
|
+
return instances[0];
|
|
1168
|
+
}
|
|
1169
|
+
} else {
|
|
1170
|
+
return undefined;
|
|
1165
1171
|
}
|
|
1166
|
-
return instances[rowIndex];
|
|
1167
|
-
} else {
|
|
1168
|
-
return instances[0];
|
|
1169
1172
|
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
};
|
|
1174
|
-
/**
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
/**
|
|
1175
1176
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1176
1177
|
* @param controlId
|
|
1177
1178
|
* @param header 明细表内是否获取表头的控件
|
|
1178
|
-
*/
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
var instances = Array.from(this.runtime.instanceMap[controlId] || []);
|
|
1188
|
-
if (header) {
|
|
1189
|
-
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1190
|
-
if (instances.length) {
|
|
1191
|
-
var instance = instances[0];
|
|
1192
|
-
if (this.inList(instance.id) === true) {
|
|
1193
|
-
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1194
|
-
if (headerInstance) {
|
|
1195
|
-
instances.unshift(headerInstance);
|
|
1196
|
-
}
|
|
1179
|
+
*/ key: "getInstances",
|
|
1180
|
+
value: function getInstances(controlId) {
|
|
1181
|
+
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1182
|
+
// const cc = console
|
|
1183
|
+
// const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
|
|
1184
|
+
// cc.time(label)
|
|
1185
|
+
if (controlId === undefined) {
|
|
1186
|
+
// cc.timeEnd(label)
|
|
1187
|
+
return this.runtime.flatInstances;
|
|
1197
1188
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1189
|
+
var instances = Array.from(this.runtime.instanceMap[controlId] || []);
|
|
1190
|
+
if (header) {
|
|
1191
|
+
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1192
|
+
if (instances.length) {
|
|
1193
|
+
var instance = instances[0];
|
|
1194
|
+
if (this.inList(instance.id) === true) {
|
|
1195
|
+
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1196
|
+
if (headerInstance) {
|
|
1197
|
+
instances.unshift(headerInstance);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
} else {
|
|
1201
|
+
var controlIdMapping = this.getControlIdMapping();
|
|
1202
|
+
var ref;
|
|
1203
|
+
var ref22 = _slicedToArray((ref = Object.entries(controlIdMapping).find(function(param) {
|
|
1204
|
+
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1205
|
+
return mapping.children && controlId in mapping.children;
|
|
1206
|
+
})) !== null && ref !== void 0 ? ref : [], 1), subtableId = ref22[0];
|
|
1207
|
+
if (subtableId) {
|
|
1208
|
+
var subtable = this.getInstance(subtableId);
|
|
1209
|
+
// @ts-ignore
|
|
1210
|
+
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1211
|
+
return column.children.find(function(item) {
|
|
1212
|
+
return item.id === controlId;
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
if (headerColumn) {
|
|
1216
|
+
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1217
|
+
return item.id === controlId;
|
|
1218
|
+
});
|
|
1219
|
+
if (headerInstance1) {
|
|
1220
|
+
instances.unshift(headerInstance1);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1219
1223
|
}
|
|
1220
1224
|
}
|
|
1221
1225
|
}
|
|
1226
|
+
// @ts-ignore
|
|
1227
|
+
return instances;
|
|
1222
1228
|
}
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
key: "setInstance",
|
|
1232
|
+
value: function setInstance(instance, props, value, rowIndex) {
|
|
1233
|
+
try {
|
|
1234
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1235
|
+
var _this = this;
|
|
1236
|
+
//修改明细表整列属性的逻辑
|
|
1237
|
+
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1238
|
+
instances.map(function(_instance) {
|
|
1239
|
+
if (_instance) {
|
|
1240
|
+
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1241
|
+
updateValueFromKeys(_instance.props, props, value);
|
|
1242
|
+
_this.schemaEvent('schema-change', {
|
|
1243
|
+
instance: _instance,
|
|
1244
|
+
props: props,
|
|
1245
|
+
value: value,
|
|
1246
|
+
rowIndex: rowIndex
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
} else {
|
|
1251
|
+
var _instance1;
|
|
1252
|
+
if (typeof instance === 'string') {
|
|
1253
|
+
_instance1 = this.getInstance(instance, rowIndex);
|
|
1254
|
+
} else {
|
|
1255
|
+
_instance1 = instance;
|
|
1256
|
+
}
|
|
1257
|
+
if (!_instance1) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance1.id, _instance1, props, value);
|
|
1261
|
+
updateValueFromKeys(_instance1.props, props, value);
|
|
1262
|
+
this.schemaEvent('schema-change', {
|
|
1263
|
+
instance: _instance1,
|
|
1239
1264
|
props: props,
|
|
1240
1265
|
value: value,
|
|
1241
1266
|
rowIndex: rowIndex
|
|
1242
1267
|
});
|
|
1243
1268
|
}
|
|
1244
|
-
})
|
|
1245
|
-
|
|
1246
|
-
var _instance;
|
|
1247
|
-
if (typeof instance === "string") {
|
|
1248
|
-
_instance = this.getInstance(instance, rowIndex);
|
|
1249
|
-
} else {
|
|
1250
|
-
_instance = instance;
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
throw e;
|
|
1251
1271
|
}
|
|
1252
|
-
|
|
1272
|
+
}
|
|
1273
|
+
},
|
|
1274
|
+
{
|
|
1275
|
+
key: "getControlIdMapping",
|
|
1276
|
+
value: function getControlIdMapping() {
|
|
1277
|
+
return this.store.controlIdMapping;
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
key: "getDataBindMapping",
|
|
1282
|
+
value: function getDataBindMapping(dataCode, fieldCode) {
|
|
1283
|
+
if (!dataCode && !fieldCode) {
|
|
1284
|
+
return this.store.dataBindMapping;
|
|
1285
|
+
}
|
|
1286
|
+
var mapping = this.store.dataBindMapping[dataCode];
|
|
1287
|
+
if (!mapping) {
|
|
1288
|
+
warn("No corresponding dataCode=".concat(dataCode, " was found"));
|
|
1253
1289
|
return;
|
|
1254
1290
|
}
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
value: value,
|
|
1261
|
-
rowIndex: rowIndex
|
|
1291
|
+
if (!fieldCode) {
|
|
1292
|
+
return mapping;
|
|
1293
|
+
}
|
|
1294
|
+
var dataBindMapping = mapping.fields.find(function(item) {
|
|
1295
|
+
return item.fieldCode === fieldCode;
|
|
1262
1296
|
});
|
|
1297
|
+
if (!dataBindMapping) {
|
|
1298
|
+
warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
return dataBindMapping;
|
|
1263
1302
|
}
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
if (!dataBindMapping) {
|
|
1287
|
-
warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
|
|
1288
|
-
return;
|
|
1289
|
-
}
|
|
1290
|
-
return dataBindMapping;
|
|
1291
|
-
};
|
|
1292
|
-
_proto.getAction = function getAction() {
|
|
1293
|
-
return this.actionManager;
|
|
1294
|
-
};
|
|
1295
|
-
_proto.initDataManager = function initDataManager(callbackExecuter) {
|
|
1296
|
-
this.dataManager = new DataManager(callbackExecuter);
|
|
1297
|
-
};
|
|
1298
|
-
_proto.getDataManager = function getDataManager() {
|
|
1299
|
-
return this.dataManager;
|
|
1300
|
-
};
|
|
1301
|
-
/**
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
key: "getAction",
|
|
1306
|
+
value: function getAction() {
|
|
1307
|
+
return this.actionManager;
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
key: "initDataManager",
|
|
1312
|
+
value: function initDataManager(callbackExecuter) {
|
|
1313
|
+
this.dataManager = new DataManager(callbackExecuter);
|
|
1314
|
+
}
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
key: "getDataManager",
|
|
1318
|
+
value: function getDataManager() {
|
|
1319
|
+
return this.dataManager;
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
key: "assertInstance",
|
|
1324
|
+
value: /**
|
|
1302
1325
|
* 判断控件的类型,返回当前控件的正确类型
|
|
1303
|
-
* */
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1326
|
+
* */ function assertInstance(instance, types) {
|
|
1327
|
+
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
key: "getInstanceRowIndex",
|
|
1332
|
+
value: /**
|
|
1307
1333
|
* 获取控件在明细子表中的行下标,
|
|
1308
1334
|
* 如果控件在表头内,则返回-1
|
|
1309
1335
|
* 如果控件在表内,则返回行下标
|
|
1310
1336
|
* 如果控件不在明细表内,则返回undefined
|
|
1311
|
-
* */
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
// @ts-ignore
|
|
1317
|
-
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1318
|
-
// 表头内的控件
|
|
1319
|
-
// @ts-ignore
|
|
1320
|
-
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1321
|
-
rowIndex = -1;
|
|
1322
|
-
} else {
|
|
1337
|
+
* */ function getInstanceRowIndex(instance) {
|
|
1338
|
+
if (!instance.parent) {
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
var rowIndex;
|
|
1323
1342
|
// @ts-ignore
|
|
1324
|
-
|
|
1325
|
-
|
|
1343
|
+
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1344
|
+
// 表头内的控件
|
|
1345
|
+
// @ts-ignore
|
|
1346
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1347
|
+
rowIndex = -1;
|
|
1348
|
+
} else {
|
|
1349
|
+
// @ts-ignore
|
|
1350
|
+
var index = instance.parent.children.findIndex(function(item) {
|
|
1351
|
+
return item === instance;
|
|
1352
|
+
});
|
|
1353
|
+
if (index > -1) {
|
|
1354
|
+
rowIndex = index;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
} else {
|
|
1358
|
+
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1359
|
+
}
|
|
1360
|
+
return rowIndex;
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
key: "getInstanceParentControl",
|
|
1365
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1366
|
+
if (!instance.parent) {
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
if (this.assertInstance(instance.parent, controlType)) {
|
|
1370
|
+
return instance.parent;
|
|
1371
|
+
}
|
|
1372
|
+
return this.getInstanceParentControl(instance.parent, controlType);
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
key: "getInstanceInSubtableHeader",
|
|
1377
|
+
value: function getInstanceInSubtableHeader(instance) {
|
|
1378
|
+
var rowIndex = this.getInstanceRowIndex(instance);
|
|
1379
|
+
if (rowIndex === undefined) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
if (rowIndex === -1) {
|
|
1383
|
+
return instance;
|
|
1384
|
+
}
|
|
1385
|
+
var columnInstance = this.assertInstance(instance, // @ts-ignore
|
|
1386
|
+
CONTROL_TYPE.SUBTABLE_COLUMN) ? instance : this.getInstanceParentControl(instance, // @ts-ignore
|
|
1387
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1388
|
+
if (!columnInstance) {
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
var subtable = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1392
|
+
CONTROL_TYPE.SUBTABLE);
|
|
1393
|
+
// @ts-ignore
|
|
1394
|
+
var headerColumn = subtable.props.headers.find(// @ts-ignore
|
|
1395
|
+
function(column) {
|
|
1396
|
+
return column.id === columnInstance.id;
|
|
1326
1397
|
});
|
|
1327
|
-
if (
|
|
1328
|
-
|
|
1398
|
+
if (!headerColumn) {
|
|
1399
|
+
return;
|
|
1329
1400
|
}
|
|
1401
|
+
return headerColumn.children.find(// @ts-ignore
|
|
1402
|
+
function(item) {
|
|
1403
|
+
return item.id === instance.id;
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
key: "setControlConfig",
|
|
1409
|
+
value: function setControlConfig() {
|
|
1410
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1411
|
+
args[_key] = arguments[_key];
|
|
1412
|
+
}
|
|
1413
|
+
var _runtime;
|
|
1414
|
+
return (_runtime = this.runtime).registerControlConfig.apply(_runtime, _toConsumableArray(args));
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
key: "getControlConfig",
|
|
1419
|
+
value: function getControlConfig(control) {
|
|
1420
|
+
return this.runtime.getControlConfig(control);
|
|
1421
|
+
}
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
key: "inList",
|
|
1425
|
+
value: function inList(controlId) {
|
|
1426
|
+
var mapping = this.store.controlIdMapping;
|
|
1427
|
+
var result = Object.keys(mapping).some(function(key) {
|
|
1428
|
+
var ref, ref23;
|
|
1429
|
+
return (ref = mapping[key]) === null || ref === void 0 ? void 0 : (ref23 = ref.children) === null || ref23 === void 0 ? void 0 : ref23.hasOwnProperty(controlId);
|
|
1430
|
+
});
|
|
1431
|
+
return result;
|
|
1330
1432
|
}
|
|
1331
|
-
} else {
|
|
1332
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1333
|
-
}
|
|
1334
|
-
return rowIndex;
|
|
1335
|
-
};
|
|
1336
|
-
_proto.getInstanceParentControl = function getInstanceParentControl(instance, controlType) {
|
|
1337
|
-
if (!instance.parent) {
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
if (this.assertInstance(instance.parent, controlType)) {
|
|
1341
|
-
return instance.parent;
|
|
1342
|
-
}
|
|
1343
|
-
return this.getInstanceParentControl(instance.parent, controlType);
|
|
1344
|
-
};
|
|
1345
|
-
_proto.getInstanceInSubtableHeader = function getInstanceInSubtableHeader(instance) {
|
|
1346
|
-
var rowIndex = this.getInstanceRowIndex(instance);
|
|
1347
|
-
if (rowIndex === undefined) {
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
if (rowIndex === -1) {
|
|
1351
|
-
return instance;
|
|
1352
|
-
}
|
|
1353
|
-
var columnInstance = this.assertInstance(instance, // @ts-ignore
|
|
1354
|
-
CONTROL_TYPE.SUBTABLE_COLUMN) ? instance : this.getInstanceParentControl(instance, // @ts-ignore
|
|
1355
|
-
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1356
|
-
if (!columnInstance) {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
var subtable = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1360
|
-
CONTROL_TYPE.SUBTABLE);
|
|
1361
|
-
// @ts-ignore
|
|
1362
|
-
var headerColumn = subtable.props.headers.find(// @ts-ignore
|
|
1363
|
-
function(column) {
|
|
1364
|
-
return column.id === columnInstance.id;
|
|
1365
|
-
});
|
|
1366
|
-
if (!headerColumn) {
|
|
1367
|
-
return;
|
|
1368
|
-
}
|
|
1369
|
-
return headerColumn.children.find(// @ts-ignore
|
|
1370
|
-
function(item) {
|
|
1371
|
-
return item.id === instance.id;
|
|
1372
|
-
});
|
|
1373
|
-
};
|
|
1374
|
-
_proto.setControlConfig = function setControlConfig() {
|
|
1375
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1376
|
-
args[_key] = arguments[_key];
|
|
1377
1433
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
arg[_key] = arguments[_key];
|
|
1434
|
+
], [
|
|
1435
|
+
{
|
|
1436
|
+
key: "register",
|
|
1437
|
+
value: // 注册外部控件
|
|
1438
|
+
function register() {
|
|
1439
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1440
|
+
arg[_key] = arguments[_key];
|
|
1441
|
+
}
|
|
1442
|
+
var _Runtime;
|
|
1443
|
+
return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
|
|
1444
|
+
}
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
key: "judgeControlIsRegistered",
|
|
1448
|
+
value: function judgeControlIsRegistered(control) {
|
|
1449
|
+
return Runtime.staticRegisteredTypes.has(control.Runtime.controlType);
|
|
1450
|
+
}
|
|
1396
1451
|
}
|
|
1397
|
-
|
|
1398
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
|
|
1399
|
-
};
|
|
1400
|
-
Engine.judgeControlIsRegistered = function judgeControlIsRegistered(control) {
|
|
1401
|
-
return Runtime.staticRegisteredTypes.has(control.Runtime.controlType);
|
|
1402
|
-
};
|
|
1452
|
+
]);
|
|
1403
1453
|
return Engine;
|
|
1404
1454
|
}(Watcher);
|
|
1405
1455
|
export { Engine };
|
|
1406
|
-
console.log(
|
|
1456
|
+
console.log('a');
|