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