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

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
@@ -625,7 +630,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
625
630
  var index = this.getInstanceRowIndex(instance);
626
631
  var options = eventOptionsTemp || {};
627
632
  // if (instance instanceof RuntimeListControl) {
628
- if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
633
+ if (instance.controlType === CONTROL_BASE_TYPE.LIST && instance.type === CONTROL_TYPE.SUBTABLE) {
629
634
  var // @ts-ignore
630
635
  _instance_children;
631
636
  instance.children.length = 0;
@@ -643,6 +648,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
643
648
  // for (let i = 0; i < newValue.length; i++) {
644
649
  // this.setStates(newValue[i], i, options)
645
650
  // }
651
+ var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
652
+ if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
653
+ deleted = [];
654
+ }
646
655
  this.emit("list-change", {
647
656
  instance: instance,
648
657
  value: value,
@@ -650,7 +659,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
650
659
  // @ts-ignore
651
660
  changed: newRows,
652
661
  data: newValue,
653
- deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
662
+ deleted: deleted,
663
+ // deleted: oldValue ?? [],
664
+ type: "push"
654
665
  })
655
666
  });
656
667
  } else {
@@ -687,7 +698,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
687
698
  {
688
699
  key: "listControlCreateRow",
689
700
  value: function listControlCreateRow(instance, rowType) {
690
- var row = this.runtime.createControlInstance(rowType);
701
+ var row;
702
+ if (rowType === "subtable-row") {
703
+ row = {
704
+ children: [],
705
+ controlType: CONTROL_BASE_TYPE.LAYOUT,
706
+ id: genNonDuplicateId(),
707
+ type: "subtable-row",
708
+ props: {
709
+ caption: "",
710
+ isHide: false,
711
+ style: {
712
+ height: "",
713
+ heightConfig: "fill",
714
+ width: "",
715
+ widthConfig: "fill"
716
+ }
717
+ },
718
+ fieldType: undefined,
719
+ customEvents: [],
720
+ pageStatus: 0,
721
+ rules: [],
722
+ parent: undefined
723
+ };
724
+ } else {
725
+ row = this.runtime.createControlInstance(rowType);
726
+ }
691
727
  if (!row) return;
692
728
  // if (row instanceof RuntimeLayoutControl) {
693
729
  // @ts-ignore
@@ -697,8 +733,32 @@ var Engine = /*#__PURE__*/ function(Watcher) {
697
733
  var template = JSONCopy(instance.props.headers);
698
734
  // @ts-ignore
699
735
  var columns = this.createControl(template);
736
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
737
+ try {
738
+ for(var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
739
+ var column = _step.value;
740
+ if (!column.parent) {
741
+ this.runtime.resetInstanceParent(column, inst);
742
+ }
743
+ }
744
+ } catch (err) {
745
+ _didIteratorError = true;
746
+ _iteratorError = err;
747
+ } finally{
748
+ try {
749
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
750
+ _iterator.return();
751
+ }
752
+ } finally{
753
+ if (_didIteratorError) {
754
+ throw _iteratorError;
755
+ }
756
+ }
757
+ }
700
758
  (_inst_children = inst.children).push.apply(_inst_children, _to_consumable_array(columns));
701
759
  }
760
+ //@ts-ignore
761
+ row.parent = instance;
702
762
  return row;
703
763
  }
704
764
  },
@@ -818,6 +878,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
818
878
  return this.setInstance(instance, props, value, rowIndex);
819
879
  }
820
880
  },
