@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/dist/style.css +3 -0
- package/dist/tmagic-form.es.js +254 -268
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +256 -270
- 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/Table.vue.d.ts +778 -0
- 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/Table.vue +2 -19
- 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 +4 -13
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,
|