260625_08_ENH: 서면 평가원 화면에서 모니터링은 1개로 합치고 그에따른 상태값 처리 및 zip 다운로드 적용
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
useUploadPerformanceExcelMutation,
|
||||
} from "@/query/performance";
|
||||
import {useUploadWrittenAssignExcelMutation} from "@/query/assign";
|
||||
import {useDownloadReviewOriginalMutation, useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {useDownloadReviewOriginalByPerformanceMutation, useDownloadReviewOriginalMutation, useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {filterPerformance, getCodeLabel, isInternalRole, isWrittenReviewerRole} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
@@ -102,6 +102,11 @@ const monitoringAddOptions: Code[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const getPerformanceGroupKey = (performanceId: number) => {
|
||||
const id = String(performanceId);
|
||||
return id.length > 2 ? id.slice(0, -2) : id;
|
||||
};
|
||||
|
||||
const PerformancePage = () => {
|
||||
const mounted = useMounted();
|
||||
const {auth} = useAuth();
|
||||
@@ -121,6 +126,7 @@ const PerformancePage = () => {
|
||||
const exportMutation = useExportPerformanceMutation();
|
||||
const reviewPdfMutation = useDownloadReviewPdfMutation();
|
||||
const reviewOriginalMutation = useDownloadReviewOriginalMutation();
|
||||
const reviewOriginalByPerformanceMutation = useDownloadReviewOriginalByPerformanceMutation();
|
||||
|
||||
const [filters, setFilters] = useState<PerformanceFilters>({
|
||||
businessType: [],
|
||||
@@ -267,6 +273,16 @@ const PerformancePage = () => {
|
||||
downloadBlob(buffer, getReviewOriginalDownloadName(performanceId, review.reviewType, review.uploadFileName));
|
||||
};
|
||||
|
||||
const downloadMonitoringReviews = async (performanceId: number) => {
|
||||
const reviewType = 1;
|
||||
try {
|
||||
const buffer = await reviewOriginalByPerformanceMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, getReviewOriginalDownloadName(performanceId, reviewType));
|
||||
} catch {
|
||||
alert("다운로드할 모니터링 리뷰 파일을 찾을 수 없습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
const openWrittenReviewLink = (performanceId: number, userId?: string, complete = false) => {
|
||||
openWrittenReviewWindow(performanceId, userId, complete);
|
||||
};
|
||||
@@ -347,6 +363,39 @@ const PerformancePage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderWrittenReviewerMonitoringStatus = (performance: PerformanceFull) => {
|
||||
const groupKey = getPerformanceGroupKey(performance.id);
|
||||
const monitoringRows = data
|
||||
.filter((item) => getPerformanceGroupKey(item.id) === groupKey)
|
||||
.flatMap((item) => ([0, 1] as const).map((index) => getMonitoringDisplayRow(item, index)));
|
||||
|
||||
const completeCount = monitoringRows.filter((item) => isReviewComplete(item.review)).length;
|
||||
const totalCount = monitoringRows.length;
|
||||
const display = completeCount === 0
|
||||
? {label: "미완료", variant: "pending" as const}
|
||||
: completeCount === totalCount
|
||||
? {label: "완료", variant: "done" as const}
|
||||
: {label: "일부 완료", variant: "inprogress" as const};
|
||||
const onClick = completeCount > 0 ? () => downloadMonitoringReviews(performance.id) : undefined;
|
||||
|
||||
return (
|
||||
<div className="flex justify-center text-xs">
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={onClick}
|
||||
tooltip={(
|
||||
<div className="space-y-1">
|
||||
<div>완료: {completeCount}</div>
|
||||
<div>전체: {totalCount}</div>
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{accessorKey: "no", header: PERFORMANCE_FIELD_LABELS.no,
|
||||
accessorFn: (row) => row.performanceDetail["performanceNo"] ?? "",
|
||||
@@ -440,7 +489,7 @@ const PerformancePage = () => {
|
||||
{id: "monitoring1", header: "모니터링 1", cell: ({row}) => renderMonitoringStatus(row.original, 0), size:40,},
|
||||
{id: "monitoring2", header: "모니터링 2", cell: ({row}) => renderMonitoringStatus(row.original, 1), size:40,},
|
||||
] : [
|
||||
{id: "monitoring", header: "모니터링", cell: ({row}) => renderMonitoringStatus(row.original, 0), size:40,}
|
||||
{id: "monitoring", header: "모니터링", cell: ({row}) => renderWrittenReviewerMonitoringStatus(row.original), size:40,}
|
||||
]) as DataTableColumn<PerformanceFull>[],
|
||||
{
|
||||
id: "writtenReview",
|
||||
@@ -461,7 +510,7 @@ const PerformancePage = () => {
|
||||
},
|
||||
size:40,
|
||||
},
|
||||
], [codes, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
], [codes, data, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
|
||||
const downloadPerformanceTemplate = async () => {
|
||||
const buffer = await performanceTemplateMutation.mutateAsync();
|
||||
|
||||
@@ -73,6 +73,21 @@ export const GET = async (
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "download" && second && third && slug.length === 3) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}`,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Content-Disposition": `attachment; filename="${reviewFileName("review-original", second, third)}"`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "pdf" && second && third && fourth && slug.length === 4) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/pdf/${encodeURIComponent(second)}/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,
|
||||
|
||||
Reference in New Issue
Block a user