@byteluck-fe/model-driven-engine 3.0.0-beta.2 → 4.34.0-lx1

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.
@@ -329,7 +329,7 @@ function _ts_generator(thisArg, body) {
329
329
  }
330
330
  }
331
331
  import { isDataBind } from '@byteluck-fe/model-driven-core';
332
- import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
332
+ import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
333
333
  import { Runtime } from './Runtime';
334
334
  import { Store } from './Store';
335
335
  import { findItem, proxyState } from './proxyState';
@@ -355,18 +355,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
355
355
  _this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
356
356
  _define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
357
357
  // public worker: OkWorker
358
- _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), _define_property(_this, "children", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
358
+ _define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
359
359
  _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);
360
360
  _this.$options = Object.freeze(props);
361
361
  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,
362
- 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;
362
+ 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;
363
+ RulesMessage.setLocale(language);
363
364
  _this.debug = debug;
364
365
  _this.runtime = new Runtime({
365
366
  schema: schema,
366
367
  beforeCreateInstance: beforeCreateInstance
367
368
  });
368
369
  _this.externalParams = externalParams;
369
- _this.children = children;
370
370
  _this.store = new Store({
371
371
  instance: _this.runtime.instance
372
372
  });
@@ -441,7 +441,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
441
441
  {
442
442
  key: "_proxyStateBeforeSetCallback",
443
443
  value: function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
444
- var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
444
+ var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
445
445
  // 找不到控件说明不是改动控件上的字段,直接通过
446
446
  if (!instance) {
447
447
  return newValue;
@@ -491,7 +491,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
491
491
  key: "_handlerArrayUpdate",
492
492
  value: function _handlerArrayUpdate(state, key, type, args, result) {
493
493
  var _this = this;
494
- var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
494
+ var instanceItem = findItem(key, this);
495
+ var subtable = instanceItem.instance;
495
496
  // if (!(subtable instanceof RuntimeListControl)) return
496
497
  if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
497
498
  // 新增多行方法
@@ -522,6 +523,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
522
523
  createdNewRows = createRows(newRowLengths);
523
524
  createdNewRowsData = args;
524
525
  (_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
526
+ this.runtime.getFlatInstances();
525
527
  break;
526
528
  case 'splice':
527
529
  if (args.length > 2) {
@@ -539,6 +541,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
539
541
  start,
540
542
  replace
541
543
  ].concat(_to_consumable_array(createdNewRows)));
544
+ this.runtime.getFlatInstances();
542
545
  // newValues.forEach((item: any, index) => {
543
546
  // let newIndex = start + index
544
547
  // this.setStates(item, newIndex, options)
@@ -554,12 +557,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
554
557
  isDeleteLastOne = true;
555
558
  }
556
559
  (_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _to_consumable_array(args));
560
+ this.runtime.getFlatInstances();
557
561
  }
558
562
  break;
559
563
  default:
560
564
  var // @ts-ignore
561
565
  _subtable_children3;
562
566
  (_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
567
+ this.runtime.getFlatInstances();
563
568
  break;
564
569
  }
565
570
  if (type === 'splice') {
@@ -574,19 +579,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
574
579
  }
575
580
  var subtableData = this.getState(subtable.id);
576
581
  this._handlerSubtableUpdateUid(subtableData);
577
- this.runtime.getFlatInstances();
578
- var rowIndexs = createdNewRows.map(function(item) {
579
- var _item_children_, _item_children;
580
- 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];
581
- return _this.getInstanceRowIndex(subControl);
582
- });
583
582
  this.emit('list-change', {
584
583
  instance: subtable,
585
584
  value: subtableData,
586
585
  options: Object.assign({}, options, {
587
586
  changed: createdNewRows,
588
587
  data: createdNewRowsData,
589
- rowIndexs: rowIndexs,
590
588
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
591
589
  jsonValue: JSON.stringify(subtableData),
592
590
  isDeleteLastOne: isDeleteLastOne,
@@ -615,12 +613,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
615
613
  {
616
614
  key: "_handlerObjectUpdate",
617
615
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
618
- var _this = this;
619
- var instance = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
616
+ var _findItem = findItem(key, this), instance = _findItem.instance, rowIndex = _findItem.rowIndex;
620
617
  if (!instance) {
621
618
  return;
622
619
  }
623
- var index = this.getInstanceRowIndex(instance);
620
+ var index = rowIndex;
624
621
  var options = eventOptionsTemp || {};
625
622
  // if (instance instanceof RuntimeListControl) {
626
623
  if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
@@ -636,6 +633,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
636
633
  row && newRows.push(row);
637
634
  }
638
635
  (_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
636
+ this.runtime.getFlatInstances();
639
637
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
640
638
  // for (let i = 0; i < newValue.length; i++) {
641
639
  // this.setStates(newValue[i], i, options)
@@ -643,14 +641,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
643
641
  var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
644
642
  if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
645
643
  deleted = [];
646
- } else {}
647
- this.runtime.getFlatInstances();
644
+ }
648
645
  this._handlerSubtableUpdateUid(newValue);
649
- var rowIndexs = newRows.map(function(item) {
650
- var _item_children_, _item_children;
651
- 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];
652
- return _this.getInstanceRowIndex(subControl);
653
- });
654
646
  this.emit('list-change', {
655
647
  instance: instance,
656
648
  value: value,
@@ -658,7 +650,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
658
650
  // @ts-ignore
659
651
  changed: newRows,
660
652
  data: newValue,
661
- rowIndexs: rowIndexs,
662
653
  deleted: deleted,
663
654
  // deleted: oldValue ?? [],
664
655
  type: 'push',
@@ -1009,6 +1000,50 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1009
1000
  });
1010
1001
  }
1011
1002
  },
