@byteluck-fe/model-driven-engine 2.7.0-beta.4 → 2.8.0-alpha.1

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.
@@ -111,13 +111,6 @@ function _inherits(subClass, superClass) {
111
111
  });
112
112
  if (superClass) _set_prototype_of(subClass, superClass);
113
113
  }
114
- function _instanceof(left, right) {
115
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
116
- return !!right[Symbol.hasInstance](left);
117
- } else {
118
- return left instanceof right;
119
- }
120
- }
121
114
  function _iterable_to_array(iter) {
122
115
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
123
116
  }
@@ -347,8 +340,8 @@ function _ts_generator(thisArg, body) {
347
340
  };
348
341
  }
349
342
  }
350
- import { DataBind, ObjectDataBind, RuntimeListControl } from "@byteluck-fe/model-driven-core";
351
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
343
+ import { isDataBind } from "@byteluck-fe/model-driven-core";
344
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from "@byteluck-fe/model-driven-shared";
352
345
  import { Runtime } from "./Runtime";
353
346
  import { Store } from "./Store";
354
347
  import { findItem, proxyState } from "./proxyState";
@@ -525,7 +518,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
525
518
  value: function _handlerArrayUpdate(state, key, type, args, result) {
526
519
  var _this = this;
527
520
  var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
528
- if (!_instanceof(subtable, RuntimeListControl)) return;
521
+ // if (!(subtable instanceof RuntimeListControl)) return
522
+ if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
529
523
  // 新增多行方法
530
524
  var createRows = function(len) {
531
525
  // @ts-ignore
@@ -543,6 +537,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
543
537
  var createdNewRows = [];
544
538
  var createdNewRowsData = [];
545
539
  var deleted = [];
540
+ var isDeleteLastOne = false;
546
541
  if (type && args) {
547
542
  // const subtableOldLength = subtable.children.length
548
543
  switch(type){
@@ -579,6 +574,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
579
574
  } else {
580
575
  var // @ts-ignore
581
576
  _subtable_children2;
577
+ // 从哪儿开始
578
+ var start1 = args[0];
579
+ // 替换几个
580
+ var replace1 = args[1];
581
+ if (start1 + replace1 === subtable.children.length - 1) {
582
+ isDeleteLastOne = true;
583
+ }
582
584
  (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
583
585
  this.runtime.getFlatInstances();
584
586
  }
@@ -607,7 +609,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
607
609
  changed: createdNewRows,
608
610
  data: createdNewRowsData,
609
611
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
610
- jsonValue: JSON.stringify(this.getState(subtable.id))
612
+ jsonValue: JSON.stringify(this.getState(subtable.id)),
613
+ isDeleteLastOne: isDeleteLastOne,
614
+ type: type,
615
+ args: args
611
616
  })
612
617
  });
613
618
  // 主动清空本次任务中的options
@@ -650,7 +655,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
650
655
  // @ts-ignore
651
656
  changed: newRows,
652
657
  data: newValue,
653
- deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
658
+ deleted: oldValue !== null && oldValue !== void 0 ? oldValue : [],
659
+ type: "push"
654
660
  })
655
661
  });
656
662
  } else {
@@ -945,7 +951,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
945
951
  }
946
952
  var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
947
953
  var state = this.getState(controlId1, rowIndex);
