更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using HandyControl.Controls;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Extension;
|
||||
using YY.Admin.Core.Helper;
|
||||
using YY.Admin.Services.Service;
|
||||
using YY.Admin.Services.Service.Tenant;
|
||||
using YY.Admin.ViewModels.Control;
|
||||
|
||||
namespace YY.Admin.ViewModels.SysManage
|
||||
{
|
||||
public class TenantManagementViewModel : BaseViewModel
|
||||
{
|
||||
private readonly ISysTenantSyncService _tenantSyncService;
|
||||
|
||||
private PaginationDataGridViewModel<TenantOutput> _paginationDataGridViewModel;
|
||||
public PaginationDataGridViewModel<TenantOutput> PaginationDataGridViewModel
|
||||
{
|
||||
get => _paginationDataGridViewModel;
|
||||
set => SetProperty(ref _paginationDataGridViewModel, value);
|
||||
}
|
||||
|
||||
private PageTenantInput _input;
|
||||
public PageTenantInput Input
|
||||
{
|
||||
get => _input;
|
||||
set => SetProperty(ref _input, value);
|
||||
}
|
||||
|
||||
public List<KeyValuePair<string, int>> StatusList =>
|
||||
Enum.GetValues(typeof(StatusEnum))
|
||||
.Cast<StatusEnum>()
|
||||
.Select(e => new KeyValuePair<string, int>(e.GetDescription(), (int)e))
|
||||
.ToList();
|
||||
|
||||
public DelegateCommand SearchCommand { get; }
|
||||
public DelegateCommand ResetCommand { get; }
|
||||
public DelegateCommand SyncCommand { get; }
|
||||
|
||||
public TenantManagementViewModel(
|
||||
ISysTenantSyncService tenantSyncService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_tenantSyncService = tenantSyncService;
|
||||
_paginationDataGridViewModel = new PaginationDataGridViewModel<TenantOutput>(FetchTenantsAsync);
|
||||
_input = new PageTenantInput();
|
||||
|
||||
SearchCommand = new DelegateCommand(async () => await SearchAsync());
|
||||
ResetCommand = new DelegateCommand(async () => await ResetAsync());
|
||||
SyncCommand = new DelegateCommand(async () => await SyncAsync());
|
||||
|
||||
_ = InitializeAsync();
|
||||
}
|
||||
|
||||
private async Task InitializeAsync()
|
||||
{
|
||||
await UIHelper.WaitForRenderAsync();
|
||||
await PaginationDataGridViewModel.LoadDataAsync();
|
||||
}
|
||||
|
||||
private async Task<(IEnumerable<TenantOutput> data, int totalCount)> FetchTenantsAsync()
|
||||
{
|
||||
Input.Page = PaginationDataGridViewModel.PageIndex;
|
||||
Input.PageSize = PaginationDataGridViewModel.DataCountPerPage;
|
||||
var result = await _tenantSyncService.PageAsync(Input);
|
||||
return (result.Items, result.Total);
|
||||
}
|
||||
|
||||
private async Task SearchAsync()
|
||||
{
|
||||
PaginationDataGridViewModel.PageIndex = 1;
|
||||
await PaginationDataGridViewModel.LoadDataAsync();
|
||||
}
|
||||
|
||||
private async Task ResetAsync()
|
||||
{
|
||||
Input = new PageTenantInput();
|
||||
await UIHelper.WaitForRenderAsync();
|
||||
await SearchAsync();
|
||||
}
|
||||
|
||||
private async Task SyncAsync()
|
||||
{
|
||||
var count = await _tenantSyncService.SyncFromJeecgAsync();
|
||||
if (count > 0)
|
||||
{
|
||||
Growl.Success($"同步完成,共处理 {count} 条租户数据");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("未同步到租户数据,请确认已使用Jeecg账号登录且后端可访问");
|
||||
}
|
||||
await SearchAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user