仓库管理系统26--权限设置

news2024/10/6 6:22:10

原创不易,打字不易,截图不易,多多点赞,送人玫瑰,留有余香,财务自由明日实现 

1、权限概述 

在应用软件中,通常将软件的功能分为若干个子程序,通过主程序调用。那么,通过众多客户来说,如果设置各人的权限呢?软件系统的权限控制几乎是非常常见且必备的,这篇文章整理下常见的九种模型,几乎基本够你用了,主流的权限模型主要有以下9种:

1、ACL模型

访问控制列表

2、DAC模型

自主访问控制

3、MAC模型

强制访问控制

4、ABAC模型

基于属性的访问控制,更灵活复杂

5、RBAC模型

基于角色的权限访问控制,最常用

6、TBAC模型

基于任务和工作流的访问控制

7、T-RBAC模型

基于任务和角色的访问控制

8、OBAC模型

基于对象的访问控制

9、UCON模型

使用控制模型 

2、权限实现

 本项目没有采用复杂的权限管理,只采用最简单的操作方法,具体是根据不同角色隐藏或显示菜单,具体实现方法是:

1)创建转换器对象

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace West.StoreMgr.Helper.Converter
{
    /// <summary>
    /// 菜单权限转换器
    /// </summary>
    public class AdminVisibleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return Visibility.Collapsed;
            if (int.TryParse(value.ToString(), out int index))
            {
                return index == 0 ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

 

2、主界面引入转换器  

<Window x:Class="West.StoreMgr.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:West.StoreMgr" 
        xmlns:Control="clr-namespace:West.StoreMgr.Control"
        mc:Ignorable="d"
        DataContext="{Binding  Source={StaticResource Locator},Path=Main}"
        WindowStartupLocation="CenterScreen"
        xmlns:converter="clr-namespace:West.StoreMgr.Helper.Converter"
        Title="欢迎使用仓库管理系统" Height="720" Width="1380">
    <Window.Resources>
        <converter:AdminVisibleConverter x:Key="AdminVisibleConverter"/>
    </Window.Resources>
    <Grid>
        <!--整体布局分为2行2列-->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="276"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="61"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <!--第1行第1列标识名称-->
        <Grid Grid.Row="0" Grid.Column="0" Tag="标志" Background="#367FA8">
            <TextBlock Text="企业仓库管理系统" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#F6A518" FontSize="28"/>
        </Grid>
        <!--第1行第2列帐号信息-->
        <Grid Grid.Row="0" Grid.Column="1" Tag="顶栏" Background="#3C8DBB">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                <TextBlock Margin="10" FontSize="16" Text="&#xf039;" FontFamily="Fonts/#FontAwesome" Foreground="White" VerticalAlignment="Center"/>
                <TextBlock Margin="0 10 0 10" FontSize="16" Text="欢迎"  Foreground="White" VerticalAlignment="Center"/>
                <TextBlock Margin="5 10 0 10" FontSize="16" Text="{Binding AppData.User.Name}"  Foreground="White" VerticalAlignment="Center" Style="{StaticResource TextBoxBanberStyle}" MouseUp="TextBlock_MouseUp_2"/>
            </StackPanel>
            <StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Margin="0 0 20 0">
                <TextBlock Margin="10" FontSize="16" Text="&#xf023;" FontFamily="Fonts/#FontAwesome" Foreground="White" VerticalAlignment="Center"/>
                <TextBlock Margin="0 10 0 10" FontSize="16" Text="修改密码"  Foreground="White" VerticalAlignment="Center" Style="{StaticResource TextBoxBanberStyle}" MouseUp="TextBlock_MouseUp_1"/>
                <TextBlock Margin="10" FontSize="16" Text="&#xf08b;" FontFamily="Fonts/#FontAwesome" Foreground="White" VerticalAlignment="Center"/>
                <TextBlock Margin="0 10 0 10" FontSize="16" Text="退出系统"  Foreground="White" Style="{StaticResource TextBoxBanberStyle}" MouseUp="TextBlock_MouseUp" />
            </StackPanel>
        </Grid>
        <!--第2行1列菜单-->
        <Grid Grid.Row="1" Grid.Column="0" Tag="菜单">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border Height="41" Background="#1A2327" VerticalAlignment="Center">
                <TextBlock Text="导航菜单" FontSize="20" Foreground="AntiqueWhite" VerticalAlignment="Center"/>
            </Border>
            <!--左侧主菜单-->
            <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
                <StackPanel Background="#222C32">
                    <RadioButton x:Name="IndexView"  Click="StoreView_Checked"  Height="50" Content="控制台首页" FontSize="16" Tag="&#xf17a;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                    <!--基础数据菜单,加上权限设置-->
                    <Expander Background="#1D282B" ExpandDirection="Down"  SnapsToDevicePixels="True" 
                              VerticalAlignment="Top" Style="{DynamicResource ExpanderStyle}" 
                              Visibility="{Binding AppData.User.Role,Converter={StaticResource AdminVisibleConverter}}">
                        <Expander.Header>
                            <StackPanel Orientation="Horizontal" Height="50" Background="Transparent">
                                <TextBlock Width="auto" Margin="10 0 10 0" Text="&#xf170;" FontFamily="Fonts/#FontAwesome" FontSize="22"  Foreground="Red" VerticalAlignment="Center"></TextBlock>
                                <TextBlock Width="200" FontSize="18" Text="基础数据" Foreground="#918C8C" VerticalAlignment="Center"></TextBlock>
                            </StackPanel>
                        </Expander.Header>
                        <Expander.Content>
                            <StackPanel Background="#F6F8F8">
                                <RadioButton x:Name="GoodsTypeView" Click="StoreView_Checked"   Height="30" Content="物资设置" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="GoodsView"  Click="StoreView_Checked"   Height="30" Content="物资登记" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton Name="SupplierView" Click="StoreView_Checked"   Height="30" Content="供应商设置" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton Name="CustomerView" Click="StoreView_Checked"    Height="30" Content="客户管理" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="StoreView" Click="StoreView_Checked"  Height="30" Content="仓库设置" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="SpecView"  Click="StoreView_Checked"   Height="30" Content="规格设置" FontSize="16" Tag="&#xf069;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                            </StackPanel>
                        </Expander.Content>
                    </Expander>
                    <!--物品管理菜单-->
                    <Expander Background="#1D282B" ExpandDirection="Down"  SnapsToDevicePixels="True" VerticalAlignment="Top" Style="{DynamicResource ExpanderStyle}">
                        <Expander.Header>
                            <StackPanel Orientation="Horizontal" Height="50" Background="Transparent">
                                <TextBlock Width="auto" Margin="10 0 10 0" Text="&#xf170;" FontFamily="Fonts/#FontAwesome" FontSize="22"  Foreground="Red" VerticalAlignment="Center"></TextBlock>
                                <TextBlock Width="200" FontSize="18" Text="物品管理" Foreground="#918C8C" VerticalAlignment="Center"></TextBlock>
                            </StackPanel>
                        </Expander.Header>
                        <Expander.Content>
                            <StackPanel Background="#F6F8F8">
                                <RadioButton x:Name="InStoreView" Click="StoreView_Checked" Height="30" Content="入库管理" FontSize="16" Tag="&#xf172;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="OutStoreView" Click="StoreView_Checked" Height="30" Content="出库管理" FontSize="16" Tag="&#xf172;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="InventoryView" Click="StoreView_Checked"    Height="30" Content="盘存管理" FontSize="16" Tag="&#xf172;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                            </StackPanel>
                        </Expander.Content>
                    </Expander>
                    <!--查询统计菜单-->
                    <Expander Background="#1D282B" ExpandDirection="Down"  SnapsToDevicePixels="True" VerticalAlignment="Top" Style="{DynamicResource ExpanderStyle}">
                        <Expander.Header>
                            <StackPanel Orientation="Horizontal" Height="50" Background="Transparent">
                                <TextBlock Width="auto" Margin="10 0 10 0" Text="&#xf170;" FontFamily="Fonts/#FontAwesome" FontSize="22"  Foreground="Red" VerticalAlignment="Center"></TextBlock>
                                <TextBlock Width="200" FontSize="18" Text="查询统计" Foreground="#918C8C" VerticalAlignment="Center"></TextBlock>
                            </StackPanel>
                        </Expander.Header>
                        <Expander.Content>
                            <StackPanel Background="#F6F8F8">
                                <RadioButton x:Name="QueryStockView"  Click="StoreView_Checked"  Height="30" Content="库存查询" FontSize="16" Tag="&#xf080;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="QueryInStoreView"   Click="StoreView_Checked"  Height="30" Content="入库查询" FontSize="16" Tag="&#xf080;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="QueryOutStoreView"  Click="StoreView_Checked"    Height="30" Content="出库查询" FontSize="16" Tag="&#xf080;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                                <RadioButton x:Name="LiveChartView"  Click="StoreView_Checked"  Height="30" Content="报表统计" FontSize="16" Tag="&#xf080;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                            </StackPanel>
                        </Expander.Content>
                    </Expander>
                    <!--系统维护菜单-->
                    <Expander Background="#1D282B" ExpandDirection="Down"  SnapsToDevicePixels="True" VerticalAlignment="Top" Style="{DynamicResource ExpanderStyle}" Visibility="{Binding AppData.User.Role,Converter={StaticResource AdminVisibleConverter}}">
                        <Expander.Header>
                            <StackPanel Orientation="Horizontal" Height="50" Background="Transparent">
                                <TextBlock Width="auto" Margin="10 0 10 0" Text="&#xf170;" FontFamily="Fonts/#FontAwesome" FontSize="22"  Foreground="Red" VerticalAlignment="Center"></TextBlock>
                                <TextBlock Width="200" FontSize="18" Text="系统维护" Foreground="#918C8C" VerticalAlignment="Center"></TextBlock>
                            </StackPanel>
                        </Expander.Header>
                        <Expander.Content>
                            <StackPanel Background="#F6F8F8">
                                <RadioButton x:Name="DataExportView"    Click="StoreView_Checked"    Height="30" Content="数据导出" FontSize="16" Tag="&#xf073;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F"  />
                            </StackPanel>
                        </Expander.Content>
                    </Expander>
                    <!--系统应用菜单-->
                    <Expander Background="#1D282B" ExpandDirection="Down"  SnapsToDevicePixels="True" VerticalAlignment="Top" Style="{DynamicResource ExpanderStyle}">
                        <Expander.Header>
                            <StackPanel Orientation="Horizontal" Height="50" Background="Transparent">
                                <TextBlock Width="auto" Margin="10 0 10 0" Text="&#xf170;" FontFamily="Fonts/#FontAwesome" FontSize="22"  Foreground="Red" VerticalAlignment="Center"></TextBlock>
                                <TextBlock Width="200" FontSize="18" Text="系统应用" Foreground="#918C8C" VerticalAlignment="Center"></TextBlock>
                            </StackPanel>
                        </Expander.Header>
                        <Expander.Content>
                            <StackPanel Background="#F6F8F8">
                                <!--权限设置-->
                                <RadioButton x:Name="UserInfoView"  Click="StoreView_Checked"  Height="30" Content="用户管理" FontSize="16" Tag="&#xf2bb;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" Visibility="{Binding AppData.User.Role,Converter={StaticResource AdminVisibleConverter}}" />
                                <RadioButton Click="RadioButton_Click"    Height="30" Content="退出系统"  FontSize="16" Tag="&#xf2bb;" Style="{DynamicResource RadioButtonMenuStyle}" Foreground="#85979F" />
                            </StackPanel>
                        </Expander.Content>
                    </Expander>
                </StackPanel>
            </ScrollViewer>
        </Grid>
        <!--第2行2列内容-->
        <Grid Grid.Row="1" Grid.Column="1" Tag="舞台" Background="#E4ECEF">
            <ContentControl x:Name="container">
                <!--<Control:ButtonCard Logo="&#xf1ae;" Title="入库管理" Content="这是一个可以入库的快捷操作"></Control:ButtonCard>-->
            </ContentControl>
        </Grid>
    </Grid>
</Window>

3)使用转换器 

   3、运行效果

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1887470.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python的matplotlib简单操作及图像闪屏问题

1.显示一个sinx的图像 import matplotlib.pyplot as plt import numpy as np xnp.linspace(0,10,100)#生成0到10 之间 分成100份等间隔 ynp.sin(x) # # plt.plot(x,y)#放入x与y plt.title("ysin(x)")#给图像命名 plt.xlabel("x")#设置x位置的名字 plt.yl…

HarmonyOS开发实战:UDP通讯示例规范

1. UDP简介 UDP协议是传输层协议的一种&#xff0c;它不需要建立连接&#xff0c;是不可靠、无序的&#xff0c;相对于TCP协议报文更简单&#xff0c;在特定场景下有更高的数据传输效率&#xff0c;在现代的网络通讯中有广泛的应用&#xff0c;以最新的HTTP/3为例&#xff0c;…

无需修改代码,深入探究 pytest 如何自动查找并加载三方插件

相信测试的同学或者python开发同学&#xff0c;都知道pytest框架&#xff0c;pytest不仅是一个功能强大的测试框架&#xff0c;同时还是一个插件化的测试平台。 插件只需配置就可以直接使用&#xff0c;而不需要测试代码配合。如果安装了插件&#xff0c;pytest则可以自动查找…

基于python的随机森林回归预测+贝叶斯优化超参数前后训练效果对比

目录 1.导入必要的库 2.导入数据与数据预处理 3.查看数据分布 4.特征选择 5.模型建立与训练 6.训练集预测结果 7.模型评估 8.预测新数据 9.贝叶斯优化超参数 1.导入必要的库 # 导入所需的库 from sklearn.model_selection import cross_val_score import pandas as …

【聊聊原子性,中断,以及nodejs中的具体示例】

什么是原子性 从一个例子说起&#xff0c; x &#xff0c;读和写 &#xff0c; 如图假设多线程&#xff0c;线程1和线程2同时操作变量x&#xff0c;进行x的操作&#xff0c;那么由于写的过程中&#xff0c;都会先读一份x数据到cpu的寄存器中&#xff0c;所以这个时候cpu1 和 c…

Michael.W基于Foundry精读Openzeppelin第61期——ERC1967Upgrade.sol

Michael.W基于Foundry精读Openzeppelin第61期——ERC1967Upgrade.sol 0. 版本0.1 ERC1967Upgrade.sol 1. 目标合约2. 代码精读2.1 _getImplementation() internal && _upgradeTo(address newImplementation) internal2.2 _upgradeToAndCall(address newImplementation,…

11--ElasticStack7-ELK+Kafka

前言&#xff1a;日志分析管理平台对于平时的规模化运维占的权重非常大&#xff0c;这一章涉及的程序较多&#xff0c;会将每个程序的基础使用和模块分开梳理&#xff0c;基础概念会分布在每小节开头&#xff0c;最后串联成一个完整的工作环境。 1、ELK架构 ELK 是一个非常流…

基于机器学习的永磁同步电机矢量控制策略-高分资源-下载可用!

基于机器学习的永磁同步电机矢量控制策略 优势 训练了RL-Agent&#xff0c;能够提高电机在非线性负载下的性能。 部分程序 仿真结果 转矩估计及dq轴电流。 代码有偿&#xff0c;50&#xff0c;需要的可以联系。

【STM32HAL库学习】通信方式:USART、IIC、SPI

通信的目的&#xff1a;将一个设备的数据传送到另一个设备&#xff0c;扩展硬件系统 通信接口区别 名称引脚双工时钟电平设备USARTTX、RX全双工异步单端点对点I2CSCL、SDA半双工同步单端多设备SPISCLK、MOSI、MISO、CS全双工同步单端多设备CANCAN_H、CAN_L半双工异步差分多设…

【antd + vue】表格行合并,同时使用插槽

一、需求说明 表格中&#xff0c;如果一个学校有多个考试科目&#xff0c;则分行展示&#xff0c;其余列&#xff0c;则合并为一行展示&#xff0c;如图所示 二、需求分析 1、表格行合并 相当于有4行&#xff0c;其中1、2行是同一个学校包含不同考试科目及对应人次的数据&am…

COB封装的LED显示屏是什么?

COB&#xff08;Chip on Board&#xff09;封装的LED显示屏&#xff0c;是一种采用先进倒装COB封装技术的显示屏&#xff0c;其中LED芯片是直接被安装并封装在PCB电路板上&#xff0c;而不是先对单个封装再焊接至电路板&#xff0c;与SMD&#xff08;Surface Mount Device&…

Java知识点整理 18 — Lambda表达式

一. 简介 Lambda 表达式是函数式编程思想的体现&#xff0c;强调做什么&#xff0c;而不是以什么方式去做。 面向对象编程思想强调的是对象&#xff0c;必须通过对象的形式来做一些事情。比如多线程执行任务&#xff0c;需要创建对象&#xff0c;对象需要实现指定接口&#x…

【吴恩达机器学习-week2】可选实验:使用 Scikit-Learn 进行线性回归

支持我的工作 &#x1f389; &#x1f4c3;亲爱的朋友们&#xff0c;感谢你们一直以来对我的关注和支持&#xff01; &#x1f4aa;&#x1f3fb; 为了提供更优质的内容和更有趣的创作&#xff0c;我付出了大量的时间和精力。如果你觉得我的内容对你有帮助或带来了欢乐&#xf…

看完这篇文章你就知道什么是未来软件开发的方向了!即生成式AI在软件开发领域的革新=CodeFlying

从最早的UGC&#xff08;用户生成内容&#xff09;到PGC&#xff08;专业生成内容&#xff09;再到AIGC&#xff08;人工智能生成内容&#xff09;体现了web1.0→web2.0→web3.0的发展历程。 毫无疑问UGC已经成为了当前拥有群体数量最大的内容生产方式。 同时随着人工智能技术…

SAP 表字段调整,表维护生成器调整

表维护生成器->已生成的对象->更改->专家模式

Linux下的wifi开发

了解什么是wifi 可参考&#xff1a; 什么是Wi-Fi&#xff1f;Wi-Fi和WLAN的区别是什么&#xff1f; - 华为 (huawei.com) WLAN的基本元素 工作站STA&#xff08;Station&#xff09;&#xff1a;支持802.11标准的终端设备。例如带无线网卡的电脑、支持WLAN的手机等。 接入点AP&…

OpenSSH RCE (CVE-2024-6387) | 附poc | 小试

Ⅰ 漏洞描述 OpenSSH 远程代码执行漏洞(CVE-2024-6387)&#xff0c;该漏洞是由于OpenSSH服务器 (sshd) 中的信号处理程序竞争问题&#xff0c;未经身份验证的攻击者可以利用此漏洞在Linux系统上以root身份执行任意代码。 Ⅱ 影响范围 8.5p1 < OpenSSH < 9.8p1 但OpenSS…

数学建模--层次分析法~~深入解读

目录 1.基本概念 &#xff08;1&#xff09;研究案例 &#xff08;2&#xff09;模型框架 &#xff08;3&#xff09;阐述说明 &#xff08;4&#xff09;注意事项 2.模型的建立和求解 &#xff08;1&#xff09;数量级的统一 &#xff08;2&#xff09;归一化处理 &am…

用Vue3和Rough.js绘制一个粗糙的3D条形图

本文由ScriptEcho平台提供技术支持 项目地址&#xff1a;传送门 使用 Rough.js 和 D3.js 绘制粗糙手写风格条形图 应用场景 该代码适用于需要在 Web 应用程序中创建具有粗糙手写风格的条形图的情况。它可以用于数据可视化、信息图表或任何需要以独特和有吸引力的方式呈现数…

Java StringBuffer类和StringBuilder类

在使用 StringBuffer 类时&#xff0c;每次都会对 StringBuffer 对象本身进行操作&#xff0c;而不是生成新的对象&#xff0c;所以如果需要对字符串进行修改推荐使用 StringBuffer。 StringBuilder 类在 Java 5 中被提出&#xff0c;它和 StringBuffer 之间的最大不同在于 St…