This commit is contained in:
mmrbnjd
2024-05-27 18:01:50 +03:30
parent ef530f0d81
commit e8c5dfcda4
10 changed files with 182 additions and 93 deletions

View File

@@ -2,6 +2,8 @@
@using Shared.DTOs
@inject HttpClientController hc;
@inject Fixedvalues fv;
<ConfirmDialog @ref="dialog" />
<form>
@* alert *@
<div class="row">
@@ -13,10 +15,11 @@
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<div class="form-group col-md-5">
<label class="col-sm-4 col-form-label" style="color:red" for="inputcod">کالا</label>
<select @bind="itemDTO.CODID" @bind:after="() =>
<select @bind="itemDTO.CODID" @bind:after="async () =>
{
await AfterAsync();
if(itemDTO.ID==null)
itemDTO.vra=cods.Where(w=>w.ID==itemDTO.CODID).Select(s=>s.Tax).FirstOrDefault();
}" class="form-control" aria-label="Default select example" id="inputcod">
@@ -49,41 +52,47 @@
</select>
</div>
<div class="form-group col-md-3">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div>
<div class="form-group col-md-3">
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
<InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ کل</label>
<InputNumber @bind-Value="itemDTO.prdis" type="text" class="form-control" id="inputfee" placeholder="مبلغ کل" readonly />
</div>
<div class="col-md-4">
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
<InputNumber @bind-Value="itemDTO.dis" type="text" @bind-Value:after="AfterAsync" class="form-control" id="inputdis" placeholder="مبلغ تخفیف" />
</div>
<div class="col-md-4">
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">نرخ مالیات</label>
<InputNumber @bind-Value="itemDTO.vra" type="text" class="form-control" id="inputvra" placeholder="نرخ مالیات" readonly />
</div>
<div class="form-group col-md-4">
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
<InputNumber @bind-Value="itemDTO.vam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div>
<div class="form-group col-md-4">
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
<CurrencyInput TValue="decimal" @bind-Value="@itemDTO.fee" @bind-Value:after="AfterAsync" Locale="fa-Ir" Placeholder="مبلغ واحد" />
@* <InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" /> *@
</div>
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ کل</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.prdis" Locale="fa-Ir" Placeholder="مبلغ کل" readonly />
</div>
</div>
<div class="row g-3">
<div class="col-md-6">
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.dis" Locale="fa-Ir" @bind-Value:after="AfterAsync" Placeholder="مبلغ تخفیف" />
</div>
<div class="col-md-6">
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.adis" Locale="fa-Ir" Placeholder="مبلغ بعد تخفیف" readonly />
</div>
</div>
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.vam" Locale="fa-Ir" Placeholder="مبلغ مالیات" readonly />
</div>
<div class="form-group col-md-6">
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ نهایی" readonly />
<CurrencyInput TValue="decimal?" @bind-Value="itemDTO.tsstam" Locale="fa-Ir" Placeholder="مبلغ نهایی" readonly />
</div>
</div>
</form>
@@ -100,13 +109,15 @@ else
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
}
@code {
[Inject] ToastService ToastService { get; set; } = default!;
private ConfirmDialog dialog = default!;
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
@@ -233,22 +244,22 @@ else
return;
}
var rsp = await hc.Put<InvoiceItemDTO>($"InvoiceItem/UpdateItem/{InvoiceID}", itemDTO);
if (rsp.IsSuccessStatusCode)
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.update;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
result.Status = ComponentStatus.success;
result.Action = ComponentAction.update;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
public async Task OnClickAdd()
{
@@ -281,19 +292,40 @@ else
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
if (request)
{
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
private async Task ShowConfirmationDeleteAsync()
{
if (itemDTO.ID != null && itemDTO.ID > 0 && InvoiceID != null && InvoiceID > 0)
{
var confirmation = await dialog.ShowAsync(
title: "عملیات حذف آیتم صورتحساب",
message1: $"از حذف آیتم {itemDTO.ID} از صورتحساب {InvoiceID}",
message2: "اطمینان دارید?");
if (confirmation)
{
await OnClickDelete();
}
else
{
ToastService.Notify(new ToastMessage(ToastType.Secondary, $"عملیات حذف متوقف شد"));
}
}
}
}