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