수요처관리 수요처 등록및 수정 완료

This commit is contained in:
leedj312
2025-06-12 20:00:58 +09:00
parent 8a1c4641ab
commit b1f108c485
3 changed files with 85 additions and 24 deletions
+22 -3
View File
@@ -29,6 +29,7 @@ import SdmInsertForm, {
import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
import { Toaster } from "react-hot-toast";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
import { fetchType, getFetch } from "@/components/lib/api";
export default function CoSttn() {
const {
@@ -38,8 +39,11 @@ export default function CoSttn() {
coSttnSearch,
getDemandCompList,
regDemandCompany,
updateDemandCompany,
coSttnTxtSearch,
checkDemand,
demandCompList,
dmdIsSucees
} = useWrStore((state) => state);
const [bdstTable, setBdstTable] = useState<DemandCompType[]>();
@@ -215,7 +219,7 @@ export default function CoSttn() {
bodyClass={"w-[40vw] max-w-none h-[90vh]"}
open={isDmdModal.isMoal}
onOpenChange={() => {
setIsDmdModal({ isMoal: false, data: {} as DemandCompType });
setIsDmdModal({ isMoal: false, data: {} as DemandCompType });
}}
body={
<SdmInsertForm
@@ -225,9 +229,24 @@ export default function CoSttn() {
rtnValue={(searchText: string, pageCnt: number) => {
getDemandCompList(searchText, pageCnt);
}}
rtnInputData={(data) => {
regDemandCompany(data as DemandCompType);
rtnInputData={ async(data) => {
if(upadateData?.dmdInfoPk){
updateDemandCompany(data as DemandCompType)
}else{
const dmd= await getFetch(fetchType.WR,`/reuseFc/request/${data.dmdInfoPk}`)
if(dmd) {
ToastFormUi({body: `사업자번호 ${dmd.dmdInfoPk}는 이미 등록되었습니다. 다시등록해주세요`, title:"수요처 관리"})
return
}
regDemandCompany(data as DemandCompType);
}
if(dmdIsSucees ==='success'){
ToastFormUi({body: `수요처 등록 및 수정이 완료되었습니다.`, title:"수요처 관리"})
setIsDmdModal({ isMoal: false, data: data as DemandCompType });
}else{
ToastFormUi({body: `수요처 등록 및 수정 에러입니다.`, title:"수요처 관리"})
}
}}
bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"}
updateList={upadateData}
+62 -19
View File
@@ -1,16 +1,22 @@
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
import {
fetchType,
getFetch,
postFectch,
putFectch,
} from "@/components/lib/api";
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
import type { DemandCompType } from "@common/business_components/ui";
export type comFcltState = {
searchFclts: pubHasuType;
demandCompList: DemandCompType[];
dmdIsSucees: string;
checkDemand: DemandCompType;
};
export type comFcltActions = {
getSwtrmtFcltNm: (searchNm: string) => void;
getDemandCompList :(searchNm: string,cnt:number) => void
regDemandCompany:(data:DemandCompType ) => void
getDemandCompList: (searchNm: string, cnt: number) => void;
regDemandCompany: (data: DemandCompType) => void;
updateDemandCompany: (data: DemandCompType) => void;
};
export const searchActions: (set: any) => comFcltActions = (set: any) => {
@@ -28,27 +34,64 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => {
addr: item.addr,
fctCpc: item.fctCpc,
}));
return set((state: comFcltState) => ({
set((state: comFcltState) => ({
...state,
searchFclts: fcltNmCd,
}));
},
getDemandCompList: async (searchNm: string ,cnt:number) => {
getDemandCompList: async (searchNm: string, cnt: number) => {
const coList = await getFetch(
fetchType.WR,
`/reuseFc/request/${searchNm}/${cnt}`
`/reuseFc/request/${searchNm}/${cnt}`
);
return set((state: comFcltState) => {
state.demandCompList= coList
return state
set((state: comFcltState) => {
state.demandCompList = coList;
return state;
});
},regDemandCompany: async (data:DemandCompType)=>{
try{
const response = await postFectch('/reuseFc/request',data,fetchType.WR )
}catch(err){
console.log(err)
}
},
regDemandCompany: async (data: DemandCompType) => {
try {
const response = await postFectch(
"/reuseFc/request",
data,
fetchType.WR
);
let message = "";
if (response.status === 200) {
message = "success";
} else {
message = "fail";
}
set((state: comFcltState) => {
state.dmdIsSucees = message;
return state;
});
} catch (err) {
console.log(err);
}
},
updateDemandCompany: async (data: DemandCompType) => {
try {
const response = await putFectch("/reuseFc/request", data);
let message = "";
if (response.status === 200) {
message = "success";
} else {
message = "fail";
}
set((state: comFcltState) => {
state.dmdIsSucees = message;
return state;
});
} catch (err) {
console.log(err);
}
}
};
}
};
+1 -2
View File
@@ -1,6 +1,5 @@
import type { CommonTableProps } from "@/app/store/common/type/header";
import { fetchType, getFetch } from "@/components/lib/api";
import { z } from "zod";
import { coSttHeadListExport, coSttNodeListExport } from "./headList";
import { excelCoSttnParsing } from "./excel";
import type { DemandCompType } from "@common/business_components/ui";
@@ -116,6 +115,6 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
} catch (erTxt) {
console.log("error", erTxt);
}
},
}
}
}