<template>
    <div class="app-container simulation-add-task">
        <el-card class="card-step">
            <el-steps style="width: 900px;max-width: 900px;" :space="200" :active="active" finish-status="success">
                <el-step title="Step1" :class="active == 0 ? 'active' : ''" description="评估基本信息填写" />
                <el-step title="Step2" :class="active == 1 ? 'active' : ''" description="选择模型" />
                <el-step title="Step3" :class="active == 2 ? 'active' : ''" description="选择设备" />
                <el-step title="Step4" :class="active == 3 ? 'active' : ''" description="评估数据集选择" />
            </el-steps>
        </el-card>
        <div style="margin-bottom:100px;" class="card-content">
            <addStep1 ref="step1" v-if="active == 1" />
            <addStep2 ref="step2" v-if="active == 2"/>
            <addStep3 ref="step3" v-if="active == 3"  :modelInfo="modelInfo"/>
            <addStep4 v-if="active == 4" />
        </div>
        <el-card class="card-footer">
            <el-button type="primary" v-if="active == 3" @click="doCompile">编译部署</el-button>
            <el-button type="primary" v-if="active == 4" @click="doStart">开始</el-button>
            <el-button type="primary" v-if="active > 0 && active <= 4" @click="doPrev">上一步</el-button>
            <el-button @click="doNext" v-if="active < 4">下一步</el-button>
        </el-card>
    </div>
</template>

<script setup>
import addStep1 from './addStep1.vue'
import addStep2 from './addStep2.vue'
import addStep3 from './addStep3.vue'
import addStep4 from './addStep4.vue'
const active = ref(1)
const step1=ref()
const step2=ref()
let taskInfo=reactive({});
let modelInfo=reactive({});

const doStart = () => {

}
const doCompile = () => {

}
const doPrev = () => {
    active.value--;
}
const doNext = () => {
    if(active.value==1){
        step1.value.checkForm().then(d=>{
            if(d){
                taskInfo=step1.value.getFormData();
                active.value++;
            }
        });
    }else if(active.value==2){
        let tmp=step2.value.checkForm();
        if(tmp){
            modelInfo=tmp;
            active.value++;
        }else{
            ElMessage.error("请选择模型!");
        }
    }else{
        active.value++;
    }
}
</script>
<style lang='scss'>
.simulation-add-task {
    .card-step {
        .el-card__body {
            padding-left: 100px;
            display: flex;
            justify-content: center;

            .el-steps {
                flex-grow: 1;
                margin-left: 100px;

                .el-step {
                    &.active {}

                    .el-step__main {
                        position: relative;

                        .el-step__title {
                            display: inline-block;
                            width: 150px;
                            text-align: center;
                            padding: 0px;
                            position: relative;
                            left: -65px;
                        }

                        .el-step__description {
                            display: inline-block;
                            width: 150px;
                            text-align: center;
                            padding: 0px;
                            position: relative;
                            left: -65px;
                        }
                    }
                }
            }
        }
    }

    .card-content {
        .el-card__header {
            padding: 8px 12px;
            display: flex;
            align-items: center;
            font-weight: bold;
        }
    }

    .card-footer {
        position: fixed;
        width: calc(100% - 215px);
        bottom: 0px;

        :deep(.el-card__body) {
            padding: 10px;

            .el-pagination {
                justify-content: end;
            }
        }
    }
}
</style>