@byteluck-fe/model-driven-engine 2.5.2 → 2.5.4

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.
@@ -355,6 +355,7 @@ import { findItem, proxyState } from "./proxyState";
355
355
  import { ActionManager } from "./ActionManager";
356
356
  import { DataManager } from "./DataManager";
357
357
  import { checkerSubtableValue, checkerValue } from "./checkerValue";
358
+ import { buildUUID } from "../utils/runtimeUtils";
358
359
  if (typeof window !== "undefined") {
359
360
  // @ts-ignore
360
361
  window.engines = {};
@@ -600,14 +601,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
600
601
  result
601
602
  ];
602
603
  }
604
+ var subtableData = this.getState(subtable.id);
605
+ this._handlerSubtableUpdateUid(subtableData);
603
606
  this.emit("list-change", {
604
607
  instance: subtable,
605
- value: this.getState(subtable.id),
608
+ value: subtableData,
606
609
  options: Object.assign({}, options, {
607
610
  changed: createdNewRows,
608
611
  data: createdNewRowsData,
609
612
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
610
- jsonValue: JSON.stringify(this.getState(subtable.id))
613
+ jsonValue: JSON.stringify(subtableData)
611
614
  })
612
615
  });
613
616
  // 主动清空本次任务中的options
@@ -615,6 +618,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
615
618
  }
616
619
  }
617
620
  },
621
+ {
622
+ key: "_handlerSubtableUpdateUid",
623
+ value: function _handlerSubtableUpdateUid(subtableData) {
624
+ subtableData.forEach(function(item) {
625
+ if (!item.uid) {
626
+ Object.assign(item, {
627
+ uid: "new:" + buildUUID("uid")
628
+ });
629
+ }
630
+ });
631
+ }
632
+ },
618
633
  {
619
634
  key: "_handlerObjectUpdate",
620
635
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
@@ -643,6 +658,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
643
658
  // for (let i = 0; i < newValue.length; i++) {
644
659
  // this.setStates(newValue[i], i, options)
645
660
  // }
661
+ var deleted = oldValue !== null && oldValue !== void 0 ? oldValue : [];
662
+ if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
663
+ deleted = [];
664
+ }
665
+ this._handlerSubtableUpdateUid(newValue);
646
666
  this.emit("list-change", {
647
667
  instance: instance,
648
668
  value: value,
@@ -650,7 +670,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
650
670
  // @ts-ignore
651
671
  changed: newRows,
652
672
  data: newValue,
653
- deleted: oldValue !== null && oldValue !== void 0 ? oldValue : []
673
+ deleted: deleted,
674
+ // deleted: oldValue ?? [],
675
+ type: "push",
676
+ jsonValue: JSON.stringify(newValue)
654
677
  })
655
678
  });
656
679
  } else {
@@ -973,18 +996,22 @@ var Engine = /*#__PURE__*/ function(Watcher) {
973
996
  var data = getFieldData.map(function(item) {
974
997
  var obj = {};
975
998
  for(var key in item){
976
- var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
977
- var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
978
- //未绑定字段的控件,直接抛弃
979
- if (fieldCode !== "") {
980
- var _controlIdMapping_controlId1;
981
- if (fieldCode) {
982
- obj[fieldCode] = item[key];
983
- } else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
984
- // 兼容一个控件需要绑定多个字段的情况
985
- for(var keyChi in item[key]){
986
- var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
987
- obj[(_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : (_controlIdMapping_controlId_children_key1 = _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
999
+ if (key === "uid") {
1000
+ obj = item[key];
1001
+ } else {
1002
+ var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
1003
+ var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
1004
+ //未绑定字段的控件,直接抛弃
1005
+ if (fieldCode !== "") {
1006
+ var _controlIdMapping_controlId1;
1007
+ if (fieldCode) {
1008
+ obj[fieldCode] = item[key];
1009
+ } else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
1010
+ // 兼容一个控件需要绑定多个字段的情况
1011
+ for(var keyChi in item[key]){
1012
+ var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
1013
+ obj[(_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : (_controlIdMapping_controlId_children_key1 = _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
1014
+ }
988
1015
  }
989
1016
  }
990
1017
  }
@@ -1004,16 +1031,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1004
1031
  obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
1005
1032
  var objChi = {};
1006
1033
  for(var keyChi in item){
1007
- var _controlIdMapping_key_children_keyChi;
1008
- 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;
1009
- //未绑定字段的控件,直接抛弃
1010
- if (fieldCode !== "") {
1011
- if (fieldCode) {
1012
- objChi[fieldCode] = item[keyChi];
1013
- } else {
1014
- for(var keyChi1 in item[keyChi]){
1015
- var _controlIdMapping_key_children_keyChi1;
1016
- 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];
1034
+ if (keyChi === "uid") {
1035
+ objChi = item[keyChi];
1036
+ } else {
1037
+ var _controlIdMapping_key_children_keyChi;
1038
+ 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;
1039
+ //未绑定字段的控件,直接抛弃
1040
+ if (fieldCode !== "") {
1041
+ if (fieldCode) {
1042
+ objChi[fieldCode] = item[keyChi];
1043
+ } else {
1044
+ for(var keyChi1 in item[keyChi]){
1045
+ var _controlIdMapping_key_children_keyChi1;
1046
+ 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];
1047
+ }
1017
1048
  }
1018
1049
  }
1019
1050
  }
@@ -86,6 +86,16 @@ var Store = /*#__PURE__*/ function() {
86
86
  var controlInfo = this.controlIdMapping[controlId];
87
87
  var noProxyValue = JSONCopy(value);
88
88
  if (controlInfo !== undefined) {
89
+ //明细表
90
+ if (controlInfo.children) {
91
+ value.forEach(function(item) {
92
+ if (!item.uid) {
93
+ Object.assign(item, {
94
+ uid: "new:" + buildUUID("uid")
95
+ });
96
+ }
97
+ });
98
+ }
89
99
  //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
90
100
  this.state[controlInfo.dataView][controlId] = noProxyValue;
91
101
  // if (