그리드 정렬기능

This commit is contained in:
2026-08-26 16:25:29 +09:00
parent ccfbe6ae32
commit e0cdba00be
61 changed files with 1777 additions and 590 deletions
@@ -19,11 +19,12 @@ import {
import {
STANDARD_ROW_NUMBER_HEADER,
StandardDataTable,
StandardTableSortHeader,
getStandardRowNumber,
type UiTableSort,
} from "@common/business_components";
import {
getCoreRowModel,
getPaginationRowModel,
useReactTable,
type ColumnDef,
type PaginationState,
@@ -40,20 +41,23 @@ import type {
import { ExmnStatusDetailPanel } from "./ExmnStatusDetailPanel";
import { EXMN_TABLE_HEADER_CLASS } from "./ExmnStandardDataTable";
// 서버 호환을 위해 전체 후보를 한 번에 받고 공통 표에서 10건씩 페이지 표시한다.
const BUSINESS_LIST_SCROLL_FETCH_SIZE = 1000;
const BUSINESS_LIST_PAGE_SIZE = 10;
const BUSINESS_TABLE_HEAD = [
{ id: "rowNumber", title: STANDARD_ROW_NUMBER_HEADER },
{ id: "bizCyclText", title: "사업차수" },
{ id: "bizYr", title: "사업년도" },
{ id: "ctpvNm", title: "시도" },
{ id: "sggNm", title: "시군구" },
{ id: "bizNm", title: "사업명" },
{ id: "trtdstCntText", title: "처리구역·분구(개소)" },
{ id: "prcisExmnPrlgText", title: "정밀조사 연장(km)" },
{ id: "reportYnText", title: "보고서" },
{ id: "rowNumber", title: STANDARD_ROW_NUMBER_HEADER, sortKey: "exmnBizId" },
{ id: "bizCyclText", title: "사업차수", sortKey: "bizCycl" },
{ id: "bizYr", title: "사업년도", sortKey: "bizYr" },
{ id: "ctpvNm", title: "시도", sortKey: "ctpvNm" },
{ id: "sggNm", title: "시군구", sortKey: "sggNm" },
{ id: "bizNm", title: "사업명", sortKey: "bizNm" },
{ id: "trtdstCntText", title: "처리구역·분구(개소)", sortKey: "trtdstCnt" },
{
id: "prcisExmnPrlgText",
title: "정밀조사 연장(km)",
sortKey: "prcisExmnPrlg",
},
// 첨부서비스에서 현재 페이지 파일명을 보강하므로 전체 결과 파일명 정렬은 지원하지 않는다.
{ id: "reportYnText", title: "보고서", sortKey: null },
];
interface BusinessFilters {
@@ -94,6 +98,8 @@ export function ExmnRegistrationPage() {
pageIndex: 0,
pageSize: BUSINESS_LIST_PAGE_SIZE,
});
// 표시명 컬럼도 같은 이름 필드를 사용하는 서버 단일 정렬 상태다.
const [sort, setSort] = useState<UiTableSort>();
// 선택 사업 ID는 서버 재조회 뒤에도 같은 행을 복원할 수 있도록 객체와 별도로 유지한다.
const [selectedBusinessId, setSelectedBusinessId] = useState<string | null>(
null,
@@ -143,6 +149,8 @@ export function ExmnRegistrationPage() {
rowNumber: getStandardRowNumber({
total: totalElements,
rowIndex: index,
pageIndex: pagination.pageIndex,
pageSize: pagination.pageSize,
}),
bizCyclText: business.bizCycl == null ? "-" : `${business.bizCycl}차`,
trtdstCntText: Number(business.trtdstCnt ?? 0).toLocaleString("ko-KR"),
@@ -156,35 +164,47 @@ export function ExmnRegistrationPage() {
? "있음"
: "없음"),
})),
[businesses, totalElements],
[businesses, pagination.pageIndex, pagination.pageSize, totalElements],
);
/** 화면 조건을 행정구역 이름과 목록 내부 스크롤용 단일 서버 Page 계약으로 변환한다. */
/** 화면 조건과 현재 정렬을 0-base 서버 Page 계약으로 변환한다. */
const buildSearchParams = (
filters: BusinessFilters,
pageIndex: number,
nextSort?: UiTableSort,
): ExmnBusinessSearchParams => ({
bizCycl: filters.bizCycl || undefined,
bizYr: filters.bizYr !== "0" ? filters.bizYr : undefined,
ctpvNm: filters.ctpvNm || undefined,
sggNm: filters.sggNm || undefined,
bizNm: filters.bizNm || undefined,
page: 0,
size: BUSINESS_LIST_SCROLL_FETCH_SIZE,
page: pageIndex,
size: BUSINESS_LIST_PAGE_SIZE,
sort: nextSort ? `${nextSort.key},${nextSort.direction}` : undefined,
});
/** 지정 조회조건으로 사업 목록을 읽고 선택 행을 가능한 경우 유지한다. */
const fetchBusinesses = async (filters: BusinessFilters) => {
/** 지정 조회조건·정렬·페이지로 사업 목록을 읽고 현재 페이지 선택을 복원한다. */
const fetchBusinesses = async (
filters: BusinessFilters,
pageIndex = 0,
nextSort: UiTableSort | undefined = sort,
) => {
setIsLoading(true);
setNotice(null);
try {
const result = await getExmnBusinesses(buildSearchParams(filters));
const result = await getExmnBusinesses(
buildSearchParams(filters, pageIndex, nextSort),
);
const content = result.content;
setBusinesses(content);
setTotalElements(result.totalElements);
setSelectedBusinessId((current) =>
content.some((item) => item.exmnBizId === current) ? current : null,
);
setPagination((current) => ({ ...current, pageIndex: 0 }));
setPagination((current) => ({
...current,
pageIndex: result.number,
}));
return true;
} catch (error) {
setBusinesses([]);
@@ -207,7 +227,7 @@ export function ExmnRegistrationPage() {
useEffect(() => {
if (initialBusinessesLoadedRef.current) return;
initialBusinessesLoadedRef.current = true;
void fetchBusinesses(EMPTY_FILTERS);
void fetchBusinesses(EMPTY_FILTERS, 0, undefined);
// 최초 진입 시점의 빈 조회조건으로 한 번만 실행한다.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -215,7 +235,7 @@ export function ExmnRegistrationPage() {
/** 입력 중 조건을 확정하고 첫 페이지를 조회한다. */
const handleSearch = async () => {
setAppliedFilters(draftFilters);
await fetchBusinesses(draftFilters);
await fetchBusinesses(draftFilters, 0, sort);
};
/** CS 초기화 버튼으로 모든 검색조건과 페이지를 최초 조회 기준으로 복원한다. */
@@ -223,7 +243,8 @@ export function ExmnRegistrationPage() {
setDraftFilters(EMPTY_FILTERS);
setAppliedFilters(EMPTY_FILTERS);
setSelectedBusinessId(null);
await fetchBusinesses(EMPTY_FILTERS);
setSort(undefined);
await fetchBusinesses(EMPTY_FILTERS, 0, undefined);
};
/** 목록의 보고서 링크에서 첨부서비스 원본 PDF를 내려받는다. */
@@ -332,7 +353,7 @@ export function ExmnRegistrationPage() {
event.data?.type === WINDOW_POPUP_MESSAGE_TYPE.EXMN_BUSINESS_CREATED
) {
setSelectedBusinessId(null);
void fetchBusinesses(appliedFilters).then((refreshed) => {
void fetchBusinesses(appliedFilters, 0, sort).then((refreshed) => {
if (refreshed)
setNotice({ type: "success", text: "조사사업이 등록되었습니다." });
});
@@ -342,7 +363,11 @@ export function ExmnRegistrationPage() {
if (
event.data?.type === WINDOW_POPUP_MESSAGE_TYPE.EXMN_BUSINESS_UPDATED
) {
void fetchBusinesses(appliedFilters).then((refreshed) => {
void fetchBusinesses(
appliedFilters,
pagination.pageIndex,
sort,
).then((refreshed) => {
if (refreshed)
setNotice({ type: "success", text: "조사사업이 수정되었습니다." });
});
@@ -352,7 +377,11 @@ export function ExmnRegistrationPage() {
if (
event.data?.type === WINDOW_POPUP_MESSAGE_TYPE.EXMN_RESULT_COMMITTED
) {
void fetchBusinesses(appliedFilters).then((refreshed) => {
void fetchBusinesses(
appliedFilters,
pagination.pageIndex,
sort,
).then((refreshed) => {
if (refreshed)
setNotice({
type: "success",
@@ -364,7 +393,14 @@ export function ExmnRegistrationPage() {
window.addEventListener("message", handlePopupMessage);
return () => window.removeEventListener("message", handlePopupMessage);
}, [appliedFilters]);
}, [appliedFilters, pagination.pageIndex, sort]);
/** 정렬 변경 시 첫 페이지와 선택 사업을 초기화하고 서버 전체 결과를 다시 조회한다. */
const handleBusinessSortChange = (nextSort?: UiTableSort) => {
setSort(nextSort);
setSelectedBusinessId(null);
void fetchBusinesses(appliedFilters, 0, nextSort);
};
/** 보고서 다운로드와 행 선택을 유지하며 조사사업 목록을 공통 DataTable 열로 변환한다. */
const columns = useMemo<ColumnDef<(typeof businessRows)[number]>[]>(
@@ -372,7 +408,17 @@ export function ExmnRegistrationPage() {
BUSINESS_TABLE_HEAD.map((head) => ({
id: head.id,
accessorFn: (row) => row[head.id as keyof typeof row],
header: head.title,
header: () =>
head.sortKey === null ? (
head.title
) : (
<StandardTableSortHeader
label={head.title}
sortKey={head.sortKey}
sort={sort}
onSortChange={handleBusinessSortChange}
/>
),
cell: ({ row, getValue }) => {
const business = row.original;
const isReportCell = head.id === "reportYnText";
@@ -420,7 +466,7 @@ export function ExmnRegistrationPage() {
align: "center" as const,
},
})),
[],
[appliedFilters, sort],
);
const table = useReactTable({
@@ -431,9 +477,16 @@ export function ExmnRegistrationPage() {
rowSelection: selectedBusinessId ? { [selectedBusinessId]: true } : {},
},
getRowId: (row) => row.exmnBizId,
onPaginationChange: setPagination,
rowCount: totalElements,
manualPagination: true,
onPaginationChange: (updater) => {
const next =
typeof updater === "function" ? updater(pagination) : updater;
if (next.pageIndex === pagination.pageIndex) return;
setSelectedBusinessId(null);
void fetchBusinesses(appliedFilters, next.pageIndex, sort);
},
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
});
return (
@@ -2,6 +2,11 @@
import LoadingOverlay from "@/components/ui/LoadingBar";
import { openWindowPopup } from "@/features/windowPopup/lib/openWindowPopup";
import {
StandardTableSortHeader,
sortStandardTableRows,
type UiTableSort,
} from "@common/business_components";
import {
Button,
Table,
@@ -28,23 +33,23 @@ import { EXMN_TABLE_HEADER_HEIGHT_REM } from "./ExmnStandardDataTable";
const SUMMARY_GRID_ROW_HEIGHT_REM = 3.2;
const PIPE_SUMMARY_TABLE_HEAD = [
{ id: "rowNumber", title: "순번", widthPercent: 6 },
{ id: "trtdstNm", title: "처리분구", widthPercent: 18 },
{ id: "trgtPrlgText", title: "대상연장(m)", widthPercent: 13 },
{ id: "drvngDstncText", title: "주행거리(m)", widthPercent: 13 },
{ id: "wholeCountText", title: "총 이상항목(개소)", widthPercent: 15 },
{ id: "structuralCountText", title: "구조적결함(개소)", widthPercent: 14 },
{ id: "operationalCountText", title: "운영적결함(개소)", widthPercent: 14 },
{ id: "etcCountText", title: "기타", widthPercent: 7 },
{ id: "rowNumber", title: "순번", widthPercent: 6, sortKey: "rowNumber" },
{ id: "trtdstNm", title: "처리분구", widthPercent: 18, sortKey: "trtdstNm" },
{ id: "trgtPrlgText", title: "대상연장(m)", widthPercent: 13, sortKey: "trgtPrlgText" },
{ id: "drvngDstncText", title: "주행거리(m)", widthPercent: 13, sortKey: "drvngDstncText" },
{ id: "wholeCountText", title: "총 이상항목(개소)", widthPercent: 15, sortKey: "wholeCountText" },
{ id: "structuralCountText", title: "구조적결함(개소)", widthPercent: 14, sortKey: "structuralCountText" },
{ id: "operationalCountText", title: "운영적결함(개소)", widthPercent: 14, sortKey: "operationalCountText" },
{ id: "etcCountText", title: "기타", widthPercent: 7, sortKey: "etcCountText" },
];
const MANHOLE_SUMMARY_TABLE_HEAD = [
{ id: "rowNumber", title: "순번", widthPercent: 8 },
{ id: "trtdstNm", title: "처리분구", widthPercent: 28 },
{ id: "wholeCountText", title: "총 이상항목(개소)", widthPercent: 18 },
{ id: "structuralCountText", title: "구조적결함(개소)", widthPercent: 17 },
{ id: "operationalCountText", title: "운영적결함(개소)", widthPercent: 17 },
{ id: "etcCountText", title: "기타", widthPercent: 12 },
{ id: "rowNumber", title: "순번", widthPercent: 8, sortKey: "rowNumber" },
{ id: "trtdstNm", title: "처리분구", widthPercent: 28, sortKey: "trtdstNm" },
{ id: "wholeCountText", title: "총 이상항목(개소)", widthPercent: 18, sortKey: "wholeCountText" },
{ id: "structuralCountText", title: "구조적결함(개소)", widthPercent: 17, sortKey: "structuralCountText" },
{ id: "operationalCountText", title: "운영적결함(개소)", widthPercent: 17, sortKey: "operationalCountText" },
{ id: "etcCountText", title: "기타", widthPercent: 12, sortKey: "etcCountText" },
];
type Notice = { type: "info" | "error"; text: string } | null;
@@ -88,6 +93,8 @@ export function ExmnStatusDetailPanel({
const [summaryRows, setSummaryRows] = useState<ExmnSectionSummaryRow[]>([]);
/** 상세보기 팝업에 전달할 현재 선택 처리분구다. */
const [selectedTrtdstId, setSelectedTrtdstId] = useState<string | null>(null);
// 서버가 반환한 전체 처리분구 집계행에 적용하는 단일 로컬 정렬 상태다.
const [sort, setSort] = useState<UiTableSort>();
const [isLoading, setIsLoading] = useState(false);
const [isDownloading, setIsDownloading] = useState(false);
const [notice, setNotice] = useState<Notice>(null);
@@ -96,11 +103,13 @@ export function ExmnStatusDetailPanel({
useEffect(() => {
setJobType("PPL");
setSelectedTrtdstId(null);
setSort(undefined);
setNotice(null);
}, [business?.exmnBizId]);
useEffect(() => {
setSelectedTrtdstId(null);
setSort(undefined);
}, [jobType]);
useEffect(() => {
@@ -176,7 +185,7 @@ export function ExmnStatusDetailPanel({
etc: 0,
},
);
const rows: DisplaySummaryRow[] = summaryRows.map((row, index) => {
const displayRows: DisplaySummaryRow[] = summaryRows.map((row, index) => {
const counts = getCounts(row);
return {
trtdstId: row.trtdstId,
@@ -191,7 +200,7 @@ export function ExmnStatusDetailPanel({
};
});
return {
rows,
rows: sortStandardTableRows(displayRows, sort),
totals: {
trgtPrlgText: formatNumber(totals.trgtPrlg),
drvngDstncText: formatNumber(totals.drvngDstnc),
@@ -201,7 +210,7 @@ export function ExmnStatusDetailPanel({
etcCountText: formatNumber(totals.etc),
} as Record<string, string>,
};
}, [jobType, summaryRows]);
}, [jobType, sort, summaryRows]);
const summaryColumns =
jobType === "PPL" ? PIPE_SUMMARY_TABLE_HEAD : MANHOLE_SUMMARY_TABLE_HEAD;
@@ -299,6 +308,12 @@ export function ExmnStatusDetailPanel({
setNotice(null);
};
/** 정렬 변경 시 상세 대상 선택을 해제하고 전체 집계행을 다시 배열한다. */
const handleSummarySortChange = (nextSort?: UiTableSort) => {
setSort(nextSort);
setSelectedTrtdstId(null);
};
/** 보이는 버튼 전체에서 조사유형을 즉시 바꾸고, 상세 조회는 별도 effect에서 수행한다. */
const handleJobTypeChange = (nextJobType: ExmnJobType) => {
if (nextJobType === jobType) return;
@@ -417,7 +432,12 @@ export function ExmnStatusDetailPanel({
className="sticky top-0 z-20 !py-[1.2rem] text-center"
style={{ height: `${EXMN_TABLE_HEADER_HEIGHT_REM}rem` }}
>
{column.title}
<StandardTableSortHeader
label={column.title}
sortKey={column.sortKey}
sort={sort}
onSortChange={handleSummarySortChange}
/>
</TableHead>
))}
</TableRow>
@@ -3,7 +3,12 @@
import type { UIEvent } from "react";
import { useEffect, useMemo, useState } from "react";
import { StandardPopupLayout } from "@common/business_components";
import {
StandardPopupLayout,
StandardTableSortHeader,
sortStandardTableRows,
type UiTableSort,
} from "@common/business_components";
import {
Button,
Input,
@@ -16,6 +21,9 @@ import {
Table,
} from "@common/components";
import { downloadExcelWithKoreanHeaders } from "@/shared/lib/download-excel";
import PopupSearchPanel, {
PopupSearchActions,
} from "@/features/windowPopup/ui/PopupSearchPanel";
import {
getExmnFacilityDetails,
@@ -164,6 +172,8 @@ export function ExmnSurveyDetailPopupPage({
const [searchRequestSeq, setSearchRequestSeq] = useState(0);
/** 가로 스크롤 위치를 기준으로 요약 라벨과 고정 열 경계선 위치를 함께 보정한다. */
const [tableScrollLeft, setTableScrollLeft] = useState(0);
// 관로·맨홀 고정 정보 열을 전체 조회 결과에서 정렬하는 상태다.
const [sort, setSort] = useState<UiTableSort>();
/** 다운로드 미연결 등 현재 팝업 안내 메시지를 표시한다. */
const [notice, setNotice] = useState<Notice>(null);
/** 실제 DB 상세조회 결과와 요청 상태다. */
@@ -246,13 +256,20 @@ export function ExmnSurveyDetailPopupPage({
row.pipeNo.toLocaleLowerCase("ko-KR").includes(normalizedKeyword),
);
}, [actualUnitRows, appliedDetailNumberKeyword, isUnitMode]);
const rows = filteredRows;
const rows = useMemo(
() =>
sortStandardTableRows(filteredRows, sort, (row, key) =>
getFixedCellValue(row, key as ExmnDetailFixedColumnId),
),
[filteredRows, sort],
);
/** 관로·맨홀 조사유형 또는 결함 범위가 바뀌면 이전 검색 조건과 안내를 초기화한다. */
useEffect(() => {
setDetailMode("PIPE");
setDetailNumberKeyword("");
setAppliedDetailNumberKeyword("");
setSort(undefined);
setNotice(null);
}, [defectType, jobType]);
@@ -750,7 +767,7 @@ export function ExmnSurveyDetailPopupPage({
<section className="flex min-w-0 flex-col gap-[1.2rem]">
{!isDefectTypeView && (
<div className="card card-border !m-0 flex flex-wrap items-center gap-3 !p-[1.2rem]">
<PopupSearchPanel contentClassName="gap-3">
<div className="flex items-center gap-2">
<Label
htmlFor="exmn-detail-district"
@@ -835,7 +852,7 @@ export function ExmnSurveyDetailPopupPage({
</div>
)}
<div className="ml-auto flex items-center gap-2">
<PopupSearchActions>
<Button type="button" color="primary" onClick={handleSearch}>
조회
</Button>
@@ -852,8 +869,8 @@ export function ExmnSurveyDetailPopupPage({
>
초기화
</Button>
</div>
</div>
</PopupSearchActions>
</PopupSearchPanel>
)}
{loadError && (
@@ -978,9 +995,23 @@ export function ExmnSurveyDetailPopupPage({
: undefined
}
>
<span className="whitespace-pre-line">
{columnLabel}
</span>
{columnIndex < 9 ? (
<StandardTableSortHeader
label={columnLabel.replace(/\n/g, " ")}
title={
<span className="whitespace-pre-line">
{columnLabel}
</span>
}
sortKey={column.id}
sort={sort}
onSortChange={setSort}
/>
) : (
<span className="whitespace-pre-line">
{columnLabel}
</span>
)}
</th>
);
})}
@@ -12,7 +12,6 @@ import {
} from "@common/components/ui";
import { useCallback, useEffect, useMemo, useState } from "react";
import {
downloadPplExport,
getExmnBusiness,
getPplFacilities,
getPplSummaries,
@@ -25,6 +24,8 @@ import type {
} from "../model/exmn-business-types";
import { PplFacilityDetailModal } from "./PplFacilityDetailModal";
import { ExmnStandardDataTable } from "./ExmnStandardDataTable";
import { downloadExcelWithKoreanHeaders } from "@/shared/lib/download-excel";
import { fetchAllPages } from "@/shared/lib/fetch-all-pages";
const SUMMARY_TABLE_HEAD = [
{ id: "trtdstNm", title: "처리분구", widthPercent: 20 },
@@ -121,16 +122,6 @@ interface PplSummaryModalProps {
const formatNumber = (value: number | null | undefined) =>
Number(value ?? 0).toLocaleString("ko-KR", { maximumFractionDigits: 3 });
/** Blob을 PPL 집계 엑셀 다운로드로 전달한다. */
const saveBlob = (blob: Blob, fileName: string) => {
const objectUrl = URL.createObjectURL(blob);
const anchor = document.createElement("a");
anchor.href = objectUrl;
anchor.download = fileName;
anchor.click();
URL.revokeObjectURL(objectUrl);
};
/** 처리분구별 PPL 집계에서 결함 수를 따라 시설 목록과 단위 상세까지 탐색하는 모달이다. */
export function PplSummaryModal({
open,
@@ -352,10 +343,40 @@ export function PplSummaryModal({
setIsLoading(true);
setNotice(null);
try {
saveBlob(
await downloadPplExport(business.exmnBizId, trtdstId || undefined),
`${business.bizNm}_PPL집계.xlsx`,
);
const result = await fetchAllPages({
fetchPage: (page, size) =>
getPplSummaries(business.exmnBizId, {
trtdstId: trtdstId || undefined,
page,
size,
}),
getItems: (page) => page.content ?? [],
getTotal: (page) => Number(page.totalElements ?? 0),
});
const excelRows = result.items.map((row) => ({
trtdstNm: row.trtdstNm,
trgtPrlg: row.trgtPrlg,
drvngDstnc: row.drvngDstnc,
pplExmnWholAnmlyArtclCnt: row.pplExmnWholAnmlyArtclCnt,
pplExmnStrctDfcCnt: row.pplExmnStrctDfcCnt,
pplExmnOperDfcCnt: row.pplExmnOperDfcCnt,
pplExmnEtcCnt: row.pplExmnEtcCnt,
}));
await downloadExcelWithKoreanHeaders({
data: excelRows as unknown as JSON[],
fileName: `${business.bizNm}_PPL집계.xlsx`,
sheetNameArray: ["처리분구별 PPL 집계"],
headerRange: "A1:G1",
headerMapping: {
trtdstNm: "처리분구",
trgtPrlg: "대상연장(m)",
drvngDstnc: "주행거리(m)",
pplExmnWholAnmlyArtclCnt: "PPL 전체이상",
pplExmnStrctDfcCnt: "구조결함",
pplExmnOperDfcCnt: "운영결함",
pplExmnEtcCnt: "기타",
},
});
} catch (error) {
setNotice({
type: "error",
@@ -5,7 +5,10 @@ import useStore from "@/store/useStore";
import {
STANDARD_ROW_NUMBER_HEADER,
StandardDataTable,
StandardTableSortHeader,
getStandardRowNumber,
sortStandardTableRows,
type UiTableSort,
} from "@common/business_components";
import {
Button,
@@ -143,6 +146,8 @@ export function TrtdstManagementPage() {
pageIndex: 0,
pageSize: 10,
});
// 서버가 반환한 전체 활성 처리분구를 페이지 절단 전에 정렬하는 상태다.
const [sort, setSort] = useState<UiTableSort>();
// DataTable 선택 행은 저장·재조회 중에도 로컬 키 기준으로 명확히 추적한다.
const [selectedRowKey, setSelectedRowKey] = useState<string | null>(null);
// 조회·삭제 참조 확인·저장 요청 중 화면의 중복 조작을 막는다.
@@ -255,6 +260,7 @@ export function TrtdstManagementPage() {
}
setCtpvCd("0");
setSggCd("0");
setSort(undefined);
if (await fetchRows(EMPTY_APPLIED_REGION)) {
setAppliedRegion(EMPTY_APPLIED_REGION);
}
@@ -275,6 +281,8 @@ export function TrtdstManagementPage() {
return;
}
setEditingRowKey(selectedRow.localKey);
setSort(undefined);
setPagination((current) => ({ ...current, pageIndex: 0 }));
};
/** 선택한 행정구역으로 빈 신규 행을 만들고 처리분구명은 그리드에서 직접 입력받는다. */
@@ -289,6 +297,8 @@ export function TrtdstManagementPage() {
}
const localKey = createLocalKey();
setSort(undefined);
setPagination((current) => ({ ...current, pageIndex: 0 }));
setRows((current) =>
withDescendingRowNumbers([
...current,
@@ -464,13 +474,30 @@ export function TrtdstManagementPage() {
}
};
const sortedRows = useMemo(
() => sortStandardTableRows(rows, sort),
[rows, sort],
);
/** 인라인 편집과 변경 상태 표시를 유지한 채 공통 DataTable 열로 변환한다. */
const columns = useMemo<ColumnDef<TrtdstTableRow>[]>(
() =>
TRTDST_TABLE_HEAD.map((head) => ({
id: head.id,
accessorKey: head.id,
header: head.title,
header: () => (
<StandardTableSortHeader
label={head.title}
sortKey={head.id}
sort={sort}
onSortChange={(nextSort) => {
setSort(nextSort);
setPagination((current) => ({ ...current, pageIndex: 0 }));
setSelectedRowKey(null);
setEditingRowKey(null);
}}
/>
),
cell: ({ row, getValue }) => {
const item = row.original;
const isNameEditable =
@@ -505,11 +532,11 @@ export function TrtdstManagementPage() {
},
meta: { width: head.width, align: "center" as const },
})),
[editingRowKey],
[editingRowKey, sort],
);
const table = useReactTable({
data: rows,
data: sortedRows,
columns,
state: {
pagination,