tian
2025-09-28 97667573dd1f176bccb9aa09c0bf71fbb16974e1
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: {
      // 替换原有的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() {
    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 || "授权失败,已经授权过了")
    }
      })
    }
  }