@byteluck-fe/model-driven-engine 2.2.7 → 2.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/common/ActionManager.js +114 -79
- package/dist/esm/common/DataManager.js +80 -39
- package/dist/esm/common/Engine.js +1106 -931
- package/dist/esm/common/OkWorker.js +121 -76
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +61 -44
- package/dist/esm/common/Store.js +145 -113
- package/dist/esm/common/checkerValue.js +367 -292
- package/dist/esm/common/proxyState.js +11 -11
- package/dist/esm/plugins/CalcPlugin.js +405 -317
- package/dist/esm/plugins/ControlsEventPlugin.js +174 -135
- package/dist/esm/plugins/ES6ModulePlugin.js +77 -43
- package/dist/esm/plugins/LifecycleEventPlugin.js +134 -98
- package/dist/esm/plugins/StylePlugin.js +48 -15
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (Array.isArray(arr)) return
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
13
|
if (self === void 0) {
|
|
14
14
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
15
|
}
|
|
@@ -29,7 +29,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
29
29
|
Promise.resolve(value).then(_next, _throw);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function _async_to_generator(fn) {
|
|
33
33
|
return function() {
|
|
34
34
|
var self = this, args = arguments;
|
|
35
35
|
return new Promise(function(resolve, reject) {
|
|
@@ -44,12 +44,26 @@ function _asyncToGenerator(fn) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function _class_call_check(instance, Constructor) {
|
|
48
48
|
if (!(instance instanceof Constructor)) {
|
|
49
49
|
throw new TypeError("Cannot call a class as a function");
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function
|
|
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 _create_class(Constructor, protoProps, staticProps) {
|
|
62
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
63
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
64
|
+
return Constructor;
|
|
65
|
+
}
|
|
66
|
+
function _define_property(obj, key, value) {
|
|
53
67
|
if (key in obj) {
|
|
54
68
|
Object.defineProperty(obj, key, {
|
|
55
69
|
value: value,
|
|
@@ -66,23 +80,23 @@ function _get(target, property, receiver) {
|
|
|
66
80
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
67
81
|
_get = Reflect.get;
|
|
68
82
|
} else {
|
|
69
|
-
_get = function
|
|
70
|
-
var base =
|
|
83
|
+
_get = function get(target, property, receiver) {
|
|
84
|
+
var base = _super_prop_base(target, property);
|
|
71
85
|
if (!base) return;
|
|
72
86
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
73
87
|
if (desc.get) {
|
|
74
|
-
return desc.get.call(receiver);
|
|
88
|
+
return desc.get.call(receiver || target);
|
|
75
89
|
}
|
|
76
90
|
return desc.value;
|
|
77
91
|
};
|
|
78
92
|
}
|
|
79
93
|
return _get(target, property, receiver || target);
|
|
80
94
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
95
|
+
function _get_prototype_of(o) {
|
|
96
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
83
97
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
84
98
|
};
|
|
85
|
-
return
|
|
99
|
+
return _get_prototype_of(o);
|
|
86
100
|
}
|
|
87
101
|
function _inherits(subClass, superClass) {
|
|
88
102
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -95,7 +109,7 @@ function _inherits(subClass, superClass) {
|
|
|
95
109
|
configurable: true
|
|
96
110
|
}
|
|
97
111
|
});
|
|
98
|
-
if (superClass)
|
|
112
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
99
113
|
}
|
|
100
114
|
function _instanceof(left, right) {
|
|
101
115
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
@@ -104,10 +118,10 @@ function _instanceof(left, right) {
|
|
|
104
118
|
return left instanceof right;
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
|
-
function
|
|
121
|
+
function _iterable_to_array(iter) {
|
|
108
122
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
109
123
|
}
|
|
110
|
-
function
|
|
124
|
+
function _iterable_to_array_limit(arr, i) {
|
|
111
125
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
112
126
|
if (_i == null) return;
|
|
113
127
|
var _arr = [];
|
|
@@ -131,13 +145,13 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
131
145
|
}
|
|
132
146
|
return _arr;
|
|
133
147
|
}
|
|
134
|
-
function
|
|
148
|
+
function _non_iterable_rest() {
|
|
135
149
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
136
150
|
}
|
|
137
|
-
function
|
|
151
|
+
function _non_iterable_spread() {
|
|
138
152
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
139
153
|
}
|
|
140
|
-
function
|
|
154
|
+
function _object_spread(target) {
|
|
141
155
|
for(var i = 1; i < arguments.length; i++){
|
|
142
156
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
143
157
|
var ownKeys = Object.keys(source);
|
|
@@ -147,7 +161,7 @@ function _objectSpread(target) {
|
|
|
147
161
|
}));
|
|
148
162
|
}
|
|
149
163
|
ownKeys.forEach(function(key) {
|
|
150
|
-
|
|
164
|
+
_define_property(target, key, source[key]);
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
return target;
|
|
@@ -165,7 +179,7 @@ function ownKeys(object, enumerableOnly) {
|
|
|
165
179
|
}
|
|
166
180
|
return keys;
|
|
167
181
|
}
|
|
168
|
-
function
|
|
182
|
+
function _object_spread_props(target, source) {
|
|
169
183
|
source = source != null ? source : {};
|
|
170
184
|
if (Object.getOwnPropertyDescriptors) {
|
|
171
185
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
@@ -176,45 +190,45 @@ function _objectSpreadProps(target, source) {
|
|
|
176
190
|
}
|
|
177
191
|
return target;
|
|
178
192
|
}
|
|
179
|
-
function
|
|
180
|
-
if (call && (
|
|
193
|
+
function _possible_constructor_return(self, call) {
|
|
194
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
181
195
|
return call;
|
|
182
196
|
}
|
|
183
|
-
return
|
|
197
|
+
return _assert_this_initialized(self);
|
|
184
198
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
199
|
+
function _set_prototype_of(o, p) {
|
|
200
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
187
201
|
o.__proto__ = p;
|
|
188
202
|
return o;
|
|
189
203
|
};
|
|
190
|
-
return
|
|
204
|
+
return _set_prototype_of(o, p);
|
|
191
205
|
}
|
|
192
|
-
function
|
|
193
|
-
return
|
|
206
|
+
function _sliced_to_array(arr, i) {
|
|
207
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
194
208
|
}
|
|
195
|
-
function
|
|
209
|
+
function _super_prop_base(object, property) {
|
|
196
210
|
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
197
|
-
object =
|
|
211
|
+
object = _get_prototype_of(object);
|
|
198
212
|
if (object === null) break;
|
|
199
213
|
}
|
|
200
214
|
return object;
|
|
201
215
|
}
|
|
202
|
-
function
|
|
203
|
-
return
|
|
216
|
+
function _to_consumable_array(arr) {
|
|
217
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
204
218
|
}
|
|
205
|
-
|
|
219
|
+
function _type_of(obj) {
|
|
206
220
|
"@swc/helpers - typeof";
|
|
207
221
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
208
|
-
}
|
|
209
|
-
function
|
|
222
|
+
}
|
|
223
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
210
224
|
if (!o) return;
|
|
211
|
-
if (typeof o === "string") return
|
|
225
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
212
226
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
213
227
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
214
228
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
215
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
229
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
216
230
|
}
|
|
217
|
-
function
|
|
231
|
+
function _is_native_reflect_construct() {
|
|
218
232
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
219
233
|
if (Reflect.construct.sham) return false;
|
|
220
234
|
if (typeof Proxy === "function") return true;
|
|
@@ -225,20 +239,20 @@ function _isNativeReflectConstruct() {
|
|
|
225
239
|
return false;
|
|
226
240
|
}
|
|
227
241
|
}
|
|
228
|
-
function
|
|
229
|
-
var hasNativeReflectConstruct =
|
|
242
|
+
function _create_super(Derived) {
|
|
243
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
230
244
|
return function _createSuperInternal() {
|
|
231
|
-
var Super =
|
|
245
|
+
var Super = _get_prototype_of(Derived), result;
|
|
232
246
|
if (hasNativeReflectConstruct) {
|
|
233
|
-
var NewTarget =
|
|
247
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
234
248
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
235
249
|
} else {
|
|
236
250
|
result = Super.apply(this, arguments);
|
|
237
251
|
}
|
|
238
|
-
return
|
|
252
|
+
return _possible_constructor_return(this, result);
|
|
239
253
|
};
|
|
240
254
|
}
|
|
241
|
-
|
|
255
|
+
function _ts_generator(thisArg, body) {
|
|
242
256
|
var f, y, t, g, _ = {
|
|
243
257
|
label: 0,
|
|
244
258
|
sent: function() {
|
|
@@ -332,7 +346,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
332
346
|
done: true
|
|
333
347
|
};
|
|
334
348
|
}
|
|
335
|
-
}
|
|
349
|
+
}
|
|
336
350
|
import { DataBind, ObjectDataBind, RuntimeListControl } from "@byteluck-fe/model-driven-core";
|
|
337
351
|
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
338
352
|
import { Runtime } from "./Runtime";
|
|
@@ -353,20 +367,29 @@ var applyingPluginName = "";
|
|
|
353
367
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
354
368
|
"use strict";
|
|
355
369
|
_inherits(Engine, Watcher);
|
|
356
|
-
var _super =
|
|
370
|
+
var _super = _create_super(Engine);
|
|
357
371
|
function Engine(props) {
|
|
358
|
-
|
|
372
|
+
_class_call_check(this, Engine);
|
|
359
373
|
var _this;
|
|
360
374
|
_this = _super.call(this);
|
|
361
|
-
_this
|
|
375
|
+
_define_property(_assert_this_initialized(_this), "store", void 0);
|
|
376
|
+
_define_property(_assert_this_initialized(_this), "rawStore", {});
|
|
377
|
+
_define_property(_assert_this_initialized(_this), "parent", void 0);
|
|
378
|
+
// 提供注册运行态控件以及实例化控件的能力
|
|
379
|
+
_define_property(_assert_this_initialized(_this), "runtime", void 0);
|
|
362
380
|
// 提供子线程处理脚本以及修改数据的能力
|
|
363
381
|
// public worker: OkWorker
|
|
364
|
-
_this
|
|
365
|
-
_this
|
|
366
|
-
_this
|
|
367
|
-
|
|
368
|
-
_this
|
|
369
|
-
_this
|
|
382
|
+
_define_property(_assert_this_initialized(_this), "isMounted", false);
|
|
383
|
+
_define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
|
|
384
|
+
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
385
|
+
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
386
|
+
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
387
|
+
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
388
|
+
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
389
|
+
_define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
|
|
390
|
+
_define_property(_assert_this_initialized(_this), "dataManager", void 0);
|
|
391
|
+
_define_property(_assert_this_initialized(_this), "_jobTasks", []);
|
|
392
|
+
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
370
393
|
_this.$options = Object.freeze(props);
|
|
371
394
|
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? true : _this_$options_autoMount, schema = _this_$options.schema, beforeCreateInstance = _this_$options.beforeCreateInstance, externalParams = _this_$options.externalParams, _this_$options_language = _this_$options.// fieldModel,
|
|
372
395
|
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug;
|
|
@@ -385,978 +408,1130 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
385
408
|
autoMount && _this.mount();
|
|
386
409
|
return _this;
|
|
387
410
|
}
|
|
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 [];
|
|
411
|
+
_create_class(Engine, [
|
|
412
|
+
{
|
|
413
|
+
key: "debugLog",
|
|
414
|
+
value: function debugLog() {
|
|
415
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
416
|
+
args[_key] = arguments[_key];
|
|
417
|
+
}
|
|
418
|
+
this.debug && log.apply(void 0, _to_consumable_array(args));
|
|
443
419
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (
|
|
449
|
-
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
key: "use",
|
|
423
|
+
value: function use(plugin) {
|
|
424
|
+
if (!this.__pluginsApplied) {
|
|
425
|
+
this.__plugins.push(plugin);
|
|
426
|
+
}
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
key: "registerControl",
|
|
432
|
+
value: // 注册外部控件
|
|
433
|
+
function registerControl() {
|
|
434
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
435
|
+
arg[_key] = arguments[_key];
|
|
436
|
+
}
|
|
437
|
+
var _this_runtime;
|
|
438
|
+
(_this_runtime = this.runtime).register.apply(_this_runtime, _to_consumable_array(arg));
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
key: "mount",
|
|
444
|
+
value: function mount() {
|
|
445
|
+
this.debugLog("engine的mount方法开始调用");
|
|
446
|
+
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
447
|
+
this._handlerProxyState();
|
|
448
|
+
this.__plugins = plugins;
|
|
449
|
+
this.applyPlugins();
|
|
450
|
+
// 触发所有控件的默认值的change事件
|
|
451
|
+
this.setStates(this.getState());
|
|
452
|
+
this.debugLog("engine的mount方法调用结束");
|
|
453
|
+
if (this.debug && typeof window !== "undefined") {
|
|
454
|
+
// @ts-ignore
|
|
455
|
+
window.engines[this.id] = this;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
key: "destroy",
|
|
461
|
+
value: function destroy() {
|
|
462
|
+
if (this.debug && typeof window !== "undefined") {
|
|
463
|
+
// @ts-ignore
|
|
464
|
+
delete window.engines[this.id];
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
key: "_handlerProxyState",
|
|
470
|
+
value: function _handlerProxyState() {
|
|
471
|
+
this.store.state = proxyState(this.store.state, this._proxyStateCallback.bind(this), this._proxyStateBeforeSetCallback.bind(this));
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
key: "_proxyStateBeforeSetCallback",
|
|
476
|
+
value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
|
|
477
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
478
|
+
// 找不到控件说明不是改动控件上的字段,直接通过
|
|
479
|
+
if (!instance) {
|
|
480
|
+
return newValue;
|
|
450
481
|
}
|
|
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
482
|
// @ts-ignore
|
|
486
|
-
|
|
487
|
-
|
|
483
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
484
|
+
if (newValue === null) {
|
|
485
|
+
return [];
|
|
486
|
+
}
|
|
487
|
+
// @ts-ignore
|
|
488
|
+
var fieldTypeMap = instance.props.headers.reduce(function(result, column) {
|
|
489
|
+
var formInstance = column.children[0];
|
|
490
|
+
// if (formInstance && formInstance instanceof RuntimeFormControl) {
|
|
491
|
+
if (formInstance && formInstance.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
492
|
+
result[formInstance.id] = formInstance.fieldType;
|
|
493
|
+
}
|
|
494
|
+
return result;
|
|
495
|
+
}, {});
|
|
496
|
+
// @ts-ignore
|
|
497
|
+
var emptyState = this.getEmptyState(instance.id);
|
|
498
|
+
return newValue.map(function(row) {
|
|
499
|
+
return(// @ts-ignore
|
|
500
|
+
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
var keys = key.split(".");
|
|
504
|
+
var lastKey = keys[keys.length - 1];
|
|
505
|
+
try {
|
|
506
|
+
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
507
|
+
} catch (e) {
|
|
508
|
+
warn("the id=".concat(instance.id, "'s instance setState error, %o ").concat(e, "."), newValue);
|
|
509
|
+
throw e;
|
|
510
|
+
}
|
|
488
511
|
}
|
|
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
|
-
var newValues = args.slice(2);
|
|
515
|
-
createdNewRows = createRows(newRowLengths1);
|
|
516
|
-
createdNewRowsData = newValues;
|
|
517
|
-
// 从哪儿开始
|
|
518
|
-
var start = args[0];
|
|
519
|
-
// 替换几个
|
|
520
|
-
var replace = args[1];
|
|
521
|
-
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
522
|
-
start,
|
|
523
|
-
replace
|
|
524
|
-
].concat(_toConsumableArray(createdNewRows)));
|
|
525
|
-
this.runtime.getFlatInstances();
|
|
526
|
-
// newValues.forEach((item: any, index) => {
|
|
527
|
-
// let newIndex = start + index
|
|
528
|
-
// this.setStates(item, newIndex, options)
|
|
529
|
-
// })
|
|
530
|
-
} else {
|
|
531
|
-
var // @ts-ignore
|
|
532
|
-
_subtable_children2;
|
|
533
|
-
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
|
|
534
|
-
this.runtime.getFlatInstances();
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
key: "_proxyStateCallback",
|
|
515
|
+
value: function _proxyStateCallback(state, key, type, args, result) {
|
|
516
|
+
if (Array.isArray(state)) {
|
|
517
|
+
this._handlerArrayUpdate(state, key, type, args, result);
|
|
518
|
+
} else {
|
|
519
|
+
this._handlerObjectUpdate(state, key, type, args);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
key: "_handlerArrayUpdate",
|
|
525
|
+
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
526
|
+
var _this = this;
|
|
527
|
+
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
528
|
+
if (!_instanceof(subtable, RuntimeListControl)) return;
|
|
529
|
+
// 新增多行方法
|
|
530
|
+
var createRows = function(len) {
|
|
531
|
+
// @ts-ignore
|
|
532
|
+
var newRows = [];
|
|
533
|
+
for(var i = 0; i < len; i++){
|
|
534
|
+
// @ts-ignore
|
|
535
|
+
var row = _this.listControlCreateRow(subtable, "subtable-row");
|
|
536
|
+
row && newRows.push(row);
|
|
535
537
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
+
// @ts-ignore
|
|
539
|
+
return newRows;
|
|
540
|
+
};
|
|
541
|
+
var options = eventOptionsTemp;
|
|
542
|
+
// @ts-ignore
|
|
543
|
+
var createdNewRows = [];
|
|
544
|
+
var createdNewRowsData = [];
|
|
545
|
+
var deleted = [];
|
|
546
|
+
if (type && args) {
|
|
547
|
+
// const subtableOldLength = subtable.children.length
|
|
548
|
+
switch(type){
|
|
549
|
+
case "push":
|
|
550
|
+
case "unshift":
|
|
551
|
+
var _subtable_children;
|
|
552
|
+
var newRowLengths = args.length;
|
|
553
|
+
createdNewRows = createRows(newRowLengths);
|
|
554
|
+
createdNewRowsData = args;
|
|
555
|
+
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
556
|
+
this.runtime.getFlatInstances();
|
|
557
|
+
break;
|
|
558
|
+
case "splice":
|
|
559
|
+
if (args.length > 2) {
|
|
560
|
+
var // @ts-ignore
|
|
561
|
+
_subtable_children1;
|
|
562
|
+
var newRowLengths1 = args.length - 2;
|
|
563
|
+
var newValues = args.slice(2);
|
|
564
|
+
createdNewRows = createRows(newRowLengths1);
|
|
565
|
+
createdNewRowsData = newValues;
|
|
566
|
+
// 从哪儿开始
|
|
567
|
+
var start = args[0];
|
|
568
|
+
// 替换几个
|
|
569
|
+
var replace = args[1];
|
|
570
|
+
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
571
|
+
start,
|
|
572
|
+
replace
|
|
573
|
+
].concat(_to_consumable_array(createdNewRows)));
|
|
574
|
+
this.runtime.getFlatInstances();
|
|
575
|
+
// newValues.forEach((item: any, index) => {
|
|
576
|
+
// let newIndex = start + index
|
|
577
|
+
// this.setStates(item, newIndex, options)
|
|
578
|
+
// })
|
|
579
|
+
} else {
|
|
580
|
+
var // @ts-ignore
|
|
581
|
+
_subtable_children2;
|
|
582
|
+
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
|
|
583
|
+
this.runtime.getFlatInstances();
|
|
584
|
+
}
|
|
585
|
+
break;
|
|
586
|
+
default:
|
|
587
|
+
var // @ts-ignore
|
|
588
|
+
_subtable_children3;
|
|
589
|
+
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
|
|
590
|
+
this.runtime.getFlatInstances();
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
if (type === "splice") {
|
|
594
|
+
deleted = result;
|
|
595
|
+
} else if ([
|
|
596
|
+
"pop",
|
|
597
|
+
"shift"
|
|
598
|
+
].includes(type)) {
|
|
599
|
+
deleted = [
|
|
600
|
+
result
|
|
601
|
+
];
|
|
602
|
+
}
|
|
603
|
+
this.emit("list-change", {
|
|
604
|
+
instance: subtable,
|
|
605
|
+
value: this.getState(subtable.id),
|
|
606
|
+
options: Object.assign({}, options, {
|
|
607
|
+
changed: createdNewRows,
|
|
608
|
+
data: createdNewRowsData,
|
|
609
|
+
deleted: deleted !== null && deleted !== void 0 ? deleted : [],
|
|
610
|
+
jsonValue: JSON.stringify(this.getState(subtable.id))
|
|
611
|
+
})
|
|
612
|
+
});
|
|
613
|
+
// 主动清空本次任务中的options
|
|
614
|
+
eventOptionsTemp = null;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
key: "_handlerObjectUpdate",
|
|
620
|
+
value: function _handlerObjectUpdate(state, key, value, oldValue) {
|
|
621
|
+
var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
622
|
+
if (!instance) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
var index = this.getInstanceRowIndex(instance);
|
|
626
|
+
var options = eventOptionsTemp || {};
|
|
627
|
+
// if (instance instanceof RuntimeListControl) {
|
|
628
|
+
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
538
629
|
var // @ts-ignore
|
|
539
|
-
|
|
540
|
-
|
|
630
|
+
_instance_children;
|
|
631
|
+
instance.children.length = 0;
|
|
632
|
+
var newValue = value;
|
|
633
|
+
// @ts-ignore
|
|
634
|
+
var newRows = [];
|
|
635
|
+
for(var i = 0; i < newValue.length; i++){
|
|
636
|
+
// @ts-ignore
|
|
637
|
+
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
638
|
+
row && newRows.push(row);
|
|
639
|
+
}
|
|
640
|
+
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
541
641
|
this.runtime.getFlatInstances();
|
|
542
|
-
|
|
642
|
+
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
643
|
+
// for (let i = 0; i < newValue.length; i++) {
|
|
644
|
+
// this.setStates(newValue[i], i, options)
|
|
645
|
+
// }
|
|
646
|
+
this.emit("list-change", {
|
|
647
|
+
instance: instance,
|
|
648
|
+
value: value,
|
|
649
|
+
options: _object_spread_props(_object_spread({}, options), {
|
|
650
|
+
// @ts-ignore
|
|
651
|
+
changed: newRows,
|
|
652
|
+
data: newValue,
|
|
653
|
+
deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
|
|
654
|
+
})
|
|
655
|
+
});
|
|
656
|
+
} else {
|
|
657
|
+
this.emit("change", {
|
|
658
|
+
instance: instance,
|
|
659
|
+
value: this.getState(instance.id, index),
|
|
660
|
+
rowIndex: index,
|
|
661
|
+
options: _object_spread_props(_object_spread({}, options), {
|
|
662
|
+
oldValue: oldValue
|
|
663
|
+
})
|
|
664
|
+
});
|
|
665
|
+
}
|
|
543
666
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
key: "applyPlugins",
|
|
670
|
+
value: function applyPlugins() {
|
|
671
|
+
var _this = this;
|
|
672
|
+
if (this.__pluginsApplied) return;
|
|
673
|
+
this.__plugins.forEach(function(plugin) {
|
|
674
|
+
try {
|
|
675
|
+
var _plugin_pluginName;
|
|
676
|
+
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
677
|
+
plugin.apply(_this);
|
|
678
|
+
} catch (e) {
|
|
679
|
+
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
680
|
+
} finally{
|
|
681
|
+
applyingPluginName = "";
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
this.__pluginsApplied = true;
|
|
553
685
|
}
|
|
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++){
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
key: "listControlCreateRow",
|
|
689
|
+
value: function listControlCreateRow(instance, rowType) {
|
|
690
|
+
var row = this.runtime.createControlInstance(rowType);
|
|
691
|
+
if (!row) return;
|
|
692
|
+
// if (row instanceof RuntimeLayoutControl) {
|
|
584
693
|
// @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), {
|
|
694
|
+
if (row.controlType === CONTROL_BASE_TYPE.LAYOUT) {
|
|
695
|
+
var _inst_children;
|
|
696
|
+
var inst = row;
|
|
697
|
+
var template = JSONCopy(instance.props.headers);
|
|
598
698
|
// @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 = "";
|
|
699
|
+
var columns = this.createControl(template);
|
|
700
|
+
(_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
|
|
701
|
+
}
|
|
702
|
+
return row;
|
|
627
703
|
}
|
|
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
|
-
2
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
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);
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
key: "listControlAddRow",
|
|
707
|
+
value: function listControlAddRow(instance) {
|
|
708
|
+
var // @ts-ignore
|
|
709
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
|
|
710
|
+
var row = this.listControlCreateRow(instance, rowType);
|
|
711
|
+
if (!row) return;
|
|
712
|
+
instance.children.push(row);
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
key: "emit",
|
|
717
|
+
value: // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
|
|
718
|
+
function emit(eventKey, payload) {
|
|
719
|
+
var _this = this;
|
|
720
|
+
var _this1 = this, _superprop_get_emit = function() {
|
|
721
|
+
return _get(_get_prototype_of(Engine.prototype), "emit", _this);
|
|
722
|
+
};
|
|
723
|
+
return _async_to_generator(function() {
|
|
724
|
+
var needWait, promiseResolver, promise, results;
|
|
725
|
+
return _ts_generator(this, function(_state) {
|
|
726
|
+
switch(_state.label){
|
|
727
|
+
case 0:
|
|
728
|
+
if (!(eventKey === "engine-mounted")) return [
|
|
729
|
+
3,
|
|
730
|
+
3
|
|
731
|
+
];
|
|
732
|
+
if (_this1.isMounted) {
|
|
733
|
+
warn("The engine-mounted life cycle can only be triggered once");
|
|
734
|
+
return [
|
|
735
|
+
2,
|
|
736
|
+
Promise.resolve([])
|
|
737
|
+
];
|
|
738
|
+
}
|
|
739
|
+
if (!_this1._jobTasks.length) return [
|
|
740
|
+
3,
|
|
741
|
+
2
|
|
742
|
+
];
|
|
743
|
+
console.time("engine-mounted need wait");
|
|
744
|
+
needWait = _to_consumable_array(_this1._jobTasks);
|
|
745
|
+
return [
|
|
746
|
+
4,
|
|
747
|
+
Promise.all(needWait)
|
|
748
|
+
];
|
|
749
|
+
case 1:
|
|
750
|
+
_state.sent();
|
|
751
|
+
console.timeEnd("engine-mounted need wait");
|
|
752
|
+
_state.label = 2;
|
|
753
|
+
case 2:
|
|
754
|
+
_this1.isMounted = true;
|
|
755
|
+
_state.label = 3;
|
|
756
|
+
case 3:
|
|
757
|
+
// 如果没有挂载的话,需要记录在挂载之前触发的所有任务
|
|
758
|
+
if (!_this1.isMounted) {
|
|
759
|
+
promise = new Promise(function(resolve) {
|
|
760
|
+
promiseResolver = resolve;
|
|
761
|
+
});
|
|
762
|
+
_this1._jobTasks.push(promise);
|
|
763
|
+
}
|
|
764
|
+
return [
|
|
765
|
+
4,
|
|
766
|
+
_superprop_get_emit().call(_this1, eventKey, payload)
|
|
767
|
+
];
|
|
768
|
+
case 4:
|
|
769
|
+
results = _state.sent();
|
|
770
|
+
if (promiseResolver && promise) {
|
|
771
|
+
// 每一个任务完成的时候,都把自己从task中去掉
|
|
772
|
+
promiseResolver();
|
|
773
|
+
_this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
|
|
774
|
+
}
|
|
775
|
+
return [
|
|
776
|
+
2,
|
|
777
|
+
results
|
|
778
|
+
];
|
|
710
779
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
780
|
+
});
|
|
781
|
+
})();
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
key: "on",
|
|
786
|
+
value: function on(key, callback) {
|
|
787
|
+
if (applyingPluginName) {
|
|
788
|
+
callback.applyingPluginName = applyingPluginName;
|
|
715
789
|
}
|
|
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
|
-
|
|
790
|
+
return _get(_get_prototype_of(Engine.prototype), "on", this).call(this, key, callback);
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
key: "createControl",
|
|
795
|
+
value: function createControl() {
|
|
796
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
797
|
+
args[_key] = arguments[_key];
|
|
798
|
+
}
|
|
799
|
+
var _this_runtime;
|
|
800
|
+
return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _to_consumable_array(args));
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
key: "createInstance",
|
|
805
|
+
value: function createInstance(type, initSchema) {
|
|
806
|
+
return this.runtime.createControlInstance(type, initSchema);
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
key: "schemaEvent",
|
|
811
|
+
value: function schemaEvent(eventKey, payload) {
|
|
812
|
+
this.emit(eventKey, payload);
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
key: "updateInstanceProps",
|
|
817
|
+
value: function updateInstanceProps(instance, props, value, rowIndex) {
|
|
818
|
+
return this.setInstance(instance, props, value, rowIndex);
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
key: "getRules",
|
|
823
|
+
value: function getRules(controlId) {
|
|
824
|
+
if (controlId === undefined) {
|
|
825
|
+
return this.runtime.rules;
|
|
826
|
+
} else {
|
|
827
|
+
var _this_runtime_rules_controlId;
|
|
828
|
+
return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
key: "getAntdRules",
|
|
834
|
+
value: function getAntdRules(controlId) {
|
|
835
|
+
if (controlId === undefined) {
|
|
836
|
+
return this.runtime.antdRules;
|
|
837
|
+
} else {
|
|
838
|
+
var _this_runtime_antdRules_controlId;
|
|
839
|
+
return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
key: "getState",
|
|
845
|
+
value: function getState(controlId, rowIndex) {
|
|
846
|
+
if (controlId === undefined) {
|
|
847
|
+
return this.store.state;
|
|
848
|
+
} else {
|
|
849
|
+
return this.store.getState(controlId, rowIndex);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
key: "getEmptyState",
|
|
855
|
+
value: function getEmptyState(controlId) {
|
|
856
|
+
if (controlId === undefined) {
|
|
857
|
+
return JSONCopy(this.store.emptyState);
|
|
858
|
+
} else {
|
|
859
|
+
return JSONCopy(this.store.getEmptyState(controlId));
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
/**
|
|
772
865
|
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
773
866
|
* @param options 需要携带的options
|
|
774
|
-
* */
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
867
|
+
* */ key: "setPayloadOptions",
|
|
868
|
+
value: function setPayloadOptions(options) {
|
|
869
|
+
eventOptionsTemp = options;
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
key: "setState",
|
|
874
|
+
value: function setState(controlId, value, rowIndex, options) {
|
|
875
|
+
eventOptionsTemp = options;
|
|
876
|
+
this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
|
|
877
|
+
this.store.setState(controlId, value, rowIndex);
|
|
878
|
+
this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
|
|
879
|
+
eventOptionsTemp = null;
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
/**
|
|
785
884
|
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
786
885
|
* @param states
|
|
787
|
-
*/
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
886
|
+
*/ key: "setStates",
|
|
887
|
+
value: function setStates(states, rowIndex, options) {
|
|
888
|
+
var _this = this;
|
|
889
|
+
var newStates = states;
|
|
890
|
+
Object.keys(newStates).forEach(function(stateId) {
|
|
891
|
+
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
892
|
+
var _param = _sliced_to_array(param, 2), controlId = _param[0], controlIdMapping = _param[1];
|
|
893
|
+
if (controlIdMapping.dataView === stateId) {
|
|
894
|
+
// state对象是dataView包裹的
|
|
895
|
+
var value = newStates[stateId][controlId];
|
|
896
|
+
if (value !== undefined) {
|
|
897
|
+
_this.setState(controlId, value, rowIndex, options);
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
// state对象是单独的,没有被dataView包裹的
|
|
901
|
+
if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
|
|
902
|
+
if (newStates[stateId] !== undefined) {
|
|
903
|
+
_this.setState(stateId, newStates[stateId], rowIndex, options);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
804
906
|
}
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
907
|
+
});
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
/**
|
|
811
913
|
* 通过dataCode和fieldCode来获取控件的值
|
|
812
914
|
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
813
915
|
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
814
916
|
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
815
|
-
* */
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
var dataBindMapping1 = this.getDataBindMapping(dataCode, fieldCode);
|
|
825
|
-
if (!dataBindMapping1) {
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
829
|
-
var state = this.getState(controlId1, rowIndex);
|
|
830
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
831
|
-
return Object.entries(dataBind).reduce(function(result, param) {
|
|
832
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
833
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
834
|
-
if (dataBind.fieldCode === fieldCode) {
|
|
835
|
-
return result[key];
|
|
917
|
+
* */ key: "getField",
|
|
918
|
+
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
919
|
+
if (!fieldCode) {
|
|
920
|
+
var dataBindMapping = this.getDataBindMapping(dataCode);
|
|
921
|
+
if (dataBindMapping) {
|
|
922
|
+
var controlId = dataBindMapping.controlId;
|
|
923
|
+
return this.getState(controlId);
|
|
924
|
+
}
|
|
925
|
+
return;
|
|
836
926
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
var getFieldData = this.getField(dataCode);
|
|
850
|
-
// 明细子表值
|
|
851
|
-
if (Array.isArray(getFieldData)) {
|
|
852
|
-
var data = getFieldData.map(function(item) {
|
|
853
|
-
var obj = {};
|
|
854
|
-
for(var key in item){
|
|
855
|
-
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId1;
|
|
856
|
-
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) {
|
|
857
|
-
var _controlIdMapping_controlId_children_key1;
|
|
858
|
-
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];
|
|
859
|
-
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
860
|
-
// 兼容一个控件需要绑定多个字段的情况
|
|
861
|
-
for(var keyChi in item[key]){
|
|
862
|
-
var _controlIdMapping_controlId_children_key2, _controlIdMapping_controlId2;
|
|
863
|
-
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];
|
|
864
|
-
}
|
|
927
|
+
var dataBindMapping1 = this.getDataBindMapping(dataCode, fieldCode);
|
|
928
|
+
if (!dataBindMapping1) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
932
|
+
var state = this.getState(controlId1, rowIndex);
|
|
933
|
+
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
934
|
+
return Object.entries(dataBind).reduce(function(result, param) {
|
|
935
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
936
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
937
|
+
if (dataBind.fieldCode === fieldCode) {
|
|
938
|
+
return result[key];
|
|
865
939
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
940
|
+
return result;
|
|
941
|
+
}, state);
|
|
942
|
+
} else {
|
|
943
|
+
return state;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
key: "getData",
|
|
949
|
+
value: function getData(dataCode) {
|
|
950
|
+
if (!dataCode) return;
|
|
951
|
+
var dataBindMapping = this.getDataBindMapping(dataCode);
|
|
952
|
+
var controlIdMapping = this.getControlIdMapping();
|
|
953
|
+
if (dataBindMapping) {
|
|
954
|
+
var controlId = dataBindMapping.controlId;
|
|
955
|
+
var getFieldData = this.getField(dataCode);
|
|
956
|
+
// 明细子表值
|
|
957
|
+
if (Array.isArray(getFieldData)) {
|
|
958
|
+
var data = getFieldData.map(function(item) {
|
|
959
|
+
var obj = {};
|
|
960
|
+
for(var key in item){
|
|
961
|
+
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId1;
|
|
962
|
+
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) {
|
|
963
|
+
var _controlIdMapping_controlId_children_key1;
|
|
964
|
+
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];
|
|
965
|
+
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
966
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
967
|
+
for(var keyChi in item[key]){
|
|
968
|
+
var _controlIdMapping_controlId_children_key2, _controlIdMapping_controlId2;
|
|
969
|
+
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];
|
|
891
970
|
}
|
|
892
971
|
}
|
|
893
972
|
}
|
|
894
|
-
return
|
|
973
|
+
return obj;
|
|
895
974
|
});
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
var
|
|
900
|
-
|
|
901
|
-
|
|
975
|
+
return data;
|
|
976
|
+
} else {
|
|
977
|
+
var _loop = function(key) {
|
|
978
|
+
var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
|
|
979
|
+
if ((_controlIdMapping_key = controlIdMapping[key]) === null || _controlIdMapping_key === void 0 ? void 0 : (_controlIdMapping_key_dataBind = _controlIdMapping_key.dataBind) === null || _controlIdMapping_key_dataBind === void 0 ? void 0 : _controlIdMapping_key_dataBind.fieldCode) {
|
|
980
|
+
var _controlIdMapping_key2;
|
|
981
|
+
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
982
|
+
} else if ((_controlIdMapping_key1 = controlIdMapping[key]) === null || _controlIdMapping_key1 === void 0 ? void 0 : (_controlIdMapping_key_dataBind1 = _controlIdMapping_key1.dataBind) === null || _controlIdMapping_key_dataBind1 === void 0 ? void 0 : _controlIdMapping_key_dataBind1.dataCode) {
|
|
983
|
+
var _controlIdMapping_key3;
|
|
984
|
+
// 明细字表只循环一层明细子表未递归
|
|
985
|
+
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
|
|
986
|
+
var objChi = {};
|
|
987
|
+
for(var keyChi in item){
|
|
988
|
+
var _controlIdMapping_key_children_keyChi;
|
|
989
|
+
if ((_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode) {
|
|
990
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
991
|
+
objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind.fieldCode] = item[keyChi];
|
|
992
|
+
} else {
|
|
993
|
+
for(var keyChi1 in item[keyChi]){
|
|
994
|
+
var _controlIdMapping_key_children_keyChi2;
|
|
995
|
+
objChi[(_controlIdMapping_key_children_keyChi2 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi2 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi2.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
996
|
+
//
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return objChi;
|
|
1001
|
+
});
|
|
1002
|
+
} else if (controlIdMapping[key]) {
|
|
1003
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
1004
|
+
for(var keyChi in getFieldData[key]){
|
|
1005
|
+
var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
|
|
1006
|
+
obj[(_controlIdMapping_key_dataBind_keyChi = (_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
// 主表
|
|
1011
|
+
var obj = {};
|
|
1012
|
+
for(var key in getFieldData)_loop(key);
|
|
1013
|
+
return obj;
|
|
902
1014
|
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
var obj = {};
|
|
906
|
-
for(var key in getFieldData)_loop(key);
|
|
907
|
-
return obj;
|
|
1015
|
+
}
|
|
1016
|
+
return;
|
|
908
1017
|
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
/**
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
/**
|
|
913
1021
|
* 通过dataCode和fieldCode来设置控件的值
|
|
914
1022
|
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
915
1023
|
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
916
1024
|
* @param value 修改的值
|
|
917
1025
|
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
918
1026
|
* @param options 触发事件携带的参数
|
|
919
|
-
* */
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
925
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
926
|
-
var _JSONCopy;
|
|
927
|
-
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
928
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
929
|
-
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
930
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
931
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
932
|
-
if (dataBind.fieldCode === fieldCode) {
|
|
933
|
-
result[key] = value;
|
|
1027
|
+
* */ key: "setField",
|
|
1028
|
+
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
1029
|
+
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
1030
|
+
if (!dataBindMapping) {
|
|
1031
|
+
return;
|
|
934
1032
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1033
|
+
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
1034
|
+
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
1035
|
+
var _JSONCopy;
|
|
1036
|
+
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
1037
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
1038
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
1039
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1040
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
1041
|
+
if (dataBind.fieldCode === fieldCode) {
|
|
1042
|
+
result[key] = value;
|
|
1043
|
+
}
|
|
1044
|
+
return result;
|
|
1045
|
+
}, oldState);
|
|
1046
|
+
this.setState(controlId, newState, rowIndex, options);
|
|
1047
|
+
} else {
|
|
1048
|
+
this.setState(controlId, value, rowIndex, options);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
/**
|
|
943
1054
|
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
944
1055
|
* @param dataCode 需要赋值的目标模型
|
|
945
1056
|
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
946
1057
|
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
947
1058
|
* @param options 触发事件携带的参数
|
|
948
|
-
* */
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
// 对象类型的值
|
|
964
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
965
|
-
var _JSONCopy;
|
|
966
|
-
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
967
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
968
|
-
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
969
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
970
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
971
|
-
skipKeys.push(dataBind.fieldCode);
|
|
972
|
-
var value = state[dataBind.fieldCode];
|
|
973
|
-
if (value !== undefined) {
|
|
974
|
-
result[key] = value;
|
|
1059
|
+
* */ key: "setFields",
|
|
1060
|
+
value: function setFields(dataCode, state, rowIndex, options) {
|
|
1061
|
+
var _this = this;
|
|
1062
|
+
var mapping = this.getDataBindMapping(dataCode);
|
|
1063
|
+
if (!mapping) {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
var skipKeys = [];
|
|
1067
|
+
mapping.fields.forEach(function(item) {
|
|
1068
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
1069
|
+
if (skipKeys.includes(fieldCode)) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (!Object.hasOwnProperty.call(state, fieldCode)) {
|
|
1073
|
+
return;
|
|
975
1074
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1075
|
+
// 对象类型的值
|
|
1076
|
+
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
1077
|
+
var _JSONCopy;
|
|
1078
|
+
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
1079
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
1080
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
1081
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1082
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
1083
|
+
skipKeys.push(dataBind.fieldCode);
|
|
1084
|
+
var value = state[dataBind.fieldCode];
|
|
1085
|
+
if (value !== undefined) {
|
|
1086
|
+
result[key] = value;
|
|
1087
|
+
}
|
|
1088
|
+
return result;
|
|
1089
|
+
}, oldState);
|
|
1090
|
+
_this.setState(item.controlId, newState, rowIndex, options);
|
|
1091
|
+
} else {
|
|
1092
|
+
_this.setState(controlId, state[fieldCode], rowIndex, options);
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
981
1095
|
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
/**
|
|
985
1099
|
* 通过dataCode来将state转化为标准的state结构
|
|
986
1100
|
* @param dataCode 需要转换的目标模型code
|
|
987
1101
|
* @param state 值对象,以fieldCode为key组成的对象
|
|
988
|
-
* */
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
if (!Object.hasOwnProperty.call(state, fieldCode)) {
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
// 对象类型的值
|
|
1005
|
-
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
1006
|
-
var oldState = _this.getEmptyState(controlId);
|
|
1007
|
-
// fieldCode不代表是key,所以需要找到对应的key
|
|
1008
|
-
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1009
|
-
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
1010
|
-
// objectDataBind的元素,跳过下一次赋值
|
|
1011
|
-
skipKeys.push(dataBind.fieldCode);
|
|
1012
|
-
var value = state[dataBind.fieldCode];
|
|
1013
|
-
if (value !== undefined) {
|
|
1014
|
-
result[key] = value;
|
|
1102
|
+
* */ key: "buildFields",
|
|
1103
|
+
value: function buildFields(dataCode, state) {
|
|
1104
|
+
var _this = this;
|
|
1105
|
+
var mapping = this.getDataBindMapping(dataCode);
|
|
1106
|
+
if (!mapping) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
var skipKeys = [];
|
|
1110
|
+
var result = {};
|
|
1111
|
+
mapping.fields.forEach(function(item) {
|
|
1112
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
1113
|
+
if (skipKeys.includes(fieldCode)) {
|
|
1114
|
+
return;
|
|
1015
1115
|
}
|
|
1016
|
-
|
|
1017
|
-
}, oldState);
|
|
1018
|
-
} else {
|
|
1019
|
-
result[controlId] = state[fieldCode];
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
return result;
|
|
1023
|
-
};
|
|
1024
|
-
/**
|
|
1025
|
-
* 向Store设置一组值,并触发事件携带options
|
|
1026
|
-
* @param dataSet
|
|
1027
|
-
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1028
|
-
*/ _proto.setData = function setData(dataSet, options) {
|
|
1029
|
-
var _this = this;
|
|
1030
|
-
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1031
|
-
var newState = {};
|
|
1032
|
-
Object.keys(dataSet).map(function(dataCode) {
|
|
1033
|
-
var entity = dataSet[dataCode];
|
|
1034
|
-
if (Array.isArray(entity)) {
|
|
1035
|
-
entity.map(function(row) {
|
|
1036
|
-
var mapping = _this.getDataBindMapping(dataCode);
|
|
1037
|
-
if (!mapping) {
|
|
1116
|
+
if (!Object.hasOwnProperty.call(state, fieldCode)) {
|
|
1038
1117
|
return;
|
|
1039
1118
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
if (fieldMapping) {
|
|
1052
|
-
if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
|
|
1053
|
-
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1054
|
-
} else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
|
|
1055
|
-
var _this_getEmptyState;
|
|
1056
|
-
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1057
|
-
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1058
|
-
var dataBind = fieldMapping.dataBind[key];
|
|
1059
|
-
if (row[dataBind.fieldCode] !== undefined) {
|
|
1060
|
-
objValue[key] = row[dataBind.fieldCode];
|
|
1061
|
-
}
|
|
1062
|
-
skipKey.push(dataBind.fieldCode);
|
|
1063
|
-
});
|
|
1064
|
-
newRow[fieldMapping.controlId] = objValue;
|
|
1119
|
+
// 对象类型的值
|
|
1120
|
+
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
1121
|
+
var oldState = _this.getEmptyState(controlId);
|
|
1122
|
+
// fieldCode不代表是key,所以需要找到对应的key
|
|
1123
|
+
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1124
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
|
|
1125
|
+
// objectDataBind的元素,跳过下一次赋值
|
|
1126
|
+
skipKeys.push(dataBind.fieldCode);
|
|
1127
|
+
var value = state[dataBind.fieldCode];
|
|
1128
|
+
if (value !== undefined) {
|
|
1129
|
+
result[key] = value;
|
|
1065
1130
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
if (!newState[mapping.dataViewId][mapping.controlId]) {
|
|
1072
|
-
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1131
|
+
return result;
|
|
1132
|
+
}, oldState);
|
|
1133
|
+
} else {
|
|
1134
|
+
result[controlId] = state[fieldCode];
|
|
1073
1135
|
}
|
|
1074
|
-
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1075
1136
|
});
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1137
|
+
return result;
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
/**
|
|
1142
|
+
* 向Store设置一组值,并触发事件携带options
|
|
1143
|
+
* @param dataSet
|
|
1144
|
+
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1145
|
+
*/ key: "setData",
|
|
1146
|
+
value: function setData(dataSet, options) {
|
|
1147
|
+
var _this = this;
|
|
1148
|
+
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1149
|
+
var newState = {};
|
|
1150
|
+
Object.keys(dataSet).map(function(dataCode) {
|
|
1151
|
+
var entity = dataSet[dataCode];
|
|
1152
|
+
if (Array.isArray(entity)) {
|
|
1153
|
+
entity.map(function(row) {
|
|
1154
|
+
var mapping = _this.getDataBindMapping(dataCode);
|
|
1155
|
+
if (!mapping) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1159
|
+
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1160
|
+
;
|
|
1161
|
+
Object.keys(row).map(function(fieldCode) {
|
|
1162
|
+
var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
|
|
1163
|
+
if (skipKey.includes(fieldCode)) {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
var fieldMapping = (_this_store_dataBindMapping_dataCode = _this.store.dataBindMapping[dataCode]) === null || _this_store_dataBindMapping_dataCode === void 0 ? void 0 : (_this_store_dataBindMapping_dataCode_fields = _this_store_dataBindMapping_dataCode.fields) === null || _this_store_dataBindMapping_dataCode_fields === void 0 ? void 0 : _this_store_dataBindMapping_dataCode_fields.find(function(i) {
|
|
1167
|
+
return i.fieldCode === fieldCode;
|
|
1168
|
+
});
|
|
1169
|
+
if (fieldMapping) {
|
|
1170
|
+
if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
|
|
1171
|
+
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1172
|
+
} else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
|
|
1173
|
+
var _this_getEmptyState;
|
|
1174
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1175
|
+
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1176
|
+
var dataBind = fieldMapping.dataBind[key];
|
|
1177
|
+
if (row[dataBind.fieldCode] !== undefined) {
|
|
1178
|
+
objValue[key] = row[dataBind.fieldCode];
|
|
1179
|
+
}
|
|
1180
|
+
skipKey.push(dataBind.fieldCode);
|
|
1181
|
+
});
|
|
1182
|
+
newRow[fieldMapping.controlId] = objValue;
|
|
1183
|
+
}
|
|
1097
1184
|
}
|
|
1098
|
-
skipKey.push(dataBind.fieldCode);
|
|
1099
1185
|
});
|
|
1100
|
-
newState[mapping.dataViewId
|
|
1101
|
-
|
|
1186
|
+
if (!newState[mapping.dataViewId]) {
|
|
1187
|
+
newState[mapping.dataViewId] = {};
|
|
1188
|
+
}
|
|
1189
|
+
if (!newState[mapping.dataViewId][mapping.controlId]) {
|
|
1190
|
+
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1191
|
+
}
|
|
1192
|
+
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1193
|
+
});
|
|
1194
|
+
} else if (entity) {
|
|
1195
|
+
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1196
|
+
;
|
|
1197
|
+
Object.keys(entity).map(function(fieldCode) {
|
|
1198
|
+
if (skipKey.includes(fieldCode)) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
var mapping = _this.getDataBindMapping(dataCode, fieldCode);
|
|
1202
|
+
if (mapping) {
|
|
1203
|
+
if (!newState[mapping.dataViewId[0]]) {
|
|
1204
|
+
newState[mapping.dataViewId[0]] = {};
|
|
1205
|
+
}
|
|
1206
|
+
if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
|
|
1207
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode];
|
|
1208
|
+
} else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
|
|
1209
|
+
var _this_getEmptyState;
|
|
1210
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1211
|
+
Object.keys(mapping.dataBind).map(function(key) {
|
|
1212
|
+
var dataBind = mapping.dataBind[key];
|
|
1213
|
+
if (entity[dataBind.fieldCode] !== undefined) {
|
|
1214
|
+
objValue[key] = entity[dataBind.fieldCode];
|
|
1215
|
+
}
|
|
1216
|
+
skipKey.push(dataBind.fieldCode);
|
|
1217
|
+
});
|
|
1218
|
+
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1102
1222
|
}
|
|
1103
1223
|
});
|
|
1224
|
+
this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
|
|
1225
|
+
this.setStates(newState, undefined, options);
|
|
1226
|
+
this.debugLog("engine setData方法执行完成。");
|
|
1104
1227
|
}
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
this.debugLog("engine setData方法执行完成。");
|
|
1109
|
-
};
|
|
1110
|
-
/**
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
/**
|
|
1111
1231
|
* 获取控件的dataBind
|
|
1112
1232
|
* @param controlId
|
|
1113
|
-
* */
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1233
|
+
* */ key: "getDataBind",
|
|
1234
|
+
value: function getDataBind(controlId) {
|
|
1235
|
+
return this.store.getDataBind(controlId);
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
/**
|
|
1117
1240
|
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1118
1241
|
* @param controlId
|
|
1119
1242
|
* @param rowIndex
|
|
1120
|
-
*/
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1243
|
+
*/ key: "getInstance",
|
|
1244
|
+
value: function getInstance(controlId, rowIndex) {
|
|
1245
|
+
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
1246
|
+
if (instances.length > 0) {
|
|
1247
|
+
if (rowIndex !== undefined) {
|
|
1248
|
+
if (rowIndex === -1) {
|
|
1249
|
+
return instances[0];
|
|
1250
|
+
}
|
|
1251
|
+
return instances[rowIndex];
|
|
1252
|
+
} else {
|
|
1253
|
+
return instances[0];
|
|
1254
|
+
}
|
|
1255
|
+
} else {
|
|
1256
|
+
return undefined;
|
|
1126
1257
|
}
|
|
1127
|
-
return instances[rowIndex];
|
|
1128
|
-
} else {
|
|
1129
|
-
return instances[0];
|
|
1130
1258
|
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
};
|
|
1135
|
-
/**
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
/**
|
|
1136
1262
|
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1137
1263
|
* @param controlId
|
|
1138
1264
|
* @param header 明细表内是否获取表头的控件
|
|
1139
|
-
*/
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
var instances = this.runtime.instanceMap[controlId] || [];
|
|
1145
|
-
if (header) {
|
|
1146
|
-
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1147
|
-
if (instances.length) {
|
|
1148
|
-
var instance = instances[0];
|
|
1149
|
-
if (this.inList(instance.id) === true) {
|
|
1150
|
-
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1151
|
-
if (headerInstance) {
|
|
1152
|
-
instances.unshift(headerInstance);
|
|
1153
|
-
}
|
|
1265
|
+
*/ key: "getInstances",
|
|
1266
|
+
value: function getInstances(controlId) {
|
|
1267
|
+
var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1268
|
+
if (controlId === undefined) {
|
|
1269
|
+
return this.runtime.flatInstances;
|
|
1154
1270
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1271
|
+
var instances = Array.from(this.runtime.instanceMap[controlId] || []);
|
|
1272
|
+
if (header) {
|
|
1273
|
+
// 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
|
|
1274
|
+
if (instances.length) {
|
|
1275
|
+
var instance = instances[0];
|
|
1276
|
+
if (this.inList(instance.id) === true) {
|
|
1277
|
+
var headerInstance = this.getInstanceInSubtableHeader(instance);
|
|
1278
|
+
if (headerInstance) {
|
|
1279
|
+
instances.unshift(headerInstance);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
} else {
|
|
1283
|
+
var controlIdMapping = this.getControlIdMapping();
|
|
1284
|
+
var _Object_entries_find;
|
|
1285
|
+
var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1286
|
+
var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
|
|
1287
|
+
return mapping.children && controlId in mapping.children;
|
|
1288
|
+
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1289
|
+
if (subtableId) {
|
|
1290
|
+
var subtable = this.getInstance(subtableId);
|
|
1291
|
+
// @ts-ignore
|
|
1292
|
+
var headerColumn = subtable.props.headers.find(function(column) {
|
|
1293
|
+
return column.children.find(function(item) {
|
|
1294
|
+
return item.id === controlId;
|
|
1295
|
+
});
|
|
1296
|
+
});
|
|
1297
|
+
if (headerColumn) {
|
|
1298
|
+
var headerInstance1 = headerColumn.children.find(function(item) {
|
|
1299
|
+
return item.id === controlId;
|
|
1300
|
+
});
|
|
1301
|
+
if (headerInstance1) {
|
|
1302
|
+
instances.unshift(headerInstance1);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1176
1305
|
}
|
|
1177
1306
|
}
|
|
1178
1307
|
}
|
|
1308
|
+
// @ts-ignore
|
|
1309
|
+
return instances;
|
|
1179
1310
|
}
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
key: "setInstance",
|
|
1314
|
+
value: function setInstance(instance, props, value, rowIndex) {
|
|
1315
|
+
var _this = this;
|
|
1316
|
+
try {
|
|
1317
|
+
if (typeof instance === "string" && rowIndex === -1) {
|
|
1318
|
+
//修改明细表整列属性的逻辑
|
|
1319
|
+
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1320
|
+
instances.map(function(_instance) {
|
|
1321
|
+
if (_instance) {
|
|
1322
|
+
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1323
|
+
updateValueFromKeys(_instance.props, props, value);
|
|
1324
|
+
_this.schemaEvent("schema-change", {
|
|
1325
|
+
instance: _instance,
|
|
1326
|
+
props: props,
|
|
1327
|
+
value: value,
|
|
1328
|
+
rowIndex: rowIndex
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
} else {
|
|
1333
|
+
var _instance;
|
|
1334
|
+
if (typeof instance === "string") {
|
|
1335
|
+
_instance = this.getInstance(instance, rowIndex);
|
|
1336
|
+
} else {
|
|
1337
|
+
_instance = instance;
|
|
1338
|
+
}
|
|
1339
|
+
if (!_instance) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1193
1343
|
updateValueFromKeys(_instance.props, props, value);
|
|
1194
|
-
|
|
1344
|
+
this.schemaEvent("schema-change", {
|
|
1195
1345
|
instance: _instance,
|
|
1196
1346
|
props: props,
|
|
1197
1347
|
value: value,
|
|
1198
1348
|
rowIndex: rowIndex
|
|
1199
1349
|
});
|
|
1200
1350
|
}
|
|
1201
|
-
})
|
|
1202
|
-
|
|
1203
|
-
var _instance;
|
|
1204
|
-
if (typeof instance === "string") {
|
|
1205
|
-
_instance = this.getInstance(instance, rowIndex);
|
|
1206
|
-
} else {
|
|
1207
|
-
_instance = instance;
|
|
1351
|
+
} catch (e) {
|
|
1352
|
+
throw e;
|
|
1208
1353
|
}
|
|
1209
|
-
|
|
1354
|
+
}
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
key: "getControlIdMapping",
|
|
1358
|
+
value: function getControlIdMapping() {
|
|
1359
|
+
return this.store.controlIdMapping;
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
{
|
|
1363
|
+
key: "getDataBindMapping",
|
|
1364
|
+
value: function getDataBindMapping(dataCode, fieldCode) {
|
|
1365
|
+
if (!dataCode && !fieldCode) {
|
|
1366
|
+
return this.store.dataBindMapping;
|
|
1367
|
+
}
|
|
1368
|
+
var mapping = this.store.dataBindMapping[dataCode];
|
|
1369
|
+
if (!mapping) {
|
|
1370
|
+
warn("No corresponding dataCode=".concat(dataCode, " was found"));
|
|
1210
1371
|
return;
|
|
1211
1372
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
value: value,
|
|
1218
|
-
rowIndex: rowIndex
|
|
1373
|
+
if (!fieldCode) {
|
|
1374
|
+
return mapping;
|
|
1375
|
+
}
|
|
1376
|
+
var dataBindMapping = mapping.fields.find(function(item) {
|
|
1377
|
+
return item.fieldCode === fieldCode;
|
|
1219
1378
|
});
|
|
1379
|
+
if (!dataBindMapping) {
|
|
1380
|
+
warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
return dataBindMapping;
|
|
1220
1384
|
}
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
if (!dataBindMapping) {
|
|
1244
|
-
warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
return dataBindMapping;
|
|
1248
|
-
};
|
|
1249
|
-
_proto.getAction = function getAction() {
|
|
1250
|
-
return this.actionManager;
|
|
1251
|
-
};
|
|
1252
|
-
_proto.initDataManager = function initDataManager(callbackExecuter) {
|
|
1253
|
-
this.dataManager = new DataManager(callbackExecuter);
|
|
1254
|
-
};
|
|
1255
|
-
_proto.getDataManager = function getDataManager() {
|
|
1256
|
-
return this.dataManager;
|
|
1257
|
-
};
|
|
1258
|
-
/**
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
key: "getAction",
|
|
1388
|
+
value: function getAction() {
|
|
1389
|
+
return this.actionManager;
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
key: "initDataManager",
|
|
1394
|
+
value: function initDataManager(callbackExecuter) {
|
|
1395
|
+
this.dataManager = new DataManager(callbackExecuter);
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
key: "getDataManager",
|
|
1400
|
+
value: function getDataManager() {
|
|
1401
|
+
return this.dataManager;
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
key: "assertInstance",
|
|
1406
|
+
value: /**
|
|
1259
1407
|
* 判断控件的类型,返回当前控件的正确类型
|
|
1260
|
-
* */
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1408
|
+
* */ function assertInstance(instance, types) {
|
|
1409
|
+
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
key: "getInstanceRowIndex",
|
|
1414
|
+
value: /**
|
|
1264
1415
|
* 获取控件在明细子表中的行下标,
|
|
1265
1416
|
* 如果控件在表头内,则返回-1
|
|
1266
1417
|
* 如果控件在表内,则返回行下标
|
|
1267
1418
|
* 如果控件不在明细表内,则返回undefined
|
|
1268
|
-
* */
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
// @ts-ignore
|
|
1274
|
-
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1275
|
-
// 表头内的控件
|
|
1276
|
-
// @ts-ignore
|
|
1277
|
-
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1278
|
-
rowIndex = -1;
|
|
1279
|
-
} else {
|
|
1419
|
+
* */ function getInstanceRowIndex(instance) {
|
|
1420
|
+
if (!instance.parent) {
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
var rowIndex;
|
|
1280
1424
|
// @ts-ignore
|
|
1281
|
-
|
|
1282
|
-
|
|
1425
|
+
if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
|
|
1426
|
+
// 表头内的控件
|
|
1427
|
+
// @ts-ignore
|
|
1428
|
+
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
|
|
1429
|
+
rowIndex = -1;
|
|
1430
|
+
} else {
|
|
1431
|
+
// @ts-ignore
|
|
1432
|
+
var index = instance.parent.children.findIndex(function(item) {
|
|
1433
|
+
return item === instance;
|
|
1434
|
+
});
|
|
1435
|
+
if (index > -1) {
|
|
1436
|
+
rowIndex = index;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
} else {
|
|
1440
|
+
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1441
|
+
}
|
|
1442
|
+
return rowIndex;
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
key: "getInstanceParentControl",
|
|
1447
|
+
value: function getInstanceParentControl(instance, controlType) {
|
|
1448
|
+
if (!instance.parent) {
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
if (this.assertInstance(instance.parent, controlType)) {
|
|
1452
|
+
return instance.parent;
|
|
1453
|
+
}
|
|
1454
|
+
return this.getInstanceParentControl(instance.parent, controlType);
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
key: "getInstanceInSubtableHeader",
|
|
1459
|
+
value: function getInstanceInSubtableHeader(instance) {
|
|
1460
|
+
var rowIndex = this.getInstanceRowIndex(instance);
|
|
1461
|
+
if (rowIndex === undefined) {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (rowIndex === -1) {
|
|
1465
|
+
return instance;
|
|
1466
|
+
}
|
|
1467
|
+
var columnInstance = this.assertInstance(instance, // @ts-ignore
|
|
1468
|
+
CONTROL_TYPE.SUBTABLE_COLUMN) ? instance : this.getInstanceParentControl(instance, // @ts-ignore
|
|
1469
|
+
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1470
|
+
if (!columnInstance) {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
var subtable = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1474
|
+
CONTROL_TYPE.SUBTABLE);
|
|
1475
|
+
// @ts-ignore
|
|
1476
|
+
var headerColumn = subtable.props.headers.find(// @ts-ignore
|
|
1477
|
+
function(column) {
|
|
1478
|
+
return column.id === columnInstance.id;
|
|
1283
1479
|
});
|
|
1284
|
-
if (
|
|
1285
|
-
|
|
1480
|
+
if (!headerColumn) {
|
|
1481
|
+
return;
|
|
1286
1482
|
}
|
|
1483
|
+
return headerColumn.children.find(// @ts-ignore
|
|
1484
|
+
function(item) {
|
|
1485
|
+
return item.id === instance.id;
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
key: "setControlConfig",
|
|
1491
|
+
value: function setControlConfig() {
|
|
1492
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1493
|
+
args[_key] = arguments[_key];
|
|
1494
|
+
}
|
|
1495
|
+
var _this_runtime;
|
|
1496
|
+
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _to_consumable_array(args));
|
|
1497
|
+
}
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
key: "getControlConfig",
|
|
1501
|
+
value: function getControlConfig(control) {
|
|
1502
|
+
return this.runtime.getControlConfig(control);
|
|
1503
|
+
}
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
key: "inList",
|
|
1507
|
+
value: function inList(controlId) {
|
|
1508
|
+
var mapping = this.store.controlIdMapping;
|
|
1509
|
+
var result = Object.keys(mapping).some(function(key) {
|
|
1510
|
+
var _mapping_key, _mapping_key_children;
|
|
1511
|
+
return (_mapping_key = mapping[key]) === null || _mapping_key === void 0 ? void 0 : (_mapping_key_children = _mapping_key.children) === null || _mapping_key_children === void 0 ? void 0 : _mapping_key_children.hasOwnProperty(controlId);
|
|
1512
|
+
});
|
|
1513
|
+
return result;
|
|
1287
1514
|
}
|
|
1288
|
-
} else {
|
|
1289
|
-
rowIndex = this.getInstanceRowIndex(instance.parent);
|
|
1290
|
-
}
|
|
1291
|
-
return rowIndex;
|
|
1292
|
-
};
|
|
1293
|
-
_proto.getInstanceParentControl = function getInstanceParentControl(instance, controlType) {
|
|
1294
|
-
if (!instance.parent) {
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
if (this.assertInstance(instance.parent, controlType)) {
|
|
1298
|
-
return instance.parent;
|
|
1299
|
-
}
|
|
1300
|
-
return this.getInstanceParentControl(instance.parent, controlType);
|
|
1301
|
-
};
|
|
1302
|
-
_proto.getInstanceInSubtableHeader = function getInstanceInSubtableHeader(instance) {
|
|
1303
|
-
var rowIndex = this.getInstanceRowIndex(instance);
|
|
1304
|
-
if (rowIndex === undefined) {
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
|
-
if (rowIndex === -1) {
|
|
1308
|
-
return instance;
|
|
1309
|
-
}
|
|
1310
|
-
var columnInstance = this.assertInstance(instance, // @ts-ignore
|
|
1311
|
-
CONTROL_TYPE.SUBTABLE_COLUMN) ? instance : this.getInstanceParentControl(instance, // @ts-ignore
|
|
1312
|
-
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1313
|
-
if (!columnInstance) {
|
|
1314
|
-
return;
|
|
1315
|
-
}
|
|
1316
|
-
var subtable = this.getInstanceParentControl(instance, // @ts-ignore
|
|
1317
|
-
CONTROL_TYPE.SUBTABLE);
|
|
1318
|
-
// @ts-ignore
|
|
1319
|
-
var headerColumn = subtable.props.headers.find(// @ts-ignore
|
|
1320
|
-
function(column) {
|
|
1321
|
-
return column.id === columnInstance.id;
|
|
1322
|
-
});
|
|
1323
|
-
if (!headerColumn) {
|
|
1324
|
-
return;
|
|
1325
|
-
}
|
|
1326
|
-
return headerColumn.children.find(// @ts-ignore
|
|
1327
|
-
function(item) {
|
|
1328
|
-
return item.id === instance.id;
|
|
1329
|
-
});
|
|
1330
|
-
};
|
|
1331
|
-
_proto.setControlConfig = function setControlConfig() {
|
|
1332
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1333
|
-
args[_key] = arguments[_key];
|
|
1334
1515
|
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
arg[_key] = arguments[_key];
|
|
1516
|
+
], [
|
|
1517
|
+
{
|
|
1518
|
+
key: "register",
|
|
1519
|
+
value: // 注册外部控件
|
|
1520
|
+
function register() {
|
|
1521
|
+
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1522
|
+
arg[_key] = arguments[_key];
|
|
1523
|
+
}
|
|
1524
|
+
var _Runtime;
|
|
1525
|
+
return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
|
|
1526
|
+
}
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
key: "judgeControlIsRegistered",
|
|
1530
|
+
value: function judgeControlIsRegistered(control) {
|
|
1531
|
+
return Runtime.staticRegisteredTypes.has(control.Runtime.controlType);
|
|
1532
|
+
}
|
|
1353
1533
|
}
|
|
1354
|
-
|
|
1355
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
|
|
1356
|
-
};
|
|
1357
|
-
Engine.judgeControlIsRegistered = function judgeControlIsRegistered(control) {
|
|
1358
|
-
return Runtime.staticRegisteredTypes.has(control.Runtime.controlType);
|
|
1359
|
-
};
|
|
1534
|
+
]);
|
|
1360
1535
|
return Engine;
|
|
1361
1536
|
}(Watcher);
|
|
1362
1537
|
export { Engine };
|