<template>
<div class="view-container car-detail-view">
<div class="detail-center">
<div id="stageCanvas" class="stage-content">
<div class="item" v-for="(item,index) in stageData" :key="item.id" :style="getPosition(index,'x')" @mouseover="mouseoverHandle" @mouseout="mouseoutHandle">
<span class="text-x">{{item.name}}</span>
<span><el-icon @click="deleteStage(item,'x')" ><CircleClose /></el-icon></span>
<div class="children" v-for="(child,index) in item.children" :key="child.id" :style="getPosition(index,'y')" @mouseover.stop>
<span class="text-y">{{child.name}}</span>
<span><el-icon @click="deleteStage(child,'y',item)"><CircleClose /></el-icon></span>
</div>
<div class="children add-btn" @click="addStage(item.children,'y')" :style="getPosition(item.children.length,'y')" @mouseover.stop>
<span class="icon iconfont icon-increase"></span> <!-- y新增-->
<span>并行任務 </span>
</div>
</div>
<div class="item add-btn" @click="addStage(stageData,'x')" :style="getPosition(stageData.length,'x')" @mouseover="mouseoverHandle" @mouseout="mouseoutHandle"> <!-- x新增-->
<span class="icon iconfont icon-increase"></span>
<span>{{stageData.length > 0 ?"串行任務":'新增'}}</span>
</div>
</div>
</div>
<el-dialog :model-value="stageAddVisible" title="添加階段" @close="closeDialog" width="518px" >
<div>
<el-form :rules="stageRules" ref="ruleFormRefStage" label-width="120px" :model="stageDialogData">
<el-form-item label="階段:" prop="data">
<el-select :multiple="false" v-model="stageDialogData.data" :popper-append-to-body="false" placeholder="請選擇">
<el-option v-for="item in stageOptionData" :key="item.id" :label="item.name" :value="item.name" ></el-option>
</el-select>
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="closeDialog">取消</el-button>
<el-button type="primary" @click="sureDialog()">確定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script lang="ts">
import { type } from "os";
import { defineComponent ,ref} from "vue";
import { ElForm, ElMessage } from "element-plus";
type FormInstance = InstanceType<typeof ElForm>;
export default defineComponent({
data() {
return {
stageOptionData: [
{
id: 1,
name: "編譯",
value: "ifBuild",
}, {
id: 2,
name: "靜態(tài)檢查",
value: "ifCodeCheck",
}, {
id: 3,
name: "單元測試",
value: "ifUT",
}, {
id: 4,
name: "冒煙",
value: "ifSmoke",
},
],
stageRules: {
data: [
{
required: true,
trigger: "change",
message: "請選擇階段",
},
],
},
activeNames : ref(['4']),
stageAddVisible: false,
stageDialogData:{
data:''
},
// stageData:[],
stageData: [
{
id:1,
name:'初始化環(huán)境',
children:[{
id:2,
'name':'靜態(tài)檢查'
},
{
id:3,
'name':'編譯'
},
]
},
{
id:4,
name:'編譯',
children:[{
id:5,
'name':'靜態(tài)檢查'
},
{
id:6,
'name':'冒煙'
}
]
},
{
id:7,
name:'編譯2',
children:[]
},
{
id:8,
name:'編譯3',
children:[]
},
],
curArr:[] as any,//當前操作數組
curType:'x',//當前操作的軸 "x" -x軸 "y" ---y軸
};
},
created() {
},
mounted() {
},
unmounted() {
},
methods: {
addStage(info,type){
this.stageAddVisible = true;
if(this.$refs.ruleFormRefStage){
this.$refs.ruleFormRefStage.clearValidate();
}
console.log('info------',info);
console.log('type------',type);
this.curArr = info;
this.curType = type;
},
deleteStage(info,type,fatherInfo?){
console.log('info-----------------',info);
let conTip = '是否刪除當前階段?';
let $that = this;
this.$layer.confirm(conTip, {
async onSure () {
if(type == 'x'){ //是外層
$that.stageData = $that.stageData.filter(function(item) { return item.id != info.id});//刪除
}else{ //是children
if(fatherInfo.children.length > 0){
let yOneDelInfo = fatherInfo.children;
yOneDelInfo = yOneDelInfo.filter(function(item) { return item.id != info.id});
let targetIndex = $that.stageData.findIndex((itemTemp) => {
return itemTemp.id == fatherInfo.id
});
$that.stageData[targetIndex].children = yOneDelInfo;
}
}
},
});
},
closeDialog() {
this.stageAddVisible = false;
// 清除表單驗證提示信息
if(this.$refs.ruleFormRefStage){
this.$refs.ruleFormRefStage.clearValidate();
}
this.stageDialogData = {
data: "",
}
},
getPosition(number,type){
let leftVal = 0;
let topVal = 0;
if(type == 'x'){
leftVal = 140*number;
}else if(type == 'y'){
number = number + 1;
topVal = 40*number;
}
let obj = {
left: leftVal+'px',
top: topVal+'px'
}
return obj;
},
mouseoverHandle(event){
if(typeof event.target.className == 'object'){ //是刪除圖標
return;
}
if(event.target.className.indexOf('item') === -1) {
event.target.parentNode.className = `${event.target.parentNode.className } hover-btn`
return
}
event.target.className = `${event.target.className } hover-btn`
},
mouseoutHandle(event){
if(typeof event.target.className == 'object'){ //是刪除圖標
return;
}
if(event.target.className.indexOf('item') === -1) {
event.target.parentNode.className =event.target.parentNode.className.replace('hover-btn', '')
return
}
event.target.className = event.target.className.replace('hover-btn', '')
},
sureDialog() {
(this.$refs.ruleFormRefStage as FormInstance).validate((valid) => {
if (valid) {
console.log('this.stageDialogData=====22============---',this.stageDialogData);
let curVal = this.stageOptionData.filter((i)=>{
return i.name == this.stageDialogData.data;
})
if(this.curType =='x'){
this.curArr.push({
id: parseInt(Math.random() * 100000000000),
name: this.stageDialogData.data,
value:curVal[0]?.value,
children:[]
})
}else{
this.curArr.push( {
id: parseInt(Math.random() * 100000000000),
value:curVal[0]?.value,
name: this.stageDialogData.data,
})
}
console.log('this.curArr=====333============---',this.curArr);
this.stageAddVisible = false;
}
});
},
},
});
</script>
<style lang="scss" scoped>
.car-detail-view {
.car-detail-title {
background: #fff;
padding: 0 10px;
height: 50px;
line-height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 4px;
margin-bottom: 10px;
}
.detail-center {
display: flex;
height: calc(100% - 60px);
flex-direction: column;
background: #ffffff;
padding: 10px;
.stage-content{
height: 400px;
width: 100%;
overflow: auto;
position: relative;
.item{
width: 90px;
height: 32px;
background-color: #ededed;
line-height: 32px;
text-align: center;
// border:1px dotted #ededed;
color:#000000a6;
border-radius: 5px;
cursor: pointer;
position: absolute;
span:first-child{
margin-right: 4px;
}
span.icon{
vertical-align: middle;
}
i.el-icon{
vertical-align: middle;
font-size: 16px;
}
span.text-x::before{//水平線
content: '';
width: 50px;
height: 0px;
border-top:1px dotted #aaa;
position: absolute;
left: 90px;
top: 16px;
}
span.text-y::after,
span.text-x::after{//垂直線
content: '';
height: 50px;
width: 0;
border-left:1px dotted #aaa;
position: absolute;
left: 45px;
top: 32px;
}
// &:hover{
// background-color:#1c3dd7;
// color: #ffffff;
// }
.children{
position: relative;
width: 90px;
height: 32px;
line-height: 32px;
text-align: center;
background-color: #ededed;
// border:1px dotted #1c3dd7;
color:#000000a6;
border-radius: 5px;
cursor: pointer;
&:hover{
background-color:#1c3dd7;
color: #ffffff;
}
// &:hover ~ .item{
// background-color: #E8EBFB;
// pointer-events: none;
// border: 1px solid #000;
// }
}
}
.children.add-btn,
.add-btn{
background-color: #E8EBFB ;
border:1px dotted #1c3dd7;
color:#1c3dd7;
}
.hover-btn{
background-color:#1c3dd7;
color: #ffffff;
}
}
}
}
</style>
橫向和縱向流程圖新增
?著作權歸作者所有,轉載或內容合作請聯系作者
- 文/潘曉璐 我一進店門费尽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人羊始,你說我怎么就攤上這事旱幼。” “怎么了突委?”我有些...
- 正文 為了忘掉前任敌蚜,我火速辦了婚禮桥滨,結果婚禮上,老公的妹妹穿的比我還像新娘弛车。我一直安慰自己齐媒,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布纷跛。 她就那樣靜靜地躺著喻括,像睡著了一般。 火紅的嫁衣襯著肌膚如雪忽舟。 梳的紋絲不亂的頭發(fā)上双妨,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼兜挨!你這毒婦竟也來了膏孟?” 一聲冷哼從身側響起,我...
- 正文 年R本政府宣布少欺,位于F島的核電站,受9級特大地震影響别惦,放射性物質發(fā)生泄漏狈茉。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一掸掸、第九天 我趴在偏房一處隱蔽的房頂上張望氯庆。 院中可真熱鬧,春花似錦扰付、人聲如沸堤撵。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽实昨。三九已至,卻和暖如春盐固,著一層夾襖步出監(jiān)牢的瞬間荒给,已是汗流浹背丈挟。 一陣腳步聲響...
推薦閱讀更多精彩內容
- 黃坍儀 橫向學習·縱向比較 第一次接觸思維導圖鱼蝉,是在2018年年初大V店蒙臺梭利課程洒嗤,老師要求用思...
- ImageViewer 關于 圖片瀏覽器,支持圖片手勢縮放睬魂、拖拽等操作,自定義View的模式顯示镀赌,自定義圖片加載方...
- 相關依賴庫 前往 【閱讀原文】[https://mp.weixin.qq.com/s?__biz=MzA3ODk1...
- 批量插入圖片到工作表中玛追,自動統(tǒng)一尺寸税课,自支對齊。 支持精確匹配和模糊匹配痊剖,橫向縱向排列皆可韩玩。
- 哎呀,這個是最簡單的陆馁,我就直接貼代碼了找颓。 import matplotlib matplotlib.use('Ag...