[st] - 일정등록, 입력단 지난검증결과 알림 뱃지, 로그 상세조회, 검토단 cell style 적용
This commit is contained in:
@@ -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) },
|
||||
|
||||
Reference in New Issue
Block a user