2018-08-04 19:42:51 +08:00

305 lines
11 KiB
Plaintext

<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/IncludeBeginMD.jsp"%><%
String sRoleID = CurPage.getParameter("RoleID");
if(sRoleID == null) sRoleID = "";
%>
<script type="text/javascript">
var availableReportCaptionList = new Array;
var availableReportNameList = new Array;
var selectedReportCaptionList = new Array;
var selectedReportNameList = new Array;
<%
int num = 0;
BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.awe.AWE_MENU_INFO");
String queryStr = " select MenuID,MenuName from O " +
" where MenuID not in (select rm.MenuID from jbo.awe.AWE_ROLE_MENU rm where rm.RoleID = :RoleID) order by MenuID ";
List<BizObject> ml = bm.createQuery(queryStr).setParameter("RoleID",sRoleID).getResultList(false);
for(BizObject bo : ml){
String menuID = bo.getAttribute("MenuID").getString();
String menuName = bo.getAttribute("MenuName").getString();
String displayName = menuID +" "+menuName;
out.println("availableReportCaptionList[" + num + "] = '" + displayName + "';\r");
out.println("availableReportNameList[" + num + "] = '" + menuID + "';\r");
num++;
}
queryStr = " select MenuID,MenuName from O " +
" where MenuID in (select rm.MenuID from jbo.awe.AWE_ROLE_MENU rm where rm.RoleID = :RoleID) order by MenuID ";
List<BizObject> ml1 = bm.createQuery(queryStr).setParameter("RoleID",sRoleID).getResultList(false);
num = 0;
for(BizObject bo : ml1){
String menuID = bo.getAttribute("MenuID").getString();
String menuName = bo.getAttribute("MenuName").getString();
String displayName = menuID +" "+menuName;
out.println("selectedReportCaptionList[" + num + "] = '" + displayName + "';\r");
out.println("selectedReportNameList[" + num + "] = '" + menuID + "';\r");
num++;
}
%>
setDialogTitle("对角色编号【<%=sRoleID%>】进行菜单授权");
</script>
<html>
<head>
<title>主菜单授权</title>
</head>
<body bgcolor="#E4E4E4">
<form name="analyseterm">
<table align="center" width="100%">
<tr>
<td>
<table width='100%' border='1' cellpadding='0' cellspacing='5' bgcolor='#DDDDDD'>
<tr>
<td colspan="4">
<span>选取要新增的主菜单</span>
</td>
</tr>
<tr>
<td bgcolor='#DDDDDD'>
<span class='dialog-label'>可新增的主菜单列表</span>
</td>
<td bordercolor='#DDDDDD'></td>
<td bgcolor='#DDDDDD'>
<span class='dialog-label'>已配置的主菜单列表</span>
</td>
<td></td>
</tr>
<tr>
<td align='center'>
<select name='report_available' onchange='selectionChanged(document.forms["analyseterm"].elements["report_available"],document.forms["analyseterm"].elements["report_chosen"]);' size='12' style='width:100%;' multiple>
</select>
</td>
<td width='1' align='center' valign='middle' bordercolor='#DDDDDD'>
<img name='movefrom_report_available'
onmousedown='pushButton("movefrom_report_available",true);'
onmouseup='pushButton("movefrom_report_available",false);'
onmouseout='pushButton("movefrom_report_available",false);'
onclick='moveSelected(document.forms["analyseterm"].elements["report_available"],document.forms["analyseterm"].elements["report_chosen"]);updateHiddenChooserField(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report"]);'
border='0'
src='<%=CurConfig.getImagePath()%>/chooser_orange/arrowRight_disabled.gif'
alt='Add selected items' />
<br><br>
<img name='movefrom_report_chosen'
onmousedown='pushButton("movefrom_report_chosen",true);'
onmouseup='pushButton("movefrom_report_chosen",false);'
onmouseout='pushButton("movefrom_report_chosen",false);'
onclick='moveSelected(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report_available"]);updateHiddenChooserField(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report"]);'
border='0'
src='<%=CurConfig.getImagePath()%>/chooser_orange/arrowLeft_disabled.gif'
alt='Remove selected items' />
</td>
<td align='center'>
<select name='report_chosen' onchange='selectionChanged(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report_available"]);' size='12' style='width:100%;' multiple>
</select>
<input type='hidden' name='report' value=''>
</td>
<td width='1' align='center' valign='middle' bordercolor='#DDDDDD'>
<img name='shiftup_report_chosen'
onmousedown='pushButton("shiftup_report_chosen",true);'
onmouseup='pushButton("shiftup_report_chosen",false);'
onmouseout='pushButton("shiftup_report_chosen",false);'
onclick='shiftSelected(document.forms["analyseterm"].elements["report_chosen"],-1);updateHiddenChooserField(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report"]);'
border='0'
src='<%=CurConfig.getImagePath()%>/chooser_orange/arrowUp_disabled.gif'
alt='Shift selected items down' />
<br><br>
<img name='shiftdown_report_chosen'
onmousedown='pushButton("shiftdown_report_chosen",true);'
onmouseup='pushButton("shiftdown_report_chosen",false);'
onmouseout='pushButton("shiftdown_report_chosen",false);'
onclick='shiftSelected(document.forms["analyseterm"].elements["report_chosen"],1);updateHiddenChooserField(document.forms["analyseterm"].elements["report_chosen"],document.forms["analyseterm"].elements["report"]);'
border='0'
src='<%=CurConfig.getImagePath()%>/chooser_orange/arrowDown_disabled.gif'
alt='Shift selected items up' />
</td>
</tr>
</table>
</td>
</tr>
<tr height=1>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=4>
<table style="width: 100%;">
<tr>
<td width="30%" align="right">
<%=new Button("&nbsp;恢&nbsp;复&nbsp;","恢复","doDefault()","","").getHtmlText()%>
</td>
<td width="40%" align="center">
<%=new Button("&nbsp;确&nbsp;定&nbsp;","确定","doQuery()","","").getHtmlText()%>
</td>
<td width="30%" align="left">
<%=new Button("&nbsp;返&nbsp;回&nbsp;","返回","parent.AsDialog.ClosePage();","","").getHtmlText()%>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<script type="text/javascript">
function cloneOption(option){
var out = new Option(option.text,option.value);
out.selected = option.selected;
out.defaultSelected = option.defaultSelected;
return out;
}
function shiftSelected(chosen,howFar){
var opts = chosen.options;
var newopts = new Array(opts.length);
var start, end, incr;
if(howFar > 0){
start = 0;
end = newopts.length;
incr = 1;
}else{
start = newopts.length - 1;
end = -1;
incr = -1;
}
for(var sel = start; sel != end; sel += incr){
if (opts[sel].selected) {
setAtFirstAvailable(newopts, cloneOption(opts[sel]), sel + howFar, -incr);
}
}
for(var uns = start; uns != end; uns += incr){
if (!opts[uns].selected) {
setAtFirstAvailable(newopts, cloneOption(opts[uns]), start, incr);
}
}
opts.length = 0;
for(var i=0; i<newopts.length; i++){
opts[opts.length] = newopts[i];
}
}
function setAtFirstAvailable(array,obj,startIndex,incr){
if (startIndex < 0) startIndex = 0;
if (startIndex >= array.length) startIndex = array.length -1;
for(var xxx=startIndex; xxx>= 0 && xxx<array.length; xxx += incr){
if (array[xxx] == null) {
array[xxx] = obj;
return;
}
}
}
function moveSelected(from,to) {
newTo = new Array();
for(var i=0; i<to.options.length; i++){
newTo[newTo.length] = cloneOption(to.options[i]);
newTo[newTo.length-1].selected = false;
}
for(i=0; i<from.options.length; i++){
if (from.options[i].selected) {
newTo[newTo.length] = cloneOption(from.options[i]);
from.options[i] = null;
i--;
}
}
to.options.length = 0;
for(i=0; i<newTo.length; i++){
to.options[to.options.length] = newTo[i];
}
selectionChanged(to,from);
}
function updateHiddenChooserField(chosen,hidden){
hidden.value='';
var opts = chosen.options;
for(var i=0; i<opts.length; i++){
hidden.value = hidden.value + opts[i].value+'\n';
}
}
function selectionChanged(selectedElement,unselectedElement){
for(var i=0; i<unselectedElement.options.length; i++){
unselectedElement.options[i].selected=false;
}
form = selectedElement.form;
enableButton("movefrom_"+selectedElement.name,(selectedElement.selectedIndex != -1));
enableButton("movefrom_"+unselectedElement.name,(unselectedElement.selectedIndex != -1));
enableButton("shiftdown_"+selectedElement.name,(selectedElement.selectedIndex != -1));
enableButton("shiftup_"+selectedElement.name,(selectedElement.selectedIndex != -1));
enableButton("shiftdown_"+unselectedElement.name,(unselectedElement.selectedIndex != -1));
enableButton("shiftup_"+unselectedElement.name,(unselectedElement.selectedIndex != -1));
}
function enableButton(buttonName,enable){
var img = document.images[buttonName];
if (img == null) return;
var src = img.src;
var und = src.lastIndexOf("_disabled.gif");
if (und != -1) {
if(enable) img.src = src.substring(0,und)+".gif";
}else{
if(!enable){
var gif = src.lastIndexOf("_clicked.gif");
if (gif == -1) gif = src.lastIndexOf(".gif");
img.src = src.substring(0,gif)+"_disabled.gif";
}
}
}
function pushButton(buttonName,push){
var img = document.images[buttonName];
if (img == null) return;
var src = img.src;
var und = src.lastIndexOf("_disabled.gif");
if (und != -1) return false;
und = src.lastIndexOf("_clicked.gif");
if (und == -1) {
var gif = src.lastIndexOf(".gif");
if (push) img.src = src.substring(0,gif)+"_clicked.gif";
}else{
if (!push) img.src = src.substring(0,und)+".gif";
}
}
function doQuery(){
if($("select[name='report_chosen']")[0].length == 0){
alert("请选择要新增的主菜单!");
return;
}
var vReturn = "";
var vReportCount = $("select[name='report_chosen']")[0].length;
for(var i=0; i<vReportCount;i++){
var vTemp = $("select[name='report_chosen']")[0].options[i].value;
vReturn = vReturn+vTemp+"@";
}
var sReturn = RunJavaMethodTrans("com.amarsoft.app.awe.config.role.action.ManageRoleMenuRela","addRoleMenus","RoleID=<%=sRoleID%>,RelaValues="+vReturn);
if(sReturn == "SUCCEEDED"){
alert("菜单授权成功!");
}else{
alert("菜单授权失败!");
}
parent.AsDialog.ClosePage();
}
function doDefault(){
$("select[name='report_available']")[0].options.length = 0;
$("select[name='report_chosen']")[0].length = 0;
var j = 0;
for(var i = 0; i < availableReportNameList.length; i++){
$("select[name='report_available']")[0].options[j] = new Option(availableReportCaptionList[i], availableReportNameList[i]);
j++;
}
j = 0;
for(var i = 0; i < selectedReportNameList.length; i++){
$("select[name='report_chosen']")[0].options[i] = new Option(selectedReportCaptionList[j], selectedReportNameList[j]);
j++;
}
}
doDefault();
</script>
<%@ include file="/IncludeEnd.jsp"%>