Files
plus-ui/src/api/system/role/index.ts

161 lines
3.0 KiB
TypeScript
Raw Normal View History

2025-08-07 09:12:03 +08:00
import { UserVO } from '@/api/system/user/types';
import { UserQuery } from '@/api/system/user/types';
import { AxiosPromise } from 'axios';
import { RoleQuery, RoleVO, RoleDeptTree } from './types';
import request from '@/utils/request';
export const listRole = (query: RoleQuery): AxiosPromise<RoleVO[]> => {
return request({
url: '/system/role/list',
method: 'get',
params: query
});
};
/**
* roleIds查询角色
* @param roleIds
*/
export const optionSelect = (roleIds: (number | string)[]): AxiosPromise<RoleVO[]> => {
return request({
url: '/system/role/optionselect?roleIds=' + roleIds,
method: 'get'
});
};
/**
*
*/
export const getRole = (roleId: string | number): AxiosPromise<RoleVO> => {
return request({
url: '/system/role/' + roleId,
method: 'get'
});
};
/**
*
*/
export const addRole = (data: any) => {
return request({
url: '/system/role',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateRole = (data: any) => {
return request({
url: '/system/role',
method: 'put',
data: data
});
};
/**
*
*/
export const dataScope = (data: any) => {
return request({
url: '/system/role/dataScope',
method: 'put',
data: data
});
};
/**
*
*/
export const changeRoleStatus = (roleId: string | number, status: string) => {
const data = {
roleId,
status
};
return request({
url: '/system/role/changeStatus',
method: 'put',
data: data
});
};
/**
*
*/
export const delRole = (roleId: Array<string | number> | string | number) => {
return request({
url: '/system/role/' + roleId,
method: 'delete'
});
};
/**
*
*/
export const allocatedUserList = (query: UserQuery): AxiosPromise<UserVO[]> => {
return request({
url: '/system/role/authUser/allocatedList',
method: 'get',
params: query
});
};
/**
*
*/
export const unallocatedUserList = (query: UserQuery): AxiosPromise<UserVO[]> => {
return request({
url: '/system/role/authUser/unallocatedList',
method: 'get',
params: query
});
};
/**
*
*/
export const authUserCancel = (data: any) => {
return request({
url: '/system/role/authUser/cancel',
method: 'put',
data: data
});
};
/**
*
*/
export const authUserCancelAll = (data: any) => {
return request({
url: '/system/role/authUser/cancelAll',
method: 'put',
params: data
});
};
/**
*
*/
export const authUserSelectAll = (data: any) => {
return request({
url: '/system/role/authUser/selectAll',
method: 'put',
params: data
});
};
// 根据角色ID查询部门树结构
export const deptTreeSelect = (roleId: string | number): AxiosPromise<RoleDeptTree> => {
return request({
url: '/system/role/deptTree/' + roleId,
method: 'get'
});
};
export default {
optionSelect,
listRole
};