var frontproducts_generalsearch01={ patterndate :/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/, patterncurrency :/^\d{1,8}(\.\d{0,2})?$/, compid :"", mustinputkeyword:"false", inputkeyword:"", /*** * 对输入关键字进行判断 * @param {} compid * @param {} inputkeyword */ keyover:function(compid,inputkeyword){ if(jquery("#"+compid+"_keyword").val() ==inputkeyword){ jquery("#"+compid+"_keyword").val(""); jquery("#"+compid+"_keyword").focus(); } }, /*** * 对输入关键字进行判断 * @param {} compid * @param {} inputkeyword */ keyout:function(compid,inputkeyword){ if(this.trim(jquery("#"+compid+"_keyword").val()) ==""){ jquery("#"+compid+"_keyword").val(inputkeyword); jquery("#"+compid+"_keyword").addclass("input-keyword"); }else{ jquery("#"+compid+"_keyword").val(this.trim(jquery("#"+compid+"_keyword").val())); jquery("#"+compid+"_keyword").removeclass("input-keyword"); } }, /** *功能:去掉字符串的特殊字符,用""取代之。 *参数:str-要被修改的字符串 * flag-标志 */ trim:function (str , flag){ str = ""+str; if( flag == "l" || flag == "l" )/*trim left side only*/ { regularexp = /^\s+/gi; return str.replace( regularexp,"" ); } else if( flag == "r" || flag == "r" )/*trim right side only*/ { regularexp = /\s+$/gi; return str.replace( regularexp,"" ); } else/*defautly, trim both left and right side*/ { regularexp = /^\s+|\s+$/gi; var keyword = str.replace( regularexp,"" ); //var ts = keyword.replace(/(^ *)/g, ""); return keyword; } }, /** *功能 : 检查输入框 *参数 : form对象object */ validateform:function (compid,mustinputkeyword,inputkeyword){ this.compid = compid; this.mustinputkeyword = mustinputkeyword; this.inputkeyword = inputkeyword; //验证关键字是否必填 if(this.checkkeywords()==false){ return false; } var beginvalue = jquery("#"+this.compid+"_beginvalue").val(); var endvalue = jquery("#"+this.compid+"_endvalue").val(); var propertyid = jquery("#"+this.compid+"_propertyid").val(); var propertytype = jquery("#"+this.compid+"_propertytype").val(); var areatype = jquery("#"+this.compid+"_areatype").val(); //去除得到的form名字的空格等字符 var keyword = this.trim(jquery("#"+this.compid+"_keyword").val()); jquery("#"+this.compid+"_keyword").val(keyword); //编译并赋值 if(keyword==this.inputkeyword){ jquery("#"+this.compid+"_keyword").val(""); } var searchtype="1";//默认认为propertyid==null只查询keyword,pmcid if(propertyid !=null && propertyid !="" ){ if(propertytype =="3" ){ searchtype ="3";//keyword,pmcid,propertyid,beginvalue,endvalue }else{ searchtype ="2";//keyword,pmcid,propertyid } } jquery("#"+this.compid+"_searchtype").val(searchtype); if(areatype!=""){ //判断区间属性输入 if(areatype =="bigdecimal"){ //验证开始值和结束值 if(this.checknumber()==false) return false; }else if(areatype =="date"){ //验证日期 if(this.ischeckareadate()==false) return false; } } var fpkeyword=jquery("#"+this.compid+"_keyword").serialize(); jquery.ajax({ type: "post", url: "/frontproducts.do?method=keywordstat", data:fpkeyword, datatype: "text", cache: false, success: function(data){ } }); return true; }, /*** * 验证关键字必填 * @return {boolean} */ checkkeywords:function(){ if(this.mustinputkeyword=='true'){ if(this.trim(jquery("#"+this.compid+"_keyword").val())==this.inputkeyword ||this.trim(jquery("#"+this.compid+"_keyword").val())=="") { alert(this.inputkeyword); jquery("#"+this.compid+"_keyword").val(""); jquery("#"+this.compid+"_keyword").focus(); return false; } } return true; }, /** * 验证区间数值的大小 * 参数 : beginvalueobj开始值,endvalueobj 结束值 * */ checknumber:function (){ if (jquery("#"+this.compid+"_beginvalue").val() && !this.patterncurrency.test(jquery("#"+this.compid+"_beginvalue").val())) { alert(i18n_products_error_beginvalue); jquery("#"+this.compid+"_beginvalue").focus(); return false; } if (jquery("#"+this.compid+"_endvalue").val() && !this.patterncurrency.test(jquery("#"+this.compid+"_endvalue").val())) { alert(i18n_products_error_endvalue); jquery("#"+this.compid+"_endvalue").focus(); return false; } if (jquery("#"+this.compid+"_beginvalue").val() && jquery("#"+this.compid+"_endvalue").val() && (parseint(jquery("#"+this.compid+"_beginvalue").val()) > parseint(jquery("#"+this.compid+"_endvalue").val()))) { alert(i18n_products_mustaboveprice); jquery("#"+this.compid+"_endvalue").focus(); return false; } return true; }, /** *功能 : 高级搜索连接 *参数 : href -- 连接地址, * opentype -- 打开方式 */ queryadvance:function (href,opentype){ if(opentype=="_self") { location.href = href; }else { window.open(href); } }, /** *功能 : 根据不同的分类获取分类的属性 *参数 : form--form id * this.compid--组件 id * type -- 标签样式 * */ changecategory:function(compid,type,pmcid,allproperty){ //ztouch sp4中去掉dwr 改用jquery方式实现 jquery.getjson('/frontproducts.do?method=dogettemplatepropertiesbycategoryid',{"pmcid":pmcid},function(obj){ if(obj){ var inner_str2 = ""; _getelementbyid(compid,type,"template").innerhtml=inner_str2; } }); //取得模版 //producttempaletservice.dogettemplatepropertiesbycategoryid(pmcid,function(obj){ //如果模版不为空,取得该模版中对应的属性。并且重写jsp选择下拉框 // if(obj!=null){ // var inner_str2 = ""; // _getelementbyid(compid,type,"template").innerhtml=inner_str2; // } //}); }, /**功能 : 验证相连日期的输入值样式为2009-02-21 * 参数 :beginvalueobj--开始日期对象 * endvalueobj --结束日期对象 */ ischeckareadate:function(){ if (jquery("#"+this.compid+"_beginvalue").val() && !this.patterndate.test(jquery("#"+this.compid+"_beginvalue").val())) { alert(i18n_products_inputcorrectdate); jquery("#"+this.compid+"_beginvalue").focus(); return false; } if (jquery("#"+this.compid+"_endvalue").val() && !this.patterndate.test(jquery("#"+this.compid+"_endvalue").val())) { alert(i18n_products_inputcorrectdate); jquery("#"+this.compid+"_endvalue").focus(); return false; } if (jquery("#"+this.compid+"_beginvalue").val() && jquery("#"+this.compid+"_endvalue").val() && (jquery("#"+this.compid+"_beginvalue").val() > jquery("#"+this.compid+"_endvalue").val())) { alert(i18n_products_mustlessenddate); jquery("#"+this.compid+"_endvalue").focus(); return false; } return true; } }