refactor(所有页面): ♻️ 所有页面的按钮权限配置
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as api from './api';
|
||||
import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
|
||||
import { dictionary } from '/@/utils/dictionary';
|
||||
import { nextTick, ref } from 'vue';
|
||||
import {inject, nextTick, ref} from 'vue';
|
||||
import { successMessage } from '/@/utils/message';
|
||||
|
||||
export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
@@ -18,6 +18,11 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp
|
||||
const addRequest = async ({ form }: AddReq) => {
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
//权限判定
|
||||
const hasPermissions = inject("$hasPermissions")
|
||||
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
@@ -27,6 +32,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp
|
||||
delRequest,
|
||||
},
|
||||
rowHandle: {
|
||||
fixed:'right',
|
||||
width: 200,
|
||||
buttons: {
|
||||
view: {
|
||||
@@ -35,14 +41,17 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp
|
||||
edit: {
|
||||
iconRight: 'Edit',
|
||||
type: 'text',
|
||||
show:hasPermissions('dictonary:Update')
|
||||
},
|
||||
remove: {
|
||||
iconRight: 'Delete',
|
||||
type: 'text',
|
||||
show:hasPermissions('dictonary:Delete')
|
||||
},
|
||||
custom: {
|
||||
text: '字典配置',
|
||||
type: 'text',
|
||||
show:hasPermissions('dictonary:Update'),
|
||||
tooltip: {
|
||||
placement: 'top',
|
||||
content: '字典配置',
|
||||
|
||||
Reference in New Issue
Block a user