text: Array.prototype.indexOf=function(e){for(var t=0;t<this.length;t++)if(this[t]==e)return t;return-1},Array.prototype.remove=function(e){var t=this.indexOf(e);t>-1&&this.splice(t,1)};var ajaxHelper=function(){var defaults={url:"",type:"",data:null,dataType:"json",contentType:"application/json",timeout:3e5},ajaxFun=function(options){var url=options.url;if(void 0==url||null==url||""==url)return console.error("ajax request url is null or empty"),!1;var type=options.type;return void 0==type||null==type||""==type?(console.error("ajax request type  is null or empty"),!1):(url+=-1==url.indexOf("?")?"?":"&",url+="t="+Math.random(),void $.ajax({url:url,type:options.type,dataType:options.dataType,data:options.data,contentType:options.contentType,timeout:options.timeout,success:function(result){try{if(result=eval("("+result+")"),null!=result.ErrMsg&&void 0!=result.ErrMsg&&""!=result.ErrMsg)return void DialogHelper.Error({Title:"出现异常",Content:result.ErrMsg})}catch(e){}void 0!=options.success&&options.success(result)},error:function(e,t,a){switch(e.status){case 500:DialogHelper.Error({Content:"服务器系统内部错误"});break;case 401:DialogHelper.Error({Content:"您未登录,请先登录账号",CallBack:function(){return location.reload(),!1}});break;case 403:DialogHelper.Error({Content:"无权限执行此操作"});break;case 404:DialogHelper.Error({Content:"未找到对应的服务地址"});break;case 408:DialogHelper.Error({Content:"服务请求超时,请稍后重试!"});break;default:DialogHelper.Error({Content:"未知错误信息:"+e.status})}return void 0!=options.error&&options.error(),!1},complete:function(){void 0!=options.complete&&options.complete()}}))};return{send:function(e){e=$.extend(defaults,e),ajaxFun(e)},post:function(e){e=$.extend(defaults,{type:"post"},e),ajaxFun(e)},get:function(e){e=$.extend(defaults,{type:"get",dataType:"text"},e),ajaxFun(e)},getJSON:function(e){e=$.extend(defaults,{type:"get",dataType:"json"},e),ajaxFun(e)}}}(),check_user_ids=new Array,pageSize=10,UserCheckPlugin=function(){var e='<div class="modal fade" id="user-modal-plugin" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static"><div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">分配用户</h4></div><div class="modal-body"><div class="row"><div class="col-lg-12"><section class="panel"><div class="panel-body"><form class="form-inline" role="form"><div class="form-group"><input type="text" class="form-control" id="tb-keyword-user-plugin" placeholder="用户昵称"></div> <button class="btn btn-primary btn-search-user-plugin"><i class="fa fa-search"></i> 查询</button></form></div></section></div></div><div class="row"><div class="col-lg-12"><section class="panel"><table class="table table-striped table-advance table-hover"><thead><tr><th style="width:80px;"></th><th>编号</th><th>用户名称</th><th>账号</th><th>状态</th></tr></thead><tbody class="user-container-plugin"></tbody></table></section><ul class="pagination pull-right userpages-plugin"></ul></div></div></div><div class="modal-footer"><button data-dismiss="modal" class="btn btn-default" type="button"><i class="fa fa-close"></i> 关闭</button><button class="btn btn-success btn-save-plugin" type="button"><i class="fa fa-save"></i> 保存</button></div></div></div></div>';$("body").find(".modal-plugin-container").append(e);var t=function(){check_user_ids=new Array,$("#tb_KeyWord_User_Plugin").empty(),$(".user-container-plugin").empty(),$(".userpages-plugin").empty(),$(".btn-save-plugin").unbind("click")},a=function(){$("#user-modal-plugin").modal("hide")},n=function(){$("#user-modal-plugin").modal("show")},l=function(e){return $.getJSON("/Admin/User/GetPageUserList",{keyWord:$("#tb-keyword-user-plugin").val(),page:e,pageSize:pageSize},function(t){var a=t.TotalCount,n=Math.ceil(a/pageSize);$(".userpages-plugin").PageHelper({Handler:l,CurrentPage:e,PageSize:4,PageCount:n});var o=$(".user-container-plugin");o.empty();var i="";$(t.Users).each(function(e,t){i+=' <tr class="plugin-tr"><td><icheck><label class="checkbox-inline i-checks"><div class="icheckbox_flat-green '+(check_user_ids.indexOf(t.Id)>=0?"checked":"")+'" user-id="'+t.Id+'" style="position: relative;"><input type="checkbox" style="position: absolute; opacity: 0; "></div></label></icheck></td><td>'+t.Id+"</td><td>"+t.NickName+"</td><td>"+t.Account+"</td><td>"+(t.IsLock?'<span class="label label-danger label-mini">锁定</span></td>':'<span class="label label-success label-mini">正常</span></td>')+"</tr>",o.html(i)})}),!1};$(".user-container-plugin").on("click",".plugin-tr",function(){var e=$(this).find(".icheckbox_flat-green"),t=$(e).attr("user-id");return e.hasClass("checked")?(e.removeClass("checked"),check_user_ids.remove(t)):(e.addClass("checked"),check_user_ids.push(t)),!1});var o=function(e){return l(1),$(".btn-search-user-plugin").click(function(){return getContent(1),!1}),$(".btn-save-plugin").click(function(){null!=e.CallBack&&void 0!=e.CallBack&&e.CallBack(check_user_ids),a()}),n(),!1};return{Check:function(e){return t(),o(e),!1}}}(),DialogHelper=function(){var e='<div id="enDialogModal" class="modal fade" style="z-index:9999 !important" role="dialog" data-backdrop="static" data-keyboard="false"><div class="modal-dialog"><div class="modal-content"> <div class="modal-header"><span class="modal-title" id="modal_endialog_title" style="font-size:22px;font-weight:bold"></span></div><div class="modal-body"><div class="hidden dvWarning EndialogContainer"><i class="fa fa-warning" style="font-size: 25px !important; color: #f8ac59"></i><span id="warningContent" class="DialogContentSpan" style="font-size: 13px; color: #f8ac59; margin-left: 5px;">警告</span></div><div class="hidden dvError EndialogContainer"><i class="fa fa-times-circle" style="font-size: 29px !important; color: #ed5565"></i><span id="errorContent" class="DialogContentSpan" style="font-size: 13px;color: #ed5565; margin-left: 5px; ">错误</span></div><div class="hidden dvSuccess EndialogContainer"><i class="fa fa-check-circle" style="font-size: 29px !important; color: #1ab394"></i><span id="successContent" class="DialogContentSpan" style="font-size: 13px;color: #1ab394; margin-left:5px;">成功</span></div> </div><div class="modal-footer"><button  id="btn_endialog_sure"  type="button" class="btn btn-success"><i class="fa fa-save"></i> 确 定</button><button id="btn_endialog_cancle" type="button" class="btn btn-default hidden" data-dismiss="modal"><i class="fa fa-close"></i> 取 消</button></div></div></div></div>';$("body").append(e);var t=function(){$(".EndialogContainer,#btn_endialog_cancle").addClass("hidden"),$(".DialogContentSpan").empty(),$("#modal_endialog_title").empty(),$("#btn_endialog_sure").unbind("click"),$("#btn_endialog_sure").html('<i class="fa fa-save"></i> 确定'),$("#btn_endialog_cancle").html('<i class="fa fa-close"></i> 取消')},a=function(){$("#enDialogModal").modal("hide")},n=function(){$("#enDialogModal").modal("show")},l=function(e){var t={Title:"警告",Content:"非管理人员，请谨慎操作",CallBack:null},l=$.extend(t,e);if(0==l.Type){var o=l.OkContent;(l.OkContent=""||void 0==l.OkContent||null==l.OkContent)&&(o='<i class="fa fa-save"></i> 确定'),$("#btn_endialog_sure").html(o);var i=l.CancleContent;(l.CancleContent=""||void 0==l.CancleContent||null==l.CancleContent)&&(i='<i class="fa fa-close"></i> 取消'),$("#btn_endialog_cancle").html(i),$("#btn_endialog_cancle").removeClass("hidden"),$("#modal_endialog_title").css("color","#f8ac59")}1==l.Type&&$("#modal_endialog_title").css("color","#ed5565"),2==l.Type&&$("#modal_endialog_title").css("color","#1ab394"),$("#modal_endialog_title").html(l.Title),$(".EndialogContainer").eq(l.Type).removeClass("hidden"),$(".DialogContentSpan").eq(l.Type).text(l.Content),$("#btn_endialog_sure").click(function(){null!=l.CallBack&&void 0!=l.CallBack&&setTimeout(function(){l.CallBack()},400),a()}),n()};return{Confirm:function(e){t();var a=$.extend(e,{Type:0});(""==a.Title||void 0==a.Title||null==a.Title)&&(a=$.extend(a,{Title:"警告"})),(""==a.Content||void 0==a.Content||null==a.Content)&&(a=$.extend(a,{Content:"您确定要执行此操作吗？"})),l(a)},Error:function(e){t();var a=$.extend(e,{Type:1});(""==a.Title||void 0==a.Title||null==a.Title)&&(a=$.extend(a,{Title:"错误"})),(""==a.Content||void 0==a.Content||null==a.Content)&&(a=$.extend(a,{Content:"操作失败!"})),l(a)},Success:function(e){t();var a=$.extend(e,{Type:2});(""==a.Title||void 0==a.Title||null==a.Title)&&(a=$.extend(a,{Title:"成功"})),(""==a.Content||void 0==a.Content||null==a.Content)&&(a=$.extend(a,{Content:"操作成功!"})),l(a)}}}();!function($){$.fn.PageHelper=function(options){var handler=options.Handler,currentPage=options.CurrentPage,pageSize=options.PageSize,pageCount=options.PageCount,url=options.Url;if(null==handler||void 0==handler||""==handler)return DialogHelper.Error({Title:"PageHelper设置错误",Content:"PageHelper未设置Handler处理函数,无法分页。"}),!1;if(null==currentPage||void 0==currentPage||""==currentPage)return DialogHelper.Error({Title:"PageHelper设置错误",Content:"PageHelper未设置CurrentPage参数,无法分页。"}),!1;if(null==pageSize||void 0==pageSize||""==pageSize)return DialogHelper.Error({Title:"PageHelper设置错误",Content:"PageHelper未设置PageSize参数,无法分页。"}),!1;var rootNode=this;if(rootNode.html(""),2>pageCount)return void rootNode.html('<li class="disabled"><a href="javascript:;">«<span class="hidden-480 disabled">上一页</span></a></li><li class="active"><a href="javascript:;">1</a></li><li class="next disabled"><a href="javascript:;"><span class="hidden-480 ">下一页</span> » </a></li>');var temp=Math.ceil(pageSize/2),minNode=currentPage-temp;1>minNode&&(minNode=1);var maxNode=minNode+pageSize-1;maxNode>pageCount&&(maxNode=pageCount,minNode=maxNode-pageSize+1,1>minNode&&(minNode=1));var isFirstPage=1==currentPage,isLastPage=currentPage==pageCount;null!=url&&(url+=-1==url.indexOf("?")?"?":"&");var aHtml=null==url?'<a href="javascript:;">':'<a href="'+url+'page={page}">',html='<li class="prev '+(isFirstPage?"disabled":"page_node_item")+'" page="'+(currentPage-1)+'">'+(isFirstPage?'<a href="javascript:;">':aHtml.replace("{page}",currentPage-1))+'« <span class="hidden-480">上一页</span></a></li>';minNode>1&&(html+='<li class="page_node_item" page="1">'+aHtml.replace("{page}",1)+"1</a></li>"),minNode>2&&(html+='<li><a href="###" style="border-top:0;border-bottom:0">......</a></li>');for(var i=minNode;maxNode>=i;i++)html+='<li class="page_node_item '+(currentPage==i?"active":"")+'" page="'+i+'">'+aHtml.replace("{page}",i)+i+"</a></li>";if(pageCount-1>maxNode&&(html+='<li><a href="###" style="border-top:0;border-bottom:0">......</a></li>'),pageCount>maxNode&&(html+='<li class="page_node_item" page="'+pageCount+'">'+aHtml.replace("{page}",pageCount)+pageCount+"</a></li>"),html+='<li class="next '+(isLastPage?"disabled":"page_node_item")+'" page="'+(currentPage+1)+'">'+(isLastPage?'<a href="javascript:;">':aHtml.replace("{page}",currentPage+1))+'<span class="hidden-480">下一页</span> »'+(isLastPage?"":"</a>")+"</li>",null==url){var htmlObj=$(html);htmlObj.each(function(){var obj=$(this),page=parseInt(obj.attr("page"));obj.hasClass("page_node_item")&&obj.click(function(){"string"==typeof handler?eval(handler+"("+page+")"):"function"==typeof handler&&handler(page)})}),rootNode.append(htmlObj)}else rootNode.html(html)}}(jQuery)(function(e){e.fn.MenuSelect=function(t){var a={ProjectId:0,SelAll:!1,PleaseSel:!0,Value:""},n=e.extend(a,t),l=this;e.getJSON("/Menu/GetParentMenus",{ProjectId:n.ProjectId},function(t){var a="";n.SelAll&&(a+='<option value="-1">--全部--</option>'),n.PleaseSel&&(a+='<option value="-1">--请选择--</option>'),e(t).each(function(e,t){a+=""!=n.Value&&void 0!=n.Value&&n.Value==t.Id?'<option value="'+t.Id+'" selected="selected">'+t.Name+"</option>":'<option value="'+t.Id+'">'+t.Name+"</option>"}),l.empty().append(a)})},e.fn.ChildMenuSelect=function(t){var a={ProjectId:0,ParentId:-1,SelAll:!1,PleaseSel:!0,Value:""},n=e.extend(a,t),l=this;e.getJSON("/Menu/GetChildMenus",{ProjectId:n.ProjectId,ParentId:n.ParentId},function(t){var a="";n.SelAll&&(a+='<option value="-1">--全部--</option>'),n.PleaseSel&&(a+='<option value="-1">--请选择--</option>'),e(t).each(function(e,t){a+=""!=n.Value&&void 0!=n.Value&&n.Value==t.Id?'<option value="'+t.Id+'" selected="selected">'+t.Name+"</option>":'<option value="'+t.Id+'">'+t.Name+"</option>"}),l.empty().append(a)})}})(jQuery);