新增MES模块,包含供应商、客户、车辆和地磅数据记录管理功能,支持免密接口和数据同步。更新相关控制器、实体、服务和数据库配置,优化权限管理和数据字典支持,确保系统的灵活性和可扩展性。
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Ioc;
|
||||
using YY.Admin.Core.Const;
|
||||
using YY.Admin.Services.Service.Config;
|
||||
|
||||
namespace YY.Admin.ViewModels.SysManage;
|
||||
|
||||
/// <summary>
|
||||
/// 登录与会话相关系统配置
|
||||
/// </summary>
|
||||
public class LoginSettingsViewModel : BaseViewModel
|
||||
{
|
||||
private readonly ISysConfigService _configService;
|
||||
|
||||
private int _tokenExpireMinutes = 30;
|
||||
public int TokenExpireMinutes
|
||||
{
|
||||
get => _tokenExpireMinutes;
|
||||
set => SetProperty(ref _tokenExpireMinutes, value);
|
||||
}
|
||||
|
||||
private int _refreshTokenExpireMinutes = 20160;
|
||||
public int RefreshTokenExpireMinutes
|
||||
{
|
||||
get => _refreshTokenExpireMinutes;
|
||||
set => SetProperty(ref _refreshTokenExpireMinutes, value);
|
||||
}
|
||||
|
||||
private int _idleExtendMinutes = 20;
|
||||
public int IdleExtendMinutes
|
||||
{
|
||||
get => _idleExtendMinutes;
|
||||
set => SetProperty(ref _idleExtendMinutes, value);
|
||||
}
|
||||
|
||||
private int _checkIntervalMinutes = 1;
|
||||
public int CheckIntervalMinutes
|
||||
{
|
||||
get => _checkIntervalMinutes;
|
||||
set => SetProperty(ref _checkIntervalMinutes, value);
|
||||
}
|
||||
|
||||
private bool _neverExpire;
|
||||
public bool NeverExpire
|
||||
{
|
||||
get => _neverExpire;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _neverExpire, value))
|
||||
RaisePropertyChanged(nameof(IsConfigEditable));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsConfigEditable => !NeverExpire;
|
||||
|
||||
public DelegateCommand LoadCommand { get; }
|
||||
public DelegateCommand SaveCommand { get; }
|
||||
|
||||
public LoginSettingsViewModel(
|
||||
ISysConfigService configService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_configService = configService;
|
||||
LoadCommand = new DelegateCommand(async () => await LoadAsync());
|
||||
SaveCommand = new DelegateCommand(async () => await SaveAsync());
|
||||
_ = LoadAsync();
|
||||
}
|
||||
|
||||
private async Task LoadAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var t = await _configService.GetConfigValue<int>(ConfigConst.SysTokenExpire);
|
||||
TokenExpireMinutes = t > 0 ? t : 30;
|
||||
|
||||
var r = await _configService.GetConfigValue<int>(ConfigConst.SysRefreshTokenExpire);
|
||||
RefreshTokenExpireMinutes = r > 0 ? r : 20160;
|
||||
|
||||
var i = await _configService.GetConfigValue<int>(ConfigConst.SysTokenIdleExtendMinutes);
|
||||
IdleExtendMinutes = i > 0 ? i : 20;
|
||||
|
||||
var c = await _configService.GetConfigValue<int>(ConfigConst.SysTokenCheckIntervalMinutes);
|
||||
CheckIntervalMinutes = c > 0 ? c : 1;
|
||||
|
||||
NeverExpire = await _configService.GetConfigValue<bool>(ConfigConst.SysTokenNeverExpire);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error($"加载配置失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (!NeverExpire && (TokenExpireMinutes < 5 || TokenExpireMinutes > 43200))
|
||||
{
|
||||
Growl.Warning("Token 过期时间建议在 5~43200 分钟之间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NeverExpire && (IdleExtendMinutes < 1 || IdleExtendMinutes > 1440))
|
||||
{
|
||||
Growl.Warning("会话续期阈值建议在 1~1440 分钟之间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NeverExpire && IdleExtendMinutes > TokenExpireMinutes)
|
||||
{
|
||||
Growl.Warning("续期阈值不应大于 Token 过期时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NeverExpire && (CheckIntervalMinutes < 1 || CheckIntervalMinutes > 120))
|
||||
{
|
||||
Growl.Warning("登录状态检查间隔建议在 1~120 分钟之间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NeverExpire && RefreshTokenExpireMinutes < TokenExpireMinutes * 2)
|
||||
{
|
||||
Growl.Warning("RefreshToken 过期时间建议不小于 Token 过期时间的 2 倍");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var pairs = new[]
|
||||
{
|
||||
(ConfigConst.SysTokenExpire, TokenExpireMinutes.ToString()),
|
||||
(ConfigConst.SysRefreshTokenExpire, RefreshTokenExpireMinutes.ToString()),
|
||||
(ConfigConst.SysTokenIdleExtendMinutes, IdleExtendMinutes.ToString()),
|
||||
(ConfigConst.SysTokenCheckIntervalMinutes, CheckIntervalMinutes.ToString()),
|
||||
(ConfigConst.SysTokenNeverExpire, NeverExpire.ToString()),
|
||||
};
|
||||
|
||||
foreach (var (code, val) in pairs)
|
||||
{
|
||||
var (ok, msg) = await _configService.SetConfigValueAsync(code, val);
|
||||
if (!ok)
|
||||
{
|
||||
Growl.Warning($"{code}:{msg}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Growl.Success("登录相关配置已保存");
|
||||
BaseViewModel.RefreshTokenCheckIntervalFromConfig();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error($"保存失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Extension;
|
||||
using YY.Admin.Event;
|
||||
using YY.Admin.Services.Service.Menu;
|
||||
|
||||
namespace YY.Admin.ViewModels.SysManage;
|
||||
|
||||
/// <summary>
|
||||
/// 左侧列表一行(树形扁平展示)
|
||||
/// </summary>
|
||||
public sealed class MenuFlatRow
|
||||
{
|
||||
public SysMenu Menu { get; }
|
||||
public int Depth { get; }
|
||||
public string IndentTitle { get; }
|
||||
|
||||
public MenuFlatRow(SysMenu menu, int depth)
|
||||
{
|
||||
Menu = menu;
|
||||
Depth = depth;
|
||||
var pad = new string(' ', depth);
|
||||
var tag = menu.Type == MenuTypeEnum.Dir ? "[目录] " : menu.Type == MenuTypeEnum.Btn ? "[按钮] " : "[菜单] ";
|
||||
IndentTitle = pad + tag + menu.Title;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可编辑字段(与界面绑定)
|
||||
/// </summary>
|
||||
public class MenuEditorModel : BindableBase
|
||||
{
|
||||
private long _id;
|
||||
private long _pid;
|
||||
private MenuTypeEnum _type = MenuTypeEnum.Menu;
|
||||
private string? _name;
|
||||
private string? _path;
|
||||
private string? _component;
|
||||
private string? _redirect;
|
||||
private string? _permission;
|
||||
private string _title = string.Empty;
|
||||
private string? _icon;
|
||||
private bool _isIframe;
|
||||
private string? _outLink;
|
||||
private bool _isHide;
|
||||
private bool _isKeepAlive = true;
|
||||
private bool _isAffix;
|
||||
private int _orderNo = 100;
|
||||
private StatusEnum _status = StatusEnum.Enable;
|
||||
private string? _remark;
|
||||
|
||||
public long Id { get => _id; set => SetProperty(ref _id, value); }
|
||||
public long Pid { get => _pid; set => SetProperty(ref _pid, value); }
|
||||
public MenuTypeEnum Type { get => _type; set => SetProperty(ref _type, value); }
|
||||
public string? Name { get => _name; set => SetProperty(ref _name, value); }
|
||||
public string? Path { get => _path; set => SetProperty(ref _path, value); }
|
||||
public string? Component { get => _component; set => SetProperty(ref _component, value); }
|
||||
public string? Redirect { get => _redirect; set => SetProperty(ref _redirect, value); }
|
||||
public string? Permission { get => _permission; set => SetProperty(ref _permission, value); }
|
||||
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
||||
public string? Icon { get => _icon; set => SetProperty(ref _icon, value); }
|
||||
public bool IsIframe { get => _isIframe; set => SetProperty(ref _isIframe, value); }
|
||||
public string? OutLink { get => _outLink; set => SetProperty(ref _outLink, value); }
|
||||
public bool IsHide { get => _isHide; set => SetProperty(ref _isHide, value); }
|
||||
public bool IsKeepAlive { get => _isKeepAlive; set => SetProperty(ref _isKeepAlive, value); }
|
||||
public bool IsAffix { get => _isAffix; set => SetProperty(ref _isAffix, value); }
|
||||
public int OrderNo { get => _orderNo; set => SetProperty(ref _orderNo, value); }
|
||||
public StatusEnum Status { get => _status; set => SetProperty(ref _status, value); }
|
||||
public string? Remark { get => _remark; set => SetProperty(ref _remark, value); }
|
||||
|
||||
public bool IsNew => Id == 0;
|
||||
|
||||
public void LoadFrom(SysMenu m)
|
||||
{
|
||||
Id = m.Id;
|
||||
Pid = m.Pid;
|
||||
Type = m.Type;
|
||||
Name = m.Name;
|
||||
Path = m.Path;
|
||||
Component = m.Component;
|
||||
Redirect = m.Redirect;
|
||||
Permission = m.Permission;
|
||||
Title = m.Title;
|
||||
Icon = m.Icon;
|
||||
IsIframe = m.IsIframe;
|
||||
OutLink = m.OutLink;
|
||||
IsHide = m.IsHide;
|
||||
IsKeepAlive = m.IsKeepAlive;
|
||||
IsAffix = m.IsAffix;
|
||||
OrderNo = m.OrderNo;
|
||||
Status = m.Status;
|
||||
Remark = m.Remark;
|
||||
}
|
||||
|
||||
public SysMenu ToSysMenu()
|
||||
{
|
||||
return new SysMenu
|
||||
{
|
||||
Id = Id,
|
||||
Pid = Pid,
|
||||
Type = Type,
|
||||
Name = Name,
|
||||
Path = Path,
|
||||
Component = Component,
|
||||
Redirect = Redirect,
|
||||
Permission = Permission,
|
||||
Title = Title.Trim(),
|
||||
Icon = Icon,
|
||||
IsIframe = IsIframe,
|
||||
OutLink = OutLink,
|
||||
IsHide = IsHide,
|
||||
IsKeepAlive = IsKeepAlive,
|
||||
IsAffix = IsAffix,
|
||||
OrderNo = OrderNo,
|
||||
Status = Status,
|
||||
Remark = Remark
|
||||
};
|
||||
}
|
||||
|
||||
public void ResetForNew(long pid, MenuTypeEnum type)
|
||||
{
|
||||
Id = 0;
|
||||
Pid = pid;
|
||||
Type = type;
|
||||
Name = null;
|
||||
Path = null;
|
||||
Component = null;
|
||||
Redirect = null;
|
||||
Permission = null;
|
||||
Title = type == MenuTypeEnum.Dir ? "新目录" : type == MenuTypeEnum.Menu ? "新菜单" : "新按钮";
|
||||
Icon = "";
|
||||
IsIframe = false;
|
||||
OutLink = null;
|
||||
IsHide = false;
|
||||
IsKeepAlive = true;
|
||||
IsAffix = false;
|
||||
OrderNo = 100;
|
||||
Status = StatusEnum.Enable;
|
||||
Remark = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class MenuManagementViewModel : BaseViewModel
|
||||
{
|
||||
private readonly ISysMenuService _menuService;
|
||||
|
||||
public ObservableCollection<MenuFlatRow> FlatRows { get; } = new();
|
||||
public ObservableCollection<KeyValuePair<long, string>> ParentOptions { get; } = new();
|
||||
|
||||
private MenuFlatRow? _selectedRow;
|
||||
public MenuFlatRow? SelectedRow
|
||||
{
|
||||
get => _selectedRow;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _selectedRow, value))
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
Editor = null;
|
||||
RaisePropertyChanged(nameof(Editor));
|
||||
RaisePropertyChanged(nameof(HasEditor));
|
||||
}
|
||||
else
|
||||
{
|
||||
Editor ??= new MenuEditorModel();
|
||||
Editor.LoadFrom(value.Menu);
|
||||
RaisePropertyChanged(nameof(Editor));
|
||||
RaisePropertyChanged(nameof(HasEditor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MenuEditorModel? _editor;
|
||||
public MenuEditorModel? Editor
|
||||
{
|
||||
get => _editor;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _editor, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(HasEditor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasEditor => Editor != null;
|
||||
|
||||
public List<KeyValuePair<string, int>> StatusList =>
|
||||
Enum.GetValues(typeof(StatusEnum))
|
||||
.Cast<StatusEnum>()
|
||||
.Select(e => new KeyValuePair<string, int>(e.GetDescription(), (int)e))
|
||||
.ToList();
|
||||
|
||||
public List<KeyValuePair<string, int>> MenuTypeList =>
|
||||
Enum.GetValues(typeof(MenuTypeEnum))
|
||||
.Cast<MenuTypeEnum>()
|
||||
.Select(e => new KeyValuePair<string, int>(e.GetDescription(), (int)e))
|
||||
.ToList();
|
||||
|
||||
public DelegateCommand RefreshCommand { get; }
|
||||
public DelegateCommand AddRootCommand { get; }
|
||||
public DelegateCommand AddChildCommand { get; }
|
||||
public DelegateCommand SaveCommand { get; }
|
||||
public DelegateCommand DeleteCommand { get; }
|
||||
|
||||
public MenuManagementViewModel(
|
||||
ISysMenuService menuService,
|
||||
IContainerExtension container,
|
||||
IRegionManager regionManager) : base(container, regionManager)
|
||||
{
|
||||
_menuService = menuService;
|
||||
|
||||
RefreshCommand = new DelegateCommand(async () => await RefreshAsync());
|
||||
AddRootCommand = new DelegateCommand(() => BeginNew(0, MenuTypeEnum.Dir));
|
||||
AddChildCommand = new DelegateCommand(BeginNewChild, () => SelectedRow != null)
|
||||
.ObservesProperty(() => SelectedRow);
|
||||
SaveCommand = new DelegateCommand(async () => await SaveAsync(), () => Editor != null)
|
||||
.ObservesProperty(() => Editor);
|
||||
DeleteCommand = new DelegateCommand(async () => await DeleteAsync(), () => SelectedRow != null && SelectedRow.Menu.Id != 0)
|
||||
.ObservesProperty(() => SelectedRow);
|
||||
|
||||
_ = RefreshAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var all = await _menuService.GetAllMenusForManageAsync();
|
||||
RebuildFlat(all);
|
||||
RebuildParentOptions(all);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error($"加载菜单失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RebuildFlat(List<SysMenu> all)
|
||||
{
|
||||
FlatRows.Clear();
|
||||
void Walk(long pid, int depth)
|
||||
{
|
||||
foreach (var m in all.Where(x => x.Pid == pid).OrderBy(x => x.OrderNo).ThenBy(x => x.Id))
|
||||
{
|
||||
FlatRows.Add(new MenuFlatRow(m, depth));
|
||||
Walk(m.Id, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Walk(0, 0);
|
||||
}
|
||||
|
||||
private void RebuildParentOptions(List<SysMenu> all)
|
||||
{
|
||||
ParentOptions.Clear();
|
||||
ParentOptions.Add(new KeyValuePair<long, string>(0, "(根目录)"));
|
||||
void Walk(long pid, int depth)
|
||||
{
|
||||
foreach (var m in all.Where(x => x.Pid == pid).OrderBy(x => x.OrderNo).ThenBy(x => x.Id))
|
||||
{
|
||||
var indent = new string(' ', depth);
|
||||
ParentOptions.Add(new KeyValuePair<long, string>(m.Id, indent + m.Title));
|
||||
Walk(m.Id, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Walk(0, 0);
|
||||
}
|
||||
|
||||
private void BeginNew(long pid, MenuTypeEnum type)
|
||||
{
|
||||
// 先取消列表选中,避免 setter 把新建的 Editor 清空
|
||||
_selectedRow = null;
|
||||
RaisePropertyChanged(nameof(SelectedRow));
|
||||
Editor = new MenuEditorModel();
|
||||
Editor.ResetForNew(pid, type);
|
||||
RaisePropertyChanged(nameof(Editor));
|
||||
RaisePropertyChanged(nameof(HasEditor));
|
||||
}
|
||||
|
||||
private void BeginNewChild()
|
||||
{
|
||||
if (SelectedRow == null)
|
||||
return;
|
||||
BeginNew(SelectedRow.Menu.Id, MenuTypeEnum.Menu);
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (Editor == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var entity = Editor.ToSysMenu();
|
||||
if (Editor.IsNew)
|
||||
{
|
||||
var (ok, msg, id) = await _menuService.CreateMenuAsync(entity);
|
||||
if (ok)
|
||||
{
|
||||
Growl.Success(msg);
|
||||
_eventAggregator.GetEvent<MenuStructureChangedEvent>().Publish(true);
|
||||
await RefreshAsync();
|
||||
SelectedRow = FlatRows.FirstOrDefault(r => r.Menu.Id == id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var (ok, msg) = await _menuService.UpdateMenuAsync(entity);
|
||||
if (ok)
|
||||
{
|
||||
Growl.Success(msg);
|
||||
_eventAggregator.GetEvent<MenuStructureChangedEvent>().Publish(true);
|
||||
var keepId = entity.Id;
|
||||
await RefreshAsync();
|
||||
SelectedRow = FlatRows.FirstOrDefault(r => r.Menu.Id == keepId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error($"保存失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteAsync()
|
||||
{
|
||||
if (SelectedRow == null)
|
||||
return;
|
||||
|
||||
var r = System.Windows.MessageBox.Show(
|
||||
$"确定删除「{SelectedRow.Menu.Title}」?若存在子菜单将无法删除。",
|
||||
"确认删除",
|
||||
System.Windows.MessageBoxButton.OKCancel,
|
||||
System.Windows.MessageBoxImage.Question);
|
||||
if (r != System.Windows.MessageBoxResult.OK)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
var (ok, msg) = await _menuService.DeleteMenuAsync(SelectedRow.Menu.Id);
|
||||
if (ok)
|
||||
{
|
||||
Growl.Success(msg);
|
||||
_eventAggregator.GetEvent<MenuStructureChangedEvent>().Publish(true);
|
||||
Editor = null;
|
||||
SelectedRow = null;
|
||||
await RefreshAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning(msg);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error($"删除失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,14 +135,12 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
SysUser = new SysUser
|
||||
{
|
||||
Id = user.Id,
|
||||
//Account = user.Account,
|
||||
Account = user.Account,
|
||||
RealName = user.RealName,
|
||||
NickName = user.NickName,
|
||||
//Phone = user.Phone,
|
||||
Sex = user.Sex,
|
||||
Birthday = user.Birthday,
|
||||
Age = user.Age,
|
||||
//AccountType = user.AccountType,
|
||||
Status = user.Status
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Windows;
|
||||
using YY.Admin.Core;
|
||||
using YY.Admin.Core.Extension;
|
||||
using YY.Admin.Core.Helper;
|
||||
using YY.Admin.Infrastructure.Sync;
|
||||
using YY.Admin.Services.Service;
|
||||
using YY.Admin.Services.Service.User;
|
||||
using YY.Admin.ViewModels.Control;
|
||||
@@ -20,9 +21,11 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
private PageUserInput _userInput;
|
||||
|
||||
private readonly ISysUserService _sysUserService;
|
||||
private readonly OutboxProcessor _outboxProcessor;
|
||||
|
||||
private readonly IDialogService _dialogService;
|
||||
private SubscriptionToken? _jeecgSyncToken;
|
||||
private bool _isManualUploading;
|
||||
public PaginationDataGridViewModel<UserOutput> PaginationDataGridViewModel
|
||||
{
|
||||
get => _paginationDataGridViewModel;
|
||||
@@ -94,6 +97,7 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
public DelegateCommand<UserOutput> EditCommand { get; private set; }
|
||||
|
||||
public DelegateCommand<UserOutput> StatusToggleCommand { get; private set; }
|
||||
public DelegateCommand ManualUploadCommand { get; private set; }
|
||||
|
||||
|
||||
// 行选择改变命令
|
||||
@@ -101,12 +105,14 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
|
||||
public UserManagementViewModel(
|
||||
ISysUserService sysUserService,
|
||||
OutboxProcessor outboxProcessor,
|
||||
IContainerExtension container,
|
||||
IDialogService dialogService,
|
||||
IRegionManager regionManager
|
||||
) : base(container, regionManager)
|
||||
{
|
||||
_sysUserService= sysUserService;
|
||||
_outboxProcessor = outboxProcessor;
|
||||
_dialogService = dialogService;
|
||||
// 创建分页控件的 ViewModel,传递一个获取数据的委托
|
||||
_paginationDataGridViewModel = new PaginationDataGridViewModel<UserOutput>(FetchUsersAsync);
|
||||
@@ -132,6 +138,7 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
EditCommand = new DelegateCommand<UserOutput>(async (user) => await ShowEditDialog(user));
|
||||
|
||||
StatusToggleCommand = new DelegateCommand<UserOutput>(async (user) => await ToggleStatus(user));
|
||||
ManualUploadCommand = new DelegateCommand(async () => await ManualUploadAsync(), () => !_isManualUploading);
|
||||
|
||||
//RowSelectionChangedCommand = new DelegateCommand<UserOutput>(OnRowSelectionChanged);
|
||||
|
||||
@@ -457,6 +464,31 @@ namespace YY.Admin.ViewModels.SysManage
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ManualUploadAsync()
|
||||
{
|
||||
if (_isManualUploading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isManualUploading = true;
|
||||
ManualUploadCommand.RaiseCanExecuteChanged();
|
||||
try
|
||||
{
|
||||
await _outboxProcessor.FlushPendingAsync(CancellationToken.None);
|
||||
Growl.Success("已触发手动上传,请稍后查看后端数据。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Warning($"手动上传失败:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isManualUploading = false;
|
||||
ManualUploadCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// 全选/取消全选方法
|
||||
//private void SelectAll(bool isSelected)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user