From bbe94610a28e72414df1fb2b36a6d11385873e54 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 20 一月 2025 11:30:16 +0800
Subject: [PATCH] update 优化 parseTime 提示报错问题

---
 src/views/system/user/authRole.vue |   48 ++++++++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/src/views/system/user/authRole.vue b/src/views/system/user/authRole.vue
index e55a8d8..fe2e974 100644
--- a/src/views/system/user/authRole.vue
+++ b/src/views/system/user/authRole.vue
@@ -2,7 +2,7 @@
   <div class="p-2">
     <div class="panel">
       <h4 class="panel-title">鍩烘湰淇℃伅</h4>
-      <el-form :model="form" label-width="80px" :inline="true">
+      <el-form :model="form" :inline="true">
         <el-row :gutter="10">
           <el-col :span="2.5">
             <el-form-item label="鐢ㄦ埛鏄电О" prop="nickName">
@@ -21,12 +21,12 @@
       <h4 class="panel-title">瑙掕壊淇℃伅</h4>
       <div>
         <el-table
+          ref="tableRef"
           v-loading="loading"
           :row-key="getRowKey"
-          @row-click="clickRow"
-          ref="tableRef"
-          @selection-change="handleSelectionChange"
           :data="roles.slice((pageNum - 1) * pageSize, pageNum * pageSize)"
+          @row-click="clickRow"
+          @selection-change="handleSelectionChange"
         >
           <el-table-column label="搴忓彿" width="55" type="index" align="center">
             <template #default="scope">
@@ -39,12 +39,12 @@
           <el-table-column label="鏉冮檺瀛楃" align="center" prop="roleKey" />
           <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
             <template #default="scope">
-              <span>{{ parseTime(scope.row.createTime) }}</span>
+              <span>{{ proxy.parseTime(scope.row.createTime) }}</span>
             </template>
           </el-table-column>
         </el-table>
-        <pagination v-show="total > 0" :total="total" v-model:page="pageNum" v-model:limit="pageSize" />
-        <div style="text-align: center;margin-left:-120px;margin-top:30px;">
+        <pagination v-show="total > 0" v-model:page="pageNum" v-model:limit="pageSize" :total="total" />
+        <div style="text-align: center; margin-left: -120px; margin-top: 30px">
           <el-button type="primary" @click="submitForm()">鎻愪氦</el-button>
           <el-button @click="close()">杩斿洖</el-button>
         </div>
@@ -55,9 +55,11 @@
 </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 { RoleVO } from '@/api/system/role/types';
+import { getAuthRole, updateAuthRole } from '@/api/system/user';
+import { UserForm } from '@/api/system/user/types';
+import { RouteLocationNormalized } from 'vue-router';
+import { parseTime } from '@/utils/ruoyi';
 
 const route = useRoute();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -70,7 +72,7 @@
 const roles = ref<RoleVO[]>([]);
 const form = ref<Partial<UserForm>>({
   nickName: undefined,
-  userName: "",
+  userName: '',
   userId: undefined
 });
 
@@ -78,12 +80,12 @@
 
 /** 鍗曞嚮閫変腑琛屾暟鎹� */
 const clickRow = (row: RoleVO) => {
-  // ele鐨勬柟娉曟湁闂锛宻elected搴旇涓哄彲閫夊弬鏁�
-  tableRef.value?.toggleRowSelection(row);
+  row.flag = !row.flag;
+  tableRef.value?.toggleRowSelection(row, row.flag);
 };
 /** 澶氶�夋閫変腑鏁版嵁 */
 const handleSelectionChange = (selection: RoleVO[]) => {
-  roleIds.value = selection.map(item => item.roleId);
+  roleIds.value = selection.map((item) => item.roleId);
 };
 /** 淇濆瓨閫変腑鐨勬暟鎹紪鍙� */
 const getRowKey = (row: RoleVO): string => {
@@ -91,15 +93,25 @@
 };
 /** 鍏抽棴鎸夐挳 */
 const close = () => {
-  const obj = { path: "/system/user" };
+  const obj: RouteLocationNormalized = {
+    fullPath: '',
+    hash: '',
+    matched: [],
+    meta: undefined,
+    name: undefined,
+    params: undefined,
+    query: undefined,
+    redirectedFrom: undefined,
+    path: '/system/user'
+  };
   proxy?.$tab.closeOpenPage(obj);
 };
 /** 鎻愪氦鎸夐挳 */
 const submitForm = async () => {
   const userId = form.value.userId;
-  const rIds = roleIds.value.join(",");
+  const rIds = roleIds.value.join(',');
   await updateAuthRole({ userId: userId as string, roleIds: rIds });
-  proxy?.$modal.msgSuccess("鎺堟潈鎴愬姛");
+  proxy?.$modal.msgSuccess('鎺堟潈鎴愬姛');
   close();
 };
 
@@ -112,7 +124,7 @@
     Object.assign(roles.value, res.data.roles);
     total.value = roles.value.length;
     await nextTick(() => {
-      roles.value.forEach(row => {
+      roles.value.forEach((row) => {
         if (row?.flag) {
           tableRef.value?.toggleRowSelection(row, true);
         }

--
Gitblit v1.9.3