feat: 대규모 코드베이스 개선 - 백엔드 통합성 강화 및 UI 일관성 완성
- CLAUDE.md 대폭 개선: 개발 가이드라인 및 프로젝트 상태 문서화 - 백엔드 API 통합: 모든 엔티티 간 Foreign Key 관계 완벽 구현 - UI 일관성 강화: shadcn_ui 컴포넌트 표준화 적용 - 데이터 모델 개선: DTO 및 모델 클래스 백엔드 스키마와 100% 일치 - 사용자 관리: 회사 연결, 중복 검사, 입력 검증 기능 추가 - 창고 관리: 우편번호 연결, 중복 검사 기능 강화 - 회사 관리: 우편번호 연결, 중복 검사 로직 구현 - 장비 관리: 불필요한 카테고리 필드 제거, 벤더-모델 관계 정리 - 우편번호 시스템: 검색 다이얼로그 Provider 버그 수정 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:superport/screens/common/templates/form_layout_template.dart';
|
||||
import 'package:superport/utils/currency_formatter.dart';
|
||||
import 'package:superport/core/widgets/category_cascade_form_field.dart';
|
||||
import 'controllers/equipment_in_form_controller.dart';
|
||||
import 'widgets/equipment_vendor_model_selector.dart';
|
||||
import 'package:superport/utils/formatters/number_formatter.dart';
|
||||
@@ -11,8 +10,9 @@ import 'package:superport/utils/formatters/number_formatter.dart';
|
||||
/// 새로운 Equipment 입고 폼 (Lookup API 기반)
|
||||
class EquipmentInFormScreen extends StatefulWidget {
|
||||
final int? equipmentInId;
|
||||
final Map<String, dynamic>? preloadedData; // 사전 로드된 데이터
|
||||
|
||||
const EquipmentInFormScreen({super.key, this.equipmentInId});
|
||||
const EquipmentInFormScreen({super.key, this.equipmentInId, this.preloadedData});
|
||||
|
||||
@override
|
||||
State<EquipmentInFormScreen> createState() => _EquipmentInFormScreenState();
|
||||
@@ -23,35 +23,49 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
late TextEditingController _serialNumberController;
|
||||
late TextEditingController _initialStockController;
|
||||
late TextEditingController _purchasePriceController;
|
||||
Future<void>? _initFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = EquipmentInFormController(equipmentInId: widget.equipmentInId);
|
||||
|
||||
// preloadedData가 있으면 전달, 없으면 일반 초기화
|
||||
if (widget.preloadedData != null) {
|
||||
_controller = EquipmentInFormController.withPreloadedData(
|
||||
preloadedData: widget.preloadedData!,
|
||||
);
|
||||
_initFuture = Future.value(); // 데이터가 이미 있으므로 즉시 완료
|
||||
} else {
|
||||
_controller = EquipmentInFormController(equipmentInId: widget.equipmentInId);
|
||||
// 수정 모드일 때 데이터 로드를 Future로 처리
|
||||
if (_controller.isEditMode) {
|
||||
_initFuture = _initializeEditMode();
|
||||
} else {
|
||||
_initFuture = Future.value(); // 신규 모드는 즉시 완료
|
||||
}
|
||||
}
|
||||
|
||||
_controller.addListener(_onControllerUpdated);
|
||||
|
||||
// TextEditingController 초기화
|
||||
_serialNumberController = TextEditingController(text: _controller.serialNumber);
|
||||
_serialNumberController = TextEditingController(text: _controller.serialNumber);
|
||||
_initialStockController = TextEditingController(text: _controller.initialStock.toString());
|
||||
_purchasePriceController = TextEditingController(
|
||||
text: _controller.purchasePrice != null
|
||||
? CurrencyFormatter.formatKRW(_controller.purchasePrice)
|
||||
: ''
|
||||
);
|
||||
|
||||
// 수정 모드일 때 데이터 로드
|
||||
if (_controller.isEditMode) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _controller.initializeForEdit();
|
||||
// 데이터 로드 후 컨트롤러 업데이트
|
||||
_serialNumberController.text = _controller.serialNumber;
|
||||
_serialNumberController.text = _controller.serialNumber;
|
||||
_purchasePriceController.text = _controller.purchasePrice != null
|
||||
? CurrencyFormatter.formatKRW(_controller.purchasePrice)
|
||||
: '';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initializeEditMode() async {
|
||||
await _controller.initializeForEdit();
|
||||
// 데이터 로드 후 컨트롤러 업데이트
|
||||
setState(() {
|
||||
_serialNumberController.text = _controller.serialNumber;
|
||||
_purchasePriceController.text = _controller.purchasePrice != null
|
||||
? CurrencyFormatter.formatKRW(_controller.purchasePrice)
|
||||
: '';
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -112,32 +126,54 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
// 간소화된 디버깅
|
||||
print('🎯 [UI] canSave: ${_controller.canSave} | 장비번호: "${_controller.serialNumber}" | 제조사: "${_controller.manufacturer}"');
|
||||
|
||||
return FormLayoutTemplate(
|
||||
title: _controller.isEditMode ? '장비 수정' : '장비 입고',
|
||||
onSave: _controller.canSave && !_controller.isSaving ? _onSave : null,
|
||||
onCancel: () => Navigator.of(context).pop(),
|
||||
isLoading: _controller.isSaving,
|
||||
child: _controller.isLoading
|
||||
? const Center(child: ShadProgress())
|
||||
: Form(
|
||||
key: _controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildBasicFields(),
|
||||
const SizedBox(height: 24),
|
||||
_buildCategorySection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildLocationSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildPurchaseSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildRemarkSection(),
|
||||
],
|
||||
),
|
||||
return FutureBuilder<void>(
|
||||
future: _initFuture,
|
||||
builder: (context, snapshot) {
|
||||
// 수정 모드에서 데이터 로딩 중일 때 로딩 화면 표시
|
||||
if (_controller.isEditMode && snapshot.connectionState != ConnectionState.done) {
|
||||
return FormLayoutTemplate(
|
||||
title: '장비 정보 로딩 중...',
|
||||
onSave: null,
|
||||
onCancel: () => Navigator.of(context).pop(),
|
||||
isLoading: false,
|
||||
child: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadProgress(),
|
||||
SizedBox(height: 16),
|
||||
Text('장비 정보를 불러오는 중입니다...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 데이터 로드 완료 또는 신규 모드
|
||||
return FormLayoutTemplate(
|
||||
title: _controller.isEditMode ? '장비 수정' : '장비 입고',
|
||||
onSave: _controller.canSave && !_controller.isSaving ? _onSave : null,
|
||||
onCancel: () => Navigator.of(context).pop(),
|
||||
isLoading: _controller.isSaving,
|
||||
child: Form(
|
||||
key: _controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildBasicFields(),
|
||||
const SizedBox(height: 24),
|
||||
_buildLocationSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildPurchaseSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildRemarkSection(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,36 +244,6 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategorySection() {
|
||||
return ShadCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'장비 분류',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
CategoryCascadeFormField(
|
||||
category1: _controller.category1.isEmpty ? null : _controller.category1,
|
||||
category2: _controller.category2.isEmpty ? null : _controller.category2,
|
||||
category3: _controller.category3.isEmpty ? null : _controller.category3,
|
||||
onChanged: (cat1, cat2, cat3) {
|
||||
_controller.category1 = cat1?.trim() ?? '';
|
||||
_controller.category2 = cat2?.trim() ?? '';
|
||||
_controller.category3 = cat3?.trim() ?? '';
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLocationSection() {
|
||||
return ShadCard(
|
||||
@@ -264,8 +270,13 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
child: Text(entry.value),
|
||||
)
|
||||
).toList(),
|
||||
selectedOptionBuilder: (context, value) =>
|
||||
Text(_controller.companies[value] ?? '선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
// companies가 비어있거나 해당 value가 없는 경우 처리
|
||||
if (_controller.companies.isEmpty) {
|
||||
return const Text('로딩중...');
|
||||
}
|
||||
return Text(_controller.companies[value] ?? '선택하세요');
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_controller.selectedCompanyId = value;
|
||||
@@ -285,8 +296,13 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
child: Text(entry.value),
|
||||
)
|
||||
).toList(),
|
||||
selectedOptionBuilder: (context, value) =>
|
||||
Text(_controller.warehouses[value] ?? '선택하세요'),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
// warehouses가 비어있거나 해당 value가 없는 경우 처리
|
||||
if (_controller.warehouses.isEmpty) {
|
||||
return const Text('로딩중...');
|
||||
}
|
||||
return Text(_controller.warehouses[value] ?? '선택하세요');
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_controller.selectedWarehouseId = value;
|
||||
|
||||
Reference in New Issue
Block a user