156 lines
4.8 KiB
TypeScript
156 lines
4.8 KiB
TypeScript
// 하수맨홀
|
|
|
|
import React from 'react';
|
|
import { YearRangeSelectBox } from '@/components/ui/YearRangeSelectBox';
|
|
import { Button, Input, Label } from '@common/components';
|
|
import { MS_SWAGE_MHL_USE_CODES } from '../components/common/table';
|
|
import { SelectBox } from '@common/business_components/ui';
|
|
import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectBox';
|
|
import useSearchModalStore from '../../../store/useSearchModalStore';
|
|
import { useSearchModal, type SearchModalProps } from './useSearchModal';
|
|
|
|
interface swageMhlCqlFiltersParams {
|
|
ctpvCd: string;
|
|
sggCd: string;
|
|
yearFilter: { start: string; end: string };
|
|
start1: string;
|
|
end1: string;
|
|
var1: string;
|
|
todayYear: string;
|
|
todayMonth: string;
|
|
todayDate: string;
|
|
getDateString: (year: string, month: string, day: string, defaultDate: string) => string;
|
|
}
|
|
export const swageMhlCqlFilters = (params: swageMhlCqlFiltersParams) => {
|
|
const {
|
|
ctpvCd, sggCd,
|
|
yearFilter,
|
|
start1, end1,
|
|
var1,
|
|
todayYear, todayMonth, todayDate,
|
|
getDateString
|
|
} = params;
|
|
|
|
const cqlFilters: string[] = [];
|
|
// 시도, 시군구
|
|
if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`);
|
|
else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`);
|
|
// // 설치년도 범위
|
|
const startDate = getDateString(
|
|
yearFilter.start,
|
|
'',
|
|
'',
|
|
"19000101",
|
|
);
|
|
const endDate = getDateString(
|
|
yearFilter.end,
|
|
'',
|
|
'',
|
|
`${todayYear}${todayMonth}${todayDate}`,
|
|
);
|
|
cqlFilters.push(
|
|
`instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`,
|
|
);
|
|
if (var1) cqlFilters.push(`usg_cd='${var1}'`);
|
|
// 구경(mm) 범위
|
|
if (start1 && end1) cqlFilters.push(`swage_mhL_diam_vl BETWEEN ${start1} AND ${end1}`);
|
|
else if (start1) cqlFilters.push(`swage_mhL_diam_vl >= ${start1}`);
|
|
else if (end1) cqlFilters.push(`swage_mhL_diam_vl <= ${end1}`);
|
|
|
|
return cqlFilters;
|
|
};
|
|
|
|
const SwageMhl: React.FC<SearchModalProps> = (props) => {
|
|
const {
|
|
var1, setVar1,
|
|
start1, setStart1, end1, setEnd1,
|
|
ctpvCd, setCtpvCd,
|
|
sggCd, setSggCd,
|
|
yearFilter, setYearFilter,
|
|
} = useSearchModalStore();
|
|
const { handleSearch } = useSearchModal(props);
|
|
|
|
return (
|
|
<div className="mb-3">
|
|
<div className="mb-2 flex items-center">
|
|
<CtpvSggPrcsFcltSelectBox
|
|
sido={ctpvCd}
|
|
sigungu={sggCd}
|
|
onSidoChange={(sidoId: string) => {
|
|
setCtpvCd(sidoId);
|
|
setSggCd("0");
|
|
}}
|
|
onSigunguChange={setSggCd}
|
|
/>
|
|
{/* 설치년도 */}
|
|
<YearRangeSelectBox
|
|
start={yearFilter.start}
|
|
end={yearFilter.end}
|
|
onChange={(range) =>
|
|
setYearFilter({
|
|
...yearFilter,
|
|
start: range.start,
|
|
end: range.end,
|
|
})
|
|
}
|
|
startLabel="설치년도"
|
|
endLabel=""
|
|
/>
|
|
{/* 용도 */}
|
|
<Label className="text-xl text-gray-600 font-medium whitespace-nowrap mr-2">용도</Label>
|
|
<SelectBox
|
|
className="w-48 mr-8"
|
|
selectClass="rounded-lg bg-white text-xl"
|
|
label=""
|
|
selectArray={[{ val: "0", text: "전체" }, ...MS_SWAGE_MHL_USE_CODES]}
|
|
value={var1}
|
|
onSelectValue={(val) => {
|
|
setVar1(String(val));
|
|
}}
|
|
selectContentClass="z-[101]"
|
|
/>
|
|
{/* 하수맨홀 구경 */}
|
|
<Label className="text-xl text-gray-600 font-medium whitespace-nowrap mr-2">구경(mm)</Label>
|
|
<Input
|
|
className="w-[100px] !text-xl placeholder:text-center"
|
|
placeholder="입력"
|
|
value={start1}
|
|
onChange={(e) => {
|
|
// 숫자만 입력 허용
|
|
const val = e.target.value.replace(/[^0-9]/g, "");
|
|
setStart1(val);
|
|
}}
|
|
onKeyDown={(e) => {
|
|
if (e.key === 'Enter') {
|
|
e.preventDefault(); // Enter 키 기본 동작 방지
|
|
handleSearch();
|
|
}
|
|
}}
|
|
/>
|
|
<span className="mx-2 text-xl font-semibold">~</span>
|
|
<Input
|
|
className="mr-8 w-[100px] !text-xl placeholder:text-center"
|
|
placeholder="입력"
|
|
value={end1}
|
|
onChange={(e) => {
|
|
// 숫자만 입력 허용
|
|
const val = e.target.value.replace(/[^0-9]/g, "");
|
|
setEnd1(val);
|
|
}}
|
|
onKeyDown={(e) => {
|
|
if (e.key === 'Enter') {
|
|
e.preventDefault(); // Enter 키 기본 동작 방지
|
|
handleSearch();
|
|
}
|
|
}}
|
|
/>
|
|
{/* 조회 버튼 */}
|
|
<div className="flex-1 flex justify-end">
|
|
<Button className="text-base py-2" onClick={handleSearch}>조회</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default React.memo(SwageMhl); |