From d3592ad81b73fec31526e645c46e5eaf0b218f9d Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 23 Jun 2026 11:38:46 +0900 Subject: [PATCH] =?UTF-8?q?260623=5F02=5FENH:=20=EC=97=91=EC=85=80=20?= =?UTF-8?q?=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=EB=A5=BC=20=ED=8F=AC?= =?UTF-8?q?=ED=95=A8=ED=95=9C=201=EC=B0=A8=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/icon-excel.png | Bin 0 -> 8772 bytes src/app/(pages)/(main)/performance/page.tsx | 37 ++++++++++++++---- src/app/(pages)/(main)/user/page.tsx | 16 ++++++++ src/app/api/performance/[[...slug]]/route.ts | 22 +++++++++++ src/app/api/user/[[...slug]]/route.ts | 22 +++++++++++ src/components/common/ExcelDownloadButton.tsx | 29 ++++++++++++++ src/lib/gwcf/performance-status.ts | 2 +- src/query/performance.ts | 11 ++++++ src/query/user.ts | 11 ++++++ 9 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 public/icon-excel.png create mode 100644 src/components/common/ExcelDownloadButton.tsx diff --git a/public/icon-excel.png b/public/icon-excel.png new file mode 100644 index 0000000000000000000000000000000000000000..36a0e076c40a18db9d9503d3af55c8b7a78652d7 GIT binary patch literal 8772 zcmeHscT|&EwC@*`B7>r%3`h&ksEiAE1StkcECZtgv4etu zV?hU{h(eGSjRcVr5S0>2FjADzC6u&#zT#c?{(IND>#ga=lu3}&OW!t z&3U=9rZNOU%Xhi#_!ENU04WD4DS-dJ#=Tnv|KXzkblwgXwrGC_KbD3#?skNr68d-I zgYw|_vPhSGQ4q9(1^>m>lO6;?(7LW&I~@1M`H%IQr5^C?OC~=z+Eh+cQhdClV#9{- zpXjf8d+hh$ep`RHw;}V#4LTb(3|_x_bzNb?r`qiHR=(V<@T6^E3q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lh<9{RL2E(Voz@F*=xQ#~6c^aOYB2qFgH`9$j?Gl4_-L_Y;E!aUR zh%=q6a4=T@`XL}QQ4A9! zg5b`&{|AWXSCVE%1Wn>S&Xsgtvjw{#0H})qj7T3q7{i1wOsoOK{%#94D{*PK7IALX zq$Oy=j;L}qX29(S8o_flN_}yl9S_#`2v?(Aq$C(&CxS^A>EWprrJ&1u|6F)#d_EwC zUc_keWAKh#c4y*JAYtkrMzo0nP2RkNTKpSu@4mdGn$GK*7EjyBaW&k318Ny2Wo9`S z!Q^598@#MRP(4ii42b-@z0Rg##Gdh=iqob_fE`*NAi(D{ zAWG7va4@kIWC*wl!UBnP2Xld2!xD$vP8mny# zCHQS1>+r1hwlXu_@t+ty?6|OEyR$H>#_|n1Rau?nDpU2Us;t{Liq)?BsCJnwdU|Of})R+#jZ+nIC}wwCh*59fjKiPyYwLR#plC literal 0 HcmV?d00001 diff --git a/src/app/(pages)/(main)/performance/page.tsx b/src/app/(pages)/(main)/performance/page.tsx index ec7b62f..b37b7b0 100644 --- a/src/app/(pages)/(main)/performance/page.tsx +++ b/src/app/(pages)/(main)/performance/page.tsx @@ -16,6 +16,7 @@ import {useCodesQuery} from "@/query/code"; import { useDownloadAssignExcelTemplateMutation, useDownloadPerformanceExcelTemplateMutation, + useExportPerformanceMutation, usePerformanceDetailQuery, usePerformanceListQuery, useUpdatePerformanceMutation, @@ -50,6 +51,7 @@ import { getReviewPdfDownloadName, openWrittenReviewWindow, } from "@/lib/gwcf/file"; +import ExcelDownloadButton from "@/components/common/ExcelDownloadButton"; type PerformanceFilters = { businessType: string[]; @@ -88,6 +90,7 @@ const PerformancePage = () => { const writtenAssignUploadMutation = useUploadWrittenAssignExcelMutation(); const performanceTemplateMutation = useDownloadPerformanceExcelTemplateMutation(); const writtenAssignTemplateMutation = useDownloadAssignExcelTemplateMutation(); + const exportMutation = useExportPerformanceMutation(); const reviewPdfMutation = useDownloadReviewPdfMutation(); const reviewOriginalMutation = useDownloadReviewOriginalMutation(); @@ -372,6 +375,18 @@ const PerformancePage = () => { downloadExcelBuffer(buffer, "서면 평가 배정 template.xlsx"); }; + const downloadPerformance = async () => { + const performanceIds = filteredData.map((performance) => performance.id); + + if (performanceIds.length === 0) { + alert("다운로드할 사업 정보가 없습니다."); + return; + } + + const buffer = await exportMutation.mutateAsync({performanceIds}); + downloadExcelBuffer(buffer, "사업 정보.xlsx"); + }; + if(!mounted) return return ( @@ -402,17 +417,23 @@ const PerformancePage = () => { - {canEdit && ( + {!isWrittenReviewer && (
- - + {canEdit && ( + <> + + + + )} +
)} + { const deleteMutation = useDeleteUserMutation(); const uploadMutation = useUploadUsersExcelMutation(userRole); const templateMutation = useDownloadUserExcelTemplateMutation(userRole); + const exportMutation = useExportUserMutation(); const assignCountMap = useMemo(() => new Map(assignCounts.map((item) => [item.assignUser, item.assignCount])), [assignCounts]); @@ -131,6 +134,18 @@ const UserPage = () => { downloadExcelBuffer(buffer, tab === "monitoring" ? "모니터링 요원 template.xlsx" : "서면 평가위원 template.xlsx"); }; + const downloadUsers = async () => { + const userIds = filteredData.map((user) => user.userId); + + if (userIds.length === 0) { + alert("다운로드할 사용자가 없습니다."); + return; + } + + const buffer = await exportMutation.mutateAsync({userRole, userIds}); + downloadExcelBuffer(buffer, tab === "monitoring" ? "모니터링 요원.xlsx" : "서면 평가위원.xlsx"); + }; + const renderEditableCell = (user: UserFull, key: string, fallbackKeys: string[], type: "text" | "select" = "text", options: Code[] = []) => { const draft = draftRef.current; const isEditing = editingId === user.userId && draft; @@ -255,6 +270,7 @@ const UserPage = () => { 계정 등록 + null); + + if (!Array.isArray(body)) { + return NextResponse.json({ message: "Request body must be an array." }, { status: 400 }); + } + + const result = await backApi.post( + "/performance/excel/download", + body, + { expectBinary: true } + ); + + return new NextResponse(result, { + status: 200, + headers: { + "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "Content-Disposition": `attachment; filename="performance.xlsx"`, + }, + }); + } + return NextResponse.json({ message: "Not found" }, { status: 404 }); } catch (error: unknown) { return errorToResponse(error); diff --git a/src/app/api/user/[[...slug]]/route.ts b/src/app/api/user/[[...slug]]/route.ts index 4907652..0a10d08 100644 --- a/src/app/api/user/[[...slug]]/route.ts +++ b/src/app/api/user/[[...slug]]/route.ts @@ -73,6 +73,28 @@ export const POST = async ( }); } + if (action === "excel-download" && slug.length === 2) { + const body = await req.json().catch(() => null); + + if (!Array.isArray(body)) { + return NextResponse.json({ message: "Request body must be an array." }, { status: 400 }); + } + + const result = await backApi.post( + `/user/excel/download/${encodeURIComponent(slug[1])}`, + body, + { expectBinary: true } + ); + + return new NextResponse(result, { + status: 200, + headers: { + "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "Content-Disposition": `attachment; filename="user_${slug[1]}.xlsx"`, + }, + }); + } + return NextResponse.json({ message: "Not found" }, { status: 404 }); } catch (error: unknown) { return errorToResponse(error); diff --git a/src/components/common/ExcelDownloadButton.tsx b/src/components/common/ExcelDownloadButton.tsx new file mode 100644 index 0000000..624b5b7 --- /dev/null +++ b/src/components/common/ExcelDownloadButton.tsx @@ -0,0 +1,29 @@ +"use client"; + +import Image from "next/image"; + +export type ExcelDownloadButtonProps = { + requestExcelExport: () => void; +} + +const ExcelDownloadButton = ({ + requestExcelExport +}: ExcelDownloadButtonProps) => { + + return ( +
+ excel export +
+ + ); +}; + +export default ExcelDownloadButton; \ No newline at end of file diff --git a/src/lib/gwcf/performance-status.ts b/src/lib/gwcf/performance-status.ts index 834308a..6fb7807 100644 --- a/src/lib/gwcf/performance-status.ts +++ b/src/lib/gwcf/performance-status.ts @@ -95,7 +95,7 @@ const getMonitoringTimeline = (visits: PerformanceMonitoringVisit[]): Monitoring export const getMonitoringSlots = (performance: Partial): [MonitoringSlot, MonitoringSlot] => { const confirmedAssigns = (performance.performanceAssignList ?? []) .filter((assign) => assign.assignType === MONITORING_ASSIGN_TYPE && assign.assignConfirm) - .sort((a, b) => a.id - b.id); + .sort((a, b) => a.assignOrder - b.assignOrder || a.id - b.id); const visits = performance.performanceMonitoringVisitMap ?? {}; diff --git a/src/query/performance.ts b/src/query/performance.ts index 1204626..c706580 100644 --- a/src/query/performance.ts +++ b/src/query/performance.ts @@ -88,6 +88,17 @@ export function useDownloadPerformanceExcelTemplateMutation() { }); } +export function useExportPerformanceMutation() { + return useMutation({ + mutationFn: ({performanceIds}: {performanceIds: number[]}) => + nextApi.post( + "/performance/excel-download", + performanceIds.map(String), + { expectBinary: true } + ), + }); +} + export function useDownloadAssignExcelTemplateMutation() { return useMutation({ mutationFn: () => diff --git a/src/query/user.ts b/src/query/user.ts index f76eb94..c8785df 100644 --- a/src/query/user.ts +++ b/src/query/user.ts @@ -38,6 +38,17 @@ export function useUpdateUserMutation() { }); } +export function useExportUserMutation() { + return useMutation({ + mutationFn: ({userRole, userIds}: {userRole: number; userIds: string[]}) => + nextApi.post( + `/user/excel-download/${userRole}`, + userIds, + { expectBinary: true } + ), + }); +} + export function useDeleteUserMutation() { const qc = useQueryClient();