<template>
    <el-card style="margin-top:12px" class="simulation-add-add-step1">
        <template #header>推理信息</template>
        <el-form ref="myForm" :model="upForm" :rules="formRules" label-width="120">
            <el-form-item label="任务各称" prop="taskName">
                <el-input v-model="upForm.taskName" placeholder="请输入推理任务名称" />
            </el-form-item>

            <el-form-item label="任务说明" prop="taskDesc">
                <el-input v-model="upForm.taskDesc" type="textarea" style="width:100%;" :rows="4"
                    placeholder="请输入推理任务说明" />
            </el-form-item>

            <el-form-item label="任务类型" prop="taskType">
                <el-select v-model="upForm.taskType" placeholder="请选择" style="width: 48%">
                    <el-option v-for="(it, idx) in taskTypes" :label="it.text" :value="it.id" :key="idx" />
                </el-select>
            </el-form-item>
        </el-form>

    </el-card>
</template>

<script setup>
const myForm = ref(ElForm)
let upForm = reactive({
    taskName: '',
    taskDesc: "",
    taskType: ""
})
const formRules = computed(() => {
    return {
        taskName: [
            {
                required: true,
                trigger: "blur",
                message: "任务名称必填",
            },
        ],
        taskType: [
            {
                required: true,
                trigger: "blur",
                message: "请选择任务类型",
            }
        ]
    };
});
const checkForm = () => {
    return new Promise(resolve => {
        myForm.value.validate(b => {
            resolve(b);
        });
    });

};
const getFormData=()=>{
    return upForm;
}
const taskTypes = reactive([{ id: 1, text: '推理任务类型' }, { id: 2, text: '推理任务类型2' }, { id: 3, text: '推理任务类型3' },])

defineExpose({
    checkForm,
    getFormData
})


</script>
<style lang='scss'></style>