feat: 评测创建改为分步向导
任务配置与评测规则拆分为两个独立步骤,新增步骤导航条与下一步/返回流程,逐步校验任务配置后再进入规则设置,提交时仅校验规则项。
This commit is contained in:
@@ -16,9 +16,15 @@ type StepExposed = { validate: () => Promise<boolean> }
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
const currentStep = ref(0)
|
||||||
const taskStepRef = ref<StepExposed>()
|
const taskStepRef = ref<StepExposed>()
|
||||||
const ruleStepRef = ref<StepExposed>()
|
const ruleStepRef = ref<StepExposed>()
|
||||||
|
|
||||||
|
const WIZARD_STEPS = [
|
||||||
|
{ title: '任务配置', description: '选择模型、算力与评测数据' },
|
||||||
|
{ title: '评测规则', description: '选择或创建评测维度' },
|
||||||
|
] as const
|
||||||
|
|
||||||
const trainedModels = ref<TrainedModel[]>([])
|
const trainedModels = ref<TrainedModel[]>([])
|
||||||
const evalDatasets = ref<DatasetItem[]>([])
|
const evalDatasets = ref<DatasetItem[]>([])
|
||||||
const dimensions = ref<Dimension[]>([])
|
const dimensions = ref<Dimension[]>([])
|
||||||
@@ -131,10 +137,9 @@ async function resolveDimensionId() {
|
|||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (loading.value || submitting.value) return
|
if (loading.value || submitting.value) return
|
||||||
const taskValid = await taskStepRef.value?.validate()
|
|
||||||
const ruleValid = await ruleStepRef.value?.validate()
|
const ruleValid = await ruleStepRef.value?.validate()
|
||||||
if (!taskValid || !ruleValid) {
|
if (!ruleValid) {
|
||||||
ElMessage.warning('请检查并完善所有必填项')
|
ElMessage.warning('请检查并完善评测规则')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +166,21 @@ async function handleSubmit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleNext() {
|
||||||
|
if (loading.value || submitting.value) return
|
||||||
|
const taskValid = await taskStepRef.value?.validate()
|
||||||
|
if (!taskValid) {
|
||||||
|
ElMessage.warning('请检查并完善任务配置')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentStep.value = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBack() {
|
||||||
|
if (submitting.value) return
|
||||||
|
currentStep.value = 0
|
||||||
|
}
|
||||||
|
|
||||||
function handleCancel() {
|
function handleCancel() {
|
||||||
router.back()
|
router.back()
|
||||||
}
|
}
|
||||||
@@ -170,10 +190,38 @@ onMounted(loadData)
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<PageCard title="新建评测任务" subtitle="完成任务配置与评测规则设置后启动评测">
|
<PageCard title="新建评测任务" subtitle="完成任务配置与评测规则设置后启动评测">
|
||||||
<div v-loading="loading" class="form-container">
|
<div class="create-wizard-layout">
|
||||||
<div class="section-card">
|
<main v-loading="loading" class="wizard-main">
|
||||||
<div class="section-title">任务基本配置</div>
|
<div class="wizard-steps-container" aria-label="评测任务创建步骤">
|
||||||
|
<div class="custom-wizard-steps">
|
||||||
|
<div
|
||||||
|
v-for="(step, index) in WIZARD_STEPS"
|
||||||
|
:key="step.title"
|
||||||
|
class="step-item"
|
||||||
|
:class="{
|
||||||
|
'is-active': currentStep === index,
|
||||||
|
'is-completed': currentStep > index,
|
||||||
|
}"
|
||||||
|
:aria-current="currentStep === index ? 'step' : undefined"
|
||||||
|
>
|
||||||
|
<div v-if="index !== 0" class="step-connector"></div>
|
||||||
|
<div class="step-node">
|
||||||
|
<div class="step-icon" aria-hidden="true">
|
||||||
|
<i v-if="currentStep > index" class="fa fa-check" />
|
||||||
|
<span v-else>{{ index + 1 }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="step-text">
|
||||||
|
<div class="step-title">{{ step.title }}</div>
|
||||||
|
<div class="step-description">{{ step.description }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wizard-content">
|
||||||
<EvalTaskSetupStep
|
<EvalTaskSetupStep
|
||||||
|
v-if="currentStep === 0"
|
||||||
ref="taskStepRef"
|
ref="taskStepRef"
|
||||||
v-model="taskForm"
|
v-model="taskForm"
|
||||||
:trained-models="trainedModels"
|
:trained-models="trainedModels"
|
||||||
@@ -182,11 +230,8 @@ onMounted(loadData)
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
:disabled="submitting"
|
:disabled="submitting"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="section-card">
|
|
||||||
<div class="section-title">评测规则设置</div>
|
|
||||||
<EvalRuleSetupStep
|
<EvalRuleSetupStep
|
||||||
|
v-else
|
||||||
ref="ruleStepRef"
|
ref="ruleStepRef"
|
||||||
v-model="ruleForm"
|
v-model="ruleForm"
|
||||||
:dimensions="dimensions"
|
:dimensions="dimensions"
|
||||||
@@ -194,52 +239,201 @@ onMounted(loadData)
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
:disabled="submitting"
|
:disabled="submitting"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
|
|
||||||
<div class="form-footer">
|
<footer class="wizard-footer">
|
||||||
<el-button :disabled="submitting" @click="handleCancel">取消</el-button>
|
<el-button
|
||||||
<el-button
|
v-if="currentStep === 1"
|
||||||
type="primary"
|
class="footer-back"
|
||||||
:loading="submitting"
|
:disabled="submitting"
|
||||||
:disabled="loading"
|
@click="handleBack"
|
||||||
@click="handleSubmit"
|
>
|
||||||
>
|
<i class="fa fa-arrow-left footer-button-icon" />返回:任务配置
|
||||||
创建并启动评测
|
</el-button>
|
||||||
</el-button>
|
<el-button v-else class="footer-back" :disabled="submitting" @click="handleCancel">
|
||||||
</div>
|
取消
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
v-if="currentStep === 0"
|
||||||
|
type="primary"
|
||||||
|
:disabled="loading || submitting"
|
||||||
|
@click="handleNext"
|
||||||
|
>
|
||||||
|
下一步:评测规则<i class="fa fa-arrow-right footer-button-icon is-right" />
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-else
|
||||||
|
type="primary"
|
||||||
|
:loading="submitting"
|
||||||
|
:disabled="loading || submitting"
|
||||||
|
@click="handleSubmit"
|
||||||
|
>
|
||||||
|
创建并启动评测
|
||||||
|
</el-button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
</PageCard>
|
</PageCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.form-container {
|
.create-wizard-layout {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 24px;
|
min-height: 620px;
|
||||||
|
margin: -20px;
|
||||||
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-card {
|
.wizard-main {
|
||||||
padding: 24px;
|
flex: 1;
|
||||||
border-radius: 8px;
|
padding: 32px;
|
||||||
background: #f9fafb;
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.wizard-steps-container {
|
||||||
font-size: 16px;
|
margin-bottom: 32px;
|
||||||
font-weight: 600;
|
padding-bottom: 24px;
|
||||||
color: #111827;
|
border-bottom: 1px dashed #e2e8f0;
|
||||||
margin-bottom: 24px;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
border-bottom: 1px solid #e5e7eb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-footer {
|
.custom-wizard-steps {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
max-width: 760px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item:first-child {
|
||||||
|
flex: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-connector {
|
||||||
|
flex: 1;
|
||||||
|
height: 2px;
|
||||||
|
margin: 0 20px;
|
||||||
|
background: #e2e8f0;
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item.is-active .step-connector,
|
||||||
|
.step-item.is-completed .step-connector {
|
||||||
|
background: #5146e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-node {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-icon {
|
||||||
|
display: flex;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
flex: 0 0 30px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 2px solid #cbd5e1;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #fff;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 650;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-title {
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-description {
|
||||||
|
margin-top: 3px;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item.is-active .step-icon {
|
||||||
|
border-color: #5146e5;
|
||||||
|
background: #eef2ff;
|
||||||
|
color: #5146e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item.is-active .step-title,
|
||||||
|
.step-item.is-completed .step-title {
|
||||||
|
color: #1e293b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-item.is-completed .step-icon {
|
||||||
|
border-color: #5146e5;
|
||||||
|
background: #5146e5;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-content {
|
||||||
|
max-width: 920px;
|
||||||
|
min-height: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-footer {
|
||||||
|
display: flex;
|
||||||
|
min-height: 64px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-top: 32px;
|
padding: 0 32px;
|
||||||
padding-top: 24px;
|
border-top: 1px solid #e2e8f0;
|
||||||
border-top: 1px solid #e5e7eb;
|
background: #fff;
|
||||||
|
box-shadow: 0 -4px 6px -1px rgb(15 23 42 / 2%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-back {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-button-icon {
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-button-icon.is-right {
|
||||||
|
margin-right: 0;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
.wizard-main {
|
||||||
|
padding: 24px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-wizard-steps {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-connector {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-description {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-footer {
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user