From 54a935b0d024a26475acb6d7819812515c714662 Mon Sep 17 00:00:00 2001 From: ydy <517697206@qq.com> Date: Wed, 19 Jun 2024 18:51:45 +0800 Subject: [PATCH 1/3] fix:#170 for query bug --- .../OrganizationManage/DepartmentBLL.cs | 13 +- .../OrganizationManage/UserService.cs | 30 +- .../YiSha.Model/Param/DateTimeParam.cs | 3 + .../Param/OrganizationManage/UserParam.cs | 5 +- .../YiSha.Util/Extension/Extension.Linq.cs | 268 +++++++++++------- .../wwwroot/yisha/js/yisha.min.js | 2 +- 6 files changed, 191 insertions(+), 130 deletions(-) diff --git a/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs b/YiSha.Business/YiSha.Business/OrganizationManage/DepartmentBLL.cs index 05f20eaa..061231ce 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).ToArray(); + if (userIdsArr.Length > 0) + { + userList = await userService.GetList(new UserListParam { UserIds = string.Join(",", userIdsArr) }); + } + } 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..7dd18152 100644 --- a/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs +++ b/YiSha.Business/YiSha.Service/OrganizationManage/UserService.cs @@ -166,19 +166,15 @@ 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.UserStatus == -1) + { + param.UserStatus = null; + } //if (!string.IsNullOrEmpty(param.UserName)) //{ // expression = expression.And(t => t.UserName.Contains(param.UserName)); @@ -200,15 +196,15 @@ private Expression> ListFilter(UserListParam param) // 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 (!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)); diff --git a/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs b/YiSha.Entity/YiSha.Model/Param/DateTimeParam.cs index 1d8a64ad..c0c3486e 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 /// /// 搜索条件开始时间 /// + [LinqExpressionXAttribute(Name = "BaseModifyTime")] public DateTime? StartTime { get; set; } /// /// 搜索条件结束时间 /// + [LinqExpressionXAttribute(Name = "BaseModifyTime")] public 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..026db2f3 100644 --- a/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs +++ b/YiSha.Entity/YiSha.Model/Param/OrganizationManage/UserParam.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using YiSha.Entity.OrganizationManage; +using YiSha.Util.Extension; namespace YiSha.Model.Param.OrganizationManage { @@ -13,9 +14,9 @@ public class UserListParam : DateTimeParam public int? UserStatus { get; set; } public long? DepartmentId { get; set; } - + [LinqExpressionXAttribute(IsIgnore = true)] public List ChildrenDepartmentIdList { get; set; } - + [LinqExpressionXAttribute(IsIgnore = true)] public string UserIds { get; set; } } diff --git a/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs b/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs index b6d31cea..ab2b14eb 100644 --- a/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs +++ b/YiSha.Util/YiSha.Util/Extension/Extension.Linq.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Linq.Expressions; using System.Text; @@ -13,26 +14,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 +49,7 @@ public static Expression> And(this Expression> fi { return first.Compose(second, Expression.AndAlso); } + /// /// 组合Or /// @@ -54,7 +62,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] }) @@ -73,135 +81,140 @@ 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) { - //字符类型筛选 - if (property.PropertyType == typeof(string)) + var properties = typeof(TT).GetProperties(); + var targetProperties = typeof(T).GetProperties(); + var linqXAttrType = typeof(LinqExpressionXAttribute); + foreach (var property in properties) { - - - var value = property.GetValue(input); - - if (value != null && !string.IsNullOrEmpty(value.ToString())) + var attrName = property.Name; + //判断属性是否有 LinqExpressionXAttribute 标识,并且如果有则判断是否有忽略标识以及Name名称 + var attrObjList = property.GetCustomAttributes(linqXAttrType, true); + if (attrObjList.Length > 0) { - 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); + var attrObjData = attrObjList[0] as LinqExpressionXAttribute; + if (attrObjData.IsIgnore) + { + continue; + } + if (attrObjData.Name.Length > 0) + { + attrName = attrObjData.Name; + } } - } - //日期类型筛选 - else if (property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?)) - { - var value = property.GetValue(input); - - if (value != null) + //字符类型筛选 + if (property.PropertyType == typeof(string)) + { + var value = property.GetValue(input); + if (value != null && !string.IsNullOrEmpty(value.ToString())) + { + var propertyExpression = Expression.Property(parameter, attrName); + //var valueExpression = Expression.Constant(value); + var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); + // var containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); + // var containsExpression = Expression.Call(propertyExpression, containsMethod, valueExpression); + expression = Expression.AndAlso(expression, equalExpression); + } + } + //日期类型筛选 + else if (property.PropertyType == typeof(DateTime) || property.PropertyType == typeof(DateTime?)) { - // 开始日期筛选 - if (property.Name.Contains("Start")) + var value = property.GetValue(input); + + if (value != null) { - 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 (property.Name.Contains("Start")) + { + //var realPropertyName = attrName.Substring(0, attrName.Length - "Start".Length); + var propertyExpression = Expression.Property(parameter, attrName); + var entityfield = targetProperties.FirstOrDefault(s => s.Name == attrName); + var startDateTime = (DateTime)value; - if (entityfield.PropertyType == typeof(DateTime?)) + 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 greaterThanOrEqualExpression = Expression.GreaterThanOrEqual(propertyExpression, Expression.Constant(startDateTime, typeof(DateTime?))); - expression = Expression.AndAlso(expression, greaterThanOrEqualExpression); + //var realPropertyName = attrName.Substring(0, attrName.Length - "End".Length); + var propertyExpression = Expression.Property(parameter, attrName); + var entityfield = targetProperties.FirstOrDefault(s => s.Name == attrName); + 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 greaterThanOrEqualExpression = Expression.GreaterThanOrEqual(propertyExpression, Expression.Constant(startDateTime)); - expression = Expression.AndAlso(expression, greaterThanOrEqualExpression); + var propertyExpression = Expression.Property(parameter, attrName); + var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); + expression = Expression.AndAlso(expression, equalExpression); } - } - // 结束日期筛选 - 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); + } + //数值类型 + else if (property.PropertyType == typeof(int?) || property.PropertyType == typeof(int)) + { + var value = property.GetValue(input); + var propertyExpression = Expression.Property(parameter, attrName); + var entityfield = targetProperties.FirstOrDefault(s => s.Name == attrName); - if (entityfield.PropertyType == typeof(DateTime?)) + if (value != null) + { + if (entityfield.PropertyType == typeof(int?)) { - var lessThanOrEqualExpression = Expression.LessThanOrEqual(propertyExpression, Expression.Constant(endDateTime, typeof(DateTime?))); - expression = Expression.AndAlso(expression, lessThanOrEqualExpression); + var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value, typeof(int?))); + expression = Expression.AndAlso(expression, equalExpression); } else { - var lessThanOrEqualExpression = Expression.LessThanOrEqual(propertyExpression, Expression.Constant(endDateTime)); - expression = Expression.AndAlso(expression, lessThanOrEqualExpression); + var equalExpression = Expression.Equal(propertyExpression, Expression.Constant(value)); + expression = Expression.AndAlso(expression, equalExpression); } - - } - // 其他日期属性 - 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)) - { - var value = property.GetValue(input); - var propertyExpression = Expression.Property(parameter, property.Name); - var entityfield = targetProperties.FirstOrDefault(s => s.Name == property.Name); - - if (value != null) + //float + else if (property.PropertyType == typeof(float?) || property.PropertyType == typeof(float)) { - 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); - } + var value = property.GetValue(input); + var propertyExpression = Expression.Property(parameter, attrName); + var entityfield = targetProperties.FirstOrDefault(s => s.Name == attrName); - } - - } - //float - else if (property.PropertyType == typeof(float?) || property.PropertyType == typeof(float)) - { - 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?)) + if (value != null) { - 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); + 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); + } } - } - } - } - return Expression.Lambda>(expression, parameter); } @@ -213,15 +226,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 +247,7 @@ public static Expression ReplaceParameters(Dictionary /// Visits the parameter. /// @@ -247,7 +263,43 @@ protected override Expression VisitParameter(ParameterExpression p) } return base.VisitParameter(p); } - } } -} + + /// + /// Linq表达式实体属性标识 + /// + [AttributeUsage(AttributeTargets.Property)] + public class LinqExpressionXAttribute : Attribute + { + /// + /// 属性名称 + /// + public string Name { get; set; } + + /// + /// 操作符 + /// + public Operation Operation { get; set; } + + /// + /// 是否忽略该属性 + /// + public bool IsIgnore { get; set; } + } + + /// + /// 操作 + /// + public enum Operation + { + GreaterThan, + LessThan, + GreaterThanOrEqual, + LessThanOrEqual, + NotEqual, + Equal, + Like, + In + } +} \ 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+="