コード例 #1
0
        public IActionResult OnMyManage([FromBody] UserManageRangeModifyViewModel model)
        {
            if (model.Auth == null || !model.Auth.Verify(authService, currentUserService.CurrentUser?.Id))
            {
                return(new JsonResult(ActionStatusMessage.Account.Auth.Invalid.Default));
            }
            var id       = model.Id ?? currentUserService.CurrentUser?.Id;
            var authUser = usersService.GetById(model.Auth.AuthByUserID);

            if (authUser == null)
            {
                return(new JsonResult(ActionStatusMessage.UserMessage.NotExist));
            }
            var targetUser = usersService.GetById(id);
            var permit     = userActionServices.Permission(authUser.Application.Permission, DictionaryAllPermission.User.Application, Operation.Remove, authUser.Id, model.Code);

            if (targetUser == null)
            {
                return(new JsonResult(ActionStatusMessage.UserMessage.NotExist));
            }
            var manages = companyManagerServices.GetManagers(model.Code);
            var manage  = manages.Where(u => u.CompanyCode == targetUser.Id).FirstOrDefault();

            ; if (manage == null)
            {
                return(new JsonResult(ActionStatusMessage.CompanyMessage.ManagerMessage.NotExist));
            }
            var unused = companyManagerServices.Delete(manage);

            return(new JsonResult(ActionStatusMessage.Success));
        }
        /// <summary>
        /// 用户对指定申请进行审批
        /// </summary>
        /// <param name="model">目标申请</param>
        /// <param name="myManages">用户所管辖的单位列表</param>
        /// <param name="AuditUser">审批人</param>
        /// <returns></returns>
        private ApiResult AuditSingle <T>(ref ApplyAuditNodeVdto <T> model, User AuditUser) where T : IAuditable
        {
            var apply = model.AuditItem;

            if (apply == null)
            {
                return(ActionStatusMessage.ApplyMessage.NotExist);
            }
            var nowStep = apply.NowAuditStep;
            List <ApplyAuditStep> allStep = new List <ApplyAuditStep>(apply.ApplyAllAuditStep);

            // 审批未发布时 不可进行审批
            if (nowStep == null)
            {
                return(ActionStatusMessage.ApplyMessage.Operation.Audit.BeenAuditOrNotReceived);
            }
            if (apply.Status != AuditStatus.AcceptAndWaitAdmin && apply.Status != AuditStatus.Auditing)
            {
                return(ActionStatusMessage.ApplyMessage.Operation.Audit.NotOnAudingStatus);
            }
            // 如果当前审批人是本单位管理,则本轮审批直接通过
            var company        = nowStep.FirstMemberCompanyCode;
            var managers       = companyManagerServices.GetManagers(company).Select(m => m.UserId).ToList();
            var isManagerAudit = managers.Contains(AuditUser.Id);

            if (!isManagerAudit)
            {
                // 待审批人无当前用户时,返回无效
                if (!nowStep.MembersFitToAudit.Split("##").Contains(AuditUser.Id))
                {
                    return(ActionStatusMessage.ApplyMessage.Operation.Audit.NoYourAuditStream);
                }
                if (nowStep.MembersAcceptToAudit.Split("##").Contains(AuditUser.Id))
                {
                    return(ActionStatusMessage.ApplyMessage.Operation.Audit.BeenAudit);
                }
            }

            // 当审批的申请为未发布的申请时,将其发布
            //if (apply.Status == AuditStatus.NotSave || AuditStatus.NotPublish == apply.Status)
            //	ModifyAuditStatus(apply, AuditStatus.Auditing);
            var list = AddAuditRecord(nowStep, AuditUser, model);

            // 判断是否被驳回
            if (model.Action != AuditResult.Accept)
            {
                apply.Status = AuditStatus.Denied;
            }
            // 判断本步骤是否结束
            // 当  需审批人数<=已审批人数,需审批数为0表示需要所有人审批
            // 或  已审批人数=可审批人数
            // 或  为管理员审批
            else if (
                (nowStep.RequireMembersAcceptCount <= list.Length && nowStep.RequireMembersAcceptCount > 0) ||
                (nowStep.MembersAcceptToAudit.Length >= nowStep.MembersFitToAudit.Length) ||
                isManagerAudit)
            {
                GoNextStep(ref apply, nowStep, allStep);
            }
            return(ActionStatusMessage.Success);
        }