From cc9b67d4676dd51a6b2d88e92607aca2629ee54d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 22 十二月 2023 13:26:26 +0800
Subject: [PATCH] !72 发布 vue 版本 5.1.2 与 cloud 版本 2.1.2 Merge pull request !72 from 疯狂的狮子Li/temp

---
 src/views/system/user/index.vue |   69 +++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 8e3bcfa..100b5a7 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -154,7 +154,7 @@
     </el-row>
 
     <!-- 娣诲姞鎴栦慨鏀圭敤鎴烽厤缃璇濇 -->
-    <el-dialog :title="dialog.title" v-model="dialog.visible" width="600px" append-to-body @close="closeDialog">
+    <el-dialog ref="formDialogRef" :title="dialog.title" v-model="dialog.visible" width="600px" append-to-body @close="closeDialog">
       <el-form :model="form" :rules="rules" ref="userFormRef" label-width="80px">
         <el-row>
           <el-col :span="12">
@@ -299,12 +299,12 @@
 <script setup name="User" lang="ts">
 import api from "@/api/system/user"
 import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
-import { getToken } from "@/utils/auth";
 import { treeselect } from "@/api/system/dept";
 import { DeptVO } from "@/api/system/dept/types";
 import { RoleVO } from "@/api/system/role/types";
 import { PostVO } from "@/api/system/post/types";
 import { to } from "await-to-js";
+import { globalHeaders } from "@/utils/request";
 
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance
@@ -320,7 +320,7 @@
 const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
 const deptName = ref('');
 const deptOptions = ref<DeptVO[]>([]);
-const initPassword = ref('123456');
+const initPassword = ref<String>('');
 const postOptions = ref<PostVO[]>([]);
 const roleOptions = ref<RoleVO[]>([]);
 /*** 鐢ㄦ埛瀵煎叆鍙傛暟 */
@@ -334,19 +334,19 @@
   // 鏄惁鏇存柊宸茬粡瀛樺湪鐨勭敤鎴锋暟鎹�
   updateSupport: 0,
   // 璁剧疆涓婁紶鐨勮姹傚ご閮�
-  headers: { Authorization: "Bearer " + getToken() },
+  headers: globalHeaders(),
   // 涓婁紶鐨勫湴鍧�
   url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
 })
 // 鍒楁樉闅愪俊鎭�
 const columns = ref<FieldOption[]>([
-  { key: 0, label: `鐢ㄦ埛缂栧彿`, visible: false },
-  { key: 1, label: `鐢ㄦ埛鍚嶇О`, visible: true },
-  { key: 2, label: `鐢ㄦ埛鏄电О`, visible: true },
-  { key: 3, label: `閮ㄩ棬`, visible: true },
-  { key: 4, label: `鎵嬫満鍙风爜`, visible: true },
-  { key: 5, label: `鐘舵�乣, visible: true },
-  { key: 6, label: `鍒涘缓鏃堕棿`, visible: true }
+  { key: 0, label: `鐢ㄦ埛缂栧彿`, visible: false,children: [] },
+  { key: 1, label: `鐢ㄦ埛鍚嶇О`, visible: true,children: [] },
+  { key: 2, label: `鐢ㄦ埛鏄电О`, visible: true,children: [] },
+  { key: 3, label: `閮ㄩ棬`, visible: true,children: [] },
+  { key: 4, label: `鎵嬫満鍙风爜`, visible: true,children: [] },
+  { key: 5, label: `鐘舵�乣, visible: true,children: [] },
+  { key: 6, label: `鍒涘缓鏃堕棿`, visible: true,children: [] }
 ])
 
 
@@ -354,6 +354,7 @@
 const queryFormRef = ref<ElFormInstance>();
 const userFormRef = ref<ElFormInstance>();
 const uploadRef = ref<ElUploadInstance>();
+const formDialogRef = ref<ElDialogInstance>();
 
 const dialog = reactive<DialogOption>({
   visible: false,
@@ -547,40 +548,35 @@
 }
 /** 鍙栨秷鎸夐挳 */
 const cancel = () => {
-  reset();
   dialog.visible = false;
+  reset();
 }
 
 /** 鏂板鎸夐挳鎿嶄綔 */
-const handleAdd = () => {
+const handleAdd = async () => {
+  reset();
+  const { data } = await api.getUser();
   dialog.visible = true;
   dialog.title = "鏂板鐢ㄦ埛";
-  nextTick(async () => {
-    reset();
-    await initTreeData();
-    const { data } = await api.getUser();
-    postOptions.value = data.posts;
-    roleOptions.value = data.roles;
-    form.value.password = initPassword.value;
-  })
+  await initTreeData();
+  postOptions.value = data.posts;
+  roleOptions.value = data.roles;
+  form.value.password = initPassword.value.toString();
 }
 /** 淇敼鎸夐挳鎿嶄綔 */
-const handleUpdate = (row?: UserForm) => {
+const handleUpdate = async (row?: UserForm) => {
+  reset();
+  const userId = row?.userId || ids.value[0]
+  const { data } = await api.getUser(userId)
   dialog.visible = true;
   dialog.title = "淇敼鐢ㄦ埛";
-  nextTick(async () => {
-    reset();
-    await initTreeData();
-    const userId = row?.userId || ids.value[0]
-    const { data } = await api.getUser(userId)
-    Object.assign(form.value, data.user);
-    postOptions.value = data.posts;
-    roleOptions.value = data.roles;
-    form.value.postIds = data.postIds;
-    form.value.roleIds = data.roleIds;
-    form.value.password = "";
-  })
-
+  await initTreeData();
+  Object.assign(form.value, data.user);
+  postOptions.value = data.posts;
+  roleOptions.value = data.roles;
+  form.value.postIds = data.postIds;
+  form.value.roleIds = data.roleIds;
+  form.value.password = "";
 }
 
 /** 鎻愪氦鎸夐挳 */
@@ -617,6 +613,9 @@
 onMounted(() => {
   getTreeSelect() // 鍒濆鍖栭儴闂ㄦ暟鎹�
   getList() // 鍒濆鍖栧垪琛ㄦ暟鎹�
+  proxy?.getConfigKey("sys.user.initPassword").then(response => {
+    initPassword.value = response.data;
+  });
 });
 </script>
 

--
Gitblit v1.9.3