@byteluck-fe/model-driven-engine 4.37.0-lx2 → 6.1.0-1-beta.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.
@@ -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,
@@ -324,8 +324,9 @@ function _ts_generator(thisArg, body) {
324
324
  };
325
325
  }
326
326
  }
327
+ import { getLocaleText } from '@byteluck-fe/locale-message';
327
328
  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';
329
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
329
330
  import { Runtime } from './Runtime';
330
331
  import { Store } from './Store';
331
332
  import { findItem, proxyState } from './proxyState';
@@ -351,18 +352,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
351
352
  _this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
352
353
  _define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
353
354
  // public worker: OkWorker
354
- _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
355
+ _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
356
  _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
357
  _this.$options = Object.freeze(props);
357
358
  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);
359
+ 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
360
  _this.debug = debug;
361
361
  _this.runtime = new Runtime({
362
362
  schema: schema,
363
363
  beforeCreateInstance: beforeCreateInstance
364
364
  });
365
365
  _this.externalParams = externalParams;
366
+ _this.children = children;
366
367
  _this.store = new Store({
367
368
  instance: _this.runtime.instance
368
369
  });
@@ -405,6 +406,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
405
406
  {
406
407
  key: "mount",
407
408
  value: function mount() {
409
+ // @i18n-translate-ignore
408
410
  this.debugLog("engine的mount方法开始调用");
409
411
  var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
410
412
  this._handlerProxyState();
@@ -412,6 +414,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
412
414
  this.applyPlugins();
413
415
  // 触发所有控件的默认值的change事件
414
416
  this.setStates(this.getState());
417
+ // @i18n-translate-ignore
415
418
  this.debugLog("engine的mount方法调用结束");
416
419
  if (this.debug && typeof window !== 'undefined') {
417
420
  // @ts-ignore
@@ -437,7 +440,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
437
440
  {
438
441
  key: "_proxyStateBeforeSetCallback",
439
442
  value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
440
- var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
443
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
441
444
  // 找不到控件说明不是改动控件上的字段,直接通过
442
445
  if (!instance) {
443
446
  return newValue;
@@ -487,8 +490,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
487
490
  key: "_handlerArrayUpdate",
488
491
  value: function _handlerArrayUpdate(state, key, type, args, result) {
489
492
  var _this = this;
490
- var instanceItem = findItem(key, this);
491
- var subtable = instanceItem.instance;
493
+ var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
492
494
  // if (!(subtable instanceof RuntimeListControl)) return
493
495
  if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
494
496
  // 新增多行方法
@@ -519,7 +521,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
519
521
  createdNewRows = createRows(newRowLengths);
520
522
  createdNewRowsData = args;
521
523
  (_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
522
- this.runtime.getFlatInstances();
523
524
  break;
524
525
  case 'splice':
525
526
  if (args.length > 2) {
@@ -537,7 +538,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
537
538
  start,
538
539
  replace
539
540
  ].concat(_to_consumable_array(createdNewRows)));
540
- this.runtime.getFlatInstances();
541
541
  // newValues.forEach((item: any, index) => {
542
542
  // let newIndex = start + index
543
543
  // this.setStates(item, newIndex, options)
@@ -553,14 +553,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
553
553
  isDeleteLastOne = true;
554
554
  }
555
555
  (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
556
- this.runtime.getFlatInstances();
557
556
  }
558
557
  break;
559
558
  default:
560
559
  var // @ts-ignore
561
560
  _subtable_children3;
562
561
  (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
563
- this.runtime.getFlatInstances();
564
562
  break;
565
563
  }
566
564
  if (type === 'splice') {
@@ -575,12 +573,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
575
573
  }
576
574
  var subtableData = this.getState(subtable.id);
577
575
  this._handlerSubtableUpdateUid(subtableData);
576
+ this.runtime.getFlatInstances();
577
+ var rowIndexs = createdNewRows.map(function(item) {
578
+ var _item_children_, _item_children;
579
+ 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];
580
+ return _this.getInstanceRowIndex(subControl);
581
+ });
578
582
  this.emit('list-change', {
579
583
  instance: subtable,
580
584
  value: subtableData,
581
585
  options: Object.assign({}, options, {
582
586
  changed: createdNewRows,
583
587
  data: createdNewRowsData,
588
+ rowIndexs: rowIndexs,
584
589
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
585
590
  jsonValue: JSON.stringify(subtableData),
586
591
  isDeleteLastOne: isDeleteLastOne,
@@ -609,11 +614,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
609
614
  {
610
615
  key: "_handlerObjectUpdate",
611
616
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
612
- var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
617
+ var _this = this;
618
+ var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
613
619
  if (!instance) {
614
620
  return;
615
621
  }
616
- var index = rowIndex;
622
+ var index = this.getInstanceRowIndex(instance);
617
623
  var options = eventOptionsTemp || {};
618
624
  // if (instance instanceof RuntimeListControl) {
619
625
  if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
@@ -629,7 +635,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
629
635
  row && newRows.push(row);
630
636
  }
631
637
  (_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
632
- this.runtime.getFlatInstances();
633
638
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
634
639
  // for (let i = 0; i < newValue.length; i++) {
635
640
  // this.setStates(newValue[i], i, options)
@@ -637,8 +642,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
637
642
  var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
638
643
  if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
639
644
  deleted = [];
640
- }
645
+ } else {}
646
+ this.runtime.getFlatInstances();
641
647
  this._handlerSubtableUpdateUid(newValue);
648
+ var rowIndexs = newRows.map(function(item) {
649
+ var _item_children_, _item_children;
650
+ 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];
651
+ return _this.getInstanceRowIndex(subControl);
652
+ });
642
653
  this.emit('list-change', {
643
654
  instance: instance,
644
655
  value: value,
@@ -646,6 +657,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
646
657
  // @ts-ignore
647
658
  changed: newRows,
648
659
  data: newValue,
660
+ rowIndexs: rowIndexs,
649
661
  deleted: deleted,
650
662
  // deleted: oldValue ?? [],
651
663
  type: 'push',
@@ -961,8 +973,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
961
973
  key: "setState",
962
974
  value: function setState(controlId, value, rowIndex, options) {
963
975
  eventOptionsTemp = options;
976
+ // @i18n-translate-ignore
964
977
  this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
965
978
  this.store.setState(controlId, value, rowIndex);
979
+ // @i18n-translate-ignore
966
980
  this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
967
981
  eventOptionsTemp = null;
968
982
  }
@@ -996,50 +1010,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
996
1010
  });
997
1011
  }
998
1012
  },
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
1013
  {
1044
1014
  /**
1045
1015
  * 通过dataCode和fieldCode来获取控件的值
@@ -1117,27 +1087,31 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1117
1087
  var _controlIdMapping_key2;
1118
1088
  obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
1119
1089
  } 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];
1090
+ if (!Array.isArray(getFieldData[key])) {
1091
+ // obj[controlIdMapping[key]?.dataBind.dataCode] = ''
1092
+ } else {
1093
+ var _controlIdMapping_key3, _getFieldData_key;
1094
+ // 明细字表只循环一层明细子表未递归
1095
+ 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) {
1096
+ var objChi = {};
1097
+ for(var keyChi in item){
1098
+ var _controlIdMapping_key_children_keyChi;
1099
+ 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;
1100
+ //未绑定字段的控件,直接抛弃
1101
+ if (fieldCode !== '') {
1102
+ if (fieldCode) {
1103
+ objChi[fieldCode] = item[keyChi];
1104
+ } else {
1105
+ for(var keyChi1 in item[keyChi]){
1106
+ var _controlIdMapping_key_children_keyChi1;
1107
+ 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];
1108
+ }
1135
1109
  }
1136
1110
  }
1137
1111
  }
1138
- }
1139
- return objChi;
1140
- });
1112
+ return objChi;
1113
+ });
1114
+ }
1141
1115
  } else if (controlIdMapping[key]) {
1142
1116
  // 兼容一个控件需要绑定多个字段的情况
1143
1117
  for(var keyChi in getFieldData[key]){
@@ -1287,6 +1261,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1287
1261
  */ key: "setData",
1288
1262
  value: function setData(dataSet, options) {
1289
1263
  var _this = this;
1264
+ // @i18n-translate-ignore
1290
1265
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1291
1266
  var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
1292
1267
  var newState = this.store.defaultState;
@@ -1408,15 +1383,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1408
1383
  }
1409
1384
  }
1410
1385
  });
1386
+ // @i18n-translate-ignore
1411
1387
  _this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1412
1388
  }
1413
1389
  }
