@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/dist/style.css +3 -0
- package/dist/tmagic-form.es.js +253 -267
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +255 -269
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/containers/Fieldset.vue.d.ts +54 -31
- package/dist/types/src/containers/Tabs.vue.d.ts +2 -0
- package/dist/types/src/fields/Date.vue.d.ts +1 -2
- package/dist/types/src/fields/SelectOptionGroups.vue.d.ts +13 -0
- package/dist/types/src/fields/SelectOptions.vue.d.ts +21 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/schema.d.ts +10 -1
- package/package.json +8 -9
- package/src/containers/Fieldset.vue +44 -73
- package/src/containers/Tabs.vue +11 -2
- package/src/fields/Cascader.vue +2 -1
- package/src/fields/Date.vue +12 -16
- package/src/fields/DateTime.vue +1 -1
- package/src/fields/Daterange.vue +1 -1
- package/src/fields/Select.vue +10 -23
- package/src/fields/SelectOptionGroups.vue +20 -0
- package/src/fields/SelectOptions.vue +18 -0
- package/src/fields/Time.vue +8 -10
- package/src/index.ts +1 -1
- package/src/schema.ts +10 -1
- package/src/theme/fieldset.scss +4 -0
- package/src/utils/form.ts +3 -12
package/src/schema.ts
CHANGED
|
@@ -184,7 +184,14 @@ export interface SelectGroupOption {
|
|
|
184
184
|
label: string;
|
|
185
185
|
/** 是否禁用该选项组 */
|
|
186
186
|
disabled: boolean;
|
|
187
|
-
options:
|
|
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
|
|
package/src/theme/fieldset.scss
CHANGED
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,
|