Files
aurora-admin/frameworks/Steps.vue2.vue
T

57 lines
2.8 KiB
Vue

<template>
<div class="aa-steps" :class="direction">
<div
v-for="(s, i) in steps" :key="i"
class="aa-step"
:class="'is-' + statusOf(i)"
>
<div class="aa-step-icon">{{ statusOf(i) === 'finish' ? '✓' : (statusOf(i) === 'error' ? '!' : (i + 1)) }}</div>
<div class="aa-step-body">
<div class="aa-step-title">{{ s.title }}</div>
<div v-if="s.desc" class="aa-step-desc">{{ s.desc }}</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'AaSteps',
props: {
steps: { type: Array, required: true }, // [{ title, desc? }]
current: { type: Number, default: 0 }, // 当前步骤索引
errorAt: { type: Number, default: -1 }, // 异常步骤索引
direction: { type: String, default: 'horizontal' } // horizontal | vertical
},
methods: {
statusOf(i) {
if (i === this.errorAt) return 'error';
if (i < this.current) return 'finish';
if (i === this.current) return 'process';
return 'wait';
}
}
};
</script>
<!-- 样式对齐 组件2/7 StepList 规范 -->
<style>
.aa-steps { font-family: var(--font-family, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif); color: #262626; }
.aa-steps.horizontal { display: flex; }
.aa-steps.vertical { display: inline-flex; flex-direction: column; }
.aa-step { position: relative; display: flex; gap: 12px; flex: 1; }
.aa-steps.vertical .aa-step { flex-direction: column; }
.aa-step-icon { position: relative; width: 32px; height: 32px; border-radius: 50%; border: 2px solid #E8ECF1; display: flex; align-items: center; justify-content: center; font-size: 14px; background: #fff; color: #8C8C8C; flex-shrink: 0; z-index: 1; }
.aa-step.is-finish .aa-step-icon { border-color: #2F54EB; color: #2F54EB; background: #F0F5FF; }
.aa-step.is-process .aa-step-icon { border-color: #2F54EB; color: #fff; background: #2F54EB; }
.aa-step.is-error .aa-step-icon { border-color: #F5222D; color: #F5222D; background: #FFF1F0; }
.aa-step-title { font-size: 14px; font-weight: 500; line-height: 32px; }
.aa-step.is-wait .aa-step-title { color: #8C8C8C; }
.aa-step-desc { font-size: 12px; color: #8C8C8C; margin-top: 2px; }
.aa-steps.horizontal .aa-step:not(:last-child) .aa-step-icon::after { content: ''; position: absolute; top: 15px; left: 38px; right: -12px; height: 2px; background: #E8ECF1; }
.aa-steps.horizontal .aa-step.is-finish:not(:last-child) .aa-step-icon::after { background: #2F54EB; }
.aa-steps.vertical .aa-step-body { padding-bottom: 24px; }
.aa-steps.vertical .aa-step:not(:last-child) .aa-step-icon::after { content: ''; position: absolute; top: 40px; left: 15px; bottom: -12px; width: 2px; background: #E8ECF1; }
.aa-steps.vertical .aa-step.is-finish:not(:last-child) .aa-step-icon::after { background: #2F54EB; }
</style>