@byteluck-fe/model-driven-engine 1.7.6-bete.2 → 1.7.6-bete.20

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.
@@ -365,6 +365,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
365
365
  _this.__pluginsApplied = false;
366
366
  _this.actionManager = new ActionManager();
367
367
  _this._jobTasks = [];
368
+ /**
369
+ * 用于存储运行态无需proxy的数据
370
+ * from v1.7.6-beta
371
+ */ _this.rawStore = {};
368
372
  _this.createControlInstance = _this.createInstance;
369
373
  _this.$options = Object.freeze(props);
370
374
  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,
@@ -432,9 +436,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
432
436
  _proto._proxyStateBeforeSetCallback = function _proxyStateBeforeSetCallback(state, key, newValue, oldValue) {
433
437
  var _this = this;
434
438
  var cc = console;
435
- cc.time("㊗️_proxyStateBeforeSetCallback findItem");
439
+ var now = Date.now();
440
+ cc.log("㊗️_proxyStateBeforeSetCallback findItem " + key, newValue, oldValue);
441
+ cc.time("㊗️_proxyStateBeforeSetCallback findItem " + key + " " + now);
436
442
  var instance = findItem(this.runtime.flatInstances, key);
437
- cc.timeLog("㊗️_proxyStateBeforeSetCallback findItem");
443
+ cc.timeEnd("㊗️_proxyStateBeforeSetCallback findItem " + key + " " + now);
438
444
  // 找不到控件说明不是改动控件上的字段,直接通过
439
445
  if (!instance) {
440
446
  return newValue;
@@ -474,21 +480,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
474
480
  }
475
481
  };
