思路:根据选择type来改变参项的显示状态
例1 数据集写法:
select * from sale
where dpmc is not null
${if(type='date',"and yyrq>='"+stdate+"' and yyrq<='"+enddate+"'","")}
${if(type='month', " and month(yyrq) = "+yue+ "and year(yyrq) = '" +nf+"'", "")}
${if(type='year', " and year(yyrq)= '" +nf+"'", "")}
${if(len(qy)==0,"","and quyu in ('"+SUBSTITUTE(qy,",","','")+"')")}
type控件改变状态事件
var form=this.options.form
var value=this.options.form.getWidgetByName("type").getValue()
if (value=="date")//选项值
{
form.invisible(["nf","yue","nianf","yf"]);//[]里面为控件名;设置隐藏控件项
form.visible(["stdate","enddate"]); //显示控件
}
else if(value=="month")
{
form.visible(["nf","yue","","yf","nianf"]);
form.invisible(["stdate","enddate"]);
}
else if (value=="year")
{
form.visible(["nf","nianf"]);
form.invisible(["stdate","enddate","yue","yf"]);
}
例2:${if()}数据集写法
联动
新建数据集ds1:SELECT DISTINCT 地区 FROM 销量
新建数据集ds2:SELECT * FROM 销量 where 1=1 ${if(len(diqu)=0,""," and 地区='"+diqu+"'")}
------------------------------------------------------------------------------------------------------------------------------------
SELECT * FROM [销量] where 地区 ='${地区}' and 1=1 ${if(len(product)==0,"","and 产品类型='"+product+"'")}
——————————————————————————————————
select * from kehu where 1=1
${if(type=="日报","and jdrq='"+date+"'",
if(type=="月报","and month(jdrq)='"+month+"'"+"and year(jdrq)='"+year+"'","and year(jdrq)='"+year+"'"))}