add version 0.17.19.26
parent
7f267a882c
commit
d19937dd5c
|
@ -1,13 +1,15 @@
|
||||||
@inject ISnackbar Snackbar
|
|
||||||
|
@inject ISnackbar Snackbar
|
||||||
@inject IRestWrapper RestWrapper
|
@inject IRestWrapper RestWrapper
|
||||||
@inject IUserUtility UserUtility
|
@inject IUserUtility UserUtility
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
|
@inject IPrintingService PrintingService
|
||||||
|
|
||||||
<MudDialog class="mx-auto" DisableSidePadding="true">
|
<MudDialog class="mx-auto" DisableSidePadding="true">
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<MudContainer class="max-h-[40rem] mt-4" Style="overflow-y: scroll">
|
<MudContainer class="max-h-[40rem] mt-4" Style="overflow-y: scroll">
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
<MudItem md="9">
|
<MudItem xs="12" md="9">
|
||||||
<MudStack>
|
<MudStack>
|
||||||
|
|
||||||
<MudStack Row="true">
|
<MudStack Row="true">
|
||||||
|
@ -20,23 +22,23 @@
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
<MudItem sm="4">
|
<MudItem xs="12" sm="4">
|
||||||
<MudField Variant="Variant.Outlined" Label="نام و نام خانوادگی">@ViewModel.PageDto.UserFullName</MudField>
|
<MudField Variant="Variant.Outlined" Label="نام و نام خانوادگی">@ViewModel.PageDto.UserFullName</MudField>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
<MudItem sm="4">
|
<MudItem xs="12" sm="4">
|
||||||
<MudField Variant="Variant.Outlined" Label="شماره تماس">@ViewModel.PageDto.UserPhoneNumber</MudField>
|
<MudField Variant="Variant.Outlined" Label="شماره تماس">@ViewModel.PageDto.UserPhoneNumber</MudField>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
<MudItem sm="4">
|
<MudItem xs="12" sm="4">
|
||||||
<MudField Variant="Variant.Outlined" Label="کد تخفیف">@ViewModel.PageDto.DiscountCode</MudField>
|
<MudField Variant="Variant.Outlined" Label="کد تخفیف">@ViewModel.PageDto.DiscountCode</MudField>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
|
|
||||||
<MudItem sm="9">
|
<MudItem xs="12" sm="8">
|
||||||
<MudField Variant="Variant.Outlined" Label="آدرس">@ViewModel.PageDto?.OrderDelivery?.Address</MudField>
|
<MudField Variant="Variant.Outlined" Label="آدرس">@ViewModel.PageDto?.OrderDelivery?.Address</MudField>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem sm="3">
|
<MudItem xs="12" sm="4">
|
||||||
<MudField Variant="Variant.Outlined" Label="روش ارسال" >@ViewModel.PageDto?.OrderDelivery?.ShippingMethod</MudField>
|
<MudField Variant="Variant.Outlined" Label="روش ارسال" >@ViewModel.PageDto?.OrderDelivery?.ShippingMethod</MudField>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
|
@ -86,7 +88,7 @@
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
<MudItem md="3">
|
<MudItem xs="12" md="3">
|
||||||
|
|
||||||
<MudText Typo="Typo.h6" class="mb-2"><b>مبــــالغ</b></MudText>
|
<MudText Typo="Typo.h6" class="mb-2"><b>مبــــالغ</b></MudText>
|
||||||
<MudPaper class="bg-[--mud-palette-background-grey] rounded-md">
|
<MudPaper class="bg-[--mud-palette-background-grey] rounded-md">
|
||||||
|
@ -191,6 +193,7 @@
|
||||||
Icon="@Icons.Material.Outlined.Print"
|
Icon="@Icons.Material.Outlined.Print"
|
||||||
Size="Size.Small"
|
Size="Size.Small"
|
||||||
Variant="Variant.Outlined" Color="Color.Info"
|
Variant="Variant.Outlined" Color="Color.Info"
|
||||||
|
OnClickCallback="@(()=> PrintingService.Print("http://localhost:32770/api/order/efc18848-fde5-4687-a9f3-0df6aff8b8ed/invoice?access_token=eyJ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-ZxYQM-RptsRlxLhVeA9024u5tS2hY1QazxE9di8HAsebPZeVDnJ4gGuw",true))"
|
||||||
Content="چاپــ فاکتور" />
|
Content="چاپــ فاکتور" />
|
||||||
<MudButton Variant="Variant.Outlined" Size="Size.Medium" Color="Color.Error" OnClick="ViewModel.Cancel">بستن</MudButton>
|
<MudButton Variant="Variant.Outlined" Size="Size.Medium" Color="Color.Error" OnClick="ViewModel.Cancel">بستن</MudButton>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
@ -210,9 +213,9 @@
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (Order == null)
|
if (Order == null)
|
||||||
ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog);
|
ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog , PrintingService);
|
||||||
else
|
else
|
||||||
ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, Order);
|
ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, Order, PrintingService);
|
||||||
await ViewModel.InitializeAsync();
|
await ViewModel.InitializeAsync();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace NetinaShop.AdminPanel.PWA.Dialogs;
|
using Append.Blazor.Printing;
|
||||||
|
|
||||||
|
namespace NetinaShop.AdminPanel.PWA.Dialogs;
|
||||||
|
|
||||||
public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
{
|
{
|
||||||
|
@ -8,21 +10,26 @@ public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
private readonly IUserUtility _userUtility;
|
private readonly IUserUtility _userUtility;
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
private readonly MudDialogInstance _mudDialog;
|
private readonly MudDialogInstance _mudDialog;
|
||||||
|
private readonly IPrintingService _printingService;
|
||||||
|
|
||||||
public OrderActionDialogBoxViewModel(ISnackbar snackbar, IRestWrapper restWrapper, IUserUtility userUtility, IDialogService dialogService, MudDialogInstance mudDialog)
|
public OrderActionDialogBoxViewModel(ISnackbar snackbar, IRestWrapper restWrapper, IUserUtility userUtility, IDialogService dialogService,
|
||||||
|
MudDialogInstance mudDialog,
|
||||||
|
IPrintingService printingService)
|
||||||
{
|
{
|
||||||
_snackbar = snackbar;
|
_snackbar = snackbar;
|
||||||
_restWrapper = restWrapper;
|
_restWrapper = restWrapper;
|
||||||
_userUtility = userUtility;
|
_userUtility = userUtility;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
_mudDialog = mudDialog;
|
_mudDialog = mudDialog;
|
||||||
|
_printingService = printingService;
|
||||||
}
|
}
|
||||||
public OrderActionDialogBoxViewModel(ISnackbar snackbar,
|
public OrderActionDialogBoxViewModel(ISnackbar snackbar,
|
||||||
IRestWrapper restWrapper,
|
IRestWrapper restWrapper,
|
||||||
IUserUtility userUtility,
|
IUserUtility userUtility,
|
||||||
IDialogService dialogService,
|
IDialogService dialogService,
|
||||||
MudDialogInstance mudDialog,
|
MudDialogInstance mudDialog,
|
||||||
OrderSDto order)
|
OrderSDto order,
|
||||||
|
IPrintingService printingService)
|
||||||
{
|
{
|
||||||
_snackbar = snackbar;
|
_snackbar = snackbar;
|
||||||
_restWrapper = restWrapper;
|
_restWrapper = restWrapper;
|
||||||
|
@ -31,6 +38,7 @@ public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
_mudDialog = mudDialog;
|
_mudDialog = mudDialog;
|
||||||
PageDto.Id = order.Id;
|
PageDto.Id = order.Id;
|
||||||
IsEditing = true;
|
IsEditing = true;
|
||||||
|
_printingService = printingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +66,9 @@ public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
PageDto = order;
|
PageDto = order;
|
||||||
switch (PageDto.OrderStatus)
|
switch (PageDto.OrderStatus)
|
||||||
{
|
{
|
||||||
|
case OrderStatus.OrderBag:
|
||||||
|
ConfirmOrderButtonText = "ثبت پرداختی سفارش";
|
||||||
|
break;
|
||||||
case OrderStatus.Submitted:
|
case OrderStatus.Submitted:
|
||||||
ConfirmOrderButtonText = "ثبت پرداختی سفارش";
|
ConfirmOrderButtonText = "ثبت پرداختی سفارش";
|
||||||
break;
|
break;
|
||||||
|
@ -78,12 +89,10 @@ public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
{
|
{
|
||||||
var exe = await ex.GetContentAsAsync<ApiResult>();
|
var exe = await ex.GetContentAsAsync<ApiResult>();
|
||||||
_snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
|
_snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
|
||||||
_mudDialog.Cancel();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_snackbar.Add(e.Message, Severity.Error);
|
_snackbar.Add(e.Message, Severity.Error);
|
||||||
_mudDialog.Cancel();
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -93,6 +102,38 @@ public class OrderActionDialogBoxViewModel : BaseViewModel<OrderLDto>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task PrintInvoiceAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var token = await _userUtility.GetBearerTokenAsync();
|
||||||
|
if (token == null)
|
||||||
|
throw new Exception("Token is null");
|
||||||
|
IsProcessing = true;
|
||||||
|
string fileUrl = $"{Address.OrderController}/{PageDto.Id}/invoice?access_token={token.Split("Bearer").Last().Trim()}";
|
||||||
|
|
||||||
|
var content = await _restWrapper.OrderRestApi.GetOrderInvoice(PageDto.Id, token);
|
||||||
|
var bytes = await content.ReadAsByteArrayAsync();
|
||||||
|
var base64 = Convert.ToBase64String(bytes);
|
||||||
|
await _printingService.Print(fileUrl, showModal: true);
|
||||||
|
Console.WriteLine(fileUrl);
|
||||||
|
}
|
||||||
|
catch (ApiException ex)
|
||||||
|
{
|
||||||
|
var exe = await ex.GetContentAsAsync<ApiResult>();
|
||||||
|
_snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_snackbar.Add(e.Message, Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
|
||||||
|
IsProcessing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task SubmitConfirmAsync()
|
public async Task SubmitConfirmAsync()
|
||||||
{
|
{
|
||||||
var options = new DialogOptions { CloseOnEscapeKey = true };
|
var options = new DialogOptions { CloseOnEscapeKey = true };
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Append.Blazor.Printing" Version="6.3.0" />
|
||||||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||||
<PackageReference Include="Blazorise.LottieAnimation" Version="1.4.0" />
|
<PackageReference Include="Blazorise.LottieAnimation" Version="1.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.1" />
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Append.Blazor.Printing;
|
||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
|
@ -35,5 +36,6 @@ builder.Services.AddBlazoredLocalStorage();
|
||||||
builder.Services.AddScoped<Radzen.ContextMenuService>();
|
builder.Services.AddScoped<Radzen.ContextMenuService>();
|
||||||
builder.Services.AddScoped<Radzen.DialogService>();
|
builder.Services.AddScoped<Radzen.DialogService>();
|
||||||
builder.Services.AddSingleton<IEncryptProvider, AesJsProvider>();
|
builder.Services.AddSingleton<IEncryptProvider, AesJsProvider>();
|
||||||
|
builder.Services.AddScoped<IPrintingService, PrintingService>();
|
||||||
builder.Services.AddPWAUpdater();
|
builder.Services.AddPWAUpdater();
|
||||||
await builder.Build().RunAsync();
|
await builder.Build().RunAsync();
|
||||||
|
|
|
@ -10,4 +10,7 @@ public interface IOrderRestApi
|
||||||
|
|
||||||
[Post("/{id}/confirm")]
|
[Post("/{id}/confirm")]
|
||||||
Task<bool> ConfirmOrderStepAsync(Guid id,[Query] OrderStatus nextOrderStatus , [Header("Authorization")] string authorization);
|
Task<bool> ConfirmOrderStepAsync(Guid id,[Query] OrderStatus nextOrderStatus , [Header("Authorization")] string authorization);
|
||||||
|
|
||||||
|
[Get("/{id}/invoice")]
|
||||||
|
Task<HttpContent> GetOrderInvoice(Guid id, [Header("Authorization")] string authorization);
|
||||||
}
|
}
|
|
@ -24,3 +24,4 @@
|
||||||
@using Blazorise.Extensions
|
@using Blazorise.Extensions
|
||||||
@using NetinaShop.AdminPanel.PWA.Utilities
|
@using NetinaShop.AdminPanel.PWA.Utilities
|
||||||
@using Microsoft.AspNetCore.Components.Authorization
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
|
@using Append.Blazor.Printing
|
||||||
|
|
Loading…
Reference in New Issue