| | |
| | | import { EnumUserType } from '@/constants'; |
| | | import DialogAuthorizeV2 from './components/dialogAuthorizeV2.vue'; |
| | | import * as roleServices from '@/services/api/role'; |
| | | import { useQueryClient } from '@tanstack/vue-query'; |
| | | |
| | | defineOptions({ |
| | | name: 'RoleManage', |
| | | }); |
| | | |
| | | const operationBtnMap: Record<string, OperationBtnType> = { |
| | | editBtn: { emits: { onClick: (role) => openDialog(role) } }, |
| | | delBtn: { emits: { onClick: (role) => handleDeleteRole(role) }, props: { type: 'danger' } }, |
| | | authorize: { emits: { onClick: (role) => openAuthorizeDialog(role) } }, |
| | | editBtn: { |
| | | emits: { onClick: (role) => openDialog(role) }, |
| | | extraProps: { |
| | | hide: (role: API.GetRolesQueryResultItem) => role.isPublic, |
| | | }, |
| | | }, |
| | | delBtn: { |
| | | emits: { onClick: (role) => handleDeleteRole(role) }, |
| | | props: { type: 'danger' }, |
| | | extraProps: { |
| | | hide: (role: API.GetRolesQueryResultItem) => role.isPublic, |
| | | }, |
| | | }, |
| | | authorize: { |
| | | emits: { onClick: (role) => openAuthorizeDialog(role) }, |
| | | extraProps: { |
| | | hide: (role: API.GetRolesQueryResultItem) => role.isPublic, |
| | | }, |
| | | }, |
| | | // member: { emits: { onClick: (role) => openMemberDialog(role) } }, |
| | | disabledBtn: { |
| | | emits: { onClick: (role) => roleEnableOrForbid(role) }, |
| | | props: { type: 'danger' }, |
| | | extraProps: { |
| | | hide: (row) => row.isDisabled, |
| | | hide: (row: API.GetRolesQueryResultItem) => !(!row.isPublic && !row.isDisabled), |
| | | }, |
| | | }, |
| | | enableBtn: { |
| | | emits: { onClick: (role) => roleEnableOrForbid(role) }, |
| | | extraProps: { |
| | | hide: (row) => !row.isDisabled, |
| | | hide: (row: API.GetRolesQueryResultItem) => !(row.isDisabled && !row.isPublic), |
| | | }, |
| | | }, |
| | | }; |
| | |
| | | }, |
| | | }); |
| | | |
| | | const queryClient = useQueryClient(); |
| | | |
| | | async function handleAddOrEdit() { |
| | | try { |
| | | const isEdit = editForm.id; |
| | |
| | | if (res) { |
| | | Message.successMessage('操作成功'); |
| | | getList(isEdit ? paginationState.pageIndex : 1); |
| | | queryClient.invalidateQueries(['userServices/getUserInfoRoles']); |
| | | } |
| | | } catch (error) {} |
| | | } |
| | |
| | | if (res) { |
| | | Message.successMessage('操作成功'); |
| | | getList(paginationState.pageIndex); |
| | | queryClient.invalidateQueries(['userServices/getUserInfoRoles']); |
| | | } |
| | | } catch (error) {} |
| | | } |
| | |
| | | if (res) { |
| | | Message.successMessage('操作成功'); |
| | | getList(paginationState.pageIndex); |
| | | queryClient.invalidateQueries(['userServices/getUserInfoRoles']); |
| | | return !!res; |
| | | } |
| | | } catch (error) {} |