fix: reportTab 시도, 시군구 타입 수정
This commit is contained in:
@@ -4,7 +4,7 @@ import { Button, Label } from '@common/components';
|
||||
import { YearRangeSelectBox } from '@/components/ui/YearRangeSelectBox';
|
||||
import { SelectBox, UiTable } from '@common/business_components/ui';
|
||||
import LoadingOverlay from '@/components/ui/LoadingBar';
|
||||
import { addFileName, flattenFolders, getFileDownload, getDcTree, useDcTree, reportGubuns } from './searchModalReportApi';
|
||||
import { addFileName, flattenFolders, getFileDownload, useDcTree, reportGubuns } from './searchModalReportApi';
|
||||
import useStore from '../../../store/useStore';
|
||||
import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectBox';
|
||||
|
||||
@@ -37,8 +37,8 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
const [tableCount, setTableCount] = useState(0);
|
||||
const [curPage, setCurPage] = useState(1);
|
||||
const [yearFilter, setYearFilter] = useState({ start: "", end: "" });
|
||||
const [ctpvCd, setCtpvCd] = useState(0);
|
||||
const [sggCd, setSggCd] = useState(0);
|
||||
const [ctpvCd, setCtpvCd] = useState('0');
|
||||
const [sggCd, setSggCd] = useState('0');
|
||||
const [reportGubun, setReportGubun] = useState("0");
|
||||
// const [gubun, setGubun] = useState("");
|
||||
|
||||
@@ -49,8 +49,8 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
|
||||
useEffect(() => {
|
||||
// filterParams 초기화
|
||||
setCtpvCd(0);
|
||||
setSggCd(0);
|
||||
setCtpvCd('0');
|
||||
setSggCd('0');
|
||||
setReportGubun('0');
|
||||
setYearFilter({ start: "", end: "" });
|
||||
setShowTable(false);
|
||||
@@ -62,8 +62,8 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
let newCtpvCd = ctpv.find((n) => n.name === ctpvNm)?.id || 0;
|
||||
let newSggCd = sgg.find((n) => n.name === sggNm)?.id || 0;
|
||||
const newCtpvCd = ctpv.find((n) => n.text === ctpvNm)?.val || '0';
|
||||
const newSggCd = sgg.find((n) => n.text === sggNm)?.val || '0';
|
||||
|
||||
setCtpvCd(newCtpvCd);
|
||||
setSggCd(newSggCd);
|
||||
@@ -84,9 +84,9 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
if (showTable) fetchFilteredData();
|
||||
}, [curPage]);
|
||||
|
||||
const handleCtpvCdChange = (sidoId: number) => {
|
||||
const handleCtpvCdChange = (sidoId: string) => {
|
||||
setCtpvCd(sidoId);
|
||||
setSggCd(0);
|
||||
setSggCd('0');
|
||||
}
|
||||
|
||||
// 조회 버튼 클릭 시 1페이지로 이동 및 데이터 초기화
|
||||
@@ -122,17 +122,18 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
console.log("필터링 전 보고서 데이터:", filterReportData);
|
||||
console.log('ctpv, sgg, ctpvCd, sggCd', ctpv, sgg, ctpvCd, sggCd);
|
||||
|
||||
if (ctpvCd) { // 시도검색
|
||||
if (ctpvCd !== '0') { // 시도검색
|
||||
console.log('시도 실행되나');
|
||||
const sidoOption = ctpv.find((n) => String(n.id) === String(ctpvCd));
|
||||
console.log('ctpvCd.trim()', ctpvCd.trim());
|
||||
const sidoOption = ctpv.find((n) => n.val.trim() === ctpvCd.trim());
|
||||
console.log('sidoOption', sidoOption)
|
||||
filterReportData = filterReportData.filter(item => item.sido === sidoOption?.name);
|
||||
filterReportData = filterReportData.filter(item => item.sido === sidoOption?.text);
|
||||
console.log('시도 필터링 후:', filterReportData);
|
||||
}
|
||||
if (sggCd) { // 시군구검색
|
||||
if (sggCd !== '0') { // 시군구검색
|
||||
console.log('시군구 실행되나');
|
||||
const sigunguOption = sgg.find((n) => String(n.id) === String(sggCd));
|
||||
filterReportData = filterReportData.filter(item => item.sigungu === sigunguOption?.name);
|
||||
const sigunguOption = sgg.find((n) => String(n.val) === String(sggCd));
|
||||
filterReportData = filterReportData.filter(item => item.sigungu === sigunguOption?.text);
|
||||
console.log('시군구 필터링 후:', filterReportData);
|
||||
}
|
||||
if (reportGubun !== "0") { // 보고서구분검색
|
||||
@@ -186,7 +187,7 @@ const ReportTab: React.FC<ReportTabProps> = ({ open, isSearch = true, ctpvNm, sg
|
||||
<CtpvSggPrcsFcltSelectBox
|
||||
sido={ctpvCd}
|
||||
sigungu={sggCd}
|
||||
onSidoChange={(sidoId: number) => { handleCtpvCdChange(sidoId) }}
|
||||
onSidoChange={(sidoId: string) => { handleCtpvCdChange(sidoId) }}
|
||||
onSigunguChange={setSggCd}
|
||||
setIsLoading={setIsLoading}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user