[st] - 일정등록, 입력단 지난검증결과 알림 뱃지, 로그 상세조회, 검토단 cell style 적용

This commit is contained in:
2026-07-02 17:46:13 +09:00
parent 25417dcda1
commit cea2d39df8
66 changed files with 1615 additions and 206 deletions
+101 -6
View File
@@ -1,8 +1,11 @@
/**
* statistics/input 화면과 탭(·분할 그리드) 키 매칭용 상수.
* 각 컴포넌트에 실제로 쓰이는 `tabKey`를 모두 포함합니다.
* 각 컴포넌트에 실제로 쓰이는 `tabKey`·`statsCd`를 모두 포함합니다.
*/
/** `SeweragePenetrationRateInp.tsx` — 단일 그리드 */
export const SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS = ["ST00010001"] as const;
/** `SewagePipeInp.tsx` — 메인 탭 + `ConnectionStatusInpColumn` 좌·우 그리드 서브 키 */
export const SEWAGE_PIPE_INP_TAB_KEYS = [
"ST00020001",
@@ -18,16 +21,108 @@ export const SEWAGE_PIPE_INP_TAB_KEYS = [
/** `SewagePipeMaintainInp.tsx` — 보수·준설 탭 */
export const SEWAGE_PIPE_MAINTAIN_INP_TAB_KEYS = ["ST00030001", "ST00030002"] as const;
/** `SeweragePenetrationRateInp.tsx` — 단일 그리드(통계코드) */
export const SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS = ["ST00010001"] as const;
/** `SewageReservoirPumpInp.tsx` */
export const SEWAGE_RESERVOIR_PUMP_INP_TAB_KEYS = ["ST00040001", "ST00040002"] as const;
/** `PumpingStationInp.tsx` */
export const PUMPING_STATION_INP_TAB_KEYS = ["ST00050001"] as const;
/** `PublicSewageFacilityInp.tsx` */
export const PUBLIC_SEWAGE_FACILITY_INP_TAB_KEYS = ["ST00060001", "ST00060002"] as const;
/** `ExcretaTreatmentFacilityInp.tsx` */
export const EXCRETA_TREATMENT_FACILITY_INP_TAB_KEYS = ["ST00070001"] as const;
/**
* `PrivateSewageFacilityInp.tsx`
* ST00080003은 tabKey(`privateSewageDesigStatusInp`)와 다름 — `INPUT_TAB_KEY_BY_STATS_CD` 참고
*/
export const PRIVATE_SEWAGE_FACILITY_INP_TAB_KEYS = [
"ST00080001",
"ST00080002",
"ST00080003",
] as const;
/** `SewerageFinanceInp.tsx` */
export const SEWERAGE_FINANCE_INP_TAB_KEYS = [
"ST00090001",
"ST00090002",
"ST00090003",
"ST00090004",
] as const;
/** `WaterReuseInp.tsx` */
export const WATER_REUSE_INP_TAB_KEYS = [
"ST00100001",
"ST00100002",
"ST00100003",
"ST00100004",
"ST00100005",
] as const;
/** `SewageExcretaSlurgeInp.tsx` */
export const SEWAGE_EXCRETA_SLURGE_INP_TAB_KEYS = [
"ST00110001",
"ST00110002",
"ST00110003",
"ST00110004",
] as const;
/** `SewageExcretaRelatedInp.tsx` */
export const SEWAGE_EXCRETA_RELATED_INP_TAB_KEYS = [
"ST00120001",
"ST00120002",
"ST00120003",
"ST00120004",
] as const;
/** `SewerageServiceLevelInp.tsx` */
export const SEWERAGE_SERVICE_LEVEL_INP_TAB_KEYS = [
"ST00130001",
"ST00130002",
] as const;
/** statsCd와 입력 화면 activeTab(tabKey)이 다른 경우 */
export const INPUT_TAB_KEY_BY_STATS_CD: Record<string, string> = {
ST00080003: "privateSewageDesigStatusInp",
};
export type SeweragePenetrationRateInpTabKey =
(typeof SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS)[number];
export type SewagePipeInpTabKey = (typeof SEWAGE_PIPE_INP_TAB_KEYS)[number];
export type SewagePipeMaintainInpTabKey = (typeof SEWAGE_PIPE_MAINTAIN_INP_TAB_KEYS)[number];
export type SeweragePenetrationRateInpTabKey = (typeof SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS)[number];
export type SewagePipeMaintainInpTabKey =
(typeof SEWAGE_PIPE_MAINTAIN_INP_TAB_KEYS)[number];
export type SewageReservoirPumpInpTabKey =
(typeof SEWAGE_RESERVOIR_PUMP_INP_TAB_KEYS)[number];
export type PumpingStationInpTabKey = (typeof PUMPING_STATION_INP_TAB_KEYS)[number];
export type PublicSewageFacilityInpTabKey =
(typeof PUBLIC_SEWAGE_FACILITY_INP_TAB_KEYS)[number];
export type ExcretaTreatmentFacilityInpTabKey =
(typeof EXCRETA_TREATMENT_FACILITY_INP_TAB_KEYS)[number];
export type PrivateSewageFacilityInpTabKey =
(typeof PRIVATE_SEWAGE_FACILITY_INP_TAB_KEYS)[number];
export type SewerageFinanceInpTabKey = (typeof SEWERAGE_FINANCE_INP_TAB_KEYS)[number];
export type WaterReuseInpTabKey = (typeof WATER_REUSE_INP_TAB_KEYS)[number];
export type SewageExcretaSlurgeInpTabKey =
(typeof SEWAGE_EXCRETA_SLURGE_INP_TAB_KEYS)[number];
export type SewageExcretaRelatedInpTabKey =
(typeof SEWAGE_EXCRETA_RELATED_INP_TAB_KEYS)[number];
export type SewerageServiceLevelInpTabKey =
(typeof SEWERAGE_SERVICE_LEVEL_INP_TAB_KEYS)[number];
/** 컴포넌트 파일명 기준 묶음 (메뉴·라우트 매칭 시 참고) */
export const STATISTICS_INPUT_TAB_KEYS_BY_SCREEN = {
SeweragePenetrationRateInp: SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS,
SewagePipeInp: SEWAGE_PIPE_INP_TAB_KEYS,
SewagePipeMaintainInp: SEWAGE_PIPE_MAINTAIN_INP_TAB_KEYS,
SeweragePenetrationRateInp: SEWERAGE_PENETRATION_RATE_INP_TAB_KEYS,
SewageReservoirPumpInp: SEWAGE_RESERVOIR_PUMP_INP_TAB_KEYS,
PumpingStationInp: PUMPING_STATION_INP_TAB_KEYS,
PublicSewageFacilityInp: PUBLIC_SEWAGE_FACILITY_INP_TAB_KEYS,
ExcretaTreatmentFacilityInp: EXCRETA_TREATMENT_FACILITY_INP_TAB_KEYS,
PrivateSewageFacilityInp: PRIVATE_SEWAGE_FACILITY_INP_TAB_KEYS,
SewerageFinanceInp: SEWERAGE_FINANCE_INP_TAB_KEYS,
WaterReuseInp: WATER_REUSE_INP_TAB_KEYS,
SewageExcretaSlurgeInp: SEWAGE_EXCRETA_SLURGE_INP_TAB_KEYS,
SewageExcretaRelatedInp: SEWAGE_EXCRETA_RELATED_INP_TAB_KEYS,
SewerageServiceLevelInp: SEWERAGE_SERVICE_LEVEL_INP_TAB_KEYS,
} as const;
@@ -3,6 +3,28 @@ import { ValueType } from "realgrid";
import type { ColumnConfig, ColumnInfo } from "@/components/type/DataGrid.type";
import type { StatisticsLogDetailRow } from "@/entities/statistics/model/statistics-interface";
export const LOG_DETAIL_DETAILS_FIELD = "details";
export const LOG_DETAIL_DETAILS_RAW_FIELD = "__detailsRaw";
export interface LogDetailVerificationColumn {
tblNm: string;
metaSn: number;
fieldNm: string;
engColNm: string;
dataScpCd: string;
kornColNm: string;
}
export interface LogDetailVerificationItem {
columns: LogDetailVerificationColumn[];
cmprOpert: string | null;
vrfcDtlSn: number;
refStatsCd: string | null;
eqtnCombSeq: number;
engArtopnEqtnCn: string;
kornArtopnEqtnCn: string;
}
const COMMON_FIELD_ORDER = ["rmrk", "sggNm", "admdstCd", "admdstNm"] as const;
const FIELD_HEADER: Record<string, string> = {
@@ -10,8 +32,71 @@ const FIELD_HEADER: Record<string, string> = {
sggNm: "시군구",
admdstCd: "행정구역코드",
admdstNm: "행정구역명",
[LOG_DETAIL_DETAILS_FIELD]: "상세",
};
function parseLogDetailsValue(
value: unknown,
): LogDetailVerificationItem[] | null {
if (value == null || value === "") return null;
if (Array.isArray(value)) {
return value as LogDetailVerificationItem[];
}
if (typeof value === "string") {
try {
const parsed: unknown = JSON.parse(value);
return Array.isArray(parsed)
? (parsed as LogDetailVerificationItem[])
: null;
} catch {
return null;
}
}
return null;
}
/** details JSON 배열을 그리드 버튼 셀 + 숨김 raw 필드로 변환 */
export function prepareLogDetailRowsForGrid(
rows: StatisticsLogDetailRow[],
): Record<string, string | number>[] {
return rows.map((row) => {
const next: Record<string, string | number> = {};
for (const [key, value] of Object.entries(row)) {
if (key === LOG_DETAIL_DETAILS_FIELD) {
const parsed = parseLogDetailsValue(value);
if (parsed && parsed.length > 0) {
next[LOG_DETAIL_DETAILS_RAW_FIELD] = JSON.stringify(parsed);
next[LOG_DETAIL_DETAILS_FIELD] = "상세보기";
} else {
next[LOG_DETAIL_DETAILS_RAW_FIELD] = "";
next[LOG_DETAIL_DETAILS_FIELD] =
value === null || value === undefined
? ""
: typeof value === "object"
? ""
: String(value);
}
continue;
}
next[key] =
value === null || value === undefined
? ""
: (value as string | number);
}
if (
LOG_DETAIL_DETAILS_FIELD in row &&
!(LOG_DETAIL_DETAILS_RAW_FIELD in next)
) {
next[LOG_DETAIL_DETAILS_RAW_FIELD] = "";
}
return next;
});
}
function collectFieldNames(rows: StatisticsLogDetailRow[]): string[] {
const keys = new Set<string>();
for (const row of rows) {
@@ -47,6 +132,16 @@ function buildColumns(rows: StatisticsLogDetailRow[]): ColumnConfig[] {
return fieldNames.map((fieldName) => {
const numeric = isNumericField(rows, fieldName);
if (fieldName === LOG_DETAIL_DETAILS_FIELD) {
return {
name: fieldName,
fieldName,
header: { text: FIELD_HEADER[fieldName] ?? fieldName },
editable: false,
width: 100,
styleName: "rg-cell-outline-action-btn",
};
}
return {
name: fieldName,
fieldName,
@@ -60,13 +155,33 @@ function buildColumns(rows: StatisticsLogDetailRow[]): ColumnConfig[] {
});
}
function appendHiddenDetailsRawColumn(columns: ColumnConfig[]): ColumnConfig[] {
const hasDetails = columns.some(
(column) => column.fieldName === LOG_DETAIL_DETAILS_FIELD,
);
if (!hasDetails) return columns;
return [
...columns,
{
name: LOG_DETAIL_DETAILS_RAW_FIELD,
fieldName: LOG_DETAIL_DETAILS_RAW_FIELD,
header: { text: "" },
editable: false,
visible: false,
},
];
}
export function buildLogHistoryDetailColumnInfo(
rows: StatisticsLogDetailRow[],
): ColumnInfo {
const columns = buildColumns(rows);
const columns = appendHiddenDetailsRawColumn(buildColumns(rows));
return {
columns,
columnLayout: columns.map((c) => c.fieldName),
columnLayout: columns
.filter((column) => column.visible !== false)
.map((column) => column.fieldName),
};
}
@@ -33,16 +33,19 @@ export const rawPublicSewageFacilityInfoList = {
name: 'ctpvNm',
fieldName: 'ctpvNm',
header: { text: '시도' },
mergeCells: true,
sortdisable: true,
footer: [
{ valueCallback: (grid: GridView) => getDivisionFooterLabel(grid, 0, true) },
{ valueCallback: (grid: GridView) => getDivisionFooterLabel(grid, 1, true) },
],
},
{ name: 'sggNm', fieldName: 'sggNm', header: { text: '시군구' } },
{ name: 'sggNm', fieldName: 'sggNm', header: { text: '시군구' }, mergeCells: true, sortdisable: true },
{
name: 'displayYear',
fieldName: 'displayYear',
header: { text: '구분' },
sortdisable: true,
footer: [
{ valueCallback: (grid: GridView) => getDivisionFooterLabel(grid, 0, false) },
{ valueCallback: (grid: GridView) => getDivisionFooterLabel(grid, 1, false) },
@@ -61,6 +61,26 @@ export function buildReviewRowTypeCurrCellStyleCallbackByTab(
return map;
}
/** 여러 cellStyleCallback 결과를 styleName으로 병합 */
export function composeCellStyleCallbacks(
...callbacks: CellStyleCallback[]
): CellStyleCallback {
return (params) => {
const styleNames: string[] = [];
for (const cb of callbacks) {
const result = cb(params);
if (!result) continue;
if (typeof result === "string") {
styleNames.push(result);
} else if (result.styleName) {
styleNames.push(result.styleName);
}
}
const styleName = styleNames.join(" ").trim();
return styleName ? styleName : undefined;
};
}
/**
* 객체 배열을 그리드 row 형식으로 변환 (null/undefined → "").
* 어떤 엔티티 타입이든 공통 사용 가능.
@@ -0,0 +1,183 @@
import type { CellStyleCallback, ColumnConfig } from "@/components/type/DataGrid.type";
import {
buildReviewRowTypeCurrCellStyleExcludeMergeCells,
composeCellStyleCallbacks,
} from "@/components/util/grid/gridFunction";
const DISPLAY_YEAR_FIELD = "displayYear";
/** CURR 미입력 + OLD(전년) 데이터 있음 */
export const REVIEW_CURR_EMPTY_WARN_STYLE = "rg-cell-review-curr-empty-warn";
/** CURR 미입력 + OLD 행 없음 */
export const REVIEW_CURR_EMPTY_NEW_STYLE = "rg-cell-review-curr-empty-new";
function getColumnFieldNames(columns: readonly Pick<ColumnConfig, "fieldName">[]): string[] {
return columns.map((col) => col.fieldName).filter(Boolean);
}
function getFieldNamesBeforeDivision(columns: readonly Pick<ColumnConfig, "fieldName">[]): string[] {
const fields = getColumnFieldNames(columns);
const divisionIndex = fields.indexOf(DISPLAY_YEAR_FIELD);
if (divisionIndex <= 0) return [];
return fields.slice(0, divisionIndex);
}
function getFieldNamesAfterDivision(columns: readonly Pick<ColumnConfig, "fieldName">[]): string[] {
const fields = getColumnFieldNames(columns);
const divisionIndex = fields.indexOf(DISPLAY_YEAR_FIELD);
if (divisionIndex < 0 || divisionIndex >= fields.length - 1) return [];
return fields.slice(divisionIndex + 1);
}
function getDivisionHighlightFieldNames(
columns: readonly Pick<ColumnConfig, "fieldName" | "name">[],
): Set<string> {
const divisionColumn = columns.find((col) => col.fieldName === DISPLAY_YEAR_FIELD);
return new Set(
[DISPLAY_YEAR_FIELD, divisionColumn?.name, divisionColumn?.fieldName].filter(
Boolean,
) as string[],
);
}
function buildRowGroupKey(
row: Record<string, string | number>,
groupKeyFields: readonly string[],
): string {
return groupKeyFields.map((field) => String(row[field] ?? "")).join("\0");
}
export function isEmptyOrZeroGridValue(value: string | number | undefined): boolean {
if (value === null || value === undefined || value === "") return true;
if (typeof value === "number") return value === 0;
const trimmed = String(value).trim();
if (trimmed === "") return true;
const numeric = Number(trimmed.replace(/,/g, ""));
return !Number.isNaN(numeric) && numeric === 0;
}
export function isRowEmptyOrZeroAfterDivision(
row: Record<string, string | number>,
dataFieldNames: readonly string[],
): boolean {
if (dataFieldNames.length === 0) return false;
return dataFieldNames.every((field) => isEmptyOrZeroGridValue(row[field]));
}
type EmptyCurrHighlight =
| typeof REVIEW_CURR_EMPTY_WARN_STYLE
| typeof REVIEW_CURR_EMPTY_NEW_STYLE;
function buildOldRowByGroupKey(
rows: readonly Record<string, string | number>[],
groupKeyFields: readonly string[],
): Map<string, Record<string, string | number>> {
const map = new Map<string, Record<string, string | number>>();
for (const row of rows) {
if (String(row.rowType ?? "") !== "OLD") continue;
map.set(buildRowGroupKey(row, groupKeyFields), row);
}
return map;
}
function buildOldRowIndexByGroupKey(
rows: readonly Record<string, string | number>[],
groupKeyFields: readonly string[],
): Map<string, number> {
const map = new Map<string, number>();
rows.forEach((row, index) => {
if (String(row.rowType ?? "") !== "OLD") return;
map.set(buildRowGroupKey(row, groupKeyFields), index);
});
return map;
}
function resolveEmptyCurrHighlight(
currRow: Record<string, string | number>,
oldRowByGroupKey: ReadonlyMap<string, Record<string, string | number>>,
groupKeyFields: readonly string[],
dataFieldNames: readonly string[],
): EmptyCurrHighlight | undefined {
if (String(currRow.rowType ?? "") !== "CURR") return undefined;
if (!isRowEmptyOrZeroAfterDivision(currRow, dataFieldNames)) return undefined;
const groupKey = buildRowGroupKey(currRow, groupKeyFields);
const oldRow = oldRowByGroupKey.get(groupKey);
if (!oldRow) {
return REVIEW_CURR_EMPTY_NEW_STYLE;
}
if (isRowEmptyOrZeroAfterDivision(oldRow, dataFieldNames)) {
return undefined;
}
return REVIEW_CURR_EMPTY_WARN_STYLE;
}
/**
* 검토 그리드 — CURR 행의 구분 이후 값이 모두 비어있거나 0일 때
* 구분(displayYear): OLD 있음 → OLD·CURR 노란색, OLD 없음 → CURR 하늘색, 둘 다 없음 → 미적용
*/
export function buildReviewEmptyCurrCellStyleCallback(
columns: readonly Pick<ColumnConfig, "fieldName" | "name">[],
rows: readonly Record<string, string | number>[],
): CellStyleCallback {
const groupKeyFields = getFieldNamesBeforeDivision(columns);
const dataFieldNames = getFieldNamesAfterDivision(columns);
const highlightFieldNames = getDivisionHighlightFieldNames(columns);
const oldRowByGroupKey = buildOldRowByGroupKey(rows, groupKeyFields);
const oldRowIndexByGroupKey = buildOldRowIndexByGroupKey(rows, groupKeyFields);
const highlightByRowIndex = new Map<number, EmptyCurrHighlight>();
rows.forEach((row, index) => {
if (String(row.rowType ?? "") !== "CURR") return;
const highlight = resolveEmptyCurrHighlight(
row,
oldRowByGroupKey,
groupKeyFields,
dataFieldNames,
);
if (!highlight) return;
highlightByRowIndex.set(index, highlight);
if (highlight === REVIEW_CURR_EMPTY_WARN_STYLE) {
const oldIndex = oldRowIndexByGroupKey.get(buildRowGroupKey(row, groupKeyFields));
if (oldIndex !== undefined) {
highlightByRowIndex.set(oldIndex, highlight);
}
}
});
return ({ rowIndex, fieldName }) => {
if (highlightFieldNames.size === 0 || !highlightFieldNames.has(fieldName)) {
return undefined;
}
return highlightByRowIndex.get(rowIndex);
};
}
export function buildReviewCellStyleCallback(
columns: readonly Pick<ColumnConfig, "fieldName" | "name" | "mergeCells">[],
rows: readonly Record<string, string | number>[],
): CellStyleCallback {
const base = buildReviewRowTypeCurrCellStyleExcludeMergeCells(columns);
const emptyCurr = buildReviewEmptyCurrCellStyleCallback(columns, rows);
return composeCellStyleCallbacks(base, emptyCurr);
}
export function buildReviewCellStyleCallbackByTab(
tabs: readonly {
tabKey: string;
columns?: readonly Pick<ColumnConfig, "fieldName" | "name" | "mergeCells">[];
}[],
rowDataMap: ReadonlyMap<string, readonly Record<string, string | number>[]>,
): Map<string, CellStyleCallback> {
const map = new Map<string, CellStyleCallback>();
for (const tab of tabs) {
const columns = tab.columns ?? [];
const rows = rowDataMap.get(tab.tabKey) ?? [];
map.set(tab.tabKey, buildReviewCellStyleCallback(columns, rows));
}
return map;
}
@@ -0,0 +1,17 @@
import type { StatisticsInputCommonInfoBase } from "@/entities/statistics/model/statistics-interface";
export function isVerificationFailedFromCommonInfo(
commonInfo: Pick<StatisticsInputCommonInfoBase, "isVerificationFailed"> | null | undefined,
): boolean {
return commonInfo?.isVerificationFailed === true;
}
export function patchVerificationFailedByTab(
prev: Map<string, boolean>,
tabKey: string,
commonInfo: Pick<StatisticsInputCommonInfoBase, "isVerificationFailed"> | null | undefined,
): Map<string, boolean> {
const next = new Map(prev);
next.set(tabKey, isVerificationFailedFromCommonInfo(commonInfo));
return next;
}