사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)

This commit is contained in:
JiWoong Sul
2025-08-29 15:11:59 +09:00
parent a740ff10c8
commit d916b281a7
333 changed files with 53617 additions and 22574 deletions

View File

@@ -14,7 +14,7 @@ class AutocompleteTextField extends StatefulWidget {
final FocusNode? focusNode;
const AutocompleteTextField({
Key? key,
super.key,
required this.label,
required this.value,
required this.items,
@@ -23,7 +23,7 @@ class AutocompleteTextField extends StatefulWidget {
this.isRequired = false,
this.hintText = '',
this.focusNode,
}) : super(key: key);
});
@override
State<AutocompleteTextField> createState() => _AutocompleteTextFieldState();
@@ -141,7 +141,7 @@ class _AutocompleteTextFieldState extends State<AutocompleteTextField> {
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
color: Colors.grey.withValues(alpha: 0.3),
blurRadius: 4,
offset: const Offset(0, 2),
),

View File

@@ -16,7 +16,7 @@ class CustomDropdownField extends StatefulWidget {
final GlobalKey fieldKey;
const CustomDropdownField({
Key? key,
super.key,
required this.label,
required this.hint,
required this.required,
@@ -29,7 +29,7 @@ class CustomDropdownField extends StatefulWidget {
required this.onDropdownPressed,
required this.layerLink,
required this.fieldKey,
}) : super(key: key);
});
@override
State<CustomDropdownField> createState() => _CustomDropdownFieldState();

View File

