@using TaxBaik.Application.Services
@ButtonText
취소
@code {
[Parameter, EditorRequired]
public string ButtonText { get; set; } = "저장";
[Parameter]
public EventCallback OnSubmit { get; set; }
[Parameter]
public EventCallback OnCancel { get; set; }
[Parameter]
public CompanyFormModel? InitialData { get; set; }
private MudForm? form;
private CompanyFormModel model = new();
protected override void OnInitialized()
{
if (InitialData != null)
{
model = new CompanyFormModel
{
CompanyCode = InitialData.CompanyCode,
CompanyName = InitialData.CompanyName,
ContactPerson = InitialData.ContactPerson,
Phone = InitialData.Phone,
Email = InitialData.Email,
Memo = InitialData.Memo,
IsActive = InitialData.IsActive
};
}
}
private async Task HandleSubmit()
{
if (form == null)
return;
await form.Validate();
if (!form.IsValid)
return;
await OnSubmit.InvokeAsync(model);
}
public class CompanyFormModel
{
public string CompanyCode { get; set; } = "";
public string CompanyName { get; set; } = "";
public string? ContactPerson { get; set; }
public string? Phone { get; set; }
public string? Email { get; set; }
public string? Memo { get; set; }
public bool IsActive { get; set; } = true;
}
}