EditRole.jsp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <%@ page contentType="text/html;charset=GBK"%>
  2. <jsp:useBean id="role" class="com.yw.eu.base.role.model.Role" scope="request" />
  3. <%
  4. String id = request.getParameter("id");
  5. if (id == null)
  6. id = "";
  7. %>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  9. <head>
  10. <Title>修改角色</Title>
  11. <link href="${pageContext.request.contextPath }/main.css" rel="stylesheet" type="text/css" />
  12. <link href="${pageContext.request.contextPath }/liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css" rel="stylesheet" type="text/css" />
  13. <script type="text/javascript" src="/shares/js/jquery-1.3.2.min.js"></script>
  14. <script type="text/javascript" src="/shares/js/constant.js"></script>
  15. <script type="text/javascript" src="/shares/js/common.js"></script>
  16. <SCRIPT LANGUAGE="JavaScript">
  17. $(document).ready(function(){
  18. var msgEvent = $("#msg_event").val();
  19. if(msgEvent == "1"){
  20. window.parent.loadTree();
  21. }
  22. $("input[type='text']:first").focus();
  23. var selectedgroup = "<%=(role.getGroupid())%>";
  24. if(selectedgroup != null && selectedgroup != ""){
  25. document.getElementById("groupid").value = selectedgroup;
  26. }
  27. if(document.getElementById("groupid").value==""){
  28. document.getElementById("groupid").selectedIndex=0;
  29. }
  30. var isDefaultRoles = "<%=(role.getIsDefaultRoles())%>";
  31. if(isDefaultRoles == "" || isDefaultRoles == "null"){
  32. isDefaultRoles = "0";
  33. }
  34. document.all['isDefaultRoles'].value = isDefaultRoles;
  35. if(document.all['isDefaultRoles'].value=='1'){
  36. document.all['isDefaultRoles'][0].checked=true;
  37. }if(document.all['isDefaultRoles'].value=='0'){
  38. document.all['isDefaultRoles'][1].checked=true;
  39. }
  40. });
  41. function checkForm(){
  42. var rs = $.validate({
  43. name : "roleName",
  44. model : [ {
  45. type : "require",
  46. msg : "不能为空!"
  47. },{type: "len",
  48. max : 25,
  49. msg:"不能超过25个字符"}]
  50. });
  51. rs = $.validate({
  52. name : "groupid",
  53. model : [ {
  54. type : "require",
  55. msg : "不能为空!"
  56. } ]
  57. }) && rs;
  58. rs = $.validate({
  59. name : "pos",
  60. model : [ {
  61. type : "isNumber",
  62. msg : "必须为数字!"
  63. },{type: "len",
  64. max : 4,
  65. msg:"不能超过4个字符"} ]
  66. }) && rs;
  67. rs = $.validate({
  68. name : "description",
  69. model : [{type: "len",
  70. max : 100,
  71. msg:"不能超过100个字符"} ]
  72. }) && rs;
  73. if(rs){
  74. return true;
  75. }else{
  76. return false;
  77. }
  78. }
  79. function preSubmit() {
  80. if(checkForm()){
  81. if (theForm.roleName.value=="") {window.alert("请输入角色名称!");return("");}
  82. var gs = "";
  83. $("#select2 option").each(function(){
  84. gs +="," + $(this).val();
  85. });
  86. if(gs!="")gs=gs.substring(1);
  87. $("#role_Users").val(gs);
  88. if (theForm.groupid.value=="") {window.alert("请选择部门!");return("");}
  89. if (theForm.groupid.value!=="") {
  90. if(!checkgroup_unit()){
  91. window.alert("该部门不具备创建角色的权限!");
  92. return;
  93. }
  94. }
  95. if(document.all['isDefaultRoles'][0].checked){
  96. document.all['isDefaultRoles'].value=document.all['isDefaultRoles'][0].value;
  97. }else if(document.all['isDefaultRoles'][1].checked){
  98. document.all['isDefaultRoles'].value=document.all['isDefaultRoles'][1].value;
  99. }
  100. $("#theForm").submit();
  101. theForm.submit();
  102. }
  103. }
  104. function copyForm(){
  105. theForm.roleName.value="";
  106. theForm.description.value="";
  107. theForm.action="SubmitGroup.do?action=0";
  108. }
  109. function checkgroup_unit(){
  110. var flag = false;
  111. $.ajax({
  112. //请求的类型,有GET或者POST
  113. type:"POST",
  114. //请求的url
  115. url:"<%=request.getContextPath()%>/checkMessage.do?date="
  116. + new Date() + "&action=checkgroup_unit",
  117. //向服务发送数据
  118. data : "groupid=" + $("#groupid").val(),
  119. //服务器响应客户端的输出类型,text,html,xml,json
  120. async : false, //同步
  121. dataType : "json",
  122. error : function(data) {
  123. flag = false;
  124. ;
  125. },
  126. //服务器成功响应客户端时的回调方法
  127. success : function(data) {
  128. unit = data.unit;
  129. if (unit == 'no') {
  130. flag = false;
  131. } else {
  132. flag = true;
  133. }
  134. }
  135. });
  136. return flag;
  137. }
  138. </SCRIPT>
  139. </head>
  140. <Body>
  141. <%@ include file="/include/button.jsp"%>
  142. <%@ include file="/include/message.jsp"%>
  143. <form method="post" name='theForm' action="SubmitRole.do?id=<%=id%>">
  144. <div class="forum-container">
  145. <center>
  146. <Table class="l-table-edit line">
  147. <tr>
  148. <th colspan="2">添加角色</th>
  149. </tr>
  150. <tr>
  151. <td class="l-table-edit-text" width="20%">角色名称<FONT COLOR="red">*</FONT>:
  152. </td>
  153. <td class="l-table-edit-td" width="80%"><input name='roleName' style="width: 130px;" type='text' value='<%=(role.getRoleName())%>'></td>
  154. </tr>
  155. <tr>
  156. <td class="l-table-edit-text">所属部门<FONT COLOR="red">*</FONT>:
  157. </td>
  158. <td class="l-table-edit-td"><select name="groupid" id="groupid" class="formselect">
  159. <%=request.getAttribute("groups")%>
  160. </select></td>
  161. </tr>
  162. <tr>
  163. <td class="l-table-edit-text">默认角色<FONT COLOR="red">*</FONT>:
  164. </td>
  165. <td class="l-table-edit-td"><input type="radio" name="isDefaultRoles" value="1" />是&nbsp; <input type="radio" name="isDefaultRoles" value="0" />否&nbsp;</td>
  166. </tr>
  167. <tr>
  168. <td class="l-table-edit-text">位 置:</td>
  169. <td class="l-table-edit-td"><input type="text" style="width: 130px;" name="pos" value='<%=role.getPos()%>'></td>
  170. </tr>
  171. <tr>
  172. <td class="l-table-edit-text">描 述:</td>
  173. <td class="l-table-edit-td"><textarea rows="5" cols="40" name="description"><%=role.getDescription()%></textarea></td>
  174. </tr>
  175. </Table>
  176. </center>
  177. </div>
  178. </FORM>
  179. </div>
  180. </BODY>
  181. </HTML>