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

243 lines
9.8 KiB
Plaintext
Raw Normal View History

2024-05-31 00:24:45 +03:30
@page "/TaxPayerInvoiceItem/{InvoiceID:int}"
@using Front.Services
@using Shared.DTOs
@layout PanelLayout
@inject HttpClientController hc;
<Preload LoadingText="در حال بارگذاری..." />
<ConfirmDialog @ref="dialog" />
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
<PageTitle>آماده سازی صورتحساب</PageTitle>
2024-06-08 17:13:12 +03:30
<div class="row">
<div class="col-md-12">
<div class="card mb-4">
<h5 class="card-header">اطلاعات تکمیلی سرآمد صورتحساب</h5>
<div class="card-body">
<form>
@if (invoice?.header != null)
{
<div class="row">
@foreach (var item in invoice?.header.filds)
{
<div class="mb-3 col-md-6">
@if (item.ModeID == 1 && item.InputBox != "autofild")
{
<label style="color:red;" class="form-label">@item.fName</label>
}
else
{
<label class="form-label">@item.fName</label>
}
@if (item.InputBox == "fromdb")
{
<select @bind="item.Value" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5; " selected>@item.fName...</option>
@foreach (var itema in item.DefVals)
{
if (itema.ID == item.Value)
{
<option value="@itema.ID" selected>@itema.Name</option>
}
else
{
<option value="@itema.ID">@itema.Name</option>
}
}
</select>
}
else if (item.InputBox == "autofild")
{
<input @bind-value="item.Value" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" disabled />
}
else
{
<input @bind-value="item.Value" style="text-align:center;" class="form-control" type="text" placeholder="@item.fName" />
}
</div>
}
</div>
}
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card mb-4">
<h5 class="card-header">اطلاعات تکمیلی بدنه صورتحساب</h5>
<div class="card-body">
@if (invoice?.Bodys != null)
{
<Accordion>
@foreach (var item in invoice?.Bodys)
{<div class="col-md-12">
<div class="card mb-4">
<AccordionItem Title="@item.filds.Where(w=>w.eName=="sstt").Select(s=>s.Value).First()">
<Content>
<div class="row">
@foreach (var itemB in item.filds)
{
<div class="mb-3 col-md-6">
@if (itemB.ModeID == 1 && itemB.InputBox != "autofild")
{
<label style="color:red;" class="form-label">@itemB.fName</label>
}
else
{
<label class="form-label">@itemB.fName</label>
}
@if (itemB.InputBox == "fromdb")
{
<select @bind="itemB.Value" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5; " selected>@itemB.fName...</option>
@foreach (var itema in itemB.DefVals)
{
if (itema.ID == itemB.Value)
{
<option value="@itema.ID" selected>@itema.Name</option>
}
else
{
<option value="@itema.ID">@itema.Name</option>
}
}
</select>
}
else if (itemB.InputBox == "autofild")
{
<input @bind-value="itemB.Value" style="text-align:center;" class="form-control" type="text" placeholder="@itemB.fName" disabled />
}
else
{
<input @bind-value="itemB.Value" style="text-align:center;" class="form-control" type="text" placeholder="@itemB.fName" />
}
</div>
}
</div>
</Content>
</AccordionItem>
</div>
</div>
}
</Accordion>
}
</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" @onclick="Send" class="btn btn-primary">ارسال</button>
</div>
</div>
</div>
</div>
</div>
</div>
2024-05-31 00:24:45 +03:30
@code {
private ConfirmDialog dialog = default!;
[Parameter] public int? InvoiceID { get; set; }
List<ToastMessage> messages = new List<ToastMessage>();
[Inject] protected PreloadService PreloadService { get; set; } = default!;
2024-06-01 12:58:04 +03:30
public _TaxPayer.Atemplatefield? invoice { get; set; }
2024-05-31 00:24:45 +03:30
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
2024-06-01 12:58:04 +03:30
protected override async Task OnParametersSetAsync()
2024-05-31 00:24:45 +03:30
{
await LoadData();
2024-06-01 12:58:04 +03:30
await base.OnParametersSetAsync();
2024-06-08 17:13:12 +03:30
2024-05-31 00:24:45 +03:30
}
2024-06-01 12:58:04 +03:30
2024-05-31 00:24:45 +03:30
}
2024-06-08 17:13:12 +03:30
@functions {
public async Task Send()
{
var rsp = await hc.Post<_TaxPayer.Atemplatefield>($"TaxPayer/PreparationInvoiceBeforeSending", invoice);
if (rsp.IsSuccessStatusCode)
{
var response = await rsp.Content.ReadFromJsonAsync<bool>();
if (response)
{
ShowSuccessAlert("آماده سازی با موفقیت انجام شد");
}
else
{
ShowDangerAlert("خطای در آماده سازی اطلاعات رخ داده");
}
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
2024-05-31 00:24:45 +03:30
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;
}
private async Task LoadData()
{
PreloadService.Show(SpinnerColor.Dark);
2024-05-31 22:08:09 +03:30
var rsp = await hc.Get($"TaxPayer/GetInvoice/{InvoiceID}");
2024-05-31 00:24:45 +03:30
if (rsp.IsSuccessStatusCode)
{
2024-06-01 12:58:04 +03:30
invoice = await rsp.Content.ReadFromJsonAsync<_TaxPayer.Atemplatefield?>();
2024-05-31 00:24:45 +03:30
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
PreloadService.Hide();
}
}