사용하지 않는 파일 정리 전 백업 (Phase 10 완료 후 상태)
This commit is contained in:
310
lib/screens/inventory/components/inventory_filter_bar.dart
Normal file
310
lib/screens/inventory/components/inventory_filter_bar.dart
Normal file
@@ -0,0 +1,310 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../../screens/equipment/controllers/equipment_history_controller.dart';
|
||||
|
||||
class InventoryFilterBar extends StatefulWidget {
|
||||
const InventoryFilterBar({super.key});
|
||||
|
||||
@override
|
||||
State<InventoryFilterBar> createState() => _InventoryFilterBarState();
|
||||
}
|
||||
|
||||
class _InventoryFilterBarState extends State<InventoryFilterBar> {
|
||||
String? _transactionType;
|
||||
int? _warehouseId;
|
||||
int? _equipmentId;
|
||||
DateTime? _startDate;
|
||||
DateTime? _endDate;
|
||||
|
||||
void _applyFilters() {
|
||||
final controller = context.read<EquipmentHistoryController>();
|
||||
controller.setFilters(
|
||||
transactionType: _transactionType,
|
||||
warehouseId: _warehouseId,
|
||||
equipmentId: _equipmentId,
|
||||
startDate: _startDate,
|
||||
endDate: _endDate,
|
||||
);
|
||||
controller.loadHistory();
|
||||
}
|
||||
|
||||
void _clearFilters() {
|
||||
setState(() {
|
||||
_transactionType = null;
|
||||
_warehouseId = null;
|
||||
_equipmentId = null;
|
||||
_startDate = null;
|
||||
_endDate = null;
|
||||
});
|
||||
|
||||
final controller = context.read<EquipmentHistoryController>();
|
||||
controller.clearFilters();
|
||||
controller.loadHistory();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.card,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: theme.colorScheme.border,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
// 거래 유형 필터
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'거래 유형',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ShadSelect<String>(
|
||||
placeholder: const Text('전체'),
|
||||
options: const [
|
||||
ShadOption(value: 'IN', child: Text('입고')),
|
||||
ShadOption(value: 'OUT', child: Text('출고')),
|
||||
ShadOption(value: 'TRANSFER', child: Text('이동')),
|
||||
ShadOption(value: 'ADJUSTMENT', child: Text('조정')),
|
||||
],
|
||||
selectedOptionBuilder: (context, value) {
|
||||
switch (value) {
|
||||
case 'IN':
|
||||
return const Text('입고');
|
||||
case 'OUT':
|
||||
return const Text('출고');
|
||||
case 'TRANSFER':
|
||||
return const Text('이동');
|
||||
case 'ADJUSTMENT':
|
||||
return const Text('조정');
|
||||
default:
|
||||
return const Text('');
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_transactionType = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 창고 필터
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'창고',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ShadSelect<int>(
|
||||
placeholder: const Text('전체'),
|
||||
options: const [
|
||||
ShadOption(value: 1, child: Text('본사 창고')),
|
||||
ShadOption(value: 2, child: Text('지사 창고')),
|
||||
ShadOption(value: 3, child: Text('외부 창고')),
|
||||
],
|
||||
selectedOptionBuilder: (context, value) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return const Text('본사 창고');
|
||||
case 2:
|
||||
return const Text('지사 창고');
|
||||
case 3:
|
||||
return const Text('외부 창고');
|
||||
default:
|
||||
return const Text('');
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_warehouseId = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 시작일
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'시작일',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _startDate ?? DateTime.now(),
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
_startDate = picked;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: theme.colorScheme.border),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
_startDate != null
|
||||
? '${_startDate!.year}-${_startDate!.month.toString().padLeft(2, '0')}-${_startDate!.day.toString().padLeft(2, '0')}'
|
||||
: '선택',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
Icon(
|
||||
Icons.calendar_today,
|
||||
size: 14,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 종료일
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'종료일',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _endDate ?? DateTime.now(),
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
_endDate = picked;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: theme.colorScheme.border),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
_endDate != null
|
||||
? '${_endDate!.year}-${_endDate!.month.toString().padLeft(2, '0')}-${_endDate!.day.toString().padLeft(2, '0')}'
|
||||
: '선택',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
Icon(
|
||||
Icons.calendar_today,
|
||||
size: 14,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 버튼
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
ShadButton(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: _applyFilters,
|
||||
child: const Text('적용'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: _clearFilters,
|
||||
child: const Text('초기화'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// 검색창
|
||||
const SizedBox(height: 16),
|
||||
Consumer<EquipmentHistoryController>(
|
||||
builder: (context, controller, _) {
|
||||
return ShadInput(
|
||||
placeholder: const Text('장비명, 시리얼 번호로 검색'),
|
||||
onChanged: (value) {
|
||||
controller.setSearchQuery(value);
|
||||
if (value.isEmpty || value.length >= 2) {
|
||||
controller.loadHistory();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
140
lib/screens/inventory/components/stock_level_indicator.dart
Normal file
140
lib/screens/inventory/components/stock_level_indicator.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
class StockLevelIndicator extends StatelessWidget {
|
||||
final int current;
|
||||
final int maximum;
|
||||
final int? minimum;
|
||||
final bool showLabels;
|
||||
|
||||
const StockLevelIndicator({
|
||||
super.key,
|
||||
required this.current,
|
||||
required this.maximum,
|
||||
this.minimum,
|
||||
this.showLabels = false,
|
||||
});
|
||||
|
||||
Color _getColor(double percentage) {
|
||||
if (percentage <= 0.2) {
|
||||
return Colors.red;
|
||||
} else if (percentage <= 0.4) {
|
||||
return Colors.orange;
|
||||
} else if (percentage <= 0.6) {
|
||||
return Colors.yellow[700]!;
|
||||
} else if (percentage <= 0.8) {
|
||||
return Colors.blue;
|
||||
} else {
|
||||
return Colors.green;
|
||||
}
|
||||
}
|
||||
|
||||
String _getLabel(double percentage) {
|
||||
if (percentage <= 0.2) {
|
||||
return '매우 낮음';
|
||||
} else if (percentage <= 0.4) {
|
||||
return '낮음';
|
||||
} else if (percentage <= 0.6) {
|
||||
return '보통';
|
||||
} else if (percentage <= 0.8) {
|
||||
return '충분';
|
||||
} else {
|
||||
return '매우 충분';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
final percentage = maximum > 0 ? (current / maximum).clamp(0.0, 1.0) : 0.0;
|
||||
final color = _getColor(percentage);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (showLabels)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
_getLabel(percentage),
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${(percentage * 100).toStringAsFixed(0)}%',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showLabels) const SizedBox(height: 4),
|
||||
Container(
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.muted,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
// 최소 재고 표시
|
||||
if (minimum != null && maximum > 0)
|
||||
Positioned(
|
||||
left: (minimum! / maximum * MediaQuery.of(context).size.width).clamp(0.0, double.infinity),
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: 2,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
|
||||
// 현재 재고 표시
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
width: percentage * MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (showLabels && minimum != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'최소: $minimum',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'현재: $current',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.foreground,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'최대: $maximum',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
147
lib/screens/inventory/components/transaction_type_badge.dart
Normal file
147
lib/screens/inventory/components/transaction_type_badge.dart
Normal file
@@ -0,0 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
class TransactionTypeBadge extends StatelessWidget {
|
||||
final String type;
|
||||
|
||||
const TransactionTypeBadge({
|
||||
super.key,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (type.toUpperCase()) {
|
||||
case 'IN':
|
||||
return ShadBadge(
|
||||
backgroundColor: Colors.green.withValues(alpha: 0.1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_downward,
|
||||
size: 12,
|
||||
color: Colors.green[700],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'입고',
|
||||
style: TextStyle(
|
||||
color: Colors.green[700],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
case 'OUT':
|
||||
return ShadBadge(
|
||||
backgroundColor: Colors.red.withValues(alpha: 0.1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_upward,
|
||||
size: 12,
|
||||
color: Colors.red[700],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'출고',
|
||||
style: TextStyle(
|
||||
color: Colors.red[700],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
case 'TRANSFER':
|
||||
return ShadBadge(
|
||||
backgroundColor: Colors.blue.withValues(alpha: 0.1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.swap_horiz,
|
||||
size: 12,
|
||||
color: Colors.blue[700],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'이동',
|
||||
style: TextStyle(
|
||||
color: Colors.blue[700],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
case 'ADJUSTMENT':
|
||||
return ShadBadge(
|
||||
backgroundColor: Colors.orange.withValues(alpha: 0.1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.tune,
|
||||
size: 12,
|
||||
color: Colors.orange[700],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'조정',
|
||||
style: TextStyle(
|
||||
color: Colors.orange[700],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
case 'RETURN':
|
||||
return ShadBadge(
|
||||
backgroundColor: Colors.purple.withValues(alpha: 0.1),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.undo,
|
||||
size: 12,
|
||||
color: Colors.purple[700],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'반품',
|
||||
style: TextStyle(
|
||||
color: Colors.purple[700],
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
default:
|
||||
return ShadBadge.secondary(
|
||||
child: Text(
|
||||
type,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/data/models/equipment_history_dto.dart';
|
||||
import 'package:superport/domain/usecases/equipment_history_usecase.dart';
|
||||
import 'package:superport/injection_container.dart';
|
||||
import 'package:superport/utils/constants.dart';
|
||||
|
||||
class EquipmentHistoryController extends ChangeNotifier {
|
||||
final EquipmentHistoryUseCase _useCase = getIt<EquipmentHistoryUseCase>();
|
||||
|
||||
// 상태 관리
|
||||
bool _isLoading = false;
|
||||
bool _isSubmitting = false;
|
||||
String? _errorMessage;
|
||||
String? _successMessage;
|
||||
|
||||
// 데이터 (백엔드 스키마 기반)
|
||||
List<EquipmentHistoryDto> _histories = [];
|
||||
int _totalCount = 0;
|
||||
int _currentPage = 1;
|
||||
final int _pageSize = PaginationConstants.defaultPageSize;
|
||||
|
||||
// 필터
|
||||
int? _filterEquipmentId;
|
||||
int? _filterWarehouseId;
|
||||
int? _filterCompanyId;
|
||||
String? _filterTransactionType;
|
||||
String? _filterStartDate;
|
||||
String? _filterEndDate;
|
||||
String? _searchQuery;
|
||||
|
||||
// Getters
|
||||
bool get isLoading => _isLoading;
|
||||
bool get isSubmitting => _isSubmitting;
|
||||
String? get errorMessage => _errorMessage;
|
||||
String? get successMessage => _successMessage;
|
||||
List<EquipmentHistoryDto> get histories => _histories;
|
||||
int get totalCount => _totalCount;
|
||||
int get currentPage => _currentPage;
|
||||
int get pageSize => _pageSize;
|
||||
int get totalPages => (_totalCount / _pageSize).ceil();
|
||||
|
||||
// 필터 Getters
|
||||
int? get filterEquipmentId => _filterEquipmentId;
|
||||
int? get filterWarehouseId => _filterWarehouseId;
|
||||
int? get filterCompanyId => _filterCompanyId;
|
||||
String? get filterTransactionType => _filterTransactionType;
|
||||
String? get filterStartDate => _filterStartDate;
|
||||
String? get filterEndDate => _filterEndDate;
|
||||
String? get searchQuery => _searchQuery;
|
||||
|
||||
// 필터 설정
|
||||
void setFilters({
|
||||
int? equipmentId,
|
||||
int? warehouseId,
|
||||
int? companyId,
|
||||
String? transactionType,
|
||||
String? startDate,
|
||||
String? endDate,
|
||||
String? search,
|
||||
}) {
|
||||
_filterEquipmentId = equipmentId;
|
||||
_filterWarehouseId = warehouseId;
|
||||
_filterCompanyId = companyId;
|
||||
_filterTransactionType = transactionType;
|
||||
_filterStartDate = startDate;
|
||||
_filterEndDate = endDate;
|
||||
_searchQuery = search;
|
||||
_currentPage = 1;
|
||||
loadHistories();
|
||||
}
|
||||
|
||||
// 필터 초기화
|
||||
void clearFilters() {
|
||||
_filterEquipmentId = null;
|
||||
_filterWarehouseId = null;
|
||||
_filterCompanyId = null;
|
||||
_filterTransactionType = null;
|
||||
_filterStartDate = null;
|
||||
_filterEndDate = null;
|
||||
_searchQuery = null;
|
||||
_currentPage = 1;
|
||||
loadHistories();
|
||||
}
|
||||
|
||||
// 페이지 변경
|
||||
void changePage(int page) {
|
||||
if (page < 1 || page > totalPages) return;
|
||||
_currentPage = page;
|
||||
loadHistories();
|
||||
}
|
||||
|
||||
// 재고 이력 목록 조회
|
||||
Future<void> loadHistories() async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final response = await _useCase.getEquipmentHistories(
|
||||
page: _currentPage,
|
||||
pageSize: _pageSize,
|
||||
equipmentsId: _filterEquipmentId,
|
||||
warehousesId: _filterWarehouseId,
|
||||
companiesId: _filterCompanyId,
|
||||
transactionType: _filterTransactionType,
|
||||
startDate: _filterStartDate,
|
||||
endDate: _filterEndDate,
|
||||
);
|
||||
|
||||
_histories = response.items;
|
||||
_totalCount = response.totalCount;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
_histories = [];
|
||||
_totalCount = 0;
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 특정 장비의 재고 이력 조회
|
||||
Future<void> loadEquipmentHistories(int equipmentId) async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_histories = await _useCase.getEquipmentHistoriesByEquipmentId(equipmentId);
|
||||
_totalCount = _histories.length;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
_histories = [];
|
||||
_totalCount = 0;
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 창고별 재고 이력 조회
|
||||
Future<void> loadWarehouseHistories(int warehouseId) async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_histories = await _useCase.getEquipmentHistoriesByWarehouseId(warehouseId);
|
||||
_totalCount = _histories.length;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
_histories = [];
|
||||
_totalCount = 0;
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 백엔드 스키마 기반 단순 재고 조회 (EquipmentHistoryDto 기반)
|
||||
// 특정 장비의 현재 재고량 계산 (입고량 - 출고량)
|
||||
int calculateEquipmentStock(int equipmentId) {
|
||||
final equipmentHistories = _histories.where((h) => h.equipmentsId == equipmentId);
|
||||
int totalIn = equipmentHistories
|
||||
.where((h) => h.transactionType == 'I')
|
||||
.fold(0, (sum, h) => sum + h.quantity);
|
||||
int totalOut = equipmentHistories
|
||||
.where((h) => h.transactionType == 'O')
|
||||
.fold(0, (sum, h) => sum + h.quantity);
|
||||
return totalIn - totalOut;
|
||||
}
|
||||
|
||||
// 입고 처리 (백엔드 스키마 기반)
|
||||
Future<bool> createStockIn({
|
||||
required int equipmentsId,
|
||||
required int warehousesId,
|
||||
required int quantity,
|
||||
DateTime? transactedAt,
|
||||
String? remark,
|
||||
}) async {
|
||||
_isSubmitting = true;
|
||||
_errorMessage = null;
|
||||
_successMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final request = EquipmentHistoryRequestDto(
|
||||
equipmentsId: equipmentsId,
|
||||
warehousesId: warehousesId,
|
||||
transactionType: 'I', // 입고
|
||||
quantity: quantity,
|
||||
transactedAt: transactedAt ?? DateTime.now(),
|
||||
remark: remark,
|
||||
);
|
||||
|
||||
await _useCase.createEquipmentHistory(request);
|
||||
_successMessage = '입고 처리가 완료되었습니다.';
|
||||
await loadHistories();
|
||||
return true;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
return false;
|
||||
} finally {
|
||||
_isSubmitting = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 출고 처리 (백엔드 스키마 기반)
|
||||
Future<bool> createStockOut({
|
||||
required int equipmentsId,
|
||||
required int warehousesId,
|
||||
required int quantity,
|
||||
DateTime? transactedAt,
|
||||
String? remark,
|
||||
}) async {
|
||||
_isSubmitting = true;
|
||||
_errorMessage = null;
|
||||
_successMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final request = EquipmentHistoryRequestDto(
|
||||
equipmentsId: equipmentsId,
|
||||
warehousesId: warehousesId,
|
||||
transactionType: 'O', // 출고
|
||||
quantity: quantity,
|
||||
transactedAt: transactedAt ?? DateTime.now(),
|
||||
remark: remark,
|
||||
);
|
||||
|
||||
await _useCase.createEquipmentHistory(request);
|
||||
_successMessage = '출고 처리가 완료되었습니다.';
|
||||
await loadHistories();
|
||||
return true;
|
||||
} catch (e) {
|
||||
_errorMessage = e.toString();
|
||||
return false;
|
||||
} finally {
|
||||
_isSubmitting = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// 백엔드 스키마 기반 단순 통계 기능들
|
||||
|
||||
// 특정 창고의 재고 현황 (장비별 집계)
|
||||
Map<int, int> getWarehouseStock(int warehouseId) {
|
||||
Map<int, int> stockMap = {};
|
||||
final warehouseHistories = _histories.where((h) => h.warehousesId == warehouseId);
|
||||
|
||||
for (var equipmentId in warehouseHistories.map((h) => h.equipmentsId).toSet()) {
|
||||
stockMap[equipmentId] = calculateEquipmentStock(equipmentId);
|
||||
}
|
||||
return stockMap;
|
||||
}
|
||||
|
||||
// 전체 재고 현황 요약
|
||||
Map<String, int> getStockSummary() {
|
||||
int totalIn = _histories
|
||||
.where((h) => h.transactionType == 'I')
|
||||
.fold(0, (sum, h) => sum + h.quantity);
|
||||
int totalOut = _histories
|
||||
.where((h) => h.transactionType == 'O')
|
||||
.fold(0, (sum, h) => sum + h.quantity);
|
||||
|
||||
return {
|
||||
'totalStock': totalIn - totalOut,
|
||||
'totalIn': totalIn,
|
||||
'totalOut': totalOut,
|
||||
};
|
||||
}
|
||||
|
||||
// 메시지 클리어
|
||||
void clearMessages() {
|
||||
_errorMessage = null;
|
||||
_successMessage = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_histories.clear();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
258
lib/screens/inventory/inventory_dashboard.dart
Normal file
258
lib/screens/inventory/inventory_dashboard.dart
Normal file
@@ -0,0 +1,258 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../equipment/controllers/equipment_history_controller.dart';
|
||||
|
||||
class InventoryDashboard extends StatefulWidget {
|
||||
const InventoryDashboard({super.key});
|
||||
|
||||
@override
|
||||
State<InventoryDashboard> createState() => _InventoryDashboardState();
|
||||
}
|
||||
|
||||
class _InventoryDashboardState extends State<InventoryDashboard> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final controller = context.read<EquipmentHistoryController>();
|
||||
controller.loadHistory(refresh: true);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
body: Consumer<EquipmentHistoryController>(
|
||||
builder: (context, controller, child) {
|
||||
if (controller.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 헤더
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'재고 대시보드',
|
||||
style: theme.textTheme.h2,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'실시간 재고 현황 및 경고 알림',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.refresh, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Text('새로고침'),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
controller.loadInventoryStatus();
|
||||
controller.loadWarehouseStock();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton(
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.download, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Text('보고서 다운로드'),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
// 보고서 다운로드 기능
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 통계 카드
|
||||
GridView.count(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisCount: MediaQuery.of(context).size.width > 1200 ? 4 : 2,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 1.5,
|
||||
children: [
|
||||
_buildStatCard(
|
||||
theme,
|
||||
title: '총 입고',
|
||||
value: '${controller.getStockSummary()['totalIn']}',
|
||||
unit: '개',
|
||||
icon: Icons.input,
|
||||
color: Colors.green,
|
||||
),
|
||||
_buildStatCard(
|
||||
theme,
|
||||
title: '총 출고',
|
||||
value: '${controller.getStockSummary()['totalOut']}',
|
||||
unit: '개',
|
||||
icon: Icons.output,
|
||||
color: Colors.red,
|
||||
),
|
||||
_buildStatCard(
|
||||
theme,
|
||||
title: '현재 재고',
|
||||
value: '${controller.getStockSummary()['totalStock']}',
|
||||
unit: '개',
|
||||
icon: Icons.inventory_2,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
_buildStatCard(
|
||||
theme,
|
||||
title: '총 거래',
|
||||
value: '${controller.historyList.length}',
|
||||
unit: '건',
|
||||
icon: Icons.history,
|
||||
color: Colors.blue,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 최근 거래 이력 (백엔드 스키마 기반)
|
||||
Text(
|
||||
'최근 거래 이력',
|
||||
style: theme.textTheme.h3,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ShadCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: controller.historyList.isEmpty
|
||||
? const Center(
|
||||
child: Text('거래 이력이 없습니다.'),
|
||||
)
|
||||
: Column(
|
||||
children: controller.historyList.take(10).map((history) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
DateFormat('MM/dd HH:mm').format(history.transactedAt),
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: history.transactionType == 'I' ? Colors.green : Colors.red,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
history.transactionType == 'I' ? '입고' : '출고',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 12),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
'${history.quantity}개',
|
||||
style: theme.textTheme.small,
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
history.remark ?? '-',
|
||||
style: theme.textTheme.small,
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard(
|
||||
ShadThemeData theme, {
|
||||
required String title,
|
||||
required String value,
|
||||
required String unit,
|
||||
required IconData icon,
|
||||
required Color color,
|
||||
}) {
|
||||
return ShadCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 24),
|
||||
Text(
|
||||
unit,
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: theme.textTheme.h2,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
317
lib/screens/inventory/inventory_history_screen.dart
Normal file
317
lib/screens/inventory/inventory_history_screen.dart
Normal file
@@ -0,0 +1,317 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../screens/equipment/controllers/equipment_history_controller.dart';
|
||||
import 'components/inventory_filter_bar.dart';
|
||||
import 'components/transaction_type_badge.dart';
|
||||
|
||||
class InventoryHistoryScreen extends StatefulWidget {
|
||||
const InventoryHistoryScreen({super.key});
|
||||
|
||||
@override
|
||||
State<InventoryHistoryScreen> createState() => _InventoryHistoryScreenState();
|
||||
}
|
||||
|
||||
class _InventoryHistoryScreenState extends State<InventoryHistoryScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<EquipmentHistoryController>().loadHistory();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.card,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: theme.colorScheme.border,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'재고 이력 관리',
|
||||
style: theme.textTheme.h2,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
ShadButton(
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.add, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Text('입고 등록'),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/inventory/stock-in');
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.outline(
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.remove, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Text('출고 처리'),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/inventory/stock-out');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'장비 입출고 이력을 조회하고 관리합니다',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 필터 바
|
||||
const InventoryFilterBar(),
|
||||
|
||||
// 테이블
|
||||
Expanded(
|
||||
child: Consumer<EquipmentHistoryController>(
|
||||
builder: (context, controller, child) {
|
||||
if (controller.isLoading && controller.historyList.isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (controller.error != null) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
size: 48,
|
||||
color: theme.colorScheme.destructive,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'데이터를 불러오는 중 오류가 발생했습니다',
|
||||
style: theme.textTheme.large,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
controller.error!,
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ShadButton(
|
||||
child: const Text('다시 시도'),
|
||||
onPressed: () => controller.loadHistory(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (controller.historyList.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_outlined,
|
||||
size: 48,
|
||||
color: theme.colorScheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'등록된 재고 이력이 없습니다',
|
||||
style: theme.textTheme.large,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'입고 등록 버튼을 눌러 새로운 재고를 추가하세요',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// 테이블
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: MediaQuery.of(context).size.width,
|
||||
),
|
||||
child: ShadTable(
|
||||
columnCount: 9,
|
||||
rowCount: controller.historyList.length + 1,
|
||||
builder: (context, vicinity) {
|
||||
final column = vicinity.column;
|
||||
final row = vicinity.row;
|
||||
|
||||
if (row == 0) {
|
||||
// 헤더
|
||||
switch (column) {
|
||||
case 0:
|
||||
return const ShadTableCell.header(child: Text('ID'));
|
||||
case 1:
|
||||
return const ShadTableCell.header(child: Text('거래 유형'));
|
||||
case 2:
|
||||
return const ShadTableCell.header(child: Text('장비명'));
|
||||
case 3:
|
||||
return const ShadTableCell.header(child: Text('시리얼 번호'));
|
||||
case 4:
|
||||
return const ShadTableCell.header(child: Text('창고'));
|
||||
case 5:
|
||||
return const ShadTableCell.header(child: Text('수량'));
|
||||
case 6:
|
||||
return const ShadTableCell.header(child: Text('거래일'));
|
||||
case 7:
|
||||
return const ShadTableCell.header(child: Text('비고'));
|
||||
case 8:
|
||||
return const ShadTableCell.header(child: Text('작업'));
|
||||
default:
|
||||
return const ShadTableCell(child: SizedBox());
|
||||
}
|
||||
}
|
||||
|
||||
final history = controller.historyList[row - 1];
|
||||
switch (column) {
|
||||
case 0:
|
||||
return ShadTableCell(child: Text('${history.id}'));
|
||||
case 1:
|
||||
return ShadTableCell(
|
||||
child: TransactionTypeBadge(
|
||||
type: history.transactionType ?? '',
|
||||
),
|
||||
);
|
||||
case 2:
|
||||
return ShadTableCell(
|
||||
child: Text(history.equipment?.modelName ?? '-'),
|
||||
);
|
||||
case 3:
|
||||
return ShadTableCell(
|
||||
child: Text(history.equipment?.serialNumber ?? '-'),
|
||||
);
|
||||
case 4:
|
||||
return ShadTableCell(
|
||||
child: Text(history.warehouse?.name ?? '-'),
|
||||
);
|
||||
case 5:
|
||||
return ShadTableCell(
|
||||
child: Text('${history.quantity ?? 0}'),
|
||||
);
|
||||
case 6:
|
||||
return ShadTableCell(
|
||||
child: Text(
|
||||
DateFormat('yyyy-MM-dd').format(history.transactedAt),
|
||||
),
|
||||
);
|
||||
case 7:
|
||||
return ShadTableCell(
|
||||
child: Text(history.remark ?? '-'),
|
||||
);
|
||||
case 8:
|
||||
return ShadTableCell(
|
||||
child: Row(
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.edit, size: 14),
|
||||
onPressed: () {
|
||||
// 편집 기능
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ShadButton.ghost(
|
||||
size: ShadButtonSize.sm,
|
||||
child: const Icon(Icons.delete, size: 14),
|
||||
onPressed: () {
|
||||
// 삭제 기능
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
default:
|
||||
return const ShadTableCell(child: SizedBox());
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 페이지네이션
|
||||
if (controller.totalPages > 1)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.card,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: theme.colorScheme.border,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
enabled: controller.currentPage > 1,
|
||||
child: const Icon(Icons.chevron_left, size: 16),
|
||||
onPressed: () => controller.previousPage(),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
'${controller.currentPage} / ${controller.totalPages}',
|
||||
style: theme.textTheme.small,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
ShadButton.outline(
|
||||
enabled: controller.currentPage < controller.totalPages,
|
||||
child: const Icon(Icons.chevron_right, size: 16),
|
||||
onPressed: () => controller.nextPage(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
293
lib/screens/inventory/stock_in_form.dart
Normal file
293
lib/screens/inventory/stock_in_form.dart
Normal file
@@ -0,0 +1,293 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../screens/equipment/controllers/equipment_history_controller.dart';
|
||||
import '../../screens/equipment/controllers/equipment_list_controller.dart';
|
||||
import '../../data/models/equipment_history_dto.dart';
|
||||
|
||||
class StockInForm extends StatefulWidget {
|
||||
const StockInForm({super.key});
|
||||
|
||||
@override
|
||||
State<StockInForm> createState() => _StockInFormState();
|
||||
}
|
||||
|
||||
class _StockInFormState extends State<StockInForm> {
|
||||
final _formKey = GlobalKey<ShadFormState>();
|
||||
|
||||
int? _selectedEquipmentId;
|
||||
int? _selectedWarehouseId;
|
||||
int _quantity = 1;
|
||||
DateTime _transactionDate = DateTime.now();
|
||||
String? _notes;
|
||||
String _status = 'available'; // 장비 상태
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// 장비 목록 로드
|
||||
context.read<EquipmentListController>().refresh();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit() async {
|
||||
if (_formKey.currentState?.saveAndValidate() ?? false) {
|
||||
final controller = context.read<EquipmentHistoryController>();
|
||||
|
||||
// 백엔드 스키마에 맞는 요청 데이터 생성
|
||||
final request = EquipmentHistoryRequestDto(
|
||||
equipmentsId: _selectedEquipmentId!,
|
||||
warehousesId: _selectedWarehouseId ?? 1, // 기본 창고 ID
|
||||
transactionType: 'I', // 입고
|
||||
quantity: _quantity,
|
||||
transactedAt: _transactionDate,
|
||||
remark: _notes,
|
||||
);
|
||||
|
||||
await controller.createHistory(request);
|
||||
|
||||
if (controller.error == null && mounted) {
|
||||
ShadToaster.of(context).show(
|
||||
const ShadToast(
|
||||
title: Text('입고 등록 완료'),
|
||||
description: Text('장비가 성공적으로 입고되었습니다'),
|
||||
),
|
||||
);
|
||||
Navigator.pop(context, true);
|
||||
} else if (controller.error != null && mounted) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast.destructive(
|
||||
title: const Text('입고 등록 실패'),
|
||||
description: Text(controller.error!),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.colorScheme.card,
|
||||
title: const Text('장비 입고 등록'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Center(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
child: ShadCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ShadForm(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'입고 정보 입력',
|
||||
style: theme.textTheme.h3,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'입고할 장비와 창고 정보를 입력하세요',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 장비 선택
|
||||
Consumer<EquipmentListController>(
|
||||
builder: (context, controller, _) {
|
||||
return ShadSelect<int>(
|
||||
placeholder: const Text('장비 선택'),
|
||||
options: controller.equipments.map((equipment) {
|
||||
return ShadOption(
|
||||
value: equipment.id!,
|
||||
child: Text('${equipment.equipment.modelDto?.name ?? 'Unknown'} (${equipment.equipment.serialNumber})'),
|
||||
);
|
||||
}).toList(),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
final equipment = controller.equipments.firstWhere(
|
||||
(e) => e.id == value,
|
||||
);
|
||||
return Text('${equipment.equipment.modelDto?.name ?? 'Unknown'} (${equipment.equipment.serialNumber})');
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedEquipmentId = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 창고 선택
|
||||
ShadSelect<int>(
|
||||
placeholder: const Text('창고 선택'),
|
||||
options: [
|
||||
const ShadOption(value: 1, child: Text('본사 창고')),
|
||||
const ShadOption(value: 2, child: Text('지사 창고')),
|
||||
const ShadOption(value: 3, child: Text('외부 창고')),
|
||||
],
|
||||
selectedOptionBuilder: (context, value) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return const Text('본사 창고');
|
||||
case 2:
|
||||
return const Text('지사 창고');
|
||||
case 3:
|
||||
return const Text('외부 창고');
|
||||
default:
|
||||
return const Text('');
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedWarehouseId = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 수량
|
||||
ShadInputFormField(
|
||||
label: const Text('수량'),
|
||||
initialValue: '1',
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (v) {
|
||||
if (_quantity <= 0) {
|
||||
return '수량은 1 이상이어야 합니다';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_quantity = int.tryParse(value) ?? 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 입고일
|
||||
ShadInputFormField(
|
||||
label: const Text('입고일'),
|
||||
initialValue: '${_transactionDate.year}-${_transactionDate.month.toString().padLeft(2, '0')}-${_transactionDate.day.toString().padLeft(2, '0')}',
|
||||
enabled: false,
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.calendar_today, size: 16),
|
||||
onPressed: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _transactionDate,
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
_transactionDate = picked;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 상태
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('상태', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||
const SizedBox(height: 8),
|
||||
ShadSelect<String>(
|
||||
placeholder: const Text('상태 선택'),
|
||||
initialValue: 'available',
|
||||
options: const [
|
||||
ShadOption(value: 'available', child: Text('사용 가능')),
|
||||
ShadOption(value: 'in_use', child: Text('사용 중')),
|
||||
ShadOption(value: 'maintenance', child: Text('정비 중')),
|
||||
ShadOption(value: 'reserved', child: Text('예약됨')),
|
||||
],
|
||||
selectedOptionBuilder: (context, value) {
|
||||
switch (value) {
|
||||
case 'available':
|
||||
return const Text('사용 가능');
|
||||
case 'in_use':
|
||||
return const Text('사용 중');
|
||||
case 'maintenance':
|
||||
return const Text('정비 중');
|
||||
case 'reserved':
|
||||
return const Text('예약됨');
|
||||
default:
|
||||
return const Text('');
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_status = value ?? 'available';
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 비고
|
||||
ShadInputFormField(
|
||||
label: const Text('비고'),
|
||||
maxLines: 3,
|
||||
placeholder: const Text('추가 정보를 입력하세요'),
|
||||
onChanged: (value) {
|
||||
_notes = value.isEmpty ? null : value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 버튼
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
child: const Text('취소'),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Consumer<EquipmentHistoryController>(
|
||||
builder: (context, controller, _) {
|
||||
return ShadButton(
|
||||
enabled: !controller.isLoading,
|
||||
onPressed: _handleSubmit,
|
||||
child: controller.isLoading
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text('입고 등록'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
399
lib/screens/inventory/stock_out_form.dart
Normal file
399
lib/screens/inventory/stock_out_form.dart
Normal file
@@ -0,0 +1,399 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../screens/equipment/controllers/equipment_history_controller.dart';
|
||||
import '../../data/models/equipment_history_dto.dart';
|
||||
|
||||
class StockOutForm extends StatefulWidget {
|
||||
const StockOutForm({super.key});
|
||||
|
||||
@override
|
||||
State<StockOutForm> createState() => _StockOutFormState();
|
||||
}
|
||||
|
||||
class _StockOutFormState extends State<StockOutForm> {
|
||||
final _formKey = GlobalKey<ShadFormState>();
|
||||
|
||||
int? _selectedEquipmentId;
|
||||
int? _selectedWarehouseId;
|
||||
int _quantity = 1;
|
||||
DateTime _transactionDate = DateTime.now();
|
||||
String? _notes;
|
||||
String? _destination;
|
||||
String? _recipientName;
|
||||
String? _recipientContact;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// 재고 현황 로드
|
||||
context.read<EquipmentHistoryController>().loadInventoryStatus();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit() async {
|
||||
if (_formKey.currentState?.saveAndValidate() ?? false) {
|
||||
final controller = context.read<EquipmentHistoryController>();
|
||||
|
||||
// 재고 부족 체크
|
||||
final currentStock = await controller.getAvailableStock(
|
||||
_selectedEquipmentId!,
|
||||
warehouseId: _selectedWarehouseId!,
|
||||
);
|
||||
|
||||
if (currentStock < _quantity) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast.destructive(
|
||||
title: const Text('재고 부족'),
|
||||
description: Text('현재 재고: $currentStock개, 요청 수량: $_quantity개'),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 백엔드 스키마에 맞는 요청 데이터 생성
|
||||
final request = EquipmentHistoryRequestDto(
|
||||
equipmentsId: _selectedEquipmentId!,
|
||||
warehousesId: _selectedWarehouseId!,
|
||||
transactionType: 'O', // 출고
|
||||
quantity: _quantity,
|
||||
transactedAt: _transactionDate,
|
||||
remark: _notes,
|
||||
);
|
||||
|
||||
await controller.createHistory(request);
|
||||
|
||||
if (controller.error == null && mounted) {
|
||||
ShadToaster.of(context).show(
|
||||
const ShadToast(
|
||||
title: Text('출고 처리 완료'),
|
||||
description: Text('장비가 성공적으로 출고되었습니다'),
|
||||
),
|
||||
);
|
||||
Navigator.pop(context, true);
|
||||
} else if (controller.error != null && mounted) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast.destructive(
|
||||
title: const Text('출고 처리 실패'),
|
||||
description: Text(controller.error!),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.colorScheme.card,
|
||||
title: const Text('장비 출고 처리'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Center(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
child: ShadCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ShadForm(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'출고 정보 입력',
|
||||
style: theme.textTheme.h3,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'출고할 장비와 수령 정보를 입력하세요',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 창고 선택
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('출고 창고', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||
const SizedBox(height: 8),
|
||||
ShadSelect<int>(
|
||||
placeholder: const Text('창고 선택'),
|
||||
options: [
|
||||
const ShadOption(value: 1, child: Text('본사 창고')),
|
||||
const ShadOption(value: 2, child: Text('지사 창고')),
|
||||
const ShadOption(value: 3, child: Text('외부 창고')),
|
||||
],
|
||||
selectedOptionBuilder: (context, value) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return const Text('본사 창고');
|
||||
case 2:
|
||||
return const Text('지사 창고');
|
||||
case 3:
|
||||
return const Text('외부 창고');
|
||||
default:
|
||||
return const Text('');
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedWarehouseId = value;
|
||||
_selectedEquipmentId = null; // 창고 변경 시 장비 선택 초기화
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 장비 선택 (창고별 재고가 있는 장비만 표시)
|
||||
if (_selectedWarehouseId != null)
|
||||
FutureBuilder<List<int>>(
|
||||
future: context.read<EquipmentHistoryController>().getAvailableEquipments(warehouseId: _selectedWarehouseId),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('장비', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Text('해당 창고에 재고가 있는 장비가 없습니다'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final availableEquipmentIds = snapshot.data!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('장비', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 8),
|
||||
ShadSelect<int>(
|
||||
placeholder: const Text('장비 선택'),
|
||||
options: availableEquipmentIds.map((equipmentId) {
|
||||
return ShadOption(
|
||||
value: equipmentId,
|
||||
child: FutureBuilder<int>(
|
||||
future: context.read<EquipmentHistoryController>().getAvailableStock(
|
||||
equipmentId,
|
||||
warehouseId: _selectedWarehouseId,
|
||||
),
|
||||
builder: (context, stockSnapshot) {
|
||||
final stock = stockSnapshot.data ?? 0;
|
||||
return Text('장비 ID: $equipmentId (재고: $stock개)');
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
return FutureBuilder<int>(
|
||||
future: context.read<EquipmentHistoryController>().getAvailableStock(
|
||||
value,
|
||||
warehouseId: _selectedWarehouseId,
|
||||
),
|
||||
builder: (context, stockSnapshot) {
|
||||
final stock = stockSnapshot.data ?? 0;
|
||||
return Text('장비 ID: $value (재고: $stock개)');
|
||||
},
|
||||
);
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedEquipmentId = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (_selectedEquipmentId != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: FutureBuilder<int>(
|
||||
future: context.read<EquipmentHistoryController>().getAvailableStock(
|
||||
_selectedEquipmentId!,
|
||||
warehouseId: _selectedWarehouseId,
|
||||
),
|
||||
builder: (context, stockSnapshot) {
|
||||
final stock = stockSnapshot.data ?? 0;
|
||||
return Text(
|
||||
'현재 재고: $stock개',
|
||||
style: theme.textTheme.small.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 수량
|
||||
ShadInputFormField(
|
||||
label: const Text('출고 수량'),
|
||||
keyboardType: TextInputType.number,
|
||||
controller: TextEditingController(text: '1'),
|
||||
validator: (v) {
|
||||
if (_quantity <= 0) {
|
||||
return '수량은 1 이상이어야 합니다';
|
||||
}
|
||||
// 재고 체크는 submit 시에만 async로 처리
|
||||
return null;
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_quantity = int.tryParse(value) ?? 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 출고일
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _transactionDate,
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
_transactionDate = picked;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
child: ShadInputFormField(
|
||||
label: const Text('출고일'),
|
||||
controller: TextEditingController(
|
||||
text: '${_transactionDate.year}-${_transactionDate.month.toString().padLeft(2, '0')}-${_transactionDate.day.toString().padLeft(2, '0')}',
|
||||
),
|
||||
readOnly: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 출고 목적지
|
||||
ShadInputFormField(
|
||||
label: const Text('출고 목적지'),
|
||||
placeholder: const Text('예: 고객사명, 부서명'),
|
||||
validator: (v) {
|
||||
if (_destination == null || _destination!.isEmpty) {
|
||||
return '출고 목적지를 입력하세요';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onChanged: (value) {
|
||||
_destination = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 수령인 정보
|
||||
ShadInputFormField(
|
||||
label: const Text('수령인'),
|
||||
placeholder: const Text('수령인 이름'),
|
||||
onChanged: (value) {
|
||||
_recipientName = value.isEmpty ? null : value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
ShadInputFormField(
|
||||
label: const Text('수령인 연락처'),
|
||||
placeholder: const Text('010-0000-0000'),
|
||||
onChanged: (value) {
|
||||
_recipientContact = value.isEmpty ? null : value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 비고
|
||||
ShadInputFormField(
|
||||
label: const Text('비고'),
|
||||
maxLines: 3,
|
||||
placeholder: const Text('출고 사유 및 추가 정보'),
|
||||
onChanged: (value) {
|
||||
String fullNotes = '';
|
||||
if (_destination != null) {
|
||||
fullNotes += '목적지: $_destination';
|
||||
}
|
||||
if (_recipientName != null) {
|
||||
fullNotes += '\n수령인: $_recipientName';
|
||||
}
|
||||
if (_recipientContact != null) {
|
||||
fullNotes += '\n연락처: $_recipientContact';
|
||||
}
|
||||
if (value.isNotEmpty) {
|
||||
fullNotes += '\n비고: $value';
|
||||
}
|
||||
_notes = fullNotes.isEmpty ? null : fullNotes;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 버튼
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ShadButton.outline(
|
||||
child: const Text('취소'),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Consumer<EquipmentHistoryController>(
|
||||
builder: (context, controller, _) {
|
||||
return ShadButton(
|
||||
enabled: !controller.isLoading,
|
||||
onPressed: _handleSubmit,
|
||||
child: controller.isLoading
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text('출고 처리'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user