From 80cbda0daa36d369479746ae4f432d0c13a17a56 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 22 九月 2025 08:18:06 +0800
Subject: [PATCH] 修改了代码

---
 src/views/archiveManager/seleUser.vue |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/views/archiveManager/seleUser.vue b/src/views/archiveManager/seleUser.vue
index 6249c65..39a1eea 100644
--- a/src/views/archiveManager/seleUser.vue
+++ b/src/views/archiveManager/seleUser.vue
@@ -24,7 +24,8 @@
       </el-form-item>
     </el-form>
     <el-row>
-      <el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
+      <el-table @row-click="clickRow" ref="table" :data="userList"   @selection-change="handleSingleSelection"
+ height="260px">
         <el-table-column type="selection" width="55"></el-table-column>
         <el-table-column label="鐢ㄦ埛鍚嶇О" prop="userName" :show-overflow-tooltip="true" />
         <el-table-column label="鐢ㄦ埛鏄电О" prop="nickName" :show-overflow-tooltip="true" />
@@ -57,7 +58,7 @@
 </template>
 
 <script>
-  import {listArchiverecordstouser,addArchiverecordstouser,authRecordToUser} from "@/api/system/archiverecordstouser"
+  import {listArchiverecordstouser,addArchiverecordstouser,authRecordToUser,getArchiverecordstouserByReIdAndUid} from "@/api/system/archiverecordstouser"
 
 import { UserRoleIdList,unallocatedUserList, authUserSelectAll } from "@/api/system/role"
 export default {
@@ -67,7 +68,7 @@
     roleId: {
       type: [Number, String]
     },
-    recordId: {
+    archiveRecordsId: {
       type: [Number, String]
     }
   },
@@ -86,22 +87,36 @@
         pageNum: 1,
         pageSize: 10,
         roleId: undefined,
-        recordId: undefined,
+        archiveRecordsId: undefined,
         userName: undefined,
         phonenumber: undefined
       }
     }
   },
   methods: {
+      // 鏇挎崲鍘熸湁鐨刪andleSelectionChange鏂规硶
+  handleSingleSelection(selection) {
+    if (selection.length > 1) {
+      this.$refs.table.clearSelection();
+      this.$refs.table.toggleRowSelection(selection[selection.length - 1]);
+    }
+    else
+    this.userIds = selection.map(item => item.userId);
+  },
     // 鏄剧ず寮规
-    show() {
+    show(archiveRecordsId) {
+      if (archiveRecordsId) {
+    this.archiveRecordsId = archiveRecordsId
+  }
       this.queryParams.roleId = this.roleId
-      this.queryParams.recordId = this.recordId
+      this.queryParams.archiveRecordsId = this.archiveRecordsId
+
       this.getList()
       this.visible = true
     },
     clickRow(row) {
-      this.$refs.table.toggleRowSelection(row)
+      this.$refs.table.clearSelection();
+    this.$refs.table.toggleRowSelection(row);
     },
     // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
@@ -128,19 +143,22 @@
     },
     /** 閫夋嫨鎺堟潈鐢ㄦ埛鎿嶄綔 */
     handleSelectUser() {
-      const recordId = this.queryParams.recordId
+      const archiveRecordsId = this.queryParams.archiveRecordsId
       const userIds = this.userIds.join(",")
 
-      alert(recordId)
-      alert(userIds)
+ 
       if (userIds == "") {
         this.$modal.msgError("璇烽�夋嫨瑕佸垎閰嶇殑鐢ㄦ埛")
         return
       }
-      authRecordToUser({ recordId: recordId, userIds: userIds }).then(res => {
-        this.$modal.msgSuccess(res.msg)
-        this.visible = false
-        this.$emit("ok")
+      authRecordToUser({ recordId: archiveRecordsId, userIds: userIds }).then(res => {
+        if(res.code === 200) {
+      this.$modal.msgSuccess(res.msg)
+      this.visible = false
+      this.$emit("ok")
+    } else {
+      this.$modal.msgError(res.msg || "鎺堟潈澶辫触锛屽凡缁忔巿鏉冭繃浜�")
+    }
       })
     }
   }

--
Gitblit v1.9.1