依赖下载
照着这个引入就好,然后npm install
源码
ab
节点属性
边属性
群组属性栏
画布属性栏
多选时属性栏
缩略图
jpg
白色背景
png
透明背景
取 消
确 定
index.less
@backgroundColor: #fbfbfb;
@borderColor: #dadce0;
@itempannelAndPageBorder: 1px solid #ccc;
@pageHeight: calc(100vh - 41px - 37px);
body {
margin: 0;
}
.all {
width: 100%;
height: 100%;
.main {
overflow-y: auto;
#vue-g6-editor {
width: 100%;
height: 100%;
overflow-x: hidden;
background-color: white;
// transform: scale(0.5);
.showcontent {
height: 700px;
.showface {
height: 700px;
}
.showcanvas {
height: 700px;
}
.shownode {
height: 700px;
}
}
.showtab {
width: 100%;
height: 700px;
}
// 主画布
#page {
height: 700px;
position: relative;
display: flex;
.graph-container {
height: 700px;
}
.controltab {
width: 100%;
height: 200px;
background-color: white;
position: absolute;
bottom: 0;
z-index: 999;
/* 子盒子底部与父盒子底部对齐 */
display: flex;
flex-direction: column;
/* 垂直方向排列子元素 */
opacity: 0.5;
background-color: white;
/* 设置盒子的透明度为 0.5,即 50% 不透明 */
.controlbt {
opacity: 1;
width: 100%;
height: 50px;
display: flex;
font-size: 50px;
justify-content: center;
align-items: center;
}
}
.activeshow {
width: 90%;
opacity: 1;
flex-grow: 1;
/* 第二个子盒子沾满剩余空间 */
.header {
width: 100%;
color: black;
font-weight: 550;
font-size: 20px;
padding-left: 10px;
padding-top: 10px;
}
.showmain {
display: flex;
.objectshow {
flex: 1;
color: black;
font-weight: 550;
}
}
.staticshow {
width: 60%;
height: 110px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.admi {
color: black;
font-weight: 550;
margin-bottom: 15px;
}
.setps {
color: black;
font-weight: 550;
margin-bottom: 15px;
}
.atomname {
color: black;
font-weight: 550;
}
}
}
}
header:nth-of-type(1) {
background: @backgroundColor;
line-height: 40px;
padding-left: 20px;
border-bottom: 1px solid @borderColor;
box-sizing: border-box;
}
}
}
// 工具栏
#toolbar {
display: flex;
justify-content: center;
background: @backgroundColor;
border-bottom: 1px solid @borderColor;
padding: 4px 14px;
i {
font-size: 18px;
padding: 4px;
margin-right: 8px;
color: #999999;
&:hover {
cursor: pointer;
background-color: #eeeeee;
color: #5cb6ff;
}
}
}
// 元素面板
#itempannel {
box-sizing: border-box;
background-color: @backgroundColor;
border-right: 1px solid @borderColor;
height: @pageHeight;
padding-top: 10px;
overflow: hidden;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
align-content: flex-start;
.getItem {
cursor: move;
width: 80px;
height: 80px;
margin-bottom: 20px;
display: flex;
justify-content: center;
align-items: center;
img {
width: 100%;
}
}
}
// 右侧部分(属性栏 + 缩略图)
.right-part {
height: @pageHeight;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
// 属性栏
#detailpannel {
flex-grow: 1;
background-color: @backgroundColor;
border-left: 1px solid @borderColor;
overflow-y: scroll;
#nodeAttributeBar,
#edgeAttributeBar,
#groupAttributeBar,
#canvasAttributeBar,
#multiAttributeBar {
.title {
height: 34px;
line-height: 34px;
text-align: center;
box-sizing: border-box;
font-weight: bold;
font-size: 13px;
border-width: 0 0 1px 0;
border-style: solid;
border-color: @borderColor;
}
.main {
padding: 10px;
}
}
}
// 缩略图
#minimap {
background-color: @backgroundColor;
border-top: 1px solid #ccc;
border-left: 1px solid #ccc;
.title {
height: 34px;
line-height: 34px;
text-align: center;
box-sizing: border-box;
font-weight: bold;
font-size: 13px;
border-width: 0 0 1px 0;
border-style: solid;
border-color: @borderColor;
}
}
// 右键菜单
#contextmenu {
display: none;
.menu {
/deep/ .el-button {
width: 100%;
display: block;
margin-left: 0;
border-radius: 0 !important;
border-bottom: none;
&:nth-last-of-type(1) {
border-bottom: 1px solid #dcdfe6;
}
}
}
}
// 下载图片弹窗
.save-as-image-dialog {
/deep/ .el-select {
display: block;
}
}
}
mixin.js
export default {
methods: {
// 保存节点属性
saveNodeAttribute() {
this.editor.executeCommand(() => {
// 获取画布
const page = this.editor.getCurrentPage();
// 获取所选对象
const selectedItem = page.getSelected()[0];
page.update(selectedItem.id, {
label: this.nodeAttributeForm.label,
size: this.nodeAttributeForm.width + "*" + this.nodeAttributeForm.height,
color: this.nodeAttributeForm.color
});
});
},
// 保存边属性
saveEdgeAttribute() {
this.editor.executeCommand(() => {
// 获取画布
const page = this.editor.getCurrentPage();
// 获取所选对象
const selectedItem = page.getSelected()[0];
console.log(this.edgeAttributeForm);
page.update(selectedItem.id, {
label: this.edgeAttributeForm.label,
shape: this.edgeAttributeForm.shape
});
});
}
}
};