动态树形步骤图trees

该博客内容为转载,原文链接为https://juejin.im/post/5ccf9598e51d453a8f348bb9 ,但未明确具体关于动态树形步骤图trees的详细信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<template>
    <div>
        <div class="box clrfix">
            <!--开始-->
            <div class="start">
                <em></em>
                <p>{{sysTitle}}</p>
            </div>
            <!--已有模块-->
            <div class="model" v-for="(item,k) in obj" :key="k">
                <small title="点击查看" :class="item.isSuccess == 1?'success':item.isSuccess == 2?'active':item.isSuccess == 3?'error':''" @click="selectFun(item.jenkinsurl)"></small>
                <p>{{item.id}}</p>
                <div class="already" v-for="(list,index) in item.arr" :key="index">
                    <p>{{list.name}}</p>
                    <span title="点击查看" @click="selectFun(list.jenkinsurl)" :class="item.selected[index] == 1?'success':item.selected[index] == 2?'active':item.selected[index] == 3?'error':''"></span>
                </div>
                <!-- <div class="add-model" :class="{'new-add':!item.arr.length}">
                    <p>{{item.id+'-'+(item.arr.length+1)}}</p>
                    <span class="add" @click="addBox(k)"></span>
                </div> -->
            </div>
            <!--添加一列-->
            <!-- <div class="end">
                <em class="add" @click="addModel"></em>
            </div> -->
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            obj: [{
                id: '编译完成',
                isSuccess: -1,
				selected: [],
                arr: [],
                jobname:'',
                tag: '',
                jenkinsurl:''
			},
			// {
            //     id: 'ST-1',
            //     isSuccess: -1,
			// 	selected: [],
			// 	arr: []
			// },
			// {
            //     id: '完成',
            //     isSuccess: -1,
			// 	selected: [],
			// 	arr: []
			// }
        ],
        sysTitle: ''
        }
    },
    created() {
        this.init()
    },
    watch: {
        'dataList': function(newVal) {
            // console.log(newVal)
            this.init()
        }
    },
    methods: {
        init() {
            this.obj = [{id: '编译完成',isSuccess: '-1',selected: [],arr: [],jenkinsurl:''}]
            let num = this.dataList.jobname.indexOf('-')
            this.sysTitle = this.dataList.jobname.substr(0,this.dataList.jobname.indexOf('-',num+1))
            // console.log(this.dataList.status)
            this.obj[0].jobname = this.dataList.jobname
            this.obj[0].tag = this.dataList.tag
            this.obj[0].jenkinsurl = this.dataList.jenkinsurl
            if(this.dataList.status == 'PROCESSING') {
                this.obj[0].isSuccess = 2
                this.obj[0].id = '正在编译中'
                return
            }else if(this.dataList.status == 'ABORTED') {
                this.obj[0].isSuccess = 3
                this.obj[0].id = '编译已取消'
                return
            }else if(this.dataList.status == 'FAILURE') {
                this.obj[0].isSuccess = 3
                this.obj[0].id = '编译失败'
                return    
            }else if(this.dataList.status == 'SUCCESS' && this.dataList.target == '') {
                this.obj[0].isSuccess = 1
                this.obj[0].id = '编译成功'
                this.obj.push({id:'结束',isSuccess:'1',selected:[],arr:[]})//最后一步预先添加
                return    
            }else if(this.dataList.status == 'SUCCESS'){
                this.obj.push({id:'',isSuccess:'-1',selected:[],arr:[],jobname:this.dataList.jobname,jenkinsurl:''})//成功后添加下一步
                this.obj.push({id:'结束',isSuccess:'-1',selected:[],arr:[]})//最后一步预先添加
                this.obj[0].isSuccess = 1
                let targetList = this.dataList.target.split(',')//有多少目标环境
                if(targetList.length == 1) {
                    this.obj[1].id = targetList[0]
                }else {
                    this.obj[1].id = targetList[0]
                    targetList.map((n,i) => {//多个目标
                        if(i) {
                            this.obj[1].arr.push({name:n,jenkinsurl:false})
                        }
                    })
                    
                }
                targetList.map((m,j) => {//判断目标环境各个状态
                    if(this.dataList.deploy) {
                        let nowStatus = 2
                        let statusOne = 2
                        this.dataList.deploy.map((n,i) => {//成功的目标环境
                            if(m == n.target) {
                                if(j == 0) {//第一个目标环境完成
                                    if(n.status == 'ABORTED') {
                                        statusOne = 3
                                        this.obj[1].jenkinsurl = n.jenkinsurl
                                        // this.obj[1].isSuccess = 3
                                        return
                                    }else if(n.status == 'SUCCESS') {
                                        statusOne = 1
                                        this.obj[1].jenkinsurl = n.jenkinsurl
                                        // this.obj[1].isSuccess = 1
                                        return
                                    }else if(n.status == 'FAILURE') {
                                        statusOne = 3
                                        this.obj[1].jenkinsurl = n.jenkinsurl
                                        // this.obj[1].isSuccess = 3
                                        return
                                    }else {
                                        statusOne = -1
                                        // this.obj[1].isSuccess = -1
                                        return
                                    }
                                }else {
                                    if(n.status == 'ABORTED') {
                                        nowStatus = 3
                                        this.obj[1].arr[j-1].jenkinsurl = n.jenkinsurl
                                        return
                                        // this.obj[1].selected[j] = 3
                                    }else if(n.status == 'SUCCESS') {
                                        nowStatus = 1
                                        this.obj[1].arr[j-1].jenkinsurl = n.jenkinsurl
                                        return
                                        // this.obj[1].selected[j] = 1
                                    }else if(n.status == 'FAILURE') {
                                        nowStatus = 3
                                        this.obj[1].arr[j-1].jenkinsurl = n.jenkinsurl
                                        return
                                        // this.obj[1].selected[j] = 3
                                    }else {
                                        nowStatus = -1
                                        return
                                        // this.obj[1].selected[j] = -1
                                    }
                                }
                            }
                        })
                        if(j != 0) {
                            // console.log('哈哈哈',nowStatus,this.obj[1].selected)
                            this.obj[1].selected[j-1] = nowStatus
                        }else {
                            this.obj[1].isSuccess = statusOne
                        }
                        // console.log(this.obj[1].selected)
                    }else {//一个都没完成
                        this.obj[1].isSuccess = 2
                        targetList.map((n,i) => {
                            this.obj[1].selected[n] = 2
                        })
                    }
                })
                if(this.dataList.deploy) {
                    if(this.dataList.deploy.length == targetList.length) {//全部完成
                        this.obj[2].isSuccess = 1
                    }
                }
            }
        
        },
		//加一列
		addModel() {
			var l = this.obj.length
			if (l > 7) {
				alert('再加,自动换行会变形的!!!!!!!')
			} else {
				var nullModel = {
					id: l + 1,
					selected: -1,
					arr: []
				}
				this.obj.push(nullModel)
			}
		},
		//加一行
		// addBox(k) {
		// 	var num = this.obj[k].arr.length + 1;
		// 	this.obj[k].arr.push(num)
		// },
		//选中当前列中的数据
		selectFun(jenkinsurl) {
           if(jenkinsurl) {
               window.open(jenkinsurl)
           }
		}
    },
    props:['dataList']
}
</script>
<style scoped>
* {
    margin: 0;
    padding: 0;
    box-sizing: content-box;
}
:after, :before {
    box-sizing: content-box;
}
.clrfix {
    zoom: 1;
}

