功能变化: 按钮权限管控完成
This commit is contained in:
@@ -72,7 +72,7 @@ class MenuButtonViewSet(CustomModelViewSet):
|
||||
is_superuser = request.user.is_superuser
|
||||
is_admin = request.user.role.values_list('admin', flat=True)
|
||||
if is_superuser or True in is_admin:
|
||||
queryset = MenuButton.objects.values_list('menu_button__value',flat=True)
|
||||
queryset = MenuButton.objects.values_list('value',flat=True)
|
||||
else:
|
||||
role_id = request.user.role.values_list('id', flat=True)
|
||||
queryset = RoleMenuButtonPermission.objects.filter(role__in=role_id).values_list('menu_button__value',flat=True).distinct()
|
||||
|
||||
@@ -3,3 +3,6 @@ ENV = 'development'
|
||||
|
||||
# 本地环境接口地址
|
||||
VITE_API_URL = 'http://127.0.0.1:8000/'
|
||||
|
||||
# 是否启用按钮权限
|
||||
VITE_PM_ENABLED = true
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useRoutesList } from '/@/stores/routesList';
|
||||
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
||||
import { useMenuApi } from '/@/api/menu/index';
|
||||
import { handleMenu } from '../utils/menu';
|
||||
import {BtnPermissionStore} from "/@/plugin/permission/store.permission";
|
||||
|
||||
const menuApi = useMenuApi();
|
||||
|
||||
@@ -102,6 +103,8 @@ export async function setAddRoute() {
|
||||
* @returns 返回后端路由菜单数据
|
||||
*/
|
||||
export function getBackEndControlRoutes() {
|
||||
//获取所有的按钮权限
|
||||
BtnPermissionStore().getBtnPermissionStore();
|
||||
return menuApi.getSystemMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ import { NextLoading } from '/@/utils/loading';
|
||||
import * as loginApi from '/@/views/system/login/api';
|
||||
import { useUserInfo } from '/@/stores/userInfo';
|
||||
import { DictionaryStore } from '/@/stores/dictionary';
|
||||
import {BtnPermissionStore} from "/@/plugin/permission/store.permission";
|
||||
import { Md5 } from 'ts-md5';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -139,8 +140,8 @@ export default defineComponent({
|
||||
const loginSuccess = () => {
|
||||
//登录成功获取用户信息,获取系统字典数据
|
||||
getUserInfo();
|
||||
//获取所有字典
|
||||
DictionaryStore().getSystemDictionarys();
|
||||
|
||||
// 初始化登录成功时间问候语
|
||||
let currentTimeInfo = currentTime.value;
|
||||
// 登录成功,跳到转首页
|
||||
|
||||
@@ -3,12 +3,14 @@ import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, } fr
|
||||
import { dictionary } from "/@/utils/dictionary";
|
||||
import iconSelector from '/@/components/iconSelector/index.vue'
|
||||
import {useCompute} from '@fast-crud/fast-crud'
|
||||
import {inject} from 'vue'
|
||||
const {compute} = useCompute()
|
||||
interface CreateCrudOptionsTypes {
|
||||
crudOptions: CrudOptions;
|
||||
}
|
||||
|
||||
export const createCrudOptions = function ({ crudExpose,menuButtonRef }: { crudExpose: CrudExpose,menuButtonRef:any }): CreateCrudOptionsTypes {
|
||||
const hasPermissions = inject('$hasPermissions')
|
||||
//验证路由地址
|
||||
const validateWebPath = (rule: string, value: string, callback: Function) => {
|
||||
const isLink = crudExpose.getFormData().is_link
|
||||
@@ -67,6 +69,13 @@ export const createCrudOptions = function ({ crudExpose,menuButtonRef }: { crudE
|
||||
load:loadContentMethod,
|
||||
treeProps:{children: 'children', hasChildren: 'hasChild'}
|
||||
},
|
||||
actionbar: {
|
||||
buttons: {
|
||||
add: {
|
||||
show: hasPermissions('Menu:Create')
|
||||
}
|
||||
}
|
||||
},
|
||||
rowHandle: {
|
||||
buttons: {
|
||||
custom: {
|
||||
@@ -77,10 +86,11 @@ export const createCrudOptions = function ({ crudExpose,menuButtonRef }: { crudE
|
||||
content: "按钮配置"
|
||||
},
|
||||
show:compute(({row}:any)=>{
|
||||
if (row.web_path && !row.is_link) {
|
||||
return true
|
||||
if (row.web_path && !row.is_link) {
|
||||
return true && hasPermissions()
|
||||
}
|
||||
return false
|
||||
|
||||
}),
|
||||
click:(context:any):void => {
|
||||
const {row} = context
|
||||
|
||||
Reference in New Issue
Block a user