2018-06-03 22:26:41 +08:00

189 lines
5.2 KiB
Plaintext

<%@page import="com.amarsoft.are.lang.Element"%>
<%@page import="com.amarsoft.are.util.json.*"%>
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ include file="/Frame/resources/include/include_begin.jspf" %>
<html>
<%
String sWizardId = CurPage.getParameter("WizardId");
if(sWizardId == null) throw new IllegalArgumentException("Ïòµ¼±àºÅWizardId²ÎÊýΪ¿Õ");
String sObjectNo = CurPage.getParameter("ObjectNo");
JSONObject wizard = null;
String sWizard = Sqlca.getString(new SqlObject("select WizardInfo from "+SqlObject.getTable("jbo.awe.AWE_WIZARD_RUNNER")+" where WizardId = :WizardId and ObjectNo = :ObjectNo ").setParameter("WizardId", sWizardId).setParameter("ObjectNo", sObjectNo));
//System.out.println(sWizard);
if(sWizard != null) wizard = JSONDecoder.decode(sWizard);
if(wizard == null){
wizard = JSONObject.createObject();
Element e;
e = new JSONElement("WizardId");
e.setValue(sWizardId);
wizard.add(e);
e = new JSONElement("ObjectNo");
e.setValue(sObjectNo);
wizard.add(e);
String sWizardName = Sqlca.getString(new SqlObject("select WizardName from "+SqlObject.getTable("jbo.awe.AWE_WIZARD_CATALOG")+" where WizardId = :WizardId").setParameter("WizardId", sWizardId));
e = new JSONElement("Name");
e.setValue(sWizardName);
wizard.add(e);
e = new JSONElement("CurIndex");
e.setValue(0);
wizard.add(e);
ASResultSet rs = null;
try{
rs = Sqlca.getASResultSet(new SqlObject("select ItemNo, ItemName, Url, Params from "+SqlObject.getTable("jbo.awe.AWE_WIZARD_LIBRARY")+" where WizardId = :WizardId order by SortNo").setParameter("WizardId", sWizardId));
JSONObject items = JSONObject.createArray();
e = new JSONElement("Items");
e.setValue(items);
wizard.add(e);
while(rs.next()){
String sParams = rs.getString("Params");
if(sParams == null) sParams = "";
JSONObject item = JSONObject.createObject();
e = new JSONElement();
e.setValue(item);
items.add(e);
e = new JSONElement("ItemNo");
e.setValue(rs.getString("ItemNo"));
item.add(e);
e = new JSONElement("ItemName");
e.setValue(rs.getString("ItemName"));
item.add(e);
e = new JSONElement("Url");
e.setValue(rs.getString("Url"));
item.add(e);
e = new JSONElement("Params");
e.setValue(sParams);
item.add(e);
e = new JSONElement("RunParams");
if(sObjectNo != null) sParams = sParams.replace("#{ObjectNo}", sObjectNo);
e.setValue(sParams);
item.add(e);
}
}finally{
if(rs != null) rs.close();
rs = null;
}
}
%>
<head>
<title><%=wizard.getValue("Name")%></title>
<script type="text/javascript" src="<%=sWebRootPath%>/Frame/resources/js/chart/json2.js"></script>
</head>
<body style="height:100%;overflow:hidden;">
<iframe name="wizard" style="height:100%;width:100%;" frameborder="0" ></iframe>
</body>
<script type="text/javascript">
function Wizard(data){
//alert(JSON.stringify(data));
/**
* »ñÈ¡¶ÔÏó±àºÅ
*/
this.getObjectNo = function(){
return data["ObjectNo"];
};
/**
* ÉèÖöÔÏó±àºÅ
* @throws e ¶ÔÏó±àºÅÒÑ´æÔÚ£¬ÇÒÓëÉèÖõıàºÅ²»Í¬
*/
this.setObjectNo = function(sObjectNo){
if(data["ObjectNo"] && data["ObjectNo"] != sObjectNo){
throw {"message":"¶ÔÏó±àºÅÒѰó¶¨"};
}
data["ObjectNo"] = sObjectNo;
};
/**
* »ñÈ¡Ïòµ¼²½Öè
*/
this.getItems = function(){
return data["Items"];
};
this.getCurIndex = function(){
return data["CurIndex"];
};
/**
* Ìø×ªµ½ÏÂÒ»²½
*/
this.toNextStep = function(){
this.toStep(data["CurIndex"]+1);
};
/**
* »ØÍ˵½ÉÏÒ»²½
*/
this.toPrevStep = function(){
this.toStep(data["CurIndex"]-1);
};
/**
* Ìø×ªµ½Ö¸¶¨²½Öè
* @throws e Ö¸¶¨²½Öè²»ÔÚÏòµ¼²½Ö跶ΧÄÚ
*/
this.toStep = function(index){
if(index < 0 || index > data["Items"].length - 1){
throw {"message":"³¬³öÊý×éÒì³£"};
}
if(data["CurIndex"] != index && data["ObjectNo"]){
var curIndex = data["CurIndex"];
data["CurIndex"] = index;
var result = AsControl.RunJavaMethodTrans("com.amarsoft.awe.ui.wizard.WizardAction", "recode", "{\"WizardInfo\":"+JSON.stringify(data)+"}");
if(!result){
data["CurIndex"] = curIndex;
return;
}
if(typeof result == "string"){
alert(result);
data["CurIndex"] = curIndex;
return;
}
data = result;
}
AsControl.OpenView(data["Items"][data["CurIndex"]]["Url"], data["Items"][data["CurIndex"]]["RunParams"], "wizard");
if(typeof window.setDialogTitle == "function"){
var sText = "";
for(var i = 0; i < data["Items"].length; i++){
if(i != 0){
sText += "<span style='padding:0 5px;";
if(i != data["CurIndex"]) sText += "color:#999;";
sText += "'>¡ú</span>";
}
sText += "<span style='white-space:nowrap;";
if(i != data["CurIndex"]) sText += "color:#999;";
sText += "'>";
sText += data["Items"][i]["ItemName"];
sText += "</span>";
}
parent.AsDialog.SetDialogTitle(sText);
}
};
/**
* ÖØÔØµ±Ç°²½Öè
*/
this.reload = function(){
this.toStep(data["CurIndex"]);
if(typeof window.setWindowTitle == "function")
setWindowTitle(data["Name"]);
};
this.reload();
}
var wizard = new Wizard(<%=JSONEncoder.encode(wizard)%>);
</script>
</html>
<%@ include file="/Frame/resources/include/include_end.jspf" %>