feat: GiForm 支持 label 自定义渲染,以及插槽自定义渲染(同步 GiDemo 更新)

This commit is contained in:
2024-11-23 23:05:30 +08:00
parent 99f8edb729
commit c2463fc450
2 changed files with 15 additions and 3 deletions

View File

@@ -7,9 +7,13 @@
:span="item.span || options.gridItem?.span"
>
<a-form-item
v-bind="item.formItemProps" :label="item.label" :field="item.field" :rules="item.rules"
v-bind="item.formItemProps" :field="item.field" :rules="item.rules"
:disabled="isDisabled(item.disabled)"
>
<template #label>
<template v-if="typeof item.label === 'string'">{{ item.label }}</template>
<component :is="item.label" v-else></component>
</template>
<slot
v-if="!['group-title'].includes(item.type || '')" :name="item.field"
v-bind="{ disabled: isDisabled(item.disabled) }"
@@ -25,7 +29,12 @@
:is="`a-${item.type}`" v-else v-bind="getComponentBindProps(item)"
:model-value="modelValue[item.field as keyof typeof modelValue]"
@update:model-value="valueChange($event, item.field)"
></component>
>
<template v-for="(slotValue, slotKey) in item?.slots" :key="slotKey" #[slotKey]>
<template v-if="typeof slotValue === 'string'">{{ slotValue }}</template>
<component :is="slotValue" v-else></component>
</template>
</component>
</slot>
<slot v-else name="group-title">
<a-alert v-bind="item.props">{{ item.label }}</a-alert>