Files
frontend/apps/st/src/components/util/column/input/sewagePipe/ManholeStatusInpColumn.ts
T

159 lines
4.9 KiB
TypeScript

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=2014년 … yy25=2025년 (필드 접두 yy + 연도 끝자리)
const MANHOLE_YY_MIN = 14;
const MANHOLE_YY_MAX = 25;
const calendarYearFromYy = (yy: number) => 2000 + yy;
const intCol = (name: string, headerText: string): ColumnConfig => ({
name,
fieldName: name,
header: { text: headerText },
footer: footerInt,
editable: false,
valueType: ValueType.NUMBER,
dataFormat: "#,##0",
});
function totalBlockColumns(): ColumnConfig[] {
return [
intCol("totalWholMnhlCnt", "계"),
intCol("totalStep1MnhlCnt", "주철"),
intCol("totalStep2MnhlCnt", "주철(조화)"),
intCol("totalStep3MnhlCnt", "콘크리트"),
intCol("totalStep4MnhlCnt", "기타"),
intCol("totalStep5MnhlCnt", "추락방지시설설치맨홀(개)"),
];
}
function yyBlockColumns(yy: number): ColumnConfig[] {
const p = `yy${yy}`;
return [
intCol(`${p}WholMnhlCnt`, "계"),
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: `${y}년` },
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: "집중강우중점관리구역구분" },
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",
},
] 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"
] as ColumnLayoutItem[],
rowStartNum: 3,
fixedColumns: 2,
tabKey: "ST00020005",
tabLabel: "맨홀 현황",
};