浏览代码

添加角色和用户

xubh 4 年之前
父节点
当前提交
d51dfc80b6

+ 21 - 33
src/main/java/com/minpay/huicai/system/action/RoleManageAction.java

@@ -1,16 +1,6 @@
 package com.minpay.huicai.system.action;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.min.util.CommonUtil;
 import com.minpay.common.bean.User;
 import com.minpay.common.constant.Constant;
 import com.minpay.common.constant.IConstant;
@@ -18,25 +8,8 @@ import com.minpay.common.exception.BusinessCodeException;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.ILogService;
 import com.minpay.common.service.IPublicService;
-import com.minpay.db.table.mapper.ImBranchMapper;
-import com.minpay.db.table.mapper.ImItemMapper;
-import com.minpay.db.table.mapper.ImRoleAuthMapper;
-import com.minpay.db.table.mapper.ImRoleItemRelMapper;
-import com.minpay.db.table.mapper.ImRoleMapper;
-import com.minpay.db.table.mapper.ImUserRoleRelMapper;
-import com.minpay.db.table.model.ImBranch;
-import com.minpay.db.table.model.ImBranchExample;
-import com.minpay.db.table.model.ImItem;
-import com.minpay.db.table.model.ImItemExample;
-import com.minpay.db.table.model.ImRole;
-import com.minpay.db.table.model.ImRoleAuthExample;
-import com.minpay.db.table.model.ImRoleAuthKey;
-import com.minpay.db.table.model.ImRoleExample;
-import com.minpay.db.table.model.ImRoleItemRel;
-import com.minpay.db.table.model.ImRoleItemRelExample;
-import com.minpay.db.table.model.ImRoleItemRelKey;
-import com.minpay.db.table.model.ImUserRoleRelExample;
-import com.minpay.db.table.model.ImUserRoleRelKey;
+import com.minpay.db.table.mapper.*;
+import com.minpay.db.table.model.*;
 import com.minpay.db.table.own.mapper.RoleMapper;
 import com.startup.minpay.frame.business.IMINAction;
 import com.startup.minpay.frame.business.res.MINActionResult;
@@ -54,6 +27,8 @@ import com.startup.minpay.frame.target.MINParam;
 import com.startup.minpay.util.DateTime;
 import com.startup.minpay.util.Str;
 
