129 lines
4.8 KiB
Plaintext
129 lines
4.8 KiB
Plaintext
<%@page import="com.amarsoft.are.util.json.JSONEncoder"%>
|
|
<%@page import="com.amarsoft.awe.dw.ui.control.Support"%>
|
|
<%@page import="com.amarsoft.asquery.*"%>
|
|
<%@ page contentType="text/html; charset=GBK"%>
|
|
<%@ include file="/Frame/resources/include/include_begin.jspf"%>
|
|
<script type="text/javascript" src="<%=sWebRootPath%>/Frame/page/js/widget/htmltree.js"></script>
|
|
<%
|
|
String sColName = CurPage.getParameter("ColName");
|
|
String selected = CurPage.getParameter("selected");
|
|
if(selected == null) selected = "@@";
|
|
else selected = "@"+selected+"@";
|
|
String sSelectCol="";
|
|
|
|
ASQuery xquery = (ASQuery)session.getAttribute("AdvanceXQuery");
|
|
String as1 = xquery.getCodeItemDefinition(sColName);
|
|
String as2[][] = {
|
|
{ "ColumnName", sColName, "" },
|
|
{ "RelatedDataObjectName", "", "" },
|
|
{ "EnvironmentUserID", CurUser.getUserID(), "" } ,
|
|
{ "EnvironmentOrgID", CurUser.getOrgID(), "" } ,
|
|
{ "QueryClass", xquery.queryClass, "" },
|
|
{ "EnvironmentSortNo", CurOrg.getSortNo(), "" },
|
|
{ "EnvironmentCorpID", CurOrg.getCorpOrgID(), "" }
|
|
};
|
|
String s = xquery.getStringWithParameterReplaced(as1, as2);
|
|
|
|
String[] sCodeTableArray = StringX.parseArray(s);
|
|
String codeTableType = sCodeTableArray[0];
|
|
String codeTableSource = sCodeTableArray[1];
|
|
boolean leafOnly = false;
|
|
if(sCodeTableArray.length > 2){
|
|
leafOnly = "LeafOnly".equals(sCodeTableArray[2]);
|
|
}
|
|
|
|
String sColDisplayName = xquery.getColDisplayLabel(sColName);
|
|
ObjectTree tree = new ObjectTree(sColDisplayName);
|
|
TreeStory root = new TreeStory("", sColDisplayName, "");
|
|
root.setExpand(true);
|
|
tree.getStorys().add(root);
|
|
|
|
if("code".equalsIgnoreCase(codeTableType)){
|
|
root.getStorys().addAll(ObjectTreeManager.genTreeNodes(codeTableSource, null));
|
|
}else if("datasource".equalsIgnoreCase(codeTableType)){
|
|
int managerIndex = codeTableSource.indexOf(",");
|
|
if(managerIndex < 0) throw new Exception("JBO代码来源定义错误");
|
|
int idIndex = codeTableSource.indexOf(",", managerIndex+1);
|
|
if(idIndex < 0) throw new Exception("JBO代码来源定义错误");
|
|
int textIndex = codeTableSource.indexOf(",", idIndex+1);
|
|
if(textIndex < 0) throw new Exception("JBO代码来源定义错误");
|
|
|
|
String sIDField = codeTableSource.substring(managerIndex+1, idIndex);
|
|
String sTextField = codeTableSource.substring(idIndex+1, textIndex);
|
|
String sSortField = sIDField;
|
|
String sWhere = codeTableSource.substring(textIndex+1);
|
|
if(!StringX.isSpace(sWhere)){
|
|
sWhere = "where " + sWhere;
|
|
int iOrder = sWhere.toUpperCase().lastIndexOf("ORDER BY");
|
|
if(iOrder > -1 && sWhere.substring(iOrder+9).trim().indexOf(" ") < 0){
|
|
sSortField = sWhere.substring(iOrder+9);
|
|
}
|
|
}
|
|
|
|
BizObjectManager m = JBOFactory.getFactory().getManager(codeTableSource.substring(0, managerIndex));
|
|
BizObjectQuery q = m.createQuery("select "+sIDField+" as V.ID, "+sTextField+" as V.TEXT, "+sSortField+" as V.SORTNO from O "+sWhere);
|
|
root.getStorys().addAll(ObjectTreeManager.genTreeNodes(q.getResultList(false), null, "Text", null, "SortNo"
|
|
, null, null
|
|
, "SortNo", new String[]{as2[5][1]}
|
|
, "ID", new String[0]
|
|
));
|
|
}else{ // codetable @MIN_MAX
|
|
String[] sCodeArray = Support.getCodes(codeTableSource, codeTableType);
|
|
for(int i = 0; i + 1 < sCodeArray.length; i+=2){
|
|
TreeStory story = new TreeStory("", sCodeArray[i+1], "");
|
|
story.getAttributes().put("ID", sCodeArray[0]);
|
|
story.getAttributes().put("TEXT", sCodeArray[1]);
|
|
root.getStorys().add(story);
|
|
}
|
|
}
|
|
//System.out.println(JSONEncoder.encode(tree));
|
|
%>
|
|
<body style="overflow:hidden;height:100%;width:100%;">
|
|
<button id='search_tree' >查询</button>
|
|
<div id="body" style="overflow:auto;height:100%;"></div>
|
|
</body>
|
|
<script type="text/javascript">
|
|
var treeModel = <%=JSONEncoder.encode(tree)%>;
|
|
//alert(JSON.stringify(treeModel));
|
|
initCheck(treeModel, "<%=selected%>");
|
|
function initCheck(data, selected){
|
|
if(!data || !data.storys) return;
|
|
for(var i = 0; i < data.storys.length; i++){
|
|
initCheck(data.storys[i], selected);
|
|
if(selected.indexOf("@"+data.storys[i]["attributes"]["ID"]+"@")<0) continue;
|
|
data.storys[i]["check"] = 2;
|
|
}
|
|
}
|
|
var tree = new HtmlTree(document.getElementById("body"), treeModel);
|
|
tree.NodeOnDblclick = function(node){
|
|
node.toggle();
|
|
};
|
|
|
|
function doSure(){
|
|
var nodes = tree.getChecked();
|
|
if(nodes.length == 0 && !confirm("未选择节点,是否放弃选择?")){
|
|
parent.doClear();
|
|
return;
|
|
}
|
|
|
|
var text = "";
|
|
for(var i = 0; i < nodes.length; i++){
|
|
var sId = nodes[i].getAttribute("Id");
|
|
if(!sId || (<%=leafOnly%> && nodes[i].getChildren().length > 0)) continue;
|
|
if(text) text += "@@";
|
|
text += nodes[i].getAttribute("Text")+"@"+sId;
|
|
}
|
|
parent.closeDialog(text);
|
|
}
|
|
|
|
function showSearch(){
|
|
tree.showSearch(function(node){
|
|
node.click();
|
|
});
|
|
return false;
|
|
}
|
|
|
|
$("#search_tree").click(showSearch);
|
|
AsLink.setShortcut("Ctrl+F", showSearch);
|
|
</script>
|
|
<%@ include file="/Frame/resources/include/include_end.jspf"%> |