@page "/" @using MasaBlazorApp3.Util @using log4net @layout EmptyLayout @if (globalStateService.Operator != null) { //操作人:@globalStateService.Operator.NickName 操作人:@globalStateService.Operator.NickName } @if (globalStateService.Reviewer != null) { //复核人:@globalStateService.Reviewer.NickName 复核人:@globalStateService.Reviewer.NickName } { changeShifts(); })" /> 交接班 { logout(); })" /> jump2Page(1))"> 出库 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 10 < 10)) { } } jump2Page(2))" Style="height: 100%;width:50%"> 入库 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 20 > 0 && id - 20 < 10)) { } } jump2Page(6))" Style="height: 100%;width:50%"> 药箱管理 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 60 > 0 && id - 60 < 10)) { } } jump2Page(3))" Style="height: 43%;width:100%"> 归还 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 30 > 0 && id - 30 < 10)) { } } jump2Page(4))" Style="height: 100%;width:50%"> 库存管理 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 40 > 0 && id - 40 < 10)) { } } jump2Page(5))" Style="height: 100%;width:50%"> 系统管理 @if (globalStateService.Operator != null) { @if (!globalStateService.Operator.role.permissionIds.Any(id => id - 50 > 0 && id - 50 < 10)) { } } @code { @inject Radzen.DialogService dialogService; @inject NotificationService _message @inject NavigationManager na; @inject TooltipService tooltipService private List userPremissions { get; set; } = new(); @inject GlobalStateService globalStateService; Timer timer; @inject PortUtil _portUtil; private readonly ILog logger = LogManager.GetLogger(typeof(Home)); @inject Microsoft.Extensions.Options.IOptions setting; bool currentPage = true; protected override void OnInitialized() { // timer = new Timer(state => // { // var now = DateTime.Now; // InvokeAsync(StateHasChanged); // }, null, 0, 1000); if (setting.Value.autoOutLog > 0) { // 是否需要自动退出 var promiseUtil = new PromiseUtil(); promiseUtil.taskAsyncLoop(500, null, async (data, next, stop) => { if (globalStateService.Operator == null || !currentPage) { logger.Info($"Home页自动退出循环停止{globalStateService.Operator == null},{!currentPage}"); stop(); } else { try { //没有在操作抽屉 if (!_portUtil.Operate) { // 无人操作鼠标键盘 if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > setting.Value.autoOutLog && CheckComputerFreeState.GetLastInputTime() > setting.Value.autoOutLog) { logger.Info($"设备{setting.Value.autoOutLog}内无人操作,用户【{globalStateService.Operator?.NickName}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoOutLog:{setting.Value.autoOutLog}"); globalStateService.Operator = null; globalStateService.Reviewer = null; stop(); } else { next(); } } else { next(); } } catch (Exception ex) { logger.Info($"检查是否自动退出循环异常:{ex.Message}"); next(); } } }); } base.OnInitialized(); } public void Dispose() { timer?.Dispose(); } async void init() { var b = await dialogService.OpenAsync( $"调拨入库详情", new Dictionary() { }, new DialogOptions() { ShowTitle = false, Style = "min-height:auto;min-width:auto;width:auto", CloseDialogOnEsc = false, Resizable = true, Draggable = true, ShowClose = false } ); } protected override async Task OnAfterRenderAsync(bool firstRender) { base.OnAfterRender(firstRender); if (firstRender && !globalStateService.isInit) { this.init(); } } async void jump2Page(int parentId) { bool a = true; if ((setting.Value.loginMode == 2 && (globalStateService.Operator == null || globalStateService.Reviewer == null)) || setting.Value.loginMode == 1 && globalStateService.Operator == null) { a = await dialogService.OpenAsync( "", null, new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false }); } // bool a = globalStateService.Operator != null; // if (!a) // { // a = await dialogService.OpenAsync( // "", // null, // new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false }); // } if (a) { List childrenIds = globalStateService.Operator.role.permissionIds.Where(id => id - (parentId * 10) > 0 && id - (parentId * 10) < 10).ToList(); if (childrenIds.Count > 0) { currentPage = false; childrenIds.Sort(); int minId = childrenIds[0]; string path = new Premission().getAdminPremission().Find(p => p.Id == parentId).Items.ToList().Find(p2 => p2.Id == minId).PremissionPath; na.NavigateTo(path); } else { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"没有权限不能访问", Duration = 3000 } ); await InvokeAsync(StateHasChanged); } } } void logout() { if (globalStateService.Operator != null) { globalStateService.Operator = null; globalStateService.Reviewer = null; } else { Environment.Exit(0); } } //修改密码 async void EditPassword(int i) { //修改复核人 await dialogService.OpenAsync( "", new Dictionary() { { "userI", i } }, new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false }); } //交接班 async void changeShifts() { //修改复核人 await dialogService.OpenAsync( "", new Dictionary() { { "userI", 1 } }, new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false }); } }