+import java.util.*;
+
 /**
  * 角色管理
  * 
@@ -290,6 +265,7 @@ public class RoleManageAction implements IMINAction {
 			@MINParam(key = "name") String name, @MINParam(key = "desc") String desc,
 			@MINParam(key = "itemidStr") String itemidStr, @MINParam(key = "authInputs") String authInputs,
 			@MINParam(key = "moduleType") String[] moduleType, @MINParam(key = "roleMainPage") String roleMainPage,
+			@MINParam(key = "branchid") String branchid,
 			MINSession session) throws MINBusinessException {
 		if ("".equals(name.trim()) || name == null) {
 			throw new MINBusinessException("请输入角色名称!");
@@ -330,8 +306,8 @@ public class RoleManageAction implements IMINAction {
 		role.setId(roleId);
 		role.setName(name);
 		role.setDesc(desc);
-		role.setBranchid(u.getBranchId());
-		role.setAddbranch(u.getBranchId());
+		role.setBranchid(branchid);
+		role.setAddbranch(branchid);
 		role.setAddtime(new DateTime().toDateTimeString());
 		//role.setIndexpage(roleMainPage);
 		role.setIndexpage("main.html");
@@ -635,7 +611,11 @@ public class RoleManageAction implements IMINAction {
 		ImRoleExample example = new ImRoleExample();
 		ImRoleExample.Criteria criteria = example.createCriteria();
 		User user = session.getUser();
-		criteria.andBranchidEqualTo(user.getBranchId());
+		if(CommonUtil.isEmpty(branchId)){
+			criteria.andBranchidEqualTo(user.getBranchId());
+		}else{
+			criteria.andBranchidEqualTo(branchId);
+		}
 		List<ImRole> ls = Service.lookup(IMINDataBaseService.class).selectByExample(ImRoleMapper.class, example);
 		res.set(IMINBusinessConstant.F_QUERY_RESULT, ls);
 		return res;
@@ -860,6 +840,14 @@ public class RoleManageAction implements IMINAction {
 			criteria.andIdEqualTo(user.getBranchId());
 		}
 		List<ImBranch> ls = Service.lookup(IMINDataBaseService.class).selectByExample(ImBranchMapper.class, example);
+		ImBranchExample exampleb = new ImBranchExample();
+		ImBranchExample.Criteria criteriab = exampleb.createCriteria();
+		criteria.andSttNotEqualTo(Constant.DEPT_STT_DEL);
+		if(!user.getBranchId().equals(Constant.DEFAULT_INSTITUTIONS)){
+			criteriab.andParentidEqualTo(user.getBranchId());
+		}
+		List<ImBranch> lsb = Service.lookup(IMINDataBaseService.class).selectByExample(ImBranchMapper.class, exampleb);
+		ls.addAll(lsb);
 		res.set(IMINBusinessConstant.F_QUERY_RESULT, ls);
 		return res;
 	}

+ 5 - 0
src/main/java/com/minpay/mt/machine/action/MachineManageAction.java

@@ -1748,12 +1748,17 @@ public class MachineManageAction implements IMINAction {
         MINActionResult res = new MINActionResult();
         // 查询当前角色编号
         User u = session.getUser();
+        String branchId = u.getBranchId();
+
         MINRowBounds rows = new MINRowBounds(page, limit);
         ImBranchExample imBranchExample = new ImBranchExample();
         ImBranchExample.Criteria createCriteria = imBranchExample.createCriteria();
         if(!StringUtils.isNullOrEmpty(accountName)){
             createCriteria.andNameLike("%"+accountName+"%");
         }
+        if(!branchId.equals(Constant.ADMINISTRATION_SYSTEM_NUMBER)){
+            createCriteria.andParentidEqualTo(branchId);
+        }
         if(!StringUtils.isNullOrEmpty(accountId)){
             createCriteria.andIdEqualTo(accountId);
         }

+ 0 - 2
src/main/webapp/admin/machineManage/machineManage.html

@@ -74,9 +74,7 @@
 	{{#  if(d.songStatus == '01'){ }}
 	<a class="layui-btn layui-btn-xs" lay-event="open">开启音乐</a>
 	{{#  } }}
-	{{#  if(d.branchid == '88888888'){ }}
 	<a class="layui-btn layui-btn-xs" lay-event="bangding">绑定商户</a>
-	{{#  } }}
 </script>
 <script type="text/html" id="switchTwo">
 	<div style="width:90px;height:70px">

+ 45 - 6
src/main/webapp/admin/roleManage/roleAdd.html

@@ -15,9 +15,12 @@
 	<div style="margin-top: 20px;margin-left: 20px;margin-right: 120px; padding-bottom:60px;">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
-           <div class="layui-input-block">
+           <div class="layui-input-inline">
                <input type="text" name="name" id="name" lay-verify="required" autocomplete="off" placeholder="请输入角色名称" class="layui-input">
            </div>
+           <label class="layui-form-label" style = "width: 150px;">*所属商户:</label>
+           <div class="layui-input-inline" id ="branchSelect">
+           </div>
        </div>
        <!--<div class="layui-form-item">
            <label class="layui-form-label">角色主页</label>
@@ -58,8 +61,36 @@
 			// 打开新增页面
 			deleteTabPage('315001-01');
    		}
-   		
-        // checkbox 点击事件
+        layui.use('form', function(){
+            var form = layui.form;
+            $.request({
+                action : 'RoleManageAction/roleQueryBranch',
+                data : { },
+                success : function(data) {
+                    var selectName ="branchid";
+                    var html1 = '<select lay-verify="branchid" lay-search=""  name="';
+                    html1 = html1 + selectName;
+                    html1 = html1 + '" lay-filter="branchid';
+                    html1 = html1 + '"';
+                    html1 = html1 + '><option value="">请选择</option>';
+                    $.each(data.MINQueryResult, function(i, j) {
+                        html1 = html1 + '<option ';
+                        html1 = html1 + 'value="';
+                        html1 = html1 + j.id + '">';
+                        html1 = html1 + j.name+ '</option>';
+                        //objSelect.options.add(new Option(j.id,j.name));
+                        // $("#zcySelect").options.add(new Option(j.name,j.name));
+                        // $("#zcySelect").append("<option value="+j.id+">"+j.name+"</option>");
+                    })
+                    html1 = html1 + '</select>';
+                    $("#branchSelect").html(html1);
+                    form.render();
+                },
+            });
+
+        })
+
+            // checkbox 点击事件
         function authChoose(t){
         	var val = t.value;
         	var isChecked = t.checked;
@@ -102,7 +133,7 @@
         	var name = document.getElementById('name').value;
         	var desc = document.getElementById('desc').value;
         	var inputs = document.getElementsByTagName("input");
-        	//var roleMainPage = $("select[name='roleMainPage']").val();
+        	var branchid = $("select[name='branchid']").val();
         	// 获取菜单数组
         	for (var i = 0; i < inputs.length; i ++) {
         		if (!isEmpty(inputs[i].value) && inputs[i].checked) {
@@ -128,6 +159,13 @@
         		})
         		return;
         	}
+            if (isEmpty(branchid)) {
+                layui.use(['layer'], function(){
+                    layer.alert('请选择商户!', {icon: 2});
+                })
+                return;
+            }
+
         	
         	/*if (isEmpty(roleMainPage)) {
         		layui.use(['layer'], function(){
@@ -135,14 +173,15 @@
         		})
         		return;
         	}*/