1414
1390
  });
1391
+ // @i18n-translate-ignore
1415
1392
  this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
1416
1393
  this.setStates(newState, undefined, _object_spread({
1417
1394
  setData: true
1418
1395
  }, options));
1419
- this.debugLog("engine setData方法执行完成。");
1396
+ this.runtime.getFlatInstances();
1397
+ // @i18n-translate-ignore
1398
+ this.debugLog(getLocaleText('CMD.b44b1751969061759'));
1420
1399
  }
1421
1400
  },
1422
1401
  {
@@ -1520,12 +1499,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1520
1499
  var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1521
1500
  if (header) {
1522
1501
  // 如果能从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
- }
1502
+ // if (instances.length) {
1503
+ // const instance: RuntimeControl = instances[0]
1504
+ // const headerInstance = this.findSubtableHeadersControl(instance.id)
1505
+ // if (headerInstance !== undefined) {
1506
+ // instances.unshift(headerInstance)
1507
+ // }
1508
+ // }
1509
+ var headerInstance = this.findSubtableHeadersControl(controlId);
1510
+ if (headerInstance !== undefined) {
1511
+ instances.unshift(headerInstance);
1529
1512
  }
1530
1513
  }
1531
1514
  // @ts-ignore
@@ -1542,6 +1525,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1542
1525
  var instances = this.getInstances(instance, rowIndex === -1);
