@tmagic/form 1.0.1 → 1.0.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.
package/src/utils/form.ts CHANGED
@@ -53,16 +53,7 @@ const asyncLoadConfig = (value: FormValue, initValue: FormValue, { asyncLoad, na
53
53
 
54
54
  const isMultipleValue = (type?: string | TypeFunction) =>
55
55
  typeof type === 'string' &&
56
- [
57
- 'checkbox-group',
58
- 'checkboxGroup',
59
- 'table',
60
- 'cascader',
61
- 'group-list',
62
- 'groupList',
63
- 'dynamic-tab',
64
- 'dynamicTab',
65
- ].includes(type);
56
+ ['checkbox-group', 'checkboxGroup', 'table', 'cascader', 'group-list', 'groupList'].includes(type);
66
57
 
67
58
  const initItemsValue = (
68
59
  mForm: FormState | undefined,
@@ -71,7 +62,7 @@ const initItemsValue = (
71
62
  { items, name, extensible }: any,
72
63
  ) => {
73
64
  if (Array.isArray(initValue[name])) {
74
- value[name] = initValue[name].map((v: any) => init(mForm, items, v));
65
+ value[name] = initValue[name].map((v: any, index: number) => init(mForm, items, v, value[name]?.[index]));
75
66
  } else {
76
67
  value[name] = init(mForm, items, initValue[name], value[name]);
77
68
  if (extensible) {
@@ -83,7 +74,7 @@ const initItemsValue = (
83
74
  const setValue = (mForm: FormState | undefined, value: FormValue, initValue: FormValue, item: any) => {
84
75
  const { items, name, type, checkbox } = item;
85
76
  // 值是数组, 有可能也有items配置,所以不能放到getDefaultValue里赋值
86
- if (isMultipleValue(type)) {
77
+ if (isMultipleValue(type) || (type === 'tab' && item.dynamic)) {
87
78
  value[name] = initValue[name] || [];
88
79
  }
89
80
 
@@ -232,7 +223,7 @@ export const getRules = function (mForm: FormState | undefined, rules: Rule[] |
232
223
  fnc(
233
224
  {
234
225
  rule,
235
- value,
226
+ value: props.config.names ? props.model : value,
236
227
  callback,
237
228
  source,
238
229
  options,