Files
moadiran/TaxPayerFull/Pages/UserPanel/Customer.razor

169 lines
4.7 KiB
Plaintext
Raw Normal View History

2024-04-22 23:32:39 +03:30
@page "/Customer"
2024-05-05 18:15:37 +03:30
@using Front.Services
2024-05-04 23:13:26 +03:30
@using Shared.DTOs
2024-05-05 18:15:37 +03:30
@using Front.CUSComponent
@using Shared.DTOs.Serch
@inject HttpClientController hc;
2024-05-04 23:13:26 +03:30
<PageTitle>مشتری</PageTitle>
2024-05-05 21:35:15 +03:30
<Preload LoadingText="در حال بارگذاری..." />
2024-05-04 23:13:26 +03:30
@* search *@
<div class="row">
<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-2">
<input placeholder="شناسه" style="text-align:center;" class="form-control" type="text" >
</div>
<div class="col-md-6">
<input style="text-align:center;" placeholder="عنوان" class="form-control" type="text" >
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">جستجو</button>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
@* action *@
<div class="row">
<div class="col-md-12">
<div class="mb-2">
<div class="row">
<div class="col-md-12">
<div class="col-auto">
<button type="submit" class="btn btn-primary">جدید</button>
</div>
</div>
</div>
</div>
</div>
</div>
2024-05-05 18:15:37 +03:30
@* alert *@
2024-05-04 23:13:26 +03:30
<div class="row">
2024-05-05 18:15:37 +03:30
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
<Icon Name="@alertIconName" class="me-2"></Icon>
@alertMessage
</Alert>
2024-05-04 23:13:26 +03:30
</div>
2024-05-05 18:15:37 +03:30
@* data *@
@if (request != null)
{
<LTable ModelinComponent="request?.list" />
@* pagination *@
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
@for (int page = 1; page <= request?.PageCount; page++)
{
if (page == PageIndex)
{
2024-05-05 21:35:15 +03:30
<li class="page-item active">
2024-05-05 18:15:37 +03:30
<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>
}
}
2024-05-05 21:35:15 +03:30
2024-05-05 18:15:37 +03:30
</ul>
</nav>
2024-05-05 21:35:15 +03:30
2024-05-05 18:15:37 +03:30
}
2024-04-22 23:32:39 +03:30
@layout PanelLayout
@code {
2024-05-05 21:35:15 +03:30
[Inject] protected PreloadService PreloadService { get; set; } = default!;
2024-05-05 18:15:37 +03:30
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
2024-05-04 23:13:26 +03:30
2024-05-05 18:15:37 +03:30
protected override async Task OnParametersSetAsync()
2024-05-04 23:13:26 +03:30
{
2024-05-05 21:35:15 +03:30
2024-05-05 18:15:37 +03:30
if (PageIndex == null) PageIndex = 1;
await LoadCus(PageIndex.Value);
await base.OnParametersSetAsync();
}
[Parameter, SupplyParameterFromQuery]
public int? PageIndex { get; set; }
2024-05-04 23:13:26 +03:30
2024-05-05 18:15:37 +03:30
public Shared.DTOs.PagingDto<RCustomer>? request { get; set; }
}
@functions {
private void ShowSuccessAlert(string msg)
{
Hidealert = false;
alertColor = AlertColor.Success;
alertIconName = IconName.CheckCircleFill;
alertMessage = msg;
2024-05-04 23:13:26 +03:30
}
2024-04-22 23:32:39 +03:30
2024-05-05 18:15:37 +03:30
private void ShowDangerAlert(string msg)
2024-05-04 23:13:26 +03:30
{
2024-05-05 18:15:37 +03:30
Hidealert = false;
alertColor = AlertColor.Danger;
alertIconName = IconName.ExclamationTriangleFill;
alertMessage = msg;
}
public async Task LoadCus(int pi)
{
2024-05-05 21:35:15 +03:30
PreloadService.Show(SpinnerColor.Dark);
2024-05-05 18:15:37 +03:30
var rsp = await hc.Post<ItemSerchGetCustomer>("Customer/GetAll", new ItemSerchGetCustomer()
{
PageIndex=pi
});
if (rsp.IsSuccessStatusCode)
2024-05-04 23:13:26 +03:30
{
2024-05-05 18:15:37 +03:30
request = await rsp.Content.ReadFromJsonAsync<PagingDto<RCustomer>>();
}
else if(rsp.StatusCode==System.Net.HttpStatusCode.Forbidden)
{
ShowDangerAlert("شما دسترسی به خواندن اطلاعات مشتری را نداربد");
}
else
{
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
2024-05-05 21:35:15 +03:30
PreloadService.Hide();
2024-05-04 23:13:26 +03:30
}
2024-05-05 18:15:37 +03:30
}