로그인 사용자 건축물 등록 시도코드 적용/ 하수처리장 지도PopUp data 오류 슈ㅜ정/지도점검 오류 수정

This commit is contained in:
leedj312
2025-09-22 17:17:30 +09:00
parent 64e5c4c0fb
commit 0d9ebcbd55
7 changed files with 378 additions and 202 deletions
@@ -55,12 +55,14 @@ export default function MapFeaturePopup() {
useEffect(() => {
console.log(' layerNm ' , layerNm)
if (isFeatureCd && layerNm) {
if (layerNm === "tb_wr_bdst_ruse_fclt") {
setIsDetail(isFeatureCd);
} else if (layerNm === "tb_il_swage_prcs_fclt") {
pbnMapDetaile(isFeatureCd).then((res) => {
setIsDetail(res);
console.log('res', res)
setIsDetail([res]);
});
} else if (layerNm === "tb_wr_rnwtr_utztn_fclt") {
rainMapDetile(isFeatureCd).then((res) => {
@@ -255,12 +255,14 @@ export default function Page() {
if (selFcltDiv === "RNB") {
if (updateRainDetail && updateRainDetail.length > 0) {
rainChkDetilUpdate(updateRainDetail, searchYear);
setUpdateRainDetail([])
} else {
toast.error("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
}
} else {
if (updateRswtDetail && updateRswtDetail.length > 0) {
rswtChkDetilsUpdate(updateRswtDetail, searchYear);
setUpdateRSwtDetail([])
} else {
toast.error("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
}
@@ -1,201 +1,266 @@
import { getFetch } from "@/components/lib/api";
import { TEST_UUID, type customRainBdst } from "../rainReg";
import { TEST_UUID, type customRainBdst } from "../rainReg";
import type { customHtdflBdst } from "../htdflReg";
import type { customRswtBdst } from "../rswtReg";
import type { TableUpperProps } from "@/app/store/common/type/header";
import type { SelectDataType } from "@common/business_components/ui";
const moUpHeadList: TableUpperProps[] = [
{ id: "cityText", title: "시도" },
{ id: "sggText", title: "시군구" },
{ id: "bdstNm", title: "시설명" },
{ id: "daddr", title: "위치" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적(㎡)" },
];
const moUpHeadList: TableUpperProps[] = [
{ id: "cityText", title: "시도" },
{ id: "sggText", title: "시군구" },
{ id: "bdstNm", title: "시설명" },
{ id: "daddr", title: "위치" },
{ id: "frstArchPrmsnDt", title: "최초건축허가일" },
{ id: "archArea", title: "건축면적(㎡)", },
];
const bdstChgHeadList: TableUpperProps[] = [
{ id: "bdstChgNm", title: "구분" },
{ id: "archChgPrmsnDt", title: "허가일" },
{ id: "archChgArea", title: "변경면적(㎡)" },
];
const bdstBase: any[] = [];
const bdstChgHeadList: TableUpperProps[] = [
{ id: "bdstChgNm", title: "구분" },
{ id: "archChgPrmsnDt", title: "허가일" },
{ id: "archChgArea", title: "변경면적(㎡)" },
];
const bdstBase:any[] = [];
const isRainBdst = (data: any): data is customRainBdst=> {
const isRainBdst = (data: any): data is customRainBdst => {
return data.reuseBuilding?.[0]?.rainyObj !== undefined;
}
};
const isHtdflBdst = (data: any): data is customHtdflBdst=> {
const isHtdflBdst = (data: any): data is customHtdflBdst => {
return data.reuseBuilding?.[0]?.htdflObj !== undefined;
}
};
const isRswtBdst = (data: any): data is customRswtBdst =>{
const isRswtBdst = (data: any): data is customRswtBdst => {
return data.reuseBuilding?.[0]?.rswtrObj !== undefined;
}
};
export const makeRstr = (
data: customRainBdst | customHtdflBdst | customRswtBdst
) => {
data.rgtr = TEST_UUID;
export const makeRstr =(data:customRainBdst|customHtdflBdst|customRswtBdst) =>{
data.rgtr = TEST_UUID;
let chData
if(isRainBdst(data)){
let chData;
if (isRainBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
rgtr : TEST_UUID,
rainyObj:{
rgtr: TEST_UUID,
rainyObj: {
...item.rainyObj,
rgtr:TEST_UUID
}
rgtr: TEST_UUID,
},
}));
data.reuseBuilding=chData;
}else if(isHtdflBdst(data)){
data.reuseBuilding = chData;
} else if (isHtdflBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
rgtr : TEST_UUID,
htdflObj:{
rgtr: TEST_UUID,
htdflObj: {
...item.htdflObj,
rgtr:TEST_UUID
}
rgtr: TEST_UUID,
},
}));
data.reuseBuilding=chData;
}else if (isRswtBdst(data)){
data.reuseBuilding = chData;
} else if (isRswtBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
rgtr : TEST_UUID,
rswtrObj:{
rgtr: TEST_UUID,
rswtrObj: {
...item.rswtrObj,
rgtr:TEST_UUID
}
rgtr: TEST_UUID,
},
}));
data.reuseBuilding=chData;
data.reuseBuilding = chData;
}
if('chgBuilding' in data && Array.isArray(data.chgBuilding) && data.chgBuilding.length > 0){
const chRgtr = data.chgBuilding.map((item) =>({...item, rgtr:TEST_UUID, mdfr: item.mdfr ?? null }))
data.chgBuilding =chRgtr;
}
return data;
if (
"chgBuilding" in data &&
Array.isArray(data.chgBuilding) &&
data.chgBuilding.length > 0
) {
const chRgtr = data.chgBuilding.map((item) => ({
...item,
rgtr: TEST_UUID,
mdfr: item.mdfr ?? null,
}));
data.chgBuilding = chRgtr;
}
return data;
};
export const makeMdfr =(data:customRainBdst|customHtdflBdst|customRswtBdst) =>{
data.mdfr = TEST_UUID;
let chData
if(isRainBdst(data)){
chData = data.reuseBuilding.map((item) => ({
...item,
mdfr : TEST_UUID,
rainyObj:{
...item.rainyObj,
mdfr:TEST_UUID
}
}));
if(data?.chgBuilding.length>0){
const chRgtr = data.chgBuilding.map((item) =>({...item, rgtr:TEST_UUID, mdfr: item.mdfr ?? null }))
data.chgBuilding =chRgtr;
}
data.reuseBuilding=chData
}else if(isHtdflBdst(data)){
chData = data.reuseBuilding.map((item) => ({
export const makeMdfr = (
data: customRainBdst | customHtdflBdst | customRswtBdst
) => {
data.mdfr = TEST_UUID;
let chData;
if (isRainBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
mdfr: TEST_UUID,
rainyObj: {
...item.rainyObj,
mdfr: TEST_UUID,
},
}));
if (data?.chgBuilding.length > 0) {
const chRgtr = data.chgBuilding.map((item) => ({
...item,
mdfr : TEST_UUID,
htdflObj:{
...item.htdflObj,
mdfr:TEST_UUID
}
rgtr: TEST_UUID,
mdfr: item.mdfr ?? null,
}));
data.reuseBuilding=chData;
}else if (isRswtBdst(data)){
chData = data.reuseBuilding.map((item) => ({
...item,
mdfr : TEST_UUID,
rswtrObj:{
...item.rswtrObj,
mdfr:TEST_UUID
}
}));
data.reuseBuilding=chData;
data.chgBuilding = chRgtr;
}
if('chgBuilding' in data && Array.isArray(data.chgBuilding) && data.chgBuilding.length > 0){
const chMdfr = data.chgBuilding.map((item) =>({...item, mdfr:TEST_UUID, archChgArea: item.archChgArea ?? '' }))
data.chgBuilding =chMdfr;
}
return data;
data.reuseBuilding = chData;
} else if (isHtdflBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
mdfr: TEST_UUID,
htdflObj: {
...item.htdflObj,
mdfr: TEST_UUID,
},
}));
data.reuseBuilding = chData;
} else if (isRswtBdst(data)) {
chData = data.reuseBuilding.map((item) => ({
...item,
mdfr: TEST_UUID,
rswtrObj: {
...item.rswtrObj,
mdfr: TEST_UUID,
},
}));
data.reuseBuilding = chData;
}
if (
"chgBuilding" in data &&
Array.isArray(data.chgBuilding) &&
data.chgBuilding.length > 0
) {
const chMdfr = data.chgBuilding.map((item) => ({
...item,
mdfr: TEST_UUID,
archChgArea: item.archChgArea ?? "",
}));
data.chgBuilding = chMdfr;
}
return data;
};
export type bdstFulType = bdstState & bdstActions;
export type bdstState = {
bdst: {
bdstBase: any[];
moUpHeadList:TableUpperProps[]
bdstChgHeadList:TableUpperProps[]
moUpHeadList: TableUpperProps[];
bdstChgHeadList: TableUpperProps[];
userCityCd: SelectDataType[];
userSggCd: SelectDataType[];
};
};
type bdstActions = {
findBdst: (sggCd:string, searchTxt:string, flag:string) => void ;
};
const findBdstInfo = async(sggCd:string, searchTxt:string ,flg:string)=>{
return await getFetch('wr', `/reuseFc/building/${flg}/${sggCd}`+(searchTxt?`/${searchTxt}`:'' ))
}
findBdst: (sggCd: string, searchTxt: string, flag: string) => void;
setUserCitySggCd: (
laeSeCd: string,
cityCd: SelectDataType[],
sggCd: SelectDataType[]) => void;
setUserSggCd: ( userCityCd: string,sggCd: SelectDataType[]) => void;
};
const findBdstInfo = async (sggCd: string, searchTxt: string, flg: string) => {
return await getFetch(
"wr",
`/reuseFc/building/${flg}/${sggCd}` + (searchTxt ? `/${searchTxt}` : "")
);
};
export const bdstStateExport: bdstState = {
bdst: {
bdstBase: bdstBase, // Updated to match the array type
moUpHeadList:moUpHeadList,
bdstChgHeadList:bdstChgHeadList,
userCityCd: [],
userSggCd: [],
moUpHeadList: moUpHeadList,
bdstChgHeadList: bdstChgHeadList,
},
};
export const bdstActionsExport: (set: any) => bdstActions = (
set: any
) => {
export const bdstActionsExport: (set: any) => bdstActions = (set: any) => {
return {
findBdst: async(sggCd:string, searchTxt:string ,flg:string ) =>{
try{
const bdst = await findBdstInfo(sggCd, searchTxt, flg);
const makeBdst = bdst.map((item:any) => {
return {
...item,
reuseBuilding:[]
};
})
return set((state:bdstState) =>({
...state,
bdst:{
...state.bdst,
bdstBase:makeBdst
}
}))
}catch(error1){
console.log("error ", error1)
}finally{
}
findBdst: async (sggCd: string, searchTxt: string, flg: string) => {
try {
const bdst = await findBdstInfo(sggCd, searchTxt, flg);
const makeBdst = bdst.map((item: any) => {
return {
...item,
reuseBuilding: [],
};
});
return set((state: bdstState) => ({
...state,
bdst: {
...state.bdst,
bdstBase: makeBdst,
},
}));
} catch (error1) {
console.log("error ", error1);
} finally {
}
},
setUserCitySggCd: (
laeSeCd: string,
cityCd: SelectDataType[],
sggCd: SelectDataType[]
) => {
let city = [...cityCd];
let sgg = [...sggCd]
console.log('sgg ', sgg)
if (laeSeCd === "0" && cityCd.length > 0) {
city = city;
sgg = [{ val: "0", text: "전체" }]
} else if (laeSeCd.length === 2 && cityCd.length > 0) {
city = cityCd.filter((item) => item.val === laeSeCd);
sgg = sggCd.filter((item) => item.val.slice(0, 2) === laeSeCd);
sggCd.unshift({ val: "0", text: "전체" });
} else if (
laeSeCd.length === 5 &&
cityCd.length > 0 &&
sggCd.length > 0
) {
city = cityCd.filter((item) => item.val === laeSeCd.slice(0, 2));
sgg = sggCd.filter((item) => item.val === laeSeCd);
}
return set((state: bdstState) => ({
...state,
bdst: {
...state.bdst,
userCityCd: city,
userSggCd: sgg,
},
}));
},setUserSggCd( userCityCd: string,sggCd: SelectDataType[]){
const sgg = sggCd.filter((item) => item.val.slice(0, 2) === userCityCd);
return set((state: bdstState) => ({
...state,
bdst: {
...state.bdst,
userSggCd: sgg,
},
}));
},
};
};