From 6af68085ff6615e1ec3a5dd18c761250800d6fca Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail.com>
Date: 星期二, 06 六月 2023 22:23:43 +0800
Subject: [PATCH] update 修改页面代码 去除ele的引入以及vue的类型声明

---
 src/views/system/user/authRole.vue |   78 +++++++++++++++++++-------------------
 1 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/src/views/system/user/authRole.vue b/src/views/system/user/authRole.vue
index 0e8eba2..e55a8d8 100644
--- a/src/views/system/user/authRole.vue
+++ b/src/views/system/user/authRole.vue
@@ -55,11 +55,10 @@
 </template>
 
 <script setup name="AuthRole" lang="ts">
-import { RoleVO } from '@/api/system/role/types';
-import { getAuthRole, updateAuthRole } from '@/api/system/user';
-import { UserForm } from '@/api/system/user/types';
-import { ElTable } from "element-plus";
-import { ComponentInternalInstance } from 'vue';
+import { RoleVO } from "@/api/system/role/types";
+import { getAuthRole, updateAuthRole } from "@/api/system/user";
+import { UserForm } from "@/api/system/user/types";
+
 const route = useRoute();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -70,58 +69,59 @@
 const roleIds = ref<Array<string | number>>([]);
 const roles = ref<RoleVO[]>([]);
 const form = ref<Partial<UserForm>>({
-    nickName: undefined,
-    userName: '',
-    userId: undefined
+  nickName: undefined,
+  userName: "",
+  userId: undefined
 });
 
-const tableRef = ref(ElTable)
+const tableRef = ref<ElTableInstance>();
 
 /** 鍗曞嚮閫変腑琛屾暟鎹� */
 const clickRow = (row: RoleVO) => {
-    tableRef.value.toggleRowSelection(row);
+  // ele鐨勬柟娉曟湁闂锛宻elected搴旇涓哄彲閫夊弬鏁�
+  tableRef.value?.toggleRowSelection(row);
 };
 /** 澶氶�夋閫変腑鏁版嵁 */
 const handleSelectionChange = (selection: RoleVO[]) => {
-    roleIds.value = selection.map(item => item.roleId);
+  roleIds.value = selection.map(item => item.roleId);
 };
 /** 淇濆瓨閫変腑鐨勬暟鎹紪鍙� */
 const getRowKey = (row: RoleVO): string => {
-    return String(row.roleId);
+  return String(row.roleId);
 };
 /** 鍏抽棴鎸夐挳 */
 const close = () => {
-    const obj = { path: "/system/user" };
-    proxy?.$tab.closeOpenPage(obj);
+  const obj = { path: "/system/user" };
+  proxy?.$tab.closeOpenPage(obj);
 };
 /** 鎻愪氦鎸夐挳 */
 const submitForm = async () => {
-    const userId = form.value.userId;
-    const rIds = roleIds.value.join(",");
-    await updateAuthRole({ userId: userId as string, roleIds: rIds })
-    proxy?.$modal.msgSuccess("鎺堟潈鎴愬姛");
-    close();
+  const userId = form.value.userId;
+  const rIds = roleIds.value.join(",");
+  await updateAuthRole({ userId: userId as string, roleIds: rIds });
+  proxy?.$modal.msgSuccess("鎺堟潈鎴愬姛");
+  close();
 };
 
-const getList = async() => {
-    const userId = route.params && route.params.userId;
-    if (userId) {
-        loading.value = true;
-        const res = await getAuthRole(userId as string);
-        Object.assign(form.value, res.data.user)
-        Object.assign(roles.value, res.data.roles)
-        total.value = roles.value.length;
-        await nextTick(() => {
-            roles.value.forEach(row => {
-                if (row?.flag) {
-                    tableRef.value.toggleRowSelection(row);
-                }
-            });
-        });
-        loading.value = false;
-    }
-}
+const getList = async () => {
+  const userId = route.params && route.params.userId;
+  if (userId) {
+    loading.value = true;
+    const res = await getAuthRole(userId as string);
+    Object.assign(form.value, res.data.user);
+    Object.assign(roles.value, res.data.roles);
+    total.value = roles.value.length;
+    await nextTick(() => {
+      roles.value.forEach(row => {
+        if (row?.flag) {
+          tableRef.value?.toggleRowSelection(row, true);
+        }
+      });
+    });
+    loading.value = false;
+  }
+};
 onMounted(() => {
-    getList();
-})
+  getList();
+});
 </script>

--
Gitblit v1.9.3