120 lines
3.5 KiB
TypeScript
120 lines
3.5 KiB
TypeScript
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
|
|
import type { CommonTableProps } from "../../common/type/header";
|
|
import { coSttHeadListExport, coSttNodeListExport } from "../../matDmd/coSttn/headList";
|
|
import { fetchType, getFetchWithCount } from "@/components/lib/api";
|
|
|
|
const coSttnMapRes: DemandCompType[] = [];
|
|
|
|
export const costtnMapSize =20
|
|
|
|
export type coSttnMapState = {
|
|
coSttnMap: {
|
|
coSttnMapRes: DemandCompType[];
|
|
coSttMapHeadList: CommonTableProps[];
|
|
coSttMapNodeList: CommonTableProps[];
|
|
excelList: [];
|
|
isInit: boolean;
|
|
coSttnMapResCount: number;
|
|
};
|
|
};
|
|
|
|
type coSttnMapActions = {
|
|
coSttnMapInit: (pageNo: number, pageCnt: number, con: string) => void;
|
|
coSttnMapSearch: (pageNo: number, pageCnt: number, con: string) => void;
|
|
coSttnMapTxtSearch: (pageNo: number, pageCnt: number, con: string, txt: string) => void;
|
|
};
|
|
|
|
export type coSttnMapType = coSttnMapState & coSttnMapActions;
|
|
|
|
export const coSttnMapStateExport: coSttnMapState = {
|
|
coSttnMap: {
|
|
coSttMapHeadList: coSttHeadListExport,
|
|
coSttMapNodeList: coSttNodeListExport,
|
|
coSttnMapRes: coSttnMapRes,
|
|
excelList: [],
|
|
isInit: false,
|
|
coSttnMapResCount: 0,
|
|
},
|
|
};
|
|
|
|
|
|
export const coSttnMapActionsExport: (set: any) => coSttnMapActions = (
|
|
set: any
|
|
) => {
|
|
return {
|
|
coSttnMapInit: async (pageNo: number, pageCnt: number, con: string) => {
|
|
try {
|
|
const coSttnMapRes = await getFetchWithCount(
|
|
fetchType.WR,
|
|
`/reuseFc/request/${pageNo}/${pageCnt}/${con}`
|
|
);
|
|
set((state: coSttnMapState) => {
|
|
return {
|
|
...state,
|
|
coSttnMap: {
|
|
...state.coSttnMap,
|
|
coSttnMapRes: coSttnMapRes.data,
|
|
isInit: false,
|
|
coSttnMapResCount: coSttnMapRes.count,
|
|
},
|
|
};
|
|
});
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
},
|
|
coSttnMapSearch: async (pageNo: number, pageCnt: number, con: string) => {
|
|
try {
|
|
const coSttnMapRes = await getFetchWithCount(
|
|
fetchType.WR,
|
|
`/reuseFc/request/${pageNo}/${pageCnt}/${con}`
|
|
);
|
|
if (Number(pageCnt) >= 10000) {
|
|
set((state: coSttnMapState) => {
|
|
return {
|
|
...state,
|
|
coSttnMap: {
|
|
...state.coSttnMap,
|
|
excelList: coSttnMapRes.data,
|
|
//isInit: false,
|
|
},
|
|
};
|
|
});
|
|
} else
|
|
set((state: coSttnMapState) => {
|
|
return {
|
|
...state,
|
|
coSttnMap: {
|
|
...state.coSttnMap,
|
|
coSttnMapRes: coSttnMapRes.data,
|
|
isInit: false,
|
|
coSttnMapResCount: coSttnMapRes.count,
|
|
},
|
|
};
|
|
});
|
|
} catch (erTxt) {
|
|
console.log("error", erTxt);
|
|
}
|
|
},
|
|
coSttnMapTxtSearch: async (pageNo: number, pageCnt: number, con: string, txt: string) => {
|
|
try {
|
|
const coSttnMapRes = await getFetchWithCount(
|
|
fetchType.WR,
|
|
`/reuseFc/request/${pageNo}/${pageCnt}/${con}/${txt}`)
|
|
set((state: coSttnMapState) => {
|
|
return {
|
|
...state,
|
|
coSttnMap: {
|
|
...state.coSttnMap,
|
|
coSttnMapRes: coSttnMapRes.data,
|
|
coSttnMapResCount: coSttnMapRes.count,
|
|
isInit: false,
|
|
}
|
|
}
|
|
})
|
|
} catch (erTxt) {
|
|
console.log("error", erTxt);
|
|
}
|
|
},
|
|
}
|
|
} |