(原)Layui 页面 根据 部门编号 获取 用户列表 信息

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31653405/article/details/86518775

效果图:

一、       

  二、


代码:

前台 -html

 <span th:text="部门"></span>
<div class="layui-input-inline"> 
	<select id="orgId" name="orgName"  lay-filter="serchOrgType">
		<option value=""  th:text="--请选择--"></option>
		<option th:each="org:${orgList}" th:value="${org.departmentId}" th:text="${org.departmentName}" ></option>
	</select>
</div>&nbsp;&nbsp; 
			          
<span th:text="姓名"></span>
<div class="layui-input-inline">
	<select id="userId" name="userName">
	<!--  <option value=""  th:text="--请选择--"></option>
	<option th:each="users:${userList}" th:value="${users.openid}" th:text="${users.userName}" ></option> -->
	 </select>
</div>&nbsp;&nbsp;

前台 -js: 

 <script type="text/javascript">
      		layui.use('laydate', function(){
		       layui.laydate.render({elem: '#startTime'});
		       layui.laydate.render({elem: '#endTime'});
		       //正文
		       layui.use(['form'], function () {
		            var $ = layui.$, form = layui.form;
		            form.on('select(serchOrgType)', function(obj){
		            	var html="";
		            	var orgId = obj.value;
		            	console.log(obj.othis); //得到美化后的DOM对象
		            	$("select[name=userName]").html("");
		            	   $.ajax({
		            	        type : 'GET',
		            	        url : '/Statistical/getUsersByOrgId',
		            	        async : false,
		            	        dataType : 'json',
		            	        data : {
		            	            'orgId' : orgId
		            	        },
		            	        success : function(data) {
		            	    		$.each(data,function(){ 
		         	   	    			$(this).each(function(i,item){
		            	    				html +=  "<option value='"+item.openid+"'>"+item.userName+"</option>";
		            	    			});
		            	    		});
		            	        },
		            	        error : function() {
		            	            showAlert("错误:获取下级错误");
		            	        }
		            	    });  
		            	   $("select[name=userName]").append(html);
		            	   form.render();
		            });
		        });
		     });
   </script>

后台:

@ResponseBody
@RequestMapping(value = "getUsersByOrgId", method = RequestMethod.GET)
public List<User> findUsers(ModelMap modelMap,HttpSession session,HttpServletRequest request,HttpServletResponse response) {
		String orgId = String.valueOf(request.getParameter("orgId"));
		List<User> list = userService.findUserBydepartmentId(orgId);
		return list;
	}

 借鉴文章及应用的代码部分

https://blog.csdn.net/qq_35979073/article/details/79738531

https://blog.csdn.net/QYHuiiQ/article/details/82016425

 

猜你喜欢

转载自blog.csdn.net/qq_31653405/article/details/86518775