.clrfix:after {
    content: '';
    display: block;
    height: 0;
    clear: both;
}

.box {
    margin-left: 100px;
    margin-top: 60px;
    font-size: 14px;
}

.box .model {
    float: left;
    width: 144px;
    border-top: 2px solid #999;
    position: relative;
    z-index: 2;
}

.start {
    float: left;
    position: relative;
}

.start em {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #999;
    position: absolute;
    top: -7px;
    left: -8px;
}

.start p {
    position: absolute;
    left: -50px;
    top: -30px;
    white-space:nowrap;
}

.end {
    float: left;
    position: relative;
    width: 120px;
    border-top: 2px solid #ddd;
    z-index: 0;
}

.end em {
    position: absolute;
    top: -12px;
    right: 0;
}

.add {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.add:after {
    content: '';
    position: absolute;
    width: 12px;
    height: 2px;
    background: #ddd;
    top: 50%;
    margin-top: -1px;
    left: 50%;
    margin-left: -6px;
}

.add:before {
    content: '';
    position: absolute;
    width: 2px;
    height: 12px;
    background: #ddd;
    top: 50%;
    margin-top: -6px;
    left: 50%;
    margin-left: -1px;
}

.model small {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #999;
    right: -2px;
    background: #fff;
    border-radius: 50%;
    margin-top: -12px;
    cursor: pointer;
}

.model>p {
    position: absolute;
    width: 144px;
    text-align: center;
    left: 50%;
    margin-left: -12px;
    top: -38px;
}

.model .already:first-of-type {
    height: 50px;
    margin-top: 10px;
}

.already {
    width: 120px;
    position: relative;
    height: 72px;
    margin-top: -22px;
    border: 2px solid #999;
    left: 72px;
    border-top: 0;
    border-radius: 0 0 20px 20px;
}

.model .already:first-of-type:after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #999;
    border-color: transparent #999 transparent transparent;
    transform: rotate(-45deg);
    top: -12px;
    left: -24px;
}

