Merge commit 'e30130dc8f54918924e5221b7b4103f8b0afb2ca' into iipbs/wr/dev
iipbs_wr / build (push) Waiting to run
iipbs_wr / build (push) Waiting to run
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import { type customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { ldrmntHeadListExport, ldrmntNodeListExport } from "@/app/store/matDmd/ldrmntCoSttn/headList";
|
||||
import { ldrmntHeadListExport } from "@/app/store/matDmd/ldrmntCoSttn/headList";
|
||||
import {
|
||||
excelDownload,
|
||||
getCity,
|
||||
getCityOrSgg,
|
||||
tableData
|
||||
} from "@/components/lib/func/commom";
|
||||
import CoRegExcel from "@/components/ui/modal/coReg/coRegExcel/coRegExcelModal";
|
||||
@@ -24,54 +23,74 @@ import {
|
||||
Title,
|
||||
UiModal,
|
||||
UiTable,
|
||||
type ReturnType,
|
||||
type SelectDataType
|
||||
} from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
export default function LdrmntCoSttn() {
|
||||
const { code, ldrmnt, ldrmntInit, ldrmntSearch, } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { ldrmntRes, excelList } = ldrmnt;
|
||||
const { ldrmntRes, excelList, ldrmntResCount } = ldrmnt;
|
||||
const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customLdrmnt | undefined }>({ data: undefined, isOpen: false })
|
||||
const [pageNation, setPageNation] = useState(1);
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>()
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({ sgg: "", city: "" });
|
||||
const [bdstTable, setBdstTable] = useState<customLdrmnt[]>();
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const [excelData, setExcelData] = useState<any[]>();
|
||||
const [isExcelDownload, setIsExcelDownload] = useState(false);
|
||||
// const [isExcelDownload, setIsExcelDownload] = useState(false);
|
||||
|
||||
const excelClick = useCallback(() => {
|
||||
excelDownload(
|
||||
[[]],
|
||||
"잠재수요처 관리",
|
||||
"잠재수요처 등록양식",
|
||||
"sample_ldrmntCoSttn.xlsx",
|
||||
"A1:AL1",
|
||||
2
|
||||
);
|
||||
}, []);
|
||||
|
||||
const excelDownloadClick = () => {
|
||||
ldrmntSearch(1, "10000", "0", "");
|
||||
setIsExcelDownload(true);
|
||||
}
|
||||
const computeCityNm = () => {
|
||||
let cityTxt = "";
|
||||
let sggTxt = "";
|
||||
|
||||
if (objSearch.city) {
|
||||
cityTxt =
|
||||
code.cityCd.find((c) => c.val === objSearch.city)?.text || "";
|
||||
}
|
||||
if (objSearch.sgg) {
|
||||
sggTxt =
|
||||
code.sggCd.find((s) => s.val === objSearch.sgg)?.text || "";
|
||||
}
|
||||
|
||||
if (cityTxt === "" || cityTxt === "전체") cityTxt = "0";
|
||||
|
||||
return sggTxt && sggTxt !== "0"
|
||||
? `${cityTxt} ${sggTxt}`
|
||||
: cityTxt;
|
||||
};
|
||||
|
||||
const excelDownloadClick = useCallback(() => {
|
||||
const cityNm = computeCityNm();
|
||||
ldrmntSearch(true, pageNation, String(ldrmntResCount), cityNm, searchTxt || "");
|
||||
// setIsExcelDownload(true);
|
||||
}, [objSearch, pageNation, searchTxt, code, ldrmntSearch, computeCityNm, ldrmntResCount]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isExcelDownload && excelData && excelData.length > 0) {
|
||||
if (/*isExcelDownload &&*/ excelData && excelData.length > 0) {
|
||||
downloadExcel({
|
||||
data: excelData,
|
||||
fileName: "잠재수요처 관리",
|
||||
sheetNameArray: ["Sheet1"],
|
||||
headerRange: "A1:F1"
|
||||
});
|
||||
setIsExcelDownload(false);
|
||||
// setIsExcelDownload(false);
|
||||
}
|
||||
}, [excelData, isExcelDownload]);
|
||||
}, [excelData, /*isExcelDownload*/]);
|
||||
|
||||
const [isExcelOpen, setIsExcelOpen] = useState<{
|
||||
isModal: boolean;
|
||||
@@ -141,33 +160,8 @@ export default function LdrmntCoSttn() {
|
||||
}, [excelList])
|
||||
|
||||
useEffect(() => {
|
||||
let cityTxt = ''
|
||||
let sggTxt = ''
|
||||
|
||||
if (objSearch?.city.toString().length > 0) {
|
||||
cityTxt = code.cityCd.find((item) => item.val === objSearch?.city)?.text ?? '';
|
||||
}
|
||||
|
||||
if (objSearch?.sgg.toString().length > 1) {
|
||||
sggTxt = code.sggCd.find((item) => item.val === objSearch?.sgg)?.text ?? '';
|
||||
}
|
||||
|
||||
if (cityTxt === '전체' || cityTxt === '') {
|
||||
cityTxt = '0'
|
||||
}
|
||||
|
||||
let cityNm = ""
|
||||
|
||||
if (sggTxt !== "0") {
|
||||
cityNm = cityTxt + " " + sggTxt
|
||||
} else {
|
||||
cityNm = cityTxt
|
||||
}
|
||||
if (cityNm) {
|
||||
ldrmntSearch(pageNation, '20', cityNm, searchTxt || "");
|
||||
} else {
|
||||
ldrmntSearch(pageNation, '20', '0', searchTxt || "");
|
||||
}
|
||||
const cityNm = computeCityNm();
|
||||
ldrmntSearch(false, pageNation, '20', cityNm, searchTxt || "");
|
||||
}, [pageNation]);
|
||||
|
||||
return (
|
||||
@@ -210,32 +204,8 @@ export default function LdrmntCoSttn() {
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={(e) => {
|
||||
|
||||
let cityTxt = ''
|
||||
let sggTxt = ''
|
||||
|
||||
if (objSearch?.city.toString().length > 0) {
|
||||
cityTxt = code.cityCd.find((item) => item.val === objSearch?.city)?.text ?? '';
|
||||
}
|
||||
|
||||
if (objSearch?.sgg.toString().length > 1) {
|
||||
sggTxt = code.sggCd.find((item) => item.val === objSearch?.sgg)?.text ?? '';
|
||||
}
|
||||
|
||||
if (cityTxt === '전체' || cityTxt === '') {
|
||||
cityTxt = '0'
|
||||
}
|
||||
|
||||
let cityNm = ""
|
||||
|
||||
if (sggTxt !== "0") {
|
||||
cityNm = cityTxt + " " + sggTxt
|
||||
} else {
|
||||
cityNm = cityTxt
|
||||
}
|
||||
if (cityNm) {
|
||||
ldrmntSearch(pageNation, '20', cityNm, searchTxt || "");
|
||||
}
|
||||
const cityNm = computeCityNm();
|
||||
ldrmntSearch(false, pageNation, '20', cityNm, searchTxt || "");
|
||||
}}
|
||||
>
|
||||
조회
|
||||
@@ -273,11 +243,11 @@ export default function LdrmntCoSttn() {
|
||||
<div className="overflow-x-auto">
|
||||
<ListDiv className="min-w-max">
|
||||
<UiTable
|
||||
headName={[]}
|
||||
headName={undefined}
|
||||
tableData={bdstTable || []}
|
||||
headlist={ldrmntHeadListExport}
|
||||
pageSize={20}
|
||||
total={10000}
|
||||
total={ldrmntResCount || 0}
|
||||
cellClick={(index: number | undefined, headId: string) => { cellClick(index ?? undefined, headId) }}
|
||||
onPageChange={setPageNation}
|
||||
/>
|
||||
@@ -299,8 +269,9 @@ export default function LdrmntCoSttn() {
|
||||
setIsExcelOpen({ isModal: !isExcelOpen.isModal })
|
||||
}}
|
||||
bodyClass={"w-[40vw] max-w-none"}
|
||||
body={<CoRegExcel />}
|
||||
body={<CoRegExcel isModal={(isOpen) => setIsExcelOpen({ isModal: isOpen })} />}
|
||||
/>
|
||||
<Toaster position="top-center"></Toaster>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
if (!isDirty) {
|
||||
toast.error("변경사항이 없습니다."); // 변경사항이 없으면 메시지 표시
|
||||
return;
|
||||
} const data = writeRgtrAndMdfr(valuse.items);
|
||||
} const data = writeRgtrAndMdfr(valuse.items);
|
||||
let bizs = [] as fcBizType[];
|
||||
data.forEach((fclt) => {
|
||||
bizs = [...bizs, ...fclt.fcBizs];
|
||||
@@ -118,22 +118,22 @@ export default function PublicReuseFaciltyInsert() {
|
||||
]).then(([resFclt, resBiz]) => {
|
||||
const isFcltSuccess = resFclt.status === "fulfilled";
|
||||
const isBizSuccess = resBiz.status === "fulfilled";
|
||||
|
||||
|
||||
if (isFcltSuccess && isBizSuccess) {
|
||||
toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ')
|
||||
toast.success('하수 재이용 시설 및 사업이 수정되었습니다. ')
|
||||
// 메시지 표시, 페이지 이동 등
|
||||
} else {
|
||||
|
||||
let message =''
|
||||
let message = ''
|
||||
// ✅ 각각 어떤 항목이 실패했는지도 로그/알림 처리
|
||||
if (!isFcltSuccess) {
|
||||
message = '하수재이용 시설 '
|
||||
}
|
||||
if (!isBizSuccess) {
|
||||
message += '하수재이용 시설 사업 '
|
||||
message += '하수재이용 시설 사업 '
|
||||
}
|
||||
|
||||
toast.error(message+'오류 입니다 ')
|
||||
|
||||
toast.error(message + '오류 입니다 ')
|
||||
pubHasuInit("1", "41");
|
||||
}
|
||||
|
||||
@@ -146,45 +146,45 @@ export default function PublicReuseFaciltyInsert() {
|
||||
// 폼 유효성 검사 실패 시 호출될 함수
|
||||
const onInvalid = (errors: FieldErrors<{ items: z.infer<typeof pbnstRegZod>[] }>) => {
|
||||
console.log("errors:", errors);
|
||||
|
||||
|
||||
const findAllErrors = (
|
||||
errorObject: any,
|
||||
path: (string | number)[] = []
|
||||
): { message: string; path: (string | number)[] }[] => {
|
||||
if (!errorObject) return [];
|
||||
|
||||
|
||||
return Object.keys(errorObject).flatMap((key) => {
|
||||
const value = errorObject[key];
|
||||
const currentKey = !isNaN(parseInt(key)) ? parseInt(key) : key;
|
||||
const newPath = [...path, currentKey];
|
||||
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
if (value.message) {
|
||||
return [{ message: value.message, path: newPath }];
|
||||
}
|
||||
|
||||
|
||||
return findAllErrors(value, newPath);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const errorList = findAllErrors(errors);
|
||||
|
||||
|
||||
if (errorList.length > 0) {
|
||||
errorList.forEach((errorInfo) => {
|
||||
const { message, path } = errorInfo;
|
||||
let prefix = "";
|
||||
|
||||
|
||||
const itemsIndex = path.indexOf("items");
|
||||
|
||||
|
||||
if (itemsIndex > -1 && path.length > itemsIndex + 1) {
|
||||
const itemIdx = path[itemsIndex + 1] as number;
|
||||
const facilityName = form.getValues(`items.${itemIdx}.ruseUtztnFcltNm`);
|
||||
if (facilityName) {
|
||||
prefix += `[${facilityName}] `;
|
||||
}
|
||||
|
||||
|
||||
const fcBizsIndex = path.indexOf("fcBizs");
|
||||
if (fcBizsIndex > -1 && path.length > fcBizsIndex + 1) {
|
||||
const bizIdx = path[fcBizsIndex + 1] as number;
|
||||
@@ -194,7 +194,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 최종 오류 메시지 출력
|
||||
toast.error(`${prefix}${message}`);
|
||||
});
|
||||
@@ -239,7 +239,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
}
|
||||
}, [indexMng]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -266,7 +266,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
// ] as fcBizType[],
|
||||
// })
|
||||
// );
|
||||
append(createDefaultPbnstItem(selecTableRow, pbnstRes.length));
|
||||
append(createDefaultPbnstItem(selecTableRow, pbnstRes.length));
|
||||
|
||||
setIsRuseReg({ isModal: true });
|
||||
}
|
||||
@@ -366,24 +366,24 @@ export default function PublicReuseFaciltyInsert() {
|
||||
</ListDiv>
|
||||
</div>
|
||||
<ListDiv className="col-span-2 pr-6 ">
|
||||
<ScrollArea className="h-[60vh]">
|
||||
{formWatch && formWatch[0]?.pbnstRuseFcltPk ? (
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">
|
||||
시설정보
|
||||
</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={form.handleSubmit(onSubmit, onInvalid)}
|
||||
className="!justify-end" // 저장 버튼 위치 조정
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
{formWatch && formWatch[0]?.pbnstRuseFcltPk ? (
|
||||
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="mng">
|
||||
시설정보
|
||||
</TabsTrigger>
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={form.handleSubmit(onSubmit, onInvalid)}
|
||||
className="!justify-end" // 저장 버튼 위치 조정
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
<ScrollArea className="h-[60vh]">
|
||||
<TabsContent className="max-h-full" value="mng">
|
||||
<PbnstMngForm
|
||||
formType="update"
|
||||
@@ -406,17 +406,19 @@ export default function PublicReuseFaciltyInsert() {
|
||||
indexBiz={indexBiz}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
) : (
|
||||
<>
|
||||
|
||||
</ScrollArea>
|
||||
</Tabs>
|
||||
) : (
|
||||
<>
|
||||
<div className="card-header text-2xl">
|
||||
등록된 재이용시설 정보가 없습니다.
|
||||
등록된 재이용시설 정보가 없습니다.
|
||||
</div>
|
||||
<div className="!mx-[1.6rem] !p-0r flex flex-col items-center justify-center h-64 border rounded-md">
|
||||
<p className="text-3xl mb-4">
|
||||
신규등록 버튼을 클릭하여 재이용시설을 등록해주세요.
|
||||
</p>
|
||||
<Button
|
||||
<div className="!mx-[1.6rem] !p-0r flex flex-col items-center justify-center h-64 border rounded-md">
|
||||
<p className="text-3xl mb-4">
|
||||
신규등록 버튼을 클릭하여 재이용시설을 등록해주세요.
|
||||
</p>
|
||||
<Button
|
||||
size={"sm"}
|
||||
className=""
|
||||
onClick={() => {
|
||||
@@ -433,11 +435,10 @@ export default function PublicReuseFaciltyInsert() {
|
||||
>
|
||||
신규등록
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
</>
|
||||
|
||||
)}
|
||||
</ScrollArea>
|
||||
)}
|
||||
</ListDiv>
|
||||
<UiModal
|
||||
body={
|
||||
@@ -450,7 +451,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
}
|
||||
}}
|
||||
|
||||
onInvalid ={onInvalid}
|
||||
onInvalid={onInvalid}
|
||||
></PbnstRegModal>
|
||||
}
|
||||
bodyClass="w-[68vw] max-w-none h-[90vh]"
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function HtdflSttn() {
|
||||
const { code, htdflSttn, htdflSttnSearch, initHtdfl } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { htdflSttnRes } = htdflSttn;
|
||||
const { htdflSttnRes, htdflSttnResCount } = htdflSttn;
|
||||
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
|
||||
@@ -61,8 +61,8 @@ export default function HtdflSttn() {
|
||||
const excelClick = useCallback(() => {
|
||||
// 최신 검색 조건 반영
|
||||
const con = getConValue();
|
||||
htdflSttnSearch(true, 1, "20", String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
}, [htdflSttnSearch, objSearch, code.cityCd, code.sggCd]);
|
||||
htdflSttnSearch(true, pageNation, String(htdflSttnResCount), String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
}, [htdflSttnSearch, objSearch, code.cityCd, code.sggCd, pageNation, fcltNm, htdflSttnResCount]);
|
||||
|
||||
useEffect(() => {
|
||||
htdflSttnSearch(false, pageNation, "20", String(getConValue()), fcltNm, code.cityCd, code.sggCd);
|
||||
@@ -120,7 +120,7 @@ export default function HtdflSttn() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!htdflSttn.isInit) {
|
||||
initHtdfl(1, "20", "0", fcltNm, code.cityCd, code.sggCd);
|
||||
initHtdfl(false, 1, "20", "0", fcltNm, code.cityCd, code.sggCd);
|
||||
}
|
||||
}, [htdflSttn.isInit, initHtdfl]);
|
||||
|
||||
@@ -152,7 +152,10 @@ export default function HtdflSttn() {
|
||||
label="시도"
|
||||
selectClass={""}
|
||||
selectArray={code.cityCd}
|
||||
onSelectValue={getSelCity}
|
||||
onSelectValue={(val) => {
|
||||
getSelCity(val)
|
||||
setPageNation(1)
|
||||
}}
|
||||
/>
|
||||
<SelectBox
|
||||
className="col-span-2 w-1/6 h-full text-2xl ml-4"
|
||||
@@ -160,7 +163,10 @@ export default function HtdflSttn() {
|
||||
selectClass={""}
|
||||
selectArray={selectSgg || []}
|
||||
value={objSearch.sgg} // value props 추가
|
||||
onSelectValue={getSgg}
|
||||
onSelectValue={(val) => {
|
||||
getSgg(val)
|
||||
setPageNation(1)
|
||||
}}
|
||||
/>
|
||||
<div className="col-span-2 flex flex-row space-x-2">
|
||||
<Label className="w-28 mt-2 text-xl text-gray-600">
|
||||
@@ -219,7 +225,7 @@ export default function HtdflSttn() {
|
||||
}
|
||||
headlist={htdflSttn.htdflSttHeadList}
|
||||
pageSize={20}
|
||||
total={100000}
|
||||
total={htdflSttnResCount || 0}
|
||||
cellClick={(index: number | undefined, headId: string) => {
|
||||
cellClick(index ?? undefined, headId);
|
||||
}}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function RainSttn() {
|
||||
const { code, rainSttn, rainSttnSearch, rainSttnInit } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { rainSttnRes } = rainSttn;
|
||||
const { rainSttnRes, rainSttnResCount } = rainSttn;
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
|
||||
const [pageNation, setPageNation] = useState(1);
|
||||
@@ -96,7 +96,7 @@ export default function RainSttn() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!rainSttn.isInit) {
|
||||
rainSttnInit(1, "20", "0", fcltNm, code.cityCd, code.sggCd);
|
||||
rainSttnInit(false, 1, "20", "0", fcltNm, code.cityCd, code.sggCd);
|
||||
}
|
||||
}, [rainSttn.isInit, rainSttnInit]);
|
||||
|
||||
@@ -132,7 +132,7 @@ export default function RainSttn() {
|
||||
}, [code, rainSttnRes, rainSttn.rainSttHeadList]);
|
||||
|
||||
useEffect(() => {
|
||||
rainSttnSearch(pageNation, "20", String(getConValue()), fcltNm, code.cityCd, code.sggCd);
|
||||
rainSttnSearch(false, pageNation, "20", String(getConValue()), fcltNm, code.cityCd, code.sggCd);
|
||||
}, [pageNation]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -150,8 +150,8 @@ export default function RainSttn() {
|
||||
const excelClick = useCallback(() => {
|
||||
// 최신 검색 조건 반영
|
||||
const con = getConValue();
|
||||
rainSttnSearch(1, "10000", String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
}, [rainSttnSearch, objSearch, code.cityCd, code.sggCd]);
|
||||
rainSttnSearch(true, pageNation, String(rainSttnResCount), String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
}, [rainSttnSearch, objSearch, code.cityCd, code.sggCd, pageNation, fcltNm, rainSttnResCount]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -167,7 +167,10 @@ export default function RainSttn() {
|
||||
label="시도"
|
||||
selectClass={""}
|
||||
selectArray={code.cityCd}
|
||||
onSelectValue={getSelCity}
|
||||
onSelectValue={(val) => {
|
||||
getSelCity(val)
|
||||
setPageNation(1)
|
||||
}}
|
||||
/>
|
||||
<SelectBox
|
||||
className="col-span-2 w-1/6 h-full text-2xl ml-4"
|
||||
@@ -175,7 +178,10 @@ export default function RainSttn() {
|
||||
selectClass={""}
|
||||
selectArray={selectSgg || []}
|
||||
value={objSearch.sgg} // value props 추가
|
||||
onSelectValue={getSgg}
|
||||
onSelectValue={(val) => {
|
||||
getSgg(val)
|
||||
setPageNation(1)
|
||||
}}
|
||||
/>
|
||||
<div className="col-span-2 flex flex-row space-x-2">
|
||||
<Label className="w-28 mt-2 text-xl text-gray-600">
|
||||
@@ -197,7 +203,7 @@ export default function RainSttn() {
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
const con = getConValue();
|
||||
rainSttnSearch(pageNation, "20", String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
rainSttnSearch(false, pageNation, "20", String(con), fcltNm, code.cityCd, code.sggCd);
|
||||
}}
|
||||
>
|
||||
조회
|
||||
@@ -234,7 +240,7 @@ export default function RainSttn() {
|
||||
}
|
||||
headlist={rainSttn.rainSttHeadList}
|
||||
pageSize={20}
|
||||
total={100000}
|
||||
total={rainSttnResCount || 0}
|
||||
cellClick={(index: number | undefined, headId: string) => { cellClick(index ?? undefined, headId) }}
|
||||
onPageChange={setPageNation}
|
||||
></UiTable>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { CommonTableProps } from "@/app/store/common/type/header";
|
||||
import { deleteFectch, fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { deleteFectch, fetchType, getFetch, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import { z } from "zod";
|
||||
import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
|
||||
@@ -20,6 +20,8 @@ export type ldrmntState = {
|
||||
excelList: ExcelType[];
|
||||
isInit: boolean;
|
||||
ldrmntRes: customLdrmnt[];
|
||||
isLoading: boolean;
|
||||
ldrmntResCount: number;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -32,9 +34,10 @@ const excelDownList: ExcelType[] = [];
|
||||
type ldrmntActions = {
|
||||
ldrmntRegData: (data: any[]) => void,
|
||||
ldrmntInit: (con: string) => void
|
||||
ldrmntSearch: (page: number, sggCd: string, total: string, coNm: string) => void;
|
||||
ldrmntSearch: (isExcel:boolean, page: number, sggCd: string, total: string, coNm: string) => void;
|
||||
ldrmntUpdate: (ldrmntRes: customLdrmnt) => void;
|
||||
ldrmntDelete: () => void;
|
||||
loadingOpen: (isOpen: boolean) => void
|
||||
};
|
||||
|
||||
export type ldrmntType = ldrmntState & ldrmntActions;
|
||||
@@ -46,6 +49,8 @@ export const ldrmntStateExport: ldrmntState = {
|
||||
excelList: [],
|
||||
isInit: false,
|
||||
ldrmntRes: ldrmntRes,
|
||||
isLoading: false,
|
||||
ldrmntResCount: 1,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -55,7 +60,7 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
return {
|
||||
ldrmntInit: async (con: string) => {
|
||||
try {
|
||||
const ldrmntRes = await getFetch(
|
||||
const ldrmntRes = await getFetchWithCount(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/temp/1/20/${con}`
|
||||
);
|
||||
@@ -65,7 +70,8 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
...state,
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
ldrmntRes: ldrmntRes,
|
||||
ldrmntRes: ldrmntRes.data,
|
||||
ldrmntResCount: ldrmntRes.count,
|
||||
isInit: false,
|
||||
excelList: excelDownList,
|
||||
},
|
||||
@@ -75,33 +81,32 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
ldrmntRegData: async (data) => {
|
||||
try {
|
||||
const response = await postFectch(
|
||||
"/reuseFc/request/temp",
|
||||
data,
|
||||
fetchType.WR
|
||||
);
|
||||
|
||||
console.log('response ', response)
|
||||
|
||||
if (response.status === 200) {
|
||||
ToastFormUi({
|
||||
body: "잠재수요처 등록이 완료되었습니다. ",
|
||||
title: "잠재수요처 등록",
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
ToastFormUi({
|
||||
body: "잠재수요처 등록이 실패하였습니다. ",
|
||||
title: "잠재수요처 등록",
|
||||
});
|
||||
|
||||
}
|
||||
loadingOpen: (isOpen) => {
|
||||
return set((state: ldrmntState) => {
|
||||
return {
|
||||
...state,
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
isLoading: isOpen,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
ldrmntSearch: async (page: number, total: string, sggCd: string, coNm: string) => {
|
||||
ldrmntRegData: async (data) => {
|
||||
await deleteFectch(
|
||||
`/reuseFc/request/temp`,
|
||||
);
|
||||
|
||||
const response = await postFectch(
|
||||
"/reuseFc/request/temp",
|
||||
data,
|
||||
fetchType.WR
|
||||
);
|
||||
|
||||
console.log('response ', response)
|
||||
|
||||
},
|
||||
ldrmntSearch: async (isExcel:boolean, page: number, total: string, sggCd: string, coNm: string) => {
|
||||
let searchUrl = "";
|
||||
|
||||
if (sggCd !== "") {
|
||||
@@ -112,14 +117,14 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
}
|
||||
}
|
||||
try {
|
||||
const ldrmntRes = await getFetch(
|
||||
const ldrmntRes = await getFetchWithCount(
|
||||
fetchType.WR,
|
||||
searchUrl
|
||||
);
|
||||
|
||||
if (Number(total) > 5000) {
|
||||
console.log("알이에스", ldrmntRes)
|
||||
if (isExcel) {
|
||||
let excelDownList: ExcelType[] = [];
|
||||
ldrmntRes.forEach((item: customLdrmnt) => {
|
||||
ldrmntRes.data.forEach((item: customLdrmnt) => {
|
||||
excelDownList.push({
|
||||
ctpvCd: item.ctpvCd,
|
||||
sggCd: item.sggCd,
|
||||
@@ -135,7 +140,7 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
excelList: excelDownList,
|
||||
|
||||
ldrmntResCount: ldrmntRes.count,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -146,7 +151,8 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
...state,
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
ldrmntRes: ldrmntRes,
|
||||
ldrmntRes: ldrmntRes.data,
|
||||
ldrmntResCount: ldrmntRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
@@ -178,11 +184,30 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
},
|
||||
ldrmntDelete: async () => {
|
||||
try {
|
||||
set((state: ldrmntState) => {
|
||||
return {
|
||||
...state,
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
isLoading: true,
|
||||
},
|
||||
};
|
||||
});
|
||||
const response = await deleteFectch(
|
||||
`/reuseFc/request/temp`,
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.log("error", error)
|
||||
set((state: ldrmntState) => {
|
||||
return {
|
||||
...state,
|
||||
ldrmnt: {
|
||||
...state.ldrmnt,
|
||||
isLoading: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
console.error("Error ldrmntDelete:", error);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,13 +2,13 @@ import type { SelectDataType } from "@common/business_components/ui";
|
||||
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
|
||||
|
||||
export const excelHtdflSttnParsing = (
|
||||
data: customHtdflBdst[],
|
||||
excel: customHtdflBdst[],
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]
|
||||
): string[][] => {
|
||||
const excelExportData: string[][] = [];
|
||||
|
||||
data.forEach((item) => {
|
||||
excel.data.forEach((item) => {
|
||||
excelExportData.push([
|
||||
sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
|
||||
sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { sttnHeadListType } from "../rainSttn/headList";
|
||||
import type { z } from "zod";
|
||||
import { controlHeadView } from "../rainSttn";
|
||||
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { fetchType, getFetch, getFetchWithCount } from "@/components/lib/api";
|
||||
import type { SelectDataType } from "@common/business_components/ui";
|
||||
import { excelHtdflSttnParsing } from "./excel";
|
||||
|
||||
@@ -18,16 +18,16 @@ export type htdflSttnState = {
|
||||
htdflSttNodeList: CommonTableProps[];
|
||||
htdflSttnRes: customHtdflBdst[]
|
||||
excelList: [];
|
||||
|
||||
htdflSttnResCount: number;
|
||||
};
|
||||
};
|
||||
type htdflSttnActions = {
|
||||
initHtdfl: (page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
htdflSttnSearch: (isExcel:boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
initHtdfl: (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
htdflSttnSearch: (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
htdflChSttnHead: (
|
||||
headList: z.infer<typeof sttnHeadListType>,
|
||||
) => void;
|
||||
@@ -42,12 +42,13 @@ export const htdflSttnStateExport: htdflSttnState = {
|
||||
htdflSttnRes: [],
|
||||
excelList: [],
|
||||
isInit: false,
|
||||
htdflSttnResCount: 1,
|
||||
},
|
||||
};
|
||||
const initFetch = async (page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
const htdflRes = await getFetch(
|
||||
const htdflRes = await getFetchWithCount(
|
||||
"wr",
|
||||
`/drain/facilityList` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
@@ -63,30 +64,44 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
|
||||
set: any
|
||||
) => {
|
||||
return {
|
||||
initHtdfl: async (page: number, total: string, con: string, txt: string,
|
||||
initHtdfl: async (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
try {
|
||||
const htdflSttnRes = await initFetch(page, total, con, txt, sidoCode, sggCode);
|
||||
set((state: htdflSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
htdflSttn: {
|
||||
...state.htdflSttn,
|
||||
htdflSttnRes: htdflSttnRes,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
if (isExcel) {
|
||||
const htdflExcel = excelHtdflSttnParsing(htdflSttnRes, sidoCode, sggCode);
|
||||
set((state: htdflSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
htdflSttn: {
|
||||
...state.htdflSttn,
|
||||
excelList: htdflExcel,
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
set((state: htdflSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
htdflSttn: {
|
||||
...state.htdflSttn,
|
||||
htdflSttnRes: htdflSttnRes.data,
|
||||
htdflSttnResCount: htdflSttnRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
htdflSttnSearch: async (isExcel:boolean, page: number, total: string, con: string, txt: string,
|
||||
htdflSttnSearch: async (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
try {
|
||||
const htdflSttnRes = await getFetch(
|
||||
const htdflSttnRes = await getFetchWithCount(
|
||||
fetchType.WR,
|
||||
`/drain/facilityList` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
@@ -112,7 +127,8 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
|
||||
...state,
|
||||
htdflSttn: {
|
||||
...state.htdflSttn,
|
||||
htdflSttnRes: htdflSttnRes,
|
||||
htdflSttnRes: htdflSttnRes.data,
|
||||
htdflSttnResCount: htdflSttnRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,13 +2,13 @@ import type { SelectDataType } from "@common/business_components/ui";
|
||||
import type { customRainBdst } from "../../fcltReg/rainReg";
|
||||
|
||||
export const excelRainSttnParsing = (
|
||||
data: customRainBdst[],
|
||||
excel: customRainBdst[],
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]
|
||||
): string[][] => {
|
||||
const excelExportData: string[][] = [];
|
||||
|
||||
data.forEach((item) => {
|
||||
excel.data.forEach((item) => {
|
||||
excelExportData.push([
|
||||
sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
|
||||
sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { fetchType, getFetch, getFetchWithCount } from "@/components/lib/api";
|
||||
import {
|
||||
type customRainBdst,
|
||||
} from "../../fcltReg/rainReg";
|
||||
@@ -96,15 +96,16 @@ export type rainSttnState = {
|
||||
rainChkRes: rainChkZodType
|
||||
excelList: [];
|
||||
isInit: boolean;
|
||||
rainSttnResCount: number;
|
||||
};
|
||||
};
|
||||
type rainSttnActions = {
|
||||
rainSttnInit: (page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void
|
||||
rainSttnSearch: (page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
rainSttnInit: (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void
|
||||
rainSttnSearch: (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => void;
|
||||
rainChSttnHead: (
|
||||
headList: z.infer<typeof sttnHeadListType>,
|
||||
) => void;
|
||||
@@ -123,6 +124,7 @@ export const rainSttnStateExport: rainSttnState = {
|
||||
rainChkRes: rainChkRes,
|
||||
excelList: [],
|
||||
isInit: false,
|
||||
rainSttnResCount: 1,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -130,12 +132,12 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
|
||||
set: any
|
||||
) => {
|
||||
return {
|
||||
rainSttnInit: async (page: number, total: string, con: string, txt: string,
|
||||
rainSttnInit: async (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
try {
|
||||
|
||||
const rainSttnRes = await getFetch(
|
||||
const rainSttnRes = await getFetchWithCount(
|
||||
fetchType.WR,
|
||||
`/reuseFc/rainyInfoList` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
@@ -143,33 +145,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : "")
|
||||
);
|
||||
set((state: rainSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
rainSttn: {
|
||||
...state.rainSttn,
|
||||
rainSttnRes: rainSttnRes,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
rainSttnSearch: async (page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
try {
|
||||
const rainSttnRes = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/rainyInfoList` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
(total ? `/${total}` : "/20") +
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : "")
|
||||
);
|
||||
if (Number(total) > 9000) {
|
||||
if (isExcel) {
|
||||
const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode);
|
||||
set((state: rainSttnState) => {
|
||||
return {
|
||||
@@ -180,13 +156,54 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
set((state: rainSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
rainSttn: {
|
||||
...state.rainSttn,
|
||||
rainSttnRes: rainSttnRes.data,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
rainSttnSearch: async (isExcel: boolean, page: number, total: string, con: string, txt: string,
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]) => {
|
||||
try {
|
||||
const rainSttnRes = await getFetchWithCount(
|
||||
fetchType.WR,
|
||||
`/reuseFc/rainyInfoList` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
(total ? `/${total}` : "/20") +
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : "")
|
||||
);
|
||||
if (isExcel) {
|
||||
const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode);
|
||||
set((state: rainSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
rainSttn: {
|
||||
...state.rainSttn,
|
||||
excelList: rainExcel,
|
||||
rainSttnResCount: rainSttnRes.count,
|
||||
},
|
||||
};
|
||||
});
|
||||
} else
|
||||
set((state: rainSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
rainSttn: {
|
||||
...state.rainSttn,
|
||||
rainSttnRes: rainSttnRes,
|
||||
rainSttnRes: rainSttnRes.data,
|
||||
rainSttnResCount: rainSttnRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { SelectDataType } from "@common/business_components/ui";
|
||||
import type { customRswtBdst } from "../../fcltReg/rswtReg";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { bdstUsgCd } from "@/app/store/common/code/basicCode";
|
||||
|
||||
export const excelRSwtSttnParsing = (
|
||||
excel: customRswtBdst[],
|
||||
@@ -14,7 +15,7 @@ export const excelRSwtSttnParsing = (
|
||||
sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
|
||||
item.bdstNm ?? "",
|
||||
item.daddr ?? "",
|
||||
String(item.bdstUsgCd === -1 || item.bdstUsgCd === undefined ? "확인불가" : item.bdstUsgCd ?? ""), //건축물용도
|
||||
bdstUsgCd.find((cd)=> cd.val === item.reuseBuilding?.[0]?.bdstUsgCd.toString())?.text ?? "", //건축물용도
|
||||
String(item.frstArchPrmsnDt ?? ""),
|
||||
String(item.archArea.split('.')[0] === '-1' ? '확인불가' : item.archArea.split('.')[0]),
|
||||
String(item.reuseBuilding?.[0]?.rswtrObj.wtrUsqty ?? "0"), //물사용량
|
||||
|
||||
@@ -71,7 +71,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : "")
|
||||
);
|
||||
console.log("rswtSttnResㅇㅇ", rswtSttnRes)
|
||||
if (isExcel) {
|
||||
const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode);
|
||||
set((state: rswtSttnState) => {
|
||||
@@ -80,7 +79,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
|
||||
rswtSttn: {
|
||||
...state.rswtSttn,
|
||||
excelList: rswtExcel,
|
||||
rswtSttnResCount: rswtSttnRes.count,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -97,20 +95,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
|
||||
},
|
||||
};
|
||||
});
|
||||
// }
|
||||
|
||||
// set((state: rswtSttnState) => {
|
||||
// return {
|
||||
// ...state,
|
||||
// rswtSttn: {
|
||||
// ...state.rswtSttn,
|
||||
// rswtSttnRes: rswtSttnRes.data,
|
||||
// rswtSttnResCount: rswtSttnRes.count,
|
||||
// excelList: rswtExcel,
|
||||
// isInit: false,
|
||||
// },
|
||||
// };
|
||||
// });
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
@@ -127,6 +111,12 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : "")
|
||||
);
|
||||
console.log("주소",`/reuseFc/waterreuseFc` +
|
||||
(page ? `/${page}` : "/1") +
|
||||
(total ? `/${total}` : "/20") +
|
||||
(con ? `/${con}` : "/0") +
|
||||
(txt ? `/${txt}` : ""))
|
||||
console.log("rswtSttnRes", rswtSttnRes)
|
||||
if (isExcel) {
|
||||
const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode);
|
||||
set((state: rswtSttnState) => {
|
||||
@@ -135,7 +125,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
|
||||
rswtSttn: {
|
||||
...state.rswtSttn,
|
||||
excelList: rswtExcel,
|
||||
rswtSttnResCount: rswtSttnRes.count,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -4,32 +4,39 @@ import type { customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { names } from "@/app/store/matDmd/ldrmntCoSttn/excel";
|
||||
import { filePicked, FileUpload, FormUi, Title } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Progress } from "@common/components/ui";
|
||||
import LoadingOverlay from "@common/business_components/ui/loadingBar";
|
||||
import { Button, Input, Progress } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function CoRegExcel() {
|
||||
|
||||
|
||||
export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => void }) {
|
||||
const { ldrmnt, loadingOpen } = useWrStore((state) => state);
|
||||
const { isLoading } = ldrmnt;
|
||||
const form = useForm<z.infer<typeof coRegExcel>>({
|
||||
resolver: zodResolver(coRegExcel),
|
||||
});
|
||||
const { ldrmntRegData, ldrmntDelete } = useWrStore((state) => state);
|
||||
const [excelData, setExcelData] = useState<customLdrmnt[]>();
|
||||
|
||||
|
||||
const [file, setFiles] = useState<File | undefined>();
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const selectedFile = e.target.files?.[0];
|
||||
if (selectedFile) {
|
||||
setFiles(selectedFile);
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = (values: z.infer<typeof coRegExcel>) => {
|
||||
ldrmntDelete();
|
||||
loadingOpen(true);
|
||||
if (file) {
|
||||
filePicked(file, 0).then((res) => {
|
||||
//TODO:loading
|
||||
filePicked(file, 0).then(async (res) => {
|
||||
|
||||
try {
|
||||
let array: { [key: string]: string | number }[] = []
|
||||
let isError = false;
|
||||
if (Array.isArray(res)) {
|
||||
res.some((item, index) => {
|
||||
let object: { [key: string]: string | number } = {}
|
||||
@@ -43,26 +50,24 @@ export default function CoRegExcel() {
|
||||
}
|
||||
return false;
|
||||
})
|
||||
if (isError === true)
|
||||
return true;
|
||||
|
||||
array.push(object)
|
||||
|
||||
if (index != 0 && index % 5000 == 0) {
|
||||
ldrmntRegData(array);
|
||||
array = []
|
||||
array.length = 0;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
}
|
||||
if (isError === false)
|
||||
ldrmntRegData(array);
|
||||
await ldrmntRegData(array);
|
||||
isModal(false);
|
||||
loadingOpen(false);
|
||||
toast.success(`잠재수요처 등록이 완료되었습니다.`);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
loadingOpen(false);
|
||||
alert(e)
|
||||
return true;
|
||||
}
|
||||
|
||||
}).catch((e) => {
|
||||
console.log("file", e);
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -70,6 +75,7 @@ export default function CoRegExcel() {
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<LoadingOverlay isLoading={isLoading}></LoadingOverlay>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<div>
|
||||
@@ -91,14 +97,13 @@ export default function CoRegExcel() {
|
||||
name="file"
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<FileUpload
|
||||
files={file ? [file] : []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files && files?.length === 1) setFiles(files[0]);
|
||||
}}
|
||||
fileTypes=""
|
||||
maxFiles={1}
|
||||
></FileUpload>
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={handleFileChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
/>
|
||||
</div>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user