Quellcode durchsuchen

机构展示调整

zhengnaiwen_citu vor 6 Monaten
Ursprung
Commit
ea7e559697

+ 4 - 1
src/utils/antvG6.js

@@ -68,7 +68,10 @@ export class MindMapNode extends Circle {
 
   drawCollapseShape (attributes, container) {
     const nodes = this.context.graph.getNodeData(this.id)
-    if (!nodes.children && !nodes.hasChildren) {
+    if (this.id === 'b492100959bfde7a6b317038d1f1d15a') {
+      console.log('b492100959bfde7a6b317038d1f1d15a', nodes)
+    }
+    if (!nodes.children?.length && !nodes.hasChildren) {
       return
     }
     const btn = this.upsert('collapse-expand', Badge, {

+ 1 - 2
src/utils/elementUploadAndDownload.js

@@ -9,13 +9,12 @@ import { downloadFile } from '@/utils'
  * @param {File} file 文件
  * @param {Promise} init 实例
  */
-export async function upload (api, file, init) {
+export async function upload (api, file) {
   const formData = new FormData()
   formData.append('file', file)
   try {
     await api(formData)
     Vue.prototype.$message.success('导入成功')
-    init && init()
     return true
   } catch (error) {
     Vue.prototype.$message.error(error)

+ 20 - 10
src/views/humanResources/organizationStructure/index.vue

@@ -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) {