From ac3ad638949e4d560ddf69320a5f9bb28ca5aaca Mon Sep 17 00:00:00 2001
From: ahaos <8406649+lhailgl@user.noreply.gitee.com>
Date: 星期三, 19 七月 2023 22:48:30 +0800
Subject: [PATCH] !29 修改列表打开对话框和接口请求顺序 Merge pull request !29 from ahaos/tspr

---
 src/views/system/dept/index.vue |   65 +++++++++++++++-----------------
 1 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index a1dcb9f..12f7564 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -219,23 +219,7 @@
   queryFormRef.value?.resetFields();
   handleQuery()
 }
-/** 鏂板鎸夐挳鎿嶄綔 */
-const handleAdd = (row?: DeptVO) => {
-  listDept().then(res => {
-    const data = proxy?.handleTree<DeptOptionsType>(res.data, "deptId");
-    if (data) {
-      deptOptions.value = data
-      dialog.visible = true;
-      dialog.title = "娣诲姞閮ㄩ棬";
-      nextTick(() => {
-        reset();
-        if (row && row.deptId) {
-          form.value.parentId = row?.deptId;
-        }
-      })
-    }
-  })
-}
+
 /** 灞曞紑/鎶樺彔鎿嶄綔 */
 const handleToggleExpandAll = () => {
   isExpandAll.value = !isExpandAll.value;
@@ -249,28 +233,41 @@
   })
 }
 
+/** 鏂板鎸夐挳鎿嶄綔 */
+const handleAdd = async (row?: DeptVO) => {
+  reset();
+  const res = await listDept();
+  const data = proxy?.handleTree<DeptOptionsType>(res.data, "deptId");
+  if (data) {
+    deptOptions.value = data
+    if (row && row.deptId) {
+      form.value.parentId = row?.deptId;
+    }
+    dialog.visible = true;
+    dialog.title = "娣诲姞閮ㄩ棬";
+  }
+}
+
 /** 淇敼鎸夐挳鎿嶄綔 */
 const handleUpdate = async (row: DeptVO) => {
+  reset();
   const res = await getDept(row.deptId);
+  form.value = res.data
+  const response = await listDeptExcludeChild(row.deptId);
+  const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId")
+  if (data) {
+    deptOptions.value = data;
+    if (data.length === 0) {
+      const noResultsOptions: DeptOptionsType = {
+        deptId: res.data.parentId,
+        deptName: res.data.parentName,
+        children: []
+      };
+      deptOptions.value.push(noResultsOptions);
+    }
+  }
   dialog.visible = true;
   dialog.title = "淇敼閮ㄩ棬";
-  await nextTick(async () => {
-    reset();
-    form.value = res.data
-    const response = await listDeptExcludeChild(row.deptId);
-    const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId")
-    if (data) {
-      deptOptions.value = data;
-      if (data.length === 0) {
-        const noResultsOptions: DeptOptionsType = {
-          deptId: res.data.parentId,
-          deptName: res.data.parentName,
-          children: []
-        };
-        deptOptions.value.push(noResultsOptions);
-      }
-    }
-  })
 }
 /** 鎻愪氦鎸夐挳 */
 const submitForm = () => {

--
Gitblit v1.9.3