잠재수요처 엑셀 다운로드 수정, 페이징 처리 수정

This commit is contained in:
jyha00
2025-07-08 20:59:35 +09:00
parent e314369cbb
commit e30130dc8f
7 changed files with 37 additions and 29 deletions
@@ -42,7 +42,7 @@ export default function LdrmntCoSttn() {
const [bdstTable, setBdstTable] = useState<customLdrmnt[]>();
const [searchTxt, setSearchTxt] = useState<string>();
const [excelData, setExcelData] = useState<any[]>();
const [isExcelDownload, setIsExcelDownload] = useState(false);
// const [isExcelDownload, setIsExcelDownload] = useState(false);
const excelClick = useCallback(() => {
excelDownload(
@@ -77,20 +77,20 @@ export default function LdrmntCoSttn() {
const excelDownloadClick = useCallback(() => {
const cityNm = computeCityNm();
ldrmntSearch(true, pageNation, String(ldrmntResCount), cityNm, searchTxt || "");
setIsExcelDownload(true);
}, [objSearch, pageNation, searchTxt, code, ldrmntSearch, computeCityNm]);
// 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;
@@ -247,7 +247,7 @@ export default function LdrmntCoSttn() {
tableData={bdstTable || []}
headlist={ldrmntHeadListExport}
pageSize={20}
total={10000}
total={ldrmntResCount || 0}
cellClick={(index: number | undefined, headId: string) => { cellClick(index ?? undefined, headId) }}
onPageChange={setPageNation}
/>
@@ -60,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}`
);
@@ -70,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,
},
@@ -120,7 +121,7 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
fetchType.WR,
searchUrl
);
console.log("알이에스", ldrmntRes)
if (isExcel) {
let excelDownList: ExcelType[] = [];
ldrmntRes.data.forEach((item: customLdrmnt) => {
@@ -139,7 +140,7 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
ldrmnt: {
...state.ldrmnt,
excelList: excelDownList,
ldrmntResCount: ldrmntRes.count,
},
};
});
@@ -77,7 +77,6 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
htdflSttn: {
...state.htdflSttn,
excelList: htdflExcel,
htdflSttnResCount: htdflSttnRes.count
},
};
});
@@ -119,7 +118,6 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
htdflSttn: {
...state.htdflSttn,
excelList: htdflExcel,
htdflSttnResCount: htdflSttnRes.count
},
};
});
@@ -153,7 +153,6 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
rainSttn: {
...state.rainSttn,
excelList: rainExcel,
rainSttnResCount: rainSttnRes.count,
},
};
});
@@ -164,7 +163,6 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
rainSttn: {
...state.rainSttn,
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"), //물사용량
@@ -79,7 +79,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
rswtSttn: {
...state.rswtSttn,
excelList: rswtExcel,
rswtSttnResCount: rswtSttnRes.count,
},
};
});
@@ -112,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) => {
@@ -120,7 +125,6 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
rswtSttn: {
...state.rswtSttn,
excelList: rswtExcel,
rswtSttnResCount: rswtSttnRes.count,
},
};
});
@@ -5,7 +5,7 @@ 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 LoadingOverlay from "@common/business_components/ui/loadingBar";
import { Button, Progress } from "@common/components/ui";
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";
@@ -13,7 +13,7 @@ import toast from "react-hot-toast";
import type { z } from "zod";
export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => void }) {
const { ldrmnt,loadingOpen } = useWrStore((state) => state);
const { ldrmnt, loadingOpen } = useWrStore((state) => state);
const { isLoading } = ldrmnt;
const form = useForm<z.infer<typeof coRegExcel>>({
resolver: zodResolver(coRegExcel),
@@ -23,6 +23,13 @@ export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => vo
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>) => {
loadingOpen(true);
if (file) {
@@ -59,7 +66,7 @@ export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => vo
alert(e)
return true;
}
}).catch((e)=>{
}).catch((e) => {
console.log("file", e);
});
};
@@ -90,14 +97,13 @@ export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => vo
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>
)}
/>