import type { ColumnConfig, ColumnLayoutItem } from "@/components/type/DataGrid.type"; import { footerInt } from "@/components/util/grid/footerSummary"; import { ValueType } from "realgrid"; // 하수도 통계 관리 > 02.하수관로 > tab 5. 맨홀 현황 // SeweragePipeInputManholeStatusItem + commonInfo.ctpvNm (그리드 행에 병합) // 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); 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, header: { text: headerText }, footer: footerInt, // editable: false, valueType: ValueType.NUMBER, dataFormat: "#,##0", }); const yearlySumFields = (suffix: "WholMnhlCnt" | "Step1MnhlCnt" | "Step2MnhlCnt" | "Step3MnhlCnt" | "Step4MnhlCnt" | "Step5MnhlCnt") => Array.from({ length: MANHOLE_YY_MAX - MANHOLE_YY_MIN + 1 }, (_, i) => `yy${MANHOLE_YY_MIN + i}${suffix}`); function totalBlockColumns(): ColumnConfig[] { return [ { ...intCol("totalWholMnhlCnt", "계"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("WholMnhlCnt"), type: "sum" as const }, }, { ...intCol("totalStep1MnhlCnt", "주철"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("Step1MnhlCnt"), type: "sum" as const }, }, { ...intCol("totalStep2MnhlCnt", "주철(조화)"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("Step2MnhlCnt"), type: "sum" as const }, }, { ...intCol("totalStep3MnhlCnt", "콘크리트"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("Step3MnhlCnt"), type: "sum" as const }, }, { ...intCol("totalStep4MnhlCnt", "기타"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("Step4MnhlCnt"), type: "sum" as const }, }, { ...intCol("totalStep5MnhlCnt", "추락방지시설설치맨홀(개)"), styleName: "rg-cell-total", editable: false, computed: { fields: yearlySumFields("Step5MnhlCnt"), type: "sum" as const }, }, ]; } function yyBlockColumns(yy: number): ColumnConfig[] { const p = `yy${yy}`; return [ { ...intCol(`${p}WholMnhlCnt`, "계"), styleName: "rg-cell-total", editable: false, computed: { fields: [ `${p}Step1MnhlCnt`, `${p}Step2MnhlCnt`, `${p}Step3MnhlCnt`, `${p}Step4MnhlCnt`, `${p}Step5MnhlCnt`, ], type: "sum" as const, }, }, intCol(`${p}Step1MnhlCnt`, "주철"), intCol(`${p}Step2MnhlCnt`, "주철(조화)"), intCol(`${p}Step3MnhlCnt`, "콘크리트"), intCol(`${p}Step4MnhlCnt`, "기타"), intCol(`${p}Step5MnhlCnt`, "추락방지시설설치맨홀(개)"), ]; } function yyYearLayout(yy: number): ColumnLayoutItem { const y = calendarYearFromYy(yy); const p = `yy${yy}`; return { name: `year${y}`, hideChildHeaders: false, header: { text: manholeYearHeaderText(yy) }, items: [ { name: `year${y}Material`, hideChildHeaders: false, header: { text: "맨홀뚜껑 재질(개)" }, items: [ `${p}WholMnhlCnt`, `${p}Step1MnhlCnt`, `${p}Step2MnhlCnt`, `${p}Step3MnhlCnt`, `${p}Step4MnhlCnt`, ], }, `${p}Step5MnhlCnt`, ], }; } const yearLayoutItems: ColumnLayoutItem[] = []; for (let yy = MANHOLE_YY_MIN; yy <= MANHOLE_YY_MAX; yy++) { yearLayoutItems.push(yyYearLayout(yy)); } export const ManholeStatusInpColumn = { columns: [ { name: "ctpvNm", fieldName: "ctpvNm", header: { text: "시도" }, footer: { text: "합계" }, editable: false, styleName: "rg-cell-readonly", }, { name: "sggNm", fieldName: "sggNm", header: { text: "시군구" }, editable: false, styleName: "rg-cell-readonly", }, { name: "admdstNm", fieldName: "admdstNm", header: { text: "행정구역명" }, editable: false, styleName: "rg-cell-readonly", }, { name: "emphsMngSeNm", fieldName: "emphsMngSeNm", header: { text: "집중강우중점관리구역구분" }, editable: false, styleName: "rg-cell-readonly", footer: { text: "합계" }, // editable: false, }, ...totalBlockColumns(), ...Array.from({ length: MANHOLE_YY_MAX - MANHOLE_YY_MIN + 1 }, (_, i) => yyBlockColumns(MANHOLE_YY_MIN + i) ).flat(), { name: "rmrk", fieldName: "rmrk", header: { text: "비고" } }, { name: "admdstCd", fieldName: "admdstCd", header: { text: "행정구역코드" }, visible: false, editable: false, styleName: "rg-cell-readonly", }, { name: "emphsMngSeCd", fieldName: "emphsMngSeCd", header: { text: "집중강우중점관리구역코드" }, visible: false, editable: false, styleName: "rg-cell-readonly", }, ] as ColumnConfig[], columnLayout: [ { name: "adminArea", hideChildHeaders: false, header: { text: "행정구역" }, items: [{ column: "ctpvNm", footerUserSpans: [{ colspan: 2 }] }, "sggNm"], }, "admdstNm", "emphsMngSeNm", { name: "yearlyTotal", hideChildHeaders: false, header: { text: "연도별총계" }, items: [ { name: "yearlyTotalMaterial", hideChildHeaders: false, header: { text: "맨홀뚜껑 재질(개)" }, items: [ "totalWholMnhlCnt", "totalStep1MnhlCnt", "totalStep2MnhlCnt", "totalStep3MnhlCnt", "totalStep4MnhlCnt", ], }, "totalStep5MnhlCnt", ], }, ...yearLayoutItems, "rmrk", "admdstCd", "emphsMngSeCd", ] as ColumnLayoutItem[], rowStartNum: 3, fixedColumns: 2, tabKey: "ST00020005", tabLabel: "맨홀 현황", };