fo: pagination 수정
This commit is contained in:
@@ -466,16 +466,22 @@ export const facilityWaterQltyReducer = (set: SetFunc): FacilityWaterQltyActions
|
||||
//---------
|
||||
const waterQltyList: any[] = [];
|
||||
let recordCount = 0;
|
||||
for (let idx = 0; idx < pageSize; idx += 100) {
|
||||
const tmpPageNo = Math.floor(idx / 100) + 1;
|
||||
const tmpPageSize = Math.min(100, pageSize - idx);
|
||||
const result = await fetchFacilityWaterQltyList(tmpPageNo, tmpPageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
if (result?.status === 200 && Array.isArray(result?.data)) {
|
||||
waterQltyList.push(...result.data);
|
||||
}
|
||||
recordCount = result?.count || 0;
|
||||
if (result?.count < tmpPageNo * tmpPageSize) {
|
||||
break; // 더 이상 데이터가 없으면 중지
|
||||
if (pageSize < 5000) {
|
||||
const res = await fetchFacilityWaterQltyList(pageNo, pageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
waterQltyList.push(...res.data);
|
||||
recordCount = res.count;
|
||||
} else {
|
||||
for (let idx = 0; idx < pageSize; idx += 100) {
|
||||
const tmpPageNo = Math.floor(idx / 100) + 1;
|
||||
const tmpPageSize = Math.min(100, pageSize - idx);
|
||||
const result = await fetchFacilityWaterQltyList(tmpPageNo, tmpPageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
if (result?.status === 200 && Array.isArray(result?.data)) {
|
||||
waterQltyList.push(...result.data);
|
||||
}
|
||||
recordCount = result?.count || 0;
|
||||
if (result?.count < tmpPageNo * tmpPageSize) {
|
||||
break; // 더 이상 데이터가 없으면 중지
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------
|
||||
|
||||
@@ -285,23 +285,30 @@ export const flowRateSearchReducer: (set: (fn: (state: FlowRateSearchType) => Fl
|
||||
//---------
|
||||
const flowRateList: any[] = [];
|
||||
const results: any[] = [];
|
||||
for (let idx = 0; idx < pageSize; idx += 100) {
|
||||
const tmpPageNo = Math.floor(idx / 100) + 1;
|
||||
const tmpPageSize = Math.min(100, pageSize - idx);
|
||||
const result = await fetchFlowRateList( tmpPageNo, tmpPageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
results.push(result);
|
||||
if (result?.count < tmpPageNo * tmpPageSize) {
|
||||
break; // 더 이상 데이터가 없으면 중지
|
||||
}
|
||||
}
|
||||
console.log(results);
|
||||
// 결과를 합치기
|
||||
|
||||
for (const res of results) {
|
||||
if (res?.status === 200 && Array.isArray(res?.data)) {
|
||||
flowRateList.push(...res.data);
|
||||
if (pageSize < 5000) {
|
||||
const res = await fetchFlowRateList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
flowRateList.push(...res.data);
|
||||
results.push(res);
|
||||
} else {
|
||||
for (let idx = 0; idx < pageSize; idx += 100) {
|
||||
const tmpPageNo = Math.floor(idx / 100) + 1;
|
||||
const tmpPageSize = Math.min(100, pageSize - idx);
|
||||
const result = await fetchFlowRateList( tmpPageNo, tmpPageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm);
|
||||
results.push(result);
|
||||
if (result?.count < tmpPageNo * tmpPageSize) {
|
||||
break; // 더 이상 데이터가 없으면 중지
|
||||
}
|
||||
}
|
||||
// console.log(results);
|
||||
// 결과를 합치기
|
||||
|
||||
for (const res of results) {
|
||||
if (res?.status === 200 && Array.isArray(res?.data)) {
|
||||
flowRateList.push(...res.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------
|
||||
const recordCount = results[0]?.count || 0;
|
||||
//-------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user