결재 단계 편집 다이얼로그 구현
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
|
||||
import '../../domain/entities/approval_step_input.dart';
|
||||
import '../../domain/entities/approval_step_record.dart';
|
||||
import '../../domain/repositories/approval_step_repository.dart';
|
||||
|
||||
@@ -12,6 +13,7 @@ class ApprovalStepController extends ChangeNotifier {
|
||||
|
||||
PaginatedResult<ApprovalStepRecord>? _result;
|
||||
bool _isLoading = false;
|
||||
bool _isSaving = false;
|
||||
String _query = '';
|
||||
int? _statusId;
|
||||
int? _approverId;
|
||||
@@ -21,6 +23,7 @@ class ApprovalStepController extends ChangeNotifier {
|
||||
|
||||
PaginatedResult<ApprovalStepRecord>? get result => _result;
|
||||
bool get isLoading => _isLoading;
|
||||
bool get isSaving => _isSaving;
|
||||
String get query => _query;
|
||||
int? get statusId => _statusId;
|
||||
int? get approverId => _approverId;
|
||||
@@ -101,4 +104,43 @@ class ApprovalStepController extends ChangeNotifier {
|
||||
_approverId = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<ApprovalStepRecord?> createStep(ApprovalStepInput input) async {
|
||||
_isSaving = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
try {
|
||||
final created = await _repository.create(input);
|
||||
final nextPage = _result?.page ?? 1;
|
||||
await fetch(page: nextPage);
|
||||
return created;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
return null;
|
||||
} finally {
|
||||
_isSaving = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApprovalStepRecord?> updateStep(
|
||||
int id,
|
||||
ApprovalStepInput input,
|
||||
) async {
|
||||
_isSaving = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
try {
|
||||
final updated = await _repository.update(id, input);
|
||||
final nextPage = _result?.page ?? 1;
|
||||
await fetch(page: nextPage);
|
||||
return updated;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
return null;
|
||||
} finally {
|
||||
_isSaving = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user