지도점검 파일 등록 수정

This commit is contained in:
leedj312
2025-07-09 11:37:46 +09:00
parent bb70090766
commit b444f24d41
5 changed files with 41 additions and 40 deletions
@@ -92,6 +92,7 @@ export default function Page() {
commonCd,
fcltNm
);
setRainPageNation(1);
} else {
rainChkInit(rainPageNation, rainPageSize, searchYear, commonCd);
}
@@ -104,6 +105,7 @@ export default function Page() {
commonCd,
fcltNm
);
setRswtPageNation(1);
} else {
rswtChkgdnInit(rswtPageNation, rswtPageSize, searchYear, commonCd);
}
@@ -202,22 +204,22 @@ export default function Page() {
const clickDelete = (data: number[], selFcltDiv: string) => {
if (data.length > 0) {
if (selFcltDiv === "RNB") {
rainChkDelete(data);
rainChkDelete(data, searchYear);
} else {
rswtChkDelete(data);
rswtChkDelete(data, searchYear);
}
}
};
const chkUpdateTable = (selFcltDiv: string) => {
if (selFcltDiv === "RNB") {
if (updateRainDetail && updateRainDetail.length > 0) {
rainChkDetilUpdate(updateRainDetail);
} else {
rainChkDetilUpdate(updateRainDetail, searchYear);
} else {
toast.error("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
}
} else {
if (updateRswtDetail && updateRswtDetail.length > 0) {
rswtChkDetilsUpdate(updateRswtDetail);
rswtChkDetilsUpdate(updateRswtDetail, searchYear);
} else {
toast.error("수정을 원하는 행을 선택하고 저장버튼을 눌러주세요 ");
}
@@ -297,14 +299,14 @@ export default function Page() {
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
size={"sm"}
onClick={() => {
chkUpdateTable(selFcltDiv);
}}
>
저장
</Button>
<Button
size={"sm"}
onClick={() => {
chkUpdateTable(selFcltDiv);
}}
>
저장
</Button>
</TooltipTrigger>
<TooltipContent side="bottom" sideOffset={5}>
<h2 className="text-xl">
@@ -314,7 +316,6 @@ export default function Page() {
</Tooltip>
</TooltipProvider>
<Button
size={"sm"}
onClick={() => {
@@ -343,7 +344,8 @@ export default function Page() {
rainChkData={rainChkgdn.rainChk}
pageNation={rainPageNation}
onPageChange={rainPageChange}
pageCount={rainChkgdn.rainChkCount} />
pageCount={rainChkgdn.rainChkCount}
/>
) : (
<RswtChkgdTable
detaiRswtlUpdate={setUpdateRSwtDetail}
@@ -380,6 +382,9 @@ export default function Page() {
<ChkgdExcel
type={selFcltDiv}
setIsRegExcel={setIsRegExcel}
setYearChange={(year) => {
setSearchYear(year);
}}
></ChkgdExcel>
}
/>
@@ -68,14 +68,14 @@ type rainChkgdnActions = {
sggCd: string,
searchTxt: string
) => void;
rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise<void>;
rainChkDetilUpdate(rainChk: rainChkZodType[] ,year:string) : Promise<void>;
rainChkGuidUpdate(rainChk: rainChkZodType): Promise<void>;
rainChkExcelDownload(
sidoCode: SelectDataType[],
sggCode: SelectDataType[]
): Promise<void>;
rainChkExcelDataUPload(excelData: rainChkZodType[]): Promise<void>;
rainChkDelete(chkgdnPks: number[]): Promise<void>;
rainChkExcelDataUPload(excelData: rainChkZodType[] ,year :string) : Promise<void>;
rainChkDelete(chkgdnPks: number[] ,year :string): Promise<void>;
rainChkHeadChange: (rainChkgdn: rainChkgdnState, isEdit: boolean) => void;
rainChkNmSearch: (
pageNo: number,
@@ -165,7 +165,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
},
}));
},
rainChkExcelDataUPload: async (excelData: rainChkZodType[]) => {
rainChkExcelDataUPload: async (excelData: rainChkZodType[] ,year:string) => {
set((state: rainChkgdnType) => (
{ rainChkgdn: { ...state.rainChkgdn, isLoading: true } }));
try {
@@ -175,7 +175,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
const rainChkRes = await initFetch(
1,
rainPageSize,
currentYear,
year,
commonCd
);
set((state: rainChkgdnState) => ({
@@ -255,7 +255,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
console.log(error);
}
},
rainChkDetilUpdate: async (rainChk: rainChkZodType[]) => {
rainChkDetilUpdate: async (rainChk: rainChkZodType[] ,year:string) => {
try {
const chData = await makeMdfrChk(rainChk, "rain", "rainDetil");
@@ -264,11 +264,10 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
toast.success(
"지도점검 대체수 및 밋물이용량 수정이 완료되었습니다. "
);
const currentYear = new Date().getFullYear().toString();
const rainChkRes = await initFetch(
1,
rainPageSize,
currentYear,
year,
"41"
);
return set((state: rainChkgdnState) => ({
@@ -317,18 +316,17 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
toast.error("지도점검 수질 및 과태료 수정 오류입니다.");
}
},
rainChkDelete: async (chkgdnPks: number[]) => {
rainChkDelete: async (chkgdnPks: number[] ,year :string) => {
try {
const res = await deleteFectch(`/reuseChk/rainy`, chkgdnPks);
if (res) {
toast.success("삭제가 완료되었습니다. ");
const currentYear = new Date().getFullYear().toString();
const rainChkRes = await initFetch(
1,
rainPageSize,
currentYear,
year,
"41"
);
return set((state: rainChkgdnState) => ({
@@ -78,8 +78,8 @@ type rswtChkgdnActions = {
sggCode: SelectDataType[]
): Promise<void>;
rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void;
rswtChkDelete: (chkgdnPks: number[]) => void;
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[]) => void;
rswtChkDelete: (chkgdnPks: number[] ,year:string) => void;
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[] ,year:string) => void;
rswtChkPolAndGuide: (chkGdnPk: number) => void;
rswtChkPolInit: () => void;
rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void;
@@ -189,7 +189,6 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
try {
const rswtChkRes = await initFetch(pageNo, cnt, year, sggCd);
console.log("rswtChkRes", rswtChkRes)
set((state: rswtChkgdnState) => ({
...state,
@@ -271,7 +270,7 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
}
},
rswtChkDetilsUpdate: async (rswtChk: rswtrChkDetailsZodType[]) => {
rswtChkDetilsUpdate: async (rswtChk: rswtrChkDetailsZodType[] ,year:string) => {
try {
const chData = await makeMdfrChk(rswtChk);
@@ -279,8 +278,7 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
if (res.ok) {
toast.success("지도점검 과태료 수정이 완료되었습니다. ",)
}
const currentYear = new Date().getFullYear().toString();
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, "0");
const rswtChkRes = await initFetch(1, rswtPageSize, year, "0");
return set((state: rswtChkgdnState) => ({
...state,
rswtChkgdn: {
@@ -295,15 +293,14 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
}
},
rswtChkDelete: async (chkgdnPks: number[]) => {
rswtChkDelete: async (chkgdnPks: number[] ,year:string) => {
try {
const res = await deleteFectch(`/reuseChk/reuseWater`, chkgdnPks);
if (res) {
toast.success("삭제가 완료되었습니다.")
}
const currentYear = new Date().getFullYear().toString();
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, "0");
const rswtChkRes = await initFetch(1, rswtPageSize, year, "0");
return set((state: rswtChkgdnState) => ({
...state,
rswtChkgdn: {
@@ -23,7 +23,7 @@ import { useForm } from "react-hook-form";
import toast from "react-hot-toast";
import type { z } from "zod";
export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setIsRegExcel:(open:boolean) =>void }) {
export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type: string, setIsRegExcel:(open:boolean) =>void ,setYearChange:(year:string)=> void }) {
const { rswtChkgdn, rainChkExcelDataUPload, rswtChkExceDataUpload } =
useWrStore((state) => {
return state;
@@ -76,7 +76,6 @@ export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setI
const excelData = excelToRainChkData(res, form.getValues("chckYr"))
if(res !== undefined)
setExcelData(excelData)
// if( excelData&&excelData.errors.length>0){
// excelData.errors.forEach((err) =>{
@@ -169,9 +168,9 @@ export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setI
return;
} else {
rainChkExcelDataUPload(excelData as rainChkZodType[]);
rainChkExcelDataUPload(excelData as rainChkZodType[] , form.getValues("chckYr")) ;
setIsRegExcel(false)
setYearChange(form.getValues("chckYr"))
}
} else if (type === "RST") {
if (excelRswtData === undefined || excelRswtData?.length === 0) {
@@ -181,10 +180,11 @@ export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setI
} else {
rswtChkExceDataUpload(excelRswtData as rswtChkZodType[]);
setIsRegExcel(false)
setYearChange(form.getValues("chckYr"))
}
}
}
};
return (
<>
@@ -213,6 +213,7 @@ export default function ChkgdModal({ type, obj, setIsModal }: { type: string; ob
});
obj.guideDetails = realGuideDetail;
if (type === "RNB") {
rainChkGuidUpdate(obj);
setIsModal(false)
} else {