...
|
...
|
@@ -1931,16 +1931,27 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
|
for i := range op.CheckOption.Departments {
|
|
|
rsp.DepartmentIds = append(rsp.DepartmentIds, op.CheckOption.Departments[i].Id)
|
|
|
}
|
|
|
//所有权限
|
|
|
allPermission := func() {
|
|
|
rsp.EditChance = 1
|
|
|
rsp.EditPublicStatus = 1
|
|
|
rsp.EditScore = 1
|
|
|
}
|
|
|
//无权限
|
|
|
noPermission := func() {
|
|
|
rsp.EditChance = 0
|
|
|
rsp.EditPublicStatus = 0
|
|
|
rsp.EditScore = 0
|
|
|
}
|
|
|
//判断机会权限
|
|
|
if request.ChanceId > 0 {
|
|
|
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
|
|
|
err = protocol.NewErrWithMessage(5101)
|
|
|
return
|
|
|
}
|
|
|
if chance.Status == models.ChanceStatusClose || chance.EnableStatus == 0 { //机会关闭 / 删除
|
|
|
rsp.EditChance = 0
|
|
|
rsp.EditPublicStatus = 0
|
|
|
rsp.EditScore = 0
|
|
|
//机会关闭 / 删除
|
|
|
if chance.Status == models.ChanceStatusClose || chance.EnableStatus == 0 {
|
|
|
noPermission()
|
|
|
log.Debug(fmt.Sprintf("用户:%v chance_id:%v 机会关闭/删除 无权限", header.UserId, chance.Id))
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -1948,31 +1959,29 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
|
if chance.UserId == header.UserId {
|
|
|
//审核通过 或者 已经被人审核过 就不能编辑了
|
|
|
if len(chance.ApproveData) > 0 && chance.ReviewStatus == protocol.ReviewStatusAuditging { //审批中 且有人审批 本人不可编辑
|
|
|
rsp.EditChance = 0
|
|
|
noPermission()
|
|
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging { //未有人审核过
|
|
|
rsp.EditChance = 1
|
|
|
rsp.EditPublicStatus = 0
|
|
|
rsp.EditScore = 0
|
|
|
}
|
|
|
if chance.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
rsp.EditScore = 1
|
|
|
rsp.EditChance = 1
|
|
|
}
|
|
|
return
|
|
|
} else {
|
|
|
if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑
|
|
|
rsp.EditChance = 0
|
|
|
rsp.EditPublicStatus = 0
|
|
|
rsp.EditScore = 0
|
|
|
}
|
|
|
}
|
|
|
//他人
|
|
|
if chance.UserId != header.UserId {
|
|
|
//他人
|
|
|
if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑
|
|
|
noPermission()
|
|
|
return
|
|
|
}
|
|
|
//是否是审核人
|
|
|
if auditProcess, err = models.GetAuditFlowProcessListByAuditUser(request.ChanceId, header.UserId); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
//非审核人 并且 审核状态不是通过的,无所有权限
|
|
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
|
|
rsp.EditChance = 0
|
|
|
rsp.EditPublicStatus = 0
|
|
|
rsp.EditScore = 0
|
|
|
noPermission()
|
|
|
}
|
|
|
err = nil
|
|
|
return
|
...
|
...
|
@@ -1987,15 +1996,13 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
|
}
|
|
|
//审核进行中
|
|
|
if isApproving {
|
|
|
rsp.EditChance = 1
|
|
|
allPermission()
|
|
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(auditProcess) > 0 {
|
|
|
rsp.EditChance = 0
|
|
|
noPermission()
|
|
|
log.Debug(fmt.Sprintf("用户:%v 审核过,并且当前机会在审核中 编辑权限:false", header.UserId))
|
|
|
}
|
|
|
if chance.ReviewStatus == protocol.ReviewStatusPass && len(auditProcess) > 0 { //已通过的机会 并且是审批人 有所有编辑权限
|
|
|
rsp.EditChance = 1
|
|
|
rsp.EditPublicStatus = 1
|
|
|
rsp.EditScore = 1
|
|
|
allPermission()
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|