260623_02_ENH: 엑셀 다운로드를 포함한 1차 개발 완료
This commit is contained in:
@@ -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 <LoadingOverlay force={true} />
|
||||
|
||||
return (
|
||||
@@ -402,17 +417,23 @@ const PerformancePage = () => {
|
||||
</PagePanel>
|
||||
|
||||
<PagePanel>
|
||||
{canEdit && (
|
||||
{!isWrittenReviewer && (
|
||||
<div className="mb-3 flex justify-end gap-2">
|
||||
<Button type="button" onClick={() => showDialog("performanceExcelRegisterDialog")}>
|
||||
<Upload className="h-4 w-4" />
|
||||
사업 등록
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={() => showDialog("assignWrittenExcelDialog")}>
|
||||
서면 평가 배정
|
||||
</Button>
|
||||
{canEdit && (
|
||||
<>
|
||||
<Button type="button" onClick={() => showDialog("performanceExcelRegisterDialog")}>
|
||||
<Upload className="h-4 w-4" />
|
||||
사업 등록
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={() => showDialog("assignWrittenExcelDialog")}>
|
||||
서면 평가 배정
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<ExcelDownloadButton requestExcelExport={downloadPerformance} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={filteredData}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {useAssignUserCountsQuery} from "@/query/assign";
|
||||
import {
|
||||
useDeleteUserMutation,
|
||||
useDownloadUserExcelTemplateMutation,
|
||||
useExportUserMutation,
|
||||
useUpdateUserMutation,
|
||||
useUploadUsersExcelMutation,
|
||||
useUsersQuery,
|
||||
@@ -27,6 +28,7 @@ import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {downloadExcelBuffer} from "@/lib/gwcf/file";
|
||||
import ExcelDownloadButton from "@/components/common/ExcelDownloadButton";
|
||||
|
||||
type UserTab = "monitoring" | "written";
|
||||
type UserFilters = {area: string[]; gender: string[]; genre: string[]; keyword: string};
|
||||
@@ -64,6 +66,7 @@ const UserPage = () => {
|
||||
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 = () => {
|
||||
<Upload className="h-4 w-4" />
|
||||
계정 등록
|
||||
</Button>
|
||||
<ExcelDownloadButton requestExcelExport={downloadUsers} />
|
||||
</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
|
||||
@@ -72,6 +72,28 @@ export const POST = async (
|
||||
return new NextResponse(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "excel-download" && slug.length === 1) {
|
||||
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<ArrayBuffer>(
|
||||
"/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);
|
||||
|
||||
@@ -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<ArrayBuffer>(
|
||||
`/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);
|
||||
|
||||
Reference in New Issue
Block a user