fuyongxin
2026-06-03 00e0dbbf98347b1e47a7e0aedd41baa61f7567ed
ruoyi-ui/src/views/system/role/authUser.vue
@@ -1,12 +1,11 @@
<template>
  <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="用户名称" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名称"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
@@ -16,7 +15,6 @@
          v-model="queryParams.phonenumber"
          placeholder="请输入手机号码"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
@@ -102,8 +100,8 @@
</template>
<script>
import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role";
import selectUser from "./selectUser";
import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"
import selectUser from "./selectUser"
export default {
  name: "AuthUser",
@@ -131,40 +129,40 @@
        userName: undefined,
        phonenumber: undefined
      }
    };
    }
  },
  created() {
    const roleId = this.$route.params && this.$route.params.roleId;
    const roleId = this.$route.params && this.$route.params.roleId
    if (roleId) {
      this.queryParams.roleId = roleId;
      this.getList();
      this.queryParams.roleId = roleId
      this.getList()
    }
  },
  methods: {
    /** 查询授权用户列表 */
    getList() {
      this.loading = true;
      this.loading = true
      allocatedUserList(this.queryParams).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
          this.userList = response.rows
          this.total = response.total
          this.loading = false
        }
      );
      )
    },
    // 返回按钮
    handleClose() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({ path: "/system/role" });
      const obj = { path: "/system/role" }
      this.$tab.closeOpenPage(obj)
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
@@ -173,29 +171,29 @@
    },
    /** 打开授权用户表弹窗 */
    openSelectUser() {
      this.$refs.select.show();
      this.$refs.select.show()
    },
    /** 取消授权按钮操作 */
    cancelAuthUser(row) {
      const roleId = this.queryParams.roleId;
      const roleId = this.queryParams.roleId
      this.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?').then(function() {
        return authUserCancel({ userId: row.userId, roleId: roleId });
        return authUserCancel({ userId: row.userId, roleId: roleId })
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("取消授权成功");
      }).catch(() => {});
        this.getList()
        this.$modal.msgSuccess("取消授权成功")
      }).catch(() => {})
    },
    /** 批量取消授权按钮操作 */
    cancelAuthUserAll(row) {
      const roleId = this.queryParams.roleId;
      const userIds = this.userIds.join(",");
    cancelAuthUserAll() {
      const roleId = this.queryParams.roleId
      const userIds = this.userIds.join(",")
      this.$modal.confirm('是否取消选中用户授权数据项?').then(function() {
        return authUserCancelAll({ roleId: roleId, userIds: userIds });
        return authUserCancelAll({ roleId: roleId, userIds: userIds })
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("取消授权成功");
      }).catch(() => {});
        this.getList()
        this.$modal.msgSuccess("取消授权成功")
      }).catch(() => {})
    }
  }
};
}
</script>