0
|
18328816101Lv5中级互助发布于2019-12-31 16:41
|
${if(type="客户"&&len(code)>0,"and iea_project_id = '" + code + "'","")}
${if(type="客户"&&len(name)>0,"and iea_text_number = '" + name + "'","")}
${if(type="客户"&&len(clients)>0,"and iea_clients_name = '" + clients + "'","")}
${if(type="客户"&&len(start)>0,"and left(iea_start_operating_time,10) = '" + start + "'","")} 结合两位的方法稍作修改就行了
|
|
|
1
|
qhlLv6中级互助发布于2019-12-31 13:35(编辑于 2019-12-31 17:57)
|
只需要在最外层加上${},里面不用再加${},直接if判断拼接就好了; 如:${if(len(参数1)==0,"",if(len(参数2),"","拼接的SQL'"+参数1或者参数2+"'"))} ${if(and(type=="客户",len(code)>0),"and iea_project_id = '" + code + "'","")}
${if(and(type=="客户",len(name)>0),"and iea_text_number = '" + name + "'","")}
${if(and(type=="客户",len(clients)>0),"and iea_clients_name = '" + clients + "'","")}
${if(and(type=="客户",len(start)>0),"and left(iea_start_operating_time,10) = '" + start + "'","")}
${if(and(type=="运营",len(org)>0),"and iea_iea_organization = '" + org + "'","")}
${if(and(type=="运营",len(first)>0),"and iea_firstlevel_department = '" + first + "'","")}
${if(and(type=="运营",len(second)>0),"and iea_secondlevel_department = '" + second + "'","","")}
|
-
18328816101(提问者)
- 我把里面的${}都去掉了,结果参数没了,筛选条件可单选可多选,所以每个type的if()里面的每个参数都要用为空定义,怎么拼接
-
qhl 回复 18328816101(提问者)
- FR里面不能直接拼接多个并列的if,要这么拼接if(条件,成立,if(条件,成立,if(条件,成立,if(条件,成立,不成立)))),而不能写成类似你的那种if(条件,成立,if(条件,成立,不成立)if(条件,成立,不成立))
-
18328816101(提问者) 回复 qhl
- 那我说的这种效果你会怎么做,首先是类型为空,这个好说,但是每个类型的筛选条件都可能为空,这个怎么解决
-
qhl 回复 18328816101(提问者)
- 其实你这个不用这么拼接啊,每个参数都是独立的啊,就只是跟type有关而已,type值为空就是不拼接查全部,而type就只有两个值,可以按照更新的回答的方式来写
-
18328816101(提问者) 回复 qhl
- 虽然不知道为什么and放前面,但是sql没用,不管怎么选都是全部数据
|
|
1
|
xiaguangmangLv5见习互助发布于2019-12-31 14:27
|
试试这种: ${if(len(type) == 0,"",if(type=="客户" && len(code) != 0,"and iea_project_id = '" + code + "'", if(type=="客户" && len(name) != 0,"and iea_text_number = '" + name + "'", if(type=="客户" && len(clients) != 0,"and iea_clients_name = '" + clients + "'", if(type=="客户" && len(start) != 0,"and left(iea_start_operating_time,10) = '" + start + "'", if(type=="运营" && len(org) != 0,"and iea_iea_organization = '" + org + "'", if(type=="运营" && len(first) != 0,"and iea_firstlevel_department = '" + first + "'", if(type=="运营" && len(second) != 0,"and iea_secondlevel_department = '" + second + "'",""))))))))}
|
|
|