@@ -193,13 +193,14 @@ class EquipmentBasicInfoSection extends StatelessWidget {
focusNode: nameFieldFocusNode,
items: controller.equipmentNames,
onChanged: (value) {
controller.name = value;
// Equipment name은 model 선택으로 자동 설정됨
// controller.name = value;
},
onFieldSubmitted: (value) {
final suggestion = getEquipmentNameAutocompleteSuggestion(value);
if (suggestion != null && suggestion.length > value.length) {
equipmentNameController.text = suggestion;
controller.name = suggestion;
// controller.name = suggestion;
equipmentNameController.selection = TextSelection.collapsed(
offset: suggestion.length,
);

View File

@@ -12,10 +12,10 @@ class EquipmentHistoryDialog extends StatefulWidget {
final String equipmentName;
const EquipmentHistoryDialog({
Key? key,
super.key,
required this.equipmentId,
required this.equipmentName,
}) : super(key: key);
});
@override
State<EquipmentHistoryDialog> createState() => _EquipmentHistoryDialogState();
@@ -138,9 +138,9 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
setState(() {
if (isRefresh) {
_histories = histories;
_histories = histories.cast<EquipmentHistoryDto>();
} else {
_histories.addAll(histories);
_histories.addAll(histories.cast<EquipmentHistoryDto>());
}
_filterHistories();
_hasMore = histories.length == _perPage;
@@ -217,7 +217,7 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
border: Border.all(color: Colors.grey.shade200),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.02),
color: Colors.black.withValues(alpha: 0.02),
blurRadius: 4,
offset: const Offset(0, 2),
),
@@ -239,7 +239,7 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
width: 40,
height: 40,
decoration: BoxDecoration(
color: typeColor.withOpacity(0.1),
color: typeColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Center(
@@ -379,7 +379,7 @@ class _EquipmentHistoryDialogState extends State<EquipmentHistoryDialog> {
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
color: Colors.black.withValues(alpha: 0.15),
blurRadius: 20,
offset: const Offset(0, 10),
),

View File

@@ -0,0 +1,402 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:superport/models/equipment_unified_model.dart';
import 'package:superport/screens/equipment/controllers/equipment_history_controller.dart';
import 'package:superport/data/models/equipment_history_dto.dart';
import 'package:intl/intl.dart';
/// Equipment의 입출고 이력을 표시하는 패널 위젯
class EquipmentHistoryPanel extends StatefulWidget {
final Equipment equipment;
final bool isExpanded;
final VoidCallback? onToggleExpand;
const EquipmentHistoryPanel({
super.key,
required this.equipment,
this.isExpanded = false,
this.onToggleExpand,
});
@override
State<EquipmentHistoryPanel> createState() => _EquipmentHistoryPanelState();
}
class _EquipmentHistoryPanelState extends State<EquipmentHistoryPanel> {
late EquipmentHistoryController _controller;
bool _isLoading = false;
List<EquipmentHistoryDto> _histories = [];
@override
void initState() {
super.initState();
_controller = GetIt.instance<EquipmentHistoryController>();
if (widget.equipment.id != null) {
_loadHistory();
}
}
Future<void> _loadHistory() async {
if (widget.equipment.id == null) return;
setState(() {
_isLoading = true;
});
try {
// Equipment ID로 이력 조회
await _controller.searchEquipmentHistories(
equipmentId: widget.equipment.id,
);
setState(() {
_histories = _controller.historyList;
_isLoading = false;
});
} catch (e) {
setState(() {
_isLoading = false;
});
}
}
@override
Widget build(BuildContext context) {
return Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 헤더
InkWell(
onTap: widget.onToggleExpand,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
Icons.history,
size: 20,
color: Theme.of(context).primaryColor,
),
const SizedBox(width: 8),
Text(
'장비 이력',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 8),
if (_histories.isNotEmpty)
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: Colors.green.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${_histories.length}',
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Colors.green,
),
),
),
],
),
Icon(
widget.isExpanded ? Icons.expand_less : Icons.expand_more,
color: Colors.grey[600],
),
],
),
),
),
// 확장된 내용
if (widget.isExpanded) ...[
const Divider(height: 1),
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 현재 상태 요약
_buildCurrentStatusSummary(),
const SizedBox(height: 16),
// 이력 표시
if (_isLoading)
const Center(
child: Padding(
padding: EdgeInsets.all(32.0),
child: CircularProgressIndicator(),
),
)
else if (_histories.isEmpty)
Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.grey[300]!,
style: BorderStyle.solid,
),
),
child: Column(
children: [
Icon(
Icons.history,
size: 48,
color: Colors.grey[400],
),
const SizedBox(height: 12),
Text(
'입출고 이력이 없습니다',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.grey[700],
),
),
],
),
)
else
_buildHistoryList(),
],
),
),
],
],
),
);
}
Widget _buildCurrentStatusSummary() {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.blue[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.blue[200]!,
),
),
child: Row(
children: [
Icon(
Icons.info_outline,
size: 20,
color: Colors.blue[700],
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'현재 장비 정보',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Colors.blue[900],
),
),
const SizedBox(height: 4),
Text(
'장비번호: ${widget.equipment.serialNumber}',
style: TextStyle(
fontSize: 13,
color: Colors.blue[700],
),
),
if (widget.equipment.model != null) ...[
Text(
'제조사: ${widget.equipment.model?.vendor?.name ?? 'N/A'}',
style: TextStyle(
fontSize: 13,
color: Colors.blue[700],
),
),
Text(
'모델: ${widget.equipment.model?.name ?? 'N/A'}',
style: TextStyle(
fontSize: 13,
color: Colors.blue[700],
),
),
],
if (widget.equipment.serialNumber != null)
Text(
'시리얼: ${widget.equipment.serialNumber}',
style: TextStyle(
fontSize: 13,
color: Colors.blue[700],
),
),
],
),
),
],
),
);
}
Widget _buildHistoryList() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'입출고 이력',
style: Theme.of(context).textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]!),
borderRadius: BorderRadius.circular(8),
),
child: Column(
children: [
// 테이블 헤더
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(7),
topRight: Radius.circular(7),
),
),
child: Row(
children: [
Expanded(
flex: 2,
child: Text('거래유형',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
color: Colors.grey[700])),
),
Expanded(
flex: 2,
child: Text('날짜',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
color: Colors.grey[700])),
),
Expanded(
flex: 1,
child: Text('수량',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
color: Colors.grey[700])),
),
Expanded(
flex: 2,
child: Text('창고',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
color: Colors.grey[700])),
),
Expanded(
flex: 3,
child: Text('비고',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
color: Colors.grey[700])),
),
],
),
),
// 테이블 바디
..._histories.map((history) => _buildHistoryRow(history)),
],
),
),
],
);
}
Widget _buildHistoryRow(EquipmentHistoryDto history) {
final dateFormat = DateFormat('yyyy-MM-dd');
final isIn = history.transactionType == 'I';
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.grey[200]!),
),
),
child: Row(
children: [
Expanded(
flex: 2,
child: Row(
children: [
Icon(
isIn ? Icons.arrow_downward : Icons.arrow_upward,
size: 16,
color: isIn ? Colors.green : Colors.red,
),
const SizedBox(width: 4),
Text(
isIn ? '입고' : '출고',
style: TextStyle(
fontSize: 13,
color: isIn ? Colors.green[700] : Colors.red[700],
fontWeight: FontWeight.w500,
),
),
],
),
),
Expanded(
flex: 2,
child: Text(
dateFormat.format(history.transactedAt),
style: const TextStyle(fontSize: 13),
),
),
Expanded(
flex: 1,
child: Text(
history.quantity?.toString() ?? '-',
style: const TextStyle(fontSize: 13),
),
),
Expanded(
flex: 2,
child: Text(
'-', // 창고 정보는 백엔드에서 제공하지 않음
style: const TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
),
),
Expanded(
flex: 3,
child: Text(
history.remark ?? '-',
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
}

View File

@@ -27,7 +27,7 @@ class EquipmentMultiSummaryCard extends StatelessWidget {
...selectedEquipments.map((equipmentData) {
final equipment = equipmentData['equipment'] as Equipment;
return EquipmentSingleSummaryCard(equipment: equipment);
}).toList(),
}),
],
);
}
@@ -91,7 +91,7 @@ class EquipmentSingleSummaryCard extends StatelessWidget {
border: Border.all(color: Colors.blue.shade300),
),
child: Text(
'수량: ${equipment.quantity}',
'수량: 1',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
@@ -110,10 +110,10 @@ class EquipmentSingleSummaryCard extends StatelessWidget {
: '정보 없음',
),
EquipmentSummaryRow(
label: '카테고리',
label: '모델명',
value:
equipment.category.isNotEmpty
? '${equipment.category} > ${equipment.subCategory} > ${equipment.subSubCategory}'
equipment.modelName.isNotEmpty
? equipment.modelName
: '정보 없음',
),
EquipmentSummaryRow(
@@ -126,19 +126,13 @@ class EquipmentSingleSummaryCard extends StatelessWidget {
),
EquipmentSummaryRow(
label: '출고 수량',
value: equipment.quantity.toString(),
value: '1',
),
EquipmentSummaryRow(
label: '입고일',
value: _formatDate(equipment.inDate),
),
// 워런티 정보 추가
if (equipment.warrantyLicense != null &&
equipment.warrantyLicense!.isNotEmpty)
EquipmentSummaryRow(
label: '워런티 라이센스',
value: equipment.warrantyLicense!,
),
// 워런티 라이센스 필드는 백엔드에서 제거됨
EquipmentSummaryRow(
label: '워런티 시작일',
value: _formatDate(equipment.warrantyStartDate),

View File

@@ -0,0 +1,234 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport/data/models/model_dto.dart';
import 'package:superport/screens/vendor/controllers/vendor_controller.dart';
import 'package:superport/screens/model/controllers/model_controller.dart';
import 'package:superport/injection_container.dart';
/// Equipment 등록/수정 폼에서 사용할 Vendor→Model cascade 선택 위젯
class EquipmentVendorModelSelector extends StatefulWidget {
final int? initialVendorId;
final int? initialModelId;
final Function(int? vendorId, int? modelId) onChanged;
final bool isReadOnly;
const EquipmentVendorModelSelector({
super.key,
this.initialVendorId,
this.initialModelId,
required this.onChanged,
this.isReadOnly = false,
});
@override
State<EquipmentVendorModelSelector> createState() => _EquipmentVendorModelSelectorState();
}
class _EquipmentVendorModelSelectorState extends State<EquipmentVendorModelSelector> {
late VendorController _vendorController;
late ModelController _modelController;
int? _selectedVendorId;
int? _selectedModelId;
List<ModelDto> _filteredModels = [];
bool _isLoadingVendors = false;
bool _isLoadingModels = false;
@override
void initState() {
super.initState();
_vendorController = getIt<VendorController>();
_modelController = getIt<ModelController>();
_selectedVendorId = widget.initialVendorId;
_selectedModelId = widget.initialModelId;
_loadInitialData();
}
Future<void> _loadInitialData() async {
setState(() => _isLoadingVendors = true);
try {
// Vendor 목록 로드
await _vendorController.loadVendors();
// 초기 vendor가 설정되어 있으면 해당 vendor의 모델 로드
if (_selectedVendorId != null) {
await _loadModelsForVendor(_selectedVendorId!);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('데이터 로드 실패: ${e.toString()}'),
backgroundColor: Colors.red,
),
);
}
} finally {
if (mounted) {
setState(() => _isLoadingVendors = false);
}
}
}
Future<void> _loadModelsForVendor(int vendorId) async {
setState(() {
_isLoadingModels = true;
_filteredModels = [];
_selectedModelId = null; // Vendor 변경 시 Model 선택 초기화
});
try {
// 특정 vendor의 모델 목록 로드
await _modelController.refreshModels();
// vendor에 해당하는 모델만 필터링
final allModels = _modelController.allModels;
_filteredModels = allModels.where((model) => model.vendorsId == vendorId).toList();
// 초기 모델이 설정되어 있고 필터링된 목록에 있으면 유지
if (widget.initialModelId != null &&
_filteredModels.any((m) => m.id == widget.initialModelId)) {
_selectedModelId = widget.initialModelId;
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('모델 로드 실패: ${e.toString()}'),
backgroundColor: Colors.red,
),
);
}
} finally {
if (mounted) {
setState(() => _isLoadingModels = false);
}
}
}
void _onVendorChanged(int? vendorId) {
setState(() {
_selectedVendorId = vendorId;
_selectedModelId = null; // Vendor 변경 시 Model 초기화
});
if (vendorId != null) {
_loadModelsForVendor(vendorId);
} else {
setState(() {
_filteredModels = [];
});
}
// 변경사항 콜백
widget.onChanged(_selectedVendorId, _selectedModelId);
}
void _onModelChanged(int? modelId) {
setState(() {
_selectedModelId = modelId;
});
// 변경사항 콜백
widget.onChanged(_selectedVendorId, _selectedModelId);
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Vendor 선택 드롭다운
_buildVendorDropdown(),
const SizedBox(height: 16),
// Model 선택 드롭다운 (Vendor 선택 후 활성화)
_buildModelDropdown(),
],
);
}
Widget _buildVendorDropdown() {
if (_isLoadingVendors) {
return const Center(child: CircularProgressIndicator());
}
final vendors = _vendorController.vendors;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.isReadOnly ? '제조사 * 🔒' : '제조사 *',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
ShadSelect<int>(
placeholder: const Text('제조사를 선택하세요'),
options: vendors.map((vendor) {
return ShadOption(
value: vendor.id!,
child: Text(vendor.name),
);
}).toList(),
selectedOptionBuilder: (context, value) {
final vendor = vendors.firstWhere((v) => v.id == value);
return Text(vendor.name);
},
onChanged: widget.isReadOnly ? null : _onVendorChanged,
initialValue: _selectedVendorId,
enabled: !widget.isReadOnly,
),
],
);
}
Widget _buildModelDropdown() {
if (_isLoadingModels) {
return const Center(child: CircularProgressIndicator());
}
// Vendor가 선택되지 않으면 비활성화
final isEnabled = !widget.isReadOnly && _selectedVendorId != null;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.isReadOnly ? '모델 * 🔒' : '모델 *',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
ShadSelect<int>(
placeholder: Text(
_selectedVendorId == null
? '먼저 제조사를 선택하세요'
: '모델을 선택하세요'
),
options: _filteredModels.map((model) {
return ShadOption(
value: model.id,
child: Text(model.name),
);
}).toList(),
selectedOptionBuilder: (context, value) {
final model = _filteredModels.firstWhere((m) => m.id == value);
return Text(model.name);
},
onChanged: isEnabled ? _onModelChanged : null,
initialValue: _selectedModelId,
enabled: isEnabled,
),
],
);
}
}