role.jsp
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:7k
源码类别:
Jsp/Servlet
开发平台:
Java
- <%@ page language="java" pageEncoding="GBK"%>
- <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
- <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
- <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
- <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
- <script>
- var xmlhttp_request = false;
- function initrequest(){
- if(window.XMLHttpRequest){//这种就是Mozilla
- xmlhttp_request = new XMLHttpRequest();
- }else if(window.ActiveXObject){//这种浏览器是IE
- try{
- xmlhttp_request = new ActiveXObject("Msxml2.XMLHttp");
- }catch(e){
- try{
- xmlhttp_request = new ActiceXObject("microsoft.XMLHttp");
- }catch(e){
- }
- }
- }
- if(!xmlhttp_request){
- alert("您的浏览器不支持Ajax");
- return false;
- }
- }
- function processRequest(){
- if(xmlhttp_request.readystate==4){
- //完成返回结果,处理
- if(xmlhttp_request.status==200){
- //正确结果返回处理
- document.getElementById("result").innerHTML = xmlhttp_request.responseText;
- }else{
- //返回结果错误时的处理
- }
- }else{
- //未完成处理中...
- }
- }
- function ajaxcheck(){
- initrequest();
- xmlhttp_request.onreadystatechange=processRequest;
- var rname = document.getElementById("rname").value;
- var url = "role.do?method=checkName&rname="+rname+"&sessid="+Math.random();
- xmlhttp_request.open("post",url,true);//发送请求到服务器
- xmlhttp_request.send(null);//可以传递文件,流,字符串
- }
- </script>
- <script>
- function checkform(){
- var rname=document.getElementById("rname");
- if(rname.value.length<=0){
- alert('角色名称不能为空!');
- rname.focus();
- return false;
- }
- <%-- 数组--%>
- var role = document.getElementsByName("frole");
- var flag = false;
- for(i=0;i<role.length;i++){
- //alert(role[i].checked);
- if(role[i].checked) {
- flag = true;
- break;
- }
- }
- if(!flag) {
- alert("请为角色分配功能!");
- return false;
- }
- }
- function selectCheck(){
- }
- //选中孩子
- function selectChild(o){
- //获得本菜单的tr
- var otr = o.parentElement.parentElement;
- //获得子菜单的tr
- var otrmenu = otr.nextSibling;
- //遍历子菜单的checkbox
- for(var i=0;i<otrmenu.all.length;i++) {
- if(otrmenu.all[i].type=="checkbox"){
- otrmenu.all[i].checked = o.checked;
- }
- }
- }
- //选中父类(适用二级)
- function selectParent(o){
- //t=true默认找到
- var t= false;
- //获得本菜单的tr
- var otr = o.parentElement.parentElement;
- //获得父菜单的tr
- var otrmenu = otr.previousSibling;
- //遍历子菜单的checkbox,验证是有选
- for(var i=0;i<otr.all.length;i++) {
- if(otr.all[i].type=="checkbox" && otr.all[i].checked){
- t = true;
- break;
- }
- }
- //设置父类的checkbox状态
- if(t){
- for(var i=0;i<otrmenu.all.length;i++) {
- if(otrmenu.all[i].type=="checkbox"){
- otrmenu.all[i].checked = "checked";
- selectRoot(otrmenu.all[i]);
- break;
- }
- }
- }else{
- for(var i=0;i<otrmenu.all.length;i++) {
- if(otrmenu.all[i].type=="checkbox"){
- otrmenu.all[i].checked = "";
- selectRoot(otrmenu.all[i]);
- break;
- }
- }
- }
- }
- //选中根点节(适用一级)
- function selectRoot(o){
- //t=true默认找到
- var t= false;
- //获得本菜单的tr
- var otr = o.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement
- //获得父菜单的tr
- var otrmenu = otr.previousSibling;
- //遍历子菜单的checkbox,验证是否全选
- for(var i=0;i<otr.all.length;i++) {
- if(otr.all[i].type=="checkbox" && otr.all[i].checked){
- t = true;
- break;
- }
- }
- //设置父类的checkbox状态
- if(t){
- for(var i=0;i<otrmenu.all.length;i++) {
- if(otrmenu.all[i].type=="checkbox"){
- otrmenu.all[i].checked = "checked";
- break;
- }
- }
- }else{
- for(var i=0;i<otrmenu.all.length;i++) {
- if(otrmenu.all[i].type=="checkbox"){
- otrmenu.all[i].checked = "";
- break;
- }
- }
- }
- }
- //菜单的显示与隐藏
- function menu(o){
- if(o.style.display=="block"){
- o.style.display="none";
- }else{
- o.style.display="block";
- }
- }
- function setDisplay(id){
- var one = document.getElementById(id+"_menu");
- if(one.style.display=="none"){
- one.style.display="block";
- }else{
- one.style.display="none";
- }
- }
- function loadValue(){
- <logic:present name="rflist" scope="request">
- <logic:iterate id="rflist" name="rflist">
- var roleid = document.getElementsByName("rolefun");
- for(var i=0;i<roleid.length;i++){
- if(roleid[i].value=="${rflist.fid}"){
- roleid[i].checked = "checked";
- }
- }
- </logic:iterate>
- </logic:present>
- }
- </script>
- <style type="text/css">
- <!--
- .STYLE1 {
- font-family: "新宋体";
- font-size: 14px;
- }
- -->
- </style>
- <body onload="loadValue();">
- <div align="center"><FONT color="red">${msg}</FONT></div>
- <html:form action="/role">
- <html:hidden property="rid"/>
- <html:hidden property="method"/>
- <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#66CCFF" class="STYLE1">
- <tr class="tableHead" style="font-size: 20px">
- <td height="46" colspan="2" align="center"><STRONG>角色信息编辑</STRONG></td>
- </tr>
- <tr>
- <td align="right">角色名称:</td>
- <td><html:text property="rname" onblur="ajaxcheck();"/>
- <font color="#FF0000">* <SPAN id="result"></SPAN></font></td>
- </tr>
- <tr>
- <td align="right">角色备注:</td>
- <td><html:textarea property="rmemo" cols="50" rows="5"/></td>
- </tr>
- <tr>
- <td align="right">角色功能:</td>
- <td>
- <table width="100%" border="0">
- <logic:iterate id="fun" name="funlist" scope="request">
- <logic:equal value="0" property="fpid" name="fun">
- <tr>
- <td>
- <input type="checkbox" id="frole" name="rolefun" onclick="selectChild(this);" value="${fun.fid}"/>
- <span onclick="setDisplay('f${fun.fid}');" style="cursor: hand">${fun.fname}</span>
- </td>
- </tr>
- <tr id="f${fun.fid}_menu">
- <td>
- <table>
- <logic:iterate id="funsun" name="funlist" scope="request">
- <logic:equal value="${fun.fid}" property="fpid" name="funsun">
- <tr >
- <td>
- <input type="checkbox" name="rolefun" onclick="selectRoot(this);" value="${funsun.fid}"/>${funsun.fname}
- </td>
- </tr>
- </logic:equal>
- </logic:iterate>
- </table>
- </td>
- </tr>
- </logic:equal>
- </logic:iterate>
- </table>
- </td>
- </tr>
- <tr align="center">
- <td colspan="2">
- <html:submit onclick="return checkform();" value="确认"/>
- <html:reset value="重置" />
- </td>
- </tr>
- </table>
- </html:form>
- </body>