refactor: excel导入时,按行号排序

This commit is contained in:
Diego2098
2024-04-22 23:25:40 +08:00
parent d04e87718a
commit 28d869b099
2 changed files with 15 additions and 13 deletions

View File

@@ -572,7 +572,7 @@ public class VariableService : BaseService<Variable>, IVariableService
if (stringBuilder.Length > 0)
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((row++, false, stringBuilder.ToString()));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, stringBuilder.ToString()));
return;
}
@@ -657,7 +657,7 @@ public class VariableService : BaseService<Variable>, IVariableService
if (pluginProp == null)
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((row++, false, Localizer["ImportNullError"]));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, Localizer["ImportNullError"]));
return;
}
@@ -670,13 +670,13 @@ public class VariableService : BaseService<Variable>, IVariableService
if (businessDevName == null || businessDevice == null)
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), true, Localizer["DeviceNotNull"]));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, Localizer["DeviceNotNull"]));
return;
}
if (variableNameObj == null)
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), true, Localizer["VariableNotNull"]));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, Localizer["VariableNotNull"]));
return;
}
@@ -699,7 +699,7 @@ public class VariableService : BaseService<Variable>, IVariableService
if (stringBuilder.Length > 0)
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((row++, false, stringBuilder.ToString()));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, stringBuilder.ToString()));
return;
}
@@ -726,7 +726,7 @@ public class VariableService : BaseService<Variable>, IVariableService
else
{
importPreviewOutput.HasError = true;
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), true, Localizer["VariableNotNull"]));
importPreviewOutput.Results.Add((Interlocked.Add(ref row, 1), false, Localizer["VariableNotNull"]));
return;
}
}
@@ -775,4 +775,4 @@ public class VariablePageInput : BasePageInput
/// <inheritdoc/>
public long? BusinessDeviceId { get; set; }
}
}

View File

@@ -29,12 +29,14 @@
if (item.Value.HasError)
{
<div style="height:300px;overflow-y:scroll">
<Virtualize Items="item.Value.Results.Where(a=>!a.Success).ToList()" Context="item1" ItemSize="60" OverscanCount=2>
<Virtualize Items="item.Value.Results.Where(a=>!a.Success).OrderBy(a=>a.Row).ToList()" Context="item1" ItemSize="60" OverscanCount=2>
<ItemContent>
<span class="avatar">@item1.Row</span>
<span class=@((item1.Success?"green--text":"red--text"))>
<strong>@item1.ErrorMessage</strong>
</span>
<div>
<span class="avatar">@item1.Row</span>
<span class=@((item1.Success?"green--text":"red--text"))>
<strong>@item1.ErrorMessage</strong>
</span>
</div>
</ItemContent>
</Virtualize>
</div>
@@ -53,4 +55,4 @@
</Step>
@code {
Step step;
}
}