|
|
|
@@ -4,7 +4,7 @@ import { useWrStore } from "@/app/store";
|
|
|
|
|
import { btnClass } from "@/app/store/common/code";
|
|
|
|
|
import { rainPageSize } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
|
|
|
|
import { rswtPageSize } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
|
|
|
|
import { excelDownloadNumStyle, yearOptions } from "@/components/lib/func/common";
|
|
|
|
|
import { excelDownloadNumStyle, getCity, yearOptions } from "@/components/lib/func/common";
|
|
|
|
|
import { type SheetParameter } from "@common/business_components/ui";
|
|
|
|
|
import ChkgdModal from "@/components/ui/modal/chkgd/chkgdModal/chkgdModal";
|
|
|
|
|
import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable";
|
|
|
|
@@ -17,16 +17,20 @@ import {
|
|
|
|
|
SearchInput,
|
|
|
|
|
SelectBox,
|
|
|
|
|
UiModal,
|
|
|
|
|
type SelectDataType,
|
|
|
|
|
} from "@common/business_components/ui";
|
|
|
|
|
import ListDiv from "@common/business_components/ui/list_div";
|
|
|
|
|
import { Button, Label } from "@common/components/ui";
|
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
|
|
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
|
|
import { useAlertStore } from "@/src/shared/lib";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
|
|
|
|
const defaultSigunOptions: SelectDataType[] = [{ text: "전체", val: "0" }];
|
|
|
|
|
|
|
|
|
|
export default function Page() {
|
|
|
|
|
const {
|
|
|
|
|
auth,
|
|
|
|
|
code,
|
|
|
|
|
rainChkSttn,
|
|
|
|
|
rswtChkSttn,
|
|
|
|
|
rainChkSttnInit,
|
|
|
|
@@ -36,15 +40,28 @@ export default function Page() {
|
|
|
|
|
isRainSttn,
|
|
|
|
|
isRswtSttn,
|
|
|
|
|
rswtChkPolInit,
|
|
|
|
|
getLaeSeCdCheck,
|
|
|
|
|
} = useWrStore((state) => {
|
|
|
|
|
return state;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const { laeSeCd } = auth;
|
|
|
|
|
const isAllAreaUser = laeSeCd === "0";
|
|
|
|
|
const isLaeSeCdReady =
|
|
|
|
|
laeSeCd === "0" || laeSeCd.length === 2 || laeSeCd.length === 5;
|
|
|
|
|
const fixedSidoValue =
|
|
|
|
|
!isAllAreaUser && laeSeCd?.length ? laeSeCd.slice(0, 2) : "";
|
|
|
|
|
const fixedSigunValue =
|
|
|
|
|
!isAllAreaUser && laeSeCd?.length === 5 ? laeSeCd : "0";
|
|
|
|
|
const [selFcltDiv, setSelFcltDiv] = useState("RNB");
|
|
|
|
|
const [rainPageNation, setRainPageNation] = useState(1);
|
|
|
|
|
const [rswtPageNation, setRswtPageNation] = useState(1);
|
|
|
|
|
const [fcltNm, setFcltNm] = useState<string>("");
|
|
|
|
|
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>(defaultSigunOptions);
|
|
|
|
|
const [objSearch, setObjSearch] = useState<{ city: string; sgg: string }>({
|
|
|
|
|
city: "",
|
|
|
|
|
sgg: "",
|
|
|
|
|
});
|
|
|
|
|
const [isModal, setIsModal] = useState({
|
|
|
|
|
open: false,
|
|
|
|
|
data: {},
|
|
|
|
@@ -52,7 +69,51 @@ export default function Page() {
|
|
|
|
|
const [searchYear, setSearchYear] = useState<string>(
|
|
|
|
|
String(new Date().getFullYear())
|
|
|
|
|
);
|
|
|
|
|
const useInitRef = useRef(false);
|
|
|
|
|
const skipNextSearchRef = useRef(true);
|
|
|
|
|
|
|
|
|
|
const getSelCity = (val: string | number) => {
|
|
|
|
|
const cityValue = String(val);
|
|
|
|
|
if (cityValue === "0") {
|
|
|
|
|
setSelectSgg(defaultSigunOptions);
|
|
|
|
|
setObjSearch({ city: cityValue, sgg: "" });
|
|
|
|
|
} else {
|
|
|
|
|
const data = getCity(cityValue, code.sggCd);
|
|
|
|
|
setSelectSgg(data.length > 0 ? data : defaultSigunOptions);
|
|
|
|
|
const firstSggVal =
|
|
|
|
|
data.find((item) => item.val === "0")?.val || (data[0]?.val ?? "");
|
|
|
|
|
setObjSearch({ city: cityValue, sgg: String(firstSggVal) });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getSgg = (val: string | number) => {
|
|
|
|
|
setObjSearch((prev) => ({ ...prev, sgg: String(val) }));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getConValue = (): string => {
|
|
|
|
|
if (!objSearch.city || objSearch.city === "0") {
|
|
|
|
|
return "0";
|
|
|
|
|
}
|
|
|
|
|
if (objSearch.sgg && objSearch.sgg !== "0") {
|
|
|
|
|
return objSearch.sgg;
|
|
|
|
|
}
|
|
|
|
|
return objSearch.city;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getFixedConValue = useCallback((): string => {
|
|
|
|
|
if (laeSeCd === undefined || laeSeCd === "0") {
|
|
|
|
|
return getConValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return laeSeCd.length === 5 ? laeSeCd : laeSeCd.slice(0, 2);
|
|
|
|
|
}, [laeSeCd, objSearch]);
|
|
|
|
|
|
|
|
|
|
const cellClick = () => {
|
|
|
|
|
if (!isLaeSeCdReady) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const conValue = getFixedConValue();
|
|
|
|
|
if (searchYear) {
|
|
|
|
|
if (selFcltDiv === "RNB") {
|
|
|
|
|
if (fcltNm) {
|
|
|
|
@@ -60,11 +121,11 @@ export default function Page() {
|
|
|
|
|
rainPageNation,
|
|
|
|
|
rainPageSize,
|
|
|
|
|
searchYear,
|
|
|
|
|
laeSeCd,
|
|
|
|
|
conValue,
|
|
|
|
|
fcltNm
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
rainChkSttnInit(rainPageNation, rainPageSize, searchYear, laeSeCd);
|
|
|
|
|
rainChkSttnInit(rainPageNation, rainPageSize, searchYear, conValue);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (fcltNm) {
|
|
|
|
@@ -72,63 +133,108 @@ export default function Page() {
|
|
|
|
|
rswtPageNation,
|
|
|
|
|
rswtPageSize,
|
|
|
|
|
searchYear,
|
|
|
|
|
laeSeCd,
|
|
|
|
|
conValue,
|
|
|
|
|
fcltNm
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
rswtChkSttnInit(rswtPageNation, rswtPageSize, searchYear, laeSeCd);
|
|
|
|
|
rswtChkSttnInit(rswtPageNation, rswtPageSize, searchYear, conValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const rainPageChange = (pageNo: number) => {
|
|
|
|
|
if (!isLaeSeCdReady) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const conValue = getFixedConValue();
|
|
|
|
|
if (pageNo > 0) {
|
|
|
|
|
setRainPageNation(pageNo);
|
|
|
|
|
if (fcltNm) {
|
|
|
|
|
rainChkSttnNmSearch(pageNo, rainPageSize, searchYear, laeSeCd, fcltNm);
|
|
|
|
|
rainChkSttnNmSearch(pageNo, rainPageSize, searchYear, conValue, fcltNm);
|
|
|
|
|
} else {
|
|
|
|
|
rainChkSttnInit(pageNo, rainPageSize, searchYear, laeSeCd);
|
|
|
|
|
rainChkSttnInit(pageNo, rainPageSize, searchYear, conValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const rswtPageChange = (pageNo: number) => {
|
|
|
|
|
if (!isLaeSeCdReady) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const conValue = getFixedConValue();
|
|
|
|
|
if (pageNo > 0) {
|
|
|
|
|
setRswtPageNation(pageNo);
|
|
|
|
|
if (fcltNm) {
|
|
|
|
|
rswtChkNmSttnSearch(pageNo, rainPageSize, searchYear, laeSeCd, fcltNm);
|
|
|
|
|
rswtChkNmSttnSearch(pageNo, rainPageSize, searchYear, conValue, fcltNm);
|
|
|
|
|
} else {
|
|
|
|
|
rswtChkSttnInit(pageNo, rswtPageSize, searchYear, laeSeCd);
|
|
|
|
|
rswtChkSttnInit(pageNo, rswtPageSize, searchYear, conValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getLaeSeCdCheck();
|
|
|
|
|
useInitRef.current = true;
|
|
|
|
|
}, [getLaeSeCdCheck]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isLaeSeCdReady) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (laeSeCd === "0") {
|
|
|
|
|
setSelectSgg(defaultSigunOptions);
|
|
|
|
|
setObjSearch({ city: "0", sgg: "" });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cityValue = laeSeCd.slice(0, 2);
|
|
|
|
|
const sigunOptions = getCity(cityValue, code.sggCd);
|
|
|
|
|
setSelectSgg(sigunOptions.length > 0 ? sigunOptions : defaultSigunOptions);
|
|
|
|
|
setObjSearch({
|
|
|
|
|
city: cityValue,
|
|
|
|
|
sgg: laeSeCd.length === 5 ? laeSeCd : "0",
|
|
|
|
|
});
|
|
|
|
|
}, [laeSeCd, code.sggCd, isLaeSeCdReady]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!useInitRef.current || !isLaeSeCdReady || rainChkSttn.isInit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skipNextSearchRef.current = true;
|
|
|
|
|
if (!rainChkSttn.isInit) {
|
|
|
|
|
isRainSttn(true);
|
|
|
|
|
rainChkSttnInit(
|
|
|
|
|
1,
|
|
|
|
|
rainPageSize,
|
|
|
|
|
new Date().getFullYear().toString(),
|
|
|
|
|
laeSeCd
|
|
|
|
|
getFixedConValue()
|
|
|
|
|
);
|
|
|
|
|
setIsModal({ data: {}, open: false });
|
|
|
|
|
}
|
|
|
|
|
}, [rainChkSttn.isInit, rainChkSttnInit, rainPageSize]);
|
|
|
|
|
}, [rainChkSttn.isInit, rainChkSttnInit, rainPageSize, isLaeSeCdReady, getFixedConValue, isRainSttn]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!useInitRef.current || !isLaeSeCdReady || rswtChkSttn.isInit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skipNextSearchRef.current = true;
|
|
|
|
|
if (!rswtChkSttn.isInit) {
|
|
|
|
|
setIsModal({ data: {}, open: false });
|
|
|
|
|
rswtChkSttnInit(
|
|
|
|
|
1,
|
|
|
|
|
rswtPageSize,
|
|
|
|
|
new Date().getFullYear().toString(),
|
|
|
|
|
laeSeCd
|
|
|
|
|
getFixedConValue()
|
|
|
|
|
);
|
|
|
|
|
isRswtSttn(true);
|
|
|
|
|
}
|
|
|
|
|
}, [rswtChkSttn.isInit, rswtChkSttnInit, rswtPageSize]);
|
|
|
|
|
}, [rswtChkSttn.isInit, rswtChkSttnInit, rswtPageSize, isLaeSeCdReady, getFixedConValue, isRswtSttn]);
|
|
|
|
|
|
|
|
|
|
const handleClick = useCallback(
|
|
|
|
|
(data: any) => {
|
|
|
|
@@ -191,6 +297,42 @@ export default function Page() {
|
|
|
|
|
<div className="col-span-4">
|
|
|
|
|
<SearchDiv>
|
|
|
|
|
<SearchFormLeft>
|
|
|
|
|
<div className="col-span-2 flex flex-row space-x-2">
|
|
|
|
|
<Label className="w-28 mt-2 text-xl text-gray-600">
|
|
|
|
|
{"시도"}
|
|
|
|
|
</Label>
|
|
|
|
|
<SelectBox
|
|
|
|
|
className="w-full h-full text-2xl"
|
|
|
|
|
label=""
|
|
|
|
|
selectClass=""
|
|
|
|
|
selectArray={
|
|
|
|
|
!isAllAreaUser && fixedSidoValue
|
|
|
|
|
? code.cityCd.filter((item) => item.val === fixedSidoValue)
|
|
|
|
|
: code.cityCd
|
|
|
|
|
}
|
|
|
|
|
value={objSearch.city || "0"}
|
|
|
|
|
onSelectValue={getSelCity}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="col-span-2 flex flex-row space-x-2">
|
|
|
|
|
<Label className="w-28 mt-2 text-xl text-gray-600">
|
|
|
|
|
{"시군구"}
|
|
|
|
|
</Label>
|
|
|
|
|
<SelectBox
|
|
|
|
|
className="w-full h-full text-2xl"
|
|
|
|
|
label=""
|
|
|
|
|
selectClass=""
|
|
|
|
|
selectArray={
|
|
|
|
|
!isAllAreaUser && laeSeCd?.length === 5
|
|
|
|
|
? (selectSgg || defaultSigunOptions).filter(
|
|
|
|
|
(item) => item.val === "0" || item.val === fixedSigunValue
|
|
|
|
|
)
|
|
|
|
|
: selectSgg || defaultSigunOptions
|
|
|
|
|
}
|
|
|
|
|
value={objSearch.sgg || "0"}
|
|
|
|
|
onSelectValue={getSgg}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="col-span-2 flex flex-row space-x-2">
|
|
|
|
|
<Label className="w-48 mt-2 text-xl text-gray-600">
|
|
|
|
|
{"지도점검년도"}
|
|
|
|
|