From 6666ce5526b1ed17f5c3906c94620cad586745a5 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期五, 28 六月 2024 17:01:39 +0800
Subject: [PATCH] 优化代码

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

diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index 090384e..b483acd 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -6,11 +6,12 @@
                v-model="queryParams.deptName"
                placeholder="璇疯緭鍏ラ儴闂ㄥ悕绉�"
                clearable
+               style="width: 200px"
                @keyup.enter="handleQuery"
             />
          </el-form-item>
          <el-form-item label="鐘舵��" prop="status">
-            <el-select v-model="queryParams.status" placeholder="閮ㄩ棬鐘舵��" clearable>
+            <el-select v-model="queryParams.status" placeholder="閮ㄩ棬鐘舵��" clearable style="width: 200px">
                <el-option
                   v-for="dict in sys_normal_disable"
                   :key="dict.value"
@@ -68,25 +69,9 @@
          </el-table-column>
          <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
             <template #default="scope">
-               <el-button
-                  type="text"
-                  icon="Edit"
-                  @click="handleUpdate(scope.row)"
-                  v-hasPermi="['system:dept:edit']"
-               >淇敼</el-button>
-               <el-button
-                  type="text"
-                  icon="Plus"
-                  @click="handleAdd(scope.row)"
-                  v-hasPermi="['system:dept:add']"
-               >鏂板</el-button>
-               <el-button
-                  v-if="scope.row.parentId != 0"
-                  type="text"
-                  icon="Delete"
-                  @click="handleDelete(scope.row)"
-                  v-hasPermi="['system:dept:remove']"
-               >鍒犻櫎</el-button>
+               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">淇敼</el-button>
+               <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">鏂板</el-button>
+               <el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">鍒犻櫎</el-button>
             </template>
          </el-table-column>
       </el-table>
@@ -97,11 +82,13 @@
             <el-row>
                <el-col :span="24" v-if="form.parentId !== 0">
                   <el-form-item label="涓婄骇閮ㄩ棬" prop="parentId">
-                     <tree-select
-                        v-model:value="form.parentId"
-                        :options="deptOptions"
-                        :objMap="{ value: 'deptId', label: 'deptName', children: 'children' }"
+                     <el-tree-select
+                        v-model="form.parentId"
+                        :data="deptOptions"
+                        :props="{ value: 'deptId', label: 'deptName', children: 'children' }"
+                        value-key="deptId"
                         placeholder="閫夋嫨涓婄骇閮ㄩ棬"
+                        check-strictly
                      />
                   </el-form-item>
                </el-col>
@@ -193,11 +180,13 @@
     loading.value = false;
   });
 }
+
 /** 鍙栨秷鎸夐挳 */
 function cancel() {
   open.value = false;
   reset();
 }
+
 /** 琛ㄥ崟閲嶇疆 */
 function reset() {
   form.value = {
@@ -212,19 +201,22 @@
   };
   proxy.resetForm("deptRef");
 }
+
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 function handleQuery() {
   getList();
 }
+
 /** 閲嶇疆鎸夐挳鎿嶄綔 */
 function resetQuery() {
   proxy.resetForm("queryRef");
   handleQuery();
 }
+
 /** 鏂板鎸夐挳鎿嶄綔 */
-async function handleAdd(row) {
+function handleAdd(row) {
   reset();
-  await listDept().then(response => {
+  listDept().then(response => {
     deptOptions.value = proxy.handleTree(response.data, "deptId");
   });
   if (row != undefined) {
@@ -233,6 +225,7 @@
   open.value = true;
   title.value = "娣诲姞閮ㄩ棬";
 }
+
 /** 灞曞紑/鎶樺彔鎿嶄綔 */
 function toggleExpandAll() {
   refreshTable.value = false;
@@ -241,10 +234,11 @@
     refreshTable.value = true;
   });
 }
+
 /** 淇敼鎸夐挳鎿嶄綔 */
-async function handleUpdate(row) {
+function handleUpdate(row) {
   reset();
-  await listDeptExcludeChild(row.deptId).then(response => {
+  listDeptExcludeChild(row.deptId).then(response => {
     deptOptions.value = proxy.handleTree(response.data, "deptId");
   });
   getDept(row.deptId).then(response => {
@@ -253,6 +247,7 @@
     title.value = "淇敼閮ㄩ棬";
   });
 }
+
 /** 鎻愪氦鎸夐挳 */
 function submitForm() {
   proxy.$refs["deptRef"].validate(valid => {
@@ -273,6 +268,7 @@
     }
   });
 }
+
 /** 鍒犻櫎鎸夐挳鎿嶄綔 */
 function handleDelete(row) {
   proxy.$modal.confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.deptName + '"鐨勬暟鎹」?').then(function() {

--
Gitblit v1.9.3