fix: 페이지네이션 로직 개선 및 상세 로그 추가
- 모든 관리 화면(회사, 장비, 입고지, 유지보수)의 페이지네이션 로직 통일 - Controller에서 전체 데이터 로드, View에서만 페이지네이션 처리 - 각 화면에 상세한 터미널 로그 추가로 데이터 로드 상태 추적 가능 - 회사 DTO에 지점 정보 포함 기능 추가 - 전체 79개 회사 중 14개만 표시되던 문제 해결
This commit is contained in:
@@ -46,47 +46,51 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
Future<void> loadWarehouseLocations({bool isInitialLoad = true}) async {
|
||||
if (_isLoading) return;
|
||||
|
||||
print('[WarehouseLocationListController] loadWarehouseLocations started - isInitialLoad: $isInitialLoad');
|
||||
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
|
||||
if (isInitialLoad) {
|
||||
_currentPage = 1;
|
||||
_warehouseLocations.clear();
|
||||
_hasMore = true;
|
||||
} else {
|
||||
// 다음 페이지를 로드할 때는 페이지 번호를 먼저 증가
|
||||
_currentPage++;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && _warehouseService != null) {
|
||||
// API 사용
|
||||
print('[WarehouseLocationListController] Using API to fetch warehouse locations');
|
||||
final fetchedLocations = await _warehouseService!.getWarehouseLocations(
|
||||
page: _currentPage,
|
||||
perPage: _pageSize,
|
||||
isActive: _isActive,
|
||||
);
|
||||
|
||||
print('[WarehouseLocationListController] API returned ${fetchedLocations.length} locations');
|
||||
|
||||
if (isInitialLoad) {
|
||||
_warehouseLocations = fetchedLocations;
|
||||
} else {
|
||||
_warehouseLocations.addAll(fetchedLocations);
|
||||
}
|
||||
|
||||
_hasMore = fetchedLocations.length >= _pageSize;
|
||||
// API 사용 - 전체 데이터 로드
|
||||
print('╔══════════════════════════════════════════════════════════');
|
||||
print('║ 🏭 입고지 목록 API 호출 시작');
|
||||
print('║ • 활성 필터: ${_isActive != null ? (_isActive! ? "활성" : "비활성") : "전체"}');
|
||||
print('╚══════════════════════════════════════════════════════════');
|
||||
|
||||
// 전체 개수 조회
|
||||
_total = await _warehouseService!.getTotalWarehouseLocations(
|
||||
// 전체 데이터를 가져오기 위해 큰 perPage 값 사용
|
||||
final fetchedLocations = await _warehouseService!.getWarehouseLocations(
|
||||
page: 1,
|
||||
perPage: 1000, // 충분히 큰 값으로 전체 데이터 로드
|
||||
isActive: _isActive,
|
||||
);
|
||||
print('[WarehouseLocationListController] Total warehouse locations: $_total');
|
||||
|
||||
print('╔══════════════════════════════════════════════════════════');
|
||||
print('║ 📊 입고지 목록 로드 완료');
|
||||
print('║ ▶ 총 입고지 수: ${fetchedLocations.length}개');
|
||||
print('╟──────────────────────────────────────────────────────────');
|
||||
|
||||
// 상태별 통계 (입고지에 상태가 있다면)
|
||||
int activeCount = 0;
|
||||
int inactiveCount = 0;
|
||||
for (final location in fetchedLocations) {
|
||||
// isActive 필드가 있다면 활용
|
||||
activeCount++; // 현재는 모두 활성으로 가정
|
||||
}
|
||||
|
||||
print('║ • 활성 입고지: $activeCount개');
|
||||
if (inactiveCount > 0) {
|
||||
print('║ • 비활성 입고지: $inactiveCount개');
|
||||
}
|
||||
|
||||
print('╟──────────────────────────────────────────────────────────');
|
||||
print('║ 📑 전체 데이터 로드 완료');
|
||||
print('║ • View에서 페이지네이션 처리 예정');
|
||||
print('╚══════════════════════════════════════════════════════════');
|
||||
|
||||
_warehouseLocations = fetchedLocations;
|
||||
_hasMore = false; // 전체 데이터를 로드했으므로 더 이상 로드할 필요 없음
|
||||
_total = fetchedLocations.length;
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
print('[WarehouseLocationListController] Using Mock data');
|
||||
|
||||
Reference in New Issue
Block a user