From 02bd5982028af6e791dd0857f535a41aaf74679e Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期一, 10 二月 2025 13:14:32 +0800
Subject: [PATCH] 修改

---
 src/views/system/dept/index.vue |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index 4b87c69..d43e67e 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -56,9 +56,9 @@
       :default-expand-all="isExpandAll"
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
     >
-      <el-table-column prop="deptName" label="组织架构名称" width="260"></el-table-column>
+      <el-table-column prop="deptName" label="组织架构名称"></el-table-column>
       <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
-      <el-table-column prop="status" label="状态" width="100">
+      <el-table-column prop="status" label="状态" width="200">
         <template slot-scope="scope">
           <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
         </template>
@@ -68,7 +68,7 @@
           <span>{{ parseTime(scope.row.createTime) }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="操作" align="center" class-name="small-padding" width="200">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -103,7 +103,7 @@
         <el-row>
           <el-col :span="24" v-if="form.parentId !== 0">
             <el-form-item label="上级组织架构" prop="parentId">
-              <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级组织架构" />
+              <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级组织架构" @input="getDistrict"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -319,7 +319,7 @@
       this.title = "添加组织架构";
       listDept().then(response => {
         this.deptOptions = this.handleTree(response.data, "deptId");
-      });
+      })
     },
     /** 展开/折叠操作 */
     toggleExpandAll() {
@@ -374,6 +374,24 @@
         this.getList();
         this.$modal.msgSuccess("删除成功");
       }).catch(() => {});
+    },
+    getDistrict(val){
+      const t = this
+      t.form.districtCode = t.findCodeById(t.deptOptions,val)
+    },
+    findCodeById(data,id){
+      for(let node of data){
+        if(node.deptId == id){
+          return node.districtCode
+        }
+        if(node.children){
+          const findNode = this.findCodeById(node.children,id)
+          if(findNode){
+            return findNode
+          }
+        }
+      }
+      return null
     }
   }
 };

--
Gitblit v1.9.2