221 lines
9.2 KiB
Plaintext
221 lines
9.2 KiB
Plaintext
|
@page "/home"
|
||
|
@using MasaBlazorApp3.Util
|
||
|
@using log4net
|
||
|
@layout EmptyLayout
|
||
|
|
||
|
<style>
|
||
|
.home-menu{
|
||
|
transition: box-shadow 0.3s ease; /* 平滑过渡阴影效果 */
|
||
|
cursor: pointer;
|
||
|
position: relative;
|
||
|
z-index: 1;
|
||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
|
||
|
}
|
||
|
|
||
|
.home-menu>h2{
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
|
||
|
|
||
|
.home-menu:hover {
|
||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7); /* 阴影效果 */
|
||
|
}
|
||
|
|
||
|
.mask {
|
||
|
position: absolute;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
background-color: black;
|
||
|
opacity: 0.6;
|
||
|
z-index: 2;
|
||
|
cursor: not-allowed;
|
||
|
}
|
||
|
|
||
|
.rz-gauge .rz-tick-text {
|
||
|
fill: #ffffff !important;
|
||
|
}
|
||
|
</style>
|
||
|
<RadzenStack Orientation="Orientation.Vertical" class="rz-background-color-primary-light" AlignItems="AlignItems.Center" Style="width:100vw;height:100vh" Gap="0">
|
||
|
|
||
|
<RadzenRow Style="width:100vw;height:25vh;" Gap="0" RowGap="0">
|
||
|
<RadzenColumn Size="4">
|
||
|
|
||
|
</RadzenColumn>
|
||
|
<RadzenColumn Size="8">
|
||
|
<RadzenRow Style="height: 100%;width:100%" Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
|
||
|
<RadzenColumn Size="3">
|
||
|
|
||
|
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">操作人:@Operator.NickName</RadzenText>
|
||
|
@if (Reviewer != null)
|
||
|
{
|
||
|
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">复核人:@Reviewer.NickName</RadzenText>
|
||
|
}
|
||
|
</RadzenColumn>
|
||
|
<RadzenColumn Size="3">
|
||
|
<RadzenIcon Icon="exit_to_app" Style="font-size:3rem;cursor: pointer;" class="rz-ripple" IconColor="white" @onclick="@(() => { logout(); })" />
|
||
|
</RadzenColumn>
|
||
|
</RadzenRow>
|
||
|
</RadzenColumn>
|
||
|
</RadzenRow>
|
||
|
|
||
|
<RadzenStack class="rz-background-color-info-lighter" Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" AlignItems="AlignItems.Center" Style="width: 75vw;height: 57vh" Gap="20">
|
||
|
|
||
|
<RadzenStack Style="height: 100%;width:41%" Gap="20">
|
||
|
<RadzenStack class="home-menu rz-background-color-info-lighter rz-ripple" JustifyContent="JustifyContent.Center" Style="height: 50%" @onclick="@(() => jump2Page(1))">
|
||
|
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center" >出库</RadzenText>
|
||
|
@if (!Operator.role.permissionIds.Any(id => id - 10 < 10))
|
||
|
{
|
||
|
<div class="mask">
|
||
|
<RadzenImage Path="images/no_auth.png" />
|
||
|
</div>
|
||
|
}
|
||
|
</RadzenStack>
|
||
|
<RadzenStack class="home-menu rz-background-color-success-light rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(2))" Style="height: 50%">
|
||
|
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">入库</RadzenText>
|
||
|
@if (!Operator.role.permissionIds.Any(id => id - 20 > 0 && id - 20 < 10))
|
||
|
{
|
||
|
<div class="mask">
|
||
|
<RadzenImage Path="images/no_auth.png" />
|
||
|
</div>
|
||
|
}
|
||
|
</RadzenStack>
|
||
|
</RadzenStack>
|
||
|
<RadzenStack Style="height: 100%;width:59%" Gap="20">
|
||
|
<RadzenStack class="home-menu rz-background-color-series-2 rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(3))" Style="height: 43%;width:100%">
|
||
|
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">归还</RadzenText>
|
||
|
@if (!Operator.role.permissionIds.Any(id => id - 30 > 0 && id - 30 < 10))
|
||
|
{
|
||
|
<div class="mask">
|
||
|
<RadzenImage Path="images/no_auth.png" />
|
||
|
</div>
|
||
|
}
|
||
|
</RadzenStack>
|
||
|
<RadzenStack Orientation="Orientation.Horizontal" Style="height: 57%;width:100%">
|
||
|
<RadzenStack class="home-menu rz-background-color-primary rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(4))" Style="height: 100%;width:50%">
|
||
|
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">库存管理</RadzenText>
|
||
|
@if (!Operator.role.permissionIds.Any(id => id - 40 > 0 && id - 40 < 10))
|
||
|
{
|
||
|
<div class="mask">
|
||
|
<RadzenImage Path="images/no_auth.png" />
|
||
|
</div>
|
||
|
}
|
||
|
</RadzenStack>
|
||
|
<RadzenStack class="home-menu rz-background-color-success-lighter rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(5))" Style="height: 100%;width:50%">
|
||
|
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">系统设置</RadzenText>
|
||
|
@if (!Operator.role.permissionIds.Any(id => id - 50 > 0 && id - 50 < 10))
|
||
|
{
|
||
|
<div class="mask">
|
||
|
<RadzenImage Path="images/no_auth.png" />
|
||
|
</div>
|
||
|
}
|
||
|
</RadzenStack>
|
||
|
|
||
|
</RadzenStack>
|
||
|
</RadzenStack>
|
||
|
</RadzenStack>
|
||
|
</RadzenStack>
|
||
|
|
||
|
|
||
|
@code {
|
||
|
@inject NavigationManager na;
|
||
|
@inject TooltipService tooltipService
|
||
|
private List<Premission> userPremissions { get; set; } = new();
|
||
|
@inject GlobalStateService globalStateService;
|
||
|
Pojo.User Operator;
|
||
|
Pojo.User Reviewer;
|
||
|
|
||
|
Timer timer;
|
||
|
@inject PortUtil _portUtil;
|
||
|
private readonly ILog logger = LogManager.GetLogger(typeof(Home));
|
||
|
@inject Microsoft.Extensions.Options.IOptions<Pojo.Config.SettingConfig> setting;
|
||
|
bool currentPage = true;
|
||
|
|
||
|
protected override void OnInitialized()
|
||
|
{
|
||
|
|
||
|
|
||
|
Operator = globalStateService.Operator;
|
||
|
Reviewer = globalStateService.Reviewer;
|
||
|
|
||
|
// timer = new Timer(state =>
|
||
|
// {
|
||
|
// var now = DateTime.Now;
|
||
|
|
||
|
|
||
|
// InvokeAsync(StateHasChanged);
|
||
|
// }, null, 0, 1000);
|
||
|
if (setting.Value.autoOutLog > 0)
|
||
|
{
|
||
|
// 是否需要自动退出
|
||
|
var promiseUtil = new PromiseUtil<object>();
|
||
|
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}内无人操作,用户【{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;
|
||
|
na.NavigateTo("");
|
||
|
stop();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
next();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
next();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
logger.Info($"检查是否自动退出循环异常:{ex.Message}");
|
||
|
next();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
base.OnInitialized();
|
||
|
}
|
||
|
|
||
|
public void Dispose()
|
||
|
{
|
||
|
timer?.Dispose();
|
||
|
}
|
||
|
|
||
|
void jump2Page(int parentId)
|
||
|
{
|
||
|
List<int> childrenIds = Operator.role.permissionIds.Where(id => id - (parentId * 10) > 0 && id - (parentId * 10) < 10).ToList();
|
||
|
if(childrenIds.Count > 0)
|
||
|
{
|
||
|
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);
|
||
|
currentPage = false;
|
||
|
}
|
||
|
}
|
||
|
void logout()
|
||
|
{
|
||
|
globalStateService.Operator = null;
|
||
|
globalStateService.Reviewer = null;
|
||
|
na.NavigateTo("");
|
||
|
}
|
||
|
}
|