881
+ {
882
+ key: "getRule",
883
+ value: function getRule(controlType, props) {
884
+ return Runtime.staticGetRules(controlType, props);
885
+ }
886
+ },
821
887
  {
822
888
  key: "getAllRules",
823
889
  value: function getAllRules(controlId) {
@@ -945,7 +1011,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
945
1011
  }
946
1012
  var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
947
1013
  var state = this.getState(controlId1, rowIndex);
948
- if (_instanceof(dataBind, ObjectDataBind)) {
1014
+ //if (dataBind instanceof ObjectDataBind) {
1015
+ if (!isDataBind(dataBind)) {
949
1016
  return Object.entries(dataBind).reduce(function(result, param) {
950
1017
  var _param = _sliced_to_array(param, 2), key = _param[0], dataBind = _param[1];
951
1018
  // objectDataBind的元素,跳过下一次赋值
@@ -1052,7 +1119,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1052
1119
  return;
1053
1120
  }
1054
1121
  var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
1055
- if (_instanceof(dataBind, ObjectDataBind)) {
1122
+ // if (dataBind instanceof ObjectDataBind) {
1123
+ if (!isDataBind(dataBind)) {
1056
1124
  var _JSONCopy;
1057
1125
  var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
1058
1126
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1094,7 +1162,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1094
1162
  return;
1095
1163
  }
1096
1164
  // 对象类型的值
1097
- if (_instanceof(dataBind, ObjectDataBind)) {
1165
+ // if (dataBind instanceof ObjectDataBind) {
1166
+ if (!isDataBind(dataBind)) {
1098
1167
  var _JSONCopy;
1099
1168
  var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
1100
1169
  // fieldCode不代表是key,所以需要找到对应的key
@@ -1124,7 +1193,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1124
1193
  value: function buildFields(dataCode, state) {
1125
1194
  var _this = this;
1126
1195
  var mapping = this.getDataBindMapping(dataCode);
1127
- if (!mapping) {
1196
+ if (!mapping || !mapping.fields) {
1128
1197
  return;
1129
1198
  }
1130
1199
  var skipKeys = [];
@@ -1138,7 +1207,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1138
1207
  return;
1139
1208
  }
1140
1209
  // 对象类型的值
1141
- if (_instanceof(dataBind, ObjectDataBind)) {
1210
+ // if (dataBind instanceof ObjectDataBind) {
1211
+ if (!isDataBind(dataBind)) {
1142
1212
  var oldState = _this.getEmptyState(controlId);
1143
1213
  // fieldCode不代表是key,所以需要找到对应的key
1144
1214
  result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
@@ -1167,7 +1237,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1167
1237
  value: function setData(dataSet, options) {
1168
1238
  var _this = this;
1169
1239
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1240
+ var onlySetData = options === null || options === void 0 ? void 0 : options.onlySetData;
1170
1241
  var newState = this.store.defaultState;
1242
+ if (onlySetData === true) {
1243
+ newState = {};
1244
+ }
1171
1245
  Object.keys(dataSet).map(function(dataCode) {
1172
1246
  var entity = dataSet[dataCode];
1173
1247
  if (Array.isArray(entity)) {
@@ -1184,24 +1258,34 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1184
1258
  } else {
1185
1259
  newState[mapping.dataViewId][mapping.controlId] = [];
1186
1260
  }
1261
+ var cacheEmptyState = {};
1262
+ var cacheFieldMapping = {};
1187
1263
  entity.map(function(row) {
1188
1264
  var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
1189
1265
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1190
1266
  ;
1191
1267
  Object.keys(row).map(function(fieldCode) {
1192
- var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
1193
1268
  if (skipKey.includes(fieldCode)) {
1194
1269
  return;
1195
1270
  }
1196
- var fieldMapping = (_this_store_dataBindMapping_dataCode = _this.store.dataBindMapping[dataCode]) === null || _this_store_dataBindMapping_dataCode === void 0 ? void 0 : (_this_store_dataBindMapping_dataCode_fields = _this_store_dataBindMapping_dataCode.fields) === null || _this_store_dataBindMapping_dataCode_fields === void 0 ? void 0 : _this_store_dataBindMapping_dataCode_fields.find(function(i) {
1197
- return i.fieldCode === fieldCode;
1198
- });
1271
+ if (cacheFieldMapping.hasOwnProperty(fieldCode) === false) {
1272
+ var _this_store_dataBindMapping_dataCode_fields, _this_store_dataBindMapping_dataCode;
1273
+ cacheFieldMapping[fieldCode] = (_this_store_dataBindMapping_dataCode = _this.store.dataBindMapping[dataCode]) === null || _this_store_dataBindMapping_dataCode === void 0 ? void 0 : (_this_store_dataBindMapping_dataCode_fields = _this_store_dataBindMapping_dataCode.fields) === null || _this_store_dataBindMapping_dataCode_fields === void 0 ? void 0 : _this_store_dataBindMapping_dataCode_fields.find(function(i) {
1274
+ return i.fieldCode === fieldCode;
1275
+ });
1276
+ }
1277
+ var fieldMapping = cacheFieldMapping[fieldCode];
1199
1278
  if (fieldMapping) {
1200
- if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
1279
+ if (// fieldMapping.dataBind instanceof DataBind &&
1280
+ isDataBind(fieldMapping.dataBind) && row[fieldCode] !== undefined) {
1201
1281
  newRow[fieldMapping.controlId] = row[fieldCode];
1202
- } else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
1203
- var _this_getEmptyState;
1204
- var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1282
+ // } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
1283
+ } else if (!isDataBind(fieldMapping.dataBind)) {
1284
+ if (cacheEmptyState.hasOwnProperty(fieldMapping.controlId) === false) {
1285
+ var _this_getEmptyState;
1286
+ cacheEmptyState[fieldMapping.controlId] = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
1287
+ }
1288
+ var objValue = JSONCopy(cacheEmptyState[fieldMapping.controlId]);
1205
1289
  Object.keys(fieldMapping.dataBind).map(function(key) {
1206
1290
  var dataBind = fieldMapping.dataBind[key];
1207
1291
  if (row[dataBind.fieldCode] !== undefined) {
@@ -1211,6 +1295,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1211
1295
  });
1212
1296
  newRow[fieldMapping.controlId] = objValue;
1213
1297
  }
1298
+ } else if (fieldCode === "uid" && row["uid"] !== undefined) {
1299
+ newRow["uid"] = row["uid"];
1214
1300
  }
1215
1301
  });
1216
1302
  newState[mapping.dataViewId][mapping.controlId].push(newRow);
@@ -1232,9 +1318,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1232
1318
  if (!newState[mapping.dataViewId[0]]) {
1233
1319
  newState[mapping.dataViewId[0]] = {};
1234
1320
  }
1235
- if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1321
+ if (// mapping.dataBind instanceof DataBind &&
1322
+ isDataBind(mapping.dataBind) && entity[fieldCode] !== undefined) {
1236
1323
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1237
- } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1324
+ // } else if (mapping.dataBind instanceof ObjectDataBind) {
1325
+ } else if (!isDataBind(mapping.dataBind)) {
1238
1326
  var _this_getEmptyState;
1239
1327
  var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1240
1328
  Object.keys(mapping.dataBind).map(function(key) {
@@ -1272,7 +1360,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1272
1360
  }
1273
1361
  });
1274
1362
  this.debugLog("engine setData方法数据组合完成,参数为%o。", newState);
1275
- this.setStates(newState, undefined, options);
1363
+ this.setStates(newState, undefined, _object_spread({
1364
+ setData: true
1365
+ }, options));
1276
1366
  this.debugLog("engine setData方法执行完成。");
1277
1367
  }
1278
1368
  },
@@ -1312,7 +1402,59 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1312
1402
  * 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
1313
1403
  * @param controlId
1314
1404
  * @param header 明细表内是否获取表头的控件
1315
- */ key: "getInstances",
1405
+ */ // getInstances(
1406
+ // controlId?: string,
1407
+ // header: boolean = false
1408
+ // ): ControlRuntimeInstance<ControlsKeys>[] {
1409
+ // // const cc = console
1410
+ // // const label = '🐑 genInstances ' + controlId + ' ' + Date.now()
1411
+ // // cc.time(label)
1412
+ //
1413
+ // if (controlId === undefined) {
1414
+ // // cc.timeEnd(label)
1415
+ // return this.runtime.flatInstances
1416
+ // }
1417
+ // const instances = Array.from(this.runtime.instanceMap[controlId] || [])
1418
+ // if (header) {
1419
+ // // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1420
+ // if (instances.length) {
1421
+ // const instance: RuntimeControl = instances[0]
1422
+ // // if (this.inList(instance.id) === true) {
1423
+ // if (this.inList(instance.id) !== undefined) {
1424
+ // const headerInstance = this.getInstanceInSubtableHeader(instance)
1425
+ // if (headerInstance) {
1426
+ // instances.unshift(headerInstance)
1427
+ // }
1428
+ // }
1429
+ // } else {
1430
+ // const controlIdMapping = this.getControlIdMapping()
1431
+ // const [subtableId] =
1432
+ // Object.entries(controlIdMapping).find(
1433
+ // ([_, mapping]) => mapping.children && controlId in mapping.children
1434
+ // ) ?? []
1435
+ // if (subtableId) {
1436
+ // const subtable = this.getInstance(subtableId)
1437
+ // // @ts-ignore
1438
+ // const headerColumn = subtable.props.headers.find((column: any) =>
1439
+ // column.children.find((item: any) => item.id === controlId)
1440
+ // )
1441
+ // if (headerColumn) {
1442
+ // const headerInstance = headerColumn.children.find(
1443
+ // (item: any) => item.id === controlId
1444
+ // )
1445
+ // if (headerInstance) {
1446
+ // instances.unshift(
1447
+ // headerInstance as ControlRuntimeInstance<ControlsKeys>
1448
+ // )
1449
+ // }
1450
+ // }
1451
+ // }
1452
+ // }
1453
+ // }
1454
+ // // @ts-ignore
1455
+ // return instances
1456
+ // }
1457
+ key: "getInstances",
1316
1458
  value: function getInstances(controlId) {
1317
1459
  var header = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
1318
1460
  // const cc = console
@@ -1327,6 +1469,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1327
1469
  // 如果能从flatInstances里边取到,就通过getInstanceInSubtableHeader方法取,取不到则换一种方式
1328
1470
  if (instances.length) {
1329
1471
  var instance = instances[0];
1472
+ // if (this.inList(instance.id) === true) {
1330
1473
  if (this.inList(instance.id) !== undefined) {
1331
1474
  var headerInstance = this.getInstanceInSubtableHeader(instance);
1332
1475
  if (headerInstance) {
@@ -1464,6 +1607,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1464
1607
  return isString(types) ? instance.type === types : types.includes(instance.type);
1465
1608
  }
1466
1609
  },
1610
+ {
1611
+ key: "assertInstanceIsCustomControl",
1612
+ value: /**
1613
+ * 判断控件或控件类型是一个自定义控件
1614
+ * */ function assertInstanceIsCustomControl(instance) {
1615
+ return !isBuiltInControls(isString(instance) ? instance : instance.type);
1616
+ }
1617
+ },
1467
1618
  {
1468
1619
  key: "getInstanceRowIndex",
1469
1620
  value: /**
@@ -1471,28 +1622,57 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1471
1622
  * 如果控件在表头内,则返回-1
1472
1623
  * 如果控件在表内,则返回行下标
1473
1624
  * 如果控件不在明细表内,则返回undefined
1474
- * */ function getInstanceRowIndex(instance) {
1625
+ * */ // public getInstanceRowIndex(
1626
+ // instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
1627
+ // ) {
1628
+ // if (!instance.parent) {
1629
+ // return
1630
+ // }
1631
+ // let rowIndex: number | undefined
1632
+ // // @ts-ignore
1633
+ // if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1634
+ // // 表头内的控件
1635
+ // // @ts-ignore
1636
+ // if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1637
+ // rowIndex = -1
1638
+ // } else {
1639
+ // // @ts-ignore
1640
+ // // const index = instance.parent.children.findIndex(
1641
+ // // (item: any) => item === instance
1642
+ // // )
1643
+ // let instances = this.runtime.instanceMap[instance.id] || []
1644
+ // const index = instances.findIndex((item: any) => item === instance)
1645
+ // if (index > -1) {
1646
+ // rowIndex = index
1647
+ // }
1648
+ // }
1649
+ // } else {
1650
+ // rowIndex = this.getInstanceRowIndex(instance.parent)
1651
+ // }
1652
+ // return rowIndex
1653
+ // }
1654
+ function getInstanceRowIndex(instance) {
1475
1655
  if (!instance.parent) {
1476
1656
  return;
1477
1657
  }
1478
1658
  var rowIndex;
1479
1659
  // @ts-ignore
1480
- if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE)) {
1481
- // 表头内的控件
1482
- // @ts-ignore
1483
- if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE_COLUMN)) {
1484
- rowIndex = -1;
1485
- } else {
1486
- // @ts-ignore
1487
- var index = instance.parent.children.findIndex(function(item) {
1488
- return item === instance;
1489
- });
1490
- if (index > -1) {
1491
- rowIndex = index;
1660
+ if (this.assertInstance(instance.parent, CONTROL_TYPE.SUBTABLE_COLUMN) && this.assertInstance(instance.parent.parent, CONTROL_TYPE.SUBTABLE)) {
1661
+ rowIndex = -1;
1662
+ } else {
1663
+ var isColumnChild = this.getInstanceParentControl(instance, // @ts-ignore
1664
+ CONTROL_TYPE.SUBTABLE_COLUMN);
1665
+ if (isColumnChild) {
1666
+ var instanceList = this.runtime.instanceMap[instance.id];
1667
+ if (Object.prototype.toString.call(instanceList) === "[object Array]") {
1668
+ var index = instanceList.findIndex(function(item) {
1669
+ return item === instance;
1670
+ });
1671
+ if (index > -1) {
1672
+ rowIndex = index;
1673
+ }
1492
1674
  }
1493
1675
  }
1494
- } else {
1495
- rowIndex = this.getInstanceRowIndex(instance.parent);
1496
1676
  }
1497
1677
  return rowIndex;
1498
1678
  }
@@ -1578,12 +1758,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1578
1758
  {
1579
1759
  key: "register",
1580
1760
  value: // 注册外部控件
1581
- function register() {
1582
- for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
1583
- arg[_key] = arguments[_key];
1584
- }
1585
- var _Runtime;
1586
- return (_Runtime = Runtime).register.apply(_Runtime, _to_consumable_array(arg));
1761
+ function register(control) {
1762
+ return Runtime.register(control, "Runtime");
1587
1763
  }
1588
1764
  },
1589
1765
  {
@@ -1595,4 +1771,5 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1595
1771
  ]);
1596
1772
  return Engine;
1597
1773
  }(Watcher);
1774
+ // @ts-ignore
1598
1775
  export { Engine };
@@ -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