mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-30 15:13:59 +08:00
修复 变量页面 自动刷新时,每页条数会恢复初始值 的问题
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
@typeparam TItem
|
||||
|
||||
<Table TItem="TItem" IsBordered="true" IsStriped="true" IsMultipleSelect="IsMultipleSelect" @ref="Instance" TableSize=TableSize
|
||||
IsPagination="IsPagination" PageItemsSource="PageItemsSource" IsFixedHeader="IsFixedHeader" IndentSize=24 RowHeight=RowHeight PageItems=PageItems
|
||||
IsPagination="IsPagination" PageItemsSource="PageItemsSource" IsFixedHeader="IsFixedHeader" IndentSize=24 RowHeight=RowHeight
|
||||
IsTree="IsTree" OnTreeExpand="OnTreeExpand!" TreeNodeConverter="TreeNodeConverter!" TreeIcon="fa-solid fa-circle-chevron-right" TreeExpandIcon="fa-solid fa-circle-chevron-right fa-rotate-90" IsAutoQueryFirstRender=IsAutoQueryFirstRender
|
||||
ShowDefaultButtons="ShowDefaultButtons" ShowAdvancedSearch="ShowAdvancedSearch" ShowResetButton=ShowResetButton
|
||||
ShowEmpty="ShowEmpty" EmptyText="@EmptyText" EmptyImage="@($"{WebsiteConst.DefaultResourceUrl}images/empty.svg")" SortString="@SortString"
|
||||
|
||||
@@ -124,9 +124,7 @@ public partial class AdminTable<TItem> where TItem : class, new()
|
||||
[Parameter]
|
||||
public float RowHeight { get; set; } = 38;
|
||||
|
||||
/// <inheritdoc cref="Table{TItem}.PageItems"/>
|
||||
[Parameter]
|
||||
public int PageItems { get; set; }
|
||||
|
||||
|
||||
/// <inheritdoc cref="Table{TItem}.IsFixedHeader"/>
|
||||
[Parameter]
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="col-12 col-md-6" style="height:100%">
|
||||
|
||||
<AdminTable @ref="table2" TItem="UserSelectorOutput" AutoGenerateColumns="true" @bind-SelectedRows="@SelectedDeleteRows" ClickToSelect="true"
|
||||
ShowToolbar="true" ShowDefaultButtons="false" IsMultipleSelect="true" ShowAdvancedSearch=false ShowResetButton=false PageItems=20
|
||||
ShowToolbar="true" ShowDefaultButtons="false" IsMultipleSelect="true" ShowAdvancedSearch=false ShowResetButton=false
|
||||
ShowCardView=false ShowColumnList=false ShowSearch=false ShowRefresh=false ScrollMode=ScrollMode.Virtual Items=SelectedRows
|
||||
IsPagination=false>
|
||||
<TableToolbarTemplate>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<AdminTable @ref="table1" TItem="SysRole" AutoGenerateColumns="true" @bind-SelectedRows="@SelectedAddRows" ClickToSelect="true"
|
||||
ShowToolbar="true" ShowDefaultButtons="false" IsMultipleSelect="true" ShowAdvancedSearch=false ShowResetButton=false
|
||||
ShowCardView=false ShowColumnList=false ScrollMode=ScrollMode.Virtual PageItems=20
|
||||
ShowCardView=false ShowColumnList=false ScrollMode=ScrollMode.Virtual
|
||||
OnQueryAsync="OnQueryAsync" IsPagination=false>
|
||||
<TableToolbarTemplate>
|
||||
<TableToolbarButton TItem="SysRole" Color="Color.Info" Icon="fa-solid fa-users-gear" Text="@DefaultLocalizer["Add"]"
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="col-12 col-md-6" style="height:100%">
|
||||
|
||||
<AdminTable @ref="table2" TItem="SysRole" AutoGenerateColumns="true" @bind-SelectedRows="@SelectedDeleteRows" ClickToSelect="true"
|
||||
ShowToolbar="true" ShowDefaultButtons="false" IsMultipleSelect="true" ShowAdvancedSearch=false ShowResetButton=false PageItems=20
|
||||
ShowToolbar="true" ShowDefaultButtons="false" IsMultipleSelect="true" ShowAdvancedSearch=false ShowResetButton=false
|
||||
ShowCardView=false ShowColumnList=false ShowSearch=false ShowRefresh=false ScrollMode=ScrollMode.Virtual Items=SelectedRows
|
||||
IsPagination=false>
|
||||
<TableToolbarTemplate>
|
||||
|
||||
@@ -566,7 +566,7 @@ public abstract class DeviceHostedService : BackgroundService
|
||||
}
|
||||
|
||||
//线程卡死/初始化失败检测
|
||||
if ((driverBase.CurrentDevice.ActiveTime != null && driverBase.CurrentDevice.ActiveTime.Value.AddMinutes(CheckIntervalTime) <= DateTime.Now)
|
||||
if ((driverBase.CurrentDevice.ActiveTime != null && driverBase.CurrentDevice.ActiveTime != DateTime.UnixEpoch.ToLocalTime() && driverBase.CurrentDevice.ActiveTime.Value.AddMinutes(CheckIntervalTime) <= DateTime.Now)
|
||||
|| (driverBase.IsInitSuccess == false))
|
||||
{
|
||||
//如果线程处于暂停状态,跳过
|
||||
|
||||
@@ -1,133 +1,34 @@
|
||||
@namespace ThingsGateway.Debug
|
||||
@using BlazorComponent;
|
||||
@using BootstrapBlazor.Components
|
||||
@using Microsoft.AspNetCore.Components.Web;
|
||||
@using System.Reflection;
|
||||
|
||||
@using ThingsGateway.Foundation.OpcDa;
|
||||
@using ThingsGateway.Foundation.OpcDa.Rcw;
|
||||
@using Masa.Blazor
|
||||
@inherits BasePopupComponentBase
|
||||
|
||||
<PModal Persistent Title=@Plc?.OpcDaConfig?.ToString() Value="Visible" Width=1200 ValueChanged=@((a=>{if(!a)
|
||||
ClosePopupAsync();})) OnSave="()=>{}" SaveText="关闭">
|
||||
<div class="row ">
|
||||
|
||||
<SaveContent Context="save">
|
||||
@{
|
||||
#if Plugin
|
||||
<MMenu OffsetY Context="menu">
|
||||
<ActivatorContent>
|
||||
<MButton @attributes="@menu.Attrs" Color="primary" Class="my-1 mx-2 " Disabled="isDownLoading" Loading="isDownLoading">
|
||||
导出
|
||||
<AppChevronDown></AppChevronDown>
|
||||
</MButton>
|
||||
</ActivatorContent>
|
||||
<ChildContent>
|
||||
<MList>
|
||||
<MListItem Color="primary" OnClick="DownDeviceExport" Disabled="isDownLoading" > 导出到excel </MListItem>
|
||||
<MListItem Color="primary" OnClick="DeviceImport" Disabled="isDownLoading" >导入到系统</MListItem>
|
||||
</MList>
|
||||
|
||||
</ChildContent>
|
||||
</MMenu>
|
||||
#endif
|
||||
}
|
||||
</SaveContent>
|
||||
<div style="col-12 col-md-6 p-1 min-height:500px;">
|
||||
<TreeView TItem="OpcDaTagModel" Items="Items" ShowIcon="true"
|
||||
OnExpandNodeAsync=OnExpandNodeAsync OnTreeItemClick=@(a=>{ClickItem=a;return Task.CompletedTask; })
|
||||
IsAccordion ClickToggleNode ModelEqualityComparer="ModelEqualityComparer" />
|
||||
</div>
|
||||
<div class="col-12 col-md-6 p-1">
|
||||
|
||||
<ChildContent>
|
||||
@if (Visible)
|
||||
@if(ClickItem?.Value?.Tag?.Properties !=null)
|
||||
{
|
||||
|
||||
<MRow Class="pa-4"
|
||||
Justify="JustifyTypes.SpaceBetween">
|
||||
<MCol Cols="12" Md="6">
|
||||
<MTreeview @bind-Value=Selected @bind-Active=Actived SelectionType="SelectionType.Leaf"
|
||||
Items=Nodes TItem=OpcDaTagModel
|
||||
Color="warning"
|
||||
Selectable
|
||||
Activatable
|
||||
OpenOnClick
|
||||
LoadChildren=PopulateBranchAsync
|
||||
TKey=BrowseElement ItemKey="r=>r.Tag"
|
||||
Style="height:500px;overflow-y:auto;"
|
||||
ItemText="r=>r.Name"
|
||||
ItemChildren="r=>r.Nodes">
|
||||
</MTreeview>
|
||||
</MCol>
|
||||
<MCol Cols="12" Md="6">
|
||||
<MCardText Style="height:500px;overflow-y:auto;">
|
||||
@if (Actived?.Count == 0)
|
||||
{
|
||||
<div key="title"
|
||||
class="text-h6 font-weight-light grey--text pa-4 text-center">
|
||||
选择左侧节点
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ScrollXTransition>
|
||||
<MSheet Outlined Class="ma-0 pa-1">
|
||||
<MRow Align="AlignTypes.Center">
|
||||
<MCol>
|
||||
<MListItem>
|
||||
<ItemContent>
|
||||
<MListItemContent>
|
||||
<MListItemTitle>NodeId </MListItemTitle>
|
||||
</MListItemContent>
|
||||
</ItemContent>
|
||||
</MListItem>
|
||||
</MCol>
|
||||
<MDivider Vertical
|
||||
Center />
|
||||
<MCol>
|
||||
<MLabel Class=@($"ma-1")> @Actived.FirstOrDefault().ItemName </MLabel>
|
||||
</MCol>
|
||||
|
||||
</MRow>
|
||||
</MSheet>
|
||||
@if (nodeAttributes != null)
|
||||
{
|
||||
@foreach (var item in nodeAttributes)
|
||||
{
|
||||
<MSheet Outlined Class="ma-0 pa-1">
|
||||
<MRow Align="AlignTypes.Center">
|
||||
<MCol>
|
||||
<MListItem>
|
||||
<ItemContent>
|
||||
<MListItemContent>
|
||||
<MListItemTitle>@item.Description </MListItemTitle>
|
||||
</MListItemContent>
|
||||
</ItemContent>
|
||||
</MListItem>
|
||||
</MCol>
|
||||
<MDivider Vertical
|
||||
Center />
|
||||
<MCol>
|
||||
<MLabel Class=@($"{(item.ResultID.Failed()?"red--text":"green--text")} ma-1")> @item.Value </MLabel>
|
||||
</MCol>
|
||||
|
||||
</MRow>
|
||||
</MSheet>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
</ScrollXTransition>
|
||||
|
||||
}
|
||||
</MCardText>
|
||||
</MCol>
|
||||
|
||||
<MDivider Vertical></MDivider>
|
||||
|
||||
</MRow>
|
||||
|
||||
<MOverlay Absolute Value="overlay" Opacity="0.8">
|
||||
<span class="green--text text--darken-2">
|
||||
@("正在获取OpcDa节点...")
|
||||
</span>
|
||||
<MProgressCircular Indeterminate Width=6 Size="30"></MProgressCircular>
|
||||
</MOverlay>
|
||||
foreach (var item in ClickItem.Value.Tag.Properties )
|
||||
{
|
||||
<Display class=@($"{(item.ResultID.Failed()?"red--text":"green--text")}") @bind-Value=@item.Value DisplayText=@item.Description ShowLabel="true"/>
|
||||
}
|
||||
}
|
||||
</ChildContent>
|
||||
</PModal>
|
||||
</div>
|
||||
</div>
|
||||
@code {
|
||||
RenderFragment<OpcDaTagModel> RenderTreeItem => item =>
|
||||
@<span class="flex-fill">@item.Name</span>
|
||||
;
|
||||
|
||||
private TreeViewItem<OpcDaTagModel> ClickItem;
|
||||
}
|
||||
|
||||
@@ -8,22 +8,17 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using BlazorComponent;
|
||||
using BootstrapBlazor.Components;
|
||||
using Masa.Blazor;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using ThingsGateway.Admin.Application;
|
||||
|
||||
using ThingsGateway.Foundation.OpcDa.Rcw;
|
||||
|
||||
#if Plugin
|
||||
|
||||
using ThingsGateway.Gateway.Application;
|
||||
using ThingsGateway.Plugin.OpcDa;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,16 +27,17 @@ namespace ThingsGateway.Debug;
|
||||
/// <summary>
|
||||
/// 导入变量
|
||||
/// </summary>
|
||||
public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
public partial class OpcDaImportVariable
|
||||
{
|
||||
private List<BrowseElement> actived = new();
|
||||
|
||||
private ItemProperty[] nodeAttributes;
|
||||
|
||||
private List<OpcDaTagModel> Nodes = new();
|
||||
private List<TreeViewItem<OpcDaTagModel>> Items = new();
|
||||
private bool ModelEqualityComparer(OpcDaTagModel x, OpcDaTagModel y) => x.NodeId == y.NodeId;
|
||||
private Task<IEnumerable<TreeViewItem<OpcDaTagModel>>> OnExpandNodeAsync(TreeViewItem<OpcDaTagModel> treeViewItem)
|
||||
{
|
||||
|
||||
private bool overlay = true;
|
||||
|
||||
}
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IStringLocalizer<OpcDaImportVariable>? Localizer { get; set; }
|
||||
@@ -55,23 +51,10 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public ThingsGateway.Foundation.OpcDa.OpcDaMaster Plc { get; set; }
|
||||
|
||||
private List<BrowseElement> Actived
|
||||
{
|
||||
get => actived;
|
||||
set
|
||||
{
|
||||
if (actived?.FirstOrDefault() != value?.FirstOrDefault() && value?.Count > 0)
|
||||
{
|
||||
actived = value;
|
||||
nodeAttributes = actived.FirstOrDefault().Properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShowSkeleton = true;
|
||||
private List<BrowseElement> Selected { get; set; } = new();
|
||||
|
||||
#if Plugin
|
||||
#if Plugin1
|
||||
|
||||
private bool isDownLoading;
|
||||
|
||||
@@ -244,8 +227,8 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
{
|
||||
await Task.Factory.StartNew(async () =>
|
||||
{
|
||||
Nodes = PopulateBranch("");
|
||||
overlay = false;
|
||||
Items = PopulateBranch("");
|
||||
ShowSkeleton = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
await base.OnInitializedAsync();
|
||||
@@ -275,13 +258,13 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
if (target.HasChildren)
|
||||
{
|
||||
if (isAll)
|
||||
child.Nodes = PopulateBranch(target.ItemName);
|
||||
child.Items = PopulateBranch(target.ItemName);
|
||||
else
|
||||
child.Nodes = new();
|
||||
child.Items = new();
|
||||
}
|
||||
else
|
||||
{
|
||||
child.Nodes = null;
|
||||
child.Items = null;
|
||||
}
|
||||
|
||||
list.Add(child);
|
||||
@@ -301,7 +284,7 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
{
|
||||
Name = ex.Message,
|
||||
Tag = new(),
|
||||
Nodes = null
|
||||
Items = null
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -312,7 +295,7 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var sourceId = model.Tag.ItemName;
|
||||
model.Nodes = PopulateBranch(sourceId);
|
||||
model.Items = PopulateBranch(sourceId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -320,7 +303,7 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
{
|
||||
internal string Name { get; set; }
|
||||
internal string NodeId => (Tag?.ItemName)?.ToString();
|
||||
internal List<OpcDaTagModel> Nodes { get; set; } = new();
|
||||
internal List<OpcDaTagModel> Items { get; set; } = new();
|
||||
internal BrowseElement Tag { get; set; }
|
||||
|
||||
public List<OpcDaTagModel> GetAllTags()
|
||||
@@ -333,8 +316,8 @@ public partial class OpcDaImportVariable : BasePopupComponentBase
|
||||
private void GetAllTagsRecursive(OpcDaTagModel parentTag, List<OpcDaTagModel> allTags)
|
||||
{
|
||||
allTags.Add(parentTag);
|
||||
if (parentTag.Nodes != null)
|
||||
foreach (OpcDaTagModel childTag in parentTag.Nodes)
|
||||
if (parentTag.Items != null)
|
||||
foreach (OpcDaTagModel childTag in parentTag.Items)
|
||||
{
|
||||
GetAllTagsRecursive(childTag, allTags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user