mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-06-28 15:45:35 +08:00
feat:实现项目团队加入功能
This commit is contained in:
parent
7785fb270d
commit
0f705f0249
@ -19,7 +19,7 @@ const CaptchaSessionName = "__captcha__"
|
||||
const RegexpEmail = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
|
||||
|
||||
//允许用户名中出现点号
|
||||
const RegexpAccount = `^[a-zA-Z][a-zA-z0-9\.]{2,50}$`
|
||||
const RegexpAccount = `^[a-zA-Z][a-zA-Z0-9\.]{2,50}$`
|
||||
|
||||
// PageSize 默认分页条数.
|
||||
const PageSize = 10
|
||||
|
@ -73,7 +73,9 @@ func (c *BookController) Dashboard() {
|
||||
if key == "" {
|
||||
c.Abort("404")
|
||||
}
|
||||
|
||||
if c.Member == nil {
|
||||
c.ShowErrorPage(500,"aaaa")
|
||||
}
|
||||
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
||||
if err != nil {
|
||||
if err == models.ErrPermissionDenied {
|
||||
@ -859,26 +861,69 @@ func (c *BookController) Team() {
|
||||
func (c *BookController) TeamAdd() {
|
||||
c.Prepare()
|
||||
|
||||
c.JsonResult(0, "OK")
|
||||
teamId, _ := c.GetInt("teamId")
|
||||
|
||||
book, err := c.IsPermission()
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
|
||||
_, err = models.NewTeam().First(teamId, "team_id")
|
||||
if err != nil {
|
||||
if err == orm.ErrNoRows {
|
||||
c.JsonResult(500, "团队不存在")
|
||||
}
|
||||
c.JsonResult(5002, err.Error())
|
||||
}
|
||||
if _, err := models.NewTeamRelationship().FindByBookId(book.BookId, teamId); err == nil {
|
||||
c.JsonResult(5003, "团队已加入当前项目")
|
||||
}
|
||||
teamRel := models.NewTeamRelationship()
|
||||
teamRel.BookId = book.BookId
|
||||
teamRel.TeamId = teamId
|
||||
err = teamRel.Save()
|
||||
if err != nil {
|
||||
c.JsonResult(5004, "加入项目失败")
|
||||
}
|
||||
teamRel.Include()
|
||||
|
||||
c.JsonResult(0, "OK", teamRel)
|
||||
}
|
||||
|
||||
//删除项目的团队.
|
||||
func (c *BookController) TeamDelete() {
|
||||
c.Prepare()
|
||||
|
||||
teamId, _ := c.GetInt("teamId")
|
||||
|
||||
book, err := c.IsPermission()
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
err = models.NewTeamRelationship().DeleteByBookId(book.BookId, teamId)
|
||||
|
||||
if err != nil {
|
||||
if err == orm.ErrNoRows {
|
||||
c.JsonResult(500, "团队未加入项目")
|
||||
}
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
|
||||
func (c *BookController) TeamSearch() {
|
||||
c.Prepare()
|
||||
|
||||
teamId, _ := c.GetInt("teamId")
|
||||
keyword := strings.TrimSpace(c.GetString("q"))
|
||||
|
||||
if teamId <= 0 {
|
||||
c.JsonResult(500, "参数错误")
|
||||
}
|
||||
book, err := c.IsPermission()
|
||||
|
||||
searchResult, err := models.NewTeamRelationship().FindNotJoinBookByName(teamId, keyword, 10)
|
||||
if err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
searchResult, err := models.NewTeamRelationship().FindNotJoinBookByBookIdentify(book.BookId, keyword, 10)
|
||||
|
||||
if err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
@ -890,6 +935,10 @@ func (c *BookController) TeamSearch() {
|
||||
func (c *BookController) IsPermission() (*models.BookResult, error) {
|
||||
identify := c.GetString("identify")
|
||||
|
||||
if identify == "" {
|
||||
return nil, errors.New("参数错误")
|
||||
}
|
||||
|
||||
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
||||
|
||||
if err != nil {
|
||||
|
@ -688,7 +688,7 @@ func (c *DocumentController) Content() {
|
||||
bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
||||
|
||||
if err != nil || bookResult.RoleId == conf.BookObserver {
|
||||
beego.Error("FindByIdentify => ", err)
|
||||
beego.Error("项目不存在或权限不足 -> ", err)
|
||||
c.JsonResult(6002, "项目不存在或权限不足")
|
||||
}
|
||||
|
||||
@ -885,7 +885,7 @@ func (c *DocumentController) Export() {
|
||||
c.Abort("200")
|
||||
|
||||
} else if output == "pdf" || output == "epub" || output == "docx" || output == "mobi" {
|
||||
if err := models.BackgroupConvert(c.CruSession.SessionID(), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
||||
if err := models.BackgroundConvert(c.CruSession.SessionID(), bookResult); err != nil && err != gopool.ErrHandlerIsExist {
|
||||
c.ShowErrorPage(500, "导出失败,请查看系统日志")
|
||||
}
|
||||
|
||||
@ -1319,6 +1319,9 @@ func isReadable(identify, token string, c *DocumentController) *models.BookResul
|
||||
bookResult.MemberId = rel.MemberId
|
||||
bookResult.RoleId = rel.RoleId
|
||||
bookResult.RelationshipId = rel.RelationshipId
|
||||
} else {
|
||||
//TODO 团队权限
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -854,7 +854,7 @@ func (c *ManagerController) TeamDelete() {
|
||||
|
||||
c.CheckJsonError(5001, err)
|
||||
|
||||
c.JsonResult(0, "")
|
||||
c.JsonResult(0, "OK")
|
||||
}
|
||||
|
||||
func (c *ManagerController) TeamMemberList() {
|
||||
|
@ -97,6 +97,10 @@ func (book *Book) TableNameWithPrefix() string {
|
||||
return conf.GetDatabasePrefix() + book.TableName()
|
||||
}
|
||||
|
||||
func (book *Book) QueryTable() orm.QuerySeter {
|
||||
return orm.NewOrm().QueryTable(book.TableNameWithPrefix())
|
||||
}
|
||||
|
||||
func NewBook() *Book {
|
||||
return &Book{}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ type BookResult struct {
|
||||
HistoryCount int `json:"history_count"`
|
||||
|
||||
RelationshipId int `json:"relationship_id"`
|
||||
TeamRelationshipId int `json:"team_relationship_id"`
|
||||
RoleId conf.BookRole `json:"role_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
Status int `json:"status"`
|
||||
@ -71,8 +72,8 @@ func NewBookResult() *BookResult {
|
||||
return &BookResult{}
|
||||
}
|
||||
|
||||
func (b *BookResult) String() string {
|
||||
ret, err := json.Marshal(*b)
|
||||
func (m *BookResult) String() string {
|
||||
ret, err := json.Marshal(*m)
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
@ -87,23 +88,35 @@ func (m *BookResult) FindByIdentify(identify string, memberId int, cols ...strin
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
|
||||
book := NewBook()
|
||||
var book Book
|
||||
|
||||
err := o.QueryTable(book.TableNameWithPrefix()).Filter("identify", identify).One(book, cols...)
|
||||
err := NewBook().QueryTable().Filter("identify", identify).One(&book)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("获取项目失败 ->",err)
|
||||
return m, err
|
||||
}
|
||||
|
||||
relationship := NewRelationship()
|
||||
var relationship Relationship
|
||||
var teamMember *TeamMember
|
||||
|
||||
err = o.QueryTable(relationship.TableNameWithPrefix()).Filter("book_id", book.BookId).Filter("member_id", memberId).One(relationship)
|
||||
err = NewRelationship().QueryTable().Filter("book_id", book.BookId).Filter("member_id", memberId).One(&relationship)
|
||||
|
||||
if err != nil {
|
||||
return m, err
|
||||
if err == orm.ErrNoRows {
|
||||
//未查到项目参与者
|
||||
teamMember,err = NewTeamMember().FindByBookIdAndMemberId(book.BookId,memberId)
|
||||
if err != nil {
|
||||
return m,err
|
||||
}
|
||||
err = nil
|
||||
} else {
|
||||
return m, err
|
||||
}
|
||||
}
|
||||
var relationship2 Relationship
|
||||
|
||||
//查找项目创始人
|
||||
err = o.QueryTable(relationship.TableNameWithPrefix()).Filter("book_id", book.BookId).Filter("role_id", 0).One(&relationship2)
|
||||
|
||||
if err != nil {
|
||||
@ -116,16 +129,21 @@ func (m *BookResult) FindByIdentify(identify string, memberId int, cols ...strin
|
||||
return m, err
|
||||
}
|
||||
|
||||
m = NewBookResult().ToBookResult(*book)
|
||||
m.ToBookResult(book)
|
||||
|
||||
m.MemberId = memberId
|
||||
m.CreateName = member.Account
|
||||
|
||||
if member.RealName != "" {
|
||||
m.RealName = member.RealName
|
||||
}
|
||||
m.MemberId = relationship.MemberId
|
||||
m.RoleId = relationship.RoleId
|
||||
m.RelationshipId = relationship.RelationshipId
|
||||
|
||||
if teamMember != nil {
|
||||
m.RoleId = teamMember.RoleId
|
||||
m.TeamRelationshipId = teamMember.TeamMemberId
|
||||
} else {
|
||||
m.RoleId = relationship.RoleId
|
||||
m.RelationshipId = relationship.RelationshipId
|
||||
}
|
||||
if m.RoleId == conf.BookFounder {
|
||||
m.RoleName = "创始人"
|
||||
} else if m.RoleId == conf.BookAdmin {
|
||||
@ -226,7 +244,7 @@ func (m *BookResult) ToBookResult(book Book) *BookResult {
|
||||
}
|
||||
|
||||
//后台转换
|
||||
func BackgroupConvert(sessionId string, bookResult *BookResult) error {
|
||||
func BackgroundConvert(sessionId string, bookResult *BookResult) error {
|
||||
|
||||
if err := converter.CheckConvertCommand(); err != nil {
|
||||
beego.Error("检查转换程序失败 -> ", err)
|
||||
|
@ -35,6 +35,9 @@ func (u *Relationship) TableUnique() [][]string {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *Relationship) QueryTable() orm.QuerySeter {
|
||||
return orm.NewOrm().QueryTable(u.TableNameWithPrefix())
|
||||
}
|
||||
func NewRelationship() *Relationship {
|
||||
return &Relationship{}
|
||||
}
|
||||
|
@ -46,6 +46,11 @@ func (t *Team) First(id int, cols ...string) (*Team, error) {
|
||||
o := orm.NewOrm()
|
||||
err := o.QueryTable(t.TableNameWithPrefix()).Filter("team_id", id).One(t, cols...)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("查询团队失败 ->",id, err)
|
||||
return nil,err
|
||||
}
|
||||
t.Include()
|
||||
return t, err
|
||||
}
|
||||
|
||||
@ -107,24 +112,31 @@ func (t *Team) FindToPager(pageIndex, pageSize int) (list []*Team, totalCount in
|
||||
}
|
||||
totalCount = int(c)
|
||||
|
||||
for i,item := range list {
|
||||
if member,err := NewMember().Find(item.MemberId,"account","real_name"); err == nil {
|
||||
if member.RealName != "" {
|
||||
list[i].MemberName = member.RealName
|
||||
} else {
|
||||
list[i].MemberName = member.Account
|
||||
}
|
||||
}
|
||||
if c,err := o.QueryTable(NewTeamRelationship().TableNameWithPrefix()).Filter("team_id", item.TeamId).Count(); err == nil {
|
||||
list[i].BookCount = int(c)
|
||||
}
|
||||
if c,err := o.QueryTable(NewTeamMember().TableNameWithPrefix()).Filter("team_id", item.TeamId).Count(); err == nil {
|
||||
list[i].MemberCount = int(c)
|
||||
}
|
||||
for _,item := range list {
|
||||
item.Include()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Team) Include() {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
if member,err := NewMember().Find(t.MemberId,"account","real_name"); err == nil {
|
||||
if member.RealName != "" {
|
||||
t.MemberName = member.RealName
|
||||
} else {
|
||||
t.MemberName = member.Account
|
||||
}
|
||||
}
|
||||
if c,err := o.QueryTable(NewTeamRelationship().TableNameWithPrefix()).Filter("team_id", t.TeamId).Count(); err == nil {
|
||||
t.BookCount = int(c)
|
||||
}
|
||||
if c,err := o.QueryTable(NewTeamMember().TableNameWithPrefix()).Filter("team_id", t.TeamId).Count(); err == nil {
|
||||
t.MemberCount = int(c)
|
||||
}
|
||||
}
|
||||
|
||||
//更新或添加一个团队.
|
||||
func (t *Team) Save(cols ... string) (err error) {
|
||||
if t.TeamName == "" {
|
||||
|
@ -37,6 +37,10 @@ func (m *TeamMember) TableUnique() [][]string {
|
||||
return [][]string{{"team_id", "member_id"}}
|
||||
}
|
||||
|
||||
func (m *TeamMember) QueryTable() orm.QuerySeter {
|
||||
return orm.NewOrm().QueryTable(m.TableNameWithPrefix())
|
||||
}
|
||||
|
||||
func NewTeamMember() *TeamMember {
|
||||
return &TeamMember{}
|
||||
}
|
||||
@ -85,13 +89,13 @@ func (m *TeamMember) FindFirst(teamId, memberId int) (*TeamMember, error) {
|
||||
return nil, ErrInvalidParameter
|
||||
}
|
||||
o := orm.NewOrm()
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("team_id",teamId).Filter("member_id",memberId).One(m)
|
||||
err := o.QueryTable(m.TableNameWithPrefix()).Filter("team_id", teamId).Filter("member_id", memberId).One(m)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("查询团队用户失败 ->",err)
|
||||
return nil,err
|
||||
beego.Error("查询团队用户失败 ->", err)
|
||||
return nil, err
|
||||
}
|
||||
return m.Include(),nil
|
||||
return m.Include(), nil
|
||||
}
|
||||
|
||||
//更新或插入团队用户.
|
||||
@ -114,7 +118,7 @@ func (m *TeamMember) Save(cols ...string) (err error) {
|
||||
}
|
||||
|
||||
if m.TeamMemberId <= 0 {
|
||||
if o.QueryTable(m.TableNameWithPrefix()).Filter("team_id",m.TeamId).Filter("member_id",m.MemberId).Exist() {
|
||||
if o.QueryTable(m.TableNameWithPrefix()).Filter("team_id", m.TeamId).Filter("member_id", m.MemberId).Exist() {
|
||||
return errors.New("团队中已存在该用户")
|
||||
}
|
||||
_, err = o.Insert(m)
|
||||
@ -229,3 +233,24 @@ limit ?;`
|
||||
|
||||
return &result, err
|
||||
}
|
||||
|
||||
func (m *TeamMember) FindByBookIdAndMemberId(bookId,memberId int) (*TeamMember, error) {
|
||||
if bookId <= 0 || memberId <= 0 {
|
||||
return nil,ErrInvalidParameter
|
||||
}
|
||||
//一个用户可能在多个团队中,且一个项目可能有多个团队参与。因此需要查询用户最大权限。
|
||||
sql := `select *
|
||||
from md_team_member as team
|
||||
where team.team_id in (select rel.team_id from md_team_relationship as rel where rel.book_id = ?)
|
||||
and team.member_id = ? order by team.role_id asc limit 1;`
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
err := o.Raw(sql,bookId,memberId).QueryRow(m)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("查询用户项目所在团队失败 ->bookId=",bookId," memberId=", memberId, err)
|
||||
return nil,err
|
||||
}
|
||||
return m,nil
|
||||
}
|
||||
|
@ -10,9 +10,11 @@ import (
|
||||
|
||||
type TeamRelationship struct {
|
||||
TeamRelationshipId int `orm:"column(team_relationship_id);pk;auto;unique;" json:"team_relationship_id"`
|
||||
BookId int `orm:"column(book_id)"`
|
||||
TeamId int `orm:"column(team_id)"`
|
||||
BookId int `orm:"column(book_id)" json:"book_id"`
|
||||
TeamId int `orm:"column(team_id)" json:"team_id"`
|
||||
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
|
||||
TeamName string `orm:"-" json:"team_name"`
|
||||
MemberCount int `orm:"-" json:"member_count"`
|
||||
BookMemberId int `orm:"-" json:"book_member_id"`
|
||||
BookMemberName string `orm:"-" json:"book_member_name"`
|
||||
BookName string `orm:"-" json:"book_name"`
|
||||
@ -43,6 +45,39 @@ func NewTeamRelationship() *TeamRelationship {
|
||||
return &TeamRelationship{}
|
||||
}
|
||||
|
||||
func (m *TeamRelationship) First(teamId int, cols ...string) (*TeamRelationship, error) {
|
||||
if teamId <= 0 {
|
||||
return nil, ErrInvalidParameter
|
||||
}
|
||||
err := m.QueryTable().Filter("team_id", teamId).One(m, cols...)
|
||||
if err != nil {
|
||||
beego.Error("查询项目团队失败 ->", err)
|
||||
}
|
||||
return m, err
|
||||
}
|
||||
|
||||
//查找指定项目的指定团队.
|
||||
func (m *TeamRelationship) FindByBookId(bookId int, teamId int) (*TeamRelationship, error) {
|
||||
if teamId <= 0 || bookId <= 0 {
|
||||
return nil, ErrInvalidParameter
|
||||
}
|
||||
err := m.QueryTable().Filter("team_id", teamId).Filter("book_id", bookId).One(m)
|
||||
if err != nil {
|
||||
beego.Error("查询项目团队失败 ->", err)
|
||||
}
|
||||
return m, err
|
||||
}
|
||||
|
||||
//删除指定项目的指定团队.
|
||||
func (m *TeamRelationship) DeleteByBookId(bookId int, teamId int) error {
|
||||
err := m.QueryTable().Filter("team_id", teamId).Filter("book_id", bookId).One(m)
|
||||
if err != nil {
|
||||
beego.Error("查询项目团队失败 ->", err)
|
||||
return err
|
||||
}
|
||||
return m.Delete(teamId)
|
||||
}
|
||||
|
||||
//保存团队项目.
|
||||
func (m *TeamRelationship) Save(cols ...string) (err error) {
|
||||
if m.TeamId <= 0 || m.BookId <= 0 {
|
||||
@ -125,10 +160,17 @@ func (m *TeamRelationship) Include() (*TeamRelationship, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if m.TeamId > 0{
|
||||
team ,err := NewTeam().First(m.TeamId)
|
||||
if err == nil {
|
||||
m.TeamName = team.TeamName
|
||||
m.MemberCount = team.MemberCount
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
//查询未加入团队的用户。
|
||||
//查询未加入团队的项目.
|
||||
func (m *TeamRelationship) FindNotJoinBookByName(teamId int, bookName string, limit int) (*SelectMemberResult, error) {
|
||||
if teamId <= 0 {
|
||||
return nil, ErrInvalidParameter
|
||||
@ -163,10 +205,45 @@ and book.book_name like ? order by book_id desc limit ?;`
|
||||
return &result, err
|
||||
}
|
||||
|
||||
//查询指定项目的团队.
|
||||
func (m *TeamRelationship) FindByBookToPager(bookId, pageIndex,pageSize int) (list []*TeamRelationship,totalCount int,err error) {
|
||||
//查找指定项目中未加入的团队.
|
||||
func (m *TeamRelationship) FindNotJoinBookByBookIdentify(bookId int, teamName string, limit int) (*SelectMemberResult, error) {
|
||||
if bookId <= 0 || teamName == "" {
|
||||
return nil, ErrInvalidParameter
|
||||
}
|
||||
|
||||
if bookId <= 0{
|
||||
o := orm.NewOrm()
|
||||
sql := `select *
|
||||
from md_teams as team
|
||||
where team.team_id not in (select rel.team_id from md_team_relationship as rel where rel.book_id = ?)
|
||||
and team.team_name like ?
|
||||
order by team.team_id desc limit ?;`
|
||||
teams := make([]*Team, 0)
|
||||
|
||||
_, err := o.Raw(sql, bookId, "%"+teamName+"%", limit).QueryRows(&teams)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("查询团队项目时出错 ->", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := SelectMemberResult{}
|
||||
items := make([]KeyValueItem, 0)
|
||||
|
||||
for _, team := range teams {
|
||||
item := KeyValueItem{}
|
||||
item.Id = team.TeamId
|
||||
item.Text = team.TeamName
|
||||
items = append(items, item)
|
||||
}
|
||||
result.Result = items
|
||||
|
||||
return &result, err
|
||||
}
|
||||
|
||||
//查询指定项目的团队.
|
||||
func (m *TeamRelationship) FindByBookToPager(bookId, pageIndex, pageSize int) (list []*TeamRelationship, totalCount int, err error) {
|
||||
|
||||
if bookId <= 0 {
|
||||
err = ErrInvalidParameter
|
||||
return
|
||||
}
|
||||
@ -193,32 +270,3 @@ func (m *TeamRelationship) FindByBookToPager(bookId, pageIndex,pageSize int) (li
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -45,9 +45,11 @@ func init() {
|
||||
|
||||
var StartRouter = func(ctx *context.Context) {
|
||||
sessionId := ctx.Input.Cookie(beego.AppConfig.String("sessionname"))
|
||||
//sessionId必须是数字字母组成,且最小32个字符,最大1024字符
|
||||
if ok, err := regexp.MatchString(`^[a-zA-z0-9]{32,1024}$`, sessionId); !ok || err != nil {
|
||||
panic("401")
|
||||
if sessionId != "" {
|
||||
//sessionId必须是数字字母组成,且最小32个字符,最大1024字符
|
||||
if ok, err := regexp.MatchString(`^[a-zA-Z0-9]{32,512}$`, sessionId); !ok || err != nil {
|
||||
panic("401")
|
||||
}
|
||||
}
|
||||
}
|
||||
beego.InsertFilter("/*", beego.BeforeStatic, StartRouter, false)
|
||||
|
@ -27,11 +27,15 @@
|
||||
<div class="row">
|
||||
<div class="page-left">
|
||||
<ul class="menu">
|
||||
<li><a href="{{urlfor "BookController.Dashboard" ":key" .Model.Identify}}" class="item"><i class="fa fa-dashboard" aria-hidden="true"></i> 概要</a> </li>
|
||||
<li><a href="{{urlfor "BookController.Users" ":key" .Model.Identify}}" class="item"><i class="fa fa-user" aria-hidden="true"></i> 成员</a> </li>
|
||||
<li class="active"><a href="{{urlfor "BookController.Team" ":key" .Model.Identify}}" class="item"><i class="fa fa-group" aria-hidden="true"></i> 团队</a> </li>
|
||||
<li><a href="{{urlfor "BookController.Dashboard" ":key" .Model.Identify}}" class="item"><i
|
||||
class="fa fa-dashboard" aria-hidden="true"></i> 概要</a></li>
|
||||
<li><a href="{{urlfor "BookController.Users" ":key" .Model.Identify}}" class="item"><i
|
||||
class="fa fa-user" aria-hidden="true"></i> 成员</a></li>
|
||||
<li class="active"><a href="{{urlfor "BookController.Team" ":key" .Model.Identify}}" class="item"><i
|
||||
class="fa fa-group" aria-hidden="true"></i> 团队</a></li>
|
||||
{{if eq .Model.RoleId 0 1}}
|
||||
<li><a href="{{urlfor "BookController.Setting" ":key" .Model.Identify}}" class="item"><i class="fa fa-gear" aria-hidden="true"></i> 设置</a> </li>
|
||||
<li><a href="{{urlfor "BookController.Setting" ":key" .Model.Identify}}" class="item"><i
|
||||
class="fa fa-gear" aria-hidden="true"></i> 设置</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
@ -41,7 +45,8 @@
|
||||
<div class="box-head">
|
||||
<strong class="box-title"> 团队管理</strong>
|
||||
{{if eq .Member.Role 0}}
|
||||
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#addTeamDialogModal"><i class="fa fa-user-plus" aria-hidden="true"></i>
|
||||
<button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal"
|
||||
data-target="#addTeamDialogModal"><i class="fa fa-user-plus" aria-hidden="true"></i>
|
||||
添加团队
|
||||
</button>
|
||||
{{end}}
|
||||
@ -57,8 +62,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>团队名称</th>
|
||||
<th width="150px">成员数量</th>
|
||||
<th width="150px">项目数量</th>
|
||||
<th width="100">成员数量</th>
|
||||
<th width="180">加入时间</th>
|
||||
<th align="center" width="220px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -66,11 +71,8 @@
|
||||
<tr v-for="item in lists">
|
||||
<td>${item.team_name}</td>
|
||||
<td>${item.member_count}</td>
|
||||
<td>${item.book_count}</td>
|
||||
<td>${(new Date(item.create_time)).format("yyyy-MM-dd hh:mm:ss")}</td>
|
||||
<td>
|
||||
<a :href="'{{urlfor "ManagerController.TeamBookList" ":id" ""}}' + item.team_id" class="btn btn-primary btn-sm">项目</a>
|
||||
<a :href="'{{urlfor "ManagerController.TeamMemberList" ":id" ""}}' + item.team_id" type="button" class="btn btn-success btn-sm">成员</a>
|
||||
<button type="button" class="btn btn-sm btn-default" @click="editTeam(item.team_id)">编辑</button>
|
||||
<button type="button" class="btn btn-danger btn-sm" @click="deleteTeam(item.team_id,$event)" data-loading-text="删除中">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -90,8 +92,9 @@
|
||||
|
||||
<div class="modal fade" id="addTeamDialogModal" tabindex="-1" role="dialog" aria-labelledby="addTeamDialogModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<form method="post" autocomplete="off" class="form-horizontal" action="{{urlfor "BookController.TeamAdd"}}" id="addTeamDialogForm">
|
||||
<form method="post" autocomplete="off" id="addTeamDialogForm" class="form-horizontal" action="{{urlfor "BookController.TeamAdd"}}">
|
||||
<input type="hidden" name="bookId" value="{{.Model.BookId}}">
|
||||
<input type="hidden" name="identify" value="{{.Model.Identify}}">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
@ -101,7 +104,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="account">团队名称<span class="error-message">*</span></label>
|
||||
<div class="col-sm-10">
|
||||
<select type="text" name="teamId" class="js-data-example-ajax form-control" multiple="multiple"></select>
|
||||
<select type="text" name="teamId" id="teamId" class="js-data-example-ajax form-control" multiple="multiple"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@ -132,12 +135,12 @@
|
||||
window.addTeamDialogModalHtml = $(this).find("form").html();
|
||||
$('.js-data-example-ajax').select2({
|
||||
language: "zh-CN",
|
||||
minimumInputLength : 1,
|
||||
minimumInputLength: 1,
|
||||
minimumResultsForSearch: Infinity,
|
||||
maximumSelectionLength:1,
|
||||
width : "100%",
|
||||
maximumSelectionLength: 1,
|
||||
width: "100%",
|
||||
ajax: {
|
||||
url: '{{urlfor "BookController.TeamSearch" "identity" .Model.Identify}}',
|
||||
url: '{{urlfor "BookController.TeamSearch" "identify" .Model.Identify}}',
|
||||
dataType: 'json',
|
||||
data: function (params) {
|
||||
return {
|
||||
@ -147,22 +150,22 @@
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
return {
|
||||
results : data.data.results
|
||||
results: data.data.results
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}).on("hidden.bs.modal", function () {
|
||||
$(this).find("form").html(window.addTeamDialogModalHtml);
|
||||
}).on("shown.bs.modal",function () {
|
||||
}).on("shown.bs.modal", function () {
|
||||
$(this).find("input[name='teamId']").focus();
|
||||
});
|
||||
|
||||
|
||||
$("#addTeamDialogForm").ajaxForm({
|
||||
beforeSubmit: function () {
|
||||
var account = $.trim($("#addTeamDialogForm input[name='teamId']").val());
|
||||
if (account === "") {
|
||||
var teamId = $.trim($("#addTeamDialogForm select[name='teamId']").val());
|
||||
if (teamId == "") {
|
||||
return showError("团队名称不能为空");
|
||||
}
|
||||
$("#btnAddTeam").button("loading");
|
||||
@ -194,16 +197,15 @@
|
||||
deleteTeam: function (id, e) {
|
||||
var $this = this;
|
||||
$.ajax({
|
||||
url: "{{urlfor "ManagerController.TeamDelete"}}",
|
||||
url: "{{urlfor "BookController.TeamDelete"}}",
|
||||
type: "post",
|
||||
data: {"id": id},
|
||||
data: {"teamId": id, "identify": "{{.Model.Identify}}"},
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
if (res.errcode === 0) {
|
||||
|
||||
success: function ($res) {
|
||||
if ($res.errcode === 0) {
|
||||
for (var index in $this.lists) {
|
||||
var item = $this.lists[index];
|
||||
if (item.team_id == id) {
|
||||
if (item.team_relationship_id == id) {
|
||||
$this.lists.splice(index, 1);
|
||||
break;
|
||||
}
|
||||
@ -213,18 +215,6 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
editTeam : function (id, e) {
|
||||
var $this = this;
|
||||
for (var index in $this.lists) {
|
||||
var item = $this.lists[index];
|
||||
if (item.team_id == id) {
|
||||
editTeamDialogModal.find("input[name='teamName']").val(item.team_name);
|
||||
editTeamDialogModal.find("input[name='teamId']").val(item.team_id);
|
||||
editTeamDialogModal.modal("show");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -39,9 +39,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="80">头像</th>
|
||||
<th>账号</th>
|
||||
<th>姓名</th>
|
||||
<th>角色</th>
|
||||
<th width="100">账号</th>
|
||||
<th width="100">姓名</th>
|
||||
<th width="150">角色</th>
|
||||
<th width="80px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -53,7 +53,7 @@
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
${item.role_name}
|
||||
角色:${item.role_name}
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:;" @click="setTeamMemberRole(item.member_id,1)">管理员 <p class="text">拥有阅读、写作和管理权限</p></a> </li>
|
||||
|
Loading…
Reference in New Issue
Block a user