@tmagic/form 1.0.2 → 1.0.5

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/schema.ts CHANGED
@@ -184,7 +184,14 @@ export interface SelectGroupOption {
184
184
  label: string;
185
185
  /** 是否禁用该选项组 */
186
186
  disabled: boolean;
187
- options: SelectOption[];
187
+ options: {
188
+ /** 选项的标签 */
189
+ label: string | SelectOptionTextFunction;
190
+ /** 选项的值 */
191
+ value: any | SelectOptionValueFunction;
192
+ /** 是否禁用该选项 */
193
+ disabled?: boolean;
194
+ }[];
188
195
  }
189
196
 
190
197
  type SelectOptionFunction = (
@@ -508,6 +515,7 @@ export interface TabPaneConfig {
508
515
  lazy?: boolean;
509
516
  labelWidth?: string;
510
517
  items: FormConfig;
518
+ onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
511
519
  [key: string]: any;
512
520
  }
513
521
  export interface TabConfig extends FormItem, ContainerCommonConfig {
@@ -520,6 +528,7 @@ export interface TabConfig extends FormItem, ContainerCommonConfig {
520
528
  onChange?: (mForm: FormState | undefined, data: any) => void;
521
529
  onTabAdd?: (mForm: FormState | undefined, data: any) => void;
522
530
  onTabRemove?: (mForm: FormState | undefined, tabName: string, data: any) => void;
531
+ onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
523
532
  activeChange?: (mForm: FormState | undefined, tabName: string, data: any) => void;
524
533
  }
525
534
 
@@ -5,6 +5,10 @@ fieldset.m-fieldset {
5
5
  margin-bottom: 10px;
6
6
  min-inline-size: auto;
7
7
 
8
+ .el-checkbox {
9
+ height: 22px;
10
+ }
11
+
8
12
  legend {
9
13
  font-size: 14px;
10
14
  position: absolute;
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,
@@ -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,