번호 자동 부여 대응 및 API 공통 처리 보강
This commit is contained in:
@@ -135,7 +135,7 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
final currentPage = result?.page ?? 1;
|
||||
final totalPages = result == null || result.pageSize == 0
|
||||
? 1
|
||||
: (result.total / result.pageSize).ceil().clamp(1, 9999) as int;
|
||||
: (result.total / result.pageSize).ceil().clamp(1, 9999);
|
||||
final hasNext = result == null
|
||||
? false
|
||||
: (result.page * result.pageSize) < result.total;
|
||||
@@ -378,14 +378,13 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
|
||||
/// 신규 결재 등록 다이얼로그를 열어 UI 단계에서 필요한 필드와 안내를 제공한다.
|
||||
Future<void> _openCreateApprovalDialog() async {
|
||||
final approvalNoController = TextEditingController();
|
||||
final transactionController = TextEditingController();
|
||||
final requesterController = TextEditingController();
|
||||
final noteController = TextEditingController();
|
||||
String? createdApprovalNo;
|
||||
InventoryEmployeeSuggestion? requesterSelection;
|
||||
int? statusId = _controller.defaultApprovalStatusId;
|
||||
String? transactionError;
|
||||
String? approvalNoError;
|
||||
String? statusError;
|
||||
String? requesterError;
|
||||
|
||||
@@ -422,8 +421,6 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
onPressed: isSubmitting
|
||||
? null
|
||||
: () async {
|
||||
final approvalNo = approvalNoController.text
|
||||
.trim();
|
||||
final transactionText = transactionController.text
|
||||
.trim();
|
||||
final transactionId = int.tryParse(
|
||||
@@ -433,9 +430,6 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
final hasStatuses = statusOptions.isNotEmpty;
|
||||
|
||||
setState(() {
|
||||
approvalNoError = approvalNo.isEmpty
|
||||
? '결재번호를 입력하세요.'
|
||||
: null;
|
||||
transactionError = transactionText.isEmpty
|
||||
? '트랜잭션 ID를 입력하세요.'
|
||||
: (transactionId == null
|
||||
@@ -449,8 +443,7 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
: null;
|
||||
});
|
||||
|
||||
if (approvalNoError != null ||
|
||||
transactionError != null ||
|
||||
if (transactionError != null ||
|
||||
statusError != null ||
|
||||
requesterError != null) {
|
||||
return;
|
||||
@@ -458,7 +451,6 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
|
||||
final input = ApprovalCreateInput(
|
||||
transactionId: transactionId!,
|
||||
approvalNo: approvalNo,
|
||||
approvalStatusId: statusId!,
|
||||
requestedById: requesterSelection!.id,
|
||||
note: note.isEmpty ? null : note,
|
||||
@@ -470,6 +462,7 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
return;
|
||||
}
|
||||
if (result != null) {
|
||||
createdApprovalNo = result.approvalNo;
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
@@ -489,28 +482,18 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('결재번호', style: shadTheme.textTheme.small),
|
||||
const SizedBox(height: 8),
|
||||
ShadInput(
|
||||
controller: approvalNoController,
|
||||
enabled: !isSubmitting,
|
||||
placeholder: const Text('예: APP-2025-0001'),
|
||||
onChanged: (_) {
|
||||
if (approvalNoError != null) {
|
||||
setState(() => approvalNoError = null);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (approvalNoError != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
approvalNoError!,
|
||||
style: shadTheme.textTheme.small.copyWith(
|
||||
color: materialTheme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: shadTheme.colorScheme.mutedForeground
|
||||
.withValues(alpha: 0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'결재번호는 저장 시 자동으로 생성됩니다.',
|
||||
style: shadTheme.textTheme.muted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('트랜잭션 ID', style: shadTheme.textTheme.small),
|
||||
const SizedBox(height: 8),
|
||||
@@ -689,13 +672,16 @@ class _ApprovalEnabledPageState extends State<_ApprovalEnabledPage> {
|
||||
},
|
||||
);
|
||||
|
||||
approvalNoController.dispose();
|
||||
transactionController.dispose();
|
||||
requesterController.dispose();
|
||||
noteController.dispose();
|
||||
|
||||
if (created == true && mounted) {
|
||||
SuperportToast.success(context, '결재를 생성했습니다.');
|
||||
final number = createdApprovalNo ?? '-';
|
||||
SuperportToast.success(
|
||||
context,
|
||||
'결재를 생성했습니다. ($number)',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user