コード例 #1
0
        public JsonResult Page(int pageIndex, int pageSize, string name, string inRole, string outRole, int?deptID)
        {
            var sql = Sql.Builder.Where("is_super_user=0 and (real_name like @0 or user_name like @0)", "%" + name + "%");

            if (!string.IsNullOrEmpty(inRole))
            {
                sql.Where("role_id = @0", inRole.ToInt());
            }
            else if (!string.IsNullOrEmpty(outRole))
            {
                sql.Where("role_id <> @0", outRole.ToInt());
            }

            if (deptID.HasValue)
            {
                sql.Where("dept_id in (@0)", BasicDataCache.GetSubDepts(deptID.Value).Select(d => d.ID));
            }

            var page = SysUser.Page(pageIndex, pageSize, sql);

            return(Json(new ResponseData
            {
                Total = page.TotalItems,
                Data = page.Items.Select(user => new
                {
                    user.ID,
                    user.Email,
                    user.UserName,
                    user.RealName,
                    user.Phone,
                    user.EmployedDate,
                    DeptName = user.DeptID.ToDept().GetFullDeptName(),
                    RoleName = user.RoleID.ToRole().Name
                })
            }));
        }
コード例 #2
0
        public JsonResult AuditPage(int pageIndex, int pageSize, int?typeID, int?deptID)
        {
            var sql = Sql.Builder.Where("status in (@0,@1)", EnumVacationApplyStatus.Apply, EnumVacationApplyStatus.Audited);

            if (typeID.HasValue)
            {
                sql.Where("vacation_type_id=@0", typeID.Value);
            }

            // 如果没有查看总站的权限时
            if (!SysHelper.HasPower("vacation_apply_aduit_all"))
            {
                if (SysHelper.HasPower("vacation_apply_aduit_site"))
                {
                    if (!deptID.HasValue)
                    {
                        deptID = BasicDataCache.listDepts.Single(d => d.ID == CurrUser.DeptID).ParentID;
                    }
                }
                else
                {
                    if (!deptID.HasValue)
                    {
                        deptID = CurrUser.DeptID;
                    }
                }
            }

            if (deptID.HasValue)
            {
                sql.Where("user_id in (select id from sys_users where dept_id in (@0))", BasicDataCache.GetSubDepts(deptID.Value).Select(d => d.ID));
            }

            // 找出需要审核的流程
            var flows = BasicDataCache.listVacationAuditFlows.Where(flow => flow.AuditRoleIDs.ToIntList().Contains(CurrUser.RoleID));

            if (flows.HasElements())
            {
                // 判断范围

                List <string> scopes = new List <string>();

                foreach (var item in flows)
                {
                    switch (item.DeptLevel)
                    {
                    case EnumDeptLevel.TheOrSub:
                    {
                        scopes.Add(string.Format("flow_id={0} and user_id in (select id from sys_users where dept_id in({1}))", item.ID, BasicDataCache.GetSubDepts(CurrUser.DeptID).Select(d => d.ID).Join()));
                    }
                    break;

                    case EnumDeptLevel.TheSite:
                    {
                        scopes.Add(string.Format("flow_id={0} and user_id in (select id from sys_users where dept_id in({1}))", item.ID, BasicDataCache.GetSubDepts(BasicDataCache.GetSite(CurrUser.DeptID).ID).Select(d => d.ID).Join()));
                    }
                    break;

                    case EnumDeptLevel.All:
                    {
                        scopes.Add(string.Format("flow_id={0}", item.ID));
                    }
                    break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                sql.Where(scopes.Join(" or "));
            }
            else
            {
                return(Json(new ResponseData {
                    Total = 0, Data = new List <VacationApplyModel>()
                }));
            }

            var page = VacationApply.Page(pageIndex, pageSize, sql);

            List <VacationApplyModel> result = CreateModel(page);

            return(Json(new ResponseData
            {
                Total = page.TotalItems,
                Data = result
            }));
        }
コード例 #3
0
        public JsonResult Page(int pageIndex, int pageSize, int?typeID, int?deptID)
        {
            var sql = Sql.Builder;

            if (typeID.HasValue)
            {
                sql.Where("vacation_type_id=@0", typeID.Value);
            }
            // 如果没有查看总站的权限时
            if (!SysHelper.HasPower("vacation_record_all"))
            {
                if (SysHelper.HasPower("vacation_record_site"))
                {
                    if (!deptID.HasValue)
                    {
                        deptID = BasicDataCache.listDepts.Single(d => d.ID == CurrUser.DeptID).ParentID;
                    }
                }
                else
                {
                    if (!deptID.HasValue)
                    {
                        deptID = CurrUser.DeptID;
                    }
                }
            }

            if (deptID.HasValue)
            {
                sql.Where("user_id in (select id from sys_users where dept_id in (@0))", BasicDataCache.GetSubDepts(deptID.Value).Select(d => d.ID));
            }

            var page = VacationApply.Page(pageIndex, pageSize, sql);

            List <VacationApplyModel> result = CreateModel(page);

            return(Json(new ResponseData
            {
                Total = page.TotalItems,
                Data = result
            }));
        }