This commit is contained in:
mmrbnjd
2024-06-09 17:23:57 +03:30
parent 11663c6e82
commit 82bcfc1ffe
11 changed files with 780 additions and 104 deletions

View File

@@ -2,7 +2,166 @@
@inject HttpClientController hc;
@layout PanelLayout
@page "/TaxPayer"
@page "/TaxPayer/{routed:int}"
@using Front.Services
@code {
@using Shared
@using Shared.DTOs
@using Shared.DTOs.Serch
<Preload LoadingText="در حال بارگذاری..." />
@* search *@
<div class="row">
<h4 class="fw-bold py-3 mb-4">
<span class="text-muted fw-light">سرویس ها /</span> سامانه مودیان
</h4>
<div class="col-md-12">
<div class="card mb-2">
<div class="row">
<div class="col-md-12">
<ul class="list-group fa-padding" style="border: 2px solid #0d6efd">
<li class="list-group-item" data-toggle="modal" data-target="#issue">
<div class="row g-3">
<div class="col-md-1">
<input @bind-value="itemsearch.ID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text">
</div>
<div class="col-md-2">
<input @bind-value="itemsearch.InvoiceID" placeholder="شناسه صورتحساب" style="text-align:center;" class="form-control" type="text">
</div>
<div class="col-md-2">
<select @bind="itemsearch.invoiceType" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5" selected>نوع صورتحساب...</option>
@foreach (InvoiceType i in Enum.GetValues(typeof(InvoiceType)))
{
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
}
</select>
</div>
<div class="col-md-2">
<select @bind="itemsearch.SentStatus" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5" selected>وضعیت...</option>
@foreach (SentStatus i in Enum.GetValues(typeof(SentStatus)))
{
<option value="@Convert.ToInt32(i)">@i.GetEnumDisplayName()</option>
}
</select>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
@* alert *@
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
</div>
@* data *@
@if (request != null)
{
<LTable ModelinComponent="request?.list" OnMultipleOfThree="EventCallback.Factory.Create<int>(this,SentTaxItem)" />
@* pagination *@
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
@for (int page = 1; page <= request?.PageCount; page++)
{
if (page == PageIndex)
{
<li class="page-item active">
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
</li>
}
else
{
<li class="page-item">
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
</li>
}
}
</ul>
</nav>
}
@code {
[Inject] protected PreloadService PreloadService { get; set; } = default!;
ItemSerchGetSentTax itemsearch = new ItemSerchGetSentTax();
public int? routed { get; set; } = 0;
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
[Parameter, SupplyParameterFromQuery]
public int? PageIndex { get; set; }
public Shared.DTOs.PagingDto<SentTaxDto>? request { get; set; }
protected override async Task OnParametersSetAsync()
{
if (routed.HasValue && routed > 0)
{
ShowSuccessAlert($"صورتحساب شماره {routed} با موفقیت ارسال شد " +'\n'+
"برای برای 'نمایش وضعیت' آن را تعیین وضعیت کنید");
itemsearch.InvoiceID = routed.Value;
}
if (PageIndex == null) PageIndex = 1;
await Load(PageIndex.Value);
await base.OnParametersSetAsync();
}
}
@functions{
public async Task SentTaxItem(int ID)
{
}
public async Task Load(int pi)
{
itemsearch.PageSize = 10;
itemsearch.PageIndex = pi;
PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Post<ItemSerchGetSentTax>("TaxPayer/GetAllSentTax", itemsearch);
if (rsp.IsSuccessStatusCode)
{
request = await rsp.Content.ReadFromJsonAsync<PagingDto<SentTaxDto>>();
}
else if (rsp.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
ShowDangerAlert("شما دسترسی به خواندن اطلاعات صورتحساب را نداربد");
}
else
{
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
PreloadService.Hide();
}
private void ShowSuccessAlert(string msg)
{
Hidealert = false;
alertColor = AlertColor.Success;
alertIconName = IconName.CheckCircleFill;
alertMessage = msg;
}
private void ShowDangerAlert(string msg)
{
Hidealert = false;
alertColor = AlertColor.Danger;
alertIconName = IconName.ExclamationTriangleFill;
alertMessage = msg;
}
}

View File

@@ -5,8 +5,9 @@
@inject HttpClientController hc;
<Preload LoadingText="در حال بارگذاری..." />
<ConfirmDialog @ref="dialog" />
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
<PageTitle>آماده سازی صورتحساب</PageTitle>
@* alert *@
<div class="row">
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
@@ -228,27 +229,66 @@
};
public async Task Send()
{
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
if (!await CheckAuth())
{
ShowMessage(ToastType.Danger, "خطا در احراز هویت سازمان مالیاتی");
}
else
{
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
if (rsp.IsSuccessStatusCode)
{
var response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
ShowMessage(ToastType.Success, "آماده سازی با موفقیت انجام شد");
ShowMessage(ToastType.Light, "در حال ارسال صورتحساب");
rsp = await hc.Get($"TaxPayer/SendInvoice/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
hc._nav.NavigateTo($"TaxPayer/{InvoiceID}");
// ShowMessage(ToastType.Success, "ارسال با موفقیت انجام شد");
}
else
{
ShowMessage(ToastType.Danger, "خطای در ارسال رخ داده");
}
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowMessage(ToastType.Danger, request[0]);
}
}
else
{
ShowMessage(ToastType.Danger, "خطای در آماده سازی اطلاعات رخ داده");
}
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowMessage(ToastType.Danger, request[0]);
}
}
}
public async Task<bool> CheckAuth()
{
var rsp = await hc.Get($"TaxPayer/CheckAuth");
if (rsp.IsSuccessStatusCode)
{
var response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
ShowMessage(ToastType.Success, "آماده سازی با موفقیت انجام شد");
}
else
{
ShowMessage(ToastType.Danger, "خطای در آماده سازی اطلاعات رخ داده");
return true;
}
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
return false;
}
private void ShowSuccessAlert(string msg)
{
Hidealert = false;

View File

@@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
}) ;
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/") });
//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");