hookehuyr

fix(components): 修复动态表单字段处理和边框样式问题

修复AddTargetDialog组件中最后一个字段的边框显示问题,优化CheckinDetailPage组件中动态表单字段的处理逻辑,简化ID获取方式并使用后端提供的类型字段
......@@ -9,7 +9,7 @@
@update:show="updateShow"
>
<div class="p-4">
<div v-for="field in localFields" :key="field.id">
<div v-for="(field, index) in localFields" :key="field.id">
<van-field
v-model="field.value"
label-width="5rem"
......@@ -18,7 +18,7 @@
:type="field.type === 'textarea' ? 'textarea' : 'text'"
:rows="field.type === 'textarea' ? 2 : 1"
:autosize="field.type === 'textarea'"
class="border-b border-gray-100"
:class="{'border-b border-gray-100': index < localFields.length - 1}"
:required="field.required"
/>
</div>
......
......@@ -166,8 +166,7 @@
</van-popup>
<!-- 图片预览弹窗 -->
<van-image-preview v-model:show="imageShow" :images="imageList" :start-position="imageIndex"
:show-index="true" />
<van-image-preview v-model:show="imageShow" :images="imageList" :start-position="imageIndex" :show-index="true" />
</div>
</template>
......@@ -243,16 +242,12 @@ const personType = ref('') // 动态表单字段中的person_type
*/
const updateDynamicFormFields = (option) => {
if (option.field_list && Array.isArray(option.field_list)) {
// 处理动态表单字段
dynamicFormFields.value = option.field_list.map(field => {
// 尝试多种方式获取ID
const id = field.field_name || field.id || field.name || field.key || field.field
if (!id) {
console.warn('动态表单字段缺少ID:', field)
}
return {
id: id,
id: field.field,
label: field.label || '未命名',
type: 'text', // 默认类型,如果后端有类型字段可替换
type: field.type || 'text', // 默认类型,如果后端有类型字段可替换
required: true // 默认必填,如果后端有必填字段可替换
}
})
......