From dd2bdb18a8394d2f2a13534a98bcadb8020e3668 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: 星期三, 23 七月 2025 16:09:33 +0800
Subject: [PATCH] 修改新增

---
 src/store/modules/user.js                                                  |    2 +
 src/views/build/conpanyFunctionConsult/orgStructure/departManage/index.vue |   75 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index c0b4cc6..1a4d328 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -12,6 +12,7 @@
       id: '',
       name: '',
       companyId: null,
+      companyName: '',
       avatar: '',
       roles: [],
       permissions: []
@@ -49,6 +50,7 @@
             this.id = user.userId
             this.name = user.userName
             this.companyId = user.companyId
+            this.companyName = user.companyName
             this.avatar = avatar
             Cookies.set('userInfo',JSON.stringify(user))
             resolve(res)
diff --git a/src/views/build/conpanyFunctionConsult/orgStructure/departManage/index.vue b/src/views/build/conpanyFunctionConsult/orgStructure/departManage/index.vue
index 3d8929b..abb24d7 100644
--- a/src/views/build/conpanyFunctionConsult/orgStructure/departManage/index.vue
+++ b/src/views/build/conpanyFunctionConsult/orgStructure/departManage/index.vue
@@ -19,6 +19,7 @@
           <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button>
           <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button>
           <el-button type="primary" @click="initDistribute">生成职能分配表</el-button>
+          <el-button type="primary" @click="generateMap">生成组织机构图</el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -63,6 +64,26 @@
 <!--    />-->
     <depart-dialog ref="dialogRef" @getList=getList></depart-dialog>
     <duty-dialog ref="dutyDialogRef" @getList=getList></duty-dialog>
+    <el-dialog
+        v-model="dialogVisible"
+        title="组织机构图"
+        width="75%"
+        center
+        :before-close="handleClose"
+        :close-on-press-escape="false"
+        :close-on-click-modal="false"
+    >
+      <div class="deptTreeBox">
+        <vue3-tree-org
+            :data="deptList"
+            :horizontal="false"
+            :props="treeProps"
+            :toolBar="tools"
+            :label-style="labelStyle"
+            center
+        />
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -92,10 +113,27 @@
   },
   total: 0,
   dataList: [],
+  deptList: {
+    id: 0,
+    deptName: "",
+    children:[]
+  },
   companyList: [],
-  isAdmin: false
+  companyName: '',
+  isAdmin: false,
+  dialogVisible: false,
+  treeProps: {
+    label: 'deptName'
+  },
+  tools: {
+    scale: true, restore: true, expand: false, zoom: false, fullscreen: false
+  },
+  labelStyle: {
+    border: '1px solid #ccc',
+    background: 'rgba(0,0,0,0)'
+  }
 });
-const { queryParams, total, dataList, companyList, isAdmin } = toRefs(data);
+const { queryParams, total, dataList, companyList, isAdmin, dialogVisible, deptList, treeProps, tools, labelStyle } = toRefs(data);
 const userInfo = ref()
 onMounted(async ()=>{
   if(userStore.roles.includes('admin')){
@@ -112,12 +150,37 @@
 
 })
 
+const generateMap = async ()=>{
+  if(!data.queryParams.companyId){
+    ElMessage.warning('请先选择企业')
+  }else{
+    data.deptList.deptName = data.companyList?.find(i=>i.id == data.queryParams.companyId)?.name || userStore.companyName
+    const res = await getDepart(data.queryParams)
+    if(res.code == 200){
+      const list = proxy.handleTree(res.data, "deptId")
+      data.deptList.children = list
+    }else{
+      ElMessage.warning(res.message)
+    }
+    data.dialogVisible = true
+  }
+}
+
+const handleClose = ()=>{
+  data.deptList = {
+    id: 0,
+    deptName: "",
+    children:[]
+  }
+  data.dialogVisible = false
+}
+
 const getList = async () => {
   loading.value = true
   const res = await getDepart(data.queryParams)
   if(res.code == 200){
     data.dataList = proxy.handleTree(res.data, "deptId")
-    console.log(data.dataList,'list')
+    data.deptList.children = data.dataList
     // data.total = res.data.total
   }else{
     ElMessage.warning(res.message)
@@ -288,3 +351,9 @@
 }
 
 </script>
+<style scoped lang="scss">
+.deptTreeBox{
+  width: 100%;
+  height: 800px;
+}
+</style>

--
Gitblit v1.9.2