|
|
|
|
@@ -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();
|
|
|
|
|
|