简体   繁体   English

Asp Zero 如何将 DropDownlist 添加到用户页面?

[英]Asp Zero how to add DropDownlist to Users page?

I'm new to Asp Zero and i want to know how to add Dropdownlist and fill it from Lookups table My objective is that i have Departments and each departments will have some their documents archived on the system only one Main Department can view, edit, or add the documents.我是 Asp Zero 的新手,我想知道如何添加 Dropdownlist 并从 Lookups 表中填充它我的目标是我有部门,每个部门都会在系统上存档一些文档,只有一个主要部门可以查看、编辑、或添加文档。 Other Departments view only the documents related to their departments so want link the Users to the departments.其他部门只查看与其部门相关的文档,因此希望将用户链接到部门。 Thank you.谢谢。

Morgan,摩根,

You can follow this steps,您可以按照以下步骤操作,

The first thing you need to do, is to add the relationship between User and Department您需要做的第一件事是添加UserDepartment之间的关系

Go to YourProject.Core\Authotization\Users\User.cs and add to this class the DepartmentId like this. Go 到YourProject.Core\Authotization\Users\User.cs并添加到这个 class DepartmentId这样的。

public class User : AbpUser<User>
{
    public virtual Guid? ProfilePictureId { get; set; }

    public virtual bool ShouldChangePasswordOnNextLogin { get; set; }
    // Others propierties...

    public int? DepartmendId {get;set;}
    public virtual Department Department {get;set;}
}

The go to YourProject.Application.Shared\Authorization\Users\Dto\UserEditDto.cs go 到YourProject.Application.Shared\Authorization\Users\Dto\UserEditDto.cs

public class UserEditDto : IPassivable
{
    /// <summary>
    /// Set null to create a new user. Set user's Id to update a user
    /// </summary>
    public long? Id { get; set; }

    [Required]
    [StringLength(AbpUserBase.MaxNameLength)]
    public string Name { get; set; }

    [Required]
    [StringLength(AbpUserBase.MaxSurnameLength)]
    public string Surname { get; set; }

    // Other Properties...
    public int DepartmentId {get; set;}
}

After this create a new migration and update the database also you need to run refresh.bat file in angular project ( Angular\nswag\refresh.bat ) remember that Api must be running before running the .bat file.创建新migrationupdate数据库后,您还需要在 angular 项目 ( Angular\nswag\refresh.bat ) 中运行refresh.bat文件,请记住 Api 必须在运行.bat文件之前运行。

After this, you can call DepartmentServiceProxy in app\users\create-or-edit-user-modal.component.ts to fill the DropDownList.之后就可以调用app\users\create-or-edit-user-modal.component.ts中的DepartmentServiceProxy填充DropDownList。

Then when you save the user you can select the department.然后,当您保存用户时,您可以 select 该部门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM