fix: 페이지네이션 로직 개선 및 상세 로그 추가
- 모든 관리 화면(회사, 장비, 입고지, 유지보수)의 페이지네이션 로직 통일 - Controller에서 전체 데이터 로드, View에서만 페이지네이션 처리 - 각 화면에 상세한 터미널 로그 추가로 데이터 로드 상태 추적 가능 - 회사 DTO에 지점 정보 포함 기능 추가 - 전체 79개 회사 중 14개만 표시되던 문제 해결
This commit is contained in:
@@ -90,48 +90,65 @@ class LicenseListController extends ChangeNotifier {
|
||||
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
|
||||
if (isInitialLoad) {
|
||||
_currentPage = 1;
|
||||
_licenses.clear();
|
||||
_hasMore = true;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<LicenseService>()) {
|
||||
debugPrint('📑 API 모드로 라이센스 로드 시작...');
|
||||
// API 사용 - 전체 데이터 로드
|
||||
print('╔══════════════════════════════════════════════════════════');
|
||||
print('║ 🔧 유지보수 목록 API 호출 시작');
|
||||
print('║ • 회사 필터: ${_selectedCompanyId ?? "전체"}');
|
||||
print('║ • 활성 필터: ${_isActive != null ? (_isActive! ? "활성" : "비활성") : "전체"}');
|
||||
print('║ • 라이센스 타입: ${_licenseType ?? "전체"}');
|
||||
print('╚══════════════════════════════════════════════════════════');
|
||||
|
||||
// API 사용
|
||||
// 전체 데이터를 가져오기 위해 큰 perPage 값 사용
|
||||
final fetchedLicenses = await _licenseService.getLicenses(
|
||||
page: _currentPage,
|
||||
perPage: _pageSize,
|
||||
page: 1,
|
||||
perPage: 1000, // 충분히 큰 값으로 전체 데이터 로드
|
||||
isActive: _isActive,
|
||||
companyId: _selectedCompanyId,
|
||||
licenseType: _licenseType,
|
||||
);
|
||||
|
||||
debugPrint('📑 API에서 ${fetchedLicenses.length}개 라이센스 받음');
|
||||
|
||||
if (isInitialLoad) {
|
||||
_licenses = fetchedLicenses;
|
||||
debugPrint('📑 초기 로드: _licenses에 ${_licenses.length}개 저장');
|
||||
} else {
|
||||
_licenses.addAll(fetchedLicenses);
|
||||
debugPrint('📑 추가 로드: _licenses에 총 ${_licenses.length}개');
|
||||
print('╔══════════════════════════════════════════════════════════');
|
||||
print('║ 📊 유지보수 목록 로드 완료');
|
||||
print('║ ▶ 총 라이센스 수: ${fetchedLicenses.length}개');
|
||||
print('╟──────────────────────────────────────────────────────────');
|
||||
|
||||
// 상태별 통계
|
||||
int activeCount = 0;
|
||||
int expiringSoonCount = 0;
|
||||
int expiredCount = 0;
|
||||
final now = DateTime.now();
|
||||
|
||||
for (final license in fetchedLicenses) {
|
||||
if (license.expiryDate != null) {
|
||||
final daysUntil = license.expiryDate!.difference(now).inDays;
|
||||
if (daysUntil < 0) {
|
||||
expiredCount++;
|
||||
} else if (daysUntil <= 30) {
|
||||
expiringSoonCount++;
|
||||
} else {
|
||||
activeCount++;
|
||||
}
|
||||
} else {
|
||||
activeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
_hasMore = fetchedLicenses.length >= _pageSize;
|
||||
|
||||
// 전체 개수 조회
|
||||
debugPrint('📑 전체 개수 조회 시작...');
|
||||
_total = await _licenseService.getTotalLicenses(
|
||||
isActive: _isActive,
|
||||
companyId: _selectedCompanyId,
|
||||
licenseType: _licenseType,
|
||||
);
|
||||
debugPrint('📑 전체 개수: $_total');
|
||||
print('║ • 활성: $activeCount개');
|
||||
print('║ • 만료 임박 (30일 이내): $expiringSoonCount개');
|
||||
print('║ • 만료됨: $expiredCount개');
|
||||
|
||||
print('╟──────────────────────────────────────────────────────────');
|
||||
print('║ 📑 전체 데이터 로드 완료');
|
||||
print('║ • View에서 페이지네이션 처리 예정');
|
||||
print('╚══════════════════════════════════════════════════════════');
|
||||
|
||||
_licenses = fetchedLicenses;
|
||||
_hasMore = false; // 전체 데이터를 로드했으므로 더 이상 로드할 필요 없음
|
||||
_total = fetchedLicenses.length;
|
||||
} else {
|
||||
// Mock 데이터 사용
|
||||
final allLicenses = mockDataService?.getAllLicenses() ?? [];
|
||||
|
||||
Reference in New Issue
Block a user