| | |
| | | <template> |
| | | <div class="p-2"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div class="search" v-show="showSearch"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true"> |
| | | <div v-show="showSearch" class="search"> |
| | | <el-form ref="queryFormRef" :model="queryParams" :inline="true"> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | |
| | | <template #header> |
| | | <el-row :gutter="10"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="openSelectUser" v-hasPermi="['system:role:add']">添加用户</el-button> |
| | | <el-button v-hasPermi="['system:role:add']" type="primary" plain icon="Plus" @click="openSelectUser">添加用户</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="CircleClose" :disabled="multiple" @click="cancelAuthUserAll" v-hasPermi="['system:role:remove']"> |
| | | <el-button v-hasPermi="['system:role:remove']" type="danger" plain icon="CircleClose" :disabled="multiple" @click="cancelAuthUserAll"> |
| | | 批量取消授权 |
| | | </el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="Close" @click="handleClose">关闭</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :search="true"></right-toolbar> |
| | | <right-toolbar v-model:showSearch="showSearch" :search="true" @query-table="getList"></right-toolbar> |
| | | </el-row> |
| | | </template> |
| | | <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> |
| | |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="取消授权" placement="top"> |
| | | <el-button link type="primary" icon="CircleClose" @click="cancelAuthUser(scope.row)" v-hasPermi="['system:role:remove']"> </el-button> |
| | | <el-button v-hasPermi="['system:role:remove']" link type="primary" icon="CircleClose" @click="cancelAuthUser(scope.row)"> </el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> |
| | | <select-user ref="selectRef" :roleId="queryParams.roleId" @ok="handleQuery" /> |
| | | <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" /> |
| | | <select-user ref="selectRef" :role-id="queryParams.roleId" @ok="handleQuery" /> |
| | | </el-card> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="AuthUser" lang="ts"> |
| | | import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"; |
| | | import { UserQuery } from "@/api/system/user/types"; |
| | | import { UserVO } from "@/api/system/user/types"; |
| | | import SelectUser from "./selectUser.vue"; |
| | | |
| | | import { allocatedUserList, authUserCancel, authUserCancelAll } from '@/api/system/role'; |
| | | import { UserQuery } from '@/api/system/user/types'; |
| | | import { UserVO } from '@/api/system/user/types'; |
| | | import SelectUser from './selectUser.vue'; |
| | | |
| | | const route = useRoute(); |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")); |
| | | const { sys_normal_disable } = toRefs<any>(proxy?.useDict('sys_normal_disable')); |
| | | |
| | | const userList = ref<UserVO[]>([]); |
| | | const loading = ref(true); |
| | |
| | | pageSize: 10, |
| | | roleId: route.params.roleId as string, |
| | | userName: undefined, |
| | | phonenumber: undefined, |
| | | phonenumber: undefined |
| | | }); |
| | | |
| | | /** 查询授权用户列表 */ |
| | |
| | | userList.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | } |
| | | }; |
| | | // 返回按钮 |
| | | const handleClose = () => { |
| | | const obj = { path: "/system/role" }; |
| | | const obj = { path: '/system/role' }; |
| | | proxy?.$tab.closeOpenPage(obj); |
| | | } |
| | | }; |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.pageNum = 1; |
| | | getList(); |
| | | } |
| | | }; |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value?.resetFields(); |
| | | handleQuery(); |
| | | } |
| | | }; |
| | | // 多选框选中数据 |
| | | const handleSelectionChange = (selection: UserVO[]) => { |
| | | userIds.value = selection.map(item => item.userId); |
| | | userIds.value = selection.map((item) => item.userId); |
| | | multiple.value = !selection.length; |
| | | } |
| | | }; |
| | | /** 打开授权用户表弹窗 */ |
| | | const openSelectUser = () => { |
| | | selectRef.value?.show(); |
| | | } |
| | | }; |
| | | /** 取消授权按钮操作 */ |
| | | const cancelAuthUser = async (row: UserVO) => { |
| | | await proxy?.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?'); |
| | | await authUserCancel({ userId: row.userId, roleId: queryParams.roleId }); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | } |
| | | proxy?.$modal.msgSuccess('取消授权成功'); |
| | | }; |
| | | /** 批量取消授权按钮操作 */ |
| | | const cancelAuthUserAll = async () => { |
| | | const roleId = queryParams.roleId; |
| | | const uIds = userIds.value.join(","); |
| | | await proxy?.$modal.confirm("是否取消选中用户授权数据项?"); |
| | | const uIds = userIds.value.join(','); |
| | | await proxy?.$modal.confirm('是否取消选中用户授权数据项?'); |
| | | await authUserCancelAll({ roleId: roleId, userIds: uIds }); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | } |
| | | proxy?.$modal.msgSuccess('取消授权成功'); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getList(); |