476
482
  _proto._handlerArrayUpdate = function _handlerArrayUpdate(state, key, type, args, result) {
477
- var _this = this;
478
483
  var cc = console;
479
- cc.time("㊗️ _handlerArrayUpdate findItem");
484
+ cc.time("㊗️ _handlerArrayUpdate findItem" + key);
480
485
  var subtable = findItem(this.runtime.flatInstances, key);
481
- cc.timeLog("㊗️ _handlerArrayUpdate findItem");
486
+ cc.timeEnd("㊗️ _handlerArrayUpdate findItem" + key);
482
487
  if (!_instanceof(subtable, RuntimeListControl)) return;
483
488
  // 新增多行方法
484
489
  var createRows = function(len) {
485
490
  // @ts-ignore
486
491
  var newRows = [];
487
- for(var i = 0; i < len; i++){
488
- // @ts-ignore
489
- var row = _this.listControlCreateRow(subtable, "subtable-row");
490
- row && newRows.push(row);
491
- }
492
+ // for (let i = 0; i < len; i++) {
493
+ // // @ts-ignore
494
+ // const row = this.listControlCreateRow(subtable, 'subtable-row')
495
+ // row && newRows.push(row)
496
+ // }
492
497
  // @ts-ignore
493
498
  return newRows;
494
499
  };
@@ -569,27 +574,55 @@ var Engine = /*#__PURE__*/ function(Watcher) {
569
574
  };
570
575
  _proto._handlerObjectUpdate = function _handlerObjectUpdate(state, key, value, oldValue) {
571
576
  var cc = console;
572
- cc.time("㊗️_handlerObjectUpdate findItem");
577
+ var now = Date.now();
578
+ cc.log("㊗️_handlerObjectUpdate findItem " + key, value, oldValue);
579
+ cc.time("㊗️_handlerObjectUpdate findItem " + key + " " + now);
580
+ // 1. header -> instance
581
+ // 2. 如何判断应该 给 subtableInstance.children中 push
582
+ // JUTODO
583
+ // 1. 修改生成的key的规则,去除[index]
584
+ // 2. 新增一个查找 subtable上的 _rowPropsList 的对应key instance的函数A
585
+ // 3. 判断 当前的key 应该调用 A 或者是 findItem
586
+ // 4.
573
587
  var instance = findItem(this.runtime.flatInstances, key);
574
- cc.timeLog("㊗️_handlerObjectUpdate findItem");
588
+ cc.timeEnd("㊗️_handlerObjectUpdate findItem " + key + " " + now);
575
589
  if (!instance) {
576
590
  return;
577
591
  }
578
592
  var index = this.getInstanceRowIndex(instance);
579
593
  var options = eventOptionsTemp || {};
580
594
  if (_instanceof(instance, RuntimeListControl)) {
581
- var // @ts-ignore
582
- _instance_children;
583
- instance.children.length = 0;
595
+ // const hasValue = Object.keys(instance.rowProps).length > 0
596
+ // debugger
597
+ // if (!hasValue) {
598
+ // instance.children = instance.props.headers.map((header) => {
599
+ // // instance.rowProps[header.id] = (this.createInstance as any)(
600
+ // // header.controlType
601
+ // // )
602
+ // return (this.createInstance as any)(
603
+ // header.controlType
604
+ // )
605
+ // })
606
+ // }
607
+ // instance.children.length = 0
584
608
  var newValue = value;
585
609
  // @ts-ignore
586
610
  var newRows = [];
587
- for(var i = 0; i < newValue.length; i++){
588
- // @ts-ignore
589
- var row = this.listControlCreateRow(instance, "subtable-row");
590
- row && newRows.push(row);
591
- }
592
- (_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
611
+ // JUTODO 这里template就是headers对应的 subtable-columns
612
+ // JUTODO 需要新增一种 subtableRow 的数据结构
613
+ // 同时,可以以其中一行进行缓存,作为 subtable-headers-columns 的公共列的instance
614
+ // 究竟要去 subtableRow 中取 props 还是 去 公共header instance 取?
615
+ // 答:始终应该取 subtableRow 的props,因为它是从 subtable-headers-columns 里copy下来的,并且可能会被同行的其他列修改
616
+ // const rowID =
617
+ // const subtableRow = genSubTableRowInstanceFromHeaders(instance.props.headers)
618
+ // instance.setRowProps()
619
+ // for (let i = 0; i < newValue.length; i++) {
620
+ // // @ts-ignore
621
+ // const row = this.listControlCreateRow(instance, 'subtable-row')
622
+ // row && newRows.push(row)
623
+ // }
624
+ // @ts-ignore
625
+ // instance.children.push(...newRows)
593
626
  this.runtime.getFlatInstances();
594
627
  // 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
595
628
  // for (let i = 0; i < newValue.length; i++) {
@@ -636,20 +669,21 @@ var Engine = /*#__PURE__*/ function(Watcher) {
636
669
  var row = this.runtime.createControlInstance(rowType);
637
670
  if (!row) return;
638
671
  if (_instanceof(row, RuntimeLayoutControl)) {
639
- var _row_children;
640
- var template = JSONCopy(instance.props.headers);
641
- // @ts-ignore
642
- var columns = this.createControl(template);
643
- (_row_children = row.children).push.apply(_row_children, _toConsumableArray(columns));
672
+ // const template = JSONCopy(instance.props.headers) as any
673
+ // @ts-ignore
674
+ // const columns = this.createControl(template) as unknown as any[]
675
+ // row.children.push(...columns)
644
676
  }
645
677
  return row;
646
678
  };
647
679
  _proto.listControlAddRow = function listControlAddRow(instance) {
648
680
  var // @ts-ignore
649
681
  rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
650
- var row = this.listControlCreateRow(instance, rowType);
651
- if (!row) return;
652
- instance.children.push(row);
682
+ // JUTODO 这似乎是个二开api
683
+ throw new Error("该api已废弃");
684
+ // const row = this.listControlCreateRow(instance, rowType)
685
+ // if (!row) return
686
+ // instance.children.push(row)
653
687
  };
654
688
  // payload应该是runtimeSchema和value,然后通过runTimeSchema去找需要修改的data里边的key
655
689
  _proto.emit = function emit(eventKey, payload) {
@@ -1030,6 +1064,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1030
1064
  var _this = this;
1031
1065
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1032
1066
  var newState = {};
1067
+ debugger;
1033
1068
  Object.keys(dataSet).map(function(dataCode) {
1034
1069
  var entity = dataSet[dataCode];
1035
1070
  if (Array.isArray(entity)) {
@@ -1142,6 +1177,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1142
1177
  if (controlId === undefined) {
1143
1178
  return this.runtime.flatInstances;
1144
1179
  }
1180
+ var cc = console;
1181
+ var now = Date.now();
1182
+ var timeLabel = "⚠️ getInstances " + controlId + " " + header + now;
1183
+ cc.time(timeLabel);
1145
1184
  var instances = this.runtime.flatInstances.filter(// @ts-ignore
1146
1185
  function(item) {
1147
1186
  return item.id === controlId;
@@ -1182,6 +1221,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1182
1221
  }
1183
1222
  }
1184
1223
  }
1224
+ cc.timeEnd(timeLabel);
1185
1225
  return instances;
1186
1226
  };
1187
1227
  _proto.setInstance = function setInstance(instance, props, value, rowIndex) {
@@ -0,0 +1,14 @@
1
+ // import { RuntimeSubTableColumnControl } from '@byteluck-fe/model-driven-core'
2
+ // import { RuntimeControl } from '@byteluck-fe/model-driven-core'
3
+ import cloneDeep from "lodash.clonedeep";
4
+ export function genSubTableRowInstanceFromHeaders(// headers: RuntimeSubTableColumnControl[]
5
+ headers) {
6
+ var subtableRow = headers.reduce(function(pre, cur) {
7
+ var children = cur.children;
8
+ children.forEach(function(control) {
9
+ pre[control.id] = cloneDeep(control.props);
10
+ });
11
+ return pre;
12
+ }, {});
13
+ return subtableRow;
14
+ }
@@ -283,6 +283,10 @@ export var CalcPlugin = /*#__PURE__*/ function() {
283
283
  if (!scriptEcho || scriptEcho.length === 0) {
284
284
  return;
285
285
  }
286
+ var cc = console;
287
+ var now = Date.now();
288
+ var timeLabel = "\uD83D\uDC36 computedCalcValue " + control.id + " " + now;
289
+ cc.time(timeLabel);
286
290
  // @ts-ignore
287
291
  var scriptText = scriptEcho.reduce(function(result, current) {
288
292
  if (current.type === CALC_TOKEN_TYPE.Operator || current.type === CALC_TOKEN_TYPE.Number) {
@@ -343,6 +347,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
343
347
  rowIndex = this.engine.getInstanceRowIndex(control);
344
348
  // 控件在明细表内,但是没有行下标,说明控件被已经删除了,所以直接return
345
349
  if (rowIndex === undefined) {
350
+ cc.log(timeLabel, "------> 控件在明细表内,但是没有行下标,说明控件被已经删除了,所以直接return");
351
+ cc.timeEnd(timeLabel);
346
352
  return;
347
353
  }
348
354
  }
@@ -350,6 +356,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
350
356
  var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
351
357
  // 如果值没变的话,不触发修改
352
358
  if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
359
+ cc.log(timeLabel, "------> 如果值没变的话,不触发修改");
360
+ cc.timeEnd(timeLabel);
353
361
  return;
354
362
  }
355
363
  var _oldValue_unit;
@@ -357,6 +365,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
357
365
  result: result,
358
366
  unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
359
367
  }, rowIndex);
368
+ cc.timeEnd(timeLabel);
360
369
  };
361
370
  /**
362
371
  * @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值