zoukankan      html  css  js  c++  java
  • asp.net core + layui.js

    asp.net core + layui.js 搭建仓储系统

     

      先放几张网站图片:

      第一步先从layui 网站https://www.layui.com/doc/ 下载相关文件,复制到项目 wwwroot 目录下:

       

      然后在 _Layout.cshtml 中引用 layui.js 和 layui.css,以及添加左侧栏和头部布局(具体操作见 : https://www.layui.com/doc/element/nav.html)

      后端框架:

      

      控制器通过依赖注入引用服务(asp.net core 默认支持)。

      Startup.cs 配置数据库连接,Session(用于登录和菜单缓存),添加服务到服务容器。

    复制代码
    public class Startup
        {
            public Startup(IConfiguration configuration)
            {
                Configuration = configuration;
            }
    
            public IConfiguration Configuration { get; }
    
            // This method gets called by the runtime. Use this method to add services to the container.
            public void ConfigureServices(IServiceCollection services)
            {
                services.AddMemoryCache();
                services.AddSession(options => {
                    options.IdleTimeout = TimeSpan.FromMinutes(10);
                });
                services.Configure<CookiePolicyOptions>(options =>
                {
                    // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                    options.CheckConsentNeeded = context => true;
                    options.MinimumSameSitePolicy = SameSiteMode.None;
                });
    
                services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                    .AddCookie();
    
                services.AddMvc(
                    options =>
                    {
                        options.Filters.Add<HttpGlobalExceptionFilter>(); //加入全局异常类
                    }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
                services.AddDbContext<AccessManagementContext>(options =>
                    options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
                    providerOptions => providerOptions.EnableRetryOnFailure()));
                services.AddDbContext<LuJCDBContext>(options =>
                    options.UseSqlServer(Configuration["WMSConnectionStrings:DefaultConnection"],
                    providerOptions => providerOptions.EnableRetryOnFailure()));
                services.AddTransient<CompanyServices, CompanyServices>();
                services.AddTransient<BasicInfoServices, BasicInfoServices>();
                services.AddTransient<AppMenuServices>();
                services.AddTransient<IAccountServices,AccountServices>();
                services.AddTransient<BranchServices>();
                services.AddTransient<PresetFunctionServices>();
                services.AddTransient<RoleServices>();
                services.AddTransient<LocationServices>();
                services.AddTransient<SupplierServices>();
                services.AddTransient<CustomerServices>();
                services.AddTransient<MeasureServices>();
                services.AddTransient<ProductCategoryServices>();
                services.AddTransient<ProductServices>();
                services.AddTransient<InStorageServices>();
                services.AddTransient<OutStorageServices>(); 
                services.AddTransient<BadReportServices>();
                services.AddTransient<CheckStockServices>();
                services.AddTransient<LocalProductServices>();
                //services.AddScoped<AddHeaderFilterWithDI>();
                services.AddAutoMapper(typeof(Startup));
                Mapper.Initialize(cfg =>
                    {
                        cfg.AddProfile<AccessManagementProfile>();
                    }
                );
                //Mapper.Initialize(cfg => cfg.CreateMap<AppMenu, AppMenuViewModel>());
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory)
            {
                app.UseSession();
                
                loggerFactory.AddNLog(); //添加NLog
                NLog.LogManager.LoadConfiguration("nlog.config");
                app.UseLog();
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
                else
                {
                    app.UseExceptionHandler("/Home/Error");
                    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                    app.UseHsts();
                }
                app.UseAuthentication();
                app.UseHttpsRedirection();
                app.UseStaticFiles();
                var cookiePolicyOptions = new CookiePolicyOptions
                {
                    MinimumSameSitePolicy = SameSiteMode.Strict,
                };
                app.UseCookiePolicy(cookiePolicyOptions);
                app.UseAccountSession();
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");
                    routes.MapAreaRoute("IMS", "IMS", "IMS/{controller}/{action}/{id?}",
                        defaults: new { Controller = "Location", Action = "Index" });
                    routes.MapAreaRoute("WMS", "WMS", "WMS/{controller}/{action}/{id?}",
                        defaults: new { Controller = "InStorage", Action = "Index" });
                    routes.MapAreaRoute("Report", "Report", "Report/{controller}/{action}/{id?}",
                        defaults: new { Controller = "LocalProduct", Action = "Index" });
                });
                
            }
        }
    复制代码
  • 相关阅读:
    Cdnbest的cdn程序默认支持web Socket
    在winsshd 中添加id_rsa.pub 实现Windows 服务器主机自动信任Linux 客户端
    Excel 如何排序与多关键字排序
    JZOJ 6316. djq的朋友圈(状压DP)
    JZOJ 6309. 完全背包(矩阵max)
    JZOJ 6307. 安排(归并排序+分治)
    JZOJ 6299. 2019.08.12【NOIP提高组A】工厂(二分图+状压DP)
    JZOJ 6276. 【noip提高组模拟1】树(DFS序+扫描线)
    JZOJ 6278. 2019.8.5【NOIP提高组A】跳房子 (分块模拟)
    JZOJ 6278. 2019.8.5【NOIP提高组A】跳房子 (分块模拟)
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/13328268.html
Copyright © 2011-2022 走看看