결재 비활성 안내 개선 및 테이블 기능 보강
This commit is contained in:
@@ -837,6 +837,8 @@ class _InboundPageState extends State<InboundPage> {
|
||||
};
|
||||
|
||||
String? writerError;
|
||||
String? warehouseError;
|
||||
String? statusError;
|
||||
String? headerNotice;
|
||||
void Function(VoidCallback fn)? refreshForm;
|
||||
|
||||
@@ -847,10 +849,14 @@ class _InboundPageState extends State<InboundPage> {
|
||||
void handleSubmit() {
|
||||
final validationResult = _validateInboundForm(
|
||||
writerController: writerController,
|
||||
warehouseValue: warehouseController.text,
|
||||
statusValue: statusValue.value,
|
||||
drafts: drafts,
|
||||
lineErrors: lineErrors,
|
||||
);
|
||||
writerError = validationResult.writerError;
|
||||
warehouseError = validationResult.warehouseError;
|
||||
statusError = validationResult.statusError;
|
||||
headerNotice = validationResult.headerNotice;
|
||||
refreshForm?.call(() {});
|
||||
|
||||
@@ -871,6 +877,7 @@ class _InboundPageState extends State<InboundPage> {
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
items.sort((a, b) => a.product.compareTo(b.product));
|
||||
result = InboundRecord(
|
||||
number: initial?.number ?? _generateInboundNumber(processedAt.value),
|
||||
transactionNumber:
|
||||
@@ -936,6 +943,7 @@ class _InboundPageState extends State<InboundPage> {
|
||||
child: SuperportFormField(
|
||||
label: '창고',
|
||||
required: true,
|
||||
errorText: warehouseError,
|
||||
child: ShadSelect<String>(
|
||||
initialValue: warehouseController.text,
|
||||
selectedOptionBuilder: (context, value) =>
|
||||
@@ -943,7 +951,11 @@ class _InboundPageState extends State<InboundPage> {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
warehouseController.text = value;
|
||||
setState(() {});
|
||||
setState(() {
|
||||
if (warehouseError != null) {
|
||||
warehouseError = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
options: _warehouseOptions
|
||||
@@ -962,6 +974,7 @@ class _InboundPageState extends State<InboundPage> {
|
||||
child: SuperportFormField(
|
||||
label: '상태',
|
||||
required: true,
|
||||
errorText: statusError,
|
||||
child: ShadSelect<String>(
|
||||
initialValue: statusValue.value,
|
||||
selectedOptionBuilder: (context, value) =>
|
||||
@@ -969,7 +982,11 @@ class _InboundPageState extends State<InboundPage> {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
statusValue.value = value;
|
||||
setState(() {});
|
||||
setState(() {
|
||||
if (statusError != null) {
|
||||
statusError = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
enabled: initial?.status != '승인완료',
|
||||
@@ -1525,11 +1542,15 @@ class _LineItemFieldErrors {
|
||||
|
||||
_InboundFormValidation _validateInboundForm({
|
||||
required TextEditingController writerController,
|
||||
required String warehouseValue,
|
||||
required String statusValue,
|
||||
required List<_LineItemDraft> drafts,
|
||||
required Map<_LineItemDraft, _LineItemFieldErrors> lineErrors,
|
||||
}) {
|
||||
var isValid = true;
|
||||
String? writerError;
|
||||
String? warehouseError;
|
||||
String? statusError;
|
||||
String? headerNotice;
|
||||
|
||||
if (writerController.text.trim().isEmpty) {
|
||||
@@ -1537,12 +1558,24 @@ _InboundFormValidation _validateInboundForm({
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (warehouseValue.trim().isEmpty) {
|
||||
warehouseError = '창고를 선택하세요.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (statusValue.trim().isEmpty) {
|
||||
statusError = '상태를 선택하세요.';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
var hasLineError = false;
|
||||
final seenProductKeys = <String>{};
|
||||
for (final draft in drafts) {
|
||||
final errors = lineErrors.putIfAbsent(draft, _LineItemFieldErrors.empty);
|
||||
errors.clearAll();
|
||||
|
||||
if (draft.product.text.trim().isEmpty) {
|
||||
final productText = draft.product.text.trim();
|
||||
if (productText.isEmpty) {
|
||||
errors.product = '제품을 입력하세요.';
|
||||
hasLineError = true;
|
||||
isValid = false;
|
||||
@@ -1552,8 +1585,15 @@ _InboundFormValidation _validateInboundForm({
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
final productKey = (draft.catalogMatch?.code ?? productText.toLowerCase());
|
||||
if (productKey.isNotEmpty && !seenProductKeys.add(productKey)) {
|
||||
errors.product = '동일 제품이 중복되었습니다.';
|
||||
hasLineError = true;
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
final quantity = int.tryParse(
|
||||
draft.quantity.text.trim() == '' ? '0' : draft.quantity.text.trim(),
|
||||
draft.quantity.text.trim().isEmpty ? '0' : draft.quantity.text.trim(),
|
||||
);
|
||||
if (quantity == null || quantity < 1) {
|
||||
errors.quantity = '수량은 1 이상 정수여야 합니다.';
|
||||
@@ -1576,6 +1616,8 @@ _InboundFormValidation _validateInboundForm({
|
||||
return _InboundFormValidation(
|
||||
isValid: isValid,
|
||||
writerError: writerError,
|
||||
warehouseError: warehouseError,
|
||||
statusError: statusError,
|
||||
headerNotice: headerNotice,
|
||||
);
|
||||
}
|
||||
@@ -1589,11 +1631,15 @@ class _InboundFormValidation {
|
||||
const _InboundFormValidation({
|
||||
required this.isValid,
|
||||
this.writerError,
|
||||
this.warehouseError,
|
||||
this.statusError,
|
||||
this.headerNotice,
|
||||
});
|
||||
|
||||
final bool isValid;
|
||||
final String? writerError;
|
||||
final String? warehouseError;
|
||||
final String? statusError;
|
||||
final String? headerNotice;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user