1003
+ {
1004
+ //理想-获取表单头部信息
1005
+ key: "getTitleField",
1006
+ value: function getTitleField(key) {
1007
+ var titleData = Object.values(this.store.state).filter(function(a) {
1008
+ return a.submit_user;
1009
+ })[0];
1010
+ if (key) {
1011
+ return titleData[key];
1012
+ } else {
1013
+ return titleData;
1014
+ }
1015
+ }
1016
+ },
1017
+ {
1018
+ //理想-获取系统字段
1019
+ key: "getSystemField",
1020
+ value: function getSystemField(key) {
1021
+ var _this_externalParams;
1022
+ var systemCodesMap = [
1023
+ 'creator',
1024
+ 'process_location',
1025
+ 'create_time',
1026
+ 'uid',
1027
+ 'update_time',
1028
+ 'process_status',
1029
+ 'process_instance_id',
1030
+ 'process_key'
1031
+ ];
1032
+ var arr = ((_this_externalParams = this.externalParams) === null || _this_externalParams === void 0 ? void 0 : _this_externalParams.data.data_set.values.filter(function(a) {
1033
+ return systemCodesMap.some(function(k) {
1034
+ return k == a.code;
1035
+ });
1036
+ })) || [];
1037
+ if (key) {
1038
+ var _arr_filter_;
1039
+ return (_arr_filter_ = arr.filter(function(a) {
1040
+ return a.code == key;
1041
+ })[0]) === null || _arr_filter_ === void 0 ? void 0 : _arr_filter_.value;
1042
+ } else {
1043
+ return arr;
1044
+ }
1045
+ }
1046
+ },
1012
1047
  {
1013
1048
  /**
1014
1049
  * 通过dataCode和fieldCode来获取控件的值
@@ -1086,31 +1121,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1086
1121
  var _controlIdMapping_key2;
1087
1122
  obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
1088
1123
  } 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) {
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
- }
1124
+ var _controlIdMapping_key3;
1125
+ // 明细字表只循环一层明细子表未递归
1126
+ obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
1127
+ var objChi = {};
1128
+ for(var keyChi in item){
1129
+ var _controlIdMapping_key_children_keyChi;
1130
+ 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;
1131
+ //未绑定字段的控件,直接抛弃
1132
+ if (fieldCode !== '') {
1133
+ if (fieldCode) {
1134
+ objChi[fieldCode] = item[keyChi];
1135
+ } else {
1136
+ for(var keyChi1 in item[keyChi]){
1137
+ var _controlIdMapping_key_children_keyChi1;
1138
+ 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
1139
  }
1109
1140
  }
1110
1141
  }
1111
- return objChi;
1112
- });
1113
- }
1142
+ }
1143
+ return objChi;
1144
+ });
1114
1145
  } else if (controlIdMapping[key]) {
1115
1146
  // 兼容一个控件需要绑定多个字段的情况
1116
1147
  for(var keyChi in getFieldData[key]){
@@ -1389,7 +1420,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1389
1420
  this.setStates(newState, undefined, _object_spread({
1390
1421
  setData: true
1391
1422
  }, options));
1392
- this.runtime.getFlatInstances();
1393
1423
  this.debugLog("engine setData方法执行完成。");
1394
1424
  }
1395
1425
  },
@@ -1494,16 +1524,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1494
1524
  var instances = Array.from(this.runtime.instanceMap[controlId] || []);
1495
1525
  if (header) {
1496
1526
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1497
- // if (instances.length) {
1498
- // const instance: RuntimeControl = instances[0]
1499
- // const headerInstance = this.findSubtableHeadersControl(instance.id)
1500
- // if (headerInstance !== undefined) {
1501
- // instances.unshift(headerInstance)
1502
- // }
1503
- // }
1504
- var headerInstance = this.findSubtableHeadersControl(controlId);
1505
- if (headerInstance !== undefined) {
1506
- instances.unshift(headerInstance);
1527
+ if (instances.length) {
1528
+ var instance = instances[0];
1529
+ var headerInstance = this.findSubtableHeadersControl(instance.id);
1530
+ if (headerInstance !== undefined) {
1531
+ instances.unshift(headerInstance);
1532
+ }
1507
1533
  }
1508
1534
  }
1509
1535
  // @ts-ignore
@@ -1568,7 +1594,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1568
1594
  }
1569
1595
  var mapping = this.store.dataBindMapping[dataCode];
1570
1596
  if (!mapping) {
1571
- // warn(`No corresponding dataCode=${dataCode} was found`)
1597
+ warn("No corresponding dataCode=".concat(dataCode, " was found"));
1572
1598
  return;
1573
1599
  }
1574
1600
  if (!fieldCode) {
@@ -1578,7 +1604,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1578
1604
  return item.fieldCode === fieldCode;
1579
1605
  });
1580
1606
  if (!dataBindMapping) {
1581
- // warn(`No corresponding fieldCode=${fieldCode} was found`)
1607
+ warn("No corresponding fieldCode=".concat(fieldCode, " was found"));
1582
1608
  return;
1583
1609
  }
1584
1610
  return dataBindMapping;
@@ -110,7 +110,6 @@ 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;
114
113
  // 3.4.1 避免将subtable-row 放到 _flatInstances 中
115
114
  //4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
116
115
  // if (item.type === 'subtable-row' || item.type === 'subtable-column') {
@@ -130,9 +129,6 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
130
129
  }
131
130
  }
132
131
  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
- }
136
132
  instanceMap[item.id].push(item);
137
133
  });
138
134
  this._flatInstances = instances;
@@ -281,9 +277,9 @@ function loop(control, parentId, callback) {
281
277
  if (hasHeaderOrFooterControl(item, 'headers')) {
282
278
  loop(item.props.headers, item.id, callback);
283
279
  }
284
- // if (hasHeaderOrFooterControl(item, 'footers')) {
285
- // loop((item.props as any).footers, item.id, callback)
286
- // }
280
+ if (hasHeaderOrFooterControl(item, 'footers')) {
281
+ loop(item.props.footers, item.id, callback);
282
+ }
287
283
  });
288
284
  }
289
285
  function hasHeaderOrFooterControl(control, checkType) {
@@ -367,17 +367,15 @@ item) {
367
367
  Object.keys(item.props.dataBind).map(function(key) {
368
368
  var dataBind = item.props.dataBind;
369
369
  var dataCode = dataBind[key].dataCode;
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
- }
370
+ data[dataCode].fields.push({
371
+ fieldCode: dataBind[key].fieldCode,
372
+ controlId: item.id,
373
+ dataBind: dataBind,
374
+ dataViewId: [
375
+ dataViewId,
376
+ subtableId
377
+ ]
378
+ });
381
379
  });
382
380
  } else {
383
381
  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 { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
31
+ import { error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
32
32
  var proxyArrayApi = [
33
33
  'splice',
34
34
  'push',
@@ -220,40 +220,33 @@ 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(flatInstance, key, instanceMap) {
224
- if (key === '') return undefined;
223
+ * */ export function findItem(key, engine) {
224
+ if (key === '') return {
225
+ instance: undefined,
226
+ rowIndex: undefined
227
+ };
225
228
  var keys = key.split('.');
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);
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
+ };
257
250
  }
