@byteluck-fe/model-driven-engine 4.37.0-lx2 → 5.5.0-1-beta1

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.
@@ -185,6 +185,7 @@ export var DataManager = /*#__PURE__*/ function() {
185
185
  return _async_to_generator(function() {
186
186
  return _ts_generator(this, function(_state) {
187
187
  if (this.executer === undefined) {
188
+ // @i18n-translate-ignore
188
189
  logerror('未初始化executer');
189
190
  return [
190
191
  2,
@@ -325,7 +325,7 @@ function _ts_generator(thisArg, body) {
325
325
  }
326
326
  }
327
327
  import { isDataBind } from '@byteluck-fe/model-driven-core';
328
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
328
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
329
329
  import { Runtime } from './Runtime';
330
330
  import { Store } from './Store';
331
331
  import { findItem, proxyState } from './proxyState';
@@ -351,18 +351,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
351
351
  _this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
352
352
  _define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
353
353
  // public worker: OkWorker
354
- _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
354
+ _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), _define_property(_this, "children", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
355
355
  _define_property(_this, "__plugins", void 0), _define_property(_this, "__pluginsApplied", false), _define_property(_this, "$options", void 0), _define_property(_this, "actionManager", new ActionManager()), _define_property(_this, "dataManager", void 0), _define_property(_this, "_jobTasks", []), _define_property(_this, "createControlInstance", _this.createInstance);
356
356
  _this.$options = Object.freeze(props);
357
357
  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,
358
- 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;
359
- RulesMessage.setLocale(language);
358
+ 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, messagesI18n = _this_$options.messagesI18n, children = _this_$options.children;
360
359
  _this.debug = debug;
361
360
  _this.runtime = new Runtime({
362
361
  schema: schema,
363
362
  beforeCreateInstance: beforeCreateInstance
364
363
  });
365
364
  _this.externalParams = externalParams;
365
+ _this.children = children;
366
366
  _this.store = new Store({
367
367
  instance: _this.runtime.instance
368
368
  });
@@ -405,6 +405,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
405
405
  {
406
406
  key: "mount",
407
407
  value: function mount() {
408
+ // @i18n-translate-ignore
408
409
  this.debugLog("engine的mount方法开始调用");
409
410
  var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
410
411
  this._handlerProxyState();
@@ -412,6 +413,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
412
413
  this.applyPlugins();
413
414
  // 触发所有控件的默认值的change事件
414
415
  this.setStates(this.getState());
416
+ // @i18n-translate-ignore
415
417
  this.debugLog("engine的mount方法调用结束");
416
418
  if (this.debug && typeof window !== 'undefined') {
417
419
  // @ts-ignore
@@ -437,7 +439,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
437
439
  {
438
440
  key: "_proxyStateBeforeSetCallback",
439
441
  value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
440
- var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
442
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
441
443
  // 找不到控件说明不是改动控件上的字段,直接通过
442
444
  if (!instance) {
443
445
  return newValue;
@@ -487,8 +489,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
487
489
  key: "_handlerArrayUpdate",
488
490
  value: function _handlerArrayUpdate(state, key, type, args, result) {
489
491
  var _this = this;
490
- var instanceItem = findItem(key, this);
491
- var subtable = instanceItem.instance;
492
+ var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
492
493
  // if (!(subtable instanceof RuntimeListControl)) return
493
494
  if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
494
495
  // 新增多行方法
@@ -519,7 +520,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
519
520
  createdNewRows = createRows(newRowLengths);
520
521
  createdNewRowsData = args;
521
522
  (_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
522
- this.runtime.getFlatInstances();
523
523
  break;
524
524
  case 'splice':
525
525
  if (args.length > 2) {
@@ -537,7 +537,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
537
537
  start,
538
538
  replace
539
539
  ].concat(_to_consumable_array(createdNewRows)));
540
- this.runtime.getFlatInstances();
541
540
  // newValues.forEach((item: any, index) => {
542
541
  // let newIndex = start + index
543
542
  // this.setStates(item, newIndex, options)
@@ -553,14 +552,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
553
552
  isDeleteLastOne = true;
554
553
  }
555
554
  (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
556
- this.runtime.getFlatInstances();
557
555
  }
558
556
  break;
559
557
  default:
560
558
  var // @ts-ignore
561
559
  _subtable_children3;
562
560
  (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
563
- this.runtime.getFlatInstances();
564
561
  break;
565
562
  }
566
563
  if (type === 'splice') {
@@ -575,12 +572,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
575
572
  }
576
573
  var subtableData = this.getState(subtable.id);
577
574
  this._handlerSubtableUpdateUid(subtableData);
575
+ this.runtime.getFlatInstances();
576
+ var rowIndexs = createdNewRows.map(function(item) {
577
+ var _item_children_, _item_children;
578
+ var subControl = item === null || item === void 0 ? void 0 : (_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.children[0];
579
+ return _this.getInstanceRowIndex(subControl);
580
+ });
578
581
  this.emit('list-change', {
579
582
  instance: subtable,
580
583
  value: subtableData,
581
584
  options: Object.assign({}, options, {
582
585
  changed: createdNewRows,
583
586
  data: createdNewRowsData,
587
+ rowIndexs: rowIndexs,
584
588
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
585
589
  jsonValue: JSON.stringify(subtableData),
586
590
  isDeleteLastOne: isDeleteLastOne,
@@ -609,11 +613,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
609
613
  {
610
614
  key: "_handlerObjectUpdate",
611
615
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
612
- var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
616
+ var _this = this;
617
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
613
618
  if (!instance) {
614
619
  return;
615
620
  }
616
- var index = rowIndex;
621
+ var index = this.getInstanceRowIndex(instance);
617
622
  var options = eventOptionsTemp || {};
618
623
  // if (instance instanceof RuntimeListControl) {
619
624
  if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
@@ -629,7 +634,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
629
634
  row && newRows.push(row);
630
635
  }
631
636
  (_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
632
- this.runtime.getFlatInstances();
633
637
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
634
638
  // for (let i = 0; i < newValue.length; i++) {
635
639
  // this.setStates(newValue[i], i, options)
@@ -637,8 +641,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
637
641
  var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
638
642
  if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
639
643
  deleted = [];
640
- }
644
+ } else {}
645
+ this.runtime.getFlatInstances();
641
646
  this._handlerSubtableUpdateUid(newValue);
647
+ var rowIndexs = newRows.map(function(item) {
648
+ var _item_children_, _item_children;
649
+ var subControl = item === null || item === void 0 ? void 0 : (_item_children = item.children) === null || _item_children === void 0 ? void 0 : (_item_children_ = _item_children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.children[0];
650
+ return _this.getInstanceRowIndex(subControl);
651
+ });
642
652
  this.emit('list-change', {
643
653
  instance: instance,
644
654
  value: value,
@@ -646,6 +656,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
646
656
  // @ts-ignore
647
657
  changed: newRows,
648
658
  data: newValue,
659
+ rowIndexs: rowIndexs,
649
660
  deleted: deleted,
650
661
  // deleted: oldValue ?? [],
651
662
  type: 'push',
@@ -961,8 +972,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
961
972
  key: "setState",
962
973
  value: function setState(controlId, value, rowIndex, options) {
963
974
  eventOptionsTemp = options;
975
+ // @i18n-translate-ignore
964
976
  this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
965
977
  this.store.setState(controlId, value, rowIndex);
978
+ // @i18n-translate-ignore
966
979
  this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
967
980
  eventOptionsTemp = null;
968
981
  }
@@ -996,50 +1009,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
996
1009
  });
997
1010
  }
998
1011
  },
999
- {
1000
- //理想-获取表单头部信息
1001
- key: "getTitleField",
1002
- value: function getTitleField(key) {
1003
- var titleData = Object.values(this.store.state).filter(function(a) {
1004
- return a.submit_user;
1005
- })[0];
1006
- if (key) {
1007
- return titleData[key];
1008
- } else {
1009
- return titleData;
1010
- }
1011
- }
1012
- },
1013
- {
1014
- //理想-获取系统字段
1015
- key: "getSystemField",
1016
- value: function getSystemField(key) {
1017
- var _this_externalParams;
1018
- var systemCodesMap = [
1019
- 'creator',
1020
- 'process_location',
1021
- 'create_time',
1022
- 'uid',
1023
- 'update_time',
1024
- 'process_status',
1025
- 'process_instance_id',
1026
- 'process_key'
1027
- ];
1028
- var arr = ((_this_externalParams = this.externalParams) === null || _this_externalParams === void 0 ? void 0 : _this_externalParams.data.data_set.values.filter(function(a) {
1029
- return systemCodesMap.some(function(k) {
1030
- return k == a.code;
1031
- });
1032
- })) || [];
1033
- if (key) {
1034
- var _arr_filter_;
1035
- return (_arr_filter_ = arr.filter(function(a) {
1036
- return a.code == key;
1037
- })[0]) === null || _arr_filter_ === void 0 ? void 0 : _arr_filter_.value;
1038
- } else {
1039
- return arr;
1040
- }
1041
- }
1042
- },
1043
1012
  {
1044
1013
  /**
1045
1014
  * 通过dataCode和fieldCode来获取控件的值
@@ -1117,27 +1086,31 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1117
1086
  var _controlIdMapping_key2;
1118
1087
  obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
1119
1088
  } 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) {
1120
- var _controlIdMapping_key3;
1121
- // 明细字表只循环一层明细子表未递归
1122
- obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
1123
- var objChi = {};
1124
- for(var keyChi in item){
1125
- var _controlIdMapping_key_children_keyChi;
1126
- var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
1127
- //未绑定字段的控件,直接抛弃
1128
- if (fieldCode !== '') {
1129
- if (fieldCode) {
1130
- objChi[fieldCode] = item[keyChi];
1131
- } else {
1132
- for(var keyChi1 in item[keyChi]){
1133
- var _controlIdMapping_key_children_keyChi1;
1134
- objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
1089
+ if (!Array.isArray(getFieldData[key])) {
1090
+ // obj[controlIdMapping[key]?.dataBind.dataCode] = ''
1091
+ } else {
1092
+ var _controlIdMapping_key3, _getFieldData_key;
1093
+ // 明细字表只循环一层明细子表未递归
1094
+ obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = (_getFieldData_key = getFieldData[key]) === null || _getFieldData_key === void 0 ? void 0 : _getFieldData_key.map(function(item) {
1095
+ var objChi = {};
1096
+ for(var keyChi in item){
1097
+ var _controlIdMapping_key_children_keyChi;
1098
+ var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
1099
+ //未绑定字段的控件,直接抛弃
1100
+ if (fieldCode !== '') {
1101
+ if (fieldCode) {
1102
+ objChi[fieldCode] = item[keyChi];
1103
+ } else {
1104
+ for(var keyChi1 in item[keyChi]){
1105
+ var _controlIdMapping_key_children_keyChi1;
1106
+ objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
1107
+ }
1135
1108
  }
1136
1109
  }
1137
1110
  }
1138
- }
1139
- return objChi;
1140
- });
1111
+ return objChi;
1112
+ });
1113
+ }
1141
1114
  } else if (controlIdMapping[key]) {
1142
1115
  // 兼容一个控件需要绑定多个字段的情况
1143
1116
  for(var keyChi in getFieldData[key]){
@@ -1287,6 +1260,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1287
1260
  */ key: "setData",
1288
1261
  value: function setData(dataSet, options) {
1289
1262
  var _this = this;
1263
+ // @i18n-translate-ignore
1290
1264
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1291
1265
  var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
1292
1266
  var newState = this.store.defaultState;
@@ -1408,14 +1382,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1408
1382
  }
1409
1383
  }
1410
1384
  });
1385
+ // @i18n-translate-ignore
1411
1386
  _this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1412
1387
  }
1413
1388
  }
1414
1389
  });
1390
+ // @i18n-translate-ignore
1415
1391
  this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
1416
1392
  this.setStates(newState, undefined, _object_spread({
1417
1393
  setData: true
1418
1394
  }, options));
1395
+ this.runtime.getFlatInstances();
1396
+ // @i18n-translate-ignore
1419
1397
  this.debugLog("engine setData方法执行完成。");
1420
1398
  }
1421
1399
  },
@@ -1520,12 +1498,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1520
1498
  var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1521
1499
  if (header) {
1522
1500
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1523
- if (instances.length) {
1524
- var instance = instances[0];
1525
- var headerInstance = this.findSubtableHeadersControl(instance.id);
1526
- if (headerInstance !== undefined) {
1527
- instances.unshift(headerInstance);
1528
- }
1501
+ // if (instances.length) {
1502
+ // const instance: RuntimeControl = instances[0]
1503
+ // const headerInstance = this.findSubtableHeadersControl(instance.id)
1504
+ // if (headerInstance !== undefined) {
1505
+ // instances.unshift(headerInstance)
1506
+ // }
1507
+ // }
1508
+ var headerInstance = this.findSubtableHeadersControl(controlId);
1509
+ if (headerInstance !== undefined) {
1510
+ instances.unshift(headerInstance);
1529
1511
  }
1530
1512
  }
1531
1513
  // @ts-ignore
@@ -1542,6 +1524,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1542
1524
  var instances = this.getInstances(instance, rowIndex === -1);
1543
1525
  instances.map(function(_instance) {
1544
1526
  if (_instance) {
1527
+ // @i18n-translate-ignore
1545
1528
  _this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1546
1529
  updateValueFromKeys(_instance.props, props, value);
1547
1530
  _this.schemaEvent('schema-change', {
@@ -1562,6 +1545,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1562
1545
  if (!_instance) {
1563
1546
  return;
1564
1547
  }
1548
+ // @i18n-translate-ignore
1565
1549
  this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1566
1550
  updateValueFromKeys(_instance.props, props, value);
1567
1551
  this.schemaEvent('schema-change', {
@@ -1576,57 +1560,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1576
1560
  }
1577
1561
  }
1578
1562
  },
1579
- {
1580
- /**
1581
- * 前端二开新增方法,支持给多选控件动态赋值选项和默认值
1582
- * ctx.setInstance('zQX4ViR3c0', 'options', [{ label:'初级:N<2年', value: '初级' },{ label:'高级:N>2年', value: '高级' }]);
1583
- * ctx.setState('zQX4ViR3c0',['初级'])
1584
- * 将以上两个方法封装成一个新的方法setInstanceAndState
1585
- * ctx.setInstanceAndState('uexLafJeGH', 'options', [{ label:'初级:N<2年', value: '初级' ,checked: true},{ label:'初级:N>2年', value: '高级' }]);
1586
- * 可同时设置选项和默认值
1587
- * @param instance
1588
- * @param props
1589
- * @param value
1590
- * @param rowIndex
1591
- */ key: "setInstanceAndState",
1592
- value: function setInstanceAndState(instance, props, value, rowIndex) {
1593
- this.setInstance(instance, props, value, rowIndex);
1594
- if (value && Array.isArray(value)) {
1595
- var stateValues = [];
1596
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1597
- try {
1598
- for(var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1599
- var item = _step.value;
1600
- if (item.checked) {
1601
- stateValues.push(item.value);
1602
- }
1603
- }
1604
- } catch (err) {
1605
- _didIteratorError = true;
1606
- _iteratorError = err;
1607
- } finally{
1608
- try {
1609
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1610
- _iterator.return();
1611
- }
1612
- } finally{
1613
- if (_didIteratorError) {
1614
- throw _iteratorError;
1615
- }
1616
- }
1617
- }
1618
- if (stateValues.length > 0) {
1619
- var instanceId = '';
1620
- if (typeof instance !== 'string') {
1621
- instanceId = instance.id;
1622
- } else {
1623
- instanceId = instance;
1624
- }
1625
- this.setState(instanceId, stateValues, rowIndex);
1626
- }
1627
- }
1628
- }
1629
- },
1630
1563
  {
1631
1564
  key: "getControlIdMapping",
1632
1565
  value: function getControlIdMapping() {
@@ -1641,7 +1574,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1641
1574
  }
1642
1575
  var mapping = this.store.dataBindMapping[dataCode];
1643
1576
  if (!mapping) {
1644
- warn("No corresponding dataCode=".concat(dataCode, " was found"));
1577
+ // warn(`No corresponding dataCode=${dataCode} was found`)
1645
1578
  return;
1646
1579
  }
1647
1580
  if (!fieldCode) {
@@ -1651,7 +1584,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1651
1584
  return item.fieldCode === fieldCode;
1652
1585
  });
1653
1586
  if (!dataBindMapping) {
1654
- warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
1587
+ // warn(`No corresponding fieldCode=${fieldCode} was found`)
1655
1588
  return;
1656
1589
  }
1657
1590
  return dataBindMapping;
@@ -110,6 +110,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
110
110
  var instanceMap = {};
111
111
  var controlParentIdMap = {};
112
112
  loop(this._instance, '', function(item, parentId) {
113
+ var _item_parent;
113
114
  // 3.4.1 避免将subtable-row 放到 _flatInstances 中
114
115
  //4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
115
116
  // if (item.type === 'subtable-row' || item.type === 'subtable-column') {
@@ -129,6 +130,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
129
130
  }
130
131
  }
131
132
  instances.push(item);
133
+ if (((_item_parent = item.parent) === null || _item_parent === void 0 ? void 0 : _item_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN && item.parent.parent === undefined) {
134
+ return;
135
+ }
132
136
  instanceMap[item.id].push(item);
133
137
  });
134
138
  this._flatInstances = instances;
@@ -277,9 +281,9 @@ function loop(control, parentId, callback) {
277
281
  if (hasHeaderOrFooterControl(item, 'headers')) {
278
282
  loop(item.props.headers, item.id, callback);
279
283
  }
280
- if (hasHeaderOrFooterControl(item, 'footers')) {
281
- loop(item.props.footers, item.id, callback);
282
- }
284
+ // if (hasHeaderOrFooterControl(item, 'footers')) {
285
+ // loop((item.props as any).footers, item.id, callback)
286
+ // }
283
287
  });
284
288
  }
285
289
  function hasHeaderOrFooterControl(control, checkType) {
@@ -54,7 +54,8 @@ var Store = /*#__PURE__*/ function() {
54
54
  _class_call_check(this, Store);
55
55
  _define_property(this, "emptyState", void 0);
56
56
  _define_property(this, "state", void 0);
57
- _define_property(this, "dataBindMapping", void 0); // 主要提供给二开使用
57
+ _define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
58
+ );
58
59
  _define_property(this, "controlIdMapping", void 0);
59
60
  _define_property(this, "subtableHeadersControlIdMapping", void 0);
60
61
  _define_property(this, "defaultState", void 0);
@@ -366,15 +367,17 @@ item) {
366
367
  Object.keys(item.props.dataBind).map(function(key) {
367
368
  var dataBind = item.props.dataBind;
368
369
  var dataCode = dataBind[key].dataCode;
369
- data[dataCode].fields.push({
370
- fieldCode: dataBind[key].fieldCode,
371
- controlId: item.id,
372
- dataBind: dataBind,
373
- dataViewId: [
374
- dataViewId,
375
- subtableId
376
- ]
377
- });
370
+ if (dataBind[key].fieldCode !== '') {
371
+ data[dataCode].fields.push({
372
+ fieldCode: dataBind[key].fieldCode,
373
+ controlId: item.id,
374
+ dataBind: dataBind,
375
+ dataViewId: [
376
+ dataViewId,
377
+ subtableId
378
+ ]
379
+ });
380
+ }
378
381
  });
379
382
  } else {
380
383
  if (data[item.props.dataBind.dataCode] === undefined) {
@@ -530,7 +530,7 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
530
530
  case FieldTypes.VARCHAR:
531
531
  case FieldTypes.TIMESTAMP:
532
532
  case FieldTypes.TEXT:
533
- case FieldTypes.RELATION:
533
+ // case FieldTypes.RELATION:
534
534
  case FieldTypes.AUTO_NUMBER:
535
535
  checker = new StringValueChecker();
536
536
  break;
@@ -28,7 +28,7 @@ function _unsupported_iterable_to_array(o, minLen) {
28
28
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
29
29
  }
30
30
  var cc = console;
31
- import { error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
31
+ import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
32
32
  var proxyArrayApi = [
33
33
  'splice',
34
34
  'push',
@@ -220,33 +220,40 @@ function flatInstanceForChildren(controls) {
220
220
  * 在flatInstance中通过key查找出对应的instance
221
221
  * @param flatInstance 拍平的instance数组
222
222
  * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
223
- * */ export function findItem(key, engine) {
224
- if (key === '') return {
225
- instance: undefined,
226
- rowIndex: undefined
227
- };
223
+ * */ export function findItem(flatInstance, key, instanceMap) {
224
+ if (key === '') return undefined;
228
225
  var keys = key.split('.');
229
- if (keys.length === 0) return {
230
- instance: undefined,
231
- rowIndex: undefined
232
- };
233
- var instanceIndex = keys.filter(function(item) {
234
- return !isNaN(item);
235
- }).at(-1);
236
- var findKeyIndex = instanceIndex ? keys.lastIndexOf(instanceIndex) : -1;
237
- var rowIndex;
238
- var controlId;
239
- if (findKeyIndex > -1) {
240
- rowIndex = Number(keys[findKeyIndex]);
241
- controlId = keys === null || keys === void 0 ? void 0 : keys[findKeyIndex + 1];
242
- } else {
243
- controlId = keys[1];
244
- }
245
- var proxyInstance = engine.getInstance(controlId, rowIndex);
246
- return {
247
- instance: proxyInstance,
248
- rowIndex: rowIndex
249
- };
226
+ if (keys.length === 0) return undefined;
227
+ var oneKey = keys[0];
228
+ var otherKeys = keys.slice(1);
229
+ // 3.4.1 优化速度,读取instanceMap
230
+ // cc.time('findItem flatInstance find')
231
+ // const initInstance = flatInstance.find((item) => item.id === oneKey)
232
+ // cc.log('🏠 findItem flatInstance find result', initInstance)
233
+ // cc.timeEnd('findItem flatInstance find')
234
+ // cc.time('findItem instanceMap match')
235
+ var initInstance = instanceMap[oneKey] ? instanceMap[oneKey][0] : undefined;
236
+ // cc.log('🏠 findItem instanceMap match result', initInstance)
237
+ // cc.timeEnd('findItem instanceMap match')
238
+ if (otherKeys.length === 0) return initInstance;
239
+ // @ts-ignore
240
+ return otherKeys.reduce(function(prevItem, key) {
241
+ var index = Number(key);
242
+ var isNotIndex = Number.isNaN(index);
243
+ if (isNotIndex && prevItem) {
244
+ var flatChildren = (prevItem === null || prevItem === void 0 ? void 0 : prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
245
+ var findEndItem = flatChildren === null || flatChildren === void 0 ? void 0 : flatChildren.find(function(item) {
246
+ return item.id === key;
247
+ });
248
+ // 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
249
+ return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
250
+ } else {
251
+ var _prevItem_children;
252
+ var _prevItem_children_index;
253
+ // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
254
+ return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
255
+ }
256
+ }, initInstance);
250
257
  }
251
258
  function getArrayNewValue(type, args) {
252
259
  if ([
@@ -156,11 +156,13 @@ import { EventLogic } from '@byteluck-fe/model-driven-shared';
156
156
  // }
157
157
  export var ControlsEventPlugin = /*#__PURE__*/ function() {
158
158
  "use strict";
159
- function ControlsEventPlugin(config) {
159
+ function ControlsEventPlugin(config, customEvents) {
160
160
  _class_call_check(this, ControlsEventPlugin);
161
161
  _define_property(this, "config", void 0);
162
162
  _define_property(this, "engine", void 0);
163
+ _define_property(this, "customEvents", void 0);
163
164
  this.config = config;
165
+ this.customEvents = customEvents;
164
166
  }
165
167
  _create_class(ControlsEventPlugin, [
166
168
  {
@@ -197,6 +199,14 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
197
199
  _this.engineAddEventListener(eventItem.code, eventItem.key);
198
200
  }
199
201
  });
202
+ //注册自定义组件事件
203
+ this.customEvents.map(function(item) {
204
+ var key = item.key;
205
+ if (item.namespace !== undefined && item.namespace !== null && item.namespace !== '') {
206
+ key = item.namespace + ':' + item.key;
207
+ }
208
+ _this.engineAddEventListener(key, key);
209
+ });
200
210
  }
201
211
  },
202
212
  {