xs 5 anni fa
parent
commit
c3c5e635d5

+ 26 - 2
src/main/java/com/jeeplus/modules/sys/web/OfficeController.java

@@ -10,9 +10,11 @@ import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.core.web.BaseController;
 import com.jeeplus.modules.sys.entity.Office;
+import com.jeeplus.modules.sys.entity.Role;
 import com.jeeplus.modules.sys.entity.User;
 import com.jeeplus.modules.sys.mapper.UserMapper;
 import com.jeeplus.modules.sys.service.OfficeService;
+import com.jeeplus.modules.sys.service.SystemService;
 import com.jeeplus.modules.sys.utils.DictUtils;
 import com.jeeplus.modules.sys.utils.UserUtils;
 import org.apache.shiro.authz.annotation.Logical;
@@ -27,6 +29,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.util.*;
 
 /**
@@ -43,6 +47,8 @@ public class OfficeController extends BaseController {
 
 	@Autowired
 	private UserMapper userMapper;
+	@Autowired
+	private SystemService systemService;
 	
 	@ModelAttribute("office")
 	public Office get(@RequestParam(required=false) String id) {
@@ -171,18 +177,36 @@ public class OfficeController extends BaseController {
 	@ResponseBody
 	@RequiresPermissions("user")
 	@RequestMapping(value = "treeData")
-	public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId, @RequestParam(required=false) String type,
+	public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId,String roleNeedName, @RequestParam(required=false) String type,
 			@RequestParam(required=false) Long grade, @RequestParam(required=false) Boolean isAll, HttpServletResponse response) {
+
 		List<Map<String, Object>> mapList = Lists.newArrayList();
 		List<Office> offices = officeService.findList(isAll);
 		List<Office> list = new ArrayList<Office>();
 		List<String> strings = new ArrayList<String>();//存放父类id
 		List<String> strings1 = new ArrayList<String>();//存放父类id
+		//获取字符串
 		User user = new User();
 		Boolean flag = false;
 		String[] sts = {};//字符串数组
 		String str = "";
-		List<User> users = userMapper.findAllList(user);
+		try {
+			roleNeedName = URLDecoder.decode(roleNeedName, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		String[] split = roleNeedName.split(";");
+		if (split != null && split.length > 0) {
+			Role role = null;
+			List<Role> roles = new ArrayList<>();
+			for (int i = 0; i < split.length; i++) {
+				role = new Role();
+				role.setName(split[i]);
+				roles.add(role);
+			}
+			user.setRoleList(roles);
+		}
+		List<User> users = systemService.findUser(user);
 		for (Office office:offices){
 			flag = false;
 			for (User user1:users){

+ 2 - 1
src/main/webapp/webpage/modules/common/userSelect.jsp

@@ -9,13 +9,14 @@
 	<script type="text/javascript">
 		$(document).ready(function() {
 			//bootstrap treeview初始化
+            var roleNeedName = $("#roleNeedName").val();
 			$('#jstree').jstree({
 				'core' : {
 					"multiple" : false,
 					"animation" : 0,
 					"themes" : { "variant" : "large", "icons":true , "stripes":true},
 					'data' : {
-						"url" : "${ctx}/sys/office/treeData",
+						"url" : "${ctx}/sys/office/treeData?roleNeedName="+encodeURI(encodeURI(roleNeedName)),
 						"dataType" : "json" // needed only if you do not supply JSON headers
 					}
 				},