wr: 시군구 초기화

This commit is contained in:
dongsilove
2026-02-13 20:21:06 +09:00
parent 62fef6bcdc
commit a91bcd9cf7
4 changed files with 25 additions and 6 deletions
@@ -149,9 +149,12 @@ export default function CoMatRvw() {
const getSelCity = (val: string | number) => { const getSelCity = (val: string | number) => {
const cityValue = String(val); // Ensure val is treated as a string const cityValue = String(val); // Ensure val is treated as a string
const data = getCity(cityValue, code.sggCd); const data =
cityValue === "0"
? [{ val: "0", text: "전체" }]
: getCity(cityValue, code.sggCd);
setSelectSgg(data); setSelectSgg(data);
setObjSearch({ city: cityValue, sgg: "" }); setObjSearch({ city: cityValue, sgg: "0" });
}; };
const getSgg = (val: string | number) => { const getSgg = (val: string | number) => {
@@ -192,6 +195,7 @@ export default function CoMatRvw() {
selectClass={""} selectClass={""}
selectArray={code.cityCd || []} selectArray={code.cityCd || []}
onSelectValue={getSelCity} onSelectValue={getSelCity}
value={objSearch.city}
/> />
<SelectBox <SelectBox
className="col-span-2 w-1/3 h-full text-2xl ml-4" className="col-span-2 w-1/3 h-full text-2xl ml-4"
@@ -199,6 +203,7 @@ export default function CoMatRvw() {
selectClass={""} selectClass={""}
selectArray={selectSgg || []} selectArray={selectSgg || []}
onSelectValue={getSgg} onSelectValue={getSgg}
value={objSearch.sgg}
/> />
<div className="col-span-7 w-full"> <div className="col-span-7 w-full">
<div className="flex flex-row items-center"> <div className="flex flex-row items-center">
@@ -61,9 +61,13 @@ export default function RuseCaseMng() {
(item: { val: string; text: string }) => item.val === cityValue (item: { val: string; text: string }) => item.val === cityValue
)?.text; )?.text;
setSidoCd(cityText || ""); setSidoCd(cityText || "");
const data = getCity(cityValue, code.sggCd); const data =
cityValue === "0"
? [{ val: "0", text: "전체" }]
: getCity(cityValue, code.sggCd);
setSelectSgg(data); setSelectSgg(data);
setObjSearch({ city: cityValue, sgg: "" }); setSigunguCd("");
setObjSearch({ city: cityValue, sgg: "0" });
}; };
// 시군구 선택 // 시군구 선택
@@ -199,6 +203,7 @@ export default function RuseCaseMng() {
selectClass={""} selectClass={""}
selectArray={code.cityCd || []} selectArray={code.cityCd || []}
onSelectValue={getSelCity} onSelectValue={getSelCity}
value={objSearch.city}
/> />
<SelectBox <SelectBox
className="col-span-2 w-1/3 h-full text-2xl ml-4" className="col-span-2 w-1/3 h-full text-2xl ml-4"
@@ -206,6 +211,7 @@ export default function RuseCaseMng() {
selectClass={""} selectClass={""}
selectArray={selectSgg || []} selectArray={selectSgg || []}
onSelectValue={getSgg} onSelectValue={getSgg}
value={objSearch.sgg}
/> />
<SelectBox <SelectBox
className="col-span-2 w-1/3 h-full text-2xl ml-4" className="col-span-2 w-1/3 h-full text-2xl ml-4"
@@ -62,7 +62,10 @@ export default function RuseRvwHstry() {
const getSelCity = (val: string | number) => { const getSelCity = (val: string | number) => {
const cityValue = String(val); // Ensure val is treated as a string const cityValue = String(val); // Ensure val is treated as a string
const data = getCity(cityValue, code.sggCd); const data =
cityValue === "0"
? [{ val: "0", text: "전체" }]
: getCity(cityValue, code.sggCd);
setSelectSgg(data); setSelectSgg(data);
setObjSearch({ city: cityValue, sgg: "0" }); setObjSearch({ city: cityValue, sgg: "0" });
}; };
@@ -240,6 +243,7 @@ export default function RuseRvwHstry() {
selectClass={""} selectClass={""}
selectArray={code.cityCd || []} selectArray={code.cityCd || []}
onSelectValue={getSelCity} onSelectValue={getSelCity}
value={objSearch.city}
> >
{""} {""}
</SelectBox> </SelectBox>
@@ -249,6 +253,7 @@ export default function RuseRvwHstry() {
selectClass={""} selectClass={""}
selectArray={selectSgg || []} selectArray={selectSgg || []}
onSelectValue={getSgg} onSelectValue={getSgg}
value={objSearch.sgg}
> >
{""} {""}
</SelectBox> </SelectBox>
@@ -69,7 +69,10 @@ export default function CoSttn() {
const getSelCity = useCallback( const getSelCity = useCallback(
(val: string | number) => { (val: string | number) => {
const cityValue = String(val); const cityValue = String(val);
const data = getCity(cityValue, code.sggCd); const data =
cityValue === "0"
? [{ val: "0", text: "전체" }]
: getCity(cityValue, code.sggCd);
setSelectSgg(data); setSelectSgg(data);
// 시/도를 변경하면 시/군/구는 '전체'("0")로 초기화합니다. // 시/도를 변경하면 시/군/구는 '전체'("0")로 초기화합니다.
setObjSearch({ city: cityValue, sgg: "0" }); setObjSearch({ city: cityValue, sgg: "0" });