| | |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <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" /> |
| | | </el-card> |
| | | </div> |
| | |
| | | <script setup name="AuthUser" lang="ts"> |
| | | import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"; |
| | | import { UserQuery } from "@/api/system/user/types"; |
| | | import { ComponentInternalInstance } from "vue"; |
| | | import { UserVO } from "@/api/system/user/types"; |
| | | import SelectUser from "./selectUser.vue"; |
| | | // import { ElForm, ElSelect} from 'element-plus'; |
| | | |
| | | |
| | | const route = useRoute(); |
| | |
| | | const total = ref(0); |
| | | const userIds = ref<Array<string | number>>([]); |
| | | |
| | | const queryFormRef = ref(ElForm); |
| | | const selectRef = ref(SelectUser); |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | const selectRef = ref<InstanceType<typeof SelectUser>>(); |
| | | |
| | | const queryParams = reactive<UserQuery>({ |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | roleId: route.params.roleId as string, |
| | | userName: undefined, |
| | | phonenumber: undefined, |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | roleId: route.params.roleId as string, |
| | | userName: undefined, |
| | | phonenumber: undefined, |
| | | }); |
| | | |
| | | /** 查询授权用户列表 */ |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | const res = await allocatedUserList(queryParams); |
| | | userList.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | loading.value = true; |
| | | const res = await allocatedUserList(queryParams); |
| | | userList.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | } |
| | | // 返回按钮 |
| | | const handleClose = () => { |
| | | const obj = { path: "/system/role" }; |
| | | proxy?.$tab.closeOpenPage(obj); |
| | | const obj = { path: "/system/role" }; |
| | | proxy?.$tab.closeOpenPage(obj); |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery=() => { |
| | | queryParams.pageNum = 1; |
| | | getList(); |
| | | const handleQuery = () => { |
| | | queryParams.pageNum = 1; |
| | | getList(); |
| | | } |
| | | /** 重置按钮操作 */ |
| | | const resetQuery=() =>{ |
| | | queryFormRef.value.resetFields(); |
| | | handleQuery(); |
| | | const resetQuery = () => { |
| | | queryFormRef.value?.resetFields(); |
| | | handleQuery(); |
| | | } |
| | | // 多选框选中数据 |
| | | const handleSelectionChange = (selection: UserVO[]) =>{ |
| | | userIds.value = selection.map(item => item.userId); |
| | | multiple.value = !selection.length; |
| | | const handleSelectionChange = (selection: UserVO[]) => { |
| | | userIds.value = selection.map(item => item.userId); |
| | | multiple.value = !selection.length; |
| | | } |
| | | /** 打开授权用户表弹窗 */ |
| | | const openSelectUser = () => { |
| | | selectRef.value.show(); |
| | | selectRef.value?.show(); |
| | | } |
| | | /** 取消授权按钮操作 */ |
| | | const cancelAuthUser = async (row: UserVO) => { |
| | | await proxy?.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?'); |
| | | await authUserCancel({ userId: row.userId, roleId: queryParams.roleId }); |
| | | getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | await proxy?.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?'); |
| | | await authUserCancel({ userId: row.userId, roleId: queryParams.roleId }); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | } |
| | | /** 批量取消授权按钮操作 */ |
| | | const cancelAuthUserAll = async () => { |
| | | const roleId = queryParams.roleId; |
| | | const uIds = userIds.value.join(","); |
| | | await proxy?.$modal.confirm("是否取消选中用户授权数据项?"); |
| | | await authUserCancelAll({ roleId: roleId, userIds: uIds }); |
| | | getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | const roleId = queryParams.roleId; |
| | | const uIds = userIds.value.join(","); |
| | | await proxy?.$modal.confirm("是否取消选中用户授权数据项?"); |
| | | await authUserCancelAll({ roleId: roleId, userIds: uIds }); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess("取消授权成功"); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |