Compare commits

..

No commits in common. "b2eeb8cb3f3b51c62fdeeb71172a3196deac3bb9" and "128600c4ed8e071b6653c8106c03017dfd9ad3be" have entirely different histories.

3 changed files with 26 additions and 52 deletions

View File

@ -16,14 +16,13 @@
<!-- CANCEL -->
<MudButton Variant="Variant.Filled"
Color="@CancelButtonColor"
StartIcon="@CancelButtonIcon"
Color="Color.Error"
StartIcon="@Icons.Material.Filled.Cancel"
Disabled="@DisableCancel"
OnClick="OnCancel">
@CancelButtonText
Cancel
</MudButton>
<!-- SEND -->
<MudButton Variant="Variant.Filled"
Color="@SendButtonColor"
@ -64,7 +63,6 @@
[Parameter] public bool Copied { get; set; }
[Parameter] public bool? SendSuccess { get; set; }
[Parameter] public bool DisableCancel { get; set; }
[Parameter] public bool? CancelSuccess { get; set; }
[Parameter] public EventCallback<string> OrderJsonChanged { get; set; }
@ -97,31 +95,6 @@
_ => 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)
{
OrderJson = value;

View File

@ -7,6 +7,7 @@
@inject IJSRuntime JS
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject HttpClient Http
<MudMainContent Class="pa-0 ma-0">
@ -48,7 +49,6 @@
<JsonOutputPanel @bind-OrderJson="@OrderJson"
Copied="@copied"
SendSuccess="@sendSuccess"
CancelSuccess="@cancelSuccess"
OnCopy="CopyJsonToClipboard"
OnSend="SendOrderToServer"
OnImport="OpenImportDialog"
@ -66,7 +66,6 @@
private string OrderJson = ""; // 🔥 CACHE JSON (QUAN TRỌNG)
private bool copied;
private bool? sendSuccess;
private bool? cancelSuccess;
private CancellationTokenSource? _copyCts;
// ================= INIT =================
@ -248,31 +247,33 @@
async Task CancelOrder()
{
// reset trạng thái trước khi gửi
cancelSuccess = null;
StateHasChanged();
try
{
var res = await Http.PostAsync("/api/order/cancel", null);
cancelSuccess = res.IsSuccessStatusCode;
}
catch
sendSuccess = null; // reset trạng thái SEND
copied = false;
if (res.IsSuccessStatusCode)
{
cancelSuccess = false;
Snackbar.Add(
"⛔ Order đã huỷ",
Severity.Info);
}
StateHasChanged();
// 🔥 AUTO RESET SAU 2 GIÂY
_ = Task.Run(async () =>
else
{
await Task.Delay(2000);
cancelSuccess = null;
await InvokeAsync(StateHasChanged);
});
Snackbar.Add(
"❌ Huỷ order thất bại",
Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add(
$"❌ Lỗi: {ex.Message}",
Severity.Error);
}
}
async Task CopyJsonToClipboard()

View File

@ -131,7 +131,7 @@ public class OrderMessage
public string Version { get; set; } = "v1";
public string Manufacturer { get; set; } = "PNKX";
public string SerialNumber { get; set; } = "T800-002";
public string OrderId { get; set; }
public string OrderId { get; set; } = Guid.NewGuid().ToString();
public int OrderUpdateId { get; set; }
public string? ZoneSetId { get; set; }
@ -419,7 +419,7 @@ public class OrderMessage
manufacturer = Manufacturer,
serialNumber = SerialNumber,
orderId = OrderId= Guid.NewGuid().ToString(),
orderId = OrderId,
orderUpdateId = OrderUpdateId,
zoneSetId = string.IsNullOrWhiteSpace(ZoneSetId)