|
|
@@ -7,6 +7,7 @@ interface Props {
|
|
|
}
|
|
|
const props = defineProps<Props>()
|
|
|
|
|
|
+const containerTypes = ['form-tabs', 'form-layout']
|
|
|
const formData = computed(() => {
|
|
|
if (props.formData.id) {
|
|
|
return props.formData
|
|
|
@@ -14,19 +15,21 @@ const formData = computed(() => {
|
|
|
const res = props.formData
|
|
|
props.formConfig?.formItems.forEach(item => {
|
|
|
item.group.forEach(element => {
|
|
|
- if (element.type !== 'form-tabs') {
|
|
|
+ if (containerTypes.includes(element.type)) {
|
|
|
+ element.children?.forEach(tab => {
|
|
|
+ tab.children?.forEach(child => {
|
|
|
+ if (!child.notFormItem) {
|
|
|
+ res[child.name] =
|
|
|
+ res[child.name] !== undefined && child.value !== undefined ? res[child.name] : child.value
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
if (!element.notFormItem) {
|
|
|
// 避免修改当前表单项value重置其他表单项的value
|
|
|
res[element.name] =
|
|
|
res[element.name] !== undefined && element.value !== undefined ? res[element.name] : element.value
|
|
|
}
|
|
|
- } else {
|
|
|
- element.children?.forEach(tab => {
|
|
|
- tab.children?.forEach(child => {
|
|
|
- res[child.name] =
|
|
|
- res[child.name] !== undefined && child.value !== undefined ? res[child.name] : child.value
|
|
|
- })
|
|
|
- })
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -37,7 +40,7 @@ const formData = computed(() => {
|
|
|
// 构造formTabs插槽
|
|
|
props.formConfig.formItems.forEach(item => {
|
|
|
item.group.forEach(child => {
|
|
|
- if (child.type === 'form-tabs') {
|
|
|
+ if (containerTypes.includes(child.type)) {
|
|
|
child.slots = []
|
|
|
child.children?.forEach(tab => {
|
|
|
tab.children?.forEach((child: any) => {
|
|
|
@@ -59,11 +62,12 @@ props.formConfig.formItems.forEach(item => {
|
|
|
>
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="sub.span || formConfig.span || 12" v-for="(sub, key) in item.group" :key="key">
|
|
|
- <el-form-tabs
|
|
|
- v-if="sub.type === 'form-tabs'"
|
|
|
+ <component
|
|
|
+ :is="'el-' + sub.type"
|
|
|
+ v-if="containerTypes.includes(sub.type)"
|
|
|
v-model="sub.value"
|
|
|
v-bind="sub.props"
|
|
|
- :tabs="sub.children"
|
|
|
+ :children="sub.children"
|
|
|
:formData="formData"
|
|
|
:formConfig="formConfig"
|
|
|
v-on="sub.events || {}"
|
|
|
@@ -71,7 +75,7 @@ props.formConfig.formItems.forEach(item => {
|
|
|
<template #[slot.alias]="slotProps" v-for="slot in sub.slots" :key="slot.alias">
|
|
|
<slot :name="slot.alias" v-bind="slotProps"></slot>
|
|
|
</template>
|
|
|
- </el-form-tabs>
|
|
|
+ </component>
|
|
|
<template v-else>
|
|
|
<el-form-item :label="sub.label" :rules="sub.rules" :prop="sub.name" v-show="!sub.hidden">
|
|
|
<form-comp :item="sub" v-model="formData[sub.name]">
|
|
|
@@ -93,4 +97,8 @@ props.formConfig.formItems.forEach(item => {
|
|
|
</el-card>
|
|
|
</template>
|
|
|
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.el-select) {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+</style>
|