diff --git a/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs b/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs index 05f20eaa..2978495f 100644 --- a/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs +++ b/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs @@ -13,6 +13,7 @@ using YiSha.Util.Model; using YiSha.Util.Extension; using YiSha.Web.Code; +using NPOI.SS.Formula.Functions; namespace YiSha.Business.OrganizationManage { @@ -32,10 +33,18 @@ public async Task>> GetList(DepartmentListParam par List childrenDepartmentIdList = await GetChildrenDepartmentIdList(obj.Data, operatorInfo.DepartmentId.Value); obj.Data = obj.Data.Where(p => childrenDepartmentIdList.Contains(p.Id.Value)).ToList(); } - List userList = await userService.GetList(new UserListParam { UserIds = string.Join(",", obj.Data.Select(p => p.PrincipalId).ToArray()) }); + List userList = new List(); + if (obj.Data.Count > 0) + { + var userIdsArr = obj.Data.Where(p => p.PrincipalId > 0).Select(p => p.PrincipalId.Value); + if (userIdsArr.Count() > 0) + { + userList = await userService.GetList(new UserListParam { UserIds = userIdsArr.ToArray() }); + } + } foreach (DepartmentEntity entity in obj.Data) { - if (entity.PrincipalId > 0) + if (entity.PrincipalId > 0 && userList.Count > 0 ) { entity.PrincipalName = userList.Where(p => p.Id == entity.PrincipalId).Select(p => p.RealName).FirstOrDefault(); } diff --git a/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs b/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs index 0412d829..5b9c629c 100644 --- a/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs +++ b/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs @@ -166,54 +166,62 @@ public async Task ChangeUser(UserEntity entity) #region 私有方法 private Expression> ListFilter(UserListParam param) { - - //var expression = LinqExtensions.True(); - - if (param.UserStatus == -1) - { - param.UserStatus = null; - } - - //****根据查询字段自动过滤条件**** - var expression = LinqExtensions.GetExpressionItems(param); - - if (param != null) + if(param != null) { - //if (!string.IsNullOrEmpty(param.UserName)) - //{ - // expression = expression.And(t => t.UserName.Contains(param.UserName)); - //} - - - if (!string.IsNullOrEmpty(param.UserIds)) + if (param.UserStatus == -1) { - long[] userIdList = TextHelper.SplitToArray(param.UserIds, ','); - expression = expression.And(t => userIdList.Contains(t.Id.Value)); - } - - //if (!string.IsNullOrEmpty(param.Mobile)) - //{ - // expression = expression.And(t => t.Mobile.Contains(param.Mobile)); - //} - //if (param.UserStatus > -1) - //{ - // expression = expression.And(t => t.UserStatus == param.UserStatus); - //} - - if (!string.IsNullOrEmpty(param.StartTime.ParseToString())) - { - expression = expression.And(t => t.BaseModifyTime >= param.StartTime); + param.UserStatus = null; } if (!string.IsNullOrEmpty(param.EndTime.ParseToString())) { param.EndTime = param.EndTime.Value.Date.Add(new TimeSpan(23, 59, 59)); - expression = expression.And(t => t.BaseModifyTime <= param.EndTime); - } - if (param.ChildrenDepartmentIdList != null && param.ChildrenDepartmentIdList.Count > 0) - { - expression = expression.And(t => param.ChildrenDepartmentIdList.Contains(t.DepartmentId.Value)); } } + //****根据查询字段自动过滤条件**** + var expression = LinqExtensions.GetExpressionItems(param); + + //if (param != null) + //{ + // //if (param.UserStatus == -1) + // //{ + // // param.UserStatus = null; + // //} + + // //if (!string.IsNullOrEmpty(param.UserName)) + // //{ + // // expression = expression.And(t => t.UserName.Contains(param.UserName)); + // //} + + + // //if (!string.IsNullOrEmpty(param.UserIds)) + // //{ + // // long[] userIdList = TextHelper.SplitToArray(param.UserIds, ','); + // // expression = expression.And(t => userIdList.Contains(t.Id.Value)); + // //} + + // //if (!string.IsNullOrEmpty(param.Mobile)) + // //{ + // // expression = expression.And(t => t.Mobile.Contains(param.Mobile)); + // //} + // //if (param.UserStatus > -1) + // //{ + // // expression = expression.And(t => t.UserStatus == param.UserStatus); + // //} + + // //if (!string.IsNullOrEmpty(param.StartTime.ParseToString())) + // //{ + // // expression = expression.And(t => t.BaseModifyTime >= param.StartTime); + // //} + // //if (!string.IsNullOrEmpty(param.EndTime.ParseToString())) + // //{ + // // param.EndTime = param.EndTime.Value.Date.Add(new TimeSpan(23, 59, 59)); + // // expression = expression.And(t => t.BaseModifyTime <= param.EndTime); + // //} + // //if (param.ChildrenDepartmentIdList != null && param.ChildrenDepartmentIdList.Count > 0) + // //{ + // // expression = expression.And(t => param.ChildrenDepartmentIdList.Contains(t.DepartmentId.Value)); + // //} + //} return expression; } #endregion diff --git a/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs b/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs index 1d8a64ad..58f5ed74 100644 --- a/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs +++ b/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using YiSha.Util.Extension; namespace YiSha.Model.Param { @@ -11,11 +12,13 @@ public class DateTimeParam /// /// 搜索条件开始时间 /// - public DateTime? StartTime { get; set; } + [QueryCompareAttribute(FieldName = "BaseModifyTime",Compare =CompareEnum.GreaterThanOrEquals)] + public virtual DateTime? StartTime { get; set; } /// /// 搜索条件结束时间 /// - public DateTime? EndTime { get; set; } + [QueryCompareAttribute(FieldName = "BaseModifyTime", Compare = CompareEnum.LessThanOrEquals)] + public virtual DateTime? EndTime { get; set; } } } diff --git a/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs b/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs index 471b3a02..1a052f1a 100644 --- a/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs +++ b/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs @@ -1,22 +1,23 @@ using System; using System.Collections.Generic; using YiSha.Entity.OrganizationManage; +using YiSha.Util.Extension; namespace YiSha.Model.Param.OrganizationManage { public class UserListParam : DateTimeParam { + [QueryCompareAttribute(Compare = CompareEnum.Contains)] public string UserName { get; set; } - + [QueryCompareAttribute(Compare = CompareEnum.Contains)] public string Mobile { get; set; } - + [QueryCompareAttribute(Compare = CompareEnum.Equals)] public int? UserStatus { get; set; } - public long? DepartmentId { get; set; } - + [QueryCompareAttribute(FieldName = "DepartmentId", Compare = CompareEnum.In)] public List ChildrenDepartmentIdList { get; set; } - - public string UserIds { get; set; } + [QueryCompareAttribute(FieldName ="Id",Compare = CompareEnum.In)] + public long[] UserIds { get; set; } } public class ChangePasswordParam diff --git a/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs b/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs index b6d31cea..efaa4bf2 100644 --- a/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs +++ b/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs @@ -1,9 +1,15 @@ -using System; +using Microsoft.AspNetCore.JsonPatch.Operations; +using NLog.LayoutRenderers; +using NPOI.SS.Formula.Functions; +using NPOI.Util; +using System; +using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; +using System.Reflection; +using System.Reflection.Metadata; namespace YiSha.Util.Extension { @@ -13,26 +19,32 @@ public static Expression Property(this Expression expression, string propertyNam { return Expression.Property(expression, propertyName); } + public static Expression AndAlso(this Expression left, Expression right) { return Expression.AndAlso(left, right); } + public static Expression Call(this Expression instance, string methodName, params Expression[] arguments) { return Expression.Call(instance, instance.Type.GetMethod(methodName), arguments); } + public static Expression GreaterThan(this Expression left, Expression right) { return Expression.GreaterThan(left, right); } + public static Expression ToLambda(this Expression body, params ParameterExpression[] parameters) { return Expression.Lambda(body, parameters); } - public static Expression> True() { return param => true; } + public static Expression> True() + { return param => true; } - public static Expression> False() { return param => false; } + public static Expression> False() + { return param => false; } /// /// 组合And @@ -42,6 +54,7 @@ public static Expression> And(this Expression> fi { return first.Compose(second, Expression.AndAlso); } + /// /// 组合Or /// @@ -54,7 +67,7 @@ public static Expression> Or(this Expression> fir /// /// Combines the first expression with the second using the specified merge function. /// - static Expression Compose(this Expression first, Expression second, Func merge) + private static Expression Compose(this Expression first, Expression second, Func merge) { var map = first.Parameters .Select((f, i) => new { f, s = second.Parameters[i] }) @@ -71,138 +84,33 @@ static Expression Compose(this Expression first, Expression second, /// public static Expression> GetExpressionItems(TT input) { - var parameter = Expression.Parameter(typeof(T), "entity"); - Expression expression = Expression.Constant(true); - - var properties = typeof(TT).GetProperties(); - - var targetProperties = typeof(T).GetProperties(); - - foreach (var property in properties) + if (input == null) return x => true; + List cndQueryList = new List(); + var allProperty = typeof(TT).GetProperties(); + foreach (var p in allProperty) { - //字符类型筛选 - if (property.PropertyType == typeof(string)) - { - + var compareAttr = p.GetCustomAttribute(); + if (compareAttr != null && compareAttr.IsIgnore) continue; + var val = p.GetValue(input,null); + if ( val == null || string.IsNullOrEmpty(val.ToString())) continue; - var value = property.GetValue(input); - - if (value != null && !string.IsNullOrEmpty(value.ToString())) - { - var propertyExpression = Expression.Property(parameter, property.Name); - var valueExpression = Expression.Constant(value); - var containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); - var containsExpression = Expression.Call(propertyExpression, containsMethod, valueExpression); - expression = Expression.AndAlso(expression, containsExpression); - } - } - //日期类型筛选 - else if (property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?)) - { - var value = property.GetValue(input); - - if (value != null) - { - // 开始日期筛选 - if (property.Name.Contains("Start")) - { - var realPropertyName = property.Name.Substring(0, property.Name.Length - "Start".Length); - var propertyExpression = Expression.Property(parameter, realPropertyName); - var entityfield = targetProperties.FirstOrDefault(s => s.Name == realPropertyName); - var startDateTime = (DateTime)value; - - if (entityfield.PropertyType == typeof(DateTime?)) - { - var greaterThanOrEqualExpression = Expression.GreaterThanOrEqual(propertyExpression, Expression.Constant(startDateTime, typeof(DateTime?))); - expression = Expression.AndAlso(expression, greaterThanOrEqualExpression); - } - else - { - var greaterThanOrEqualExpression = Expression.GreaterThanOrEqual(propertyExpression, Expression.Constant(startDateTime)); - expression = Expression.AndAlso(expression, greaterThanOrEqualExpression); - } - - } - // 结束日期筛选 - else if (property.Name.Contains("End")) - { - var realPropertyName = property.Name.Substring(0, property.Name.Length - "End".Length); - var propertyExpression = Expression.Property(parameter, realPropertyName); - var entityfield = targetProperties.FirstOrDefault(s => s.Name == realPropertyName); - var endDateTime = ((DateTime)value).Date.AddDays(1).AddTicks(-1); - - if (entityfield.PropertyType == typeof(DateTime?)) - { - var lessThanOrEqualExpression = Expression.LessThanOrEqual(propertyExpression, Expression.Constant(endDateTime, typeof(DateTime?))); - expression = Expression.AndAlso(expression, lessThanOrEqualExpression); - } - else - { - var lessThanOrEqualExpression = Expression.LessThanOrEqual(propertyExpression, Expression.Constant(endDateTime)); - expression = Expression.AndAlso(expression, lessThanOrEqualExpression); - } - - } - // 其他日期属性 - else - { - var propertyExpression = Expression.Property(parameter, property.Name); - var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); - expression = Expression.AndAlso(expression, equalExpression); - } - } - - } - //数值类型 - else if (property.PropertyType == typeof(int?) || property.PropertyType == typeof(int)) + //查找和实体映射的属性名和值以及操作符 + string fieldName = p.Name; + CompareEnum compareType = CompareEnum.Equals; + if (compareAttr != null) { - var value = property.GetValue(input); - var propertyExpression = Expression.Property(parameter, property.Name); - var entityfield = targetProperties.FirstOrDefault(s => s.Name == property.Name); - - if (value != null) - { - if (entityfield.PropertyType == typeof(int?)) - { - var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value, typeof(int?))); - expression = Expression.AndAlso(expression, equalExpression); - } - else - { - var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); - expression = Expression.AndAlso(expression, equalExpression); - } - - } - + fieldName = string.IsNullOrWhiteSpace(compareAttr.FieldName) ? p.Name : compareAttr.FieldName; + compareType = compareAttr.Compare; } - //float - else if (property.PropertyType == typeof(float?) || property.PropertyType == typeof(float)) + cndQueryList.Add(new QueryCompareAttribute() { - var value = property.GetValue(input); - var propertyExpression = Expression.Property(parameter, property.Name); - var entityfield = targetProperties.FirstOrDefault(s => s.Name == property.Name); - - if (value != null) - { - if (entityfield.PropertyType == typeof(float?)) - { - var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value, typeof(float?))); - expression = Expression.AndAlso(expression, equalExpression); - } - else - { - var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); - expression = Expression.AndAlso(expression, equalExpression); - } - - } - - } - + FieldName = fieldName, + Value = val, + Compare = compareType, + }); } - - return Expression.Lambda>(expression, parameter); + var exp = BuildAndAlsoLambda(cndQueryList); + return exp; } /// @@ -213,15 +121,17 @@ private class ParameterRebinder : ExpressionVisitor /// /// The ParameterExpression map /// - readonly Dictionary map; + private readonly Dictionary map; + /// /// Initializes a new instance of the class. /// /// The map. - ParameterRebinder(Dictionary map) + private ParameterRebinder(Dictionary map) { this.map = map ?? new Dictionary(); } + /// /// Replaces the parameters. /// @@ -232,6 +142,7 @@ public static Expression ReplaceParameters(Dictionary /// Visits the parameter. /// @@ -247,7 +158,164 @@ protected override Expression VisitParameter(ParameterExpression p) } return base.VisitParameter(p); } + } + /// + /// + /// + /// + /// + private static bool IsNullable(PropertyInfo propertyInfo) + { + Type propertyType = propertyInfo.PropertyType; + return propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>); } + + private static Expression GetExpression(ParameterExpression parameter, QueryCompareAttribute condition) + { + var propertyParam = Expression.Property(parameter, condition.FieldName); + + var propertyInfo = propertyParam.Member as PropertyInfo; + if (propertyInfo == null) + throw new MissingMemberException(nameof(QueryCompareAttribute), condition.FieldName); + + //Support Nullable<> + var realPropertyType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType; + if (propertyInfo.PropertyType.IsGenericType && propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) + propertyParam = Expression.Property(propertyParam, "Value"); + + //Support IEnumerable && IEnumerable + if (condition.Compare != CompareEnum.In && condition.Compare != CompareEnum.NotIn) + { + condition.Value = Convert.ChangeType(condition.Value, realPropertyType); + } + else + { + var typeOfValue = condition.Value.GetType(); + var typeOfList = typeof(IEnumerable<>).MakeGenericType(realPropertyType); + if (typeOfValue.IsGenericType && typeOfList.IsAssignableFrom(typeOfValue)) + condition.Value = typeof(Enumerable) + .GetMethod("ToArray", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) + .MakeGenericMethod(realPropertyType) + .Invoke(null, new object[] { condition.Value }); + } + + var constantParam = Expression.Constant(condition.Value); + switch (condition.Compare) + { + case CompareEnum.Equals: + return Expression.Equal(propertyParam, constantParam); + + case CompareEnum.NotEquals: + return Expression.NotEqual(propertyParam, constantParam); + + case CompareEnum.Contains: + return Expression.Call(propertyParam, "Contains", null, constantParam); ; + case CompareEnum.NotContains: + return Expression.Not(Expression.Call(propertyParam, "Contains", null, constantParam)); + + case CompareEnum.StartsWith: + return Expression.Call(propertyParam, "StartsWith", null, constantParam); + + case CompareEnum.EndsWith: + return Expression.Call(propertyParam, "EndsWith", null, constantParam); + + case CompareEnum.GreaterThan: + return Expression.GreaterThan(propertyParam, constantParam); + + case CompareEnum.GreaterThanOrEquals: + return Expression.GreaterThanOrEqual(propertyParam, constantParam); + + case CompareEnum.LessThan: + return Expression.LessThan(propertyParam, constantParam); + + case CompareEnum.LessThanOrEquals: + return Expression.LessThanOrEqual(propertyParam, constantParam); + + case CompareEnum.In: + return Expression.Call(typeof(Enumerable), "Contains", new Type[] { realPropertyType }, new Expression[] { constantParam, propertyParam }); + + case CompareEnum.NotIn: + return Expression.Not(Expression.Call(typeof(Enumerable), "Contains", new Type[] { realPropertyType }, new Expression[] { constantParam, propertyParam })); + + default: + return Expression.Equal(propertyParam, constantParam); + } + } + + public static Expression> BuildAndAlsoLambda(IEnumerable conditions) + { + if (conditions == null || !conditions.Any()) + return x => true; + + var parameter = Expression.Parameter(typeof(T), "x"); + var simpleExps = conditions + .ToList() + .Select(c => GetExpression(parameter, c)) + .ToList(); + + var exp = simpleExps.Aggregate(null, (left, right) => + left == null ? right : Expression.AndAlso(left, right)); + return Expression.Lambda>(exp, parameter); + } + + public static Expression> BuildOrElseLambda(IEnumerable conditions) + { + if (conditions == null || !conditions.Any()) + return x => true; + + var parameter = Expression.Parameter(typeof(T), "x"); + var simpleExps = conditions + .ToList() + .Select(c => GetExpression(parameter, c)) + .ToList(); + + var exp = simpleExps.Aggregate(null, (left, right) => + left == null ? right : Expression.OrElse(left, right)); + return Expression.Lambda>(exp, parameter); + } + } + + /// + /// 查询比较符枚举 + /// + public enum CompareEnum + { + Equals = 1, + NotEquals = 2, + LessThan = 3, + LessThanOrEquals = 4, + GreaterThan = 5, + GreaterThanOrEquals = 6, + In = 7, + NotIn = 8, + Contains = 9, + NotContains = 10, + StartsWith = 11, + EndsWith = 12 + } + + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public class QueryCompareAttribute : Attribute + { + /// + /// 属性名 + /// + public string FieldName { get; set; } + + /// + /// 表达式拼接运算符号 + /// + public CompareEnum Compare = CompareEnum.Equals; + + /// + /// 值 + /// + public object Value { get; set; } + + /// + /// 是否忽略该属性 + /// + public bool IsIgnore { get; set; } } -} +} \ No newline at end of file diff --git a/YiSha.Web/YiSha.Admin.Web/wwwroot/yisha/js/yisha.min.js b/YiSha.Web/YiSha.Admin.Web/wwwroot/yisha/js/yisha.min.js index 4cc18626..827dbaa6 100644 --- a/YiSha.Web/YiSha.Admin.Web/wwwroot/yisha/js/yisha.min.js +++ b/YiSha.Web/YiSha.Admin.Web/wwwroot/yisha/js/yisha.min.js @@ -1 +1 @@ -window.ys={},function(n,t){"use strict";n.extend(t,{openDialog:function(i){t.isMobile()?(i.width="auto",i.height="auto"):i.height||(i.height=n(window).height()-50+"px");var r=n.extend({type:2,title:"",width:"768px",content:"",maxmin:!0,shade:.4,btn:["确认","关闭"],callback:null,shadeClose:!1,fix:!1,closeBtn:1},i);layer.open({type:r.type,area:[r.width,r.height],maxmin:r.maxmin,shade:r.shade,title:r.title,content:r.content,btn:r.btn,shadeClose:r.shadeClose,fix:r.fix,closeBtn:r.closeBtn,yes:r.callback,cancel:function(){return!0}})},openDialogContent:function(i){t.isMobile()?(i.width="auto",i.height="auto"):i.height||(i.height=n(window).height()-50+"px");var r=n.extend({type:1,title:!1,width:"768px",content:"",maxmin:!1,shade:.4,btn:null,callback:null,shadeClose:!0,fix:!0,closeBtn:0},i);layer.open({type:r.type,area:[r.width,r.height],maxmin:r.maxmin,shade:r.shade,title:r.title,content:r.content,btn:r.btn,shadeClose:r.shadeClose,fix:r.fix,closeBtn:r.closeBtn,yes:r.callback,cancel:function(){return!0}})},closeDialog:function(){var n=parent.layer.getFrameIndex(window.name);parent.layer.close(n)},msgWarning:function(n){layer.msg(n,{icon:0,time:1e3,shift:5})},msgSuccess:function(n){t.isNullOrEmpty(n)&&(n="操作成功");top.layer.msg(n,{icon:1,time:1e3,shift:5})},msgError:function(n){t.isNullOrEmpty(n)&&(n="操作失败");layer.msg(n,{icon:2,time:3e3,shift:5})},alertWarning:function(n){layer.alert(n,{icon:0,title:"系统提示",btn:["确认"],btnclass:["btn btn-primary"]})},alertSuccess:function(n){layer.alert(n,{icon:1,title:"系统提示",btn:["确认"],btnclass:["btn btn-primary"]})},alertError:function(n){layer.alert(n,{icon:2,title:"系统提示",btn:["确认"],btnclass:["btn btn-primary"]})},confirm:function(n,t){layer.confirm(n,{icon:3,title:"系统提示",btn:["确认","取消"],btnclass:["btn btn-primary","btn btn-danger"]},function(n){layer.close(n);t(!0)})},showLoading:function(t){n.blockUI({message:'
<\/div> '+t+"<\/div>",css:{border:"none",backgroundColor:"transparent"}})},closeLoading:function(){setTimeout(function(){n.unblockUI()},50)},getIds:function(t){var i="";return n.each(t,function(n,t){n==0?i=t.Id:i+=","+t.Id}),i},checkRowEdit:function(n){if(n.length==0)t.msgError("您没有选择任何行!");else if(n.length>1)t.msgError("您的选择大于1行!");else if(n.length==1)return!0;return!1},checkRowDelete:function(n){if(n.length==0)t.msgError("您没有选择任何行!");else if(n.length>0)return!0;return!1},ajax:function(i){var r=n.extend({url:i.url,"async":!0,type:"get",data:i.data||{},dataType:i.dataType||"json",error:function(){t.alertError("系统出错了")},success:function(){t.msgSuccess()},beforeSend:function(){t.showLoading("正在处理中...")},complete:function(){t.closeLoading()}},i);if(t.isNullOrEmpty(r.url)){t.alertError("url 参数不能为空");return}n.ajax({url:r.url,"async":r.async,type:r.type,data:r.data,dataType:r.dataType,error:r.error,success:r.success,beforeSend:r.beforeSend,complete:r.complete})},ajaxUploadFile:function(i){var r=n.extend({url:i.url,data:i.data||{},error:function(){t.alertError("系统出错了")},success:function(){t.msgSuccess()},beforeSend:function(){t.showLoading("正在处理中...")},complete:function(){t.closeLoading()}},i);if(t.isNullOrEmpty(r.url)){t.alertError("url 参数不能为空");return}if(t.isNullOrEmpty(r.data)){t.alertError("data 参数不能为空");return}n.ajax({url:r.url,data:r.data,type:"post",processData:!1,contentType:!1,error:r.error,success:r.success,beforeSend:r.beforeSend,complete:r.complete})},exportExcel:function(n,i){t.ajax({url:n,type:"post",data:i,success:function(n){n.Tag==1?window.location.href=ctx+"File/DownloadFile?filePath="+n.Data+"&delete=1":t.msgError(n.Message)},beforeSend:function(){t.showLoading("正在导出数据,请稍后...")}})},request:function(n){var i=decodeURI(window.location.search),r=new RegExp("(^|&)"+n+"=([^&]*)(&|$)"),t=i.substr(1).match(r);return t!=null?unescape(t[2]):null},getHttpFileName:function(n){if(n==null||n=="")return n;var t=n.lastIndexOf("/");return t>0?n.substring(t+1):n},getFileNameWithoutExtension:function(n){if(n==null||n=="")return n;var t=n.indexOf(".");return t>0?n.substring(0,t):n},changeURLParam:function(n,t,i){var e=t+"=([^&]*)",r=t+"="+i,f,u;return n.match(e)?(f="/("+t+"=)([^&]*)/gi",n.replace(eval(f),r)):n.match("[?]")?(u=n.split("#"),u.length>1?u[0]+"&"+r+"#"+u[1]:n+"&"+r):n+"?"+r},isNullOrEmpty:function(n){return typeof n=="string"&&n==""||n==null||n==undefined?!0:!1},getJson:function(n){return n},getGuid:function(){for(var i,t="",n=1;n<=32;n++)i=Math.floor(Math.random()*16).toString(16),t+=i,(n==8||n==12||n==16||n==20)&&(t+="-");return t},getValueByKey:function(t,i){var r="";return n.each(t,function(n,t){t.Key==i&&(r=t.Value)}),r},getLastValue:function(n){if(!t.isNullOrEmpty(n)){var i=n.toString().split(",");return i[i.length-1]}return""},formatDate:function(n,t){var i,r,u;if(!n)return"";i=n;typeof n=="string"&&(i=n.indexOf("/Date(")>-1?new Date(parseInt(n.replace("/Date(","").replace(")/",""),10)):new Date(Date.parse(n.replace(/-/g,"/").replace("T"," ").split(".")[0])));r={"M+":i.getMonth()+1,"d+":i.getDate(),"H+":i.getHours(),"m+":i.getMinutes(),"s+":i.getSeconds(),"q+":Math.floor((i.getMonth()+3)/3),S:i.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(i.getFullYear()+"").substr(4-RegExp.$1.length)));for(u in r)new RegExp("("+u+")").test(t)&&(t=t.replace(RegExp.$1,RegExp.$1.length==1?r[u]:("00"+r[u]).substr((""+r[u]).length)));return t},trimStart:function(n,t){var r,i;return t==null||t==""?n.replace(/^s*/,""):(r=new RegExp("^"+t+"*"),i=n.replace(r,""),i)},trimEnd:function(n,t){var r,i;if(t==null||t==""){for(r=/s/,i=n.length;r.test(n.charAt(--i)););return n.slice(0,i+1)}for(r=new RegExp(t),i=n.length;r.test(n.charAt(--i)););return n.slice(0,i+1)},toString:function(n){return n==null?"":n.toString()},openLink:function(n,t){var i=document.createElement("a");i.target=t?t:"_blank";i.href=n;i.click()},recursion:function(n,i,r,u,f){u||(u="id");f||(f="parentId");for(var e in n)if(n[e][u]==i)return r.push(n[e]),t.recursion(n,n[e][f],r,u,f)},isMobile:function(){return navigator.userAgent.match(/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i)}})}(window.jQuery,window.ys),function(n){"use strict";n.fn.ysRadioBox=function(t,i){var u,f,r,e;return typeof t=="string"?n.fn.ysRadioBox.methods[t](this,i):(u=n(this),f=u.attr("id"),!f)?!1:(r=n.extend({url:null,key:"Key",value:"Value",data:null,dataName:"Data","default":undefined},t),e={loadData:function(){r.url&&n.ajax({url:r.url,type:"get",dataType:"json","async":!1,cache:!1,success:function(n){r.data=n;r.dataName&&r.data!=null&&(r.data=r.data[r.dataName])},error:function(){throw exception;}})},render:function(t){if(t.data&&t.data.length>=0){var r=u.attr("ref"),e=f+"_radiobox",i="";n.each(t.data,function(n){var u=t.data[n];i+="