diff --git a/apps/wr/app/matMng/coMng/coSttn/page.tsx b/apps/wr/app/matMng/coMng/coSttn/page.tsx index e828f4226..163ed1b40 100644 --- a/apps/wr/app/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/coSttn/page.tsx @@ -2,6 +2,7 @@ import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; +import { excelCoSttnParsing } from "@/app/store/matDmd/coSttn/excel"; import { fetchType, getFetch } from "@/components/lib/api"; import { excelDownload, @@ -42,7 +43,6 @@ export default function CoSttn() { updateDemandCompany, coSttnTxtSearch, demandCompList, - dmdIsSucees } = useWrStore((state) => state); const [bdstTable, setBdstTable] = useState(); @@ -116,31 +116,36 @@ export default function CoSttn() { coSttn.excelList, "수요처 관리", "sample_coSttn.xlsx", - "A1:F1", + "A1:G1", 2 ); } }, [coSttn.excelList]); - useEffect(() => { - const con = (objSearch.sgg && objSearch.sgg !== "0") ? objSearch.sgg : objSearch.city ? objSearch.city : "0"; - if(con){ - coSttnSearch(String(pageNation), "13", String(con)); - } - }, [coSttnSearch, objSearch.city, objSearch.sgg, pageNation]); + const excelClick = useCallback(() => { - const con = objSearch.sgg ? objSearch.sgg : objSearch.city; - if (con) coSttnSearch("1", "10000", String(con)); - }, [coSttnSearch, objSearch.city, objSearch.sgg]); + // const con = objSearch.sgg ? objSearch.sgg : objSearch.city; + // if (con) coSttnSearch("1", "10000", String(con)); + if(bdstTable){ + const excelData = excelCoSttnParsing(bdstTable); + excelDownload( + excelData as [], + "수요처 관리", + "sample_coSttn.xlsx", + "A1:F1", + 2 + ); + } + // }, [coSttnSearch, objSearch.city, objSearch.sgg]); +}, [excelDownload, bdstTable]); const searchClick = () => { const con = (objSearch.sgg && objSearch.sgg !== "0") ? objSearch.sgg : objSearch.city; if (con) { if (seartchTxt && seartchTxt?.length > 0) { - console.log(' seartchTxt ', seartchTxt) coSttnTxtSearch("1", "13", String(con), seartchTxt ?? ""); } else { coSttnSearch("1", "13", String(con)); @@ -233,7 +238,7 @@ export default function CoSttn() { headName={[]} tableData={bdstTable || []} headlist={coSttn.coSttHeadList} - pageSize={bdstTable?.length ? Math.ceil(bdstTable.length / 13) : 0} + pageSize={20} total={ coSttnResCount || 0 } cellClick={(index: number | undefined, headId: string) => { setUpdateData(coSttnRes[index as number]); @@ -258,22 +263,24 @@ export default function CoSttn() { getDemandCompList(searchText, pageCnt); }} rtnInputData={ async(data) => { + const con = (objSearch.sgg && objSearch.sgg !== "0") ? objSearch.sgg : objSearch.city; + if(upadateData?.dmdInfoPk){ - updateDemandCompany(data as DemandCompType) + + await updateDemandCompany(data as DemandCompType) + coSttnInit("1", "13", String(con)); + setIsDmdModal({ isMoal: false, data: data as DemandCompType }); }else{ const dmd= await getFetch(fetchType.WR,`/reuseFc/request/${data.dmdInfoPk}`) if(dmd) { toast.error(`사업자번호 ${dmd.dmdInfoPk}는 이미 등록되었습니다. 다시등록해주세요`) return } - regDemandCompany(data as DemandCompType); - } - if(dmdIsSucees ==='success'){ - toast.success(`수요처 등록 및 수정 완료되었습니다..`) - setIsDmdModal({ isMoal: false, data: data as DemandCompType }); - }else{ - toast.error(`수요처 등록 및 수정 에러입니다.`) + await regDemandCompany(data as DemandCompType); + coSttnInit("1", "13", String(con)); + setIsDmdModal({ isMoal: false, data: data as DemandCompType }); } + }} bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} diff --git a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx index d3333f676..873ad85f3 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx @@ -24,9 +24,8 @@ import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal import { Toaster } from "react-hot-toast"; export default function Home() { - const { code, htdfl, initHtdflReg, getHtdflBdstData ,htdflNmSearch} = useWrStore( - (state) => state - ); + const { code, htdfl, initHtdflReg, getHtdflBdstData, htdflNmSearch } = + useWrStore((state) => state); const [searchTxt, setSearchTxt] = useState(""); const [pageNation, setPageNation] = useState(1); @@ -43,26 +42,26 @@ export default function Home() { useEffect(() => { if (!htdfl.isInit) { - initHtdflReg('0') + initHtdflReg("0"); } }, [htdfl.isInit, initHtdflReg]); useEffect(() => { - if (htdflRes&&htdflRes.length>0) { - - console.log('htdflRes ', htdflRes) + if (htdflRes && htdflRes.length > 0) { const htdflData = tableData(htdflRes, { code }).map( (item: customHtdflBdst) => { - let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가' + let archArea = + item?.archArea.split(".")[0] !== "-1" + ? item?.archArea.split(".")[0] + : "확인불가"; return { ...item, - archArea:archArea - + archArea: archArea, }; } ); setbdstTable(htdflData); - }else{ + } else { setbdstTable([]); } }, [code, htdflRes]); @@ -114,11 +113,10 @@ export default function Home() {