From 5e3ecfc0a65e65fc46e0dbb9a8e6be2c58f7af22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Sun, 3 Dec 2023 15:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.优化对字段权限的处理 --- web/src/utils/columnPermission.ts | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/web/src/utils/columnPermission.ts b/web/src/utils/columnPermission.ts index 6a678fa..42e50ac 100644 --- a/web/src/utils/columnPermission.ts +++ b/web/src/utils/columnPermission.ts @@ -7,3 +7,40 @@ export const columnPermission = (key: string, type: permissionType): boolean => return !!permissions.some((i) => i.field_name === key && i[type]); }; + +/** + * 处理字段权限 + * @param crudOptions + */ +export const handleColumnPermission = async (crudOptions:any)=>{ + const res = await GetPermission(); + const columns = crudOptions.columns; + for(let col in columns){ + if(columns[col].column){ + columns[col].column.show = false + }else{ + columns[col]['column'] = { + show:false + } + } + columns[col].addForm = { + show:false + } + columns[col].editForm = { + show:false + } + for(let item of res.data){ + if(item.field_name === col){ + columns[col].column.show = item['is_query'] + columns[col].addForm = { + show:item['is_create'] + } + columns[col].editForm = { + show:item['is_update'] + } + break; + } + } + } + return columns +}