258
251
  function getArrayNewValue(type, args) {
259
252
  if ([
@@ -160,13 +160,11 @@ import { EventLogic } from '@byteluck-fe/model-driven-shared';
160
160
  // }
161
161
  export var ControlsEventPlugin = /*#__PURE__*/ function() {
162
162
  "use strict";
163
- function ControlsEventPlugin(config, customEvents) {
163
+ function ControlsEventPlugin(config) {
164
164
  _class_call_check(this, ControlsEventPlugin);
165
165
  _define_property(this, "config", void 0);
166
166
  _define_property(this, "engine", void 0);
167
- _define_property(this, "customEvents", void 0);
168
167
  this.config = config;
169
- this.customEvents = customEvents;
170
168
  }
171
169
  _create_class(ControlsEventPlugin, [
172
170
  {
@@ -203,14 +201,6 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
203
201
  _this.engineAddEventListener(eventItem.code, eventItem.key);
204
202
  }
205
203
  });
206
- //注册自定义组件事件
207
- this.customEvents.map(function(item) {
208
- var key = item.key;
209
- if (item.namespace !== undefined && item.namespace !== null && item.namespace !== '') {
210
- key = item.namespace + ':' + item.key;
211
- }
212
- _this.engineAddEventListener(key, key);
213
- });
214
204
  }
215
205
  },
216
206
  {
@@ -1,8 +1,8 @@
1
1
  /*
2
2
  * @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
3
3
  * @Date: 2022-04-15 14:06:03
4
- * @LastEditors: SuperLuckyqi
5
- * @LastEditTime: 2024-11-08 11:17:53
4
+ * @LastEditors: zhaoxiaoyang zhaoxiaoyang@byteluck.com
5
+ * @LastEditTime: 2023-11-30 16:38:47
6
6
  * @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
7
7
  */ function _class_call_check(instance, Constructor) {
8
8
  if (!(instance instanceof Constructor)) {
@@ -39,13 +39,10 @@ function _define_property(obj, key, value) {
39
39
  export var StylePlugin = /*#__PURE__*/ function() {
40
40
  "use strict";
41
41
  function StylePlugin(config) {
42
- var isPC = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
43
42
  _class_call_check(this, StylePlugin);
44
43
  _define_property(this, "config", void 0);
45
44
  _define_property(this, "engine", void 0);
46
- _define_property(this, "isPc", void 0);
47
45
  this.config = config;
48
- this.isPc = isPC;
49
46
  }
50
47
  _create_class(StylePlugin, [
51
48
  {
@@ -56,16 +53,11 @@ export var StylePlugin = /*#__PURE__*/ function() {
56
53
  var _this_config_source;
57
54
  var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
58
55
  var style = document.createElement('style');
59
- style.className = 'edit-css-' + engine.id;
56
+ style.className = 'edit-css';
57
+ style.type = 'text/css';
58
+ style.innerHTML = compiledStyle;
60
59
  var dom = document.querySelector('head');
61
- dom === null || dom === void 0 ? void 0 : dom.appendChild(style);
62
- var cssStyleText;
63
- if (this.isPc) {
64
- cssStyleText = ".render-engine-".concat(engine.id, "{ ").concat(compiledStyle, " }");
65
- } else {
66
- cssStyleText = compiledStyle;
67
- }
68
- style.appendChild(document.createTextNode(cssStyleText));
60
+ dom.appendChild(style);
69
61
  }
70
62
  }
71
63
  ]);
@@ -6,8 +6,7 @@ export function loopFormControl(control, callback) {
6
6
  if (Array.isArray(control)) {
7
7
  control.map(function(item) {
8
8
  //TODO 此处需要再抽象一层 datagrid/datalist
9
- // if (item.type === CONTROL_TYPE.SUBTABLE) {
10
- if (item.controlType === CONTROL_BASE_TYPE.LIST) {
9
+ if (item.type === CONTROL_TYPE.SUBTABLE) {
11
10
  // @ts-ignore
12
11
  var children = []//item.getChildrenFormControl() as RuntimeFormControl[]
13
12
  ;