.model .already:first-of-type:before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #999;
    border-color: transparent #999 transparent transparent;
    transform: rotate(-135deg);
    top: -12px;
    right: -24px;
}

.model .already:first-of-type p {
    padding-top: 12px;
}

.already p {
    text-align: center;
    padding-top: 42px
}

.already span {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #999;
    bottom: -12px;
    left: 50%;
    margin-left: -12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
}

.already span.active,
.model small.active {
    border-color: #ff9900;
}
.already span.success,
.model small.success {
    border-color: #19be6b;
}
.already span.error,
.model small.error {
    border-color: #ed4014;
}

.already span.active:before,
.model small.active:before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    background: #ff9900;
    transform: translate(-50%, -50%);
    animation: twinkling 1s infinite ease-in-out;
}
.already span.success:before,
.model small.success:before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    background: #19be6b;
    transform: translate(-50%, -50%);
    /* animation: twinkling 1s infinite ease-in-out; */
}
.already span.error:before,
.model small.error:before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    background: #ed4014;
    transform: translate(-50%, -50%);
    /* animation: twinkling 1s infinite ease-in-out; */
}
@keyframes twinkling {
    0%{
        opacity:0; 
    }
    50%{
        opacity:1; 
    }
    100%{
        opacity:0; 
    }
}

.add-model {
    width: 60px;
    height: 84px;
    position: relative;
    left: 72px;
    border: 2px solid #ddd;
    top: -14px;
    border-color: transparent transparent #ddd #ddd;
    border-radius: 0 0 0 20px;
}

.add-model span {
    position: absolute;
    bottom: -12px;
    right: -12px;
}

.add-model p {
    width: 120px;
    text-align: center;
    padding-top: 32px
}

.new-add.add-model {
    height: 68px;
    top: 10px;
}

.new-add.add-model:before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ddd;
    border-color: transparent #ddd transparent transparent;
    transform: rotate(-45deg);
    top: -13px;
    left: -24px;
}

.new-add.add-model p {
    padding-top: 10px;
}
</style>

复制代码

转载于:https://juejin.im/post/5ccf9598e51d453a8f348bb9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值