步骤条组件,用于展示流程进度、当前步骤状态和每个步骤的扩展内容。
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
steps | StepsItem[] | - | 步骤列表 |
status | 'error' | 'process' | 'wait' | 'finish' | 'process' | 当前步骤状态 |
class | HTMLAttributes['class'] | - | 自定义 CSS 类 |
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
modelValue | number | 0 | 当前步骤下标,从 0 开始 |
| 属性 | 类型 | 说明 |
|---|---|---|
id | string | 步骤唯一标识,也是具名插槽名称 |
title | string | 步骤标题 |
description | string | 步骤描述 |
每个步骤都可以通过 steps.id 对应的具名插槽扩展内容。
| 名称 | 说明 | 作用域参数 |
|---|---|---|
[steps.id] | 指定步骤的扩展内容 | step: StepsItem - 当前步骤数据index: number - 当前步骤下标status: StepsStatus - 当前步骤最终状态active: boolean - 是否为当前步骤finished: boolean - 是否已完成 |
<script setup lang="ts">
import type { StepsItem } from '@fantastic-admin/components'
const steps: StepsItem[] = [
{ id: 'account', title: '账号信息', description: '填写登录账号' },
{ id: 'profile', title: '完善资料', description: '补充姓名与部门' },
{ id: 'permission', title: '分配权限', description: '选择角色和菜单' },
{ id: 'done', title: '完成', description: '确认并提交' },
]
</script>
<template>
<FaSteps :model-value="2" :steps="steps" />
</template><script setup lang="ts">
import type { StepsItem } from '@fantastic-admin/components'
const currentStep = ref(1)
const steps: StepsItem[] = [
{ id: 'create', title: '创建订单', description: '录入客户和商品' },
{ id: 'payment', title: '支付确认', description: '等待支付结果' },
{ id: 'delivery', title: '安排发货', description: '选择物流渠道' },
{ id: 'finish', title: '订单完成', description: '归档交易记录' },
]
function prevStep() {
currentStep.value = Math.max(currentStep.value - 1, 0)
}
function nextStep() {
currentStep.value = Math.min(currentStep.value + 1, steps.length - 1)
}
</script>
<template>
<div class="flex flex-col gap-6">
<FaSteps v-model="currentStep" :steps="steps" />
<FaButtonGroup class="mx-auto">
<FaButton variant="outline" :disabled="currentStep === 0" @click="prevStep">
上一步
</FaButton>
<FaButton :disabled="currentStep === steps.length - 1" @click="nextStep">
下一步
</FaButton>
</FaButtonGroup>
</div>
</template><script setup lang="ts">
import type { StepsItem, StepsStatus } from '@fantastic-admin/components'
const currentStep = ref(1)
const status = ref<StepsStatus>('wait')
const steps: StepsItem[] = [
{ id: 'draft', title: '提交资料', description: '保存申请表单' },
{ id: 'review', title: '审核中', description: '等待主管确认' },
{ id: 'archive', title: '归档', description: '生成最终记录' },
]
</script>
<template>
<FaSteps v-model="currentStep" :steps="steps" :status="status" />
</template><script setup lang="ts">
import type { StepsItem } from '@fantastic-admin/components'
const steps: StepsItem[] = [
{ id: 'prepare', title: '准备', description: '校验订单信息' },
{ id: 'ship', title: '发货', description: '同步物流单号' },
{ id: 'receive', title: '签收', description: '确认客户收货' },
]
</script>
<template>
<FaSteps :model-value="1" :steps="steps">
<template #prepare="{ finished }">
<div v-if="finished" class="text-xs text-green-500">
商品库存已锁定
</div>
</template>
<template #ship="{ active, status }">
<div v-if="active" class="text-xs text-muted-foreground">
当前节点:{{ status }},物流单待生成
</div>
</template>
</FaSteps>
</template>modelValue 从 0 开始,和 steps 数组下标保持一致process:当前步骤进行中,显示步骤序号wait:当前步骤等待中,显示加载图标和呼吸动效finish:当前步骤完成,显示完成图标error:当前步骤异常,显示错误图标status 为 finish 时,当前步骤也视为已完成steps.id,请确保每个步骤的 id 唯一且适合作为 Vue slot name