@byteluck-fe/model-driven-engine 2.8.1-beta1 → 2.8.2-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.
@@ -348,6 +348,7 @@ import { findItem, proxyState } from "./proxyState";
348
348
  import { ActionManager } from "./ActionManager";
349
349
  import { DataManager } from "./DataManager";
350
350
  import { checkerSubtableValue, checkerValue } from "./checkerValue";
351
+ import { buildUUID } from "../utils/runtimeUtils";
351
352
  if (typeof window !== "undefined") {
352
353
  // @ts-ignore
353
354
  window.engines = {};
@@ -602,14 +603,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
602
603
  result
603
604
  ];
604
605
  }
606
+ var subtableData = this.getState(subtable.id);
607
+ this._handlerSubtableUpdateUid(subtableData);
605
608
  this.emit("list-change", {
606
609
  instance: subtable,
607
- value: this.getState(subtable.id),
610
+ value: subtableData,
608
611
  options: Object.assign({}, options, {
609
612
  changed: createdNewRows,
610
613
  data: createdNewRowsData,
611
614
  deleted: deleted !== null && deleted !== void 0 ? deleted : [],
612
- jsonValue: JSON.stringify(this.getState(subtable.id)),
615
+ jsonValue: JSON.stringify(subtableData),
613
616
  isDeleteLastOne: isDeleteLastOne,
614
617
  type: type,
615
618
  args: args
@@ -620,6 +623,18 @@ var Engine = /*#__PURE__*/ function(Watcher) {
620
623
  }
621
624
  }
622
625
  },
626
+ {
627
+ key: "_handlerSubtableUpdateUid",
628
+ value: function _handlerSubtableUpdateUid(subtableData) {
629
+ subtableData.forEach(function(item) {
630
+ if (!item.uid) {
631
+ Object.assign(item, {
632
+ uid: "new:" + buildUUID("uid")
633
+ });
634
+ }
635
+ });
636
+ }
637
+ },
623
638
  {
624
639
  key: "_handlerObjectUpdate",
625
640
  value: function _handlerObjectUpdate(state, key, value, oldValue) {
@@ -652,6 +667,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
652
667
  if ((options === null || options === void 0 ? void 0 : options.setData) === true) {
653
668
  deleted = [];
654
669
  }
670
+ this._handlerSubtableUpdateUid(newValue);
655
671
  this.emit("list-change", {
656
672
  instance: instance,
657
673
  value: value,
@@ -661,7 +677,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
661
677
  data: newValue,
662
678
  deleted: deleted,
663
679
  // deleted: oldValue ?? [],
664
- type: "push"
680
+ type: "push",
681
+ jsonValue: JSON.stringify(newValue)
665
682
  })
666
683
  });
667
684
  } else {
@@ -180,26 +180,33 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
180
180
  {
181
181
  key: "allRules",
182
182
  get: function get() {
183
- var antdRules = {};
184
- var ruleItems = {};
183
+ var defaultAntdRules = {};
184
+ var defaultRule = {};
185
+ var defaultFieldRules = {};
185
186
  loopDataViewControl(this._instance, function(dataView) {
186
187
  var result = Runtime.staticGetRules(dataView.type, dataView.props);
187
- ruleItems[dataView.id] = JSONCopy(result[0]);
188
- antdRules[dataView.id] = JSONCopy(result[0]);
188
+ defaultRule[dataView.id] = JSONCopy(result[0]);
189
+ defaultAntdRules[dataView.id] = JSONCopy(result[0]);
190
+ defaultFieldRules[dataView.id] = JSONCopy(result[0]);
189
191
  loopFormControl(dataView.children, function(item) {
190
192
  // if (
191
193
  // item instanceof RuntimeFormControl ||
192
194
  // item instanceof RuntimeListControl
193
195
  // ) {
194
196
  if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
195
- buildControlRules(ruleItems[dataView.id].fields, item);
196
- buildControlAntdRules(antdRules[dataView.id].fields, item);
197
+ buildControlRules(defaultRule[dataView.id].fields, item, true);
198
+ buildControlAntdRules(defaultAntdRules[dataView.id].fields, item, true);
199
+ buildFieldCodeRules(defaultFieldRules[dataView.id].fields, item, true);
197
200
  }
198
201
  });
199
202
  });
200
203
  return {
201
- rules: ruleItems,
202
- antdRules: antdRules
204
+ rules: this.rules,
205
+ antdRules: this.antdRules,
206
+ fieldCodeRules: this.fieldCodeRules,
207
+ defaultAntdRules: defaultAntdRules,
208
+ defaultRule: defaultRule,
209
+ defaultFieldRules: defaultFieldRules
203
210
  };
204
211
  }
205
212
  },
@@ -307,6 +314,7 @@ function hasHeaderOrFooterControl(control, checkType) {
307
314
  }
308
315
  function buildControlRules(data, // @ts-ignore
309
316
  item) {
317
+ var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
310
318
  if (getControlIsHide(item)) {
311
319
  return;
312
320
  }
@@ -322,7 +330,11 @@ item) {
322
330
  type: "array",
323
331
  fields: {}
324
332
  };
325
- item.children.forEach(function(row, index) {
333
+ (isSubtableDefaultRules === true ? [
334
+ {
335
+ children: item.props.headers
336
+ }
337
+ ] : item.children).forEach(function(row, index) {
326
338
  loopFormSchema(row.children, function(formControl) {
327
339
  if (itemRules.fields) {
328
340
  if (!itemRules.fields[index]) {
@@ -347,6 +359,7 @@ item) {
347
359
  }
348
360
  function buildFieldCodeRules(data, // @ts-ignore
349
361
  item) {
362
+ var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
350
363
  if (getControlIsHide(item)) {
351
364
  return;
352
365
  }
@@ -378,7 +391,11 @@ item) {
378
391
  type: "array",
379
392
  fields: {}
380
393
  };
381
- item.children.forEach(function(row, index) {
394
+ (isSubtableDefaultRules === true ? [
395
+ {
396
+ children: item.props.headers
397
+ }
398
+ ] : item.children).forEach(function(row, index) {
382
399
  loopFormSchema(row.children, function(formControl) {
383
400
  if (itemRules.fields) {
384
401
  if (!itemRules.fields[index]) {
@@ -425,6 +442,7 @@ function findFields(childResult) {
425
442
  }
426
443
  function buildControlAntdRules(antdRules, // @ts-ignore
427
444
  item) {
445
+ var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
428
446
  if (getControlIsHide(item)) {
429
447
  return;
430
448
  }
@@ -435,7 +453,11 @@ item) {
435
453
  antdRules[item.id] = result;
436
454
  } else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
437
455
  antdRules[item.id] = [];
438
- item.children.forEach(function(row) {
456
+ (isSubtableDefaultRules === true ? [
457
+ {
458
+ children: item.props.headers
459
+ }
460
+ ] : item.children).forEach(function(row) {
439
461
  var rules = {};
440
462
  loopFormSchema(row.children, function(formControl) {
441
463
  // rules[formControl.id] = (formControl as RuntimeFormControl).rules
@@ -79,6 +79,16 @@ var Store = /*#__PURE__*/ function() {
79
79
  var controlInfo = this.controlIdMapping[controlId];
80
80
  var noProxyValue = JSONCopy(value);
81
81
  if (controlInfo !== undefined) {
82
+ //明细表
83
+ if (controlInfo.children) {
84
+ value.forEach(function(item) {
85
+ if (!item.uid) {
86
+ Object.assign(item, {
87
+ uid: "new:" + buildUUID("uid")
88
+ });
89
+ }
90
+ });
91
+ }
82
92
  //qiyu 按照对象赋值,Object.assign会触发多次key的change事件
83
93
  this.state[controlInfo.dataView][controlId] = noProxyValue;
84
94
  // if (
@@ -365,6 +375,13 @@ item) {
365
375
  });
366
376
  });
367
377
  } else {
378
+ if (data[item.props.dataBind.dataCode] === undefined) {
379
+ data[item.props.dataBind.dataCode] = {
380
+ controlId: dataViewId,
381
+ fields: [],
382
+ dataViewId: dataViewId
383
+ };
384
+ }
368
385
  data[item.props.dataBind.dataCode].fields.push({
369
386
  fieldCode: item.props.dataBind.fieldCode,
370
387
  controlId: item.id,