물재이용: 빗물이용 시설 내용 업데이트 시 테이블 index 조정
This commit is contained in:
@@ -48,14 +48,14 @@ export default function Home() {
|
||||
|
||||
const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth;
|
||||
|
||||
const { rainRes, rainResCount } = rain;
|
||||
const { rainRes, rainResCount ,rainTableIndex} = rain;
|
||||
const useInitRef = useRef(false);
|
||||
const [rainForm, setRainForm] = useState<customRainBdst>();
|
||||
const [issNewReg, setIsNewReg] = useState<boolean>(false);
|
||||
const [pageNation, setPageNation] = useState(1);
|
||||
const [bdstTable, setbdstTable] = useState<customRainBdst[]>();
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
|
||||
const [resetPageNo, setResetPageNo] = useState<boolean>(false);
|
||||
useEffect(() => {
|
||||
getLaeSeCdCheck();
|
||||
useInitRef.current = true;
|
||||
@@ -91,13 +91,23 @@ export default function Home() {
|
||||
const cellClick: (val: number | undefined) => void = (val) => {
|
||||
if (val !== undefined) {
|
||||
setRainForm(rainRes[val]);
|
||||
setResetPageNo(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getRainData(pageNation, laeSeCd);
|
||||
setResetPageNo(false);
|
||||
}, [pageNation]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof rainTableIndex === 'number' && rainTableIndex >= 0) {
|
||||
cellClick(rainTableIndex);
|
||||
setResetPageNo(true);
|
||||
}
|
||||
}, [rainTableIndex]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentsDiv>
|
||||
@@ -157,6 +167,8 @@ export default function Home() {
|
||||
cellClick(val);
|
||||
}}
|
||||
onPageChange={setPageNation}
|
||||
index={rainTableIndex}
|
||||
resetPageNo={resetPageNo}
|
||||
></UiTable>
|
||||
{/* </ScrollArea> */}
|
||||
</ListDiv>
|
||||
|
||||
@@ -88,6 +88,7 @@ export type rainFacState = {
|
||||
upHeadList: TableUpperProps[];
|
||||
rainRes: customRainBdst[];
|
||||
rainResCount: number;
|
||||
rainTableIndex?: number;
|
||||
};
|
||||
};
|
||||
type rainFacSActions = {
|
||||
@@ -96,6 +97,7 @@ type rainFacSActions = {
|
||||
rainSearch: (txt: string, pageNation: number, code: string) => void;
|
||||
rainBdstReg: (data: customRainBdst, code: string | number) => void;
|
||||
rainBdstUpdate: (data: customRainBdst, code: string | number) => void;
|
||||
ResetRainTableIndex:(index:number)=>void;
|
||||
};
|
||||
|
||||
export type rainFacType = rainFacState & rainFacSActions;
|
||||
@@ -105,6 +107,7 @@ export const rainFacStateExport: rainFacState = {
|
||||
rainRes: rainRes,
|
||||
rainResCount: 1,
|
||||
upHeadList: upHeadList,
|
||||
rainTableIndex: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -229,7 +232,6 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
if (res.status === 200) {
|
||||
if (data.chgBuilding.length > 0) {
|
||||
const chPK = data?.bdstInfoSn;
|
||||
console.log("chPK", chPK);
|
||||
const makeCh = data.chgBuilding.map((item: chgBuilding) => ({
|
||||
...item,
|
||||
bdstInfoSn: chPK,
|
||||
@@ -263,5 +265,19 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
ResetRainTableIndex: (index: number) => {
|
||||
// 1) 동일값도 '변경'으로 느끼게 잠깐 -1
|
||||
set((state: rainFacState) => ({
|
||||
...state,
|
||||
rain: { ...state.rain, rainTableIndex: -1 },
|
||||
}));
|
||||
// 2) 다음 마이크로태스크에서 진짜 값 복구
|
||||
Promise.resolve().then(() => {
|
||||
set((state: rainFacState) => ({
|
||||
...state,
|
||||
rain: { ...state.rain, rainTableIndex: index },
|
||||
}));
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -38,10 +38,11 @@ export default function RainRegForm({
|
||||
readonly?: boolean;
|
||||
isMap?: boolean;
|
||||
}) {
|
||||
const { code, rainBdstReg, rainBdstUpdate } = useWrStore(
|
||||
const { auth,code, rainBdstReg, rainBdstUpdate ,ResetRainTableIndex} = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { rainFcltCd } = code;
|
||||
const {laeSeCd } = auth;
|
||||
const form = useForm<z.infer<typeof rainZod>>({
|
||||
resolver: zodResolver(rainZod),
|
||||
// defaultValues: defaultValues,
|
||||
@@ -57,7 +58,7 @@ export default function RainRegForm({
|
||||
// const [divStyle, setDivStyle] = useState("h-[53vh]");
|
||||
useEffect(() => {
|
||||
if(isMap=== true){
|
||||
|
||||
|
||||
}
|
||||
}, [isMap]);
|
||||
|
||||
@@ -128,10 +129,10 @@ export default function RainRegForm({
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
|
||||
const onSubmit = (values: z.infer<typeof rainZod>) => {
|
||||
const onSubmit = async(values: z.infer<typeof rainZod>) => {
|
||||
if (isModal) {
|
||||
const data = regCtpvCd ? regCtpvCd : regSggcd ? regSggcd : "noCd";
|
||||
|
||||
|
||||
if (data === "noCd") {
|
||||
toast.error("시도/시군구 코드를 선택해야합니다.");
|
||||
return;
|
||||
@@ -143,7 +144,8 @@ export default function RainRegForm({
|
||||
confirmToast(t('isInsertMsg'), handleConfirm);
|
||||
} else {
|
||||
const handleConfirm = async () => {
|
||||
rainBdstUpdate(values, "41");
|
||||
await rainBdstUpdate(values, laeSeCd);
|
||||
ResetRainTableIndex(0)
|
||||
};
|
||||
confirmToast(t('isUpdateMsg'), handleConfirm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user