|
@@ -140,7 +140,7 @@ export default {
|
|
|
},
|
|
|
async renderGraph (data) {
|
|
|
this.graph.setData(data)
|
|
|
- this.graph.render()
|
|
|
+ await this.graph.render()
|
|
|
},
|
|
|
async onInit () {
|
|
|
this.loading = true
|
|
@@ -239,15 +239,9 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- await this.graph.render()
|
|
|
this.onGraphHandles(this.graph)
|
|
|
- data.nodes.forEach(e => {
|
|
|
- if (e.depth === 1) {
|
|
|
- this.graph.collapseElement(e.id)
|
|
|
- }
|
|
|
- })
|
|
|
- // 关闭之后重新排版计算
|
|
|
- this.graph.render()
|
|
|
+ await this.graph.render()
|
|
|
+ this.onSetClose(data.nodes)
|
|
|
},
|
|
|
onGraphHandles (graph) {
|
|
|
const contextMenu = this.$refs.contextMenuRefs
|
|
@@ -275,6 +269,17 @@ export default {
|
|
|
contextMenu.style.display = 'none'
|
|
|
})
|
|
|
},
|
|
|
+ // 设置默认展示格式
|
|
|
+ onSetClose (nodes) {
|
|
|
+ // 默认展示第一层
|
|
|
+ nodes.forEach(e => {
|
|
|
+ if (e.depth === 1) {
|
|
|
+ this.graph.collapseElement(e.id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 关闭之后重新排版计算
|
|
|
+ this.graph.render()
|
|
|
+ },
|
|
|
async onDelete (nodes) {
|
|
|
this.$confirm('是否删除该项', '提示').then(async () => {
|
|
|
try {
|
|
@@ -324,7 +329,12 @@ export default {
|
|
|
},
|
|
|
async onImport (response) {
|
|
|
this.importLoading = true
|
|
|
- await upload(importOrganization, response.file, this.onInit)
|
|
|
+ const check = await upload(importOrganization, response.file)
|
|
|
+ if (check) {
|
|
|
+ const graphData = await this.onInit()
|
|
|
+ await this.renderGraph(graphData)
|
|
|
+ this.onSetClose(graphData.nodes)
|
|
|
+ }
|
|
|
this.importLoading = false
|
|
|
},
|
|
|
async editTag (nodes) {
|