[st] - fix: 오류 수정 및 누락 기능 추가
This commit is contained in:
@@ -4,7 +4,7 @@ import { ValueType } from "realgrid";
|
||||
|
||||
// 하수도 통계 관리 > 02.하수관로 > tab 5. 맨홀 현황
|
||||
// SeweragePipeInputManholeStatusItem + commonInfo.ctpvNm (그리드 행에 병합)
|
||||
// API: yy14=2014년 … yy{(현재연도-1)%100} (필드 접두 yy + 연도 끝자리)
|
||||
// API: yy14=2015년 이전(2014년 데이터) … yy{(현재연도-1)%100} (필드 접두 yy + 연도 끝자리)
|
||||
|
||||
const MANHOLE_START_YEAR = 2014;
|
||||
const MANHOLE_LAST_DATA_YEAR = Math.max(MANHOLE_START_YEAR, new Date().getFullYear() - 1);
|
||||
@@ -12,6 +12,12 @@ const MANHOLE_YY_MIN = MANHOLE_START_YEAR % 100;
|
||||
const MANHOLE_YY_MAX = MANHOLE_LAST_DATA_YEAR % 100;
|
||||
const calendarYearFromYy = (yy: number) => 2000 + yy;
|
||||
|
||||
/** yy14(2014) 구간은 헤더에 「2015년 이전」 표기 (합계·검토 컬럼과 동일) */
|
||||
const manholeYearHeaderText = (yy: number): string => {
|
||||
const y = calendarYearFromYy(yy);
|
||||
return y === MANHOLE_START_YEAR ? "2015년 이전" : `${y}년`;
|
||||
};
|
||||
|
||||
const intCol = (name: string, headerText: string): ColumnConfig => ({
|
||||
name,
|
||||
fieldName: name,
|
||||
@@ -98,7 +104,7 @@ function yyYearLayout(yy: number): ColumnLayoutItem {
|
||||
return {
|
||||
name: `year${y}`,
|
||||
hideChildHeaders: false,
|
||||
header: { text: `${y}년` },
|
||||
header: { text: manholeYearHeaderText(yy) },
|
||||
items: [
|
||||
{
|
||||
name: `year${y}Material`,
|
||||
|
||||
@@ -211,8 +211,9 @@ export const PipeTypeStatusInpColumn = {
|
||||
],
|
||||
},
|
||||
...yearLayoutItems,
|
||||
"rmrk",
|
||||
'rmrk',
|
||||
'admdstCd',
|
||||
'pipeSeCd'
|
||||
] as ColumnLayoutItem[],
|
||||
rowStartNum: 2,
|
||||
fixedColumns: 2,
|
||||
|
||||
@@ -955,6 +955,7 @@ export const getST00020003Config = (statsYr: string | number) => {
|
||||
valueType: ValueType.NUMBER,
|
||||
dataFormat: "#,##0.0",
|
||||
editable: false,
|
||||
excludeFromExcelExport: true,
|
||||
},
|
||||
...(() => {
|
||||
const yearColumns = [];
|
||||
|
||||
@@ -134,6 +134,7 @@ export const SeweragePentrationRateTotColumn = {
|
||||
editable: false,
|
||||
valueType: ValueType.NUMBER,
|
||||
dataFormat: '#,##0.0',
|
||||
excludeFromExcelExport: true,
|
||||
},
|
||||
|
||||
// 비고
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { ColumnConfig } from "@/components/type/DataGrid.type";
|
||||
import type { GridView } from "realgrid";
|
||||
|
||||
export type ExcelExportVisibilitySnapshot = Map<string, boolean>;
|
||||
|
||||
/** 엑셀보내기 직전: 제외 컬럼 숨김, 그리드용 숨김(visible:false) 컬럼은 export에만 표시 */
|
||||
export function prepareGridColumnsForExcelExport(
|
||||
gridView: GridView,
|
||||
columns: ColumnConfig[],
|
||||
): ExcelExportVisibilitySnapshot {
|
||||
const excludedNames = new Set(
|
||||
columns.filter((c) => c.excludeFromExcelExport).map((c) => c.name),
|
||||
);
|
||||
const snapshot = new Map<string, boolean>();
|
||||
|
||||
columns.forEach((col) => {
|
||||
const gridCol = gridView.columnByName?.(col.name);
|
||||
if (!gridCol) return;
|
||||
|
||||
const wasVisible = gridCol.visible !== false;
|
||||
snapshot.set(col.name, wasVisible);
|
||||
|
||||
if (excludedNames.has(col.name)) {
|
||||
gridCol.visible = false;
|
||||
} else if (col.visible === false) {
|
||||
gridCol.visible = true;
|
||||
}
|
||||
});
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
export function restoreGridColumnsAfterExcelExport(
|
||||
gridView: GridView,
|
||||
snapshot: ExcelExportVisibilitySnapshot,
|
||||
): void {
|
||||
snapshot.forEach((visible, name) => {
|
||||
const gridCol = gridView.columnByName?.(name);
|
||||
if (gridCol) gridCol.visible = visible;
|
||||
});
|
||||
}
|
||||
|
||||
export function shouldPrepareColumnsForExcelExport(columns: ColumnConfig[]): boolean {
|
||||
return columns.some((c) => c.excludeFromExcelExport || c.visible === false);
|
||||
}
|
||||
Reference in New Issue
Block a user