实现添加项目成员时下拉提示

This commit is contained in:
Minho
2018-02-03 15:25:10 +08:00
parent c7d83576bd
commit ba9c390a13
7 changed files with 156 additions and 13 deletions

View File

@@ -385,6 +385,7 @@ func (c *BookController) Users() {
}
}
// Create 创建项目.
func (c *BookController) Create() {

View File

@@ -7,6 +7,7 @@ import (
"github.com/astaxie/beego/orm"
"github.com/lifei6671/mindoc/conf"
"github.com/lifei6671/mindoc/models"
"github.com/astaxie/beego"
)
type BookMemberController struct {
@@ -16,10 +17,10 @@ type BookMemberController struct {
// AddMember 参加参与用户.
func (c *BookMemberController) AddMember() {
identify := c.GetString("identify")
account := c.GetString("account")
account,_ := c.GetInt("account")
role_id, _ := c.GetInt("role_id", 3)
if identify == "" || account == "" {
beego.Info(account)
if identify == "" || account <= 0 {
c.JsonResult(6001, "参数错误")
}
book, err := c.IsPermission()
@@ -28,9 +29,10 @@ func (c *BookMemberController) AddMember() {
c.JsonResult(6001, err.Error())
}
member := models.NewMember()
if _, err := member.FindByAccount(account); err != nil {
if _, err := member.Find(account); err != nil {
c.JsonResult(404, "用户不存在")
}
if member.Status == 1 {

View File

@@ -13,7 +13,7 @@ import (
type SearchController struct {
BaseController
}
//搜索首页
func (c *SearchController) Index() {
c.Prepare()
c.TplName = "search/index.tpl"
@@ -95,3 +95,41 @@ func (c *SearchController) Index() {
c.Data["Lists"] = search_result
}
}
//搜索用户
func (c *SearchController) User() {
c.Prepare()
key := c.Ctx.Input.Param(":key")
keyword := strings.TrimSpace(c.GetString("q"))
if key == "" || keyword == ""{
c.JsonResult(404,"参数错误")
}
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
if err != nil {
if err == models.ErrPermissionDenied {
c.JsonResult(403,"没有权限")
}
c.JsonResult(500,"项目不存在")
}
members,err := models.NewMemberRelationshipResult().FindNotJoinUsersByAccount(book.BookId,10,"%"+keyword+"%")
if err != nil {
beego.Error("查询用户列表出错:" + err.Error())
c.JsonResult(500,err.Error())
}
result := models.SelectMemberResult{}
items := make([]models.KeyValueItem,0)
for _,member := range members {
item := models.KeyValueItem{}
item.Id = member.MemberId
item.Text = member.Account
items = append(items,item)
}
result.Result = items
c.JsonResult(0,"OK", result)
}