106 lines
5.9 KiB
Plaintext
106 lines
5.9 KiB
Plaintext
@using Indotalent.ConfigBackEnd.Extensions
|
|
@using Indotalent.Features.Purchase.PurchaseRequisition
|
|
@using Indotalent.Features.Purchase.PurchaseRequisition.Cqrs
|
|
@using MudBlazor
|
|
@using Indotalent.Features.Root.Shared
|
|
@inject PurchaseRequisitionService PurchaseRequisitionService
|
|
@inject IDialogService DialogService
|
|
@inject ISnackbar Snackbar
|
|
|
|
<MudPaper Elevation="0" Outlined="true" Style="border-radius: 12px; border: 1px solid #E5E7EB;">
|
|
<div style="padding: 20px 24px; border-bottom: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: center; background-color: #ffffff;">
|
|
<MudText Typo="Typo.button" Color="Color.Default" Style="font-weight: 600; color: #111827;">Items</MudText>
|
|
@if (!ReadOnly)
|
|
{
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" OnClick="OnAddClick" Size="Size.Small" Style="text-transform: none; font-weight: 500; border-radius: 6px;">
|
|
Add Item
|
|
</MudButton>
|
|
}
|
|
</div>
|
|
|
|
<MudTable Items="Items" Striped="true" Class="mud-table-styled" Hover="true" Elevation="0" Dense="true" T="PurchaseRequisitionItemResponse">
|
|
<HeaderContent>
|
|
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Product</MudTh>
|
|
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB; text-align: right;">UnitPrice</MudTh>
|
|
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB; text-align: right;">Quantity</MudTh>
|
|
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB; text-align: right;">Total</MudTh>
|
|
@if (!ReadOnly)
|
|
{
|
|
<MudTh Style="width: 100px; text-align: right; font-weight: 600; color: #6B7280;">Actions</MudTh>
|
|
}
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd DataLabel="Product">@context.ProductName</MudTd>
|
|
<MudTd DataLabel="UnitPrice" Style="text-align: right;">@context.UnitPrice?.ToString("N2")</MudTd>
|
|
<MudTd DataLabel="Quantity" Style="text-align: right;">@context.Quantity</MudTd>
|
|
<MudTd DataLabel="Total" Style="text-align: right; font-weight: 700;">@context.Total?.ToString("N2")</MudTd>
|
|
@if (!ReadOnly)
|
|
{
|
|
<MudTd Style="text-align: right;">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" Color="Color.Primary" OnClick="@(() => OnEditClick(context))" />
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" OnClick="@(() => OnDeleteClick(context))" />
|
|
</MudTd>
|
|
}
|
|
</RowTemplate>
|
|
</MudTable>
|
|
</MudPaper>
|
|
|
|
<script>
|
|
function downloadFile(fileName, contentType, base64String) {
|
|
const link = document.createElement('a');
|
|
link.download = fileName;
|
|
link.href = `data:${contentType};base64,${base64String}`;
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
}
|
|
</script>
|
|
|
|
|
|
<style>
|
|
.mud-table-styled .mud-table-row:hover { background-color: #F9FAFB !important; }
|
|
.mud-input-outlined-border { border-radius: 8px !important; }
|
|
.custom-select-dense .mud-input-control { margin-top: 0 !important; }
|
|
.custom-select-dense .mud-input-slot { padding-top: 4px !important; padding-bottom: 4px !important; padding-left: 8px !important; font-size: 12px !important; }
|
|
</style>
|
|
|
|
@code {
|
|
[Parameter] public string PurchaseRequisitionId { get; set; } = string.Empty;
|
|
[Parameter] public List<PurchaseRequisitionItemResponse> Items { get; set; } = new();
|
|
[Parameter] public bool ReadOnly { get; set; } = false;
|
|
[Parameter] public EventCallback OnChanged { get; set; }
|
|
|
|
private async Task OnAddClick()
|
|
{
|
|
var parameters = new DialogParameters { ["PurchaseRequisitionId"] = PurchaseRequisitionId };
|
|
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true };
|
|
var dialog = await DialogService.ShowAsync<_PurchaseRequisitionItemCreateForm>("Add Item", parameters, options);
|
|
var result = await dialog.Result;
|
|
if (result != null && !result.Canceled) await OnChanged.InvokeAsync();
|
|
}
|
|
|
|
private async Task OnEditClick(PurchaseRequisitionItemResponse item)
|
|
{
|
|
var parameters = new DialogParameters { ["Data"] = item };
|
|
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true };
|
|
var dialog = await DialogService.ShowAsync<_PurchaseRequisitionItemUpdateForm>("Edit Item", parameters, options);
|
|
var result = await dialog.Result;
|
|
if (result != null && !result.Canceled) await OnChanged.InvokeAsync();
|
|
}
|
|
|
|
private async Task OnDeleteClick(PurchaseRequisitionItemResponse item)
|
|
{
|
|
var parameters = new DialogParameters { ["ContentText"] = $"Are you sure you want to remove this item?" };
|
|
var dialog = await DialogService.ShowAsync<_DeleteConfirmation>("Delete Confirmation", parameters, new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true });
|
|
var result = await dialog.Result;
|
|
if (result != null && !result.Canceled)
|
|
{
|
|
var success = await PurchaseRequisitionService.DeletePurchaseRequisitionItemAsync(item.Id!);
|
|
if (success)
|
|
{
|
|
Snackbar.Add("Removed successfully", Severity.Success);
|
|
await OnChanged.InvokeAsync();
|
|
}
|
|
}
|
|
}
|
|
} |