HKC_Blazor/MasaBlazorApp3/Pages/Home.razor

491 lines
22 KiB
Plaintext
Raw Normal View History

2025-05-20 11:17:07 +08:00
@page "/"
2025-04-18 11:01:56 +08:00
@using MasaBlazorApp3.Util
@using log4net
@layout EmptyLayout
<style>
2025-05-20 11:17:07 +08:00
.home-menu {
2025-05-20 13:13:25 +08:00
transition: box-shadow 0.3s ease; /* 平滑过渡阴影效果 */
cursor: pointer;
position: relative;
z-index: 1;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
2025-04-18 11:01:56 +08:00
}
2025-05-20 13:13:25 +08:00
.home-menu > h2 {
font-weight: bold;
}
2025-04-18 11:01:56 +08:00
2025-05-20 13:13:25 +08:00
.home-menu:hover {
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7); /* 阴影效果 */
}
2025-04-18 11:01:56 +08:00
.mask {
2025-05-20 13:13:25 +08:00
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: black;
opacity: 0.6;
z-index: 2;
cursor: not-allowed;
2025-04-18 11:01:56 +08:00
}
.rz-gauge .rz-tick-text {
2025-05-20 13:13:25 +08:00
fill: #ffffff !important;
2025-04-18 11:01:56 +08:00
}
</style>
2025-05-20 11:17:07 +08:00
<RadzenStack Orientation="Orientation.Vertical" class="rz-background-color-primary-light" AlignItems="AlignItems.Center" Style="width:100vw;height:100vh" Gap="0">
2025-04-18 11:01:56 +08:00
<RadzenRow Style="width:100vw;height:25vh;" Gap="0" RowGap="0">
<RadzenColumn Size="4">
2025-05-20 11:17:07 +08:00
2025-04-18 11:01:56 +08:00
</RadzenColumn>
<RadzenColumn Size="8">
<RadzenRow Style="height: 100%;width:100%" Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
2025-08-11 14:58:39 +08:00
<RadzenColumn Size="3">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12">
<RadzenIcon Icon="language" Style="font-size:3rem;cursor: pointer;margin-left:-60px" class="rz-ripple" IconColor="white" />
<RadzenDropDown TValue="string" Value=@SelectedCulture Data=@languageNames Change="@(args => LanguageClick(args))" Style="width: 100%; max-width: 400px;" Name="DropDownChangeEvent" />
</RadzenStack>
</RadzenColumn>
2025-07-30 17:21:58 +08:00
<RadzenColumn Size="2">
2025-05-20 11:17:07 +08:00
@if (globalStateService.Operator != null)
{
//<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">操作人:@globalStateService.Operator.NickName</RadzenText>
//<RadzenText onclick="@(() => { EditPassword(1); })" Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">操作人:@globalStateService.Operator.NickName</RadzenText>
2025-07-30 17:21:58 +08:00
<RadzenProfileMenu prefix="" Click="MenuClick" Style="background-color:transparent;z-index:99">
<Template>
2025-08-11 14:58:39 +08:00
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">@myText.Operator @globalStateService.Operator.NickName</RadzenText>
2025-07-30 17:21:58 +08:00
</Template>
<ChildContent>
2025-08-11 14:58:39 +08:00
<RadzenProfileMenuItem Text="@myText.EnterFingerprint" Value="11" Icon="fingerprint"></RadzenProfileMenuItem>
<RadzenProfileMenuItem Text="@myText.EnterSign" Value="21" Icon="line_weight"></RadzenProfileMenuItem>
<RadzenProfileMenuItem Text="@myText.UpdatePassword" Value="31" Icon="password"></RadzenProfileMenuItem>
2025-07-30 17:21:58 +08:00
</ChildContent>
</RadzenProfileMenu>
2025-05-20 11:17:07 +08:00
}
@if (globalStateService.Reviewer != null)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
//<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">复核人:@globalStateService.Reviewer.NickName</RadzenText>
//<RadzenText onclick="@(() => { EditPassword(2); })" Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">复核人:@globalStateService.Reviewer.NickName</RadzenText>
2025-07-30 17:21:58 +08:00
<RadzenProfileMenu prefix="" Click="MenuClick" Style="background-color:transparent">
<Template>
2025-08-11 14:58:39 +08:00
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H5" TextAlign="TextAlign.Center">@myText.Checker@globalStateService.Reviewer.NickName</RadzenText>
2025-07-30 17:21:58 +08:00
</Template>
<ChildContent>
2025-08-11 14:58:39 +08:00
<RadzenProfileMenuItem Text="@myText.EnterFingerprint" Value="12" Icon="fingerprint"></RadzenProfileMenuItem>
<RadzenProfileMenuItem Text="@myText.EnterSign" Value="22" Icon="line_weight"></RadzenProfileMenuItem>
<RadzenProfileMenuItem Text="@myText.UpdatePassword" Value="32" Icon="password"></RadzenProfileMenuItem>
2025-07-30 17:21:58 +08:00
</ChildContent>
</RadzenProfileMenu>
2025-04-18 11:01:56 +08:00
}
</RadzenColumn>
<RadzenColumn Size="3">
2025-07-30 17:21:58 +08:00
<div @onclick="@(() => { changeShifts(); })">
<RadzenIcon Icon="compare_arrows" Style="font-size:3rem;cursor: pointer;" class="rz-ripple" IconColor="white" />
2025-08-11 14:58:39 +08:00
<div>@myText.Handover</div>
2025-07-05 10:07:33 +08:00
</div>
2025-07-30 17:21:58 +08:00
<div style="clear:both"></div>
2025-07-05 10:07:33 +08:00
</RadzenColumn>
<RadzenColumn Size="2">
2025-07-30 17:21:58 +08:00
<RadzenIcon Icon="exit_to_app" Style="font-size:3rem;cursor: pointer;margin-left:-60px" class="rz-ripple" IconColor="white" @onclick="@(() => { logout(); })" />
2025-04-18 11:01:56 +08:00
</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">
2025-05-20 11:17:07 +08:00
2025-04-18 11:01:56 +08:00
<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))">
2025-08-11 14:58:39 +08:00
<RadzenText Style="" class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.Outbound</RadzenText>
2025-05-20 11:17:07 +08:00
@if (globalStateService.Operator != null)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 10 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
2025-04-18 11:01:56 +08:00
}
</RadzenStack>
2025-07-05 10:07:33 +08:00
<RadzenStack Orientation="Orientation.Horizontal" Style="height: 50%;width:100%">
2025-07-30 17:21:58 +08:00
<RadzenStack class="home-menu rz-background-color-success-light rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(2))" Style="height: 100%;width:50%">
2025-08-11 14:58:39 +08:00
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.FillStorage</RadzenText>
2025-07-05 10:07:33 +08:00
@if (globalStateService.Operator != null)
2025-05-20 11:17:07 +08:00
{
2025-07-05 10:07:33 +08:00
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 20 > 0 && id - 20 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
2025-05-20 11:17:07 +08:00
}
2025-07-05 10:07:33 +08:00
</RadzenStack>
<RadzenStack class="home-menu rz-background-color-danger-lighter rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(6))" Style="height: 100%;width:50%">
2025-08-11 14:58:39 +08:00
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.BoxManage</RadzenText>
2025-07-05 10:07:33 +08:00
@if (globalStateService.Operator != null)
{
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 60 > 0 && id - 60 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
}
</RadzenStack>
2025-04-18 11:01:56 +08:00
</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%">
2025-08-11 14:58:39 +08:00
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.Return</RadzenText>
2025-05-20 11:17:07 +08:00
@if (globalStateService.Operator != null)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 30 > 0 && id - 30 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
2025-04-18 11:01:56 +08:00
}
</RadzenStack>
2025-05-20 11:17:07 +08:00
<RadzenStack Orientation="Orientation.Horizontal" Style="height: 57%;width:100%">
2025-04-18 11:01:56 +08:00
<RadzenStack class="home-menu rz-background-color-primary rz-text-white rz-ripple" JustifyContent="JustifyContent.Center" @onclick="@(() => jump2Page(4))" Style="height: 100%;width:50%">
2025-08-11 14:58:39 +08:00
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.StockManage</RadzenText>
2025-05-20 11:17:07 +08:00
@if (globalStateService.Operator != null)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 40 > 0 && id - 40 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
2025-04-18 11:01:56 +08:00
}
</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%">
2025-08-11 14:58:39 +08:00
<RadzenText class="rz-color-white" TextStyle="TextStyle.H2" TextAlign="TextAlign.Center">@myText.SystemManage</RadzenText>
2025-05-20 11:17:07 +08:00
@if (globalStateService.Operator != null)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
@if (!globalStateService.Operator.role.permissionIds.Any(id => id - 50 > 0 && id - 50 < 10))
{
<div class="mask">
<RadzenImage Path="images/no_auth.png" />
</div>
}
2025-04-18 11:01:56 +08:00
}
</RadzenStack>
2025-05-20 11:17:07 +08:00
2025-04-18 11:01:56 +08:00
</RadzenStack>
</RadzenStack>
</RadzenStack>
</RadzenStack>
@code {
2025-05-20 11:17:07 +08:00
@inject Radzen.DialogService dialogService;
@inject NotificationService _message
2025-04-18 11:01:56 +08:00
@inject NavigationManager na;
@inject TooltipService tooltipService
private List<Premission> userPremissions { get; set; } = new();
@inject GlobalStateService globalStateService;
2025-08-11 14:58:39 +08:00
@inject Toolbelt.Blazor.I18nText.I18nText I18nText;
2025-04-18 11:01:56 +08:00
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;
2025-08-11 14:58:39 +08:00
public static I18nText.local myText = new I18nText.local();
IEnumerable<string> languageNames;
private string culture;
private string SelectedCulture
2025-04-18 11:01:56 +08:00
{
2025-08-11 14:58:39 +08:00
get => culture;
set { }
}
protected override async Task OnInitializedAsync()
{
languageNames = new List<string> { "简体中文", "English" };
myText = await I18nText.GetTextTableAsync<I18nText.local>(this);
2025-04-18 11:01:56 +08:00
if (setting.Value.autoOutLog > 0)
{
// 是否需要自动退出
var promiseUtil = new PromiseUtil<object>();
promiseUtil.taskAsyncLoop(500, null, async (data, next, stop) =>
{
if (globalStateService.Operator == null || !currentPage)
{
2025-05-20 11:17:07 +08:00
logger.Info($"Home页自动退出循环停止{globalStateService.Operator == null},{!currentPage}");
2025-04-18 11:01:56 +08:00
stop();
}
else
{
try
{
//没有在操作抽屉
if (!_portUtil.Operate)
{
// 无人操作鼠标键盘
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > setting.Value.autoOutLog && CheckComputerFreeState.GetLastInputTime() > setting.Value.autoOutLog)
{
2025-05-20 11:17:07 +08:00
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}");
2025-04-18 11:01:56 +08:00
globalStateService.Operator = null;
globalStateService.Reviewer = null;
stop();
}
else
{
next();
}
}
else
{
next();
}
}
catch (Exception ex)
{
logger.Info($"检查是否自动退出循环异常:{ex.Message}");
next();
}
}
});
}
2025-08-11 14:58:39 +08:00
culture = I18nText.GetCurrentLanguageAsync().Result == "en-US" ? "English" : "简体中文";
base.OnInitializedAsync();
2025-04-18 11:01:56 +08:00
}
2025-08-11 14:58:39 +08:00
// 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<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}内无人操作,用户【{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();
// }
2025-04-18 11:01:56 +08:00
public void Dispose()
{
timer?.Dispose();
}
2025-05-20 11:17:07 +08:00
async void init()
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
var b = await dialogService.OpenAsync<InitPage>(
$"调拨入库详情",
new Dictionary<string, object>() { },
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)
2025-04-18 11:01:56 +08:00
{
2025-05-20 11:17:07 +08:00
this.init();
}
}
async void jump2Page(int parentId)
{
2025-05-20 13:13:25 +08:00
bool a = true;
if ((setting.Value.loginMode == 2 && (globalStateService.Operator == null || globalStateService.Reviewer == null))
|| setting.Value.loginMode == 1 && globalStateService.Operator == null)
2025-05-20 11:17:07 +08:00
{
a = await dialogService.OpenAsync<LoginDialog>(
2025-05-20 13:13:25 +08:00
"",
null,
new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false });
2025-05-20 11:17:07 +08:00
}
2025-05-20 13:13:25 +08:00
// bool a = globalStateService.Operator != null;
// if (!a)
// {
// a = await dialogService.OpenAsync<LoginDialog>(
// "",
// null,
// new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false });
// }
2025-05-20 11:17:07 +08:00
if (a)
{
List<int> 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);
}
2025-04-18 11:01:56 +08:00
}
}
void logout()
{
2025-05-20 11:17:07 +08:00
if (globalStateService.Operator != null)
{
globalStateService.Operator = null;
globalStateService.Reviewer = null;
}
else
{
Environment.Exit(0);
}
}
//修改密码
async void EditPassword(int i)
{
2025-05-20 13:13:25 +08:00
//修改复核人
await dialogService.OpenAsync<EditPasswordDialog>(
"",
new Dictionary<string, object>() { { "userI", i } },
new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false });
2025-04-18 11:01:56 +08:00
}
async void MenuClick(RadzenProfileMenuItem item)
{
2025-07-30 17:21:58 +08:00
string strValue = item.Value.Substring(0, 1);
Pojo.User user = new Pojo.User();
2025-07-30 17:21:58 +08:00
switch (strValue)
{
case "1":
int userId = 0;
if (item.Value == "11")
{
user = globalStateService.Operator;
}
else
{
user = globalStateService.Reviewer;
}
await dialogService.OpenAsync<FingerRegDialog>(
$"录入指纹-{user.Username}",
new Dictionary<string, object>() { { "userId", user.Id } },
new DialogOptions() { Width = "55vw", Resizable = true, Draggable = false, ShowClose = false }
);
break;
case "2":
2025-07-30 17:21:58 +08:00
if (item.Value == "21")
{
user = globalStateService.Operator;
}
else
{
user = globalStateService.Reviewer;
}
await dialogService.OpenAsync<SignatureDialog>(
$"签名-{user.NickName}",
new Dictionary<string, object>() { { "user", user } },
new DialogOptions() { Width = "55vw", Resizable = true, Draggable = false, ShowClose = true }
);
break;
case "3":
if (item.Value == "31")
{
user = globalStateService.Operator;
}
else
{
user = globalStateService.Reviewer;
}
2025-07-30 17:21:58 +08:00
int userI = Convert.ToInt32(item.Value.Substring(1, 1));
await dialogService.OpenAsync<EditPasswordDialog>(
$"修改密码-{user.Username}",
2025-07-30 17:21:58 +08:00
new Dictionary<string, object>() { { "userI", userI } },
new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = true }
);
break;
}
}
2025-07-05 10:07:33 +08:00
//交接班
async void changeShifts()
{
//修改复核人
await dialogService.OpenAsync<ChangeShifts>(
"",
new Dictionary<string, object>() { { "userI", 1 } },
new DialogOptions() { Width = "55vw", Resizable = false, Draggable = false, ShowClose = false, ShowTitle = false });
}
2025-08-11 14:58:39 +08:00
async void LanguageClick(object item)
{
string culture = string.Empty;// new System.Globalization.CultureInfo(item.Value);
switch (item.ToString())
{
case "简体中文":
culture = "zh-CN";
break;
case "English":
culture = "en-US";
break;
}
await I18nText.SetCurrentLanguageAsync(culture);
}
2025-04-18 11:01:56 +08:00
}