function Tsites_advance_search() { var _this = this; //学院id _this.collegeid = 0; //学科id _this.disciplineid = ""; //系所id _this.facultyid = 0; //招生专业id _this.enrolldisciplineid = 0; //职称编码 _this.rankid = 0; //荣誉id _this.honorid = 0; //字母 _this.pinyin = ""; //教师名称 _this.teacherName = ""; //研究方向 _this.searchDirection = ""; //是否只查博导 _this.isbd = "false"; //是否只查硕导 _this.issd = "false"; _this.callbackFun = ""; _this.decorateCallbackFun = ""; _this.endBackFun = ""; //内容容器id _this.lineId = ""; //当前组件模式,是访问还是样式配置 _this.viewMode = 8; _this.viewid = 0; _this.siteOwner = 0; _this.viewOwner = ""; _this.viewUniqueId = ""; //每页显示条数 _this.pageNumber = 10; //图片宽度 _this.imageWidth = 100; //图片高度 _this.imageHeight = 100; //当前是第几页,默认是第一页 _this.currentPage = 1; //是否已经加载过数据 _this.loading = false; //当前资料源下一共有多少条数据 _this.totalNum = 0; //加载的json数据 _this.contentJSONData ; //一共有多少页 _this.totalpage = 0; _this.uid = ""; _this.imageScale = null; _this.showlang = ""; _this.profilelen = 100; _this.ellipsis = ""; _this.alignright = false; //翻页条id _this.pageBarCustomPageId = ""; _this.pageBarPageNumberId = ""; _this.pageBarTotalNumberId = ""; _this.pageBarCurPageId = ""; _this.pageBarTotalPageId = ""; _this.pageBarFirstPageId = ""; _this.pageBarPrePageId = ""; _this.pageBarNextPageId = ""; _this.pageBarLastPageId = ""; _this.pageBarGotoPageId = ""; _this.actiontype = ""; _this.initParam = function(p) { //翻页条id _this.pageBarCustomPageId = p.pageBarCustomPageId?p.pageBarCustomPageId:""; _this.pageBarPageNumberId = p.pageBarPageNumberId?p.pageBarPageNumberId:""; _this.pageBarTotalNumberId = p.pageBarTotalNumberId?p.pageBarTotalNumberId:""; _this.pageBarCurPageId = p.pageBarCurPageId?p.pageBarCurPageId:""; _this.pageBarTotalPageId = p.pageBarTotalPageId?p.pageBarTotalPageId:""; _this.pageBarFirstPageId = p.pageBarFirstPageId?p.pageBarFirstPageId:""; _this.pageBarPrePageId = p.pageBarPrePageId?p.pageBarPrePageId:""; _this.pageBarNextPageId = p.pageBarNextPageId?p.pageBarNextPageId:""; _this.pageBarLastPageId = p.pageBarLastPageId?p.pageBarLastPageId:""; _this.pageBarGotoPageId = p.pageBarGotoPageId?p.pageBarGotoPageId:""; //职称 _this.rankid = p.rankid?p.rankid:0; _this.facultyid = p.facultyid?p.facultyid:""; //拼音 _this.pinyin = p.pinyin?p.pinyin:""; //数据类型 _this.actiontype = p.actiontype?p.actiontype:""; _this.collegeid = p.collegeid?p.collegeid:0; _this.disciplineid = p.disciplineid?p.disciplineid:0; _this.honorid = p.honorid?p.honorid:0; //是否只查博导 _this.isbd = p.isbd?p.isbd:"false"; //是否只查硕导 _this.issd = p.issd?p.issd:"false"; _this.callbackFun = p.callbackFun?p.callbackFun:""; _this.decorateCallbackFun = p.decorateCallbackFun?p.decorateCallbackFun:""; _this.endBackFun = p.endBackFun?p.endBackFun:""; //内容容器id _this.lineId = p.lineId?p.lineId:""; _this.type = p.type?p.type:""; //当前组件模式,是访问还是样式配置 _this.viewMode = p.viewMode?p.viewMode:8; _this.viewid = p.viewId?p.viewId:0; _this.viewOwner = p.viewOwner?p.viewOwner:""; _this.siteOwner = p.siteOwner?p.siteOwner:0; _this.viewUniqueId = p.viewUniqueId?p.viewUniqueId:""; _this.profilelen = p.profilelen?p.profilelen:100; _this.ellipsis = p.ellipsis?p.ellipsis:""; _this.alignright = p.alignright?p.alignright:false; _this.uid = "u_" + _this.viewUniqueId + "_"; //每页显示条数 _this.pageNumber = p.pageNumber?p.pageNumber:10; //图片宽度 _this.imageWidth = p.imageWidth?p.imageWidth:100; //图片高度 _this.imageHeight = p.imageHeight?p.imageHeight:100; _this.showlang = p.showlang?p.showlang:""; _this.imageScale = new ImageScale(_this.uid,_this.imageWidth,_this.imageHeight,true,true); _this.setContainer(); } //模板对象 _this.template = null; //容器对象 _this.containerobj = null; _this.setContainer = function() { //找到模板 _this.oldtemplatehtml = jQuery("#"+_this.lineId); if(_this.oldtemplatehtml && _this.oldtemplatehtml[0]) { //创建一个模板的html结构 _this.templatehtml = jQuery(_this.oldtemplatehtml).clone(true); //把最原始的模板干掉 _this.containerobj = _this.oldtemplatehtml.parent(); _this.containerobj.empty(); //设置模板的样式 _this.templatehtml.css("display",""); //创建模板对象 _this.template = jQuery.templates(_this.templatehtml[0].outerHTML); } return null; } //加载内容 _this.loadData = function() { _this.clearContainer(); jQuery.when(_this.queryData()).then( function(){ if(_this.contentJSONData) { _this.totalNum = _this.contentJSONData.totalnum; _this.totalpage = _this.contentJSONData.totalpage; var teacherData = _this.contentJSONData.teacherData; if(teacherData.length==0) { _this.currentPage = 0; } for(var i=0 ; i< teacherData.length;i++) { var onedata = teacherData[i]; if(_this.template) { var htmlOutput = _this.template.render(onedata); var htmlOutputObj = jQuery(htmlOutput); if(_this.decorateCallbackFun!="" && _this.decorateCallbackFun && window[_this.decorateCallbackFun]) { var dr = window[_this.decorateCallbackFun].call(this,onedata,i,htmlOutput); if(dr) { htmlOutput = dr; } } _this.containerobj.append(htmlOutput); //调用回调方法 if(_this.callbackFun!="" && window[_this.callbackFun] && _this.callbackFun) { window[_this.callbackFun].call(this,onedata,i,htmlOutputObj); } //数据加载完毕后重置翻页条 } if(_this.imageScale) { _this.imageScale.addimg(onedata.picUrl,onedata.url,onedata.showName,onedata.teacherId); } } if(_this.endBackFun !="" && window[_this.endBackFun] && _this.endBackFun) { window[_this.endBackFun].call(this,teacherData); } _this.changePageBar(); } _this.loading = false; } ); } //加载数据 _this.queryData = function() { //如果数据加载过了,直接跳过 if(_this.loading) { return; } //异步请求加载json数据 if(!jQuery)return; var url = "/system/resource/tsites/portal/queryteacher.jsp"; var param = "collegeid="+encodeURIComponent(_this.collegeid) +"&facultyid="+encodeURIComponent(_this.facultyid) +"&disciplineid="+encodeURIComponent(_this.disciplineid) +"&rankid="+encodeURIComponent(_this.rankid) +"&enrollid="+encodeURIComponent(_this.enrolldisciplineid) +"&pageindex="+_this.currentPage +"&pagesize="+_this.pageNumber +"&profilelen="+_this.profilelen +"&honorid="+encodeURIComponent(_this.honorid) +"&pinyin="+encodeURIComponent(_this.pinyin) +"&isbd="+encodeURIComponent(_this.isbd) +"&issd="+encodeURIComponent(_this.issd) +"&teacherName="+encodeURIComponent(_this.teacherName) +"&searchDirection="+encodeURIComponent(_this.searchDirection) +"&viewmode="+encodeURIComponent(_this.viewMode) +"&viewOwner="+encodeURIComponent(_this.viewOwner) +"&viewid="+encodeURIComponent(_this.viewid) +"&siteOwner="+encodeURIComponent(_this.siteOwner) +"&viewUniqueId="+encodeURIComponent(_this.viewUniqueId) +"&showlang="+encodeURIComponent(_this.showlang) +"&actiontype="+encodeURIComponent(_this.actiontype); jQuery.ajax( url, { dataType:"json", async:false, data:param, success: function(data) { _this.loading = true; _this.contentJSONData = data; } } ); } //设置学院id _this.setCollege = function(collegeid) { _this.currentPage = 1; _this.collegeid = collegeid; _this.loadData(); } //重置学院编号 _this.resetCollege = function(collegeid) { _this.currentPage = 1; _this.collegeid = collegeid; } //设置系所ID _this.setFacultyid = function(facultyid) { _this.currentPage = 1; _this.facultyid = facultyid; _this.loadData(); } //重置系所ID _this.resetFacultyid = function(facultyid) { _this.currentPage = 1; _this.facultyid = facultyid; } //设置学科id _this.setDiscipline = function(disciplineid) { _this.currentPage = 1; _this.disciplineid = disciplineid; _this.loadData(); } //重置 _this.resetDiscipline = function(disciplineid) { _this.currentPage = 1; _this.disciplineid = disciplineid; } //设置招生专业id _this.setEnrollDiscipline = function(id) { _this.currentPage = 1; _this.enrolldisciplineid = id; _this.loadData(); } _this.resetEnrollDiscipline = function(id) { _this.currentPage = 1; _this.enrolldisciplineid = id; } //设置荣誉id _this.setHonor = function(id) { _this.currentPage = 1; _this.honorid = id; _this.loadData(); } _this.resetHonor = function(id) { _this.currentPage = 1; _this.honorid = id; } //设置职称 _this.setRank = function(rankid) { _this.currentPage = 1; _this.rankid = rankid; _this.loadData(); } _this.resetRank = function(rankid) { _this.currentPage = 1; _this.rankid = rankid; } //设置拼音 _this.setPinyin = function(p) { _this.currentPage = 1; _this.pinyin = p; _this.loadData(); } _this.resetPinyin = function(p) { _this.currentPage = 1; _this.pinyin = p; } //设置教师名称 _this.setTeacherName = function(n) { _this.currentPage = 1; _this.teacherName = n; _this.loadData(); } _this.resetTeacherName = function(n) { _this.currentPage = 1; _this.teacherName = n; } //设置是否只查询博导 _this.setIsBd = function(n) { _this.currentPage = 1; _this.isbd = n; _this.loadData(); } //设置是否只查询硕导 _this.setIsSd = function(n) { _this.currentPage = 1; _this.issd = n; _this.loadData(); } //设置研究方向 _this.setSearchDirection = function(s) { _this.currentPage = 1; _this.searchDirection = s; _this.loadData(); } _this.resetSearchDirection = function(s) { _this.currentPage = 1; _this.searchDirection = s; } _this.onlySetTeacherNameAndRd = function(tname,rdvalue) { _this.currentPage = 1; _this.teacherName = tname; _this.searchDirection = rdvalue; } _this.setTeacherNameAndRd = function(tname,rdvalue) { _this.currentPage = 1; _this.teacherName = tname; _this.searchDirection = rdvalue; _this.loadData(); } //转到第几页 _this.gotoPage = function(page) { _this.currentPage = page; _this.loadData(); _this.changePageBar(); } //转到多少页面的绑定事件 _this.gotoPageBindFunction = function(option) { if(option) { var methodAction = option.data.methodAction; if(methodAction=="pre") { _this.currentPage = _this.currentPage-1<=0?1:_this.currentPage-1; } if(methodAction=="next") { _this.currentPage = _this.currentPage+1>_this.totalpage?_this.totalpage:_this.currentPage+1; } if(methodAction=="first") { _this.currentPage = 1; } if(methodAction=="last") { _this.currentPage = _this.totalpage; } if(methodAction=="custom") { if(jQuery("#"+_this.pageBarCustomPageId)) { var topage = jQuery("#"+_this.pageBarCustomPageId).val(); topage = parseInt(topage); if(topage<=0) { _this.currentPage = 1; }else if(topage>_this.totalpage) { _this.currentPage = _this.totalpage; }else if(isNaN(topage)) { _this.currentPage = 1; } else { _this.currentPage = topage; } } } _this.loadData(); _this.changePageBar(); } } //修改翻页条 _this.changePageBar = function() { if(jQuery("#"+_this.pageBarCustomPageId)) { jQuery("#"+_this.pageBarCustomPageId).val(""); } if(jQuery("#"+_this.pageBarPageNumberId)) { jQuery("#"+_this.pageBarPageNumberId).html(_this.pageNumber); } if(jQuery("#"+_this.pageBarTotalNumberId)) { jQuery("#"+_this.pageBarTotalNumberId).html(_this.totalNum); } if(jQuery("#"+_this.pageBarCurPageId)) { jQuery("#"+_this.pageBarCurPageId).html(_this.currentPage); } if(jQuery("#"+_this.pageBarTotalPageId)) { jQuery("#"+_this.pageBarTotalPageId).html(_this.totalpage); } //设置首页,上一页,下一页,尾页,转到按钮的单击事件 //首页 if(jQuery("#"+_this.pageBarFirstPageId)) { jQuery("#"+_this.pageBarFirstPageId).unbind("click"); jQuery("#"+_this.pageBarFirstPageId).bind("click",{"methodAction":"first"},_this.gotoPageBindFunction); } //上一页 if(jQuery("#"+_this.pageBarPrePageId)) { jQuery("#"+_this.pageBarPrePageId).unbind("click"); if(_this.currentPage>1) { jQuery("#"+_this.pageBarPrePageId).bind("click",{"methodAction":"pre"},_this.gotoPageBindFunction); } } //下一页 if(jQuery("#"+_this.pageBarNextPageId)) { jQuery("#"+_this.pageBarNextPageId).unbind("click"); if(_this.currentPage<_this.totalpage) { jQuery("#"+_this.pageBarNextPageId).bind("click",{"methodAction":"next"},_this.gotoPageBindFunction); } } //尾页 if(jQuery("#"+_this.pageBarLastPageId)) { jQuery("#"+_this.pageBarLastPageId).unbind("click"); if(_this.currentPage != _this.totalpage) { jQuery("#"+_this.pageBarLastPageId).bind("click",{"methodAction":"last"},_this.gotoPageBindFunction); } } //转到 if(jQuery("#"+_this.pageBarGotoPageId)) { jQuery("#"+_this.pageBarGotoPageId).unbind("click"); jQuery("#"+_this.pageBarGotoPageId).bind("click",{"methodAction":"custom"},_this.gotoPageBindFunction); } } //清空内容区 _this.clearContainer = function() { _this.containerobj.empty(); } }