@tmagic/form 1.2.0-beta.9 → 1.2.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.
- package/dist/style.css +1 -1
- package/dist/{tmagic-form.mjs → tmagic-form.js} +313 -129
- package/dist/tmagic-form.js.map +1 -0
- package/dist/{tmagic-form.umd.js → tmagic-form.umd.cjs} +312 -127
- package/dist/tmagic-form.umd.cjs.map +1 -0
- package/package.json +10 -8
- package/src/Form.vue +2 -2
- package/src/FormDialog.vue +3 -1
- package/src/containers/Col.vue +3 -1
- package/src/containers/Container.vue +6 -3
- package/src/containers/Fieldset.vue +4 -1
- package/src/containers/GroupList.vue +4 -2
- package/src/containers/GroupListItem.vue +8 -5
- package/src/containers/Panel.vue +4 -1
- package/src/containers/Row.vue +3 -1
- package/src/containers/Step.vue +3 -1
- package/src/containers/Table.vue +46 -19
- package/src/containers/Tabs.vue +9 -4
- package/src/fields/Cascader.vue +2 -2
- package/src/fields/Checkbox.vue +2 -2
- package/src/fields/CheckboxGroup.vue +8 -3
- package/src/fields/ColorPicker.vue +2 -2
- package/src/fields/Date.vue +3 -3
- package/src/fields/DateTime.vue +2 -2
- package/src/fields/Daterange.vue +2 -2
- package/src/fields/Display.vue +1 -1
- package/src/fields/DynamicField.vue +2 -2
- package/src/fields/Hidden.vue +1 -1
- package/src/fields/Link.vue +2 -2
- package/src/fields/Number.vue +2 -2
- package/src/fields/RadioGroup.vue +9 -5
- package/src/fields/Select.vue +63 -24
- package/src/fields/SelectOptionGroups.vue +1 -1
- package/src/fields/SelectOptions.vue +1 -1
- package/src/fields/Switch.vue +2 -2
- package/src/fields/Text.vue +2 -2
- package/src/fields/Textarea.vue +2 -2
- package/src/fields/Time.vue +4 -2
- package/src/index.ts +1 -1
- package/src/schema.ts +25 -9
- package/src/theme/form.scss +1 -1
- package/src/utils/config.ts +1 -1
- package/src/utils/containerProps.ts +1 -1
- package/src/utils/createForm.ts +1 -1
- package/src/utils/form.ts +6 -6
- package/src/utils/useAddField.ts +1 -1
- package/types/Form.vue.d.ts +32 -170
- package/types/FormDialog.vue.d.ts +4 -0
- package/types/containers/Col.vue.d.ts +12 -74
- package/types/containers/Container.vue.d.ts +17 -95
- package/types/containers/Fieldset.vue.d.ts +15 -87
- package/types/containers/GroupList.vue.d.ts +11 -71
- package/types/containers/GroupListItem.vue.d.ts +12 -80
- package/types/containers/Panel.vue.d.ts +4 -0
- package/types/containers/Row.vue.d.ts +12 -74
- package/types/containers/Step.vue.d.ts +13 -79
- package/types/containers/Table.vue.d.ts +10 -0
- package/types/containers/Tabs.vue.d.ts +12 -74
- package/types/fields/Cascader.vue.d.ts +12 -78
- package/types/fields/Checkbox.vue.d.ts +12 -78
- package/types/fields/CheckboxGroup.vue.d.ts +12 -78
- package/types/fields/ColorPicker.vue.d.ts +12 -78
- package/types/fields/Date.vue.d.ts +12 -78
- package/types/fields/DateTime.vue.d.ts +12 -78
- package/types/fields/Daterange.vue.d.ts +12 -78
- package/types/fields/Display.vue.d.ts +9 -65
- package/types/fields/DynamicField.vue.d.ts +12 -78
- package/types/fields/Hidden.vue.d.ts +9 -65
- package/types/fields/Link.vue.d.ts +12 -78
- package/types/fields/Number.vue.d.ts +12 -81
- package/types/fields/RadioGroup.vue.d.ts +12 -78
- package/types/fields/Select.vue.d.ts +12 -79
- package/types/fields/SelectOptionGroups.vue.d.ts +4 -50
- package/types/fields/SelectOptions.vue.d.ts +5 -53
- package/types/fields/Switch.vue.d.ts +12 -78
- package/types/fields/Text.vue.d.ts +12 -81
- package/types/fields/Textarea.vue.d.ts +12 -81
- package/types/fields/Time.vue.d.ts +12 -78
- package/types/schema.d.ts +23 -8
- package/types/utils/form.d.ts +2 -1
- package/dist/tmagic-form.mjs.map +0 -1
- package/dist/tmagic-form.umd.js.map +0 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts" setup>
|
|
15
|
+
<script lang="ts" setup name="MFormDynamicField">
|
|
16
16
|
/**
|
|
17
17
|
* 动态表单,目前只支持input类型字段
|
|
18
18
|
* inputType: 'dynamic-field',
|
|
@@ -39,7 +39,7 @@ const props = defineProps<{
|
|
|
39
39
|
name: string;
|
|
40
40
|
prop: string;
|
|
41
41
|
disabled?: boolean;
|
|
42
|
-
size
|
|
42
|
+
size?: 'large' | 'default' | 'small';
|
|
43
43
|
}>();
|
|
44
44
|
|
|
45
45
|
const emit = defineEmits(['change']);
|
package/src/fields/Hidden.vue
CHANGED
package/src/fields/Link.vue
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script lang="ts" setup>
|
|
19
|
+
<script lang="ts" setup name="MFormLink">
|
|
20
20
|
import { computed, inject, ref } from 'vue';
|
|
21
21
|
|
|
22
22
|
import { TMagicButton } from '@tmagic/design';
|
|
@@ -33,7 +33,7 @@ const props = defineProps<{
|
|
|
33
33
|
name: string;
|
|
34
34
|
prop: string;
|
|
35
35
|
disabled?: boolean;
|
|
36
|
-
size
|
|
36
|
+
size?: 'large' | 'default' | 'small';
|
|
37
37
|
}>();
|
|
38
38
|
|
|
39
39
|
const emit = defineEmits(['change']);
|
package/src/fields/Number.vue
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
></TMagicInputNumber>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
|
-
<script lang="ts" setup>
|
|
18
|
+
<script lang="ts" setup name="MFormNumber">
|
|
19
19
|
import { inject } from 'vue';
|
|
20
20
|
|
|
21
21
|
import { TMagicInputNumber } from '@tmagic/design';
|
|
@@ -31,7 +31,7 @@ const props = defineProps<{
|
|
|
31
31
|
name: string;
|
|
32
32
|
prop: string;
|
|
33
33
|
disabled?: boolean;
|
|
34
|
-
size
|
|
34
|
+
size?: 'large' | 'default' | 'small';
|
|
35
35
|
}>();
|
|
36
36
|
|
|
37
37
|
const emit = defineEmits(['change', 'input']);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TMagicRadioGroup v-if="model" v-model="model[name]" :size="size" :disabled="disabled" @change="changeHandler">
|
|
3
|
-
<TMagicRadio
|
|
4
|
-
option.
|
|
5
|
-
|
|
3
|
+
<TMagicRadio
|
|
4
|
+
v-for="option in config.options"
|
|
5
|
+
:label="option.value"
|
|
6
|
+
:value="option.value"
|
|
7
|
+
:key="`${option.value}`"
|
|
8
|
+
>{{ option.text }}</TMagicRadio
|
|
9
|
+
>
|
|
6
10
|
</TMagicRadioGroup>
|
|
7
11
|
</template>
|
|
8
12
|
|
|
9
|
-
<script lang="ts" setup>
|
|
13
|
+
<script lang="ts" setup name="MFormRadioGroup">
|
|
10
14
|
import { TMagicRadio, TMagicRadioGroup } from '@tmagic/design';
|
|
11
15
|
|
|
12
16
|
import { RadioGroupConfig } from '../schema';
|
|
@@ -20,7 +24,7 @@ const props = defineProps<{
|
|
|
20
24
|
name: string;
|
|
21
25
|
prop: string;
|
|
22
26
|
disabled?: boolean;
|
|
23
|
-
size
|
|
27
|
+
size?: 'large' | 'default' | 'small';
|
|
24
28
|
}>();
|
|
25
29
|
|
|
26
30
|
const emit = defineEmits(['change']);
|
package/src/fields/Select.vue
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</TMagicSelect>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
|
-
<script lang="ts" setup>
|
|
28
|
+
<script lang="ts" setup name="MFormSelect">
|
|
29
29
|
import { inject, nextTick, onBeforeMount, onMounted, Ref, ref, watchEffect } from 'vue';
|
|
30
30
|
|
|
31
31
|
import { TMagicSelect } from '@tmagic/design';
|
|
@@ -45,7 +45,7 @@ const props = defineProps<{
|
|
|
45
45
|
name: string;
|
|
46
46
|
prop: string;
|
|
47
47
|
disabled?: boolean;
|
|
48
|
-
size
|
|
48
|
+
size?: 'large' | 'default' | 'small';
|
|
49
49
|
}>();
|
|
50
50
|
|
|
51
51
|
const emit = defineEmits(['change']);
|
|
@@ -99,11 +99,16 @@ const getOptions = async () => {
|
|
|
99
99
|
|
|
100
100
|
const { config } = props;
|
|
101
101
|
const { option } = config;
|
|
102
|
-
|
|
102
|
+
const { root = '', totalKey = 'total' } = option;
|
|
103
|
+
let { body = {}, url } = option;
|
|
104
|
+
|
|
105
|
+
if (typeof url === 'function') {
|
|
106
|
+
url = await url(mForm, { model: props.model, formValue: mForm?.values });
|
|
107
|
+
}
|
|
103
108
|
|
|
104
109
|
let postOptions: Record<string, any> = {
|
|
105
110
|
method: option.method || 'POST',
|
|
106
|
-
url
|
|
111
|
+
url,
|
|
107
112
|
cache: option.cache,
|
|
108
113
|
timeout: option.timeout,
|
|
109
114
|
mode: option.mode,
|
|
@@ -111,22 +116,21 @@ const getOptions = async () => {
|
|
|
111
116
|
json: option.json || false,
|
|
112
117
|
};
|
|
113
118
|
|
|
114
|
-
if (body) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}) as Record<string, any>;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
body.query = query.value;
|
|
125
|
-
body.pgSize = pgSize.value;
|
|
126
|
-
body.pgIndex = pgIndex.value;
|
|
127
|
-
postOptions.data = body;
|
|
119
|
+
if (typeof body === 'function') {
|
|
120
|
+
body = body(mForm, {
|
|
121
|
+
model: props.model,
|
|
122
|
+
formValue: mForm?.values,
|
|
123
|
+
formValues: mForm?.values,
|
|
124
|
+
config: props.config,
|
|
125
|
+
}) as Record<string, any>;
|
|
128
126
|
}
|
|
129
127
|
|
|
128
|
+
body.query = query.value;
|
|
129
|
+
body.pgSize = pgSize.value;
|
|
130
|
+
body.pgIndex = pgIndex.value;
|
|
131
|
+
|
|
132
|
+
postOptions.data = body;
|
|
133
|
+
|
|
130
134
|
const requestFuc = getConfig('request') as Function;
|
|
131
135
|
|
|
132
136
|
if (typeof option.beforeRequest === 'function') {
|
|
@@ -151,10 +155,14 @@ const getOptions = async () => {
|
|
|
151
155
|
});
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
const optionsData =
|
|
158
|
+
const optionsData = root.split('.').reduce((accumulator, currentValue: any) => accumulator[currentValue], res);
|
|
155
159
|
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
const resTotal = globalThis.parseInt(
|
|
161
|
+
totalKey.split('.').reduce((accumulator, currentValue: any) => accumulator[currentValue], res),
|
|
162
|
+
10,
|
|
163
|
+
);
|
|
164
|
+
if (resTotal > 0) {
|
|
165
|
+
total.value = resTotal;
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
remoteData.value = remoteData.value.concat(optionsData);
|
|
@@ -214,6 +222,8 @@ const getInitOption = async () => {
|
|
|
214
222
|
|
|
215
223
|
const { config } = props;
|
|
216
224
|
const { option } = config;
|
|
225
|
+
const { root = '', initRoot = '' } = option;
|
|
226
|
+
let { initBody = {} } = option;
|
|
217
227
|
|
|
218
228
|
let options: SelectOption[] | SelectGroupOption[] = [];
|
|
219
229
|
|
|
@@ -226,24 +236,53 @@ const getInitOption = async () => {
|
|
|
226
236
|
url = await url(mForm, { model: props.model, formValue: mForm?.values });
|
|
227
237
|
}
|
|
228
238
|
|
|
229
|
-
|
|
239
|
+
if (typeof initBody === 'function') {
|
|
240
|
+
initBody = initBody(mForm, {
|
|
241
|
+
model: props.model,
|
|
242
|
+
formValue: mForm?.values,
|
|
243
|
+
formValues: mForm?.values,
|
|
244
|
+
config: props.config,
|
|
245
|
+
}) as Record<string, any>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let postOptions: Record<string, any> = {
|
|
230
249
|
method: option.method || 'POST',
|
|
231
250
|
url,
|
|
232
251
|
data: {
|
|
233
252
|
id: props.model[props.name],
|
|
253
|
+
...initBody,
|
|
234
254
|
},
|
|
235
255
|
mode: option.mode,
|
|
236
256
|
headers: option.headers || {},
|
|
237
257
|
json: option.json || false,
|
|
238
258
|
};
|
|
259
|
+
|
|
260
|
+
if (typeof option.beforeInitRequest === 'function') {
|
|
261
|
+
postOptions = option.beforeInitRequest(mForm, postOptions, {
|
|
262
|
+
model: props.model,
|
|
263
|
+
formValue: mForm?.values,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
239
267
|
if (option.method?.toLocaleLowerCase() === 'jsonp') {
|
|
240
268
|
postOptions.jsonpCallback = option.jsonpCallback || 'callback';
|
|
241
269
|
}
|
|
242
270
|
|
|
243
271
|
const requestFuc = getConfig('request') as Function;
|
|
244
|
-
|
|
272
|
+
let res = await requestFuc(postOptions);
|
|
273
|
+
|
|
274
|
+
if (typeof option.afterRequest === 'function') {
|
|
275
|
+
res = option.afterRequest(mForm, res, {
|
|
276
|
+
model: props.model,
|
|
277
|
+
formValue: mForm?.values,
|
|
278
|
+
formValues: mForm?.values,
|
|
279
|
+
config: props.config,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
245
282
|
|
|
246
|
-
let initData =
|
|
283
|
+
let initData = (initRoot || root)
|
|
284
|
+
.split('.')
|
|
285
|
+
.reduce((accumulator, currentValue: any) => accumulator[currentValue], res);
|
|
247
286
|
if (initData) {
|
|
248
287
|
if (!Array.isArray(initData)) {
|
|
249
288
|
initData = [initData];
|
package/src/fields/Switch.vue
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
></TMagicSwitch>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
|
-
<script lang="ts" setup>
|
|
12
|
+
<script lang="ts" setup name="MFormSwitch">
|
|
13
13
|
import { computed } from 'vue';
|
|
14
14
|
|
|
15
15
|
import { TMagicSwitch } from '@tmagic/design';
|
|
@@ -25,7 +25,7 @@ const props = defineProps<{
|
|
|
25
25
|
name: string;
|
|
26
26
|
prop: string;
|
|
27
27
|
disabled?: boolean;
|
|
28
|
-
size
|
|
28
|
+
size?: 'large' | 'default' | 'small';
|
|
29
29
|
}>();
|
|
30
30
|
|
|
31
31
|
const emit = defineEmits(['change']);
|
package/src/fields/Text.vue
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</TMagicInput>
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
|
-
<script lang="ts" setup>
|
|
26
|
+
<script lang="ts" setup name="MFormText">
|
|
27
27
|
import { inject } from 'vue';
|
|
28
28
|
|
|
29
29
|
import { TMagicInput } from '@tmagic/design';
|
|
@@ -40,7 +40,7 @@ const props = defineProps<{
|
|
|
40
40
|
name: string;
|
|
41
41
|
prop: string;
|
|
42
42
|
disabled?: boolean;
|
|
43
|
-
size
|
|
43
|
+
size?: 'large' | 'default' | 'small';
|
|
44
44
|
}>();
|
|
45
45
|
|
|
46
46
|
const emit = defineEmits(['change', 'input']);
|
package/src/fields/Textarea.vue
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</TMagicInput>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts" setup>
|
|
15
|
+
<script lang="ts" setup name="MFormTextarea">
|
|
16
16
|
import { inject } from 'vue';
|
|
17
17
|
|
|
18
18
|
import { TMagicInput } from '@tmagic/design';
|
|
@@ -28,7 +28,7 @@ const props = defineProps<{
|
|
|
28
28
|
name: string;
|
|
29
29
|
prop: string;
|
|
30
30
|
disabled?: boolean;
|
|
31
|
-
size
|
|
31
|
+
size?: 'large' | 'default' | 'small';
|
|
32
32
|
}>();
|
|
33
33
|
|
|
34
34
|
const emit = defineEmits(['change', 'input']);
|
package/src/fields/Time.vue
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TMagicTimePicker
|
|
3
3
|
v-model="model[name]"
|
|
4
|
+
:value-format="config.valueFormat || 'HH:mm:ss'"
|
|
5
|
+
:format="config.format || 'HH:mm:ss'"
|
|
4
6
|
:size="size"
|
|
5
7
|
:placeholder="config.placeholder"
|
|
6
8
|
:disabled="disabled"
|
|
@@ -8,7 +10,7 @@
|
|
|
8
10
|
></TMagicTimePicker>
|
|
9
11
|
</template>
|
|
10
12
|
|
|
11
|
-
<script lang="ts" setup>
|
|
13
|
+
<script lang="ts" setup name="MFormTime">
|
|
12
14
|
import { TMagicTimePicker } from '@tmagic/design';
|
|
13
15
|
|
|
14
16
|
import { TimeConfig } from '../schema';
|
|
@@ -22,7 +24,7 @@ const props = defineProps<{
|
|
|
22
24
|
name: string;
|
|
23
25
|
prop: string;
|
|
24
26
|
disabled?: boolean;
|
|
25
|
-
size
|
|
27
|
+
size?: 'large' | 'default' | 'small';
|
|
26
28
|
}>();
|
|
27
29
|
|
|
28
30
|
const emit = defineEmits(['change']);
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
package/src/schema.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -348,6 +348,7 @@ export interface HiddenConfig extends FormItem {
|
|
|
348
348
|
export interface DateConfig extends FormItem, Input {
|
|
349
349
|
type: 'date';
|
|
350
350
|
format?: 'YYYY-MM-dd HH:mm:ss' | string;
|
|
351
|
+
valueFormat?: 'YYYY-MM-dd HH:mm:ss' | string;
|
|
351
352
|
}
|
|
352
353
|
|
|
353
354
|
/**
|
|
@@ -365,6 +366,8 @@ export interface DateTimeConfig extends FormItem, Input {
|
|
|
365
366
|
*/
|
|
366
367
|
export interface TimeConfig extends FormItem, Input {
|
|
367
368
|
type: 'time';
|
|
369
|
+
format?: 'HH:mm:ss' | string;
|
|
370
|
+
valueFormat?: 'HH:mm:ss' | string;
|
|
368
371
|
}
|
|
369
372
|
|
|
370
373
|
/**
|
|
@@ -430,7 +433,7 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
430
433
|
options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
|
|
431
434
|
remote: true;
|
|
432
435
|
option: {
|
|
433
|
-
url: string;
|
|
436
|
+
url: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
|
|
434
437
|
initUrl?: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
|
|
435
438
|
method?: 'jsonp' | string;
|
|
436
439
|
cache?: boolean;
|
|
@@ -441,13 +444,22 @@ export interface SelectConfig extends FormItem, Input {
|
|
|
441
444
|
};
|
|
442
445
|
json?: false | boolean;
|
|
443
446
|
body?: Record<string, any> | RemoteSelectOptionBodyFunction;
|
|
447
|
+
initBody?: Record<string, any> | RemoteSelectOptionBodyFunction;
|
|
444
448
|
jsonpCallback?: 'callback' | string;
|
|
445
449
|
afterRequest?: RemoteSelectOptionRequestFunction;
|
|
450
|
+
afterInitRequest?: RemoteSelectOptionRequestFunction;
|
|
446
451
|
beforeRequest?: (mForm: FormState | undefined, postOptions: Record<string, any>, data: any) => Record<string, any>;
|
|
447
|
-
|
|
452
|
+
beforeInitRequest?: (
|
|
453
|
+
mForm: FormState | undefined,
|
|
454
|
+
postOptions: Record<string, any>,
|
|
455
|
+
data: any,
|
|
456
|
+
) => Record<string, any>;
|
|
457
|
+
root?: string;
|
|
458
|
+
totalKey?: string;
|
|
459
|
+
initRoot?: string;
|
|
448
460
|
item?: RemoteSelectOptionItemFunction;
|
|
449
|
-
value
|
|
450
|
-
text
|
|
461
|
+
value?: string | SelectOptionValueFunction;
|
|
462
|
+
text?: string | SelectOptionTextFunction;
|
|
451
463
|
};
|
|
452
464
|
}
|
|
453
465
|
|
|
@@ -586,11 +598,11 @@ export interface PanelConfig extends FormItem, ContainerCommonConfig {
|
|
|
586
598
|
schematic?: string;
|
|
587
599
|
}
|
|
588
600
|
|
|
589
|
-
export interface ColumnConfig extends FormItem
|
|
590
|
-
name
|
|
601
|
+
export interface ColumnConfig extends FormItem {
|
|
602
|
+
name?: string;
|
|
591
603
|
label: string;
|
|
592
|
-
width
|
|
593
|
-
sortable
|
|
604
|
+
width?: string | number;
|
|
605
|
+
sortable?: boolean;
|
|
594
606
|
[key: string]: any;
|
|
595
607
|
}
|
|
596
608
|
|
|
@@ -610,6 +622,9 @@ export interface TableConfig extends FormItem {
|
|
|
610
622
|
border?: boolean;
|
|
611
623
|
/** 显示行号 */
|
|
612
624
|
showIndex?: boolean;
|
|
625
|
+
/** 操作栏宽度 */
|
|
626
|
+
operateColWidth?: number | string;
|
|
627
|
+
pagination?: boolean;
|
|
613
628
|
enum?: any[];
|
|
614
629
|
/** 是否显示添加按钮 */
|
|
615
630
|
addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean;
|
|
@@ -629,6 +644,7 @@ export interface TableConfig extends FormItem {
|
|
|
629
644
|
enableFullscreen?: boolean;
|
|
630
645
|
fixed?: boolean;
|
|
631
646
|
itemExtra?: string | FilterFunction;
|
|
647
|
+
rowKey?: string;
|
|
632
648
|
}
|
|
633
649
|
|
|
634
650
|
export interface GroupListConfig extends FormItem {
|
package/src/theme/form.scss
CHANGED
package/src/utils/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
package/src/utils/createForm.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
package/src/utils/form.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -62,9 +62,9 @@ const initItemsValue = (
|
|
|
62
62
|
{ items, name, extensible }: any,
|
|
63
63
|
) => {
|
|
64
64
|
if (Array.isArray(initValue[name])) {
|
|
65
|
-
value[name] = initValue[name].map((v: any, index: number) =>
|
|
65
|
+
value[name] = initValue[name].map((v: any, index: number) => createValues(mForm, items, v, value[name]?.[index]));
|
|
66
66
|
} else {
|
|
67
|
-
value[name] =
|
|
67
|
+
value[name] = createValues(mForm, items, initValue[name], value[name]);
|
|
68
68
|
if (extensible) {
|
|
69
69
|
value[name] = Object.assign({}, initValue[name], value[name]);
|
|
70
70
|
}
|
|
@@ -129,7 +129,7 @@ const initValueItem = function (
|
|
|
129
129
|
|
|
130
130
|
if (!name) {
|
|
131
131
|
// 没有配置name,直接跳过
|
|
132
|
-
return
|
|
132
|
+
return createValues(mForm, items, initValue, value);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
setValue(mForm, value, initValue, item);
|
|
@@ -137,7 +137,7 @@ const initValueItem = function (
|
|
|
137
137
|
return value;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
const
|
|
140
|
+
export const createValues = function (
|
|
141
141
|
mForm: FormState | undefined,
|
|
142
142
|
config: FormConfig | TabPaneConfig[] = [],
|
|
143
143
|
initValue: FormValue = {},
|
|
@@ -253,7 +253,7 @@ export const initValue = async (
|
|
|
253
253
|
) => {
|
|
254
254
|
if (!Array.isArray(config)) throw new Error('config应该为数组');
|
|
255
255
|
|
|
256
|
-
let valuesTmp =
|
|
256
|
+
let valuesTmp = createValues(mForm, config, toRaw(initValues), {});
|
|
257
257
|
|
|
258
258
|
const [firstForm] = config as [ContainerCommonConfig];
|
|
259
259
|
if (firstForm && typeof firstForm.onInitValue === 'function') {
|
package/src/utils/useAddField.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|