+
         	// 执行新增
         	$.request({
         		action : 'RoleManageAction/roleAdd',
         		data : {
         			itemidStr : itemid,
         			name : name,
-        			desc : desc/*,
-        			roleMainPage : roleMainPage*/
+        			desc : desc,
+        			branchid : branchid
         		},
         		success : function(data){
         			if (data.MINStatus == 0) {

+ 61 - 41
src/main/webapp/admin/userManage/addUser.html

@@ -37,16 +37,17 @@
 		            </div>
 	            </div>
 	        </div>
-	        <div class="layui-form-item">
-	            <label class="layui-form-label" style = "width: 150px;">*角色:</label>
-	            <div class="layui-input-inline" id ="zcySelect">
-	           </div>
-			</div>
 			<div class="layui-form-item">
 				<label class="layui-form-label" style = "width: 150px;">*商户:</label>
 				<div class="layui-input-inline" id ="branchSelect">
 				</div>
 			</div>
+	        <div class="layui-form-item">
+	            <label class="layui-form-label" style = "width: 150px;">*角色:</label>
+	            <div class="layui-input-inline" id ="zcySelect">
+	           </div>
+			</div>
+
 			<div class="layui-form-item">
 	            <div class="layui-inline">
 	                <label class="layui-form-label" style = "width: 150px;">*手机号:</label>
@@ -83,32 +84,64 @@
 		}
 	    layui.use('form', function(){
 	    	  var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
-	    	  $.request({
+
+			role();
+
+
+			$.request({
+				action : 'RoleManageAction/roleQueryBranch',
+				data : { },
+				success : function(data) {
+					var selectName ="branchid";
+					var html1 = '<select lay-verify="branchid" lay-search="" name="' ;
+					html1 = html1 + selectName;
+					html1 = html1 + '" lay-filter="branchid';
+					html1 = html1 + '"';
+					html1 = html1 + '><option value="">请选择</option>';
+					$.each(data.MINQueryResult, function(i, j) {
+						html1 = html1 + '<option ';
+						html1 = html1 + 'value="';
+						html1 = html1 + j.id + '">';
+						html1 = html1 + j.name+ '</option>';
+						//objSelect.options.add(new Option(j.id,j.name));
+						// $("#zcySelect").options.add(new Option(j.name,j.name));
+						// $("#zcySelect").append("<option value="+j.id+">"+j.name+"</option>");
+					})
+					html1 = html1 + '</select>';
+					$("#branchSelect").html(html1);
+					form.render();
+				},
+			});
+			form.on('select(branchid)', function(data){
+				$.request({
 					action : 'RoleManageAction/roleQueryByBranchId',
-					data : { },
+					data : {branchId:data.value},
 					success : function(data) {
 						var selectName ="roleid";
 						var html = '<select lay-verify="roleid" name="';
 						html = html + selectName;
 						html = html + '" lay-filter="';
 						html = html + '"';
-						html = html + '><option value="">请选择</option>';
+						html = html + '><option value="">请选择商户</option>';
 						$.each(data.MINQueryResult, function(i, j) {
-							  html = html + '<option ';
-							  html = html + 'value="';
-						      html = html + j.id + '">';
-						      html = html + j.name+ '</option>';
-						}) 
+							html = html + '<option ';
+							html = html + 'value="';
+							html = html + j.id + '">';
+							html = html + j.name+ '</option>';
+						})
 						html = html + '</select>';
 						$("#zcySelect").html(html);
-						  form.render();
+						form.render();
 					},
-				});	
+				});
+
+			});
+
 // 	    		//监听取消
 // 	      	$('#cancel').on('click', function(){
-//       	    	 parent.layer.close(parent.layer.index); 
+//       	    	 parent.layer.close(parent.layer.index);
 //       	   	});
-    	});  
+    	});
     
         function renderForm(){
 			 layui.use('form', function(){
@@ -188,31 +221,18 @@
                 return false;
 			});
         });
-		$.request({
-			action : 'RoleManageAction/roleQueryBranch',
-			data : { },
-			success : function(data) {
-				var selectName ="branchid";
-				var html1 = '<select lay-verify="branchid" name="';
-				html1 = html1 + selectName;
-				html1 = html1 + '" lay-filter="';
-				html1 = html1 + '"';
-				html1 = html1 + '><option value="">请选择</option>';
-				$.each(data.MINQueryResult, function(i, j) {
-					html1 = html1 + '<option ';
-					html1 = html1 + 'value="';
-					html1 = html1 + j.id + '">';
-					html1 = html1 + j.name+ '</option>';
-					//objSelect.options.add(new Option(j.id,j.name));
-					// $("#zcySelect").options.add(new Option(j.name,j.name));
-					// $("#zcySelect").append("<option value="+j.id+">"+j.name+"</option>");
-				})
-				html1 = html1 + '</select>';
-				$("#branchSelect").html(html1);
-				form.render();
-			},
-		});
         initSelect('isCustManage', "IS_SUSTOMER_MANAGER", "isCustManage", '00', true);
+        function role() {
+			var selectName ="roleid";
+			var html = '<select lay-verify="roleid" name="';
+			html = html + selectName;
+			html = html + '" lay-filter="';
+			html = html + '"';
+			html = html + '><option value="">请先选择商户</option>';
+			html = html + '</select>';
+			$("#zcySelect").html(html);
+
+		}
     </script>
 </body>
 </html>