Добавил выпадающие списки в диалоговом окне добавления принтера

This commit is contained in:
Hukuta committed 2026-05-08 11:45:26 +09:00
1 parent 88f53c793e
commit b492435289
8 files changed
+106 -5

No files matched your search

+64 -3
View File
@@ -1,4 +1,5 @@
@using CartriX.Shared.DTOs.Printer
@using CartriX.Shared.DTOs.PrinterModel
<RadzenStack Gap="16px">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
@@ -58,11 +59,36 @@
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.model;
if (queryPrinterToAdd.model is null)
{
<div style="position: relative; display: flex; width: 100%; max-width: 400px;">
<RadzenAutoComplete Data="printerModels"
Placeholder="Модель XXX"
OpenOnFocus="true"
TextProperty="name"
@bind-Value="printerModelValue"
MinLength="0"
FilterDelay="100"
FilterOperator="StringFilterOperator.Contains"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
Style="width: 100%;"
InputAttributes="@inputAttributes"
Name="AutoCompleteComboBox"
aria-labelledby="AutoCompleteComboBoxLabel" />
<div class="rz-dropdown-trigger rz-corner-right" style="pointer-events: none;">
<span class="notranslate rz-dropdown-trigger-icon rzi rzi-chevron-down"></span>
</div>
</div>
}
else
{
@queryPrinterToAdd.model;
}
}
else
{
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
}
</RadzenTableCell>
</RadzenTableRow>
@@ -75,7 +101,15 @@
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.location;
if (queryPrinterToAdd.location is null)
{
<RadzenTextBox Style="width: 100%;" @TabIndex="queryPrinterToAdd.location" Placeholder="Кабинет XXX" />
}
else
{
@queryPrinterToAdd.location;
}
}
else
{
@@ -95,7 +129,14 @@
private string printerIpOrHostname = "";
private bool processingQueryToPrinter = false;
string? printerModelValue;
QueryPrinterToAdd queryPrinterToAdd = null!;
List<PrinterModelDto> printerModels = null!;
readonly IReadOnlyDictionary<string, object> inputAttributes =
new Dictionary<string, object> { { "style", "padding-right: 2rem;" } };
private async Task OnQueryPrinter()
{
@@ -122,4 +163,24 @@
processingQueryToPrinter = false;
}
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
try
{
HttpClient client = new();
var response = await client.GetAsync($"http://localhost:5197/api/Printer/Models");
if (response.IsSuccessStatusCode)
{
var result = JsonConvert.DeserializeObject<List<PrinterModelDto>>(await response.Content.ReadAsStringAsync());
printerModels = result!;
}
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка: {ex.Message}");
}
}
}