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

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

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