...
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
@using Shared.DTOs
|
||||
@inject HttpClientController hc;
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
@@ -11,24 +13,103 @@
|
||||
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">وضغیت</label>
|
||||
<InputText @value="order.StatusTitle" type="text" class="form-control" id="StatusTitle" placeholder="وضغیت" />
|
||||
<input style="text-align: center;" value="@order.StatusTitle" type="text" class="form-control" id="StatusTitle" placeholder="وضغیت" readonly />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">تاریخ ایحاد</label>
|
||||
<InputText @bind-Value="order.DateCreate" type="text" class="form-control" id="DateCreate" placeholder="تاریخ ایجاد" />
|
||||
<InputText style="text-align: center;" @bind-Value="order.DateCreate" type="text" class="form-control" id="DateCreate" placeholder="تاریخ ایجاد" readonly />
|
||||
</div>
|
||||
@if (order.Status!=StatusOrder.Create)
|
||||
@if (order.Status != StatusOrder.Create)
|
||||
{
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">@titledateapp</label>
|
||||
<InputText @bind-Value="order.ApprovalDate" type="text" class="form-control" id="ApprovalDate" placeholder="@titledateapp" />
|
||||
<InputText style="text-align: center;" @bind-Value="order.ApprovalDate" type="text" class="form-control" id="ApprovalDate" placeholder="@titledateapp" readonly />
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<hr class="hr" />
|
||||
<div class="row g-3">
|
||||
<Grid @ref="grid" TItem="OrderItemDto"
|
||||
AllowRowClick="true"
|
||||
AllowSorting="true"
|
||||
Class="table table-hover"
|
||||
DataProvider="DataProvider"
|
||||
AllowPaging="true"
|
||||
PageSize="10"
|
||||
Responsive="true">
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="عنوان">
|
||||
@context.Title
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="نوع">
|
||||
@context.Type
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="تعداد">
|
||||
@context.CreditAmount
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="قیمت واحد">
|
||||
@context.APrice.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="تخفیف">
|
||||
@context.Discount.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="مالیات">
|
||||
@context.Tax.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="مبلغ کل">
|
||||
@context.Total.ToString("N0")
|
||||
</GridColumn>
|
||||
</Grid>
|
||||
|
||||
</div>
|
||||
<hr class="hr" />
|
||||
<div class="row g-3">
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مبلغ سفارش</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.PreDiscount" Locale="fa-Ir" Placeholder="مبلغ سفارش" readonly />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">تخفیف سفارش</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TDiscount" Locale="fa-Ir" Placeholder="تخفیف سفارش" readonly />
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مالیات</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TTax" Locale="fa-Ir" Placeholder="مالیات" readonly />
|
||||
</div>
|
||||
|
||||
@* <div class="col-md-4">
|
||||
<label class="col-sm-5 col-form-label">بغد از تخفیف</label>
|
||||
<CurrencyInput TValue="decimal" @bind-Value="order.lstDiscount" Locale="fa-Ir" Placeholder="بغد از تخفیف" readonly />
|
||||
</div> *@
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مبلغ نهایی</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TTax" Locale="fa-Ir" Placeholder="مبلغ نهایی" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<br />
|
||||
@if (order.Status == StatusOrder.Create)
|
||||
{
|
||||
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickPay" Type="ButtonType.Button">
|
||||
پرداخت
|
||||
</Button>
|
||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickCancel" Type="ButtonType.Button">
|
||||
ابطال
|
||||
</Button>
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
#region Alert
|
||||
@@ -38,7 +119,9 @@
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
#endregion
|
||||
|
||||
private ConfirmDialog dialog = default!;
|
||||
public ActionInResultComponent result { get; set; }
|
||||
Grid<OrderItemDto> grid = default!;
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||
[Parameter] public OrderDto order { get; set; }
|
||||
@@ -46,7 +129,7 @@
|
||||
string titledateapp = "تاریخ";
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (order.Status==StatusOrder.Cancel)
|
||||
if (order.Status == StatusOrder.Cancel)
|
||||
{
|
||||
titledateapp += " ابطال";
|
||||
}
|
||||
@@ -57,7 +140,13 @@
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
@functions {
|
||||
private async Task<GridDataProviderResult<OrderItemDto>> DataProvider(GridDataProviderRequest<OrderItemDto> request)
|
||||
{
|
||||
OrderItems = await LoadOrderItem(); // call a service or an API to pull the employees
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(OrderItems));
|
||||
}
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
@@ -72,14 +161,62 @@
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private async Task LoadOrderItem(){
|
||||
private async Task<List<OrderItemDto>> LoadOrderItem()
|
||||
{
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Orderss/GetOrderDetails/{order.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
OrderItems = await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
|
||||
else
|
||||
ShowDangerAlert("خطایی در بارگیری");
|
||||
var rsp = await hc.Get($"Orders/GetOrderDetails/{order.ID}");
|
||||
PreloadService.Hide();
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
return await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در بارگیری");
|
||||
return new List<OrderItemDto>();
|
||||
}
|
||||
|
||||
}
|
||||
private async Task OnClickPay()
|
||||
{
|
||||
// result.Status = ComponentStatus.success;
|
||||
// result.Action = ComponentAction.add;
|
||||
// await OnMultipleOfThree.InvokeAsync(result);
|
||||
|
||||
|
||||
}
|
||||
private async Task OnClickCancel()
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "عملیات ابطال سفارش",
|
||||
message1: $"از ابطال سفارش {order.ID}",
|
||||
message2: "اطمینان دارید?");
|
||||
|
||||
if (confirmation)
|
||||
{
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Orders/CancelOrder/{order.ID}");
|
||||
PreloadService.Hide();
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
if(await rsp.Content.ReadFromJsonAsync<bool>())
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else
|
||||
ShowDangerAlert("خطای سیستمی");
|
||||
}
|
||||
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
|
||||
ShowDangerAlert("سفارش یافت نشد");
|
||||
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -148,7 +148,7 @@
|
||||
itemsearch.PageSize = 10;
|
||||
itemsearch.PageIndex = pi;
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Post<ItemSerachOrder>("Orderss/GetAllOrder",itemsearch);
|
||||
var rsp = await hc.Post<ItemSerachOrder>("Orders/GetAllOrder",itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
request = await rsp.Content.ReadFromJsonAsync<Shared.DTOs.PagingDto<OrderDto>?>();
|
||||
else
|
||||
@@ -171,20 +171,15 @@
|
||||
alertMessage = msg;
|
||||
}
|
||||
|
||||
public async Task CallBackItem(ActionInResultComponent result)
|
||||
public async Task CallBackFromReadItem(ActionInResultComponent result)
|
||||
{
|
||||
|
||||
if (result.Action == ComponentAction.add)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("سفارش جدید با موفقیت اضافه شد");
|
||||
ShowSuccessAlert("سفارش پرداخت شد");
|
||||
|
||||
}
|
||||
else if (result.Action == ComponentAction.update)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("اطلاعات سفارش با موفقیت ویرایش شد");
|
||||
}
|
||||
else if (result.Action == ComponentAction.delete)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
@@ -200,10 +195,10 @@
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
||||
var item = request.list.Where(w => w.ID == ID).First().Clone();
|
||||
var item = request?.list.Where(w => w.ID == ID).First().Clone();
|
||||
parameters.Add("order", item);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackItem));
|
||||
await modal.ShowAsync<CodItem>(title:$"سفارش {ID}", parameters: parameters);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackFromReadItem));
|
||||
await modal.ShowAsync<OrderItemRead>(title:$"سفارش {ID}", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
|
||||
|
||||
//Home
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||
|
||||
//farzan
|
||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||
|
||||
|
Reference in New Issue
Block a user