Browse Source

子表单列宽自定义

tongshangming 2 years ago
parent
commit
b318879391
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/components/form/ElFormTable.vue

+ 8 - 1
src/components/form/ElFormTable.vue

@@ -9,6 +9,8 @@ interface Props {
 }
 const props = defineProps<Props>()
 
+const width = (props.formItem?.props as any)?.width
+
 const keys: any = {}
 props.formItem.children &&
   props.formItem.children.forEach((item: BasicFormItem) => {
@@ -35,7 +37,12 @@ const handleDelete = (index: number) => {
       <el-button type="primary" @click="handleAdd" icon="plus" plain size="default" class="mb-2">添加</el-button>
       <vxe-table :data="formItem.value" border>
         <vxe-column type="seq" width="50"></vxe-column>
-        <vxe-column v-for="item in formItem.children" :title="item.label" :field="item.name">
+        <vxe-column
+          v-for="(item, key) in formItem.children"
+          :title="item.label"
+          :field="item.name"
+          :width="isArray(width) ? width[key] : width"
+        >
           <template #default="{ row }">
             <form-comp :item="item" v-model="row[item.name]">
               <template #[slot.alias]="slotProps" v-for="slot in item.slots" :key="slot.alias">