Commit 001075f0 authored by 刘殿昕's avatar 刘殿昕

流程大改,闭环没搞定,先吃饭

parent 6ed0e7f4
......@@ -4,11 +4,11 @@
<div class="scale_block">
<div class="scale_control">
<div class="less">
<i class="el-icon-minus" @click="changeScale('down')"></i>
<i class="el-icon-minus" @click="changeScale(-10)"></i>
</div>
<div class="num">{{ scale_num }}%</div>
<div class="add">
<i class="el-icon-plus" @click="changeScale('up')"></i>
<i class="el-icon-plus" @click="changeScale(10)"></i>
</div>
</div>
<div class="node-container">
......@@ -27,13 +27,15 @@
</div>
<div class="flow-container" ref="flowContainer">
<super-flow
id="superFlow"
ref="superFlow"
:node-list="nodeList"
:link-list="linkList"
:link-menu="linkMenu"
line-color="#c4d8f8"
onLineColor="#94a8c8"
:origin="origin"
:origin="origins"
@mousedown.native="superMove"
>
<template v-slot:node="node">
<div
......@@ -42,11 +44,12 @@
>
<div
class="node_span"
:style="`line-height: ${line_hieght}px;font-size: ${font_size}px;`"
@click="clickItem(node.meta.id)"
@blur="blurItem"
:title="nodeParams(node.meta.id).name"
>{{nodeParams(node.meta.id).name}}</div>
<div class="node_del" @click="delNode(node.meta.node_id)"></div>
<div class="node_del" @click="delNode(node.meta.id)"></div>
</div>
</template>
</super-flow>
......@@ -412,9 +415,15 @@ export default {
},
deep: true,
},
origin: {
handler() {
this.origins = this.origin;
},
},
},
data() {
return {
origins: [0, 0],
scale_num: 100,
nodeList: [],
linkList: [],
......@@ -514,7 +523,7 @@ export default {
{
label: "删除",
selected: (link) => {
console.log(link);
// console.log(link);
link.remove();
},
},
......@@ -619,6 +628,8 @@ export default {
max_time_type_1: 1,
max_time_check_0: false,
max_time_check_1: false,
line_hieght: 41,
font_size: 16,
};
},
mounted() {
......@@ -678,9 +689,10 @@ export default {
clientX - conf.offsetLeft,
clientY - conf.offsetTop
);
console.log(clientX, conf.offsetLeft, coordinate);
// console.log(clientX, conf.offsetLeft, coordinate);
// 添加节点
let query = { width: 120, height: 48, meta: {} };
let scale = this.scale_num / 100;
let query = { width: 120 * scale, height: 48 * scale, meta: {} };
query.meta.type = conf.info.meta.type;
if (!conf.info.meta.id) {
query.meta.id =
......@@ -688,7 +700,6 @@ export default {
"a" +
parseInt(Math.random() * 1000 * 1000);
}
console.log(query);
this.$refs.superFlow.addNode({
coordinate,
...query,
......@@ -723,7 +734,6 @@ export default {
};
}
this.nodeParamsList.push(obj);
console.log(this.nodeParamsList);
}
conf.isMove = false;
}
......@@ -733,6 +743,7 @@ export default {
}
},
nodeItemMouseDown(evt, info) {
console.log("dwad");
const { clientX, clientY, currentTarget } = evt;
const { top, left } = evt.currentTarget.getBoundingClientRect();
const conf = this.dragConf;
......@@ -755,17 +766,25 @@ export default {
clickItem(index) {
let item = this.nodeParams(index);
this.nodeItem = item;
console.log(item);
// console.log(item);
},
blurItem() {
this.nodeItem = {
id: "",
};
console.log(this.nodeItem);
// console.log(this.nodeItem);
},
getData() {
let objs = this.$refs.superFlow.toJSON();
let scale = this.scale_num / 100;
objs.nodeList.forEach((item) => {
item.width = parseInt(item.width / scale);
item.height = parseInt(item.height / scale);
item.coordinate[0] = parseInt(item.coordinate[0] / scale);
item.coordinate[1] = parseInt(item.coordinate[1] / scale);
});
return {
obj: this.$refs.superFlow.toJSON(),
obj: objs,
params: this.nodeParamsList,
};
},
......@@ -1022,7 +1041,7 @@ export default {
let index = self.nodeParamsList.findIndex((item) => {
return item.id == self.nodeItem.id;
});
console.log(self.nodeParamsList[index]);
// console.log(self.nodeParamsList[index]);
let plugin_index = self.nodeParamsList[index].plugins.findIndex(
(item) => {
return item.plugin_type == 1;
......@@ -1221,23 +1240,22 @@ export default {
let obj = this.$refs.superFlow.toJSON();
let nodes = obj.nodeList;
let links = obj.linkList;
let node_meta_id = "";
let node_id = "";
for (let i = 0; i < nodes.length; i++) {
console.log(nodes[i]);
if (nodes[i].id == item) {
node_meta_id = nodes[i].meta.id;
if (nodes[i].meta.id == item) {
node_id = nodes[i].id;
nodes.splice(i, 1);
}
}
for (let i = 0; i < links.length; i++) {
console.log(links[i]);
if (links[i].startId == item || links[i].endId == item) {
// console.log(links[i]);
if (links[i].startId == node_id || links[i].endId == node_id) {
links.splice(i, 1);
i--;
}
}
let index = this.nodeParamsList.findIndex((item) => {
return item.id == node_meta_id;
let index = this.nodeParamsList.findIndex((ele) => {
return ele.id == item;
});
this.nodeParamsList.splice(index, 1);
this.nodeList = nodes;
......@@ -1246,11 +1264,60 @@ export default {
id: "",
name: "",
};
console.log(this.nodeList, this.linkList, this.nodeParamsList);
// console.log(this.nodeList, this.linkList, this.nodeParamsList);
},
changeScale(size) {
let old_scale = this.scale_num / 100;
if (this.scale_num > 50 && this.scale_num < 150) {
this.scale_num += size;
} else if (this.scale_num == 50) {
if (size > 0) {
this.scale_num += size;
}
} else if (this.scale_num == 150) {
if (size < 0) {
this.scale_num += size;
}
}
let scale = this.scale_num / 100;
// console.log(scale);
let obj = this.$refs.superFlow.toJSON();
// console.log(obj);
obj.nodeList.forEach((item) => {
item.width /= old_scale;
item.width *= scale;
item.height /= old_scale;
item.height *= scale;
item.coordinate[0] /= old_scale;
item.coordinate[0] *= scale;
item.coordinate[1] /= old_scale;
item.coordinate[1] *= scale;
});
this.line_hieght = 41 * scale;
this.font_size = 16 * scale;
this.nodeList = obj.nodeList;
this.linkList = obj.linkList;
},
superMove(e) {
if (e.srcElement.id == "superFlow") {
this.$refs.superFlow.$el.style.cursor = "move";
let old_X = e.clientX;
let old_Y = e.clientY;
let origin_left = this.origins[0];
let origin_top = this.origins[1];
document.onmousemove = (e) => {
let left = origin_left + e.clientX - old_X;
let top = origin_top + e.clientY - old_Y;
this.origins = [left, top];
};
document.onmouseup = (e) => {
this.$refs.superFlow.$el.style.cursor = "auto";
document.onmousemove = null;
document.onmouseup = null;
};
} else {
}
},
changeScale(type) {
}
},
};
</script>
......@@ -1427,6 +1494,7 @@ export default {
justify-content: space-around;
border-radius: 8px;
border: solid 2px #e3e5ef;
background-color: #fff;
height: 40px;
font-size: 16px;
line-height: 36px;
......@@ -1435,10 +1503,12 @@ export default {
.less {
padding: 0 10px;
border-right: solid 2px #e3e5ef;
cursor: pointer;
}
.add {
padding: 0 10px;
border-left: solid 2px #e3e5ef;
cursor: pointer;
}
.num {
color: #58617a;
......@@ -1657,7 +1727,6 @@ export default {
border: none;
background-color: transparent;
border-radius: 8px;
font-size: 16px;
/deep/ .node_span {
text-align: center;
overflow: hidden;
......@@ -1667,7 +1736,6 @@ export default {
.flow-node-begin {
width: 100%;
height: 100%;
line-height: 42px;
padding: 0 6px;
border-radius: 8px;
border: solid 3px #109e93;
......@@ -1678,7 +1746,6 @@ export default {
.flow-node-end {
width: 100%;
height: 100%;
line-height: 42px;
padding: 0 6px;
border-radius: 8px;
background-color: #f78181;
......@@ -1689,7 +1756,6 @@ export default {
.flow-node-default {
width: 100%;
height: 100%;
line-height: 42px;
padding: 0 6px;
border-radius: 8px;
background-color: #fff;
......@@ -1699,7 +1765,6 @@ export default {
.flow-node-default-active {
width: 100%;
height: 100%;
line-height: 42px;
padding: 0 6px;
border-radius: 8px;
border: solid 3px #b4c6f5;
......
......@@ -151,6 +151,7 @@ export default {
workflows_id: "",
sector: 0,
},
loop: 0,
};
},
methods: {
......@@ -172,8 +173,6 @@ export default {
});
item.meta = da;
item.node_code = da.node_code;
item.coordinate[0] = parseInt(item.coordinate[0]);
item.coordinate[1] = parseInt(item.coordinate[1]);
if (item.meta.type == 1) {
start_num++;
start_id = item.id;
......@@ -198,6 +197,10 @@ export default {
out_edge++;
}
});
this.loop = 0;
datas.nodeList.forEach((item) => {
this.checkClosedLoop(datas.linkList, item.id, end_id);
});
datas.linkList.forEach((item) => {
if (start_id == item.endId) {
start_before++;
......@@ -230,10 +233,31 @@ export default {
type: "warning",
});
return false;
} else if (this.loop != 0) {
this.$message({
message: "存在闭环",
type: "warning",
});
} else {
return datas;
}
},
checkClosedLoop(arr, id, endding_id) {
// let self = this;
// arr.forEach((item) => {
// if (item.startId == id) {
// if (item.endId == endding_id) {
// return false;
// } else if (item.endId == id) {
// self.loop++;
// } else {
// this.checkClosedLoop(arr, item.endId, endding_id);
// }
// } else {
// return false;
// }
// });
},
backToList() {
this.$router.push("/progress/designer");
},
......
......@@ -136,6 +136,7 @@ export default {
},
workplace_list: [],
origin: [],
loop: 0,
};
},
methods: {
......@@ -157,8 +158,6 @@ export default {
});
item.meta = da;
item.node_code = da.node_code;
item.coordinate[0] = parseInt(item.coordinate[0]);
item.coordinate[1] = parseInt(item.coordinate[1]);
if (item.meta.type == 1) {
start_num++;
start_id = item.id;
......@@ -183,6 +182,10 @@ export default {
out_edge++;
}
});
this.loop = 0;
datas.nodeList.forEach((item) => {
this.checkClosedLoop(datas.linkList, item.id, end_id);
});
datas.linkList.forEach((item) => {
if (start_id == item.endId) {
start_before++;
......@@ -215,10 +218,31 @@ export default {
type: "warning",
});
return false;
} else if (this.loop != 0) {
this.$message({
message: "存在闭环",
type: "warning",
});
} else {
return datas;
}
},
checkClosedLoop(arr, id, endding_id) {
// let self = this;
// arr.forEach((item) => {
// if (item.startId == id) {
// if (item.endId == endding_id) {
// return false;
// } else if (item.endId == id) {
// self.loop++;
// } else {
// this.checkClosedLoop(arr, item.endId, endding_id);
// }
// } else {
// return false;
// }
// });
},
backToList() {
this.$router.push("/progress/designer");
},
......
......@@ -539,7 +539,7 @@ export default {
trigger: "blur",
},
],
area: [{ required: true, message: "请选择服务领域", trigger: "blur" }],
area: [{ required: true, message: "请选择服务领域", trigger: "change" }],
origin: [
{ required: true, message: "请选择所属组织", trigger: "blur" },
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment