"use strict"; //{(function(){objectPicker( //"ffry", //"null", //"testRy", //"true", //"env.rycx", //"null", //"{'input':'true','visible':'xm','invisible':'ryid','name':'ffry','codebook':'env.rycx','object':'testRy'}", //"/service?token=7548c1572b6149cfb1e03f7cc4675cc2", //"null", //"null");})()} var wd=window.wd; if (!wd) { var wd = {}; } if(!wd.edit){ wd.edit={}; } if(!wd.edit.objectPicker){ wd.edit.objectPicker={}; } if(!wd.edit.objectPicker.instance){ wd.edit.objectPicker.instance={}; } if(!wd.edit.objectPicker.activeInstance){ wd.edit.objectPicker.activeInstance={}; } if(!wd.edit.objectPicker.tipWinList){ wd.edit.objectPicker.tipWinList=[]; //绑定清除元素时间 $(window).unload(function(){ if(wd.edit.objectPicker.tipWinList.length==0)return; var removeId=""; $(wd.edit.objectPicker.tipWinList).each(function(index,ele){ removeId+="#"+ele+","; }) removeId=removeId.substring(0,removeId.length-1); wd.topWindow.window.$(removeId).remove(); }) } if(!wd.edit.objectPicker.getInstance){ wd.edit.objectPicker.getInstance=function(name){ return wd.edit.objectPicker.instance[name]; }; } if(!wd.topWindow){ wd.topWindow=window; } if(!wd.edit.objectPicker.setValue) wd.edit.objectPicker.setValue=function(objectID){ // console.log(objectID); wd.topWindow.objectPickerObject.initValueWithOption(objectID) wd.topWindow.objectPickerObject=null; wd.display.closeDialog(); } if(!wd.edit.objectPicker.getDisplayValue) wd.edit.objectPicker.getDisplayValue=function(dataElement){ return dataElement.objectPickerBody.getElementValue(); } if(!wd.edit.objectPicker.isObjectPicker) wd.edit.objectPicker.isObjectPicker=function(dataElement){ if(!dataElement)return false return dataElement.objectPickerBody?true:false; } if(!wd.edit.objectPicker.bodyClick){ wd.edit.objectPicker.bodyClick=function(e){ for(var key in wd.edit.objectPicker.activeInstance){ var aa=wd.edit.objectPicker.activeInstance[key]; if(!aa)continue; aa.elementBlurFunction(e); } } $("body").on("click",window.wd.edit.objectPicker.bodyClick); $(".content-div,.list-div").scroll(wd.edit.objectPicker.bodyClick); $(function(){ //app用 setTimeout(function(){ $("#app").on("click",window.wd.edit.objectPicker.bodyClick); $("#app").scroll(wd.edit.objectPicker.bodyClick); },3000) }) } if(!wd.edit.objectPicker.hideAllOptions){ wd.edit.objectPicker.hideAllOptions=function(e){ for(var key in wd.edit.objectPicker.activeInstance){ var aa=wd.edit.objectPicker.activeInstance[key]; if(!aa)continue; aa.hiddenOptions(e); } } } if(typeof wd.edit.objectPicker.initScrollId =="undefined") wd.edit.objectPicker.initScrollId=null; if(typeof wd.edit.objectPicker.addButtonClickName =="undefined") wd.edit.objectPicker.addButtonClickName=null; if(!wd.edit.cascading) wd.edit.cascading={} if(!wd.edit.cascading.instance) wd.edit.cascading.instance={} if(!wd.edit.cascading.display) wd.edit.cascading.display=function(data){ var data=eval("("+data+")"); // console.log(data); for(var key in data){ $("[name="+key+"]").hide().after(""+data[key]+"") } } if(!wd.edit.cascading.getInstance) wd.edit.cascading.getInstance=function(name){ //console.log("cascading "+name); var s=wd.edit.cascading.instance[name]; if(!s)return ; var casFunction= function(){ this.param={ cascadingInputsRule:null, cascadingLevel:null, cascadingInputsName:null, cascadingInputsElement:null }; // this.extension={ // onchange:null, // getValue:null, // getDisplayValue:null, // getDisplayElement:null, // validation:null, // passValidation:null, // failValidation:null, // getName:null, // refreshOption:null, // initValue:null, // getOptionsSize:null // } this.init=function(param){ this.param=param; return this; } this.setValue=function(val){ //console.log("cascading value :"+val) val+=""; var values=[] for(var i=0;i=rulNum){ v+=val.substr(j,1); }else{ v+="0"; } } values.push(v); } for(var i=0;i" // +"" // + ((data.helpSize.toLowerCase() == "l") ? "" : "
") +"
" +"
" +"
" +"
" // +"
" +"
" +"
" +"
" +"
" +"" ).appendTo("body"); dialog.on("click",".pin",function(){ dialog.find(".pin").hide(); dialog.find(".close").show(); clearTimeout(wd.edit.objectPicker.showHelpid); }) dialog.on("click",".close",function(){ wd.edit.objectPicker.hideHelp(); }) } wd.edit.objectPicker.showHelp=function(element,data){ dialog.find(".content").html(data.content); dialog.find(".pin").show(); dialog.find(".close").hide(); var bounding=element.getBoundingClientRect(); var left=bounding.left+bounding.width; var top=bounding.top+bounding.height; dialog.show(); if(top+dialog.outerHeight()>wd.topWindow.innerHeight){ top=bounding.top-dialog.outerHeight(); dialog.find(".arrowup").hide(); dialog.find(".arrowdown").show(); }else{ dialog.find(".arrowup").show(); dialog.find(".arrowdown").hide(); } dialog.css({left:left+"px",top:top+"px"}); clearTimeout(wd.edit.objectPicker.showHelpid); wd.edit.objectPicker.showHelpid=setTimeout(function(){ wd.edit.objectPicker.hideHelp(); },3000); } wd.edit.objectPicker.hideHelp=function(){ dialog.hide(); } } //根据查找id或name查找元素,可传入多个参数一起查找, 返回找到的第一个 if(!wd.edit.objectPicker.getElementByIdOrByName){ wd.edit.objectPicker.getElementByIdOrByName=function(val){ var result; for(var a=0;a" + "
" + "")[0]; wd.topWindow.document.body.appendChild(ele); return ele } wd.edit.objectPicker.buildMobileSelectOption = function (dom, datalist, valueKey, nameKey, selectValue, hasNullOption) { var ul = dom.childNodes[0]; var st='' if (datalist && datalist.length > 0) { var listr = hasNullOption ? '
   
' : ''; for (var i = 0; i < datalist.length; i++) { var name = datalist[i][nameKey]; var value = datalist[i][valueKey]; listr += '
' + name + '
'; } ul.innerHTML = listr; } else { ul.innerHTML = hasNullOption ? '
找不到相关项
' : ''; } } if(!wd.edit.objectPicker.body) wd.edit.objectPicker.body=function(){ var THIS=this; this.service=null; this.IS_MOBILE=false; //最小输入触发长度,大于等于 this.MINIMUM_INPUT_SIZE=1; //是否每个输入都要查询 this.REAL_TIME_SEARCH=true; //输入停止后触发搜索延迟时间,毫秒 this.SEARCH_DELAY_TIME=1000; //延迟显示详细信息时间 毫秒 this.SHOW_DELAY_TIME=1000; this.VIEW_OBJECT_NAME=null; this.MODIFYABLE=true; //搜索服务,显示服务 this.searchService=null; this.previewService=null; this.name=null;//种子 //唯一标识 this.ID=null; this.initparam=null//初始化参数 this.OTHER_PARAM={}; //其他参数 this.element=null; this.dataElement=null; this.playElement=null; //表面要显示的数据 this.face_name=null; //背后隐藏的数据 this.back_name=null; this.helptip_name=null; this.tipWin=null; this.tipWin_option=null; this.tipWin_button=null; this.tipWin_detail=null; this.selectOption // 搜索结果 this.searchResult=null; this.staticResult=null; this.firstClick=true; //已经输入过 this.haveComfirm=true; // ajax请求时的参数 this.CONNECT_PARAM=null; this.QUERY_PARAM={}; this.wins=null; //弹窗选择器 this.dialogFinderButton=null this.input=false; this.cascadingLevel=null; this.cascadingInputsRule=null; this.cascadingInputsName=null; this.cascadingInputsElement=null; this.addButton=null; this.WINDOWS=null; this.instantSearch=null; this.dropdown=null; // this.$objectPickerNameDiv=$(""+"") this.placeholder=null; this.GrowHeightInstance=null; this.filterField=null; this.getCascadingInputsValue=function(){ if(!this.cascadingInputsElement)return return this.cascadingInputsElement.value } this.setCascadingInputsValue=function(){ if(!this.cascadingInputsElement)return //112233 var rule=this.cascadingInputsRule+""; var vs=[]; for(var i=0;i(rule.length-1)||!vs[num]){ result+="0" }else{ result+=vs[num].substr(i,1); } } if(result.replace(/0+/,"").length==0) result=""; // if(!v){ // // var preObjectPickerName=this.getPreCascadingName(); // var preObjectPicker=wd.edit.objectPicker.getInstance(preObjectPickerName); // // if(preObjectPicker){ // v=preObjectPicker.getValue(); // }else{ // v="" // } // } // this.cascadingInputsElement.value=result; try{ //校验器 // $(this.cascadingInputsElement).trigger("blur").trigger("focus").trigger("keyup"); $(this.cascadingInputsElement).trigger("keyup") }catch(e){ console.log(e); } } //外部调用 this.extension={ onchange:null, getValue:null, getDisplayValue:null, getDisplayElement:null, validation:null, passValidation:null, failValidation:null, getName:null, refreshOption:null, initValue:null, getOptionsSize:null, getOptions:null, refreshCascadingInputsValue:null, refreshElementDisplay:null, setwdCloseWindowParamData:null, setQueryParam:null, copyObjectPicker:null, focus:null, modify:null } this.extension.onchange=null; this.extension.getValue=function getDataElementValue(){ return THIS.getDataElementValue(); } this.extension.getDisplayValue=function(){ return THIS.getElementValue(); } this.extension.passValidation=function(){ return THIS.passValidation() } this.extension.failValidation=function(){ return THIS.failValidation() } this.extension.getName=function(){ return THIS.name; } this.extension.refreshOption=function(args){ var setting=$.extend({},{refreshCascadingOption:true,refreshCascadingName:""},args); THIS.receiveData({async:true,callback:function(){ THIS.showOptions(); THIS.buildOptions(); THIS.setDataElementValue(""); if(!THIS.isCascading()){ THIS.initElementValue(); THIS.showOptions(); }else{ //THIS.initElementValue(); // THIS.confirmOption(true); THIS.setDataElementValue(""); THIS.setElementValue(""); THIS.setCascadingInputsValue(THIS.getDataElementValue()); THIS.hiddenOptions(); THIS.hiddenDetail(); THIS.changeFinish(setting); if(THIS.getOptionsSize()>0&&setting.refreshCascadingName==THIS.name){ THIS.showOptions(); } } }}); } this.extension.initValue=function(v,args){ THIS.setDataElementValue(v); THIS.initElementValue(); THIS.changeFinish(args); } this.extension.getDisplayElement=function(){ return THIS.getElement(); } this.extension.getOptionsSize=function(){ return THIS.getAllData().length; } this.extension.refreshCascadingInputsValue=function(){ return THIS.setCascadingInputsValue(); } this.extension.refreshElementDisplay=function(args){ if(args.value) THIS.setDataElementValue(args.value); THIS.initElementDisplay(args); //THIS.changeFinish(args); } this.extension.setwdCloseWindowParamData=function(datas){ THIS.setwdCloseWindowParamData(datas); THIS.WINDOWS.wd.edit.objectPicker.addButtonClickName=null; } this.extension.setQueryParam=function(name,v){ console.log(THIS.QUERY_PARAM); THIS.QUERY_PARAM[name]=v; } this.extension.copyObjectPicker=function(name){ //不支持级联 var newinitparam=$.extend({},THIS.initparam,{name:name}); new wd.edit.objectPicker.body().init(newinitparam); } this.extension.focus=function(){ THIS.elementInputFunction(); } this.extension.modify=function(canModify){ THIS.MODIFYABLE=canModify?true:false; THIS.$objectPickerSelectTriangle.css("opacity",canModify?1:0); } this.extension.getOptions=function(){ var setting={refreshCascadingOption:false}; THIS.receiveData({async:false,callback:function(){ }}); return THIS.getAllData(); } //初始化 this.init=function(initparam){ this.name=initparam.name; this.input=initparam.input; this.IS_MOBILE=initparam.isMobile var name=this.name; var placeholder=""; //目标输入元素 var elem,hiddenElem,playElem,$elem,$elem_mobile; hiddenElem=wd.edit.objectPicker.getElementByIdOrByName(name,name+"m",name+"id",name+"Id",name+"ID"); playElem=wd.edit.objectPicker.getElementByIdOrByName(name+"Play"); $elem=$("
"); $elem_mobile=$("
"); elem=wd.edit.objectPicker.getElementByIdOrByName(name+"name",name+"Name",name+"NAME"); var cssElement; cssElement=elem||hiddenElem; if(cssElement.getAttribute("placeholder")){ placeholder=cssElement.getAttribute("placeholder"); $elem.attr("placeholder",placeholder); $elem_mobile.attr("placeholder",placeholder); } $elem.attr("style",cssElement.getAttribute("style")); $elem_mobile.attr("style",cssElement.getAttribute("style")); if(playElem){ playElem.setAttribute("style",cssElement.getAttribute("style")); playElem.style.display="inline-block"; } if(cssElement.getAttribute("width")){ $elem.css({width:cssElement.getAttribute("width")}); $elem_mobile.css({width:cssElement.getAttribute("width")}); } this.placeholder=placeholder; hiddenElem.setAttribute("type","hidden"); if(elem){ $(elem).remove(); } var GrowHeightInstance; if(this.IS_MOBILE){ $(hiddenElem).before($elem_mobile); var $elem_mobile_textarea=$($elem_mobile).find("textarea"); this.GrowHeightInstance={val:function(v){ if(typeof v=="undefined"){ return $elem_mobile_textarea.val()||''; } $elem_mobile_textarea.val(v); }}; if(!this.input){ $elem_mobile_textarea.attr("disabled",true); } elem=$elem_mobile[0]; }else{ $(hiddenElem).before($elem); var thisid=$elem.attr("id"); try{ if(!window.getGrowHeight||!wd.edit.initGrowHigh){ $("head").append("") $("head").append("") } if(window.growHeightList&&window.growHeightList[thisid]){ $(window.growHeightList[thisid].container.parentNode).remove(); delete window.growHeightList[thisid]; } wd.edit.initGrowHigh(thisid,'null',{}); GrowHeightInstance=window.growHeightList[thisid]; elem=GrowHeightInstance.getInputElement().parentNode; if(!this.input){ GrowHeightInstance.getInputElement().setAttribute("disabled",true); } this.GrowHeightInstance=GrowHeightInstance; }catch(e){ console.log(e); return; } } // target:elem, // datatarget:hiddenElem, // playElem:playElem, //////this.element=initparam.target; //////this.dataElement=initparam.datatarget //////this.playElement=initparam.playElem; this.element=elem; this.dataElement=hiddenElem; this.playElement=playElem /////////////////////////////////////// if(!wd.topWindow)wd.topWindow=top this.WINDOWS=window; // console.log(initparam); this.wins=window; /////this.GrowHeightInstance=initparam.GrowHeightInstance; // this.ID=initparam.ID; this.initparam=initparam ////this.element=initparam.target; ////this.dataElement=initparam.datatarget ////this.playElement=initparam.playElem; this.element.objectPickerBody=this; this.dataElement.objectPickerBody=this; this.elementValue=null this.dataElementValue=null this.searchService=initparam.search this.previewService=initparam.preview this.face_name=initparam.facename; this.back_name=initparam.backname; this.helptip_name=initparam.helptipname; // this.tipWin_button=initparam.okbutton//按钮 this.VIEW_OBJECT_NAME=initparam.viewobject; //eval+stringify复制这个对象 this.OTHER_PARAM=initparam.otherparam; ////this.placeholder=initparam.placeholder; this.addButton=initparam.addButton; this.instantSearch=initparam.instantSearch; this.dropdown=initparam.dropdown; this.filterField=initparam.filterField; var p=initparam.connectparam; this.CONNECT_PARAM=JSON.stringify(initparam.connectparam); this.cascadingLevel=initparam.cascadingLevel; this.cascadingInputsRule=initparam.cascadingInputsRule; this.cascadingInputsName=initparam.cascadingInputsName; if(this.cascadingInputsName){ this.cascadingInputsElement=document.querySelector("[name="+this.cascadingInputsName+"]"); if(this.cascadingInputsElement){ wd.edit.cascading.instance[this.cascadingInputsName]={} wd.edit.cascading.instance[this.cascadingInputsName]["cascadingInputsRule"]=this.cascadingInputsRule; wd.edit.cascading.instance[this.cascadingInputsName]["cascadingLevel"]=this.cascadingLevel; wd.edit.cascading.instance[this.cascadingInputsName]["cascadingInputsName"]=this.cascadingInputsName; wd.edit.cascading.instance[this.cascadingInputsName]["cascadingInputsElement"]=this.cascadingInputsName; } } // this.helptip_name="meow"; initparam.helptipData=initparam.helptipData||{}; //初始化转换数据 if(initparam.codebookData){ // {1: '男性', 2: '女性'}。Lin this.searchResult=[]; for(var i=0;i").insertAfter(this.element); // console.log(this.element); // } // console.log(this.extension); wd.edit.objectPicker.instance[this.name]=this.extension this.initElementDisplay({isInit:true,triggerChange:false}); // this.initElementValue();//初始化姓名 return this; } this.initdialogFinderButton=function(){ if(!this.dialogFinderButton)return; var THIS=this; $(this.dialogFinderButton).on("click",(function(){ return function(){ // console.log(THIS); wd.topWindow.objectPickerObject=THIS } })()) } this.initElementDisplay=function(args){ var setting=$.extend({},{iteration:false,isInit:false,triggerChange:true},args); this.setElementValue(""); var receive=false; if(setting.iteration){ receive=true; }else if(this.isCascading()){ //级联从最后一级往上初始化 receive=!THIS.getNextCascadingName() if(setting.isInit){ // 根据rule填充值 var cascadingV=this.calCascadingInputValue(); if(cascadingV) this.setDataElementValue(cascadingV); } if(receive){ args={refreshPreCascading:true,iteration:true,triggerChange:false}; } }else if(this.getDataElementValue()){ receive=true; } if(receive){//单独picker this.receiveData({async:true,searchValue:true,dataValue:this.getDataElementValue(),callback:function(){ var thisData=null; for(var i=0;THIS.searchResult&&i" // +"
" // +"" //// +"" // +"
" // +"
    " // var content="
    " // +"
    " // +"
    " var content="" //详细信息 +"
    " // +"
    " +"
    " +"
    " //确认按钮 // position:absolute;left:10px;top:10px;display:none;z-index:1003; +"" try{ this.ID="objectPickerBody_"+this.name.replace(/\./,''); var usableId=this.ID; var count=1; var exitTopWin=wd.topWindow.$("#"+usableId); while(exitTopWin.length>0){ var opw=exitTopWin[0].objectpickerwindow; if(opw&&opw.closed===true){//清除无用的div exitTopWin.remove(); break; } count++; usableId=THIS.ID+"_"+count; exitTopWin=wd.topWindow.$("#"+usableId) } this.ID=usableId; this.tipWin.setAttribute("class"," objectPickerBody"); this.tipWin.setAttribute("id",this.ID); // $(window).unload(function(){ // wd.topWindow.window.$("#"+THIS.ID).remove(); // }) this.tipWin.objectpickerwindow=window; // wd.topWindow.window.$("."+this.ID).remove(); wd.topWindow.document.body.appendChild(this.tipWin); wd.edit.objectPicker.tipWinList.push(this.ID); }catch(e){ console.log(e) } this.tipWin.innerHTML=content var initSelectOption=this.IS_MOBILE?wd.edit.objectPicker.initMobileSelectOption:wd.display.initSelectOption; this.tipWin.appendChild(initSelectOption(this.ID+"_selectOption")) // console.log(this.tipWin.childNodes) this.tipWin_option=this.tipWin.childNodes[2] $(this.tipWin_option).addClass("objectPickerOption"); this.tipWin_detail=this.tipWin.childNodes[0] if(this.IS_MOBILE){ this.$objectPickerSelectTriangle=$(""); this.tipWin_option_list_class="mobilePopupList"; }else{ this.$objectPickerSelectTriangle=$(""); this.tipWin_option_list_class="popupList"; } if(!this.dropdown){ this.$objectPickerSelectTriangle.hide(); }else if(this.input){ this.$objectPickerSelectTriangle.last().hide(); }else{ this.$objectPickerSelectTriangle.first().hide(); } this.$objectPickerSelectTriangle.appendTo(this.element); $(this.element).find("textarea").css("width","calc(100% - "+(this.$objectPickerSelectTriangle.width()+4)+"px)"); // //确认按钮可能已经在页面设置好 // if(!this.tipWin_button){ // console.log("找不到ok按钮") // this.tipWin_button=this.tipWin.childNodes[1] // } $(this.tipWin_option).on("mouseover","."+this.tipWin_option_list_class,this.tipWinOptionMouseOverFun) $(this.tipWin_option).on("mouseout","."+this.tipWin_option_list_class,this.tipWinOptionMouseOutFun) $(this.tipWin_option).on("click",this.tipWinOptionClickFun); $(this.tipWin_option).on("contextmenu",function(){return false}); $(this.tipWin_option).on("mousedown","."+this.tipWin_option_list_class,this.tipWinOptionRightClickFun); //关闭按钮\n // $(this.tipWin_option).on("click",".close_option",this.tipWinOptionCloseFun()); //显示全部按钮 // $(this.tipWin_option).on("click",".show_all_option",this.tipWinOptionShowAllFun()); //$(this.tipWin_button).on("click",this.tipWinButtonClickFun).insertAfter(this.element); // $(this.tipWin_button).on("mouseover","button,input[type=button]",this.tipWinButtonMouseOverFun()) // $(this.tipWin_button).on("mouseout","button,input[type=button]",this.tipWinButtonMouseOutFun()) // $(this.element).on("contextmenu",function(){return false}); // $(this.element).on("mouseover",this.elementMouseoverFunction); // $(this.element).on("mouseout",this.elementMouseOutFunction); if(this.input){ if(this.instantSearch){ $(this.element).find("textarea").on("input",this.elementInputFunction); }else{ $(this.element).find("textarea").on("keyup",this.elementEnterKeyFunction); } // $(this.element).find("input").on("keyup",this.keyupAndDownFunction()); $(this.element).find("textarea").focus(this.elementFocusFunction).blur(this.elementFocusToBlurFunction); }else{ $(this.element).on("click",this.elementInputFunction); } this.$objectPickerSelectTriangle.on("click",this.triangleClickFunction); // try{ // wd.topWindow.$("body").on("click",this.elementBlurFunction); // }catch(e){ // console.log(e) // } // // //$(".content-div,.list-div").scroll(this.elementBlurFunction); } this.tipWinOptionMouseOutFun=function(){ if(THIS.selectOneOption){ THIS.uncheckOption(THIS.selectOneOption); } THIS.selectOneOption=null; } this.selectOneOption=null; //列表上预览信息 this.tipWinOptionMouseOverFun=function(){ //console.log(this); var lis=THIS.tipWin_option.querySelectorAll("."+THIS.tipWin_option_list_class) THIS.selectOneOption=this; THIS.checkOption(this) for(var i=0;iop.scrollTop+boundingEle.height*capacity){ op.scrollTop=boundingEle.height*(index-capacity) } // //新位置看不到,滚动到底部 // if(ele.offsetHeight*index>op.getBoundingClientRect().height){ // op.scrollTop=ele.offsetHeight*(index+capacity) // } } ele.setAttribute("checkstate","selected"); // ele.style.backgroundColor="#ccc" // ele.style.border="1px solid" } //根据提供字符串的相识度选中最高的下拉 this.checkMatchingOption=function(inputValue){ var op=this.tipWin_option; var all=op.querySelectorAll("."+this.tipWin_option_list_class+"[status=people]") //完全匹配 var ferfectMatch=false; for(var i=0;i"; content+=""; div.innerHTML=content; },1000) }else{ // div.style.display="none"; } } this.tipWinOptionShowAllFun=function(){ var THIS=this; return function(){ console.log("开发中") } } this.tipWinOptionCloseFun=function(){ var THIS=this; return function(){ THIS.hiddenDetail(); THIS.hiddenOptions(); } } this.hiddenButton=function(){ // this.tipWin_button.style.display="none"; $(this.tipWin_button).hide(); } this.showButton=function(){ var xy=this.recursionIframe() var bounding= this.element.getBoundingClientRect(); //确认按钮先显示,先可以获取宽度 // if(false&&this.input) // this.tipWin_button.style.display="none"; if(false&&this.input) $(this.tipWin_button).show(); // this.tipWin_button.style.display=""; // this.tipWin_button.style.left=xy.left+bounding.left+bounding.width-this.tipWin_button.clientWidth+"px"; // var correction=1;//偏差修正值 // this.tipWin_button.style.top=xy.top+bounding.top+correction+"px"; // // this.tipWin_button.style.height=bounding.height-correction+"px"; // $(this.tipWin_button).children("input").insertAfter(this.element).css({height:(bounding.height-correction)}); } this._optionishidden=false; this.optionisHidden=function(){ return this._optionishidden; } this.showOptions=function(){ this._optionishidden=false; this.tipWin_option.style.display="" wd.edit.objectPicker.activeInstance[this.name]=this; if(this.IS_MOBILE){ }else{ //减少调用次数 if(wd.edit.objectPicker.initScrollId){ window.clearTimeout(wd.edit.objectPicker.initScrollId) } wd.edit.objectPicker.initScrollId=setTimeout(function(){ try{ if(wd.topWindow.initNiceScorll) wd.topWindow.initNiceScorll(); }catch(e){ console.log(e); } },1000) } } this.hiddenOptions=function(){ this._optionishidden=true this.tipWin_option.style.display="none" wd.edit.objectPicker.activeInstance[this.name]=null; wd.edit.objectPicker.hideHelp(); } this.elementKeyUpFunction=function(){ var THIS=this; return function(){ } } this.showLeftSpan=function(){ // console.log(this); var leftSpan=document.getElementById(this.name+"Span"); if(!leftSpan){ leftSpan=document.createElement("span"); leftSpan.setAttribute("id",this.name+"Span"); leftSpan.setAttribute("class","border-input-error"); this.getElement().parentNode.insertBefore(leftSpan,this.getElement()); } leftSpan.style.display= ""; } this.hideLeftSpan=function(){ var leftSpan=document.getElementById(this.name+"Span"); if(!leftSpan)return; leftSpan.style.display= "none"; } this.lastInputValue=null; this.keyupAndDownFunction=function(){ var THIS=this; return function(){ var keycode=window.event.keyCode; //按下键盘上,键盘下 // console.log(keycode) if(keycode==38||keycode==40||keycode==13){ window.event.stopPropagation() //UP if(keycode==38){ THIS.nextOption(-1) } //DOWN if(keycode==40){ THIS.nextOption(1) } //ENTER if(keycode==13){ THIS.confirmOption(true) } return true } } } this.elementInputTimeOutId=null; this.elementInputFunction=function(){ //wd.topWindow.$(".objectPickerOption").css({display:"none"}); wd.edit.objectPicker.hideAllOptions(); var inputValue=THIS.getElementValue();//当前数值 if(!THIS.MODIFYABLE|| THIS.input&&!inputValue)return THIS.haveComfirm=false; THIS.showOptions(); if(!THIS.searchResult||THIS.REAL_TIME_SEARCH){ if(THIS.input){//延时请求 if(THIS.elementInputTimeOutId){ clearTimeout(THIS.elementInputTimeOutId); THIS.elementInputTimeOutId=null; } THIS.elementInputTimeOutId=setTimeout(function(){ THIS.receiveData({callback:function(){ //查询出结果集之后,如果只有一个值就自动选中 if(THIS.searchResult.length==1){ var nextCascadingName=THIS.getNextCascadingName(); THIS.confirmOptionData(true,{refreshCascadingName:nextCascadingName},THIS.searchResult[0]); }else{ THIS.buildOptions(); } },async:true}); },THIS.SEARCH_DELAY_TIME) }else{ THIS.receiveData({callback:THIS.buildOptions,async:true}); } } THIS.lastInputValue=inputValue; return false; } this.elementEnterKeyFunction=function(){ if(window.event.keyCode===13){ THIS.elementInputFunction(); return false; } } this.triangleClickFunction=function(){ if(!THIS.MODIFYABLE||!THIS.optionisHidden()){ THIS.hiddenOptions(); return false } //wd.topWindow.$(".objectPickerOption").css({display:"none"}); wd.edit.objectPicker.hideAllOptions(); var inputValue=THIS.getElementValue();//当前数值 THIS.haveComfirm=false; THIS.showOptions(); if(!THIS.searchResult||THIS.REAL_TIME_SEARCH){ THIS.receiveData({callback:THIS.buildOptions,searchAll:true,async:true}); } THIS.lastInputValue=inputValue; return false; } this.calCascadingInputValue=function(){ if(!this.cascadingInputsRule)return null; var inputsV=this.getCascadingInputsValue(); if(!inputsV)return null; if(inputsV.length!=this.cascadingInputsRule.length)return null; var index=0; var inIt=false; for(var i=0;i=cv){ result+=inputsV.substr(i,1) }else{ result+="0" } } return result; } //是否级联 this.isCascading=function(){ return (!this.cascadingLevel||this.cascadingLevel.length==0)?false:true; } this.getPreCascadingName=function(searchname){ if(!this.isCascading())return null; if(!searchname) searchname=this.name; var index=0; for(var i=0;i10)break; count++; preObjectPickerName=THIS.getPreCascadingName(preObjectPickerName); // console.log(preObjectPickerName) preObjectPicker=wd.edit.objectPicker.getInstance(preObjectPickerName); if(preObjectPicker){ var v=preObjectPicker.getValue(); param[preObjectPickerName]=v; if(!param["upperValue"]) param["upperValue"]=v; }else{ break; } } } if(setting.searchAll){ param["objectpickerinput"]=""; } if(requestData){ if(THIS.IS_MOBILE){ }else{ wd.display.showLoad(); } $.ajax({ url:this.searchService, data:param, dataType:'json', async:setting.async, timeout:10000, error:function(data){ if(THIS.IS_MOBILE){ }else{ if("timeout"==data.statusText){ wd.display.alert("网络连接超时!"); }else{ wd.display.alert("网络连接失败!"); } wd.display.closeLoad(); } return false; }, success:function(data){ ///// 再增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin /* 再去掉,改为 (data.ssCode != 0) 后一直显示 "undefined" 错误信息 -- data.ssMsg 值为 "undefined"。Lin * ObjpServ.loadOptByA() 还没有使用 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData * data.ssCode 为 undefined 时,之前写的 (data.ssCode == 0) 为 false,改为 (data.ssCode != 0) 则为 true -- ssCode,把 0 = 错误、1 = 成功 改为 0 = 成功,1 = 错误 if (data.ssCode != 0) { /// * 再改,要用 alert(,要有弹出窗口 -- 一闪而过,以为没错。Lin // wd.display.alert(data.msg); // 不用 alert( -- 有弹出窗口。Lin /// * alert(data.ssMsg); return; } */ ///// if(THIS.IS_MOBILE){ }else{ wd.display.closeLoad(); if(data.errmsg){ console.log(data.errmsg); wd.display.alert(data.errmsg); return false; } } /* 再改 data.result(List>) 为 Map。Lin * 原 List,Map<"xbm":"2","mc":"女">> 改为 Map<"1":"男","2":"女"> * 在这再转回 List,Map<"xbm":"2","mc":"女">> -- 先把 Java 改好,不改 JS 先 * 先不支持 Tips 内容,用到再弄 THIS.searchResult=data.result; */ /// 抄自 init( 里的。Lin //初始化转换数据 if (data.result) { // {1:'男性', 2:'女性'}。Lin THIS.searchResult = []; for (var key in data.result) { var aa = {}; aa[data.invisiable] = key; // "xbm"。Lin aa[data.visiable] = data.result[key]; // "mc"。Lin THIS.searchResult.push(aa); // {mc: '男性', xbm: '1'}, {mc: '女性', xbm: '2'}。Lin } } /// if(data.visiable) THIS.face_name=data.visiable; if(data.invisiable) THIS.back_name=data.invisiable; if(data.helptip_name) THIS.helptip_name=data.helptip_name if(typeof THIS.searchResult=="string"){ THIS.searchResult=eval("("+THIS.searchResult+")") } if(setting.callback){ //定时器 setting.callback.apply(THIS) } } }) }else{ if(setting.callback){ //定时器 setting.callback.apply(THIS) } } } this.getOptionsSize=function(){ var op=this.tipWin_option; var queryselector=op.querySelectorAll("."+this.tipWin_option_list_class); return queryselector.length-1; } this.getAllData=function(){ var result=[]; if(this.staticResult){ result=result.concat(this.staticResult); // null。Lin } if(this.searchResult){ result=result.concat(this.searchResult); // {mc: '男性', xbm: '1'}, {mc: '女性', xbm: '2'}。Lin } return result; } this.findDataByValue=function(v){ var alldata=this.getAllData(); for(var i=0;i0){ // this.hideLeftSpan(); // // var listr = '
    请选择
    ',arr = this.searchResult; // for(var i = 0;i'+arr[i][this.face_name]+''; // } // ul.innerHTML=listr; //// this.checkMatchingOption(inputValue) // }else{ // this.showLeftSpan(); // ul.innerHTML='
    找不到相关项
    ' // } // console.log(this.addButton); var buildSelectOption=THIS.IS_MOBILE?wd.edit.objectPicker.buildMobileSelectOption:wd.display.buildSelectOption; buildSelectOption(this.tipWin_option,this.getAllData(),this.back_name,this.face_name,this.getDataElementValue(),true) if(this.addButton) $('
    ').appendTo(ul).on("click",function(){ THIS.WINDOWS.wd.edit.objectPicker.addButtonClickName=THIS.name; THIS.hiddenOptions(); eval(THIS.addButton); }) if(this.searchResult.length>0){ this.hideLeftSpan(); }else{ this.showLeftSpan(); } //定位位置 var bounding=this.element.getBoundingClientRect(); var xy=this.recursionIframe(); var left=bounding.left+xy.left; var top; if(THIS.IS_MOBILE){ top=bounding.top+bounding.height; }else{ top=bounding.top+xy.top+bounding.height; } this.tipWin_option.style.left=left+"px"; this.tipWin_option.style.top=top+"px"; this.tipWin_option.style.minWidth=this.element.offsetWidth+"px"; this.tipWin_option.style.maxWidth=`calc(100vw - ${bounding.left}px - 18px)`; ul.style.minWidth=this.element.offsetWidth-18+"px"; this.tipWin_option.style.width="auto"; ul.style.width="auto"; ul.style.maxWidth=`calc(100vw - ${bounding.left}px - 18px)`; if(top+this.tipWin_option.offsetHeight>wd.topWindow.innerHeight){ var options=$(ul).children().detach(); for(var i=options.length-1;i>=0;i--){ $(options[i]).appendTo(ul); } top=bounding.top+xy.top-this.tipWin_option.offsetHeight this.tipWin_option.style.top=top+"px"; ul.scrollTop=ul.scrollHeight; } } //计算字符串相似度 this.calSimilarity=function(s1,s2){ } this.inputMouseUpAndDown_Interaval_ID=null; //向上选择 this.nextOption=function(step){ var op=this.tipWin_option; // if(op.querySelectorAll("li[status=noitem]").length>0){return} var index=null; var queryselector=op.querySelectorAll("."+this.tipWin_option_list_class); var selection=null; var index=0; var all=op.querySelectorAll("."+this.tipWin_option_list_class+"[status=people]"); if(queryselector.length>0){ selection= queryselector[0] this.uncheckOption(selection) index=parseInt(selection.getAttribute("index")); index+=step; } if(index<0){ index=0; }else if(index>all.length){ index=all.length } var nextselection=all[index]; this.checkOption(nextselection,true) var bounding=this.tipWin_option.getBoundingClientRect() var xy=this.recursionIframe(); // this.showDetail(xy.left+bounding.left+bounding.width,xy.top+bounding.top,index); } // this.oneclickhiddendetail=false; // // // this.elementMouseoverFunction=function(){ // // if(THIS.optionisHidden()&&THIS.haveComfirm&& THIS.getDataElementValue()){ // var xy=THIS.recursionIframe(); // var bounding=this.getBoundingClientRect(); // // var left=bounding.left+xy.left; // var top=bounding.top+bounding.height+xy.top; // // THIS.showDetailByValue(left,top,THIS.getDataElementValue()) // // if(!THIS.oneclickhiddendetail){ // $(document).one("click",function(){ // THIS.oneclickhiddendetail=false; // THIS.hiddenDetail() // }) // THIS.oneclickhiddendetail=true; // } // // // // }else{ // THIS.hiddenDetail() // } // return false; // } // // // // this.elementMouseOutFunction=function(){ // // THIS.hiddenDetail(); // return false; // } this.elementFocusFunction=function(){ console.log("elementFocusFunction"); if(THIS.getElementValue().length>=THIS.MINIMUM_INPUT_SIZE){ THIS.showOptions(); THIS.receiveData({callback:THIS.buildOptions,async:true}); } if(THIS.IS_MOBILE){ $(THIS.element).addClass("mobileInput-div-selected input-s"); }else{ $(THIS.element).addClass("input-div-selected input-s"); } } this.elementFocusToBlurFunction=function(){ if(THIS.getElementValue()!=THIS.elementValue){ THIS.setElementValue(THIS.elementValue); } $(THIS.element).removeClass("mobileInput-div-selected input-div-selected input-s"); return false; } this.elementBlurFunction=function(e){ if(THIS.optionisHidden()){ return }else{ if(THIS.cascadingInputsRule){ } } if(!e)e=window.event; if(!e)return; if(e.target&&(e.target==THIS.element))return; if(e.target&&$(THIS.element).children().is(e.target))return; if($(e.target).parents(".objectPickerBody").length>0)return; THIS.refreshElementValue(); THIS.hiddenOptions(); THIS.hiddenDetail(); return false; } this.recursionIframe=function(win){ if(!win){ win=this.wins; } function getTop (e){ var offset=e.offsetTop; if(e.offsetParent!=null) offset+=getTop(e.offsetParent); return offset; } function getLeft (e){ var offset=e.offsetLeft; if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); return offset; } if(win.parent==top&&win.parent==win){ return {"left": 0, "top": 0 }; } var winPar = win.parent;// .opener var iframeArr = winPar.document.getElementsByTagName('IFRAME'); var targetIframe; var iframeArr1 = win.document.getElementsByTagName('IFRAME'); for(var i=0;i"+this.placeholder+"" //// +this.objectPickerSelectTriangle; //// }else{ //// this.element.innerHTML=""+v+"" //// +this.objectPickerSelectTriangle; //// } // if(!v){ // this.$objectPickerNameDiv.last().show().html(this.placeholder); // this.$objectPickerNameDiv.first().hide(); // }else{ // this.$objectPickerNameDiv.last().hide(); // this.$objectPickerNameDiv.first().show().html(v);; // } // // } if(this.playElement) this.playElement.innerHTML=v; // var $triangle=$(this.element.childNodes[1]); // this.element.childNodes[0].style.maxWidth=$(this.element).width()-$triangle.width()-parseInt($triangle.css('marginLeft')); // } this.getDataElement=function(){ return this.dataElement; } this.getDataElementValue=function(){ return this.dataElement.value; } this.setDataElementValue=function(v){ $(this.dataElement).val(v); this.dataElementValue=v; } this.changeFinish=function(args){ //console.log("change fish "+this.name); var setting=$.extend({},{triggerChange:true,refreshCascadingOption:false,refreshPreCascading:false,refreshNextCascading:false},args); if(setting.refreshCascadingOption){//刷新下一个选项卡选项 var nextCascadingName=this.getNextCascadingName(); var nextCascading=wd.edit.objectPicker.getInstance(nextCascadingName); if(nextCascading){ nextCascading.refreshOption(args); } } //刷新上一个级联 if(setting.refreshPreCascading){ var preCascadingName=this.getPreCascadingName(); //console.log("preCascadingName:"+preCascadingName); var preCascading=wd.edit.objectPicker.getInstance(preCascadingName); if(preCascading){ preCascading.refreshElementDisplay(args); }else{ this.setCascadingInputsValue() } } //刷新下一个级联 if(setting.refreshNextCascading){ var nextCascadingName=this.getNextCascadingName(); var nextCascading=wd.edit.objectPicker.getInstance(preCascadingName); if(nextCascading){ nextCascading.refreshElementDisplay(args); } } if(setting.triggerChange){ $(this.element).trigger("change"); $(this.dataElement).trigger("change").trigger("keyup"); if(this.extension.onchange){ this.extension.onchange.call(this.extension,this.extension); } } } this.passValidation=function(){ this.getElement().style.border=""; } this.failValidation=function(){ this.getElement().style.border="red 1px solid"; } } if(!wd.edit.objectPicker.createObjectPicker) wd.edit.objectPicker.createObjectPicker=function(name,field,viewobject,input,defaultValue,param,sservice,miniPlay,codebookData,addButton,instantSearch,dropdown,filterField,helptipData,isMobile_){ // var parentRoot; // //根据查找id或name查找元素,可传入多个参数一起查找, 返回找到的第一个 // function getElementByIdOrByName(val){ // var result; // for(var a=0;a // var selectElement=document.createElement("select"); // selectElement.setAttribute("name",name); // // //nulloption // var nulloption=document.createElement("option"); // selectElement.appendChild(nulloption) // // //