From 59a9680200198956dc7a192602e8b940e61e977d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A7=80=EC=B2=A0?= Date: Thu, 7 Aug 2025 13:07:40 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B6=8C=ED=95=9C=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=9D=BC=EA=B4=84=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=EB=90=98=EA=B2=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group-menu-authority-table-columns.tsx | 104 +++++++++++++++++- .../pages/groups/ui/menu-authority-dialog.tsx | 4 +- 2 files changed, 101 insertions(+), 7 deletions(-) diff --git a/apps/cs/src/pages/groups/model/group-menu-authority-table-columns.tsx b/apps/cs/src/pages/groups/model/group-menu-authority-table-columns.tsx index 0a56a6701..3e26e1106 100644 --- a/apps/cs/src/pages/groups/model/group-menu-authority-table-columns.tsx +++ b/apps/cs/src/pages/groups/model/group-menu-authority-table-columns.tsx @@ -11,6 +11,7 @@ export const createColumns = ( form: UseFormReturn, ): ColumnDef[] => { const getCurrentRow = (i: number) => form.watch("menuAuthority")[i]; + const menuAuthorityData = form.watch("menuAuthority"); const handleCheckedChange = (i: number, key: keyof MenuAuthorityPayload) => (checked: boolean) => { @@ -20,6 +21,19 @@ export const createColumns = ( form.setValue(`menuAuthority.${i}.${key}`, checked ? "Y" : "N"); }; + const handleHeaderCheckedChange = (key: keyof MenuAuthorityPayload) => (checked: boolean) => { + menuAuthorityData.forEach((_, index) => { + if (getCurrentRow(index)?.mode === "R") { + form.setValue(`menuAuthority.${index}.mode`, "U"); + } + form.setValue(`menuAuthority.${index}.${key}`, checked ? "Y" : "N"); + }); + }; + + const isAllChecked = (key: keyof MenuAuthorityPayload) => { + return menuAuthorityData.every((item) => item?.[key] === "Y"); + }; + return [ { accessorKey: "menuNm", @@ -27,7 +41,41 @@ export const createColumns = ( }, { accessorKey: "mngAuthrtYn", - header: "관리권한", + header: () => ( +
+ 관리권한 + { + if (checked) { + // 관리권한 체크시 모든 권한 체크 + menuAuthorityData.forEach((_, index) => { + if (getCurrentRow(index)?.mode === "R") { + form.setValue(`menuAuthority.${index}.mode`, "U"); + } + form.setValue(`menuAuthority.${index}.regAuthrtYn`, "Y"); + form.setValue(`menuAuthority.${index}.mdfcnAuthrtYn`, "Y"); + form.setValue(`menuAuthority.${index}.delAuthrtYn`, "Y"); + form.setValue(`menuAuthority.${index}.inqAuthrtYn`, "Y"); + form.setValue(`menuAuthority.${index}.mngAuthrtYn`, "Y"); + }); + } else { + // 관리권한 해제시 모든 권한 해제 + menuAuthorityData.forEach((_, index) => { + if (getCurrentRow(index)?.mode === "R") { + form.setValue(`menuAuthority.${index}.mode`, "U"); + } + form.setValue(`menuAuthority.${index}.regAuthrtYn`, "N"); + form.setValue(`menuAuthority.${index}.mdfcnAuthrtYn`, "N"); + form.setValue(`menuAuthority.${index}.delAuthrtYn`, "N"); + form.setValue(`menuAuthority.${index}.inqAuthrtYn`, "N"); + form.setValue(`menuAuthority.${index}.mngAuthrtYn`, "N"); + }); + } + }} + /> +
+ ), cell: ({ row }) => { return ( ( +
+ 등록권한 + { + if (checked) { + // 등록권한 체크시 조회권한도 체크 + menuAuthorityData.forEach((_, index) => { + if (getCurrentRow(index)?.mode === "R") { + form.setValue(`menuAuthority.${index}.mode`, "U"); + } + form.setValue(`menuAuthority.${index}.inqAuthrtYn`, "Y"); + form.setValue(`menuAuthority.${index}.regAuthrtYn`, "Y"); + }); + } else { + // 등록권한 해제시 해당 권한만 해제 + handleHeaderCheckedChange("regAuthrtYn")(false); + } + }} + /> +
+ ), cell: ({ row }) => { return ( ( +
+ 수정권한 + +
+ ), cell: ({ row }) => { return ( ( +
+ 삭제권한 + +
+ ), cell: ({ row }) => { return ( ( +
+ 조회권한 + +
+ ), cell: ({ row }) => { return ( MenuAuthorityApi.getGroupMenuAuthorityList({ groupId }), + queryFn: () => MenuAuthorityApi.getGroupMenuAuthorityList({ groupId, useYn: "Y" }), enabled: open && !!groupId, }); @@ -82,7 +82,7 @@ function MenuAuthorityDialog({ groupId }: MenuAuthorityDialogProps) { 메뉴권한 - + 그룹별 메뉴 권한