| | |
| | | </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" /> |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 替换原有的handleSelectionChange方法 |
| | | 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(archiveRecordsId) { |
| | | if (archiveRecordsId) { |
| | | this.archiveRecordsId = archiveRecordsId |
| | | } |
| | | // 进行类型转换 |
| | | this.archiveRecordsId = !isNaN(Number(archiveRecordsId)) ? Number(archiveRecordsId) : 0 |
| | | } |
| | | this.queryParams.roleId = this.roleId |
| | | this.queryParams.archiveRecordsId = this.archiveRecordsId |
| | | |
| | |
| | | this.visible = true |
| | | }, |
| | | clickRow(row) { |
| | | this.$refs.table.toggleRowSelection(row) |
| | | this.$refs.table.clearSelection(); |
| | | this.$refs.table.toggleRowSelection(row); |
| | | }, |
| | | // 多选框选中数据 |
| | | handleSelectionChange(selection) { |
| | |
| | | const archiveRecordsId = this.queryParams.archiveRecordsId |
| | | const userIds = this.userIds.join(",") |
| | | |
| | | |
| | | if (userIds == "") { |
| | | this.$modal.msgError("请选择要分配的用户") |
| | | return |
| | | } |
| | | authRecordToUser({ recordId: archiveRecordsId, userIds: userIds }).then(res => { |
| | | |
| | | // 创建转换后的参数,确保recordId是数字类型 |
| | | const convertedRecordId = !isNaN(Number(archiveRecordsId)) ? Number(archiveRecordsId) : 0 |
| | | |
| | | authRecordToUser({ recordId: convertedRecordId, 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 || "授权失败,已经授权过了") |
| | | } |
| | | this.$modal.msgSuccess(res.msg) |
| | | this.visible = false |
| | | this.$emit("ok") |
| | | } else { |
| | | this.$modal.msgError(res.msg || "授权失败,已经授权过了") |
| | | } |
| | | }) |
| | | } |
| | | } |