function recruitment(){} recruitment.prototype.recruitparam = {};//招聘参数 recruitment.prototype.initmethod = function(arg){ recruitment.prototype.recruitparam.recruittype = arg.recruittype; recruitment.prototype.initdata(); recruitment.prototype.bindevent(); recruitment.prototype.pagequerypositioninfo(); } recruitment.prototype.bindevent = function(){ $("#searchbtn").click(function(){ recruitment.prototype.pagequerypositioninfo(); }); $("#queryform\\:name").focus(function(){ recruitment.prototype.cleardefaultvalue("queryform\\:name", "岗位名称"); }); $("#queryform\\:name").blur(function(){ recruitment.prototype.setdefaultvalue("queryform\\:name", "岗位名称"); }); // 查询区enter键keydown事件 $("#queryform").bind("keydown" , function(e){ if(e.keycode == 13){ $("#searchbtn").trigger("click"); } }); } recruitment.prototype.setdefaultvalue = function(id,defaultvalue){ var textvalue = $("#"+id).val(); if(textvalue == ""){ $("#"+id).val(defaultvalue); } } /** * 初始化工作地点值 * @return */ recruitment.prototype.initdata = function(){ $.ajax({ url: root_path + "/sysdict/getsysdictdata" , data: null , type: "post" , datatype: "json" , success: function(result){ recruitment.prototype.setworkaddressandpositiontype(result); }, error: function(){ alert("查询数据字典信息出错!"); } }); } /** * 设置岗位类别和工作地点数据 * @return */ recruitment.prototype.setworkaddressandpositiontype = function(data){ var workaddress = data["workaddress"]; var positiontype = data["positiontype"]; if(workaddress != null && workaddress.length > 0){ recruitment.prototype.setselectvalue(workaddress, "queryform\\:workaddress","工作地点"); } if(positiontype != null && positiontype.length > 0){ recruitment.prototype.setselectvalue(positiontype, "queryform\\:positiontype","请选择职位类别"); } } /** * 填充下拉框值 * @param data * @param id * @return */ recruitment.prototype.setselectvalue = function(data,id,defaultvalue){ var option = $(""); $("#"+id).append(option); for(var index = 0 ; index < data.length; index++){ var name = data[index].name; var value = data[index].value; var option = $(""); option.val(value); option.text(name); $("#"+id).append(option); } $("#"+id).chosen({width:"25%"}); } /** * 填充表格数据 * @param data * @return */ recruitment.prototype.setpostioninfo = function(data){ $("#positioncontent").empty(); if(data != null && data.length > 0){ for(var index = 0; index < data.length;index++){ var positionname = data[index].name; var positiontype = data[index].a1; var recruitnum = data[index].recruitnum; var workaddress = data[index].workaddress; var workplace = ""; if(workaddress != null && workaddress !=""){ workplace = workaddress.substr(workaddress,8); if(workplace.lastindexof(",") == workplace.length-1){ workplace = workplace.replace(workplace.charat(workplace.lastindexof(",")),"..."); }else{ if(workplace.length == 8){ workplace += "..."; } } } var positionid = data[index].positionid; var createdate = data[index].a2 == null?"":data[index].a2; var $str = ' '+positionname+''; $str += ''+positiontype+' '; $str += ''+recruitnum+''; $str += ''+workplace+' '; $str += ''+createdate+''; $("#positioncontent").append($str); } } } /** * 查询招聘岗位信息 * @return */ recruitment.prototype.pagequerypositioninfo = function(v_pagesize,v_currentpage){ if( v_pagesize == null ){ v_pagesize = 15; } if( v_currentpage == null ){ v_currentpage = 1; } var queryobj = $("#queryform").getjson().queryform; if(queryobj.name == "岗位名称"){ queryobj.name = null; } queryobj.recruittype = recruitment.prototype.recruitparam.recruittype; queryobj.status = 1; queryobj.pagesize = v_pagesize; queryobj.currentpage = v_currentpage; $.ajax({ url: root_path + "/positionother/pagequerypositionother" , data: queryobj , type: "post" , datatype: "json" , success: function(data){ if(data.totalpages < 1){ data.totalpages = 1; } var pageopt = { totalpages : data.totalpages ,currentpage : data.number , numberofpages : data.size }; recruitment.prototype.setpaginator( pageopt); recruitment.prototype.setpostioninfo(data.content); }, error: function(){ alert("查询社会招聘信息出错!"); } }); } recruitment.prototype.cleardefaultvalue = function(id,defaultvalue){ var textvalue = $("#"+id).val(); if(textvalue == defaultvalue){ $("#"+id).val(""); } } /** * 设置分页 * @param pageopt * @return */ recruitment.prototype.setpaginator = function ( pageopt ){ var options = { alignment:'center', onpageclicked: function(e,originalevent,type,page){ recruitment.prototype.pagequerypositioninfo( pageopt.numberofpages ,page ); } }; options = jquery.extend(pageopt, options); $('#pager').bootstrappaginator(options); }