a-col

文章展示了如何在Vue应用中使用AntDesignVue库创建一个具有行列布局的表单,特别是焦点在于`a-col`用于列布局,`a-form-item`配合`labelCol`和`wrapperCol`定义标签和输入域的分布,以及`a-textarea`用于创建可调整大小的文本区域,用`v-decorator`进行数据绑定。

表单里面的里面的行列布局

<a-col :span="23" >
 <a-form-item :labelCol="{ span: 3 }" :wrapperCol="{ span: 18 }" label="备注">
   <a-textarea placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 2 }"
      v-decorator="['remark', {}]" />
 </a-form-item>
</a-col>

主要想优化card内部字段的放置: <a-row> <a-col :span="12"> <a-form-model-item :prop="'StepForms.' + index + '.fabName'" label="Fab Area:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-select placeholder="请选择" v-model="step.fabName" style="width: 100%" :disabled="step.isSubmitted" @change="(value) => handleFabNameChange(value, step)"> <a-select-option v-for="item in StepFabAreaList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.area'" label="Area:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-select placeholder="请选择" v-model="step.area" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in StepAreaList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <!-- RCP 字段 --> <a-col :span="12"> <a-form-model-item label="Check With RCP" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }"> <a-checkbox :checked="step.rcp === 'on'" @change="(e) => handleRcpChange(e, step)" :disabled="step.isSubmitted"> </a-checkbox> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="16"> <a-form-model-item prop="'StepForms.' + index + '.stepNo'" label="Reference Step No" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12 }" :required='required'> <div style="display: flex; align-items: center; gap: 8px; white-space: nowrap;"> <a-checkbox :checked="step.noStepNo === 'on'" @change="(e) => handleNoStepNoChange(e, step)" :disabled="step.isSubmitted || step.isstepNoupdate">NA </a-checkbox> <a-input v-model="step.stepNo" placeholder="Enter Step No" :disabled="step.isreadonlyStepNo || step.isSubmitted || step.isstepNoupdate" style="flex: 1; height: 32px;" /> <a-button @click="getStepLotInfo(index)" style="height: 32px;" :disabled="step.isSubmitted || step.isstepNoupdate">Go </a-button> <a-button @click="getfuturestepinfo(index)" style="height: 32px;" :disabled="step.isSubmitted || step.isstepNoupdate"> ViewFutureStep</a-button> </div> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.eqpMode'" label="Equipment:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 6, offset: 2 }" :required='required'> <a-select placeholder="请选择" v-model="step.eqpMode" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in StepEqpModeList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.eqpModeName'" label="" :labelCol="{ span: 6 }" :wrapperCol="{ span: 20, offset: 2 }" :required='required'> <div style="display: flex; align-items: center; gap: 8px; Height: 40px;"> <a-input v-model="step.eqpModeName" :disabled="step.isSubmitted" @blur="handleEqpNameBlur(step)" /> <div style="color: red; white-space: nowrap;"> EqpGroup区分大小写,输入的EqpID最大长度7位!!! </div> </div> </a-form-model-item> </a-col> </a-row> <!-- Recipe 字段(根据条件显示) --> <a-row> <a-col :span="12" v-if="!step.showPhotoFields"> <a-form-model-item prop="'StepForms.' + index + '.recipe'" label="Recipe:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <div style="display: flex; align-items: center; gap: 8px; Height: 40px;"> <a-input v-model="step.recipe" :disabled="step.isSubmitted" /> <div style="color: red; white-space: nowrap;"> 区分大小写!!! </div> </div> </a-form-model-item> </a-col> </a-row> <!-- Photo 相关字段(当 area 包含 photo 时显示) --> <template v-if="step.showPhotoFields"> <a-row> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.trackOutRecipe'" label="TrackOut Recipe:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <template #help> <span style="color: red;"> 区分大小写!!!</span> </template> <a-input v-model="step.trackOutRecipe" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.scannerRecipe'" label="Scanner Recipe:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <template #help> <span style="color: red;"> 区分大小写!!!</span> </template> <a-input v-model="step.scannerRecipe" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="Recipe Type:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-radio-group :value="step.recipeType" @change="(e) => handleRecipeTypeChange(e, step, index)" :disabled="step.isSubmitted"> <a-radio value="Production">Production</a-radio> <a-radio value="Engineer" @click.stop="confirmEngineer(step, index)">Engineer</a-radio> </a-radio-group> </a-form-model-item> </a-col> <template v-if="step.recipeType === 'Engineer'"> <a-col :span="12"> <a-form-model-item label="Batch Type:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-radio-group :value="step.batchType" @change="(e) => handleBatchTypeChange(e, step, index)" :disabled="step.isSubmitted"> <a-radio value="Production">Production</a-radio> <a-radio value="Matrix" @click.stop="confirmMatrix(step, index)">Matrix</a-radio> </a-radio-group> </a-form-model-item> </a-col> </template> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.reticleId'" label="Reticle ID:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-input v-model="step.reticleId" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.energy'" label="Energy:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-input v-model="step.energy" :disabled="step.isSubmitted" @blur="handleEnergyFocusStepBlur(step)" /> </a-form-model-item> </a-col> <template v-if="step.batchType === 'Matrix'"> <a-col :span="12"> <a-form-model-item label="Energy Step:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }"> <template #help> <span style="color: red;">(Value:-1000.0~1000.0)</span> </template> <a-input v-model="step.energyStep" :disabled="step.isSubmitted" @blur="handleEnergyFocusStepBlur(step)" /> </a-form-model-item> </a-col> </template> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.focus'" label="Focus:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-input v-model="step.focus" :disabled="step.isSubmitted" @blur="handleEnergyFocusStepBlur(step)" /> </a-form-model-item> </a-col> <template v-if="step.batchType === 'Matrix'"> <a-col :span="12"> <a-form-model-item label="Focus Step:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <template #help> <span style="color: red;">(Value:-2.00~2.00)</span> </template> <a-input v-model="step.focusStep" :disabled="step.isSubmitted" @blur="handleEnergyFocusStepBlur(step)" /> </a-form-model-item> </a-col> </template> <!-- <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.ovlData'" label="OVL Data:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-textarea v-model="step.ovlData" :rows="3" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> --> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.ovlData'" label="OVL Data:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-textarea v-model="step.ovlData" @click="() => openOvLDataModal(index)" read-only style="cursor: pointer" :rows="3" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> </a-row> </template> <a-row> <!-- WaferID 显示和弹窗按钮 --> <a-col :span="18"> <a-form-model-item prop="'StepForms.' + index + '.waferId'" label="WaferID" :labelCol="{ span: 3 }" :wrapperCol="{ span: 15 }" :required='required'> <a-input :value="step.waferId" placeholder="请选择 WaferID" @click="() => openWaferModal(index)" read-only style="cursor: pointer" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <!-- QTY 数量显示 --> <a-col :span="6"> <a-form-model-item prop="'StepForms.' + index + '.waferIdQty'" label="QTY" :labelCol="{ span: 3 }" :wrapperCol="{ span: 3 }"> <a-input :value="step.waferIdQty.toString()" read-only :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> </a-row> <a-row> <!-- MeasWaferID 显示和弹窗按钮 --> <a-col :span="18"> <a-form-model-item prop="'StepForms.' + index + '.slotId'" label="MeasSlotId" :labelCol="{ span: 3 }" :wrapperCol="{ span: 15 }"> <a-input :value="step.slotId" placeholder="请选择量测 WaferID" @click="() => openMeasWaferModal(index)" read-only style="cursor: pointer" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <!-- MeasWaferIDQTY 数量显示 --> <a-col :span="6"> <a-form-model-item prop="'StepForms.' + index + '.slotIdQty'" label="QTY" :labelCol="{ span: 3 }" :wrapperCol="{ span: 3 }"> <a-input :value="step.slotIdQty.toString()" read-only :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> </a-row> <a-row> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.contaminationFlag'" label="ContaminationFlag:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 12, offset: 2 }" :required='required'> <a-select placeholder="请选择" v-model="step.contaminationFlag" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in contaminationFlagList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.remark'" label="Remark:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }" :required='required'> <template #help> <span style="color: red;">如果输入中文,Runcard只能Manual Run!!!</span> </template> <a-textarea v-model="step.remark" placeholder="100字内..." :rows="3" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.ecdPlanName'" label="EDC Plan Name:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.ecdPlanName" placeholder="Enter EDC PlanName" :disabled="step.isSubmitted" /> <a-button @click="getEdcPlanSpecInfomation(index)" :disabled="step.isSubmitted">Go</a-button> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item prop="'StepForms.' + index + '.spec'" label="量测规格SPEC:" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-textarea v-model="step.spec" read-only style="overflow: auto; white-space: nowrap;" :row="3" /> </a-form-model-item> </a-col> </a-row>
最新发布
12-07
你当前的 `a-card` 内部字段布局存在以下问题: --- ### ❗当前问题分析: | 问题 | 描述 | |------|------| | 字段对齐混乱 | `labelCol` 和 `wrapperCol` 不统一,导致视觉不一致 | | 表单项间距不统一 | 有些字段紧贴,有些间距大,影响阅读 | | 表单字段嵌套混乱 | 多个 `a-row` 和 `a-col` 嵌套,结构复杂 | | `label` 长短不一 | 长 label 挤压输入框,影响布局美观 | | 输入组件高度不一致 | `a-input`、`a-select`、`a-button` 高度不统一 | --- ### ✅ 优化目标: - 字段统一布局,视觉对称 - 表单项间距一致 - label 长度统一,输入框宽度统一 - 组件高度统一 - 响应式设计(PC / 平板适配) --- ## ✅ 推荐优化方案 ### ✨ 1. 使用统一的 `labelCol` 和 `wrapperCol` ```vue <a-form-model-item label="Fab Area" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> ``` --- ### ✨ 2. 使用 `a-space` 控制按钮间距 ```vue <a-space size="middle"> <a-button>Go</a-button> <a-button>ViewFutureStep</a-button> </a-space> ``` --- ### ✨ 3. 使用 `a-row :gutter="16"` 提升字段间距一致性 ```vue <a-row :gutter="16"> <a-col :span="12"> <!-- 字段1 --> </a-col> <a-col :span="12"> <!-- 字段2 --> </a-col> </a-row> ``` --- ### ✨ 4. 使用 `a-form-item` 统一高度 ```vue <a-form-model-item label="Recipe" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.recipe" style="height: 32px;" /> </a-form-model-item> ``` --- ## ✅ 优化后的字段布局示例(精选部分字段) ```vue <a-card :title="`Run Card Step ${index + 1}`" style="margin-top: 16px; border-radius: 8px;"> <a-row :gutter="16"> <!-- Fab Area + Area --> <a-col :span="12"> <a-form-model-item label="Fab Area" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-select v-model="step.fabName" style="width: 100%" :disabled="step.isSubmitted" @change="(value) => handleFabNameChange(value, step)"> <a-select-option v-for="item in StepFabAreaList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="Area" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-select v-model="step.area" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in StepAreaList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <!-- RCP --> <a-col :span="12"> <a-form-model-item label="Check With RCP" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-checkbox :checked="step.rcp === 'on'" @change="(e) => handleRcpChange(e, step)" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> </a-row> <!-- Reference Step No --> <a-row :gutter="16"> <a-col :span="24"> <a-form-model-item label="Reference Step No" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-space direction="horizontal" style="width: 100%; display: flex; align-items: center;"> <a-checkbox :checked="step.noStepNo === 'on'" @change="(e) => handleNoStepNoChange(e, step)" :disabled="step.isSubmitted || step.isstepNoupdate">NA</a-checkbox> <a-input v-model="step.stepNo" placeholder="Enter Step No" :disabled="step.isreadonlyStepNo || step.isSubmitted || step.isstepNoupdate" /> <a-button @click="getStepLotInfo(index)">Go</a-button> <a-button @click="getfuturestepinfo(index)">ViewFutureStep</a-button> </a-space> </a-form-model-item> </a-col> </a-row> <!-- Equipment + Eqp Mode Name --> <a-row :gutter="16"> <a-col :span="12"> <a-form-model-item label="Equipment" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-select v-model="step.eqpMode" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in StepEqpModeList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="Eqp Mode Name" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.eqpModeName" :disabled="step.isSubmitted" @blur="handleEqpNameBlur(step)" /> <span style="color: red; font-size: 12px;">EqpGroup区分大小写,输入的EqpID最大长度7位</span> </a-form-model-item> </a-col> </a-row> <!-- Recipe --> <a-row :gutter="16" v-if="!step.showPhotoFields"> <a-col :span="12"> <a-form-model-item label="Recipe" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.recipe" :disabled="step.isSubmitted" /> <span style="color: red; font-size: 12px;">区分大小写</span> </a-form-model-item> </a-col> </a-row> <!-- Photo Fields --> <template v-if="step.showPhotoFields"> <a-divider orientation="left">Photo Settings</a-divider> <a-row :gutter="16"> <a-col :span="12"> <a-form-model-item label="TrackOut Recipe" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.trackOutRecipe" :disabled="step.isSubmitted" /> <span style="color: red; font-size: 12px;">区分大小写</span> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="Scanner Recipe" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input v-model="step.scannerRecipe" :disabled="step.isSubmitted" /> <span style="color: red; font-size: 12px;">区分大小写</span> </a-form-model-item> </a-col> </a-row> <a-row :gutter="16"> <a-col :span="12"> <a-form-model-item label="Recipe Type" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-radio-group v-model="step.recipeType" :disabled="step.isSubmitted" @change="(e) => handleRecipeTypeChange(e, step, index)"> <a-radio value="Production">Production</a-radio> <a-radio value="Engineer" @click.stop="confirmEngineer(step, index)">Engineer</a-radio> </a-radio-group> </a-form-model-item> </a-col> <a-col :span="12" v-if="step.recipeType === 'Engineer'"> <a-form-model-item label="Batch Type" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-radio-group v-model="step.batchType" :disabled="step.isSubmitted" @change="(e) => handleBatchTypeChange(e, step, index)"> <a-radio value="Production">Production</a-radio> <a-radio value="Matrix" @click.stop="confirmMatrix(step, index)">Matrix</a-radio> </a-radio-group> </a-form-model-item> </a-col> </a-row> </template> <!-- Wafer ID + Qty --> <a-row :gutter="16"> <a-col :span="18"> <a-form-model-item label="WaferID" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input :value="step.waferId" @click="() => openWaferModal(index)" read-only style="cursor: pointer" :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> <a-col :span="6"> <a-form-model-item label="QTY" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-input :value="step.waferIdQty.toString()" read-only :disabled="step.isSubmitted" /> </a-form-model-item> </a-col> </a-row> <!-- ContaminationFlag + Remark --> <a-row :gutter="16"> <a-col :span="12"> <a-form-model-item label="ContaminationFlag" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-select v-model="step.contaminationFlag" style="width: 100%" :disabled="step.isSubmitted"> <a-select-option v-for="item in contaminationFlagList" :key="item">{{ item }}</a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="Remark" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }"> <a-textarea v-model="step.remark" :rows="3" :disabled="step.isSubmitted" /> <span style="color: red; font-size: 12px;">如果输入中文,Runcard只能Manual Run!!!</span> </a-form-model-item> </a-col> </a-row> </a-card> ``` --- ## ✅ 优化总结 | 优化项 | 效果 | |--------|------| | 使用 `a-row :gutter="16"` | 提高字段间距一致性 | | 统一 `labelCol` 和 `wrapperCol` | 提高表单对齐性 | | 使用 `a-space` 控制按钮间距 | 提高按钮区域美观性 | | 使用 `a-divider` 分隔区块 | 提高视觉层次 | | 统一输入框高度和宽度 | 提高整体一致性 | | 使用 `v-if` 控制条件渲染 | 提高性能与结构清晰度 | --- ### ✅ 推荐额外优化: - 使用 `a-tabs` 将字段分类展示(如 Basic Info / Photo Info / QTime Info) - 使用 `a-form-model` 的 `ref` 实现统一校验 - 使用 `a-form-model-item` 的 `help` 插槽统一提示信息 - 使用 `customRow` 和 `customCell` 优化表格样式 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值