1543
1526
  instances.map(function(_instance) {
1544
1527
  if (_instance) {
1528
+ // @i18n-translate-ignore
1545
1529
  _this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1546
1530
  updateValueFromKeys(_instance.props, props, value);
1547
1531
  _this.schemaEvent('schema-change', {
@@ -1562,6 +1546,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1562
1546
  if (!_instance) {
1563
1547
  return;
1564
1548
  }
1549
+ // @i18n-translate-ignore
1565
1550
  this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
1566
1551
  updateValueFromKeys(_instance.props, props, value);
1567
1552
  this.schemaEvent('schema-change', {
@@ -1576,57 +1561,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1576
1561
  }
1577
1562
  }
1578
1563
  },
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
1564
  {
1631
1565
  key: "getControlIdMapping",
1632
1566
  value: function getControlIdMapping() {
@@ -1641,7 +1575,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1641
1575
  }
1642
1576
  var mapping = this.store.dataBindMapping[dataCode];
1643
1577
  if (!mapping) {
1644
- warn("No corresponding dataCode=".concat(dataCode, " was found"));
1578
+ // warn(`No corresponding dataCode=${dataCode} was found`)
1645
1579
  return;
1646
1580
  }
1647
1581
  if (!fieldCode) {
@@ -1651,7 +1585,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1651
1585
  return item.fieldCode === fieldCode;
1652
1586
  });
1653
1587
  if (!dataBindMapping) {
1654
- warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
1588
+ // warn(`No corresponding fieldCode=${fieldCode} was found`)
1655
1589
  return;
1656
1590
  }
1657
1591
  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
  {