948
- if (_instanceof(dataBind, ObjectDataBind)) {
954
+ //if (dataBind instanceof ObjectDataBind) {
955
+ if (!isDataBind(dataBind)) {
949
956
  return Object.entries(dataBind).reduce(function(result, param) {
950
957
  var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
951
958
  // objectDataBind的元素,跳过下一次赋值
@@ -1052,7 +1059,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1052
1059
  return;
1053
1060
  }
1054
1061
  var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
1055
- if (_instanceof(dataBind, ObjectDataBind)) {
1062
+ // if (dataBind instanceof ObjectDataBind) {
1063
+ if (!isDataBind(dataBind)) {
1056
1064
  var _JSONCopy;
1057
1065
  var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
1058
1066
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1094,7 +1102,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1094
1102
  return;
1095
1103
  }
1096
1104
  // 对象类型的值
1097
- if (_instanceof(dataBind, ObjectDataBind)) {
1105
+ // if (dataBind instanceof ObjectDataBind) {
1106
+ if (!isDataBind(dataBind)) {
1098
1107
  var _JSONCopy;
1099
1108
  var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
1100
1109
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1138,7 +1147,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1138
1147
  return;
1139
1148
  }
1140
1149
  // 对象类型的值
1141
- if (_instanceof(dataBind, ObjectDataBind)) {
1150
+ // if (dataBind instanceof ObjectDataBind) {
1151
+ if (!isDataBind(dataBind)) {
1142
1152
  var oldState = _this.getEmptyState(controlId);
1143
1153
  // fieldCode不代表是key,所以需要找到对应的key
1144
1154
  result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
@@ -1197,9 +1207,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1197
1207
  return i.fieldCode === fieldCode;
1198
1208
  });
1199
1209
  if (fieldMapping) {
1200
- if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
1210
+ if (// fieldMapping.dataBind instanceof DataBind &&
1211
+ isDataBind(fieldMapping.dataBind) && row[fieldCode] !== undefined) {
1201
1212
  newRow[fieldMapping.controlId] = row[fieldCode];
1202
- } else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
1213
+ // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1214
+ } else if (!isDataBind(fieldMapping.dataBind)) {
1203
1215
  var _this_getEmptyState;
1204
1216
  var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1205
1217
  Object.keys(fieldMapping.dataBind).map(function(key) {
@@ -1232,9 +1244,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1232
1244
  if (!newState[mapping.dataViewId[0]]) {
1233
1245
  newState[mapping.dataViewId[0]] = {};
1234
1246
  }
1235
- if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1247
+ if (// mapping.dataBind instanceof DataBind &&
1248
+ isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
1236
1249
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1237
- } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1250
+ // } else if (mapping.dataBind instanceof ObjectDataBind) {
1251
+ } else if (!isDataBind(mapping.dataBind)) {
1238
1252
  var _this_getEmptyState;
1239
1253
  var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1240
1254
  Object.keys(mapping.dataBind).map(function(key) {
@@ -1327,6 +1341,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1327
1341
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1328
1342
  if (instances.length) {
1329
1343
  var instance = instances[0];
1344
+ // if (this.inList(instance.id) === true) {
1330
1345
  if (this.inList(instance.id) !== undefined) {
1331
1346
  var headerInstance = this.getInstanceInSubtableHeader(instance);
1332
1347
  if (headerInstance) {
@@ -1464,6 +1479,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1464
1479
  return isString(types) ? instance.type === types : types.includes(instance.type);
1465
1480
  }
1466
1481
  },
1482
+ {
1483
+ key: "assertInstanceIsCustomControl",
1484
+ value: /**
1485
+ * 判断控件或控件类型是一个自定义控件
1486
+ * */ function assertInstanceIsCustomControl(instance) {
1487
+ return !isBuiltInControls(isString(instance) ? instance : instance.type);
1488
+ }
1489
+ },
1467
1490
  {
1468
1491
  key: "getInstanceRowIndex",
1469
1492
  value: /**
@@ -1499,7 +1522,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1499
1522
  },
1500
1523
  {
1501
1524
  key: "getInstanceParentControl",
1502
- value: function getInstanceParentControl(instance, controlType) {
1525
+ value: // public getInstanceRowIndex(
1526
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1527
+ // ) {
1528
+ // let rowIndex: number | undefined
1529
+ // // @ts-ignore
1530
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1531
+ // rowIndex = -1
1532
+ // }else{
1533
+ // const instanceList = this.runtime.instanceMap[instance.id]
1534
+ // if(Object.prototype.toString.call(instanceList) === '[object Array]'){
1535
+ // const index = instanceList.findIndex(
1536
+ // (item: any) => item === instance
1537
+ // )
1538
+ // if (index > -1) {
1539
+ // rowIndex = index
1540
+ // }
1541
+ // }
1542
+ // }
1543
+ // return rowIndex
1544
+ // }
1545
+ function getInstanceParentControl(instance, controlType) {
1503
1546
  if (!instance.parent) {
1504
1547
  return;
1505
1548
  }
@@ -77,7 +77,9 @@ var OkWorker = /*#__PURE__*/ function() {
77
77
  key: "createWorkerFunction",
78
78
  value: function createWorkerFunction() {
79
79
  return function() {
80
- var createHandler = function createHandler(parentKey) {
80
+ log("‍\uD83D\uDE80 worker running");
81
+ var _self = self;
82
+ function createHandler(parentKey) {
81
83
  return {
82
84
  get: function get(target, key, value) {
83
85
  return Reflect.get(target, key, value);
@@ -92,9 +94,7 @@ var OkWorker = /*#__PURE__*/ function() {
92
94
  return Reflect.set(target, key, value);
93
95
  }
94
96
  };
95
- };
96
- log("‍\uD83D\uDE80 worker running");
97
- var _self = self;
97
+ }
98
98
  // function createProxy(
99
99
  // obj: Record<string, unknown> | Array<Record<string, unknown>>,
100
100
  // parentKey?: string
@@ -234,8 +234,12 @@ function loop(control, callback) {
234
234
  control.map(function(item) {
235
235
  callback(item);
236
236
  if (hasChildrenControl(item)) {
237
+ var ctl = item;
238
+ if (!ctl.children) {
239
+ ctl.children = [];
240
+ }
237
241
  // @ts-ignore
238
- loop(item.children, callback);
242
+ loop(ctl.children, callback);
239
243
  }
240
244
  });
241
245
  } else {
@@ -30,13 +30,6 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- function _instanceof(left, right) {
34
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35
- return !!right[Symbol.hasInstance](left);
36
- } else {
37
- return left instanceof right;
38
- }
39
- }
40
33
  function _object_spread(target) {
41
34
  for(var i = 1; i < arguments.length; i++){
42
35
  var source = arguments[i] != null ? arguments[i] : {};
@@ -52,7 +45,7 @@ function _object_spread(target) {
52
45
  }
53
46
  return target;
54
47
  }
55
- import { DataBind, ObjectDataBind } from "@byteluck-fe/model-driven-core";
48
+ import { DataBind, isDataBind } from "@byteluck-fe/model-driven-core";
56
49
  import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
57
50
  import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
58
51
  var Store = /*#__PURE__*/ function() {
@@ -82,10 +75,9 @@ var Store = /*#__PURE__*/ function() {
82
75
  value: function setState(controlId, value, rowIndex) {
83
76
  var _this = this;
84
77
  var controlInfo = this.controlIdMapping[controlId];
85
- var noProxyValue = JSONCopy(value);
86
78
  if (controlInfo !== undefined) {
87
79
  //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
88
- this.state[controlInfo.dataView][controlId] = noProxyValue;
80
+ this.state[controlInfo.dataView][controlId] = value;
89
81
  // if (
90
82
  // controlInfo.dataBind instanceof ObjectDataBind &&
91
83
  // isPlainObject(value)
@@ -104,7 +96,7 @@ var Store = /*#__PURE__*/ function() {
104
96
  Object.keys(children).map(function(childControlId) {
105
97
  if (childControlId === controlId) {
106
98
  if (_this.state[dataView][subtableId][rowIndex]) {
107
- _this.state[dataView][subtableId][rowIndex][controlId] = noProxyValue;
99
+ _this.state[dataView][subtableId][rowIndex][controlId] = value;
108
100
  }
109
101
  }
110
102
  });
@@ -112,7 +104,7 @@ var Store = /*#__PURE__*/ function() {
112
104
  });
113
105
  } else {
114
106
  //不存在的 controlId,直接被挂载到外部key
115
- this.state[controlId] = noProxyValue;
107
+ this.state[controlId] = value;
116
108
  }
117
109
  }
118
110
  }
@@ -288,7 +280,8 @@ item) {
288
280
  // if (item instanceof RuntimeFormControl) {
289
281
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
290
282
  var _item_props_dataBind, _item_props;
291
- if (_instanceof(item.props.dataBind, ObjectDataBind)) {
283
+ // if (item.props.dataBind instanceof ObjectDataBind) {
284
+ if (!isDataBind(item.props.dataBind)) {
292
285
  // 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
293
286
  Object.keys(item.props.dataBind).map(function(key) {
294
287
  var dataBind = item.props.dataBind;
@@ -343,7 +336,8 @@ item) {
343
336
  };
344
337
  var subtableId = item.id;
345
338
  loopFormSchema(item.props.headers, function(item) {
346
- if (_instanceof(item.props.dataBind, ObjectDataBind)) {
339
+ // if (item.props.dataBind instanceof ObjectDataBind) {
340
+ if (!isDataBind(item.props.dataBind)) {
347
341
  Object.keys(item.props.dataBind).map(function(key) {
348
342
  var dataBind = item.props.dataBind;
349
343
  var dataCode = dataBind[key].dataCode;
@@ -63,13 +63,6 @@ function _inherits(subClass, superClass) {
63
63
  });
64
64
  if (superClass) _set_prototype_of(subClass, superClass);
65
65
  }
66
- function _instanceof(left, right) {
67
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
68
- return !!right[Symbol.hasInstance](left);
69
- } else {
70
- return left instanceof right;
71
- }
72
- }
73
66
  function _iterable_to_array_limit(arr, i) {
74
67
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
75
68
  if (_i == null) return;
@@ -254,13 +247,13 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
254
247
  {
255
248
  key: "transform",
256
249
  value: function transform(value) {
257
- var getStringValueArray = function getStringValueArray(value) {
250
+ if (value === undefined || value === null) {
251
+ return [];
252
+ }
253
+ function getStringValueArray(value) {
258
254
  return value.map(function(item) {
259
255
  return !item ? "" : String(item);
260
256
  });
261
- };
262
- if (value === undefined || value === null) {
263
- return [];
264
257
  }
265
258
  if (isArray(value)) {
266
259
  return getStringValueArray(value);
@@ -299,15 +292,15 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
299
292
  {
300
293
  key: "transform",
301
294
  value: function transform(value) {
302
- var getNumberValueArray = function getNumberValueArray(value) {
295
+ if (value === undefined || value === null) {
296
+ return [];
297
+ }
298
+ function getNumberValueArray(value) {
303
299
  return value.map(function(item) {
304
300
  return !item && item !== 0 ? "" : Number(item);
305
301
  }).filter(function(item) {
306
302
  return item === "" || !Number.isNaN(item);
307
303
  });
308
- };
309
- if (value === undefined || value === null) {
310
- return [];
311
304
  }
312
305
  if (isArray(value)) {
313
306
  return getNumberValueArray(value);
@@ -344,7 +337,8 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
344
337
  {
345
338
  key: "validate",
346
339
  value: function validate(value) {
347
- return _instanceof(value, AmountValue) || isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency);
340
+ return(// value instanceof AmountValue ||
341
+ isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency));
348
342
  }
349
343
  },
350
344
  {
@@ -394,7 +388,8 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
394
388
  {
395
389
  key: "validate",
396
390
  value: function validate(value) {
397
- return _instanceof(value, RangeDateValue) || isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max);
391
+ return(// value instanceof RangeDateValue ||
392
+ isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
398
393
  }
399
394
  },
400
395
  {
@@ -441,7 +436,8 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
441
436
  {
442
437
  key: "validate",
443
438
  value: function validate(value) {
444
- return _instanceof(value, CalcValue) || isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit);
439
+ return(// value instanceof CalcValue ||
440
+ isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
445
441
  }
446
442
  },
447
443
  {
@@ -491,7 +487,18 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
491
487
  {
492
488
  key: "validate",
493
489
  value: function validate(value) {
494
- return _instanceof(value, AddressValue);
490
+ // return value instanceof AddressValue
491
+ if (isPlainObject(value)) {
492
+ // city?: string;
493
+ // cityDisplay?: string;
494
+ // district?: string;
495
+ // districtDisplay?: string;
496
+ // province?: string;
497
+ // provinceDisplay?: string
498
+ return true;
499
+ } else {
500
+ return false;
501
+ }
495
502
  }
496
503
  },
497
504
  {
@@ -24,7 +24,7 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  var cc = console;
27
- import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from "@byteluck-fe/model-driven-shared";
27
+ import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
28
28
  var proxyArrayApi = [
29
29
  "splice",
30
30
  "push",
@@ -125,7 +125,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
125
125
  return Reflect.get(target, propertyKey, receiver);
126
126
  },
127
127
  set: function set(target, propertyKey, value, receiver) {
128
- var reProxyState = function reProxyState(value) {
128
+ var newValue = value;
129
+ // @ts-ignore
130
+ var oldValue = target[propertyKey];
131
+ var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
132
+ function reProxyState(value) {
129
133
  if (typeof value === "object" && value !== null) {
130
134
  // @ts-ignore
131
135
  if (value[engineProxyFlag] !== true) {
@@ -136,20 +140,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
136
140
  value[engineTargetKey], callback, beforeSetCallback, concatKey);
137
141
  }
138
142
  }
139
- };
140
- var newValue = JSONCopy(value);
141
- // @ts-ignore
142
- var oldValue = target[propertyKey];
143
- var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
143
+ }
144
144
  var _reProxyState;
145
- newValue = (_reProxyState = reProxyState(newValue)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
145
+ newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
146
146
  // 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
147
147
  var setResult;
148
148
  // TODO 数组拦截操作需要重构,优化现有逻辑
149
149
  // TODO 直接操作下标改动明细表时,没有对行数据进行checker
150
150
  if (Array.isArray(target)) {
151
151
  // 操作数组的时候,不需要使用拼接的thisKey,先判断执行的是否是违规操作,违规操作的话会报错,不允许继续执行,正常操作的话,返回一个回调函数,用于在值修改完之后触发
152
- var nextHandler = ArrayHandler(target, propertyKey, newValue, thisKey, callback);
152
+ var nextHandler = ArrayHandler(target, propertyKey, value, thisKey, callback);
153
153
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
154
154
  if (nextHandler) {
155
155
  nextHandler();
@@ -171,7 +171,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
171
171
  return true;
172
172
  }
173
173
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
174
- callback.call(null, target, concatKey, newValue, oldValue);
174
+ callback.call(null, target, concatKey, value, oldValue);
175
175
  }
176
176
  // 不返回falsy 值(即 false、0、null、undefined、空字符串等)
177
177
  //fix: TypeError: Proxy object's 'set' trap returned falsy value for property 'length'
@@ -205,7 +205,7 @@ function flatInstanceForChildren(controls) {
205
205
  var result = [];
206
206
  controls.forEach(function(item) {
207
207
  result.push(item);
208
- if (item.controlType === "layout") {
208
+ if (item.controlType === "layout" || item.controlType === "wrap") {
209
209
  var _result;
210
210
  (_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
211
211
  }
@@ -59,12 +59,12 @@ import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from "@byteluck-fe
59
59
  import { format } from "mathjs";
60
60
  var DisplayType;
61
61
  (function(DisplayType) {
62
- DisplayType[/**
62
+ /**
63
63
  * 完全等于
64
- */ "EQ"] = "EQ";
65
- DisplayType[/**
64
+ */ DisplayType["EQ"] = "EQ";
65
+ /**
66
66
  * 包含
67
- * */ "IN"] = "IN";
67
+ * */ DisplayType["IN"] = "IN";
68
68
  })(DisplayType || (DisplayType = {}));
69
69
  export var CalcPlugin = /*#__PURE__*/ function() {
70
70
  "use strict";
@@ -156,7 +156,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
156
156
  if (control.props.isHide) {
157
157
  return true;
158
158
  }
159
- if (control.parent === null) {
159
+ if (control.parent === null || control.parent === undefined) {
160
160
  return false;
161
161
  }
162
162
  return this.getControlIsHide(control.parent);
@@ -167,12 +167,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
167
167
  value: function apply(engine) {
168
168
  var _this = this;
169
169
  this.engine = engine;
170
- this.resetDependencies();
171
170
  this.watchControlChange();
172
171
  this.watchSubtableChange();
173
172
  this.watchSchemaHideChange();
174
173
  this.engine.on("engine-mounted", function() {
175
- _this.allCalcControlComputed();
174
+ requestAnimationFrame(function() {
175
+ _this.resetDependencies();
176
+ _this.allCalcControlComputed();
177
+ });
176
178
  });
177
179
  }
178
180
  },
@@ -194,7 +196,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
194
196
  * */ function allCalcControlComputed() {
195
197
  var _this = this;
196
198
  this.calcControls.forEach(function(item) {
197
- return _this.computedCalcValue(item);
199
+ if (item.props.dataBind.result.fieldCode === null || item.props.dataBind.result.fieldCode === undefined) {
200
+ _this.computedCalcValue(item);
201
+ }
198
202
  });
199
203
  }
200
204
  },
@@ -287,6 +291,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
287
291
  var _this = this;
288
292
  this.engine.on("list-change", function(payload) {
289
293
  var _payload_options;
294
+ // 初始化前是批量操作。不做处理
295
+ if (_this.engine.isMounted === false) return;
290
296
  _this.resetDependencies();
291
297
  var _payload_options_changed;
292
298
  var changedRows = (_payload_options_changed = (_payload_options = payload.options) === null || _payload_options === void 0 ? void 0 : _payload_options.changed) !== null && _payload_options_changed !== void 0 ? _payload_options_changed : [];
@@ -312,6 +318,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
312
318
  * */ function watchControlChange() {
313
319
  var _this = this;
314
320
  this.engine.on("change", function(payload) {
321
+ // 初始化前是批量操作。不做处理
322
+ if (_this.engine.isMounted === false) return;
315
323
  var instance = payload.instance;
316
324
  if (!_this.dependenciesTriggerMap.has(instance.id)) {
317
325
  return;
@@ -213,7 +213,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
213
213
  switch(_state.label){
214
214
  case 0:
215
215
  // 初始化state的时候不触发change事件,必须在engine mounted以后才触发
216
- if ((eventKey === "change" || eventKey === "list-change") && !_this.engine.isMounted) {
216
+ if (eventKey === "change" && !_this.engine.isMounted) {
217
217
  return [
218
218
  2
219
219
  ];
@@ -8,7 +8,8 @@ export function loopFormControl(control, callback) {
8
8
  //TODO 此处需要再抽象一层 datagrid/datalist
9
9
  if (item.type === CONTROL_TYPE.SUBTABLE) {
10
10
  // @ts-ignore
11
- var children = item.getChildrenFormControl();
11
+ var children = []//item.getChildrenFormControl() as RuntimeFormControl[]
12
+ ;
12
13
  callback(item, children);
13
14
  } else if (hasChildrenControl(item)) {
14
15
  loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);