This commit is contained in:
mmrbnjd
2024-10-15 14:19:54 +03:30
parent 595a9ea5d8
commit fb4e9b5bd5
13 changed files with 257 additions and 122 deletions

View File

@@ -98,25 +98,31 @@
</div>
</form>
<div class="row g-3">
<div class="col-md-10">
@if (itemDTO.ID == null)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
</Button>
}
else
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
}
</div>
<div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
</div>
@code {
public bool SpinnerVisible { get; set; } = false;
List<ToastMessage> messages = new List<ToastMessage>();
private ConfirmDialog dialog = default!;
// alert
@@ -132,11 +138,14 @@ else
public ActionInResultComponent result { get; set; }
protected override async Task OnInitializedAsync()
{
SpinnerVisible = true;
cods = await fv.GetCODs();
SpinnerVisible = false;
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
SpinnerVisible = false;
result = new ActionInResultComponent()
{
@@ -203,7 +212,7 @@ else
//-----------------------
public async Task OnClickDelete()
{
SpinnerVisible = true;
var rsp = await hc.Delete($"InvoiceItem/DeleteItem/{itemDTO.ID}");
if (rsp.IsSuccessStatusCode)
{
@@ -222,34 +231,37 @@ else
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
public async Task OnClickUpdate()
{
SpinnerVisible = true;
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
{
ShowDangerAlert("کالا انتخاب نشده");
SpinnerVisible = false;
return;
}
if (itemDTO.am == null || itemDTO.am <= 0)
{
ShowDangerAlert("تعداد وارد نشده");
SpinnerVisible = false;
return;
}
if (itemDTO.fee == null || itemDTO.fee < 0)
{
ShowDangerAlert("مبلغ واحد وارد نشده");
ShowDangerAlert("مبلغ واحد وارد نشده"); SpinnerVisible = false;
return;
}
if (itemDTO.dis == null || itemDTO.dis < 0)
{
ShowDangerAlert("مبلغ تخفیف درست نیست");
ShowDangerAlert("مبلغ تخفیف درست نیست"); SpinnerVisible = false;
return;
}
var rsp = await hc.Put<InvoiceItemAction<InvoiceItemDTO>>($"InvoiceItem/UpdateItem"
@@ -274,30 +286,32 @@ else
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
public async Task OnClickAdd()
{
SpinnerVisible = true;
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
{
ShowDangerAlert("کالا انتخاب نشده");
ShowDangerAlert("کالا انتخاب نشده"); SpinnerVisible = false;
return;
}
if (itemDTO.am == null || itemDTO.am <= 0)
{
ShowDangerAlert("تعداد وارد نشده");
ShowDangerAlert("تعداد وارد نشده"); SpinnerVisible = false;
return;
}
if (itemDTO.fee == null || itemDTO.fee < 0)
{
ShowDangerAlert("مبلغ واحد وارد نشده");
ShowDangerAlert("مبلغ واحد وارد نشده"); SpinnerVisible = false;
return;
}
if (itemDTO.dis == null || itemDTO.dis < 0)
{
ShowDangerAlert("مبلغ تخفیف درست نیست");
ShowDangerAlert("مبلغ تخفیف درست نیست"); SpinnerVisible = false;
return;
}
@@ -323,7 +337,7 @@ else
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
private async Task ShowConfirmationDeleteAsync()
{

View File

@@ -141,12 +141,13 @@
</div>
</div>
<div class="row g-3">
<div class="col-md-10">
@if (add)
{
<div class="row g-3">
<div class="form-group col-md-6">
<Button class="mt-3" Color="ButtonColor.Success" @onclick="AddPay" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Success" @onclick="AddPay" Type="ButtonType.Button">
جدید
</Button>
</div>
@@ -155,24 +156,28 @@
else
{ <div class="row g-3">
<div class="form-group col-md-6">
<Button class="mt-3" Color="ButtonColor.Info" @onclick="UpdatePay" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Info" @onclick="UpdatePay" Type="ButtonType.Button">
ویرایش
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="DeletePay" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Danger" @onclick="DeletePay" Type="ButtonType.Button">
حذف
</Button>
<Button class="mt-3" Color="ButtonColor.Primary" @onclick="cancell" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Primary" @onclick="cancell" Type="ButtonType.Button">
انصراف
</Button>
</div>
</div>
}
</div> <div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
</div>
@code {
public bool SpinnerVisible { get; set; } = false;
private ConfirmDialog dialog = default!;
bool add = true;
[Parameter] public InvoiceDTO invoice { get; set; }
@@ -188,8 +193,9 @@
protected override async Task OnParametersSetAsync()
{
item = new InvoicePaymentDTO();
SpinnerVisible = true;
pmts = await fv.GetPaymentMethods();
SpinnerVisible = false;
await base.OnParametersSetAsync();
}
}
@@ -208,6 +214,7 @@
}
async Task AddPay()
{
SpinnerVisible = true;
Hidealert = true;
if (await Validation())
{
@@ -239,12 +246,13 @@
}
}
SpinnerVisible = false;
}
async Task UpdatePay()
{
Hidealert = true;
SpinnerVisible = true;
if (await Validation())
{
var rsp = await hc.Put<InvoiceItemAction<InvoicePaymentDTO>>("InvoicePayment/UpdatePay", new InvoiceItemAction<InvoicePaymentDTO>()
@@ -275,6 +283,7 @@
ShowDangerAlert(request[0]);
}
}
SpinnerVisible = false;
}
async Task DeletePay()
{
@@ -285,6 +294,7 @@
if (confirmation)
{
SpinnerVisible = true;
Hidealert = true;
if (item.ID.HasValue)
{
@@ -311,6 +321,7 @@
ShowDangerAlert(request[0]);
}
}
SpinnerVisible = false;
}
}

View File

@@ -126,15 +126,18 @@
<div class="row">
<div class="col-md-8">
<div class="col-md-6">
<span class="text-muted fw-light">قیمت نهایی :</span> @TotalPrice.ToString("N0") ريال
</div>
<div class="col-md-4">
<button type="submit" @onclick="NewOrder" class="btn btn-primary">ثبت</button>
<Button Disabled="SpinnerVisible" Color="ButtonColor.Primary" @onclick="NewOrder">ثبت</Button>
</div>
<div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
</div>
@code {
public bool SpinnerVisible { get; set; } = false;
#region Alert
// alert
AlertColor alertColor = AlertColor.Primary;
@@ -224,7 +227,7 @@
}
public async Task NewOrder()
{
SpinnerVisible = true;
if (Selected != null)
{
if (Selected.ID < 0 && (values[0] < 0 || values[1] < 0 || values[2] < 0 || values[3] < 0)) return;
@@ -264,7 +267,7 @@
}
}
SpinnerVisible = false;
}
}

View File

@@ -97,19 +97,21 @@
<br />
@if (order.Status == StatusOrder.Create)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickPay" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" 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 Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickCancel" Type="ButtonType.Button">
ابطال
</Button>
}
</div>
<div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
@code {
public bool SpinnerVisible { get; set; } = false;
#region Alert
// alert
AlertColor alertColor = AlertColor.Primary;
@@ -162,12 +164,17 @@
}
private async Task<List<OrderItemDto>> LoadOrderItem()
{
SpinnerVisible = true;
var rsp = await hc.Get($"Orders/GetOrderDetails/{order.ID}");
if (rsp.IsSuccessStatusCode)
{
SpinnerVisible = false;
return await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
}
else
{
SpinnerVisible = false;
ShowDangerAlert("خطایی در بارگیری");
return new List<OrderItemDto>();
}
@@ -175,6 +182,7 @@
}
private async Task OnClickPay()
{
SpinnerVisible = true;
var rsp = await hc.Get($"Orders/SubmitOrderBywallet/{order.ID}");
if (rsp.IsSuccessStatusCode)
@@ -183,6 +191,7 @@
result = new ActionInResultComponent();
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else
@@ -190,8 +199,8 @@
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
private async Task OnClickCancel()
@@ -203,32 +212,35 @@
if (confirmation)
{
SpinnerVisible = true;
PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Delete($"Orders/CancelOrder/{order.ID}");
PreloadService.Hide();
if (rsp.IsSuccessStatusCode)
{
if(await rsp.Content.ReadFromJsonAsync<bool>())
if (await rsp.Content.ReadFromJsonAsync<bool>())
{
order.Status = StatusOrder.Cancel;
result = new ActionInResultComponent();
result.Status = ComponentStatus.success;
result.Action = ComponentAction.delete;
await OnMultipleOfThree.InvokeAsync(result);
result.Action = ComponentAction.delete;
await OnMultipleOfThree.InvokeAsync(result);
}
else
ShowDangerAlert("خطای سیستمی");
}
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
ShowDangerAlert("سفارش یافت نشد");
else
ShowDangerAlert("خطای سیستمی");
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
ShowDangerAlert("سفارش یافت نشد");
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
}
}