<template>
    <ai-form-item :prop="renderRule.fieldName">
        <view class="flex-1 fx-col">
            <slot :name="slotName"/>
        </view>
    </ai-form-item>
    <uv-text v-if="renderRule.tips" type="tips" size="12" :text="renderRule.tips" prefix-icon="info-circle"
             :icon-style="{color: 'var(--warning-color)', fontSize: '14px'}"/>
</template>

<script>
import AiFormItem from "@/pages/ie/components/ai-form/ai-form-item.vue";
import MxConst from "@/common/MxConst";

export default {
    name: "ai-form-item-template",
    components: {AiFormItem},
    props: {
        renderRule: {
            type: Object,
            default: () => ({})
        }
    },
    computed: {
        slotName() {
            const types = Object.entries(MxConst.enum.ai.inputType)
            const match = types.find(t => t[1] == this.renderRule.enumInputType)
            if (!match) console.warn(`渲染类型不在预定的类型范畴[enumInputType:${this.renderRule.enumInputType}]，将按text模式渲染`)
            return match ? match[0] : 'text'
        }
    }
}
</script>

<style scoped>

</style>