From 61ae6e8eb3a9cbf6960ff9edbc11c834fc77da3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Mon, 10 Apr 2023 16:45:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=89=80=E6=9C=89=E9=A1=B5=E9=9D=A2):?= =?UTF-8?q?=20=E2=99=BB=EF=B8=8F=20=E6=89=80=E6=9C=89=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/dictionary/crud.tsx | 11 ++++++++++- web/src/views/system/messageCenter/crud.tsx | 16 +++++++++++++++- web/src/views/system/role/crud.tsx | 9 ++++++++- web/src/views/system/user/crud.tsx | 7 +++++++ web/src/views/system/whiteList/crud.tsx | 9 ++++++++- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 53ec8b7..6cd9ac6 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -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: '字典配置', diff --git a/web/src/views/system/messageCenter/crud.tsx b/web/src/views/system/messageCenter/crud.tsx index 69d3d18..aebef1e 100644 --- a/web/src/views/system/messageCenter/crud.tsx +++ b/web/src/views/system/messageCenter/crud.tsx @@ -1,7 +1,7 @@ import * as api from './api'; import { dict, useCompute, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; import tableSelector from '/@/components/tableSelector/index.vue'; -import { shallowRef, computed, ref } from 'vue'; +import {shallowRef, computed, ref, inject} from 'vue'; import manyToMany from '/@/components/manyToMany/index.vue'; const { compute } = useCompute(); @@ -36,6 +36,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx return tabActivted.value === 'receive'; }); + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -45,11 +48,17 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx delRequest, }, rowHandle: { + fixed:'right', + width:150, buttons: { edit: { show: false, }, view: { + text:"查看", + type:'text', + iconRight:'View', + show:hasPermissions("messageCenter:Search"), click({ index, row }) { crudExpose.openView({ index, row }); if (tabActivted.value === 'receive') { @@ -58,6 +67,11 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx } }, }, + remove: { + iconRight: 'Delete', + type: 'text', + show:hasPermissions('messageCenter:Delete') + }, }, }, columns: { diff --git a/web/src/views/system/role/crud.tsx b/web/src/views/system/role/crud.tsx index 0fad942..eda0af3 100644 --- a/web/src/views/system/role/crud.tsx +++ b/web/src/views/system/role/crud.tsx @@ -3,6 +3,7 @@ import _ from 'lodash-es'; import * as api from './api'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '../../../utils/message'; +import {inject} from "vue"; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -23,6 +24,9 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru return await api.AddObj(form); }; + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -42,17 +46,20 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions('role:Update') }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions('role:Delete') }, custom: { text: '权限配置', type: 'text', + show:hasPermissions('role:Update'), tooltip: { placement: 'top', - content: '删除', + content: '权限配置', }, click: (context: any): void => { const { row } = context; diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index f86143f..34b4e36 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -3,6 +3,7 @@ import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, comp import { request } from '/@/utils/service'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '/@/utils/message'; +import {inject} from "vue"; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -21,6 +22,10 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -40,10 +45,12 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions('user:Update') }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions('user:Delete') }, }, }, diff --git a/web/src/views/system/whiteList/crud.tsx b/web/src/views/system/whiteList/crud.tsx index 0b3fd67..e47280f 100644 --- a/web/src/views/system/whiteList/crud.tsx +++ b/web/src/views/system/whiteList/crud.tsx @@ -3,6 +3,7 @@ import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOption import { request } from '/@/utils/service'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '/@/utils/message'; +import {inject} from "vue"; export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery) => { @@ -18,6 +19,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -29,7 +34,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp rowHandle: { //固定右侧 fixed: 'right', - width: 200, + width: 150, buttons: { view: { show: false, @@ -37,10 +42,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions("api_white_list:Update") }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions("api_white_list:Delete") }, }, },