|
@@ -45,23 +45,33 @@
|
|
:on-line-click="onLineClick"
|
|
:on-line-click="onLineClick"
|
|
>
|
|
>
|
|
<template #node="{node}">
|
|
<template #node="{node}">
|
|
- <div>
|
|
|
|
|
|
+ <div @contextmenu.prevent="handleContextmenu($event, node)">
|
|
<div
|
|
<div
|
|
:style="{ width: node.width + 'px', height: node.height + 'px' }"
|
|
:style="{ width: node.width + 'px', height: node.height + 'px' }"
|
|
- :class="{ 'node-active': $route.params.id === node.id }"
|
|
|
|
|
|
+ :class="{ 'node-active': menu.activeId === +node.id }"
|
|
class="rounded-circle"
|
|
class="rounded-circle"
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
:style="{ 'background-color': node.color + '44', width: 20 * node.text.length + 'px' }"
|
|
:style="{ 'background-color': node.color + '44', width: 20 * node.text.length + 'px' }"
|
|
class="node-text"
|
|
class="node-text"
|
|
- :class="{ 'node-active': $route.params.id === node.id }"
|
|
|
|
|
|
+ :class="{ 'node-active': menu.activeId === +node.id }"
|
|
>
|
|
>
|
|
{{ node.text }}
|
|
{{ node.text }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
+ <template #graph-plug>
|
|
|
|
+ <v-menu v-model="menu.show" attach :position-x="menu.x" :position-y="menu.y" absolute offset-y min-width="200">
|
|
|
|
+ <v-list dense>
|
|
|
|
+ <v-list-item v-for="(k, i) in menu.items" :key="i" @click="k.handle">
|
|
|
|
+ <v-list-item-title>{{ k.title }}</v-list-item-title>
|
|
|
|
+ </v-list-item>
|
|
|
|
+ </v-list>
|
|
|
|
+ </v-menu>
|
|
|
|
+ </template>
|
|
</relation-graph>
|
|
</relation-graph>
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -108,6 +118,16 @@ export default {
|
|
},
|
|
},
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
|
|
+ menu: {
|
|
|
|
+ x: 0,
|
|
|
|
+ y: 0,
|
|
|
|
+ show: false,
|
|
|
|
+ items: [
|
|
|
|
+ { title: '查看', handle: this.handleView }
|
|
|
|
+ ],
|
|
|
|
+ activeId: +this.$route.params.id,
|
|
|
|
+ item: {}
|
|
|
|
+ },
|
|
empty: true,
|
|
empty: true,
|
|
items: [
|
|
items: [
|
|
{ text: '全链关系', value: 'all' },
|
|
{ text: '全链关系', value: 'all' },
|
|
@@ -117,7 +137,7 @@ export default {
|
|
type: 'all',
|
|
type: 'all',
|
|
loading: false,
|
|
loading: false,
|
|
graphOptions: {
|
|
graphOptions: {
|
|
- defaultJunctionPoint: 'border',
|
|
|
|
|
|
+ defaultJunctionPoint: 'lr',
|
|
// 这里可以参考"Graph 图谱"中的参数进行设置 https://www.relation-graph.com/#/docs/graph
|
|
// 这里可以参考"Graph 图谱"中的参数进行设置 https://www.relation-graph.com/#/docs/graph
|
|
debug: false, // 是否开始调试模式,调试模式下会在控制台打印额外的日志信息
|
|
debug: false, // 是否开始调试模式,调试模式下会在控制台打印额外的日志信息
|
|
showDebugPanel: false, // 是否显示调试按钮,通过此按钮可以打印配置、数据等
|
|
showDebugPanel: false, // 是否显示调试按钮,通过此按钮可以打印配置、数据等
|
|
@@ -236,6 +256,18 @@ export default {
|
|
this.init()
|
|
this.init()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ handleContextmenu (v, node) {
|
|
|
|
+ const { left, top } = this.$refs.graphRef.$el.getBoundingClientRect()
|
|
|
|
+ this.menu.x = v.clientX - left
|
|
|
|
+ this.menu.y = v.clientY - top
|
|
|
|
+ this.menu.item = node
|
|
|
|
+ this.menu.show = true
|
|
|
|
+ },
|
|
|
|
+ handleView () {
|
|
|
|
+ this.draw({ id: +this.menu.item.id }, () => {
|
|
|
|
+ this.menu.activeId = +this.menu.item.id
|
|
|
|
+ })
|
|
|
|
+ },
|
|
handleChangeMeta (val) {
|
|
handleChangeMeta (val) {
|
|
this.showMeta = val
|
|
this.showMeta = val
|
|
this.init()
|
|
this.init()
|
|
@@ -248,20 +280,25 @@ export default {
|
|
},
|
|
},
|
|
async init () {
|
|
async init () {
|
|
const query = {
|
|
const query = {
|
|
- ...this.query,
|
|
|
|
- type: this.type,
|
|
|
|
- meta: this.showMeta
|
|
|
|
|
|
+ ...this.query
|
|
}
|
|
}
|
|
if (this.$route.params.id) {
|
|
if (this.$route.params.id) {
|
|
Object.assign(query, {
|
|
Object.assign(query, {
|
|
id: +this.$route.params.id
|
|
id: +this.$route.params.id
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ this.draw(query)
|
|
|
|
+ },
|
|
|
|
+ async draw (query, successCallback = () => {}) {
|
|
// 清空再渲染
|
|
// 清空再渲染
|
|
this.loading = true
|
|
this.loading = true
|
|
this.empty = false
|
|
this.empty = false
|
|
try {
|
|
try {
|
|
- const { data } = await this.toApi(query)
|
|
|
|
|
|
+ const { data } = await this.toApi({
|
|
|
|
+ ...query,
|
|
|
|
+ type: this.type,
|
|
|
|
+ meta: this.showMeta
|
|
|
|
+ })
|
|
if (!data.nodes || !data.nodes.length) {
|
|
if (!data.nodes || !data.nodes.length) {
|
|
this.empty = true
|
|
this.empty = true
|
|
this.loading = false
|
|
this.loading = false
|
|
@@ -279,10 +316,13 @@ export default {
|
|
data.lines.forEach(ele => {
|
|
data.lines.forEach(ele => {
|
|
ele.color = LINE_COLOR_MAP[ele.text]
|
|
ele.color = LINE_COLOR_MAP[ele.text]
|
|
})
|
|
})
|
|
- this.$refs.graphRef.setOptions(this.graphOptions, async (graphInstance) => {
|
|
|
|
- this.$refs.graphRef.setJsonData(data, async (_graphInstance) => {
|
|
|
|
- await _graphInstance.setZoom(75)
|
|
|
|
- this.loading = false
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.$refs.graphRef.setOptions(this.graphOptions, async (graphInstance) => {
|
|
|
|
+ this.$refs.graphRef.setJsonData(data, async (_graphInstance) => {
|
|
|
|
+ await _graphInstance.setZoom(75)
|
|
|
|
+ successCallback()
|
|
|
|
+ this.loading = false
|
|
|
|
+ })
|
|
})
|
|
})
|
|
})
|
|
})
|
|
} catch (error) {
|
|
} catch (error) {
|