feat: 소프트 딜리트 기능 전면 구현 완료
## 주요 변경사항 - Company, Equipment, License, Warehouse Location 모든 화면에 소프트 딜리트 구현 - 관리자 권한으로 삭제된 데이터 조회 가능 (includeInactive 파라미터) - 데이터 무결성 보장을 위한 논리 삭제 시스템 완성 ## 기능 개선 - 각 리스트 컨트롤러에 toggleIncludeInactive() 메서드 추가 - UI에 "비활성 포함" 체크박스 추가 (관리자 전용) - API 데이터소스에 includeInactive 파라미터 지원 ## 문서 정리 - 불필요한 문서 파일 제거 및 재구성 - CLAUDE.md 프로젝트 상태 업데이트 (진행률 80%) - 테스트 결과 문서화 (test20250812v01.md) ## UI 컴포넌트 - Equipment 화면 위젯 모듈화 (custom_dropdown_field, equipment_basic_info_section) - 폼 유효성 검증 강화 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/models/equipment_unified_model.dart';
|
||||
import 'package:superport/models/company_model.dart';
|
||||
import 'package:superport/services/equipment_service.dart';
|
||||
import 'package:superport/services/warehouse_service.dart';
|
||||
import 'package:superport/services/company_service.dart';
|
||||
@@ -181,17 +180,30 @@ class EquipmentInFormController extends ChangeNotifier {
|
||||
|
||||
try {
|
||||
// API에서 장비 정보 가져오기
|
||||
print('DEBUG [_loadEquipmentIn] Start loading equipment ID: $actualEquipmentId');
|
||||
DebugLogger.log('장비 정보 로드 시작', tag: 'EQUIPMENT_IN', data: {
|
||||
'equipmentId': actualEquipmentId,
|
||||
});
|
||||
|
||||
final equipment = await _equipmentService.getEquipmentDetail(actualEquipmentId!);
|
||||
print('DEBUG [_loadEquipmentIn] Equipment loaded from service');
|
||||
|
||||
DebugLogger.log('장비 정보 로드 성공', tag: 'EQUIPMENT_IN', data: {
|
||||
'equipment': equipment.toJson(),
|
||||
});
|
||||
// toJson() 호출 전에 예외 처리
|
||||
try {
|
||||
final equipmentJson = equipment.toJson();
|
||||
print('DEBUG [_loadEquipmentIn] Equipment JSON: $equipmentJson');
|
||||
DebugLogger.log('장비 정보 로드 성공', tag: 'EQUIPMENT_IN', data: {
|
||||
'equipment': equipmentJson,
|
||||
});
|
||||
} catch (jsonError) {
|
||||
print('DEBUG [_loadEquipmentIn] Error converting to JSON: $jsonError');
|
||||
}
|
||||
|
||||
// 장비 정보 설정
|
||||
print('DEBUG [_loadEquipmentIn] Setting equipment data...');
|
||||
print('DEBUG [_loadEquipmentIn] equipment.manufacturer="${equipment.manufacturer}"');
|
||||
print('DEBUG [_loadEquipmentIn] equipment.name="${equipment.name}"');
|
||||
|
||||
manufacturer = equipment.manufacturer;
|
||||
name = equipment.name;
|
||||
category = equipment.category;
|
||||
@@ -203,6 +215,20 @@ class EquipmentInFormController extends ChangeNotifier {
|
||||
remarkController.text = equipment.remark ?? '';
|
||||
hasSerialNumber = serialNumber.isNotEmpty;
|
||||
|
||||
print('DEBUG [_loadEquipmentIn] After setting - manufacturer="$manufacturer", name="$name"');
|
||||
|
||||
DebugLogger.log('장비 데이터 설정 완료', tag: 'EQUIPMENT_IN', data: {
|
||||
'manufacturer': manufacturer,
|
||||
'name': name,
|
||||
'category': category,
|
||||
'subCategory': subCategory,
|
||||
'subSubCategory': subSubCategory,
|
||||
'serialNumber': serialNumber,
|
||||
'quantity': quantity,
|
||||
});
|
||||
|
||||
print('DEBUG [EQUIPMENT_IN]: Equipment loaded - manufacturer: "$manufacturer", name: "$name", category: "$category"');
|
||||
|
||||
// 워런티 정보
|
||||
warrantyLicense = equipment.warrantyLicense;
|
||||
warrantyStartDate = equipment.warrantyStartDate ?? DateTime.now();
|
||||
@@ -213,7 +239,9 @@ class EquipmentInFormController extends ChangeNotifier {
|
||||
equipmentType = EquipmentType.new_;
|
||||
// 창고 위치와 파트너사는 사용자가 수정 시 입력
|
||||
|
||||
} catch (e) {
|
||||
} catch (e, stackTrace) {
|
||||
print('DEBUG [_loadEquipmentIn] Error loading equipment: $e');
|
||||
print('DEBUG [_loadEquipmentIn] Stack trace: $stackTrace');
|
||||
DebugLogger.logError('장비 정보 로드 실패', error: e);
|
||||
throw ServerFailure(message: '장비 정보를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
String? _categoryFilter;
|
||||
int? _companyIdFilter;
|
||||
String? _selectedStatusFilter;
|
||||
bool _includeInactive = false; // 비활성(Disposed) 포함 여부
|
||||
|
||||
// Getters
|
||||
List<UnifiedEquipment> get equipments => items;
|
||||
@@ -29,6 +30,7 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
String? get categoryFilter => _categoryFilter;
|
||||
int? get companyIdFilter => _companyIdFilter;
|
||||
String? get selectedStatusFilter => _selectedStatusFilter;
|
||||
bool get includeInactive => _includeInactive;
|
||||
|
||||
// Setters
|
||||
set selectedStatusFilter(String? value) {
|
||||
@@ -36,6 +38,12 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 비활성 포함 토글
|
||||
void toggleIncludeInactive() {
|
||||
_includeInactive = !_includeInactive;
|
||||
loadData(isRefresh: true);
|
||||
}
|
||||
|
||||
EquipmentListController() {
|
||||
if (GetIt.instance.isRegistered<EquipmentService>()) {
|
||||
_equipmentService = GetIt.instance<EquipmentService>();
|
||||
@@ -58,6 +66,7 @@ class EquipmentListController extends BaseListController<UnifiedEquipment> {
|
||||
EquipmentStatusConverter.clientToServer(_statusFilter) : null,
|
||||
search: params.search,
|
||||
companyId: _companyIdFilter,
|
||||
includeInactive: _includeInactive,
|
||||
),
|
||||
onError: (failure) {
|
||||
throw failure;
|
||||
|
||||
@@ -183,48 +183,40 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
equipmentInId: widget.equipmentInId,
|
||||
);
|
||||
|
||||
print('DEBUG: initState - equipmentInId: ${widget.equipmentInId}, isEditMode: ${_controller.isEditMode}');
|
||||
|
||||
// 컨트롤러 변경 리스너 추가 (데이터 로드 전에 추가해야 변경사항을 감지할 수 있음)
|
||||
_controller.addListener(_onControllerUpdated);
|
||||
|
||||
// 수정 모드일 때 데이터 로드
|
||||
if (_controller.isEditMode) {
|
||||
print('DEBUG: Edit mode detected, loading equipment data...');
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _controller.initializeForEdit();
|
||||
// 데이터 로드 후 텍스트 컨트롤러 업데이트
|
||||
_updateTextControllers();
|
||||
print('DEBUG: Equipment data loaded, calling _updateTextControllers directly');
|
||||
// 데이터 로드 후 직접 UI 업데이트 호출
|
||||
if (mounted) {
|
||||
_updateTextControllers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_manufacturerFocusNode = FocusNode();
|
||||
_nameFieldFocusNode = FocusNode();
|
||||
_partnerController = TextEditingController(
|
||||
text: _controller.partnerCompany ?? '',
|
||||
);
|
||||
|
||||
// 추가 컨트롤러 초기화
|
||||
_warehouseController = TextEditingController(
|
||||
text: _controller.warehouseLocation ?? '',
|
||||
);
|
||||
|
||||
_manufacturerController = TextEditingController(
|
||||
text: _controller.manufacturer,
|
||||
);
|
||||
|
||||
_equipmentNameController = TextEditingController(text: _controller.name);
|
||||
|
||||
_categoryController = TextEditingController(text: _controller.category);
|
||||
|
||||
_subCategoryController = TextEditingController(
|
||||
text: _controller.subCategory,
|
||||
);
|
||||
|
||||
_subSubCategoryController = TextEditingController(
|
||||
text: _controller.subSubCategory,
|
||||
);
|
||||
|
||||
// 추가 필드 컨트롤러 초기화
|
||||
_nameController = TextEditingController(text: _controller.name);
|
||||
_serialNumberController = TextEditingController(text: _controller.serialNumber);
|
||||
_barcodeController = TextEditingController(text: _controller.barcode);
|
||||
_quantityController = TextEditingController(text: _controller.quantity.toString());
|
||||
_warrantyCodeController = TextEditingController(text: _controller.warrantyCode ?? '');
|
||||
// 컨트롤러들을 빈 값으로 초기화 (나중에 데이터 로드 시 업데이트됨)
|
||||
_partnerController = TextEditingController();
|
||||
_warehouseController = TextEditingController();
|
||||
_manufacturerController = TextEditingController();
|
||||
_equipmentNameController = TextEditingController();
|
||||
_categoryController = TextEditingController();
|
||||
_subCategoryController = TextEditingController();
|
||||
_subSubCategoryController = TextEditingController();
|
||||
_nameController = TextEditingController();
|
||||
_serialNumberController = TextEditingController();
|
||||
_barcodeController = TextEditingController();
|
||||
_quantityController = TextEditingController(text: '1');
|
||||
_warrantyCodeController = TextEditingController();
|
||||
|
||||
// 포커스 변경 리스너 추가
|
||||
_partnerFocusNode.addListener(_onPartnerFocusChange);
|
||||
@@ -236,11 +228,34 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
_subSubCategoryFocusNode.addListener(_onSubSubCategoryFocusChange);
|
||||
}
|
||||
|
||||
// 컨트롤러 데이터 변경 시 텍스트 컨트롤러 업데이트
|
||||
void _onControllerUpdated() {
|
||||
print('DEBUG [_onControllerUpdated] Called - isEditMode: ${_controller.isEditMode}, isLoading: ${_controller.isLoading}, actualEquipmentId: ${_controller.actualEquipmentId}');
|
||||
// 데이터 로딩이 완료되고 수정 모드일 때 텍스트 컨트롤러 업데이트
|
||||
// actualEquipmentId가 설정되었다는 것은 데이터가 로드되었다는 의미
|
||||
if (_controller.isEditMode && !_controller.isLoading && _controller.actualEquipmentId != null) {
|
||||
print('DEBUG [_onControllerUpdated] Condition met, updating text controllers');
|
||||
print('DEBUG [_onControllerUpdated] manufacturer: "${_controller.manufacturer}", name: "${_controller.name}"');
|
||||
_updateTextControllers();
|
||||
}
|
||||
}
|
||||
|
||||
// 텍스트 컨트롤러 업데이트 메서드
|
||||
void _updateTextControllers() {
|
||||
print('DEBUG [_updateTextControllers] Called');
|
||||
print('DEBUG [_updateTextControllers] Before update:');
|
||||
print(' manufacturerController.text="${_manufacturerController.text}"');
|
||||
print(' nameController.text="${_nameController.text}"');
|
||||
print('DEBUG [_updateTextControllers] Controller values:');
|
||||
print(' controller.manufacturer="${_controller.manufacturer}"');
|
||||
print(' controller.name="${_controller.name}"');
|
||||
print(' controller.serialNumber="${_controller.serialNumber}"');
|
||||
print(' controller.quantity=${_controller.quantity}');
|
||||
|
||||
setState(() {
|
||||
_manufacturerController.text = _controller.manufacturer;
|
||||
_nameController.text = _controller.name;
|
||||
_equipmentNameController.text = _controller.name; // 장비명 컨트롤러 추가
|
||||
_categoryController.text = _controller.category;
|
||||
_subCategoryController.text = _controller.subCategory;
|
||||
_subSubCategoryController.text = _controller.subSubCategory;
|
||||
@@ -252,10 +267,15 @@ class _EquipmentInFormScreenState extends State<EquipmentInFormScreen> {
|
||||
_warrantyCodeController.text = _controller.warrantyCode ?? '';
|
||||
_controller.remarkController.text = _controller.remarkController.text;
|
||||
});
|
||||
|
||||
print('DEBUG [_updateTextControllers] After update:');
|
||||
print(' manufacturerController.text="${_manufacturerController.text}"');
|
||||
print(' nameController.text="${_nameController.text}"');
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.removeListener(_onControllerUpdated);
|
||||
_manufacturerFocusNode.dispose();
|
||||
_nameFieldFocusNode.dispose();
|
||||
_partnerOverlayEntry?.remove();
|
||||
|
||||
@@ -214,7 +214,8 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
|
||||
if (result == true) {
|
||||
setState(() {
|
||||
_controller.loadData();
|
||||
_controller.loadData(isRefresh: true);
|
||||
_controller.goToPage(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -308,7 +309,8 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
);
|
||||
if (result == true) {
|
||||
setState(() {
|
||||
_controller.loadData();
|
||||
_controller.loadData(isRefresh: true);
|
||||
_controller.goToPage(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -344,6 +346,13 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
// 로딩 다이얼로그 닫기
|
||||
if (mounted) Navigator.pop(context);
|
||||
|
||||
// 삭제 후 리스트 새로고침 (서버에서 10개 다시 가져오기)
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.loadData(isRefresh: true);
|
||||
});
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('장비가 삭제되었습니다.')),
|
||||
@@ -508,6 +517,21 @@ class _EquipmentListState extends State<EquipmentList> {
|
||||
// 라우트별 액션 버튼
|
||||
_buildRouteSpecificActions(selectedInCount, selectedOutCount, selectedRentCount),
|
||||
],
|
||||
rightActions: [
|
||||
// 관리자용 비활성 포함 체크박스
|
||||
// TODO: 실제 권한 체크 로직 추가 필요
|
||||
Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: _controller.includeInactive,
|
||||
onChanged: (_) => setState(() {
|
||||
_controller.toggleIncludeInactive();
|
||||
}),
|
||||
),
|
||||
const Text('비활성 포함'),
|
||||
],
|
||||
),
|
||||
],
|
||||
totalCount: totalCount,
|
||||
selectedCount: selectedCount,
|
||||
onRefresh: () {
|
||||
|
||||
178
lib/screens/equipment/widgets/custom_dropdown_field.dart
Normal file
178
lib/screens/equipment/widgets/custom_dropdown_field.dart
Normal file
@@ -0,0 +1,178 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 드롭다운 기능이 있는 재사용 가능한 TextFormField 위젯
|
||||
class CustomDropdownField extends StatefulWidget {
|
||||
final String label;
|
||||
final String hint;
|
||||
final bool required;
|
||||
final TextEditingController controller;
|
||||
final FocusNode focusNode;
|
||||
final List<String> items;
|
||||
final Function(String) onChanged;
|
||||
final Function(String)? onFieldSubmitted;
|
||||
final String? Function(String)? getAutocompleteSuggestion;
|
||||
final VoidCallback onDropdownPressed;
|
||||
final LayerLink layerLink;
|
||||
final GlobalKey fieldKey;
|
||||
|
||||
const CustomDropdownField({
|
||||
Key? key,
|
||||
required this.label,
|
||||
required this.hint,
|
||||
required this.required,
|
||||
required this.controller,
|
||||
required this.focusNode,
|
||||
required this.items,
|
||||
required this.onChanged,
|
||||
this.onFieldSubmitted,
|
||||
this.getAutocompleteSuggestion,
|
||||
required this.onDropdownPressed,
|
||||
required this.layerLink,
|
||||
required this.fieldKey,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CustomDropdownField> createState() => _CustomDropdownFieldState();
|
||||
}
|
||||
|
||||
class _CustomDropdownFieldState extends State<CustomDropdownField> {
|
||||
bool _isProgrammaticChange = false;
|
||||
OverlayEntry? _overlayEntry;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_removeDropdown();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showDropdown() {
|
||||
_removeDropdown();
|
||||
|
||||
final RenderBox renderBox = widget.fieldKey.currentContext!.findRenderObject() as RenderBox;
|
||||
final size = renderBox.size;
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) => Positioned(
|
||||
width: size.width,
|
||||
child: CompositedTransformFollower(
|
||||
link: widget.layerLink,
|
||||
showWhenUnlinked: false,
|
||||
offset: const Offset(0, 45),
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 3,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
constraints: const BoxConstraints(maxHeight: 200),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: widget.items.map((item) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_isProgrammaticChange = true;
|
||||
widget.controller.text = item;
|
||||
});
|
||||
widget.onChanged(item);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_isProgrammaticChange = false;
|
||||
});
|
||||
_removeDropdown();
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: Text(item),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context).insert(_overlayEntry!);
|
||||
}
|
||||
|
||||
void _removeDropdown() {
|
||||
if (_overlayEntry != null) {
|
||||
_overlayEntry!.remove();
|
||||
_overlayEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CompositedTransformTarget(
|
||||
link: widget.layerLink,
|
||||
child: TextFormField(
|
||||
key: widget.fieldKey,
|
||||
controller: widget.controller,
|
||||
focusNode: widget.focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: widget.label,
|
||||
hintText: widget.hint,
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
onPressed: () {
|
||||
widget.onDropdownPressed();
|
||||
_showDropdown();
|
||||
},
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
if (!_isProgrammaticChange) {
|
||||
widget.onChanged(value);
|
||||
}
|
||||
},
|
||||
onFieldSubmitted: widget.onFieldSubmitted,
|
||||
),
|
||||
),
|
||||
// 자동완성 후보 표시
|
||||
if (widget.getAutocompleteSuggestion != null)
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final suggestion = widget.getAutocompleteSuggestion!(widget.controller.text);
|
||||
if (suggestion != null && suggestion.length > widget.controller.text.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 12, top: 2),
|
||||
child: Text(
|
||||
suggestion,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF1976D2),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
220
lib/screens/equipment/widgets/equipment_basic_info_section.dart
Normal file
220
lib/screens/equipment/widgets/equipment_basic_info_section.dart
Normal file
@@ -0,0 +1,220 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/custom_widgets/form_field_wrapper.dart';
|
||||
import 'package:superport/screens/equipment/controllers/equipment_in_form_controller.dart';
|
||||
import 'custom_dropdown_field.dart';
|
||||
|
||||
/// 장비 기본 정보 섹션 위젯
|
||||
class EquipmentBasicInfoSection extends StatelessWidget {
|
||||
final EquipmentInFormController controller;
|
||||
final TextEditingController partnerController;
|
||||
final TextEditingController warehouseController;
|
||||
final TextEditingController manufacturerController;
|
||||
final TextEditingController equipmentNameController;
|
||||
final FocusNode partnerFocusNode;
|
||||
final FocusNode warehouseFocusNode;
|
||||
final FocusNode manufacturerFocusNode;
|
||||
final FocusNode nameFieldFocusNode;
|
||||
final LayerLink partnerLayerLink;
|
||||
final LayerLink warehouseLayerLink;
|
||||
final LayerLink manufacturerLayerLink;
|
||||
final LayerLink equipmentNameLayerLink;
|
||||
final GlobalKey partnerFieldKey;
|
||||
final GlobalKey warehouseFieldKey;
|
||||
final GlobalKey manufacturerFieldKey;
|
||||
final GlobalKey equipmentNameFieldKey;
|
||||
final VoidCallback onPartnerDropdownPressed;
|
||||
final VoidCallback onWarehouseDropdownPressed;
|
||||
final VoidCallback onManufacturerDropdownPressed;
|
||||
final VoidCallback onEquipmentNameDropdownPressed;
|
||||
final String? Function(String) getPartnerAutocompleteSuggestion;
|
||||
final String? Function(String) getWarehouseAutocompleteSuggestion;
|
||||
final String? Function(String) getManufacturerAutocompleteSuggestion;
|
||||
final String? Function(String) getEquipmentNameAutocompleteSuggestion;
|
||||
|
||||
const EquipmentBasicInfoSection({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.partnerController,
|
||||
required this.warehouseController,
|
||||
required this.manufacturerController,
|
||||
required this.equipmentNameController,
|
||||
required this.partnerFocusNode,
|
||||
required this.warehouseFocusNode,
|
||||
required this.manufacturerFocusNode,
|
||||
required this.nameFieldFocusNode,
|
||||
required this.partnerLayerLink,
|
||||
required this.warehouseLayerLink,
|
||||
required this.manufacturerLayerLink,
|
||||
required this.equipmentNameLayerLink,
|
||||
required this.partnerFieldKey,
|
||||
required this.warehouseFieldKey,
|
||||
required this.manufacturerFieldKey,
|
||||
required this.equipmentNameFieldKey,
|
||||
required this.onPartnerDropdownPressed,
|
||||
required this.onWarehouseDropdownPressed,
|
||||
required this.onManufacturerDropdownPressed,
|
||||
required this.onEquipmentNameDropdownPressed,
|
||||
required this.getPartnerAutocompleteSuggestion,
|
||||
required this.getWarehouseAutocompleteSuggestion,
|
||||
required this.getManufacturerAutocompleteSuggestion,
|
||||
required this.getEquipmentNameAutocompleteSuggestion,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 섹션 제목
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: Text(
|
||||
'기본 정보',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 1행: 구매처, 입고지
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: FormFieldWrapper(
|
||||
label: '구매처',
|
||||
isRequired: true,
|
||||
child: CustomDropdownField(
|
||||
label: '구매처',
|
||||
hint: '구매처를 입력 또는 선택하세요',
|
||||
required: true,
|
||||
controller: partnerController,
|
||||
focusNode: partnerFocusNode,
|
||||
items: controller.partnerCompanies,
|
||||
onChanged: (value) {
|
||||
controller.partnerCompany = value;
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
final suggestion = getPartnerAutocompleteSuggestion(value);
|
||||
if (suggestion != null && suggestion.length > value.length) {
|
||||
partnerController.text = suggestion;
|
||||
controller.partnerCompany = suggestion;
|
||||
partnerController.selection = TextSelection.collapsed(
|
||||
offset: suggestion.length,
|
||||
);
|
||||
}
|
||||
},
|
||||
getAutocompleteSuggestion: getPartnerAutocompleteSuggestion,
|
||||
onDropdownPressed: onPartnerDropdownPressed,
|
||||
layerLink: partnerLayerLink,
|
||||
fieldKey: partnerFieldKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: FormFieldWrapper(
|
||||
label: '입고지',
|
||||
isRequired: true,
|
||||
child: CustomDropdownField(
|
||||
label: '입고지',
|
||||
hint: '입고지를 입력 또는 선택하세요',
|
||||
required: true,
|
||||
controller: warehouseController,
|
||||
focusNode: warehouseFocusNode,
|
||||
items: controller.warehouseLocations,
|
||||
onChanged: (value) {
|
||||
controller.warehouseLocation = value;
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
final suggestion = getWarehouseAutocompleteSuggestion(value);
|
||||
if (suggestion != null && suggestion.length > value.length) {
|
||||
warehouseController.text = suggestion;
|
||||
controller.warehouseLocation = suggestion;
|
||||
warehouseController.selection = TextSelection.collapsed(
|
||||
offset: suggestion.length,
|
||||
);
|
||||
}
|
||||
},
|
||||
getAutocompleteSuggestion: getWarehouseAutocompleteSuggestion,
|
||||
onDropdownPressed: onWarehouseDropdownPressed,
|
||||
layerLink: warehouseLayerLink,
|
||||
fieldKey: warehouseFieldKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// 2행: 제조사, 장비명
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: FormFieldWrapper(
|
||||
label: '제조사',
|
||||
isRequired: true,
|
||||
child: CustomDropdownField(
|
||||
label: '제조사',
|
||||
hint: '제조사를 입력 또는 선택하세요',
|
||||
required: true,
|
||||
controller: manufacturerController,
|
||||
focusNode: manufacturerFocusNode,
|
||||
items: controller.manufacturers,
|
||||
onChanged: (value) {
|
||||
controller.manufacturer = value;
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
final suggestion = getManufacturerAutocompleteSuggestion(value);
|
||||
if (suggestion != null && suggestion.length > value.length) {
|
||||
manufacturerController.text = suggestion;
|
||||
controller.manufacturer = suggestion;
|
||||
manufacturerController.selection = TextSelection.collapsed(
|
||||
offset: suggestion.length,
|
||||
);
|
||||
}
|
||||
},
|
||||
getAutocompleteSuggestion: getManufacturerAutocompleteSuggestion,
|
||||
onDropdownPressed: onManufacturerDropdownPressed,
|
||||
layerLink: manufacturerLayerLink,
|
||||
fieldKey: manufacturerFieldKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: FormFieldWrapper(
|
||||
label: '장비명',
|
||||
isRequired: true,
|
||||
child: CustomDropdownField(
|
||||
label: '장비명',
|
||||
hint: '장비명을 입력 또는 선택하세요',
|
||||
required: true,
|
||||
controller: equipmentNameController,
|
||||
focusNode: nameFieldFocusNode,
|
||||
items: controller.equipmentNames,
|
||||
onChanged: (value) {
|
||||
controller.name = value;
|
||||
},
|
||||
onFieldSubmitted: (value) {
|
||||
final suggestion = getEquipmentNameAutocompleteSuggestion(value);
|
||||
if (suggestion != null && suggestion.length > value.length) {
|
||||
equipmentNameController.text = suggestion;
|
||||
controller.name = suggestion;
|
||||
equipmentNameController.selection = TextSelection.collapsed(
|
||||
offset: suggestion.length,
|
||||
);
|
||||
}
|
||||
},
|
||||
getAutocompleteSuggestion: getEquipmentNameAutocompleteSuggestion,
|
||||
onDropdownPressed: onEquipmentNameDropdownPressed,
|
||||
layerLink: equipmentNameLayerLink,
|
||||
fieldKey: equipmentNameFieldKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user