@tmagic/form 1.1.6 → 1.2.0-beta.10
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/tmagic-form.mjs +2318 -2632
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +2341 -2656
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/Form.vue +123 -158
- package/src/FormDialog.vue +140 -158
- package/src/containers/Col.vue +22 -38
- package/src/containers/Container.vue +138 -171
- package/src/containers/Fieldset.vue +12 -8
- package/src/containers/GroupList.vue +80 -112
- package/src/containers/GroupListItem.vue +87 -124
- package/src/containers/Panel.vue +26 -49
- package/src/containers/Row.vue +18 -40
- package/src/containers/Step.vue +36 -48
- package/src/containers/Table.vue +449 -479
- package/src/containers/Tabs.vue +92 -118
- package/src/fields/Cascader.vue +88 -136
- package/src/fields/Checkbox.vue +46 -50
- package/src/fields/CheckboxGroup.vue +39 -35
- package/src/fields/ColorPicker.vue +5 -3
- package/src/fields/Date.vue +20 -26
- package/src/fields/DateTime.vue +31 -39
- package/src/fields/Daterange.vue +4 -3
- package/src/fields/Display.vue +1 -1
- package/src/fields/DynamicField.vue +63 -77
- package/src/fields/Hidden.vue +1 -1
- package/src/fields/Link.vue +65 -86
- package/src/fields/Number.vue +32 -34
- package/src/fields/RadioGroup.vue +23 -23
- package/src/fields/Select.vue +294 -321
- package/src/fields/SelectOptionGroups.vue +11 -6
- package/src/fields/SelectOptions.vue +5 -3
- package/src/fields/Switch.vue +46 -49
- package/src/fields/Text.vue +99 -107
- package/src/fields/Textarea.vue +32 -44
- package/src/fields/Time.vue +19 -30
- package/src/index.ts +22 -23
- package/src/schema.ts +46 -12
- package/src/utils/form.ts +4 -0
- package/types/Form.vue.d.ts +211 -111
- package/types/FormDialog.vue.d.ts +809 -154
- package/types/containers/Col.vue.d.ts +92 -40
- package/types/containers/Container.vue.d.ts +122 -65
- package/types/containers/Fieldset.vue.d.ts +1 -3
- package/types/containers/GroupList.vue.d.ts +86 -53
- package/types/containers/GroupListItem.vue.d.ts +97 -67
- package/types/containers/Panel.vue.d.ts +92 -39
- package/types/containers/Row.vue.d.ts +92 -39
- package/types/containers/Step.vue.d.ts +102 -42
- package/types/containers/Table.vue.d.ts +157 -130
- package/types/containers/Tabs.vue.d.ts +93 -50
- package/types/fields/Cascader.vue.d.ts +95 -71
- package/types/fields/Checkbox.vue.d.ts +95 -56
- package/types/fields/CheckboxGroup.vue.d.ts +95 -53
- package/types/fields/ColorPicker.vue.d.ts +1 -3
- package/types/fields/Date.vue.d.ts +95 -54
- package/types/fields/DateTime.vue.d.ts +95 -54
- package/types/fields/Daterange.vue.d.ts +1 -3
- package/types/fields/Display.vue.d.ts +1 -3
- package/types/fields/DynamicField.vue.d.ts +95 -64
- package/types/fields/Hidden.vue.d.ts +1 -3
- package/types/fields/Link.vue.d.ts +60 -657
- package/types/fields/Number.vue.d.ts +99 -56
- package/types/fields/RadioGroup.vue.d.ts +96 -52
- package/types/fields/Select.vue.d.ts +97 -65
- package/types/fields/SelectOptionGroups.vue.d.ts +1 -3
- package/types/fields/SelectOptions.vue.d.ts +1 -3
- package/types/fields/Switch.vue.d.ts +95 -56
- package/types/fields/Text.vue.d.ts +98 -57
- package/types/fields/Textarea.vue.d.ts +100 -60
- package/types/fields/Time.vue.d.ts +95 -55
- package/types/index.d.ts +0 -1
- package/types/schema.d.ts +38 -9
- package/src/utils/fieldProps.ts +0 -39
- package/types/utils/fieldProps.d.ts +0 -21
package/src/containers/Col.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
2
|
+
<TMagicCol v-show="display && config.type !== 'hidden'" :span="span">
|
|
3
|
+
<Container
|
|
4
4
|
:model="model"
|
|
5
5
|
:config="config"
|
|
6
6
|
:prop="prop"
|
|
@@ -8,49 +8,33 @@
|
|
|
8
8
|
:expand-more="expandMore"
|
|
9
9
|
:size="size"
|
|
10
10
|
@change="changeHandler"
|
|
11
|
-
></
|
|
12
|
-
</
|
|
11
|
+
></Container>
|
|
12
|
+
</TMagicCol>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import { computed,
|
|
15
|
+
<script setup lang="ts" name="MFormCol">
|
|
16
|
+
import { computed, inject } from 'vue';
|
|
17
|
+
|
|
18
|
+
import { TMagicCol } from '@tmagic/design';
|
|
17
19
|
|
|
18
20
|
import { ChildConfig, FormState } from '../schema';
|
|
19
21
|
import { display as displayFunction } from '../utils/form';
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
props: {
|
|
23
|
-
labelWidth: String,
|
|
24
|
-
expandMore: Boolean,
|
|
25
|
-
span: Number,
|
|
26
|
-
|
|
27
|
-
model: {
|
|
28
|
-
type: Object,
|
|
29
|
-
default: () => ({}),
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
config: {
|
|
33
|
-
type: Object as PropType<ChildConfig>,
|
|
34
|
-
default: () => ({}),
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
prop: String,
|
|
38
|
-
|
|
39
|
-
size: String,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
emits: ['change'],
|
|
23
|
+
import Container from './Container.vue';
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
model: any;
|
|
27
|
+
config: ChildConfig;
|
|
28
|
+
labelWidth?: string;
|
|
29
|
+
expandMore?: boolean;
|
|
30
|
+
span?: number;
|
|
31
|
+
size?: string;
|
|
32
|
+
prop?: string;
|
|
33
|
+
}>();
|
|
46
34
|
|
|
47
|
-
|
|
35
|
+
const emit = defineEmits(['change']);
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
changeHandler,
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
});
|
|
37
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
38
|
+
const display = computed(() => displayFunction(mForm, props.config.display, props));
|
|
39
|
+
const changeHandler = () => emit('change', props.model);
|
|
56
40
|
</script>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
></component>
|
|
31
31
|
|
|
32
32
|
<template v-else-if="type && display">
|
|
33
|
-
<
|
|
33
|
+
<TMagicFormItem
|
|
34
34
|
:style="config.tip ? 'flex: 1' : ''"
|
|
35
35
|
:class="{ hidden: `${itemLabelWidth}` === '0' || !config.text }"
|
|
36
36
|
:prop="itemProp"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
:rules="rule"
|
|
39
39
|
>
|
|
40
40
|
<template #label><span v-html="type === 'checkbox' ? '' : config.text"></span></template>
|
|
41
|
-
<
|
|
41
|
+
<TMagicTooltip v-if="tooltip">
|
|
42
42
|
<component
|
|
43
43
|
:key="key(config)"
|
|
44
44
|
:size="size"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<template #content>
|
|
54
54
|
<div v-html="tooltip"></div>
|
|
55
55
|
</template>
|
|
56
|
-
</
|
|
56
|
+
</TMagicTooltip>
|
|
57
57
|
|
|
58
58
|
<component
|
|
59
59
|
v-else
|
|
@@ -69,19 +69,19 @@
|
|
|
69
69
|
></component>
|
|
70
70
|
|
|
71
71
|
<div v-if="extra" v-html="extra" class="m-form-tip"></div>
|
|
72
|
-
</
|
|
72
|
+
</TMagicFormItem>
|
|
73
73
|
|
|
74
|
-
<
|
|
75
|
-
<
|
|
74
|
+
<TMagicTooltip v-if="config.tip" placement="left">
|
|
75
|
+
<TMagicIcon style="line-height: 40px; margin-left: 5px"><warning-filled /></TMagicIcon>
|
|
76
76
|
<template #content>
|
|
77
77
|
<div v-html="config.tip"></div>
|
|
78
78
|
</template>
|
|
79
|
-
</
|
|
79
|
+
</TMagicTooltip>
|
|
80
80
|
</template>
|
|
81
81
|
|
|
82
82
|
<template v-else-if="items && display">
|
|
83
83
|
<template v-if="name || name === 0 ? model[name] : model">
|
|
84
|
-
<
|
|
84
|
+
<Container
|
|
85
85
|
v-for="item in items"
|
|
86
86
|
:key="key(item)"
|
|
87
87
|
:model="name || name === 0 ? model[name] : model"
|
|
@@ -92,202 +92,169 @@
|
|
|
92
92
|
:label-width="itemLabelWidth"
|
|
93
93
|
:prop="itemProp"
|
|
94
94
|
@change="onChangeHandler"
|
|
95
|
-
></
|
|
95
|
+
></Container>
|
|
96
96
|
</template>
|
|
97
97
|
</template>
|
|
98
98
|
|
|
99
99
|
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
|
|
100
|
-
<
|
|
100
|
+
<TMagicButton type="primary" size="small" text @click="expandHandler">{{
|
|
101
|
+
expand ? '收起配置' : '展开更多配置'
|
|
102
|
+
}}</TMagicButton>
|
|
101
103
|
</div>
|
|
102
104
|
</div>
|
|
103
105
|
</template>
|
|
104
106
|
|
|
105
|
-
<script lang="ts">
|
|
106
|
-
import { computed,
|
|
107
|
+
<script setup lang="ts" name="MFormContainer">
|
|
108
|
+
import { computed, inject, ref, resolveComponent, watchEffect } from 'vue';
|
|
107
109
|
import { WarningFilled } from '@element-plus/icons-vue';
|
|
108
110
|
|
|
111
|
+
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
112
|
+
|
|
109
113
|
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
110
114
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
111
115
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
const props = withDefaults(
|
|
117
|
+
defineProps<{
|
|
118
|
+
model: FormValue;
|
|
119
|
+
config: ChildConfig;
|
|
120
|
+
prop?: string;
|
|
121
|
+
labelWidth?: string;
|
|
122
|
+
expandMore?: boolean;
|
|
123
|
+
stepActive?: string | number;
|
|
124
|
+
size?: string;
|
|
125
|
+
}>(),
|
|
126
|
+
{
|
|
127
|
+
prop: '',
|
|
128
|
+
size: 'small',
|
|
129
|
+
expandMore: false,
|
|
130
|
+
},
|
|
131
|
+
);
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
type: [Object, Array] as PropType<FormValue>,
|
|
123
|
-
required: true,
|
|
124
|
-
},
|
|
133
|
+
const emit = defineEmits(['change']);
|
|
125
134
|
|
|
126
|
-
|
|
127
|
-
type: Object as PropType<ChildConfig>,
|
|
128
|
-
required: true,
|
|
129
|
-
},
|
|
135
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
type: String,
|
|
133
|
-
default: () => '',
|
|
134
|
-
},
|
|
137
|
+
const expand = ref(false);
|
|
135
138
|
|
|
136
|
-
|
|
137
|
-
type: [String, Number],
|
|
138
|
-
},
|
|
139
|
+
const name = computed(() => props.config.name || '');
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
type: String,
|
|
142
|
-
default: 'small',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
141
|
+
const items = computed(() => (props.config as ContainerCommonConfig).items);
|
|
145
142
|
|
|
146
|
-
|
|
143
|
+
const itemProp = computed(() => {
|
|
144
|
+
let n: string | number = '';
|
|
145
|
+
const { names } = props.config as any;
|
|
146
|
+
if (names?.[0]) {
|
|
147
|
+
[n] = names;
|
|
148
|
+
} else if (name.value) {
|
|
149
|
+
n = name.value;
|
|
150
|
+
} else {
|
|
151
|
+
return props.prop;
|
|
152
|
+
}
|
|
153
|
+
return `${props.prop}${props.prop ? '.' : ''}${n}`;
|
|
154
|
+
});
|
|
147
155
|
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
const tagName = computed(() => {
|
|
157
|
+
const component = resolveComponent(`m-${items.value ? 'form' : 'fields'}-${type.value}`);
|
|
158
|
+
if (typeof component !== 'string') return component;
|
|
159
|
+
return 'm-fields-text';
|
|
160
|
+
});
|
|
150
161
|
|
|
151
|
-
|
|
162
|
+
const disabled = computed(() => filterFunction(mForm, props.config.disabled, props));
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
const extra = computed(() => filterFunction(mForm, props.config.extra, props));
|
|
156
167
|
|
|
157
|
-
|
|
158
|
-
let n: string | number = '';
|
|
159
|
-
const { names } = props.config as any;
|
|
160
|
-
if (names?.[0]) {
|
|
161
|
-
[n] = names;
|
|
162
|
-
} else if (name.value) {
|
|
163
|
-
n = name.value;
|
|
164
|
-
} else {
|
|
165
|
-
return props.prop;
|
|
166
|
-
}
|
|
167
|
-
return `${props.prop}${props.prop ? '.' : ''}${n}`;
|
|
168
|
-
});
|
|
168
|
+
const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
const type = computed((): string => {
|
|
171
|
+
let { type } = props.config;
|
|
172
|
+
if (typeof type === 'function') {
|
|
173
|
+
type = type(mForm, {
|
|
174
|
+
model: props.model,
|
|
174
175
|
});
|
|
176
|
+
}
|
|
177
|
+
if (type === 'form') return '';
|
|
178
|
+
return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
|
|
179
|
+
});
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
const display = computed((): boolean => {
|
|
182
|
+
const value = displayFunction(mForm, props.config.display, props);
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
if (value === 'expand') {
|
|
185
|
+
return expand.value;
|
|
186
|
+
}
|
|
187
|
+
return value;
|
|
188
|
+
});
|
|
179
189
|
|
|
180
|
-
|
|
190
|
+
const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);
|
|
181
191
|
|
|
182
|
-
|
|
192
|
+
watchEffect(() => {
|
|
193
|
+
expand.value = props.expandMore;
|
|
194
|
+
});
|
|
183
195
|
|
|
184
|
-
|
|
185
|
-
let { type } = props.config;
|
|
186
|
-
if (typeof type === 'function') {
|
|
187
|
-
type = type(mForm, {
|
|
188
|
-
model: props.model,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
if (type === 'form') return '';
|
|
192
|
-
return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
|
|
193
|
-
});
|
|
196
|
+
const expandHandler = () => (expand.value = !expand.value);
|
|
194
197
|
|
|
195
|
-
|
|
196
|
-
if (props.config.display === 'expand') {
|
|
197
|
-
return expand.value;
|
|
198
|
-
}
|
|
198
|
+
const key = (config: any) => config[mForm?.keyProps];
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
const filterHandler = (filter: any, value: FormValue | number | string) => {
|
|
201
|
+
if (typeof filter === 'function') {
|
|
202
|
+
return filter(mForm, value, {
|
|
203
|
+
model: props.model,
|
|
204
|
+
values: mForm?.initValues,
|
|
205
|
+
formValue: mForm?.values,
|
|
206
|
+
prop: itemProp.value,
|
|
207
|
+
config: props.config,
|
|
201
208
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (filter === 'number') {
|
|
212
|
+
return +value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return value;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const changeHandler = (onChange: any, value: FormValue | number | string) => {
|
|
219
|
+
if (typeof onChange === 'function') {
|
|
220
|
+
return onChange(mForm, value, {
|
|
221
|
+
model: props.model,
|
|
222
|
+
values: mForm?.initValues,
|
|
223
|
+
formValue: mForm?.values,
|
|
224
|
+
prop: itemProp.value,
|
|
225
|
+
config: props.config,
|
|
207
226
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const trimHandler = (trim: any, value: FormValue | number | string) => {
|
|
244
|
-
if (typeof value === 'string' && trim) {
|
|
245
|
-
return value.replace(/^\s*/, '').replace(/\s*$/, '');
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
250
|
-
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
251
|
-
let value: FormValue | number | string = v;
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
value = filterHandler(filter, v);
|
|
255
|
-
value = (await changeHandler(onChange, value)) ?? value;
|
|
256
|
-
value = trimHandler(trim, value) ?? value;
|
|
257
|
-
} catch (e) {
|
|
258
|
-
console.error(e);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// field内容下包含field-link时,model===value, 这里避免循环引用
|
|
262
|
-
if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
|
|
263
|
-
// eslint-disable-next-line vue/no-mutating-props
|
|
264
|
-
props.model[name] = value;
|
|
265
|
-
}
|
|
266
|
-
// 动态表单类型,根据value和key参数,直接修改model
|
|
267
|
-
if (key !== undefined && dynamicKey) {
|
|
268
|
-
// eslint-disable-next-line vue/no-mutating-props
|
|
269
|
-
props.model[key] = value;
|
|
270
|
-
}
|
|
271
|
-
emit('change', props.model);
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
return {
|
|
275
|
-
expand,
|
|
276
|
-
name,
|
|
277
|
-
type,
|
|
278
|
-
disabled,
|
|
279
|
-
itemProp,
|
|
280
|
-
items,
|
|
281
|
-
display,
|
|
282
|
-
itemLabelWidth,
|
|
283
|
-
tagName,
|
|
284
|
-
rule,
|
|
285
|
-
tooltip,
|
|
286
|
-
extra,
|
|
287
|
-
key,
|
|
288
|
-
onChangeHandler,
|
|
289
|
-
expandHandler,
|
|
290
|
-
};
|
|
291
|
-
},
|
|
292
|
-
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const trimHandler = (trim: any, value: FormValue | number | string) => {
|
|
231
|
+
if (typeof value === 'string' && trim) {
|
|
232
|
+
return value.replace(/^\s*/, '').replace(/\s*$/, '');
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const onChangeHandler = async function (v: FormValue, key?: string) {
|
|
237
|
+
const { filter, onChange, trim, name, dynamicKey } = props.config as any;
|
|
238
|
+
let value: FormValue | number | string = v;
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
value = filterHandler(filter, v);
|
|
242
|
+
value = (await changeHandler(onChange, value)) ?? value;
|
|
243
|
+
value = trimHandler(trim, value) ?? value;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
console.error(e);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// field内容下包含field-link时,model===value, 这里避免循环引用
|
|
249
|
+
if ((name || name === 0) && props.model !== value && (v !== value || props.model[name] !== value)) {
|
|
250
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
251
|
+
props.model[name] = value;
|
|
252
|
+
}
|
|
253
|
+
// 动态表单类型,根据value和key参数,直接修改model
|
|
254
|
+
if (key !== undefined && dynamicKey) {
|
|
255
|
+
// eslint-disable-next-line vue/no-mutating-props
|
|
256
|
+
props.model[key] = value;
|
|
257
|
+
}
|
|
258
|
+
emit('change', props.model);
|
|
259
|
+
};
|
|
293
260
|
</script>
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
:style="show ? 'padding: 15px 15px 0 5px;' : 'border: 0'"
|
|
6
6
|
>
|
|
7
7
|
<component v-if="name && config.checkbox" :is="!show ? 'div' : 'legend'">
|
|
8
|
-
<
|
|
8
|
+
<TMagicCheckbox
|
|
9
9
|
v-model="model[name].value"
|
|
10
10
|
:prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
|
|
11
11
|
:true-label="1"
|
|
12
12
|
:false-label="0"
|
|
13
13
|
><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
|
|
14
|
-
></
|
|
14
|
+
></TMagicCheckbox>
|
|
15
15
|
</component>
|
|
16
16
|
<legend v-else>
|
|
17
17
|
<span v-html="config.legend"></span>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
<div v-if="config.schematic && show" style="display: flex">
|
|
22
22
|
<div style="flex: 1">
|
|
23
|
-
<
|
|
23
|
+
<Container
|
|
24
24
|
v-for="(item, index) in config.items"
|
|
25
25
|
:key="key(item, index)"
|
|
26
26
|
:model="name ? model[name] : model"
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
:labelWidth="lWidth"
|
|
31
31
|
:size="size"
|
|
32
32
|
@change="change"
|
|
33
|
-
></
|
|
33
|
+
></Container>
|
|
34
34
|
</div>
|
|
35
35
|
|
|
36
36
|
<img class="m-form-schematic" :src="config.schematic" />
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
39
|
<template v-else-if="show">
|
|
40
|
-
<
|
|
40
|
+
<Container
|
|
41
41
|
v-for="(item, index) in config.items"
|
|
42
42
|
:key="key(item, index)"
|
|
43
43
|
:model="name ? model[name] : model"
|
|
@@ -47,16 +47,20 @@
|
|
|
47
47
|
:labelWidth="lWidth"
|
|
48
48
|
:size="size"
|
|
49
49
|
@change="change"
|
|
50
|
-
></
|
|
50
|
+
></Container>
|
|
51
51
|
</template>
|
|
52
52
|
</fieldset>
|
|
53
53
|
</template>
|
|
54
54
|
|
|
55
|
-
<script lang="ts" setup>
|
|
55
|
+
<script lang="ts" setup name="MFormFieldset">
|
|
56
56
|
import { computed, inject, watch } from 'vue';
|
|
57
57
|
|
|
58
|
+
import { TMagicCheckbox } from '@tmagic/design';
|
|
59
|
+
|
|
58
60
|
import { FieldsetConfig, FormState } from '../schema';
|
|
59
61
|
|
|
62
|
+
import Container from './Container.vue';
|
|
63
|
+
|
|
60
64
|
const props = withDefaults(
|
|
61
65
|
defineProps<{
|
|
62
66
|
labelWidth?: string;
|
|
@@ -89,7 +93,7 @@ const lWidth = computed(() => {
|
|
|
89
93
|
if (props.config.items) {
|
|
90
94
|
return props.config.labelWidth || props.labelWidth;
|
|
91
95
|
}
|
|
92
|
-
return props.config.labelWidth || props.labelWidth || (props.config.text ?
|
|
96
|
+
return props.config.labelWidth || props.labelWidth || (props.config.text ? undefined : '0');
|
|
93
97
|
});
|
|
94
98
|
|
|
95
99
|
const change = () => {
|