108 lines
3.1 KiB
TypeScript
108 lines
3.1 KiB
TypeScript
import { fetchType, postFectch } from "@/components/lib/api";
|
|
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
|
|
import { checkWrRegList } from "../../ruseFcltMng/fcltReg/pbnstReg";
|
|
import type { ReturnType } from "@common/business_components/ui";
|
|
import { pubFacHeadListExport } from "../../ruseFcltMng/fcltReg/pbnstReg/headList";
|
|
import type { TableUpperProps } from "../../common/type/header";
|
|
|
|
|
|
export const pbnMapTableSize =20;
|
|
|
|
const hasuListFetch = async (page: number, pageTotal:number, reurnValue: ReturnType, searchNm?:string) => {
|
|
|
|
let url = `/prcsFclt/ruseInfo/${page}/${pageTotal}/`;
|
|
const checkWrRegListRes = await checkWrRegList();
|
|
|
|
if (reurnValue.partValue === "A") {
|
|
url += `${reurnValue.partValue}/${
|
|
// reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue
|
|
reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue
|
|
}/0/1/SW`
|
|
|
|
|
|
} else if (reurnValue.partValue === "R") {
|
|
url += `${reurnValue.partValue}/${reurnValue.regionValue
|
|
? reurnValue.regionValue
|
|
: reurnValue.unitWaterShedValue
|
|
? reurnValue.unitWaterShedValue
|
|
: reurnValue.middleRegionValue
|
|
}/0/1/SW`
|
|
} else if (reurnValue.partValue === 'G') {
|
|
url += `${reurnValue.envPartValue}/${reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue}/0/1/SW`
|
|
} else {
|
|
url += `A/0/0/1/SW`
|
|
}
|
|
if (searchNm && searchNm?.length > 0) {
|
|
url += "/" + searchNm
|
|
}
|
|
|
|
|
|
|
|
const data = checkWrRegListRes.filter((item:string) => item !== "")
|
|
|
|
const rainRes = await postFectch(
|
|
url,
|
|
data,
|
|
fetchType.COMMON
|
|
);
|
|
|
|
const hasuList = rainRes.data.map((item: any) => {
|
|
return {
|
|
...item,
|
|
fctCpc: Number(item.fctCpc) || 0,
|
|
ruse: item.ruse === false ? "N" : "Y",
|
|
};
|
|
});
|
|
|
|
return {data: hasuList, count:rainRes.count};
|
|
};
|
|
|
|
export type pbnMapState = {
|
|
pbnMap: {
|
|
isInit:boolean,
|
|
pbnMapRes:pubHasuType[]
|
|
pbnMapCount:number;
|
|
pbnMapHeadList:TableUpperProps[];
|
|
};
|
|
};
|
|
|
|
type pbnMapActions = {
|
|
pbnMapInit: (page: number, pageTotal:number, reurnValue: ReturnType) => void;
|
|
};
|
|
|
|
export type pbnMapType = pbnMapState & pbnMapActions;
|
|
|
|
export const pbnMapStateExport: pbnMapState = {
|
|
pbnMap: {
|
|
isInit: false,
|
|
pbnMapRes:[],
|
|
pbnMapCount:1,
|
|
pbnMapHeadList:pubFacHeadListExport
|
|
},
|
|
};
|
|
|
|
|
|
export const pbnMapActionsExport: (set: any) => pbnMapActions = (
|
|
set: any
|
|
) => {
|
|
return {
|
|
pbnMapInit: async (page: number, pageTotal:number, reurnValue: ReturnType) => {
|
|
try {
|
|
const pubMapRes = await hasuListFetch(page,pageTotal,reurnValue)
|
|
set((state: pbnMapState) => {
|
|
return {
|
|
...state,
|
|
pbnMap: {
|
|
...state.pbnMap,
|
|
pbnMapRes: pubMapRes.data,
|
|
pbnMapCount: pubMapRes.count,
|
|
isInit: false,
|
|
},
|
|
};
|
|
});
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
},
|
|
}
|
|
} |