fo: 년도 초기화 및 exceldown시 조회데이터 없는 경우 처리 3본
This commit is contained in:
@@ -60,6 +60,10 @@ export default function DashBoard() {
|
||||
const [sidoValue, setSidoValue] = useState<string>('0');
|
||||
const [sigunValue, setSigunValue] = useState<string>('0');
|
||||
const { isInit, selectSearchYear, btnClass, selectSidoData, selectSigunData, } = Common;
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
const { planFcltyList } = PlanFclty;
|
||||
const { operationalStatusList } = OperationStatus;
|
||||
const { excelList } = RainManage;
|
||||
@@ -75,7 +79,7 @@ export default function DashBoard() {
|
||||
|
||||
/******************선택된 데이터******************/
|
||||
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || '0'); // 연도
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear); // 연도
|
||||
// 시설명
|
||||
const [fcltyList, setFcltyList] = useState<FacilityType>({
|
||||
bscFctCd: '11000SW001R',
|
||||
@@ -283,7 +287,7 @@ export default function DashBoard() {
|
||||
trtFrfNm: '표준활성슬러지법, MLE, A2O',
|
||||
efflWqltStndrdNm: '500톤 이상(Ⅲ지역)'
|
||||
});
|
||||
setSearchYear(selectSearchYear[0]?.val || '0');
|
||||
setSearchYear(defaultSearchYear);
|
||||
searchFcltyList.bscFctNm = '난지';
|
||||
|
||||
setSidoValue('0');
|
||||
|
||||
@@ -37,6 +37,11 @@ export default function FacilityPrecipitation() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
labelArray,
|
||||
} = FacilityPrecipitationSearch;
|
||||
@@ -90,7 +95,7 @@ export default function FacilityPrecipitation() {
|
||||
// 시설상태
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
// 조회기간
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
|
||||
|
||||
/**
|
||||
* 페이지 함수
|
||||
@@ -102,7 +107,7 @@ export default function FacilityPrecipitation() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYear(selectSearchYear[0]?.val || "0");
|
||||
setSearchYear(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -111,7 +116,7 @@ export default function FacilityPrecipitation() {
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
searchFacilityPrecipitationList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchFacilityPrecipitationList(1, 10, defaultSearchYear);
|
||||
}
|
||||
|
||||
// 모달 닫기
|
||||
@@ -134,9 +139,9 @@ export default function FacilityPrecipitation() {
|
||||
useEffect(() => {
|
||||
if (!isInit) {
|
||||
initializeCommonData();
|
||||
searchFacilityPrecipitationList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchFacilityPrecipitationList(1, 10, defaultSearchYear);
|
||||
}
|
||||
}, [isInit, initializeCommonData, searchFacilityPrecipitationList, selectSearchYear]);
|
||||
}, [isInit, initializeCommonData, searchFacilityPrecipitationList, defaultSearchYear]);
|
||||
|
||||
useEffect(() => {
|
||||
if (excelList && excelList.length > 0) {
|
||||
@@ -270,4 +275,4 @@ export default function FacilityPrecipitation() {
|
||||
)}
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ export default function ProcessFacilitySearch() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
mainLabelArray,
|
||||
upHeadList1,
|
||||
@@ -57,7 +62,7 @@ export default function ProcessFacilitySearch() {
|
||||
const [upheadList, setUpheadList] = useState<TableUpperProps[]>(upHeadList1);
|
||||
const [fcltyName, setFcltyName] = useState<string>("");
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(defaultSearchYear);
|
||||
const [fcltCpct, setFcltCpct] = useState<string>("0");
|
||||
|
||||
// 모달 상태 추가
|
||||
@@ -96,7 +101,7 @@ export default function ProcessFacilitySearch() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYearValue(selectSearchYear[0]?.val || "0");
|
||||
setSearchYearValue(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -241,4 +246,4 @@ export default function ProcessFacilitySearch() {
|
||||
)}
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"use client"
|
||||
import { useFoStore } from "@/app/store";
|
||||
import type { TableUpperProps } from "@/app/store/common";
|
||||
import type { ExcelType } from "@/app/store/flowRate";
|
||||
// import type { ExcelType } from "@/app/store/flowRate";
|
||||
import { ContentsDiv, downloadExcelFormat, MainDiv, SearchBaseForm, SearchInput, SelectBox, Title, UiModal, UiTable, type ReturnType } from "@common/business_components";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import LoadingOverlay from "@common/business_components/ui/loadingBar";
|
||||
@@ -38,6 +38,11 @@ export default function ProcessFacilitySearch() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
flowRateSearchLabelArray
|
||||
} = FlowRateSearch;
|
||||
@@ -57,17 +62,17 @@ export default function ProcessFacilitySearch() {
|
||||
const [fcltCpct, setFcltCpct] = useState<string>("0");
|
||||
const [fcltyName, setFcltyName] = useState<string>("");
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(defaultSearchYear);
|
||||
// const [widthSize, setWidthSize] = useState<string>("w-[120%]");
|
||||
const [upheadList, setUpheadList] = useState<TableUpperProps[]>(upHeadList1);
|
||||
const [resetPage, setResetPage] = useState<boolean>(false);
|
||||
const prevExcelListRef = useRef<ExcelType[] | null>(null);
|
||||
// const prevExcelListRef = useRef<ExcelType[] | null>(null);
|
||||
|
||||
// 모달 상태 추가
|
||||
const [selectedRow, setSelectedRow] = useState<number | null>(null);
|
||||
const [fcltyNm, setFcltyNm] = useState<string>("");
|
||||
const [fcltyCd, setFcltyCd] = useState<string>("");
|
||||
const [excelTrigger, setExcelTrigger] = useState<boolean>(false);
|
||||
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
|
||||
const [initTrigger, setInitTrigger] = useState<boolean>(false);
|
||||
|
||||
const searchFlowRate = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=20) => {
|
||||
@@ -99,7 +104,7 @@ export default function ProcessFacilitySearch() {
|
||||
// setWidthSize("w-[120%]");
|
||||
setUpheadList(upHeadList1)
|
||||
// 상태값 설정
|
||||
setSearchYearValue(selectSearchYear[0]?.val || "0");
|
||||
setSearchYearValue(defaultSearchYear);
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
// SearchInputSelect 초기화
|
||||
@@ -147,15 +152,17 @@ export default function ProcessFacilitySearch() {
|
||||
}, [isInit, initializeCommonData, searchFlowRateList, selectSearchYear, searchFlowRate, initTrigger]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!excelTrigger) return;
|
||||
if(!isExcelDownClick) return;
|
||||
|
||||
if (excelList && excelList.length > 0) {
|
||||
downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] });
|
||||
} else if (prevExcelListRef.current && prevExcelListRef.current.length > 0) {
|
||||
alert('다운받을 데이터가 없습니다.');
|
||||
}
|
||||
prevExcelListRef.current = excelList;
|
||||
}, [excelList, excelTrigger]);
|
||||
const timer = setTimeout(() => {
|
||||
if (excelList && excelList.length > 0) {
|
||||
downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] });
|
||||
} else {
|
||||
alert('조회된 결과가 없습니다.');
|
||||
}
|
||||
}, 1000); // 약간의 지연을 두고 다운로드 실행
|
||||
return () => clearTimeout(timer);
|
||||
}, [excelList, isExcelDownClick]);
|
||||
|
||||
const ref = useRef<ReturnType>({
|
||||
partValue: '',
|
||||
@@ -194,7 +201,7 @@ export default function ProcessFacilitySearch() {
|
||||
}
|
||||
|
||||
searchFlowRate(ref.current, 1, 10000);
|
||||
setExcelTrigger(true);
|
||||
setIsExcelDownClick(true);
|
||||
}, [searchFlowRate]);
|
||||
|
||||
const total = flowRateCount;
|
||||
|
||||
@@ -41,6 +41,11 @@ export default function PlanSewage() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
labelArray,
|
||||
} = PlanSewageSearch;
|
||||
@@ -85,7 +90,7 @@ export default function PlanSewage() {
|
||||
// 시설상태
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
// 조회기간
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
|
||||
|
||||
const [initTrigger, setInitTrigger] = useState<boolean>(false);
|
||||
|
||||
@@ -100,7 +105,7 @@ export default function PlanSewage() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYear(selectSearchYear[0]?.val || "0");
|
||||
setSearchYear(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -168,7 +173,7 @@ export default function PlanSewage() {
|
||||
setInitTrigger(true);
|
||||
}
|
||||
}
|
||||
}, [isInit, initializeCommonData, searchPlanSewageList, selectSearchYear, initTrigger, searchPlanSewage]);
|
||||
}, [isInit, initializeCommonData, initTrigger, searchPlanSewage]);
|
||||
|
||||
const chkVal = useCallback((returntype: ReturnType) => {
|
||||
// setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]")
|
||||
@@ -241,4 +246,4 @@ export default function PlanSewage() {
|
||||
</ListDiv>
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ export default function ProcessArea() {
|
||||
btnClass,
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
processFacilityLabelArray,
|
||||
} = ProcessAreaSearch;
|
||||
@@ -64,7 +69,7 @@ export default function ProcessArea() {
|
||||
const [fcltyCd, setFcltyCd] = useState<string>("");
|
||||
|
||||
const [resetPage, setResetPage] = useState<boolean>(false);
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYearValue, setSearchYearValue] = useState<string>(defaultSearchYear);
|
||||
|
||||
const ref = useRef<ReturnType>({
|
||||
partValue: '',
|
||||
@@ -95,8 +100,8 @@ export default function ProcessArea() {
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
setSearchYearValue(selectSearchYear[0]?.val || "0");
|
||||
searchProcessAreaList(1, 10, '', '', selectSearchYear[0]?.val || "0");
|
||||
setSearchYearValue(defaultSearchYear);
|
||||
searchProcessAreaList(1, 10, '', '', defaultSearchYear);
|
||||
}
|
||||
|
||||
// 셀 클릭 시 모달 표시
|
||||
@@ -116,9 +121,9 @@ export default function ProcessArea() {
|
||||
useEffect(() => {
|
||||
if (!isInit) {
|
||||
initializeCommonData();
|
||||
searchProcessAreaList(1, 10, '', '', selectSearchYear[0]?.val || "0");
|
||||
searchProcessAreaList(1, 10, '', '', defaultSearchYear);
|
||||
}
|
||||
}, [isInit, initializeCommonData, searchProcessAreaList]);
|
||||
}, [isInit, initializeCommonData, searchProcessAreaList, defaultSearchYear]);
|
||||
|
||||
useEffect(() => {
|
||||
if (excelList && excelList.length > 0) {
|
||||
@@ -200,4 +205,4 @@ export default function ProcessArea() {
|
||||
)}
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ export default function Rdi() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
labelArray,
|
||||
} = RdiSearch;
|
||||
@@ -83,7 +88,7 @@ export default function Rdi() {
|
||||
// 시설상태
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
// 조회기간
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
|
||||
// 엑셀 다운로드 트리거
|
||||
const [isInitExcelDownload, setIsInitExcelDownload] = useState<boolean>(false);
|
||||
|
||||
@@ -99,7 +104,7 @@ export default function Rdi() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYear(selectSearchYear[0]?.val || "0");
|
||||
setSearchYear(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -241,4 +246,4 @@ export default function Rdi() {
|
||||
</ContentsDiv>
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ export default function PlanSewage() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
labelArray,
|
||||
} = SewageOccurSearch;
|
||||
@@ -93,9 +98,9 @@ export default function PlanSewage() {
|
||||
// 시설상태
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
// 조회기간
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
|
||||
// 엑셀다운로드 트리거
|
||||
const [isInitExcelDownload, setIsInitExcelDownload] = useState<boolean>(false);
|
||||
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
|
||||
|
||||
/**
|
||||
* 페이지 함수
|
||||
@@ -107,7 +112,7 @@ export default function PlanSewage() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYear(selectSearchYear[0]?.val || "0");
|
||||
setSearchYear(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -116,7 +121,7 @@ export default function PlanSewage() {
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
searchSewageOccurList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchSewageOccurList(1, 10, defaultSearchYear);
|
||||
}
|
||||
|
||||
// 모달 닫기
|
||||
@@ -139,12 +144,12 @@ export default function PlanSewage() {
|
||||
useEffect(() => {
|
||||
if (!isInit) {
|
||||
initializeCommonData();
|
||||
searchSewageOccurList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchSewageOccurList(1, 10, defaultSearchYear);
|
||||
}
|
||||
}, [isInit, initializeCommonData, searchSewageOccurList, selectSearchYear]);
|
||||
}, [isInit, initializeCommonData, searchSewageOccurList, defaultSearchYear]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!isInitExcelDownload) return ;
|
||||
if(!isExcelDownClick) return ;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
if (excelList && excelList.length > 0) {
|
||||
@@ -154,11 +159,13 @@ export default function PlanSewage() {
|
||||
sheetNameArray: ['오수발생량 추정'],
|
||||
headerRange: 'A1:O1'
|
||||
});
|
||||
} else {
|
||||
alert("조회된 결과가 없습니다.");
|
||||
}
|
||||
}, 500); // 약간의 지연을 두고 다운로드 실행
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [excelList, isInit, isInitExcelDownload]);
|
||||
}, [excelList, isInit, isExcelDownClick]);
|
||||
|
||||
/**
|
||||
* 콜백함수
|
||||
@@ -213,7 +220,7 @@ export default function PlanSewage() {
|
||||
}
|
||||
}
|
||||
searchFacilityPrecipitation(ref.current, 1, 5000);
|
||||
setIsInitExcelDownload(true);
|
||||
setIsExcelDownClick(true);
|
||||
}, [searchFacilityPrecipitation]);
|
||||
|
||||
// 페이지 변경
|
||||
|
||||
@@ -50,6 +50,11 @@ export default function UnderWaterInput() {
|
||||
btnClass
|
||||
} = Common;
|
||||
|
||||
const defaultSearchYear =
|
||||
selectSearchYear.find((item) => item.selected)?.val ||
|
||||
selectSearchYear[0]?.val ||
|
||||
"0";
|
||||
|
||||
const {
|
||||
labelArray,
|
||||
} = UnderWaterSearch;
|
||||
@@ -98,9 +103,9 @@ export default function UnderWaterInput() {
|
||||
// 시설상태
|
||||
const [operationValue, setOperationValue] = useState<string>("0");
|
||||
// 조회기간
|
||||
const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0");
|
||||
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
|
||||
// 엑셀다운로드 트리거
|
||||
const [isMount, setIsMount] = useState<boolean>(false);
|
||||
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
|
||||
|
||||
/**
|
||||
* 페이지 함수
|
||||
@@ -112,7 +117,7 @@ export default function UnderWaterInput() {
|
||||
// 상태값 설정
|
||||
setFcltCpct(selectUpdownData[0]?.val || "0");
|
||||
setOperationValue(selectOperationData[0]?.val || "0");
|
||||
setSearchYear(selectSearchYear[0]?.val || "0");
|
||||
setSearchYear(defaultSearchYear);
|
||||
// SearchInputSelect 초기화
|
||||
setFcltyName("");
|
||||
if (searchInputRef.current) {
|
||||
@@ -121,7 +126,7 @@ export default function UnderWaterInput() {
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
searchUnderWaterList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchUnderWaterList(1, 10, defaultSearchYear);
|
||||
}
|
||||
|
||||
// 모달 닫기
|
||||
@@ -144,12 +149,12 @@ export default function UnderWaterInput() {
|
||||
useEffect(() => {
|
||||
if (!isInit) {
|
||||
initializeCommonData();
|
||||
searchUnderWaterList(1, 10, selectSearchYear[0]?.val || "0");
|
||||
searchUnderWaterList(1, 10, defaultSearchYear);
|
||||
}
|
||||
}, [isInit, initializeCommonData, searchUnderWaterList, selectSearchYear]);
|
||||
}, [isInit, initializeCommonData, searchUnderWaterList, defaultSearchYear]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!isMount) return ;
|
||||
if(!isExcelDownClick) return ;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
if (excelList && excelList.length > 0) {
|
||||
@@ -159,10 +164,12 @@ export default function UnderWaterInput() {
|
||||
sheetNameArray: ['지하수유입량 추정'],
|
||||
headerRange: 'A1:O1'
|
||||
});
|
||||
} else {
|
||||
alert("조회된 결과가 없습니다.");
|
||||
}
|
||||
}, 1000); // 약간의 지연을 두고 다운로드 실행
|
||||
return () => clearTimeout(timer);
|
||||
}, [excelList, isMount]);
|
||||
}, [excelList, isExcelDownClick]);
|
||||
|
||||
/**
|
||||
* 콜백함수
|
||||
@@ -217,7 +224,7 @@ export default function UnderWaterInput() {
|
||||
}
|
||||
}
|
||||
searchFacilityPrecipitation(ref.current, 1, 5000);
|
||||
setIsMount(true);
|
||||
setIsExcelDownClick(true);
|
||||
}, [searchFacilityPrecipitation]);
|
||||
|
||||
// 페이지 변경
|
||||
@@ -276,4 +283,4 @@ export default function UnderWaterInput() {
|
||||
)}
|
||||
</MainDiv>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import { getFetch, getFetchAreaList } from "@/app/components/api";
|
||||
export type SelectDataType = {
|
||||
text: string;
|
||||
val: string;
|
||||
selected?: boolean;
|
||||
hidden?: boolean;
|
||||
}
|
||||
// grid header
|
||||
export type TableUpperProps = {
|
||||
@@ -160,23 +162,21 @@ const selectFacilityPartData: SelectDataType[] = [
|
||||
const getYearData = () => {
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = today.getMonth() + 1;
|
||||
// const month = today.getMonth() + 1;
|
||||
|
||||
// 상반기(6월까지)는 2년 전, 하반기는 1년 전부터 시작
|
||||
const startYear = month <= 6 ? (year - 2) : (year - 1);
|
||||
// const startYear = month <= 6 ? (year - 2) : (year - 1);
|
||||
const startYear = year - 1;
|
||||
|
||||
const year1 = startYear;
|
||||
const year2 = startYear - 1;
|
||||
const year3 = startYear - 2;
|
||||
const year4 = startYear - 3;
|
||||
const year5 = startYear - 4;
|
||||
return [
|
||||
{ text: year1 + "년", val: year1.toString() },
|
||||
{ text: year2 + "년", val: year2.toString() },
|
||||
{ text: year3 + "년", val: year3.toString() },
|
||||
{ text: year4 + "년", val: year4.toString() },
|
||||
{ text: year5 + "년", val: year5.toString() },
|
||||
]
|
||||
// 최근 10개년도 제공 (기본값: 첫 번째 항목 선택)
|
||||
return Array.from({ length: 10 }, (_, index) => {
|
||||
const targetYear = startYear - index;
|
||||
return {
|
||||
text: `${targetYear}년`,
|
||||
val: targetYear.toString(),
|
||||
selected: index === 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const selectSearchYear: SelectDataType[] = getYearData();
|
||||
@@ -486,4 +486,4 @@ export const CommonReducer = (
|
||||
}
|
||||
}
|
||||
|
||||
export type CommonStore = CommonType & CommonAction;
|
||||
export type CommonStore = CommonType & CommonAction;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// selectBox
|
||||
|
||||
import { Label } from "@common/components";
|
||||
import React, { useEffect, useState } from "react";
|
||||
// import React, { useEffect, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
@@ -15,6 +16,7 @@ interface SelectBox1 {
|
||||
text: string;
|
||||
val: string | number;
|
||||
hidden?: boolean;
|
||||
selected?: boolean;
|
||||
}
|
||||
|
||||
const SelectBox = React.forwardRef<
|
||||
@@ -51,18 +53,22 @@ const SelectBox = React.forwardRef<
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
// hidden이 true인 항목만 드롭다운에서 제외
|
||||
const visibleItems = selectArray.filter((item) => !item.hidden);
|
||||
const selectedItem = visibleItems.find((item) => item.selected);
|
||||
|
||||
const resolvedValue =
|
||||
value === undefined && selectedItem ? selectedItem.val : value;
|
||||
|
||||
// 현재 값이 hidden 항목이거나 빈 값인 경우 undefined로 설정하여 placeholder가 표시되도록 함
|
||||
const currentValue =
|
||||
value !== undefined &&
|
||||
resolvedValue !== undefined &&
|
||||
hiddenItem &&
|
||||
(String(value) === String(hiddenItem.val) ||
|
||||
value === "" ||
|
||||
value === "0" ||
|
||||
value === 0)
|
||||
(String(resolvedValue) === String(hiddenItem.val) ||
|
||||
resolvedValue === "" ||
|
||||
resolvedValue === "0" ||
|
||||
resolvedValue === 0)
|
||||
? undefined
|
||||
: value !== undefined
|
||||
? String(value)
|
||||
: resolvedValue !== undefined
|
||||
? String(resolvedValue)
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user