feat(approvals): Approval Flow v2 프런트엔드 전면 개편
- 환경/라우터 모듈에 approval_flow_v2 토글을 추가하고 FeatureFlags 초기화를 연결 (.env*, lib/core/**) - ApiClient 빌더·ApiRoutes 확장과 ApprovalRepositoryRemote 리팩터링으로 include·액션 시그니처를 정합화 - ApprovalFlow·ApprovalDraft 엔티티/레포/유즈케이스를 도입해 서버 초안과 단계 액션(승인·회수·재상신)을 지원 - Approval 컨트롤러·히스토리·템플릿 페이지와 공유 위젯을 재작성해 감사 로그·회수 UX·템플릿 CRUD를 반영 - Inbound/Outbound/Rental 컨트롤러·페이지에 결재 섹션을 삽입하고 대시보드 pending 카드 요약을 갱신 - SuperportDialog·FormField 등 공통 위젯을 보강하고 승인 위젯 가이드를 추가해 UI 가이드를 정리 - 결재/재고 테스트 픽스처와 단위·위젯·통합 테스트를 확장하고 flutter_test_config로 스테이징 호스트를 허용 - Approval Flow 레포트/플랜 문서를 업데이트하고 ApprovalFlow_System_Integration_and_ChangePlan.md를 추가 - 실행: flutter analyze, flutter test
This commit is contained in:
@@ -16,6 +16,13 @@ import 'package:superport_v2/features/inventory/shared/widgets/product_autocompl
|
||||
import 'package:superport_v2/features/inventory/shared/widgets/employee_autocomplete_field.dart';
|
||||
import 'package:superport_v2/features/inventory/shared/widgets/customer_multi_select_field.dart';
|
||||
import 'package:superport_v2/features/inventory/shared/widgets/warehouse_select_field.dart';
|
||||
import 'package:superport_v2/features/approvals/request/presentation/controllers/approval_request_controller.dart';
|
||||
import 'package:superport_v2/features/approvals/request/presentation/utils/approval_form_initializer.dart';
|
||||
import 'package:superport_v2/features/approvals/request/presentation/widgets/approval_step_configurator.dart';
|
||||
import 'package:superport_v2/features/approvals/request/presentation/widgets/approval_template_picker.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/usecases/get_approval_draft_use_case.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/usecases/list_approval_drafts_use_case.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/usecases/save_approval_draft_use_case.dart';
|
||||
import 'package:superport_v2/core/config/environment.dart';
|
||||
import 'package:superport_v2/core/network/failure.dart';
|
||||
import 'package:superport_v2/core/common/utils/pagination_utils.dart';
|
||||
@@ -31,6 +38,7 @@ import 'package:superport_v2/features/inventory/transactions/presentation/servic
|
||||
import 'package:superport_v2/features/inventory/transactions/presentation/widgets/transaction_detail_dialog.dart';
|
||||
import 'package:superport_v2/features/masters/customer/domain/entities/customer.dart';
|
||||
import 'package:superport_v2/features/masters/customer/domain/repositories/customer_repository.dart';
|
||||
import 'package:superport_v2/features/auth/application/auth_service.dart';
|
||||
import '../../../lookups/domain/entities/lookup_item.dart';
|
||||
import '../../../lookups/domain/repositories/inventory_lookup_repository.dart';
|
||||
import '../widgets/outbound_detail_view.dart';
|
||||
@@ -133,6 +141,15 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
lookupRepository: getIt<InventoryLookupRepository>(),
|
||||
fallbackStatusOptions: OutboundTableSpec.fallbackStatusOptions,
|
||||
transactionTypeKeywords: OutboundTableSpec.transactionTypeKeywords,
|
||||
saveDraftUseCase: getIt.isRegistered<SaveApprovalDraftUseCase>()
|
||||
? getIt<SaveApprovalDraftUseCase>()
|
||||
: null,
|
||||
getDraftUseCase: getIt.isRegistered<GetApprovalDraftUseCase>()
|
||||
? getIt<GetApprovalDraftUseCase>()
|
||||
: null,
|
||||
listDraftsUseCase: getIt.isRegistered<ListApprovalDraftsUseCase>()
|
||||
? getIt<ListApprovalDraftsUseCase>()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,6 +160,10 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
}
|
||||
Future.microtask(() async {
|
||||
await controller.loadStatusOptions();
|
||||
final requester = _resolveCurrentWriter();
|
||||
if (requester != null) {
|
||||
await controller.loadApprovalDraftFromServer(requesterId: requester.id);
|
||||
}
|
||||
final hasType = await controller.resolveTransactionType();
|
||||
if (!mounted) {
|
||||
return;
|
||||
@@ -213,6 +234,26 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
}
|
||||
}
|
||||
|
||||
InventoryEmployeeSuggestion? _resolveCurrentWriter() {
|
||||
final getIt = GetIt.I;
|
||||
if (!getIt.isRegistered<AuthService>()) {
|
||||
return null;
|
||||
}
|
||||
final session = getIt<AuthService>().session;
|
||||
final user = session?.user;
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final employeeNo = (user.employeeNo ?? '').trim().isEmpty
|
||||
? user.id.toString()
|
||||
: user.employeeNo!.trim();
|
||||
return InventoryEmployeeSuggestion(
|
||||
id: user.id,
|
||||
employeeNo: employeeNo,
|
||||
name: user.name,
|
||||
);
|
||||
}
|
||||
|
||||
void _handleControllerChanged() {
|
||||
if (!mounted) {
|
||||
return;
|
||||
@@ -1556,6 +1597,25 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
return '${suggestion.name} (${suggestion.employeeNo})';
|
||||
}
|
||||
|
||||
final approvalController = ApprovalRequestController();
|
||||
final defaultRequester = () {
|
||||
final writer = writerSelection;
|
||||
if (writer == null) {
|
||||
return null;
|
||||
}
|
||||
return ApprovalRequestParticipant(
|
||||
id: writer.id,
|
||||
name: writer.name,
|
||||
employeeNo: writer.employeeNo,
|
||||
);
|
||||
}();
|
||||
ApprovalFormInitializer.populate(
|
||||
controller: approvalController,
|
||||
existingApproval: initial?.raw?.approval,
|
||||
draft: _controller?.approvalDraft,
|
||||
defaultRequester: defaultRequester,
|
||||
);
|
||||
|
||||
final writerController = TextEditingController(
|
||||
text: writerLabel(writerSelection),
|
||||
);
|
||||
@@ -1814,6 +1874,23 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
)
|
||||
.toList(growable: false);
|
||||
|
||||
StockTransactionApprovalInput approvalInput;
|
||||
try {
|
||||
approvalInput = approvalController.buildTransactionApprovalInput(
|
||||
approvalStatusId: null,
|
||||
note: approvalNoteValue.isEmpty ? null : approvalNoteValue,
|
||||
);
|
||||
} on StateError catch (error) {
|
||||
updateSaving(false);
|
||||
SuperportToast.error(context, error.message);
|
||||
return;
|
||||
} catch (_) {
|
||||
updateSaving(false);
|
||||
SuperportToast.error(context, '결재 구성을 확인하고 다시 시도하세요.');
|
||||
return;
|
||||
}
|
||||
controller.updateApprovalDraft(approvalInput);
|
||||
|
||||
final created = await controller.createTransaction(
|
||||
StockTransactionCreateInput(
|
||||
transactionTypeId: transactionTypeLookup.id,
|
||||
@@ -1824,10 +1901,7 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
note: remarkValue,
|
||||
lines: createLines,
|
||||
customers: createCustomers,
|
||||
approval: StockTransactionApprovalInput(
|
||||
requestedById: createdById,
|
||||
note: approvalNoteValue.isEmpty ? null : approvalNoteValue,
|
||||
),
|
||||
approval: approvalInput,
|
||||
),
|
||||
);
|
||||
result = created;
|
||||
@@ -2011,6 +2085,15 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
enabled: initial == null,
|
||||
onSuggestionSelected: (suggestion) {
|
||||
writerSelection = suggestion;
|
||||
approvalController.setRequester(
|
||||
suggestion == null
|
||||
? null
|
||||
: ApprovalRequestParticipant(
|
||||
id: suggestion.id,
|
||||
name: suggestion.name,
|
||||
employeeNo: suggestion.employeeNo,
|
||||
),
|
||||
);
|
||||
if (writerError != null) {
|
||||
setState(() {
|
||||
writerError = null;
|
||||
@@ -2026,6 +2109,7 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
if (currentText.isEmpty ||
|
||||
currentText != selectedLabel) {
|
||||
writerSelection = null;
|
||||
approvalController.setRequester(null);
|
||||
}
|
||||
if (writerError != null) {
|
||||
setState(() {
|
||||
@@ -2099,6 +2183,15 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (initial == null) ...[
|
||||
ApprovalTemplatePicker(controller: approvalController),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
ApprovalStepConfigurator(
|
||||
controller: approvalController,
|
||||
readOnly: initial != null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (headerNotice != null)
|
||||
Padding(
|
||||
@@ -2215,6 +2308,7 @@ class _OutboundPageState extends State<OutboundPage> {
|
||||
transactionTypeController.dispose();
|
||||
approvalNoteController.dispose();
|
||||
processedAt.dispose();
|
||||
approvalController.dispose();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user