[ST] - fix: 전남광주통합특별시 본청 데이터 관련 로직 수정, 2-3지표 컬럼 로직 수정
This commit is contained in:
@@ -71,7 +71,10 @@ import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { FactInstallStatusInpColumn } from "@/components/util/column/input/sewagePipe/FactInstallStatusInpColumn";
|
||||
import { ManholeStatusInpColumn } from "@/components/util/column/input/sewagePipe/ManholeStatusInpColumn";
|
||||
import { PipeDiameterStatusInpColumn } from "@/components/util/column/input/sewagePipe/PipeDiameterStatusInpColumn";
|
||||
import { PipeTypeStatusInpColumn } from "@/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn";
|
||||
import {
|
||||
getPipeTypeStatusInpColumn,
|
||||
resolvePipeTypeColumnEndYear,
|
||||
} from "@/components/util/column/input/sewagePipe/PipeTypeStatusInpColumn";
|
||||
import { RegionalFactStatusInpColumn } from "@/components/util/column/input/sewagePipe/RegionalFactStatusInpColumn";
|
||||
import { SewagePipeInpColumnInfoList } from "@/components/util/column/input/sewagePipe/SewagePipeInpColumn";
|
||||
import { fetchColumnGuidesRecord } from "@/components/util/grid/columnGuides";
|
||||
@@ -119,11 +122,6 @@ function buildSewagePipeSearchParam(
|
||||
};
|
||||
}
|
||||
|
||||
const getPipeTypeLastDataYear = () => {
|
||||
const lastDataYear = new Date().getFullYear() - 1;
|
||||
return Math.max(1995, lastDataYear);
|
||||
};
|
||||
|
||||
const PIPE_TYPE_STATUS_TAB_KEY = "ST00020003";
|
||||
|
||||
/** 조회 연도(statsYr)에 해당하는 연도 (y{year}* 필드용) */
|
||||
@@ -131,7 +129,7 @@ const resolvePipeTypeEditableYear = (statsYr: string | null | undefined): number
|
||||
if (!statsYr) return null;
|
||||
const year = Number(statsYr);
|
||||
if (!Number.isFinite(year)) return null;
|
||||
return Math.min(getPipeTypeLastDataYear(), Math.max(1995, year));
|
||||
return Math.min(resolvePipeTypeColumnEndYear(statsYr), Math.max(1995, year));
|
||||
};
|
||||
|
||||
/** 조회 연도(statsYr)에 해당하는 연도별 매설연장 필드명 (y{year}LyngPrlg) */
|
||||
@@ -257,8 +255,9 @@ function getSewagePipeRowVerificationErrors(
|
||||
function normalizePipeTypeStatusRow(
|
||||
row: SeweragePipeInputPipeTypeStatusItem,
|
||||
ctpvNm: string,
|
||||
statsYr?: string | number | null,
|
||||
): Record<string, string | number | SeweragePipeInputVerificationResult | undefined> {
|
||||
const lastDataYear = getPipeTypeLastDataYear();
|
||||
const lastDataYear = resolvePipeTypeColumnEndYear(statsYr);
|
||||
const {
|
||||
yearlyStatList,
|
||||
lyngPrlgWhol,
|
||||
@@ -276,8 +275,8 @@ function normalizePipeTypeStatusRow(
|
||||
|
||||
for (const y of yearlyStatList ?? []) {
|
||||
const year = Number(y.lyngYr);
|
||||
if (!Number.isFinite(year)) continue;
|
||||
const targetYear = Math.min(lastDataYear, Math.max(1995, year));
|
||||
if (!Number.isFinite(year) || year > lastDataYear) continue;
|
||||
const targetYear = Math.max(1995, year);
|
||||
yearFields[`y${targetYear}PrlgWhol`] =
|
||||
(yearFields[`y${targetYear}PrlgWhol`] ?? 0) + Number(y.pipeWholPrlg ?? 0);
|
||||
yearFields[`y${targetYear}LyngPrlg`] =
|
||||
@@ -614,10 +613,14 @@ const SewagePipeInp = () => {
|
||||
};
|
||||
});
|
||||
return SewagePipeInpColumnInfoList.map((tab: ColumnInfoList) => {
|
||||
const canEdit =
|
||||
(computeTabEnterable(tabStatusInfoMap.get(tab.tabKey) ?? null, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
|
||||
const applyEditable = (cols: ColumnConfig[] | undefined) =>
|
||||
const sourceTab =
|
||||
tab.tabKey === PIPE_TYPE_STATUS_TAB_KEY
|
||||
? getPipeTypeStatusInpColumn(lastSearchedYear)
|
||||
: tab;
|
||||
const canEdit =
|
||||
(computeTabEnterable(tabStatusInfoMap.get(sourceTab.tabKey) ?? null, inputPeriodEnterable) || isAdminInfo) && inputPeriodEnterable;
|
||||
const applyEditable = (cols: ColumnConfig[] | undefined) =>
|
||||
sourceTab.tabKey === PIPE_TYPE_STATUS_TAB_KEY
|
||||
? applyPipeTypeStatusEditableColumns(
|
||||
cols,
|
||||
canEdit,
|
||||
@@ -635,20 +638,20 @@ const SewagePipeInp = () => {
|
||||
},
|
||||
);
|
||||
|
||||
if (tab.left && tab.right) {
|
||||
if (sourceTab.left && sourceTab.right) {
|
||||
return {
|
||||
...tab,
|
||||
left: { ...tab.left, columns: applyColumnGuides(applyEditable(tab.left.columns), tab.tabKey) },
|
||||
right: { ...tab.right, columns: applyColumnGuides(applyEditable(tab.right.columns), tab.tabKey) },
|
||||
...sourceTab,
|
||||
left: { ...sourceTab.left, columns: applyColumnGuides(applyEditable(sourceTab.left.columns), sourceTab.tabKey) },
|
||||
right: { ...sourceTab.right, columns: applyColumnGuides(applyEditable(sourceTab.right.columns), sourceTab.tabKey) },
|
||||
};
|
||||
}
|
||||
return {
|
||||
...tab,
|
||||
columns: applyColumnGuides(applyEditable(tab.columns), tab.tabKey),
|
||||
...(tab.tabKey === PIPE_TYPE_STATUS_TAB_KEY && tab.columnLayout
|
||||
...sourceTab,
|
||||
columns: applyColumnGuides(applyEditable(sourceTab.columns), sourceTab.tabKey),
|
||||
...(sourceTab.tabKey === PIPE_TYPE_STATUS_TAB_KEY && sourceTab.columnLayout
|
||||
? {
|
||||
columnLayout: applyPipeTypeStatusColumnLayout(
|
||||
tab.columnLayout,
|
||||
sourceTab.columnLayout,
|
||||
shouldHidePipeTypeEditableYearDmltn(
|
||||
canEdit,
|
||||
inputPeriodEnterable,
|
||||
@@ -807,7 +810,11 @@ const SewagePipeInp = () => {
|
||||
if (response.status === 'success') {
|
||||
const commonInfo = response.data.commonInfo;
|
||||
const convertedData = filterFetched(response.data.pipeTypeStatusList).map((d) =>
|
||||
normalizePipeTypeStatusRow(d, commonInfo.ctpvNm),
|
||||
normalizePipeTypeStatusRow(
|
||||
d,
|
||||
commonInfo.ctpvNm,
|
||||
searchParam.statsYr ?? values.year,
|
||||
),
|
||||
);
|
||||
applyRowMap((m) => m.set('ST00020003', toGridRows(convertedData)));
|
||||
setTabStatusInfoMap((prev) => new Map(prev).set(tabKey, response.data.statusInfo));
|
||||
@@ -1320,7 +1327,7 @@ const SewagePipeInp = () => {
|
||||
return;
|
||||
}
|
||||
const columnFormatMap = new Map<string, string>();
|
||||
PipeTypeStatusInpColumn.columns.forEach((col) => {
|
||||
getPipeTypeStatusInpColumn(values.year).columns.forEach((col) => {
|
||||
if (col.fieldName && col.dataFormat) columnFormatMap.set(col.fieldName, col.dataFormat);
|
||||
});
|
||||
const formatNumber = (value: string | number | null | undefined, fieldName: string): number => {
|
||||
@@ -1332,7 +1339,7 @@ const SewagePipeInp = () => {
|
||||
const decimalPlaces = format.match(/\.(\d+)/)?.[1]?.length ?? 0;
|
||||
return decimalPlaces > 0 ? parseFloat(num.toFixed(decimalPlaces)) : Math.round(num);
|
||||
};
|
||||
const lastDataYear = getPipeTypeLastDataYear();
|
||||
const lastDataYear = resolvePipeTypeColumnEndYear(values.year);
|
||||
const submitList = currentData.map((d) => {
|
||||
const yearlyStatList = [];
|
||||
for (let year = 1995; year <= lastDataYear; year++) {
|
||||
@@ -1803,7 +1810,7 @@ const SewagePipeInp = () => {
|
||||
}
|
||||
|
||||
const columnFormatMap = new Map<string, string>();
|
||||
PipeTypeStatusInpColumn.columns.forEach((col) => {
|
||||
getPipeTypeStatusInpColumn(values.year).columns.forEach((col) => {
|
||||
if (col.fieldName && col.dataFormat) {
|
||||
columnFormatMap.set(col.fieldName, col.dataFormat);
|
||||
}
|
||||
@@ -1819,7 +1826,7 @@ const SewagePipeInp = () => {
|
||||
return decimalPlaces > 0 ? parseFloat(num.toFixed(decimalPlaces)) : Math.round(num);
|
||||
};
|
||||
|
||||
const lastDataYear = getPipeTypeLastDataYear();
|
||||
const lastDataYear = resolvePipeTypeColumnEndYear(values.year);
|
||||
|
||||
const saveList = currentData.map((d) => {
|
||||
const yearlyStatList = [];
|
||||
@@ -2193,7 +2200,11 @@ const SewagePipeInp = () => {
|
||||
return (
|
||||
<TabsContent key={tabKey} value={tabKey}>
|
||||
<DataGrid
|
||||
key={tabKey}
|
||||
key={
|
||||
tabKey === PIPE_TYPE_STATUS_TAB_KEY
|
||||
? `${tabKey}-${lastSearchedYear ?? ""}`
|
||||
: tabKey
|
||||
}
|
||||
columnInfo={gridColumnInfo}
|
||||
rowStartNum={info.rowStartNum}
|
||||
excelExportFileSuffix={info.tabLabel || tabKey}
|
||||
|
||||
Reference in New Issue
Block a user