效果图
<template>
<div
class="time-line"
:style="{
'margin-bottom': processList.length % 2 === 0 ? 84 + Math.floor(processList.length / 2) * 18 + 'px' : (processList.length / 2) * 18 + 'px'
}"
>
<template v-for="(item, index) in processList" :key="index">
<div
:class="{ 'first-item': index === 0, 'comment-end': item.type == 'comment_end', 'comment-start': item.type == 'comment_start' }"
class="item"
:style="{
top: index % 2 === 1 ? 66 + Math.floor(index / 2) * 18 + 'px' : (Math.floor(index / 2) - 1 > 0 ? Math.floor(index / 2) - 1 : 0.05) * 18 + 'px'
}"
>
<div class="time-num" v-if="index !== 0">{{ processList.length - index }}</div>
<div class="title">{{ item.operationModule }}</div>
<div class="content" v-if="item.type != 'comment_start' && item.type != 'comment_end'">
<div class="item-box">
<span class="label">操作人:</span>
<span class="value" :title="item?.assigneeName">{{ item?.assigneeName }}</span>
</div>
<div class="item-box">
<span class="label">时间:</span>
<span class="value">{{ item?.completedTime }}</span>
</div>
<div class="item-box">
<span class="label">意见:</span>
<span class="value" :title="item.message ? item.message : ''">{{ item?.message }}</span>
</div>
</div>
<div class="btn-box" :title="item?.activityName">{{ item?.activityName }}</div>
<div class="arrow"></div>
</div>
</template>
</div>
</template>
<script>
import { defineComponent, ref, onMounted } from 'vue'
export default defineComponent({
name: 'proccess-component',
props: {
// 后台获取的数据,根据实际情况修改element的key
processList: {
type: Array,
required: true,
default: () => []
}
},
})
</script>
<style lang="scss" scoped>
.time-line {
width: 800px;
position: relative;
display: flex;
flex-wrap: wrap;
flex-direction: row-reverse;
position: relative;
top: 15px;
.item {
width: 400px;
height: 150px;
background-image: url('@/assets/images/group-bj3.png');
background-size: 98.875% 100%;
background-repeat: no-repeat;
position: relative;
.time-num {
width: 32px;
height: 32px;
border-radius: 50%;
line-height: 32px;
text-align: center;
background-image: linear-gradient(243deg, #0971da 5%, #5cadff 100%);
color: #fff;
}
.btn-box {
position: absolute;
width: 73px;
height: 26px;
border-radius: 13px;
text-align: center;
line-height: 26px;
color: #fff;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
padding: 0 8px;
}
.arrow {
width: 20px;
height: 18px;
background-size: 100% 100%;
position: absolute;
background-repeat: no-repeat;
}
.content {
position: absolute;
font-size: 12px;
width: 281px;
.item-box {
margin-top: 4px;
display: flex;
align-items: center;
font-size: 14px;
height: 20px;
line-height: 20px;
.value {
flex: 1;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.label {
display: inline-block;
width: 64px;
text-align: right;
color: rgba(0, 0, 0, 0.65);
}
&:first-child {
margin-top: 0;
}
}
}
.title {
color: #000;
position: absolute;
font-size: 20px;
}
&:nth-child(odd) {
background-image: url('@/assets/images/group-bj4.png');
background-position: 4px 0;
.time-num {
position: relative;
bottom: 14px;
right: 16px;
}
.btn-box {
right: 0;
background: #419af6;
top: 70px;
}
.arrow {
background-image: url('@/assets/images/group-icon2.png');
top: 86px;
left: 384px;
}
.title {
left: 36px;
top: 50px;
}
.content {
top: 94px;
left: 24px;
}
}
&:nth-child(odd).comment-start {
background-image: url('@/assets/images/group-bj4-1.png');
background-size: 18% 100%;
background-repeat: no-repeat;
.btn-box {
left: 75px;
background: #419af6;
top: 70px;
}
.arrow {
background-image: url('@/assets/images/group-icon2.png');
left: 147px;
}
}
&:nth-child(even) {
background-position: 1px 0;
.time-num {
position: relative;
left: 384px;
bottom: 13px;
}
.btn-box {
left: 0;
background: #419af6;
top: 70px;
}
.arrow {
background-image: url('@/assets/images/group-icon4.png');
top: 86px;
left: -4px;
}
.title {
right: 36px;
top: 50px;
}
.content {
top: 94px;
left: 81px;
}
}
&:nth-child(even).comment-start {
background-image: url('@/assets/images/group-bj3-1.png');
background-repeat: no-repeat;
background-position: 324px 0;
background-size: 18% 100%;
.btn-box {
right: 75px;
left: auto;
}
.arrow {
right: 149px;
left: auto;
}
}
&:nth-child(2) {
.time-num {
background-image: linear-gradient(136deg, #fc7887 0%, #f8434f 100%);
}
}
}
.item.first-item {
background-image: url('@/assets/images/group-bj1.png');
background-position: 1px 0;
background-size: 98.875% 100%;
.btn-box {
background: #fb7482;
top: 54px;
}
.arrow {
background-image: url('@/assets/images/group-icon1.png');
top: 70px;
left: 384px;
}
.title {
color: #ff606c;
top: 36px;
}
.content {
top: 80px;
}
}
.item.comment-end {
background-image: url('@/assets/images/group-end.png');
background-repeat: no-repeat;
background-size: 18% 100%;
background-position: 1px 0;
.btn-box {
background: #fb7482;
top: 54px;
left: 72px;
}
.arrow {
left: 145px;
}
}
}
</style>
切图