From 97667573dd1f176bccb9aa09c0bf71fbb16974e1 Mon Sep 17 00:00:00 2001 From: tian <3072314689@qq.com> Date: 星期日, 28 九月 2025 18:19:43 +0800 Subject: [PATCH] 必选框 --- src/views/archiveManager/seleUser.vue | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/views/archiveManager/seleUser.vue b/src/views/archiveManager/seleUser.vue index 6faa5ed..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,12 +58,17 @@ </template> <script> + import {listArchiverecordstouser,addArchiverecordstouser,authRecordToUser,getArchiverecordstouserByReIdAndUid} from "@/api/system/archiverecordstouser" + import { UserRoleIdList,unallocatedUserList, authUserSelectAll } from "@/api/system/role" export default { dicts: ['sys_normal_disable'], props: { // 瑙掕壊缂栧彿 roleId: { + type: [Number, String] + }, + archiveRecordsId: { type: [Number, String] } }, @@ -81,20 +87,36 @@ pageNum: 1, pageSize: 10, roleId: 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.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) { @@ -103,6 +125,8 @@ // 鏌ヨ琛ㄦ暟鎹� getList() { UserRoleIdList(this.queryParams).then(res => { + console.log("=------00000000009") + console.log(res) this.userList = res.rows this.total = res.total }) @@ -119,16 +143,22 @@ }, /** 閫夋嫨鎺堟潈鐢ㄦ埛鎿嶄綔 */ handleSelectUser() { - const roleId = this.queryParams.roleId + const archiveRecordsId = this.queryParams.archiveRecordsId const userIds = this.userIds.join(",") + + if (userIds == "") { this.$modal.msgError("璇烽�夋嫨瑕佸垎閰嶇殑鐢ㄦ埛") return } - authUserSelectAll({ roleId: roleId, 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