결재 단계 편집 다이얼로그 구현
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/// 결재 단계 생성/수정 입력 모델
|
||||
///
|
||||
/// - 단계 순서, 승인자, 비고 등의 값을 API 페이로드로 직렬화한다.
|
||||
/// - `approvalId`는 생성 시에만 필요하며 수정 시에는 null로 둘 수 있다.
|
||||
class ApprovalStepInput {
|
||||
ApprovalStepInput({
|
||||
this.approvalId,
|
||||
required this.stepOrder,
|
||||
required this.approverId,
|
||||
this.statusId,
|
||||
this.assignedAt,
|
||||
this.decidedAt,
|
||||
this.note,
|
||||
}) : assert(stepOrder > 0, '단계 순서는 1 이상의 정수여야 합니다.'),
|
||||
assert(approverId > 0, '승인자 ID는 양수여야 합니다.');
|
||||
|
||||
final int? approvalId;
|
||||
final int stepOrder;
|
||||
final int approverId;
|
||||
final int? statusId;
|
||||
final DateTime? assignedAt;
|
||||
final DateTime? decidedAt;
|
||||
final String? note;
|
||||
|
||||
/// API 요청 페이로드를 구성한다.
|
||||
Map<String, dynamic> toPayload() {
|
||||
final payload = <String, dynamic>{
|
||||
'step_order': stepOrder,
|
||||
'approver_id': approverId,
|
||||
if (statusId != null) 'status_id': statusId,
|
||||
if (assignedAt != null)
|
||||
'assigned_at': assignedAt!.toUtc().toIso8601String(),
|
||||
if (decidedAt != null) 'decided_at': decidedAt!.toUtc().toIso8601String(),
|
||||
if (note != null && note!.trim().isNotEmpty) 'note': note,
|
||||
};
|
||||
if (approvalId != null) {
|
||||
payload['approval_id'] = approvalId;
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
ApprovalStepInput copyWith({
|
||||
int? approvalId,
|
||||
int? stepOrder,
|
||||
int? approverId,
|
||||
int? statusId,
|
||||
DateTime? assignedAt,
|
||||
DateTime? decidedAt,
|
||||
String? note,
|
||||
}) {
|
||||
return ApprovalStepInput(
|
||||
approvalId: approvalId ?? this.approvalId,
|
||||
stepOrder: stepOrder ?? this.stepOrder,
|
||||
approverId: approverId ?? this.approverId,
|
||||
statusId: statusId ?? this.statusId,
|
||||
assignedAt: assignedAt ?? this.assignedAt,
|
||||
decidedAt: decidedAt ?? this.decidedAt,
|
||||
note: note ?? this.note,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user