Files
cz-web/src/views/project/cpns/ProjectMilestones.vue
2026-10-09 10:32:49 +08:00

172 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import type { Milestone } from '@/types/business/project'
interface Props {
milestones: Milestone[]
}
const props = defineProps<Props>()
function stateClass(status: Milestone['status']): string {
if (status === '已完成') return 'is-done'
if (status === '进行中') return 'is-active'
return 'is-pending'
}
function linkDone(index: number): boolean {
return props.milestones[index + 1]?.status === '已完成'
}
</script>
<template>
<section class="project-milestones">
<h2 class="project-milestones__title">
项目进度(里程碑)
</h2>
<ol v-if="props.milestones.length > 0" class="project-milestones__track">
<li
v-for="(node, index) in props.milestones"
:key="`${node.name}-${index}`"
class="project-milestones__node"
:class="[stateClass(node.status), { 'is-link-done': linkDone(index) }]"
>
<span class="project-milestones__dot">
<svg
v-if="node.status === '已完成'"
class="project-milestones__check"
viewBox="0 0 16 16"
aria-hidden="true"
>
<path d="M3.5 8.4 6.6 11.5 12.5 4.8" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</span>
<span class="project-milestones__name">{{ node.name }}</span>
<span class="project-milestones__sub">{{ node.time || node.status }}</span>
</li>
</ol>
<p v-else class="project-milestones__empty text-secondary">
暂无里程碑数据
</p>
</section>
</template>
<style lang="less" scoped>
@milestone-dot: 26px;
@milestone-line-h: 3px;
.project-milestones {
.flex(column, flex-start, stretch);
padding: 0;
// 设计稿 el35 "项目进度(里程碑)" (82, 457) 15px/700。
// 上游时间行 y=406(底 421)→ 标题间距 36px。
&__title {
.section-title();
margin-top: 36px;
padding-left: 12px;
font-size: 15px;
font-weight: 700;
line-height: 20px;
&::before {
width: 4px;
height: 20px;
}
}
&__track {
.flex(row, flex-start, flex-start);
margin-top: 0;
padding-top: 21px;
padding-bottom: 0;
overflow-x: auto;
.scrollbar();
}
&__node {
position: relative;
.flex(column, flex-start, center);
flex: 0 0 @milestone-node;
min-width: 0;
&:not(:last-child)::after {
content: '';
position: absolute;
top: (@milestone-dot / 2 - @milestone-line-h / 2); // 13 − 1.5 = 11.5
left: calc(50% + 13px);
width: @milestone-node;
height: @milestone-line-h;
background: @milestone-ring;
}
&.is-link-done:not(:last-child)::after {
background: @milestone-done;
}
}
&__dot {
.flex(row, center, center);
position: relative;
z-index: 1;
width: @milestone-dot;
height: @milestone-dot;
border: 3px solid @milestone-idle;
border-radius: @radius-round;
background: @white;
box-sizing: border-box;
.is-done & {
border-color: @milestone-done;
background: @milestone-done;
}
.is-active & {
border-width: 3px;
border-color: @project-accent;
}
}
&__check {
width: 11px;
height: 11px;
}
&__name {
margin-top: 6px;
max-width: calc(@milestone-node - 16px);
font-size: 12px;
font-weight: 400;
line-height: 16px;
text-align: center;
color: @project-cell;
.multi-ellipsis(2);
.is-done & {
color: @success-color;
}
.is-active & {
color: @project-accent;
font-weight: 600;
}
}
&__sub {
margin-top: 4px;
max-width: calc(@milestone-node - 16px);
font-size: 10px;
line-height: 14px;
text-align: center;
color: @milestone-idle-text;
.multi-ellipsis(2);
}
&__empty {
margin-top: @spacing-base;
font-size: @font-size-body;
}
}
</style>