From 82d7193dcb8e43ddb7c7bf19a54963de79e9fb99 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 09:45:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E2=99=BB=EF=B8=8F=20=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E8=A1=A8=E6=A0=BC=E5=88=97=E5=AE=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/utils/service.ts | 6 +- web/src/views/system/areas/crud.tsx | 18 +++- web/src/views/system/dictionary/crud.tsx | 12 ++- web/src/views/system/fileList/crud.tsx | 10 +- web/src/views/system/log/loginLog/crud.tsx | 61 +++++++++-- .../views/system/log/operationLog/crud.tsx | 28 +++++ web/src/views/system/messageCenter/crud.tsx | 8 +- web/src/views/system/role/crud.tsx | 10 +- web/src/views/system/rolePermission/index.vue | 101 ++++++++++-------- web/src/views/system/whiteList/crud.tsx | 7 ++ 10 files changed, 190 insertions(+), 71 deletions(-) diff --git a/web/src/utils/service.ts b/web/src/utils/service.ts index 2385c48..c3b4644 100644 --- a/web/src/utils/service.ts +++ b/web/src/utils/service.ts @@ -62,10 +62,10 @@ function createService() { // 有 code 代表这是一个后端接口 可以进行进一步的判断 switch (code) { case 400: - Local.clear(); - Session.clear(); + // Local.clear(); + // Session.clear(); errorCreate(`${dataAxios.msg}: ${response.config.url}`); - window.location.reload(); + // window.location.reload(); break; case 401: Local.clear(); diff --git a/web/src/views/system/areas/crud.tsx b/web/src/views/system/areas/crud.tsx index 286eea5..73af3ea 100644 --- a/web/src/views/system/areas/crud.tsx +++ b/web/src/views/system/areas/crud.tsx @@ -105,8 +105,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, treeNode: true, - width: 160, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -123,6 +125,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, type: 'input', + column:{ + minWidth: 90, + }, form: { rules: [ // 表单校验规则 @@ -139,6 +144,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -155,6 +163,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: false, rules: [ @@ -168,6 +179,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, initials: { title: '首字母', + column:{ + minWidth: 100, + }, form: { rules: [ // 表单校验规则 @@ -184,9 +198,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { show: true, }, - width: 90, type: 'dict-radio', column: { + minWidth:90, component: { name: 'fs-dict-switch', activeText: '', diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 4ec048b..53ec8b7 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -111,6 +111,9 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -135,6 +138,9 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -155,12 +161,12 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, status: { title: '状态', - width: 90, search: { show: true, }, type: 'dict-radio', column: { + minWidth: 90, component: { name: 'fs-dict-switch', activeText: '', @@ -181,8 +187,10 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, sort: { title: '排序', - width: 90, type: 'number', + column:{ + minWidth: 80, + }, form: { value: 1, }, diff --git a/web/src/views/system/fileList/crud.tsx b/web/src/views/system/fileList/crud.tsx index 448d322..31a7ec2 100644 --- a/web/src/views/system/fileList/crud.tsx +++ b/web/src/views/system/fileList/crud.tsx @@ -94,6 +94,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入文件名称', @@ -106,13 +109,18 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: true, }, + column:{ + minWidth: 200, + }, }, md5sum: { title: '文件MD5', - width: 200, search: { disabled: true, }, + column:{ + minWidth: 120, + }, form: { disabled: false, }, diff --git a/web/src/views/system/log/loginLog/crud.tsx b/web/src/views/system/log/loginLog/crud.tsx index 4de311a..e8a50be 100644 --- a/web/src/views/system/log/loginLog/crud.tsx +++ b/web/src/views/system/log/loginLog/crud.tsx @@ -31,6 +31,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, rowHandle: { + fixed:'right', width: 100, buttons: { view: { @@ -89,8 +90,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, - width: 140, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, component: { @@ -103,8 +106,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, - width: 130, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, component: { @@ -118,8 +123,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, disabled: true, - width: 180, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入运营商', @@ -128,8 +135,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, continent: { title: '大州', - width: 80, type: 'input', + column:{ + minWidth: 90, + }, form: { disabled: true, component: { @@ -140,8 +149,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, country: { title: '国家', - width: 80, type: 'input', + column:{ + minWidth: 90, + }, form: { component: { placeholder: '请输入国家', @@ -151,8 +162,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, province: { title: '省份', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入省份', @@ -162,8 +175,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, city: { title: '城市', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入城市', @@ -174,8 +189,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp district: { title: '县区', key: '', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入县区', @@ -186,6 +203,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp area_code: { title: '区域代码', type: 'input', + column:{ + minWidth: 90, + }, form: { component: { placeholder: '请输入区域代码', @@ -195,8 +215,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, country_english: { title: '英文全称', - width: 120, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入英文全称', @@ -207,6 +229,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp country_code: { title: '简称', type: 'input', + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入简称', @@ -218,6 +243,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: '经度', type: 'input', disabled: true, + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入经度', @@ -229,6 +257,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: '纬度', type: 'input', disabled: true, + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入纬度', @@ -248,6 +279,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp { label: '微信扫码登录', value: 2 }, ], }), + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请选择登录类型', @@ -257,6 +291,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp os: { title: '操作系统', type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入操作系统', @@ -266,6 +303,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp browser: { title: '浏览器名', type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入浏览器名', @@ -276,6 +316,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: 'agent信息', disabled: true, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入agent信息', diff --git a/web/src/views/system/log/operationLog/crud.tsx b/web/src/views/system/log/operationLog/crud.tsx index 4d1ace9..cef5ebb 100644 --- a/web/src/views/system/log/operationLog/crud.tsx +++ b/web/src/views/system/log/operationLog/crud.tsx @@ -31,6 +31,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, rowHandle: { + fixed:'right', width: 100, buttons: { view: { @@ -90,6 +91,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -103,6 +107,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 200, + }, form: { disabled: true, component: { @@ -141,6 +148,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -164,6 +174,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -175,6 +188,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp request_browser: { title: '请求浏览器', type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, }, @@ -186,6 +202,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, }, @@ -198,6 +217,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, }, @@ -209,6 +231,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 150, + }, form: { disabled: true, }, @@ -216,6 +241,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, creator_name: { title: '操作人', + column:{ + minWidth: 100, + }, form: { disabled: true, }, diff --git a/web/src/views/system/messageCenter/crud.tsx b/web/src/views/system/messageCenter/crud.tsx index 0ddd727..69d3d18 100644 --- a/web/src/views/system/messageCenter/crud.tsx +++ b/web/src/views/system/messageCenter/crud.tsx @@ -73,6 +73,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx show: true, }, type: ['text', 'colspan'], + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -103,7 +106,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx target_type: { title: '目标类型', type: ['dict-radio', 'colspan'], - width: 120, + column:{ + minWidth: 120, + }, dict: dict({ data: [ { value: 0, label: '按用户' }, @@ -134,7 +139,6 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx search: { disabled: true, }, - width: 130, form: { component: { name: shallowRef(tableSelector), diff --git a/web/src/views/system/role/crud.tsx b/web/src/views/system/role/crud.tsx index c2f9072..0fad942 100644 --- a/web/src/views/system/role/crud.tsx +++ b/web/src/views/system/role/crud.tsx @@ -81,13 +81,6 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru align: 'center', width: '70px', columnSetDisabled: true, //禁止在列设置中选择 - formatter: (context) => { - //计算序号,你可以自定义计算规则,此处为翻页累加 - let index = context.index ?? 1; - let pagination = crudExpose.crudBinding.value.pagination; - // @ts-ignore - return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; - }, }, }, id: { @@ -108,7 +101,7 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru form: { rules: [{ required: true, message: '角色名称必填' }], component: { - placeholder: '输入角色名称搜索', + placeholder: '请输入角色名称', }, }, }, @@ -170,6 +163,7 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru search: { show: true }, type: 'dict-radio', column: { + width:100, component: { name: 'fs-dict-switch', activeText: '', diff --git a/web/src/views/system/rolePermission/index.vue b/web/src/views/system/rolePermission/index.vue index c217360..fe5e9ba 100644 --- a/web/src/views/system/rolePermission/index.vue +++ b/web/src/views/system/rolePermission/index.vue @@ -7,18 +7,24 @@ :before-close="handleClose" > +
- @@ -35,11 +41,18 @@ - +
@@ -49,12 +62,12 @@ @@ -139,8 +152,8 @@ import {ref, defineExpose, reactive, toRefs} from 'vue' import {ElMessageBox} from 'element-plus' import * as api from './api' -import type {FormRules,FormInstance} from 'element-plus' -import { ElMessage } from 'element-plus' +import type {FormRules, FormInstance} from 'element-plus' +import {ElMessage} from 'element-plus' import XEUtils from 'xe-utils' //抽屉是否显示 const drawer = ref(false) @@ -190,7 +203,7 @@ let buttonOptions = ref<[]>() let editedMenuInfo = ref() //菜单节点点击事件 const menuNodeClick = (node: any, obj: any) => { - isBtnPermissionShow.value = !node.is_catalog + isBtnPermissionShow.value = !node.is_catalog if (!node.is_catalog) { buttonOptions.value = [] editedMenuInfo.value = node @@ -198,7 +211,7 @@ const menuNodeClick = (node: any, obj: any) => { const {data} = res buttonOptions.value = data }) - api.getObj({menu: node.id,role:editedRoleInfo.value.id}).then((res:any)=>{ + api.getObj({menu: node.id, role: editedRoleInfo.value.id}).then((res: any) => { const {data} = res buttonPermissionData.value = data }) @@ -211,7 +224,7 @@ const menuTree = ref() //是否显示新增表单 const dialogFormVisible = ref(false) //部门树 -const deptTree=ref() +const deptTree = ref() //自定义部门数据 const deptOptions = ref() //选中的部门数据 @@ -220,7 +233,7 @@ const deptCheckedKeys = [] const buttonForm = reactive({ menu_button: null, role: null, - menu:null, + menu: null, data_range: null, dept: [] }) @@ -256,20 +269,20 @@ const onChangeButton = (val: any) => { }) //获取权限部门值 api.GetDataScopeDept({menu_button: val}).then((res: any) => { - deptOptions.value = XEUtils.toArrayTree(res.data,{ parentKey: 'parent', strict: false }) + deptOptions.value = XEUtils.toArrayTree(res.data, {parentKey: 'parent', strict: false}) }) } //过滤按钮名称 -const formatMenuBtn = (val:any)=>{ - let obj:any = buttonOptions.value?.find((item:any)=>{ - return item.id===val +const formatMenuBtn = (val: any) => { + let obj: any = buttonOptions.value?.find((item: any) => { + return item.id === val }) - return obj?obj.name:null + return obj ? obj.name : null } //过滤权限范围 -const formatDataRange = (val:any)=>{ - let obj:any = [ +const formatDataRange = (val: any) => { + let obj: any = [ { "value": 0, "label": '仅本人数据权限' @@ -290,17 +303,17 @@ const formatDataRange = (val:any)=>{ "value": 4, "label": '自定义数据权限' } - ].find((item:any)=>{ - return item.value===val + ].find((item: any) => { + return item.value === val }) - return obj?obj.label:null + return obj ? obj.label : null } //保存按钮表单 const onSaveButtonForm = async () => { - const {id:roleId} = editedRoleInfo.value - const {id:menuId} = editedMenuInfo.value - const form:any = Object.assign({},buttonForm) + const {id: roleId} = editedRoleInfo.value + const {id: menuId} = editedMenuInfo.value + const form: any = Object.assign({}, buttonForm) form.role = roleId form.menu = menuId //选中的部门 @@ -309,7 +322,7 @@ const onSaveButtonForm = async () => { if (!buttonFormRef.value) return await buttonFormRef.value.validate((valid, fields) => { if (valid) { - api.CreatePermission(form).then((res:any)=>{ + api.CreatePermission(form).then((res: any) => { buttonPermissionData.value.push(form) dialogFormVisible.value = false ElMessage({ @@ -320,7 +333,7 @@ const onSaveButtonForm = async () => { } else { ElMessage({ type: 'error', - title:'提交错误', + title: '提交错误', message: 'F12控制台看详情', }) console.log('提交错误', fields) @@ -329,8 +342,8 @@ const onSaveButtonForm = async () => { } //删除按钮权限 -const onDeleteBtn = (scope:any)=>{ - const {row,$index} = scope +const onDeleteBtn = (scope: any) => { + const {row, $index} = scope ElMessageBox.confirm( '您是否要删除数据?', '温馨提示', @@ -339,15 +352,15 @@ const onDeleteBtn = (scope:any)=>{ cancelButtonText: '取消', type: 'warning', } - ).then(() => { - api.DeletePermission({id:row.id}).then(res=>{ - buttonPermissionData.value.splice($index,1) - ElMessage({ - type: 'success', - message: res.msg, - }) - }) + ).then(() => { + api.DeletePermission({id: row.id}).then(res => { + buttonPermissionData.value.splice($index, 1) + ElMessage({ + type: 'success', + message: res.msg, }) + }) + }) .catch(() => { ElMessage({ type: 'info', @@ -373,12 +386,12 @@ const onSaveAuth = () => { //合并的菜单数据 const menuIdList = [...checkedList, ...halfCheckedList] // console.log(menuIdList) - const { id:roleId } = editedRoleInfo.value + const {id: roleId} = editedRoleInfo.value const data = { - role:roleId, - menu:menuIdList + role: roleId, + menu: menuIdList } - api.SaveMenuPermission(data).then((res:any)=>{ + api.SaveMenuPermission(data).then((res: any) => { ElMessage({ message: res.msg, type: 'success', diff --git a/web/src/views/system/whiteList/crud.tsx b/web/src/views/system/whiteList/crud.tsx index 41b2d3f..0b3fd67 100644 --- a/web/src/views/system/whiteList/crud.tsx +++ b/web/src/views/system/whiteList/crud.tsx @@ -124,6 +124,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, ], }), + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -162,6 +165,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }); }, }), + column:{ + minWidth: 200, + }, form: { rules: [ // 表单校验规则 @@ -199,6 +205,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, type: 'dict-radio', column: { + minWidth:120, component: { name: 'fs-dict-switch', activeText: '', From 08b56ee663c399aa26aa03e3d039258453eb5edd 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 2/2] =?UTF-8?q?refactor(=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E2=99=BB=EF=B8=8F=20=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90=E9=85=8D?= =?UTF-8?q?=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") }, }, },