수요처 추가 변경 수정
iipbs_wr / build (push) Waiting to run

This commit is contained in:
leedj312
2025-07-07 20:31:35 +09:00
parent f7580defc9
commit 5ec33d0165
4 changed files with 89 additions and 60 deletions
@@ -110,9 +110,37 @@ export default function PublicReuseFaciltyInsert() {
fcOpers: fclt.fcOpers,
};
});
await pbnstRuseFcltUpdate(pbnst as customPbnst[])
await pbnstRuseBizUpdate(bizs);
Promise.allSettled([
pbnstRuseFcltUpdate(pbnst as customPbnst[]),
pbnstRuseBizUpdate(bizs)
]).then(([resFclt, resBiz]) => {
const isFcltSuccess = resFclt.status === "fulfilled";
const isBizSuccess = resBiz.status === "fulfilled";
if (isFcltSuccess && isBizSuccess) {
toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ')
// 메시지 표시, 페이지 이동 등
} else {
let message =''
// ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리
if (!isFcltSuccess) {
message = '하수재이용 시설 '
}
if (!isBizSuccess) {
message += '하수재이용 시설 사업 '
}
toast.error(message+'오류 입니다 ')
pubHasuInit("1", "41");
}
});
};
// 폼 유효성 검사 실패 시 호출될 함수
@@ -199,9 +227,6 @@ export default function PublicReuseFaciltyInsert() {
useEffect(() => {
if (pbnst.pbnstRes && pbnst.pbnstRes?.length > 0) {
form.reset({ items: pbnst.pbnstRes });
} else {
@@ -214,6 +239,9 @@ export default function PublicReuseFaciltyInsert() {
}
}, [indexMng]);
useEffect(() => {
console.log("form errors:", form.formState.errors);
}, [form.formState.errors]);
+26 -14
View File
@@ -7,12 +7,12 @@ import {
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
import type { conCostFeeType, rateFeeType } from "./type";
import toast from "react-hot-toast";
export const comFcltStateExport: comFcltState = {
searchFclts: [] as pubHasuType[],
demandCompList: [],
dmdIsSucees: '',
checkDemand: {
index: 0,
dmdInfoPk: "",
@@ -52,7 +52,6 @@ export type comFcltType = comFcltState & comFcltActions;
export type comFcltState = {
searchFclts: pubHasuType[];
demandCompList: DemandCompType[];
dmdIsSucees: string;
checkDemand: DemandCompType;
constCostRes:conCostFeeType[],
rateFeeRes:rateFeeType[],
@@ -110,19 +109,20 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
data,
fetchType.WR
);
let message = "";
if (response.status === 200) {
message = "success";
} else {
message = "fail";
toast.success('수요처가 등록되었습니다. ')
set((state: comFcltState) => {
return {
...state,
dmdIsSucees: "success"
}
});
}
set((state: comFcltState) => {
return state.dmdIsSucees = message;
});
} catch (err) {
console.log(err);
toast.error('수요처가 등록 오류입니다.. ')
}
},
updateDemandCompany: async (data: DemandCompType) => {
@@ -137,7 +137,10 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
}
set((state: comFcltState) => {
return state.dmdIsSucees = message;
return {
...state,
dmdIsSucees: message
}
});
} catch (err) {
console.log(err);
@@ -149,7 +152,11 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
const rateFeeRes = await getFetch(fetchType.COMMON, url);
set((state: comFcltState) => {
return state.rateFeeRes = rateFeeRes;;
return {
...state,
rateFeeRes: rateFeeRes
}
});
} catch (e) {
console.log(" error ", e);
@@ -159,7 +166,12 @@ export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
const url = `/prcsFclt/CstRuse/${year}`;
const constCost = await getFetch(fetchType.COMMON, url);
set((state: comFcltState) => {
return state.constCostRes = constCost;;
return {
...state,
constCostRes: constCost
}
});
}catch (e) {
}
@@ -60,14 +60,11 @@ export type pubFacState = {
type pubFacActions = {
pubHasuInit: (page: string, sggOrCity: string) => void;
pbnstRegClick: (pubHasuRes: pubHasuType) => void;
pbnstReg: (txt: string | undefined) => void;
//pbnstReg: (txt: string | undefined) => void;
pbnstInsert(pbnstRes: customPbnst): Promise<void>;
appendRuseFclt(array: customPbnst[]): void;
fileDelete: (atflCd: string) => void;
fileDownLoad: (atflCd: string) => void;
//pbnstMngData: (data: customPbnst[]) => void;
//pbnstBizData(data: fcBizType): void;
// getBizCycle: (pbnstObj: customPbnst) => void;
getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
@@ -226,21 +223,21 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
}
},
pbnstReg: async (txt: string | undefined) => {
try {
const pbnstRes = await hasuListFetch("11", "11");
return set((state: pubFacState) => ({
...state,
pbnst: {
...state.pbnst,
pbnstRes: pbnstRes,
isInit: false,
},
}));
} catch (errorHasu) {
console.log(errorHasu);
}
},
// pbnstReg: async (txt: string | undefined) => {
// try {
// const pbnstRes = await hasuListFetch("11", "11");
// return set((state: pubFacState) => ({
// ...state,
// pbnst: {
// ...state.pbnst,
// pbnstRes: pbnstRes,
// isInit: false,
// },
// }));
// } catch (errorHasu) {
// console.log(errorHasu);
// }
// },
pbnstInsert: async (pbnstRes: customPbnst) => {
try {
@@ -272,14 +269,9 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
`/reuseFc/pubFc`,
ruseRes
);
if(response){
toast.success(` 하수재이용 시설 정보가 수정되었습니다.`);
}
} catch (error) {
console.error("Error pbnstRuseFcltUpdate:", error);
toast.error(` 하수재이용 시설 정보가 수정오류입니다.`);
}
} ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{
try {
@@ -290,22 +282,19 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
ruseRes
);
if(response){
toast.success(` 하수재이용 시설 사업이 수정되었습니다.`);
}
const pbnstRes = await hasuListFetch("11", "11");
// const pbnstRes = await hasuListFetch("11", "11");
return set((state: pubFacState) => ({
...state,
pbnst: {
...state.pbnst,
pbnstRes: pbnstRes,
isInit: false,
},
}));
// return set((state: pubFacState) => ({
// ...state,
// pbnst: {
// ...state.pbnst,
// pbnstRes: pbnstRes,
// isInit: false,
// },
// }));
} catch (error) {
console.error("Error pbnstRuseFcltUpdate:", error);
toast.error(` 하수재이용 시설 사업이 수정이 실패되엇습니다..`);
// toast.error(` 하수재이용 시설 사업이 수정이 실패되엇습니다..`);
}
} ,
getBizCycle: async (pbnstObj: customPbnst) => {
@@ -134,7 +134,6 @@ export function PbnstBuseForm({
(orgwt) => orgwt.bscFctCd === item.swtrmtFcltFk
)?.bscFctNm;
console.log("orgwtNm ", orgwtNm);
if (orgwtNm) {
form.setValue(
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts.${index}.ruseUtztnFcltNm`,
@@ -205,8 +204,6 @@ export function PbnstBuseForm({
prevDemandsLengthRef.current = fcDemands.length;
}, [fcDemands.length]);
const fcOrgwtWatch = form.watch( `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`)
const pplInstlsWatch = form.watch( `items.${indexMng}.fcBizs.${indexBiz}.pplInstls`)
const { fields: fcOrgwtFiled } = useFieldArray({
control: form.control,
@@ -319,6 +316,9 @@ useEffect(() =>{
}, [form.formState]);
const pbnstBiz = form.watch(`items.${indexMng}.fcBizs`);
return (
<>
{pbnstBiz && pbnstBiz?.length > 0 ? (