Compare commits
2 Commits
128600c4ed
...
b2eeb8cb3f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2eeb8cb3f | ||
| 7ce770404c |
|
|
@ -16,13 +16,14 @@
|
||||||
|
|
||||||
<!-- CANCEL -->
|
<!-- CANCEL -->
|
||||||
<MudButton Variant="Variant.Filled"
|
<MudButton Variant="Variant.Filled"
|
||||||
Color="Color.Error"
|
Color="@CancelButtonColor"
|
||||||
StartIcon="@Icons.Material.Filled.Cancel"
|
StartIcon="@CancelButtonIcon"
|
||||||
Disabled="@DisableCancel"
|
Disabled="@DisableCancel"
|
||||||
OnClick="OnCancel">
|
OnClick="OnCancel">
|
||||||
Cancel
|
@CancelButtonText
|
||||||
</MudButton>
|
</MudButton>
|
||||||
|
|
||||||
|
|
||||||
<!-- SEND -->
|
<!-- SEND -->
|
||||||
<MudButton Variant="Variant.Filled"
|
<MudButton Variant="Variant.Filled"
|
||||||
Color="@SendButtonColor"
|
Color="@SendButtonColor"
|
||||||
|
|
@ -63,6 +64,7 @@
|
||||||
[Parameter] public bool Copied { get; set; }
|
[Parameter] public bool Copied { get; set; }
|
||||||
[Parameter] public bool? SendSuccess { get; set; }
|
[Parameter] public bool? SendSuccess { get; set; }
|
||||||
[Parameter] public bool DisableCancel { get; set; }
|
[Parameter] public bool DisableCancel { get; set; }
|
||||||
|
[Parameter] public bool? CancelSuccess { get; set; }
|
||||||
|
|
||||||
[Parameter] public EventCallback<string> OrderJsonChanged { get; set; }
|
[Parameter] public EventCallback<string> OrderJsonChanged { get; set; }
|
||||||
|
|
||||||
|
|
@ -95,6 +97,31 @@
|
||||||
_ => Icons.Material.Filled.Send
|
_ => Icons.Material.Filled.Send
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private string CancelButtonText =>
|
||||||
|
CancelSuccess switch
|
||||||
|
{
|
||||||
|
true => "Done",
|
||||||
|
false => "Error",
|
||||||
|
_ => "Cancel"
|
||||||
|
};
|
||||||
|
|
||||||
|
private Color CancelButtonColor =>
|
||||||
|
CancelSuccess switch
|
||||||
|
{
|
||||||
|
true => Color.Success,
|
||||||
|
false => Color.Error,
|
||||||
|
_ => Color.Error
|
||||||
|
};
|
||||||
|
|
||||||
|
private string CancelButtonIcon =>
|
||||||
|
CancelSuccess switch
|
||||||
|
{
|
||||||
|
true => Icons.Material.Filled.CheckCircle,
|
||||||
|
false => Icons.Material.Filled.Error,
|
||||||
|
_ => Icons.Material.Filled.Cancel
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private void OrderJsonChange(string value)
|
private void OrderJsonChange(string value)
|
||||||
{
|
{
|
||||||
OrderJson = value;
|
OrderJson = value;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
@inject IJSRuntime JS
|
@inject IJSRuntime JS
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
@inject ISnackbar Snackbar
|
|
||||||
@inject HttpClient Http
|
@inject HttpClient Http
|
||||||
|
|
||||||
<MudMainContent Class="pa-0 ma-0">
|
<MudMainContent Class="pa-0 ma-0">
|
||||||
|
|
@ -49,6 +48,7 @@
|
||||||
<JsonOutputPanel @bind-OrderJson="@OrderJson"
|
<JsonOutputPanel @bind-OrderJson="@OrderJson"
|
||||||
Copied="@copied"
|
Copied="@copied"
|
||||||
SendSuccess="@sendSuccess"
|
SendSuccess="@sendSuccess"
|
||||||
|
CancelSuccess="@cancelSuccess"
|
||||||
OnCopy="CopyJsonToClipboard"
|
OnCopy="CopyJsonToClipboard"
|
||||||
OnSend="SendOrderToServer"
|
OnSend="SendOrderToServer"
|
||||||
OnImport="OpenImportDialog"
|
OnImport="OpenImportDialog"
|
||||||
|
|
@ -66,6 +66,7 @@
|
||||||
private string OrderJson = ""; // 🔥 CACHE JSON (QUAN TRỌNG)
|
private string OrderJson = ""; // 🔥 CACHE JSON (QUAN TRỌNG)
|
||||||
private bool copied;
|
private bool copied;
|
||||||
private bool? sendSuccess;
|
private bool? sendSuccess;
|
||||||
|
private bool? cancelSuccess;
|
||||||
private CancellationTokenSource? _copyCts;
|
private CancellationTokenSource? _copyCts;
|
||||||
|
|
||||||
// ================= INIT =================
|
// ================= INIT =================
|
||||||
|
|
@ -247,35 +248,33 @@
|
||||||
|
|
||||||
async Task CancelOrder()
|
async Task CancelOrder()
|
||||||
{
|
{
|
||||||
|
// reset trạng thái trước khi gửi
|
||||||
|
cancelSuccess = null;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var res = await Http.PostAsync("/api/order/cancel", null);
|
var res = await Http.PostAsync("/api/order/cancel", null);
|
||||||
|
cancelSuccess = res.IsSuccessStatusCode;
|
||||||
sendSuccess = null; // reset trạng thái SEND
|
|
||||||
copied = false;
|
|
||||||
|
|
||||||
if (res.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
Snackbar.Add(
|
|
||||||
"⛔ Order đã huỷ",
|
|
||||||
Severity.Info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Snackbar.Add(
|
|
||||||
"❌ Huỷ order thất bại",
|
|
||||||
Severity.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch
|
||||||
{
|
{
|
||||||
Snackbar.Add(
|
cancelSuccess = false;
|
||||||
$"❌ Lỗi: {ex.Message}",
|
|
||||||
Severity.Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
// 🔥 AUTO RESET SAU 2 GIÂY
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(2000);
|
||||||
|
cancelSuccess = null;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async Task CopyJsonToClipboard()
|
async Task CopyJsonToClipboard()
|
||||||
{
|
{
|
||||||
_copyCts?.Cancel();
|
_copyCts?.Cancel();
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class OrderMessage
|
||||||
public string Version { get; set; } = "v1";
|
public string Version { get; set; } = "v1";
|
||||||
public string Manufacturer { get; set; } = "PNKX";
|
public string Manufacturer { get; set; } = "PNKX";
|
||||||
public string SerialNumber { get; set; } = "T800-002";
|
public string SerialNumber { get; set; } = "T800-002";
|
||||||
public string OrderId { get; set; } = Guid.NewGuid().ToString();
|
public string OrderId { get; set; }
|
||||||
public int OrderUpdateId { get; set; }
|
public int OrderUpdateId { get; set; }
|
||||||
public string? ZoneSetId { get; set; }
|
public string? ZoneSetId { get; set; }
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ public class OrderMessage
|
||||||
manufacturer = Manufacturer,
|
manufacturer = Manufacturer,
|
||||||
serialNumber = SerialNumber,
|
serialNumber = SerialNumber,
|
||||||
|
|
||||||
orderId = OrderId,
|
orderId = OrderId= Guid.NewGuid().ToString(),
|
||||||
orderUpdateId = OrderUpdateId,
|
orderUpdateId = OrderUpdateId,
|
||||||
|
|
||||||
zoneSetId = string.IsNullOrWhiteSpace(ZoneSetId)
|
zoneSetId = string.IsNullOrWhiteSpace(ZoneSetId)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user