225 lines
8.2 KiB
Plaintext
225 lines
8.2 KiB
Plaintext
<%@page import="com.amarsoft.app.als.sys.tools.Tools"%>
|
||
<%@page import="java.util.regex.*"%>
|
||
<%@ page contentType="text/html; charset=GBK"%><%@ include file="/IncludeBegin.jsp"%><%
|
||
/*
|
||
Content: 选择树型对话框页面
|
||
Input Param:
|
||
SelName:查询名称
|
||
ParaString:参数字符串
|
||
*/
|
||
//获取参数:查询名称和参数
|
||
String sSelName = CurPage.getParameter("SelName");
|
||
String sParaString = CurPage.getParameter("ParaString");
|
||
sParaString = (sParaString == null)?"":java.net.URLDecoder.decode(sParaString, "UTF-8");
|
||
//将空值转化为空字符串
|
||
if(sSelName == null) sSelName = "";
|
||
if(sParaString == null) sParaString = "";
|
||
//汽车业务:1,一般租赁业务:3,其他,2
|
||
String sProductType = "";
|
||
if(sParaString.contains("ProductType")){
|
||
String[] arry = sParaString.split(",");
|
||
Pattern p = Pattern.compile("ProductType,[A-Za-z0-9@]+");
|
||
Matcher m = p.matcher(sParaString);
|
||
while(m.find()){
|
||
sProductType = m.group().split(",")[1];
|
||
}
|
||
}
|
||
String sTypeNo = "";
|
||
if(sParaString.contains("TypeNo")){
|
||
String[] arry = sParaString.split(",");
|
||
Pattern p = Pattern.compile("TypeNo,[A-Za-z0-9@]+");
|
||
Matcher m = p.matcher(sParaString);
|
||
while(m.find()){
|
||
sTypeNo = m.group().split(",")[1];
|
||
}
|
||
}
|
||
String checkValue = "";
|
||
if(sParaString.indexOf("checkValue") != -1){
|
||
checkValue = sParaString.split("checkValue")[1].split(",")[0].substring(1);
|
||
sParaString = sParaString.replaceAll("checkValue="+checkValue, "");
|
||
sParaString = sParaString.replaceAll("&&", "&");
|
||
}
|
||
|
||
//定义变量:查询类型、展现方式、参数、隐藏域
|
||
String sSelType = "",sSelBrowseMode = "",sSelArgs = "",sSelHideField = "";
|
||
//定义变量:代码、字段显示中文名称、表名、主键
|
||
String sSelCode = "",sSelFieldName = "",sSelTableName = "",sSelPrimaryKey = "";
|
||
//定义变量:字段显示风格、返回值、过滤字段、选择方式
|
||
String sSelFieldDisp = "",sSelReturnValue = "",sSelFilterField = "";
|
||
boolean isMutil = false;
|
||
//定义变量:属性1、属性2、属性3、属性4、属性5
|
||
String sAttribute1 = "",sAttribute2 = "",sAttribute3 = "",sAttribute4 = "",sAttribute5 = "";
|
||
|
||
String sSql = " select SelType,SelTableName,SelPrimaryKey,SelBrowseMode,SelArgs,SelHideField,SelCode, "+
|
||
" SelFieldName,SelFieldDisp,SelReturnValue,SelFilterField,MutilOrSingle,Attribute1, "+
|
||
" Attribute2,Attribute3,Attribute4,Attribute5 "+
|
||
" from O where SelName =:SelName and IsInUse = '1' ";
|
||
BizObject bo = JBOFactory.createBizObjectQuery("jbo.sys.SELECT_CATALOG", sSql).setParameter("SelName", sSelName).getSingleResult(false);
|
||
if(bo != null){
|
||
sSelType = bo.getAttribute("SelType").getString(); // × 预留参数,现只有Sql
|
||
sSelTableName = bo.getAttribute("SelTableName").getString(); // × 预留
|
||
sSelPrimaryKey = bo.getAttribute("SelPrimaryKey").getString(); // × 预留
|
||
sSelBrowseMode = bo.getAttribute("SelBrowseMode").getString(); // × 固定TreeView
|
||
sSelArgs = bo.getAttribute("SelArgs").getString(); // × 页面参数ParaString
|
||
sSelHideField = bo.getAttribute("SelHideField").getString(); // sColId
|
||
sSelCode = bo.getAttribute("SelCode").getString(); // sFrom
|
||
//筛选业务类型
|
||
if(!sProductType.contains("@") && "1".equals(sProductType)){
|
||
sSelCode = sSelCode + "and sortno LIKE '0005%' ";
|
||
if(sTypeNo.length() != 0){
|
||
sSelCode += " and typeno <>'"+sTypeNo+"' ";
|
||
}
|
||
}else if(!sProductType.contains("@") && "3".equals(sProductType)){
|
||
sSelCode = sSelCode + "and sortno LIKE '0006%' ";
|
||
if(sTypeNo.length() != 0){
|
||
sSelCode += " and typeno <>'"+sTypeNo+"' ";
|
||
}
|
||
}else if(sProductType.contains("@") && sProductType.contains("1") && sProductType.contains("3")){
|
||
sSelCode = sSelCode + "and sortno not LIKE '0003%' and sortno not LIKE '0004%' ";
|
||
if(sTypeNo.length() != 0){
|
||
sSelCode += " and typeno <>'"+sTypeNo+"' ";
|
||
}
|
||
}
|
||
sSelFieldName = bo.getAttribute("SelFieldName").getString(); // sColValue
|
||
sSelFieldDisp = bo.getAttribute("SelFieldDisp").getString(); // sColName
|
||
sSelReturnValue = bo.getAttribute("SelReturnValue").getString(); // × node.value@node.name
|
||
sSelFilterField = bo.getAttribute("SelFilterField").getString(); // sOrderBy
|
||
isMutil = "Multi".equals(bo.getAttribute("MutilOrSingle").getString()); // MultiSelect
|
||
sAttribute1 = bo.getAttribute("Attribute1").getString(); // ExpandNodeId
|
||
sAttribute2 = bo.getAttribute("Attribute2").getString(); // 表示是否能选文件夹节点,2表示不能
|
||
sAttribute3 = bo.getAttribute("Attribute3").getString(); // × 预留
|
||
sAttribute4 = bo.getAttribute("Attribute4").getString(); // × 预留
|
||
sAttribute5 = bo.getAttribute("Attribute5").getString(); // × 预留
|
||
}
|
||
|
||
//将空值转化为空字符串
|
||
if(sSelType == null) sSelType = "";
|
||
if(sSelTableName == null) sSelTableName = "";
|
||
if(sSelPrimaryKey == null) sSelPrimaryKey = "";
|
||
if(sSelBrowseMode == null) sSelBrowseMode = "";
|
||
if(sSelArgs == null) sSelArgs = "";
|
||
else sSelArgs = sSelArgs.trim();
|
||
if(sSelHideField == null) sSelHideField = "";
|
||
else sSelHideField = sSelHideField.trim();
|
||
if(sSelCode == null) sSelCode = "";
|
||
else sSelCode = sSelCode.trim();
|
||
if(sSelFieldName == null) sSelFieldName = "";
|
||
else sSelFieldName = sSelFieldName.trim();
|
||
if(sSelFieldDisp == null) sSelFieldDisp = "";
|
||
else sSelFieldDisp = sSelFieldDisp.trim();
|
||
if(sSelReturnValue == null) sSelReturnValue = "";
|
||
else sSelReturnValue = sSelReturnValue.trim();
|
||
if(sSelFilterField == null) sSelFilterField = "";
|
||
else sSelFilterField = sSelFilterField.trim();
|
||
if(sAttribute1 == null) sAttribute1 = "";
|
||
if(sAttribute2 == null) sAttribute2 = "";
|
||
if(sAttribute3 == null) sAttribute3 = "";
|
||
if(sAttribute4 == null) sAttribute4 = "";
|
||
if(sAttribute5 == null) sAttribute5 = "";
|
||
|
||
//获取返回值
|
||
StringTokenizer st = new StringTokenizer(sSelReturnValue,"@");
|
||
String [] sReturnValue = new String[st.countTokens()];
|
||
int l = 0;
|
||
while (st.hasMoreTokens()) {
|
||
sReturnValue[l] = st.nextToken();
|
||
l ++;
|
||
}
|
||
//设置显示标题
|
||
String sHeaders = sSelFieldName;
|
||
|
||
//将Sql中的变量用相对应的值替换
|
||
StringTokenizer stArgs = new StringTokenizer(sParaString,",");
|
||
while (stArgs.hasMoreTokens()) {
|
||
try{
|
||
String sArgName = stArgs.nextToken().trim();
|
||
String sArgValue = stArgs.nextToken().trim();
|
||
sSelCode = StringFunction.replace(sSelCode,"#"+sArgName,sArgValue );
|
||
}catch(NoSuchElementException ex){
|
||
throw new Exception("输入参数格式错误!");
|
||
}
|
||
}
|
||
%>
|
||
<html>
|
||
<head>
|
||
<title>选择信息</title>
|
||
<script type="text/javascript">
|
||
function TreeViewOnClick(){
|
||
var sType = getCurTVItem().type;
|
||
if(sType != "page" && "<%=sAttribute2%>" == '2'){
|
||
alert("页节点信息不能选择,请重新选择!");
|
||
}
|
||
}
|
||
|
||
function returnValue(){
|
||
if(<%=isMutil%>){
|
||
var nodes = getCheckedTVItems();
|
||
if(nodes.length < 1) return;
|
||
var sReturn = "";
|
||
for(var i = 0; i < nodes.length; i++){
|
||
sReturn += nodes[i].value+"@"+nodes[i].name+"~";
|
||
}
|
||
parent.sObjectInfo = sReturn;
|
||
}else{
|
||
var node = getCurTVItem();
|
||
if(!node || node.id == "root") return;
|
||
var sType = node.type;
|
||
if(sType != "page" && "<%=sAttribute2%>" == '2'){
|
||
alert("页节点信息不能选择,请重新选择!");
|
||
return;
|
||
}
|
||
parent.sObjectInfo = node.value+"@"+node.name;
|
||
}
|
||
}
|
||
|
||
//新增树图双击事件响应函数 add by hwang 20090601
|
||
function TreeViewOnDBLClick(){
|
||
parent.returnSelection();
|
||
}
|
||
|
||
function startMenu(){
|
||
<%
|
||
HTMLTreeView tviTemp = new HTMLTreeView(CurComp,sServletURL,"选择信息列表","right");
|
||
if(isMutil) tviTemp.MultiSelect = true;
|
||
else tviTemp.TriggerClickEvent=true;
|
||
//参数从左至右依次为:
|
||
//ID字段(必须),Name字段(必须),Value字段,Script字段,Picture字段,From子句(必须),OrderBy子句,Sqlca
|
||
sSelCode = Tools.getSql(sSelCode, 0);
|
||
tviTemp.initWithSql(sSelHideField,sSelFieldDisp,sSelFieldName,"","",sSelCode,sSelFilterField,Sqlca);
|
||
out.println(tviTemp.generateHTMLTreeView());
|
||
%>
|
||
expandNode('root');
|
||
<%
|
||
int j = sAttribute1.split("@").length;
|
||
String[] sExportNode = sAttribute1.split("@");
|
||
for(int i=0;i<j;i++){
|
||
%>
|
||
try{
|
||
expandNode('<%=sSelFieldName%>');
|
||
}catch(e){ }
|
||
<%
|
||
}
|
||
%>
|
||
var checkValue = '<%=checkValue%>';
|
||
if(checkValue != ''){
|
||
if(checkValue.indexOf("@") != -1){
|
||
var cValue = checkValue.split("@");
|
||
for(var c=0;c<cValue.length;c++){
|
||
setCheckTVItem(cValue[c], true);
|
||
}
|
||
}else{
|
||
setCheckTVItem(checkValue, true);
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style>
|
||
.black9pt { font-size: 9pt; color: #000000; text-decoration: none}
|
||
</style>
|
||
</head>
|
||
<body class="pagebackground"><iframe name="left" width=100% height=100% frameborder=0 ></iframe></body>
|
||
<script>
|
||
startMenu();
|
||
</script>
|
||
</html>
|
||
<%@ include file="/IncludeEnd.jsp"%> |