Browse Source

修复layout组件span不生效

tongshangming 2 years ago
parent
commit
e9eacf5a8d
2 changed files with 12 additions and 15 deletions
  1. 0 1
      src/auto-import.d.ts
  2. 12 14
      src/components/form/ElFormLayout.vue

+ 0 - 1
src/auto-import.d.ts

@@ -88,7 +88,6 @@ declare global {
   const refThrottled: typeof import('@vueuse/core')['refThrottled']
   const refWithControl: typeof import('@vueuse/core')['refWithControl']
   const resolveComponent: typeof import('vue')['resolveComponent']
-  const resolveDirective: typeof import('vue')['resolveDirective']
   const resolveRef: typeof import('@vueuse/core')['resolveRef']
   const resolveUnref: typeof import('@vueuse/core')['resolveUnref']
   const setActivePinia: typeof import('pinia')['setActivePinia']

+ 12 - 14
src/components/form/ElFormLayout.vue

@@ -12,7 +12,7 @@ defineProps<Props>()
 
 <template>
   <el-row :gutter="20">
-    <el-col v-bind="item.props" v-for="(item, index) in formItem.children" :key="index">
+    <el-col :span="item.span" v-bind="item.props" v-for="(item, index) in formItem.children" :key="index">
       <component
         :is="'el-' + item.type"
         v-if="containerTypes.includes(item.type)"
@@ -28,19 +28,17 @@ defineProps<Props>()
         </template>
       </component>
       <template v-else>
-        <el-form-item
-          v-for="child in item.children"
-          :label="child.label"
-          :rules="child.rules"
-          :prop="child.name"
-          v-show="!child.hidden"
-        >
-          <form-comp :item="child" v-model="formData[child.name]">
-            <template #[slot.alias]="slotProps" v-for="slot in child.slots" :key="slot.alias">
-              <slot :name="slot.alias" v-bind="slotProps"></slot>
-            </template>
-          </form-comp>
-        </el-form-item>
+        <el-row :gutter="20">
+          <el-col v-for="child in item.children" :span="child.span || formConfig.span || 12" v-show="!child.hidden">
+            <el-form-item :label="child.label" :rules="child.rules" :prop="child.name">
+              <form-comp :item="child" v-model="formData[child.name]">
+                <template #[slot.alias]="slotProps" v-for="slot in child.slots" :key="slot.alias">
+                  <slot :name="slot.alias" v-bind="slotProps"></slot>
+                </template>
+              </form-comp>
+            </el-form-item>
+          </el-col>
+        </el-row>
       </template>
     </el-col>
   </el-row>