Commit d70e57a6182248f4e9ed750c8ec77f07ddb15516

Authored by maliang
Exists in master

Merge branch 'master' of https://git.healthbaby.com.cn/jiangjiazhi/center

Showing 11 changed files

center.manager/src/main/java/com/lyms/cm/controller/sys/SysRolesController.java View file @ d70e57a
... ... @@ -61,6 +61,18 @@
61 61 Page<SysRoles> page = getPage();
62 62 EntityWrapper<SysRoles> ew = new EntityWrapper<SysRoles>();
63 63 ew.where("ifDel=0");
  64 + String id = getParameter("id");
  65 + String name = getParameter("name");
  66 + String type = getParameter("type");
  67 + if(StrUtils.isNotEmpty(id)){
  68 + ew.and("id like {0}", name.trim() + "%");
  69 + }
  70 + if(StrUtils.isNotEmpty(name)){
  71 + ew.and("name like {0}", name.trim() + "%");
  72 + }
  73 + if(StrUtils.isNotEmpty(type)){
  74 + ew.and("type={0}", type);
  75 + }
64 76 return toGridData(sysRolesService.selectPage(page, ew));
65 77 }
66 78  
center.manager/src/main/java/com/lyms/cm/controller/sys/SysUsersController.java View file @ d70e57a
1 1 package com.lyms.cm.controller.sys;
2 2  
  3 +import java.util.List;
3 4 import java.util.Map;
4 5  
5 6 import org.apache.commons.lang3.StringUtils;
6 7  
7 8  
... ... @@ -13,9 +14,15 @@
13 14  
14 15 import com.baomidou.mybatisplus.mapper.EntityWrapper;
15 16 import com.baomidou.mybatisplus.plugins.Page;
  17 +import com.lyms.cm.entity.sys.SysRoles;
  18 +import com.lyms.cm.entity.sys.SysUserRoleMaps;
16 19 import com.lyms.cm.entity.sys.SysUsers;
  20 +import com.lyms.cm.service.sys.SysRolesService;
  21 +import com.lyms.cm.service.sys.SysUserRoleMapsService;
17 22 import com.lyms.cm.service.sys.SysUsersService;
18 23 import com.lyms.constants.OperationName;
  24 +import com.lyms.util.InstanceUtils;
  25 +import com.lyms.util.StrUtils;
19 26 import com.lyms.web.bean.AjaxResult;
20 27 import com.lyms.web.controller.BaseController;
21 28  
... ... @@ -33,6 +40,12 @@
33 40  
34 41 @Autowired
35 42 private SysUsersService userService;
  43 +
  44 + @Autowired
  45 + private SysRolesService sysRolesService;
  46 + @Autowired
  47 + private SysUserRoleMapsService sysUserRoleMapsService;
  48 +
36 49  
37 50 /**
38 51 * 创建用户
39 52  
... ... @@ -45,12 +58,14 @@
45 58 @RequestMapping(value = "/create", method = RequestMethod.POST)
46 59 @ResponseBody
47 60 public AjaxResult create(SysUsers user, AjaxResult ajaxResult) {
48   - if(userService.isExistAccount(user.getAccount())){
  61 + if(!userService.isAllowUpdate(user.getAccount(),null)){
49 62 ajaxResult.setSuccess(true);
50 63 ajaxResult.setMessage("新增失败!" + user.getAccount() + " 已经存在,请修改登录账号!");
51 64 return ajaxResult;
52 65 }
53   - boolean tag = userService.addUser(user);
  66 + String userid = StrUtils.uuid();
  67 + user.setId(userid);
  68 + boolean tag = userService.addUser(user,getUserRoleList(userid, getParameter("roles")));
54 69 return handleAjaxResult(ajaxResult, tag, OperationName.CREATE);
55 70 }
56 71  
... ... @@ -77,6 +92,18 @@
77 92 Page<SysUsers> page = getPage();
78 93 EntityWrapper<SysUsers> ew = new EntityWrapper<SysUsers>();
79 94 ew.where("ifDel=0");
  95 + String searchName = getParameter("name");
  96 + String searchAccount = getParameter("account");
  97 + String searchPhone = getParameter("phone");
  98 + if(StrUtils.isNotEmpty(searchName)){
  99 + ew.and("name like {0}", searchName.trim() + "%");
  100 + }
  101 + if(StrUtils.isNotEmpty(searchAccount)){
  102 + ew.and("account like {0}", searchAccount.trim() + "%");
  103 + }
  104 + if(StrUtils.isNotEmpty(searchPhone)){
  105 + ew.and("phone like {0}", searchPhone.trim() + "%");
  106 + }
80 107 page = userService.selectPage(page,ew);
81 108 return toGridData(page);
82 109 }
83 110  
... ... @@ -91,7 +118,18 @@
91 118 if (!StringUtils.isBlank(id)) {
92 119 SysUsers user = userService.selectById(id);
93 120 model.addAttribute("user", user);
  121 + //当前用户角色数据
  122 + List<SysUserRoleMaps> urList = sysUserRoleMapsService
  123 + .selectList(new EntityWrapper<SysUserRoleMaps>().where("user_id={0}", "'" + id + "'"));
  124 + StringBuilder urSB = new StringBuilder();
  125 + for(SysUserRoleMaps urEntity : urList){
  126 + urSB.append("," + urEntity.getRoleId());
  127 + }
  128 + model.addAttribute("userRoles", urSB.toString().replaceFirst(",", ""));
94 129 }
  130 + //所有角色数据
  131 + List<SysRoles> roleList = sysRolesService.selectList(new EntityWrapper<SysRoles>().where("ifDel=0"));
  132 + model.addAttribute("roleString",toJson(roleList));
95 133 return "/user/user_edit";
96 134 }
97 135  
98 136  
... ... @@ -101,12 +139,12 @@
101 139 @RequestMapping(value = "/update", method = { RequestMethod.POST })
102 140 @ResponseBody
103 141 public AjaxResult update(SysUsers user, AjaxResult ajaxResult) {
104   - if(userService.isExistAccount(user.getAccount())){
  142 + if(!userService.isAllowUpdate(user.getAccount(),user.getId())){
105 143 ajaxResult.setSuccess(true);
106 144 ajaxResult.setMessage("修改失败! " + user.getAccount()+" 已经存在,请修改登录账号!");
107 145 return ajaxResult;
108 146 }
109   - boolean tag = userService.updateUser(user);
  147 + boolean tag = userService.updateUser(user,getUserRoleList(user.getId(), getParameter("roles")));
110 148 return handleAjaxResult(ajaxResult, tag, OperationName.UPDATE);
111 149  
112 150 }
... ... @@ -122,6 +160,34 @@
122 160 int tag = userService.deleteLogicById(id);
123 161 return handleAjaxResult(ajaxResult, tag, OperationName.DELETE);
124 162 }
  163 +
  164 + /**
  165 + * <li>@Description:获取用户角色对应关系列表
  166 + * <li>@param roleId
  167 + * <li>@param permissionIds
  168 + * <li>@return
  169 + * <li>创建人:方承
  170 + * <li>创建时间:2017年3月9日
  171 + * <li>修改人:
  172 + * <li>修改时间:
  173 + */
  174 + private List<SysUserRoleMaps> getUserRoleList(String userId, String roles) {
  175 + List<SysUserRoleMaps> urList = InstanceUtils.newArrayList();
  176 + if (StrUtils.isNotEmpty(roles)) {
  177 + String[] roleArray = roles.split(",");
  178 + for (String roleId : roleArray) {
  179 + if (StrUtils.isNotEmpty(roleId)) {
  180 + SysUserRoleMaps urentity = new SysUserRoleMaps();
  181 + urentity.setId(StrUtils.uuid());
  182 + urentity.setIfdel(0);
  183 + urentity.setRoleId(roleId);
  184 + urentity.setUserId(userId);
  185 + urList.add(urentity);
  186 + }
  187 + }
  188 + }
  189 + return urList;
  190 + }
125 191  
126 192 }
center.manager/src/main/java/com/lyms/cm/service/sys/SysUsersService.java View file @ d70e57a
1 1 package com.lyms.cm.service.sys;
2 2  
3 3 import java.io.Serializable;
  4 +import java.util.List;
4 5  
  6 +import com.lyms.cm.entity.sys.SysUserRoleMaps;
5 7 import com.lyms.cm.entity.sys.SysUsers;
6 8 import com.lyms.exception.SystemException;
7 9 import com.lyms.web.service.BaseService;
... ... @@ -23,7 +25,7 @@
23 25 * @return
24 26 * @author maliang
25 27 */
26   - public boolean addUser(SysUsers user) throws SystemException;
  28 + public boolean addUser(SysUsers user,List<SysUserRoleMaps> userRoleMaps) throws SystemException;
27 29  
28 30 /**
29 31 * 修改用户信息
... ... @@ -32,7 +34,7 @@
32 34 * @return
33 35 * @author maliang
34 36 */
35   - public boolean updateUser(SysUsers user) throws SystemException;
  37 + public boolean updateUser(SysUsers user,List<SysUserRoleMaps> userRoleMaps) throws SystemException;
36 38  
37 39 /**
38 40 * 根据ID获取用户信息
... ... @@ -43,17 +45,6 @@
43 45 */
44 46 // public SysUsers getUserById(String userId) throws SystemException;
45 47  
46   - /**
47   - * 启用/停用
48   - * <p>
49   - * 根据用户ID操作
50   - * <p>
51   - *
52   - * @param userId
53   - * @return
54   - * @author maliang
55   - */
56   - public boolean enabled(String userId) throws SystemException;
57 48  
58 49 /**
59 50 * 删除用户信息
60 51  
61 52  
... ... @@ -73,15 +64,16 @@
73 64  
74 65  
75 66 /**
76   - * <li>@Description:是否存在登录号
77   - * <li>@param username
  67 + * <li>@Description:是否允许添加和修改
  68 + * <li>@param account 登录账户
  69 + * <li>@param userid 如果不为null,则是修改, 否则为新增
78 70 * <li>@return
79 71 * <li>创建人:方承
80   - * <li>创建时间:2017年3月8日
  72 + * <li>创建时间:2017年3月9日
81 73 * <li>修改人:
82 74 * <li>修改时间:
83 75 */
84   - public boolean isExistAccount(String username);
  76 + public boolean isAllowUpdate(String account,String userid);
85 77  
86 78 }
center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysUsersServiceImpl.java View file @ d70e57a
1 1 package com.lyms.cm.service.sys.impl;
2 2  
3 3 import java.io.Serializable;
  4 +import java.util.List;
4 5  
5 6 import org.apache.commons.lang3.StringUtils;
6 7 import org.springframework.beans.factory.annotation.Autowired;
7 8  
8 9  
... ... @@ -9,10 +10,14 @@
9 10  
10 11 import com.baomidou.mybatisplus.mapper.EntityWrapper;
11 12 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  13 +import com.lyms.cm.dao.sys.SysUserRoleMapsMapper;
12 14 import com.lyms.cm.dao.sys.SysUsersMapper;
  15 +import com.lyms.cm.entity.sys.SysRolePermissionMaps;
  16 +import com.lyms.cm.entity.sys.SysUserRoleMaps;
13 17 import com.lyms.cm.entity.sys.SysUsers;
14 18 import com.lyms.cm.enums.StatusEnum;
15 19 import com.lyms.cm.enums.ValidityEnum;
  20 +import com.lyms.cm.service.sys.SysUserRoleMapsService;
16 21 import com.lyms.cm.service.sys.SysUsersService;
17 22 import com.lyms.exception.SystemException;
18 23 import com.lyms.util.MD5Utils;
... ... @@ -31,6 +36,10 @@
31 36  
32 37 @Autowired
33 38 private SysUsersMapper userMapper;
  39 +
  40 + @Autowired
  41 + private SysUserRoleMapsService sysUserRoleMapsService;
  42 +
34 43  
35 44 /**
36 45 * 系统默认密码
37 46  
... ... @@ -58,11 +67,10 @@
58 67  
59 68 @Override
60 69 @Transactional
61   - public boolean addUser(SysUsers user) throws SystemException {
  70 + public boolean addUser(SysUsers user,List<SysUserRoleMaps> userRoleMapsList) throws SystemException {
62 71 if (empty(user))
63 72 return false;
64 73 // 设置user ID
65   - user.setId(StrUtils.uuid());
66 74 user.setIfdel(0);
67 75 if (null == user.getType()) {//没有勾选管理,就是用户
68 76 user.setType(1);
69 77  
... ... @@ -74,12 +82,15 @@
74 82 this.initPwd(user);
75 83  
76 84 Integer tag = userMapper.insert(user);
  85 + if (!userRoleMapsList.isEmpty()) {
  86 + sysUserRoleMapsService.insertBatch(userRoleMapsList);
  87 + }
77 88 return tag != null && tag >= 1;
78 89 }
79 90  
80 91 @Override
81 92 @Transactional
82   - public boolean updateUser(SysUsers user) throws SystemException {
  93 + public boolean updateUser(SysUsers user,List<SysUserRoleMaps> userRoleMapsList) throws SystemException {
83 94 if (empty(user))
84 95 return false;
85 96 if (null == user.getType()) {//没有勾选管理,就是用户
86 97  
... ... @@ -88,12 +99,18 @@
88 99 if (null == user.getEnable()) {
89 100 user.setEnable(1);
90 101 }
91   - if (StrUtils.isNotEmpty(user.getPwd())) {
  102 + if (StrUtils.isNotEmpty(user.getPwd()) ) {
92 103 // 初始密码
93 104 this.initPwd(user);
94 105 }
95 106  
96 107 Integer tag = userMapper.updateById(user);
  108 + EntityWrapper<SysUserRoleMaps> ew = new EntityWrapper<SysUserRoleMaps>();
  109 + ew.where("user_id={0}", "'" + user.getId() + "'");
  110 + sysUserRoleMapsService.delete(ew);
  111 + if (!userRoleMapsList.isEmpty()) {
  112 + sysUserRoleMapsService.insertBatch(userRoleMapsList);
  113 + }
97 114 return tag != null && tag >= 1;
98 115 }
99 116  
100 117  
... ... @@ -103,23 +120,7 @@
103 120 * userMapper.selectById(userId); }
104 121 */
105 122  
106   - @Override
107   - @Transactional
108   - public boolean enabled(String userId) throws SystemException {
109   - // TODO 编写SQL 修改
110   - SysUsers user = this.selectById(userId);
111   - if (empty(user))
112   - return false;
113 123  
114   - // 判断当前用户的启用,禁用情况
115   - if (StatusEnum.isEnabled(user.getEnable())) {
116   - user.setEnable(StatusEnum.DISENABLED.getStatus());
117   - } else {
118   - user.setEnable(StatusEnum.ENABLED.getStatus());
119   - }
120   - return this.updateUser(user);
121   - }
122   -
123 124 @Override
124 125 @Transactional
125 126 public boolean delete(String userId) throws SystemException {
... ... @@ -148,8 +149,30 @@
148 149 }
149 150  
150 151 @Override
151   - public boolean isExistAccount(String username) {
152   - SysUsers entity = selectOne(new EntityWrapper<SysUsers>().where("account={0}", "'" + username + "'"));
  152 + public boolean isAllowUpdate(String account,String userid) {
  153 + boolean flag = true;
  154 + if(StrUtils.isNotEmpty(userid) ){//修改用户
  155 + SysUsers oldDbUser = selectById(userid);
  156 + if(!oldDbUser.getAccount().equalsIgnoreCase(account)){//登录账号改变
  157 + flag = !isExistAccount(account);
  158 + }
  159 + }else{//新增
  160 + flag = !isExistAccount(account);
  161 + }
  162 + return flag;
  163 + }
  164 +
  165 + /**
  166 + * <li>@Description:是否存在登录名
  167 + * <li>@param account
  168 + * <li>@return
  169 + * <li>创建人:方承
  170 + * <li>创建时间:2017年3月9日
  171 + * <li>修改人:
  172 + * <li>修改时间:
  173 + */
  174 + private boolean isExistAccount(String account){
  175 + SysUsers entity = selectOne(new EntityWrapper<SysUsers>().where("account={0}", "'" + account + "'").and("ifDel=0"));
153 176 if (null == entity) {
154 177 return false;
155 178 }
center.manager/src/main/webapp/WEB-INF/views/common/base_list.html View file @ d70e57a
... ... @@ -36,6 +36,71 @@
36 36 <script src="${ctx}/static/js/base/base_table_init.js"></script>
37 37 <script type="text/javascript">
38 38 $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
  39 +
  40 +
  41 +$(function(){
  42 +
  43 + function get(id,callback) {
  44 + $.get(APP.PATH+"/sysRegions/find?id="+id,function(data){
  45 + callback(data);
  46 + })
  47 + }
  48 +
  49 + //下一个级别
  50 + function nextLeve(leve) {
  51 + var tmp = leve.substring(leve.length-1);
  52 + var intTmp = parseInt(tmp)+1;
  53 + return intTmp;
  54 + }
  55 +
  56 +
  57 + //移除当前列表的后续选项
  58 + function remove(leve) {
  59 + var max = 3;
  60 + var nextLeveInt = nextLeve(leve);
  61 + for(var i=nextLeveInt;i<=max;i++) {
  62 + $("#leve"+i).children().first().nextAll().remove();
  63 + }
  64 + }
  65 +
  66 + function handler(data,leveName) {
  67 + var leve =data==null ? [] : data.records;
  68 + var nextLeveInt = nextLeve(leveName);
  69 +
  70 + if(leve!=null && leve.length>0) {
  71 + remove(leveName);
  72 + for(var i=0;i<leve.length;i++) {
  73 + $("#leve"+nextLeveInt).append("<option id="+leve[i].id+" value="+leve[i].id+">"+leve[i].name+"</option>")
  74 + }
  75 + }
  76 + }
  77 +
  78 + //初始信息
  79 + get("",function(data){
  80 + handler(data,"leve0");
  81 + //填充选择信息
  82 + });
  83 +
  84 + //
  85 + $(".leve").bind("change",function(){
  86 + var leveId = $(this).attr("id");
  87 + var leves = ["leve1","leve2","leve3"];
  88 + var thisVal = $(this).val();
  89 + var ZERO = "0";
  90 +
  91 + if((leveId === leves[0] || leveId===leves[1]) &&thisVal===ZERO){
  92 + remove(leveId);
  93 + }else{
  94 + //获取数据
  95 + get(thisVal,function(data){
  96 + handler(data,leveId);
  97 + })
  98 + }
  99 +
  100 + });
  101 +
  102 +})
  103 +
39 104 </script>
40 105 </body>
41 106 </html>
center.manager/src/main/webapp/WEB-INF/views/group/group_list.html View file @ d70e57a
... ... @@ -126,6 +126,7 @@
126 126 'Y': 's',
127 127 'N': 's'
128 128 }
  129 +
129 130 },
130 131 async:{
131 132 autoParam:["id"],
... ... @@ -258,6 +259,7 @@
258 259 }
259 260 }
260 261 var resTree = $.fn.zTree.getZTreeObj('tree_resources');
  262 +
261 263 resTree.expandAll(false);
262 264 }
263 265 });
center.manager/src/main/webapp/WEB-INF/views/role/role_edit.html View file @ d70e57a
... ... @@ -7,50 +7,6 @@
7 7 var reNodes = ${perString};
8 8 </script>
9 9 <script>
10   -function Scroll(w) {
11   - var win = w || window;
12   - var d = win.document;
13   - if (d.documentElement && !(d.documentElement.scrollTop == undefined || d.documentElement.scrollTop == 0)) {
14   - return {
15   - 'top': win.document.documentElement.scrollTop,
16   - 'left': win.document.documentElement.scrollLeft
17   - };
18   - } else if (win.document.body) {
19   - return {
20   - 'top': win.document.body.scrollTop,
21   - 'left': win.document.body.scrollLeft
22   - };
23   - }
24   -}
25   -function BoundingClientRect(obj) {
26   - if (navigator.product == 'Gecko') {
27   - var objWin = null;
28   - var top = obj.offsetTop;
29   - var left = obj.offsetLeft;
30   - var right = obj.offsetWidth;
31   - var bottom = obj.offsetHeight;
32   - while (obj = obj.offsetParent) {
33   - top += obj.offsetTop;
34   - left += obj.offsetLeft;
35   - if (obj.tagName.toLowerCase() == 'body') {
36   - objWin = obj.ownerDocument.defaultView;
37   - }
38   - }
39   - var theScroll = Scroll(objWin);
40   - left -= theScroll.left;
41   - top -= theScroll.top;
42   - right += left;
43   - bottom += top;
44   - return {
45   - 'left': left,
46   - 'top': top,
47   - 'right': right,
48   - 'bottom': bottom
49   - };
50   - } else {
51   - return obj.getBoundingClientRect();
52   - }
53   -}
54 10 var setting_resource = {
55 11 check: {
56 12 enable: true,
... ... @@ -140,7 +96,9 @@
140 96 var rpArray = rpValues.split(",");
141 97 for(var i = 0 ; i < rpArray.length ;i++){
142 98 var node = zTree.getNodeByParam('id',rpArray[i]);
143   - zTree.checkNode(node,true,false);
  99 + if(node != null){
  100 + zTree.checkNode(node,true,false);
  101 + }
144 102 }
145 103 }
146 104 zTree.expandAll(true);
... ... @@ -162,6 +120,15 @@
162 120 </div>
163 121 </div>
164 122 <div class="form-group">
  123 + <label class="col-sm-3 control-label">角色类型:</label>
  124 + <div class="col-sm-8">
  125 + <select class="form-control m-b" name="type">
  126 + <option value="1" #if ($role.type == 1) selected="selected" #end >用户角色</option>
  127 + <option value="0" #if ($role.type == 0) selected="selected" #end >管理员角色</option>
  128 + </select>
  129 + </div>
  130 + </div>
  131 + <div class="form-group">
165 132 <label class="col-sm-3 control-label">角色备注:</label>
166 133 <div class="col-sm-8">
167 134 <input type="text" placeholder="角色备注" value="$!role.remarks" aria-required="true" required="true" class="form-control" minlength="2" name="remarks" id="remarks">
168 135  
... ... @@ -184,11 +151,11 @@
184 151 <div class="col-sm-8">
185 152 <label class="checkbox-inline i-checks">
186 153 <div class="icheckbox_square-green" style="position: relative;">
187   - <input type="checkbox" value="1" name="enable" #if ($role.enable == 1) checked="checked" #end
  154 + <input type="checkbox" value="0" name="enable" #if ($role.enable == 0) checked="checked" #end
188 155 style="position: absolute; opacity: 0;" >
189 156 <ins class="iCheck-helper"
190 157 style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
191   - </div>是否可用(选中可用,不选中不可用)
  158 + </div>是否禁用(选中禁用,不选中可用)
192 159 </label>
193 160 </div>
194 161 </div>
center.manager/src/main/webapp/WEB-INF/views/role/role_list.html View file @ d70e57a
... ... @@ -4,16 +4,23 @@
4 4 <div style="padding-top:30px;">
5 5 <form role="form" class="form-inline">
6 6 <div class="form-group">
7   - <input type="text" placeholder="请输入角色名称" id="usernameSearch" class="form-control">
  7 + <input type="text" placeholder="角色名" id="searchName" class="form-control">
8 8 </div>
9 9 <div class="form-group">
10   - <input type="text" placeholder="请输入角色描述" id="idSearch" class="form-control">
  10 + <select class="form-control m-b" name="type" id="searchType" style="margin-bottom: 0;">
  11 + <option value="">所有</option>
  12 + <option value="1">用户角色</option>
  13 + <option value="0">管理员角色</option>
  14 + </select>
11 15 </div>
  16 + <div class="form-group">
  17 + <input type="text" placeholder="角色id编号" id="searchId" class="form-control">
  18 + </div>
12 19 </form>
13 20 </div>
14 21 </div>
15 22 <div class="col-sm-2">
16   - <div class="title-action">
  23 + <div class="title-action" onclick="search();">
17 24 <a class="btn btn-primary"><i class="fa fa-search"></i> 查询</a>
18 25 </div>
19 26 </div>
... ... @@ -35,6 +42,16 @@
35 42 <script type="text/javascript">
36 43 var controllerRequestMappint = "/sysRoles/";
37 44  
  45 +function search(){
  46 + var queryParams = {
  47 + query:{
  48 + name: $("#searchName").val(),
  49 + id: $("#searchId").val(),
  50 + type: $("#searchType").val()
  51 + }
  52 + }
  53 + $('#dataTable').bootstrapTable('refresh', queryParams );
  54 +}
38 55 function add() {
39 56 fullWindow("新增角色", APP.PATH + controllerRequestMappint + "0/toEdit");
40 57 }
... ... @@ -42,7 +59,7 @@
42 59 function edit(){
43 60 var id = getSingleSelectedValue("dataTable","id");
44 61 if(id){
45   - fullWindow("修改橘色", APP.PATH + controllerRequestMappint + id + "/toEdit");
  62 + fullWindow("修改角色", APP.PATH + controllerRequestMappint + id + "/toEdit");
46 63 }
47 64 }
48 65  
49 66  
50 67  
51 68  
... ... @@ -56,28 +73,32 @@
56 73 field: 'check_state',
57 74 title: '',
58 75 checkbox: true
59   - },{
60   - field: 'id',
61   - title: '编号'
62 76 }, {
63 77 field: 'name',
64 78 title: '角色名'
65 79 }, {
66 80 field: 'type',
67   - title: '角色类型'
68   - }, {
  81 + title: '角色类型',
  82 + formatter:function(value,row,index){
  83 + if(value == 0){
  84 + return '管理员'
  85 + }else{
  86 + return '用户';
  87 + }
  88 + }
  89 + },{
69 90 field: 'remarks',
70 91 title: '备注'
71 92 },{
72 93 field: 'orgId',
73 94 title: '机构id'
74 95 },{
75   - field: 'publishId',
76   - title: '发布人id'
77   - },{
78 96 field: 'enable',
79 97 title: '启/停用',
80 98 formatter:enableFormatter
  99 + },{
  100 + field: 'id',
  101 + title: '编号'
81 102 }];
82 103 </script>
83 104 #end
center.manager/src/main/webapp/WEB-INF/views/user/user_edit.html View file @ d70e57a
  1 +#override("css")
  2 +<link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css" />
  3 +#end
  4 +#override("js")
  5 +<script src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
  6 +<script type="text/javascript">
  7 +var reNodes = ${roleString};
  8 +</script>
  9 +<script>
  10 +var setting_resource = {
  11 + check: {
  12 + enable: true,
  13 + chkboxType: {
  14 + 'Y': 's',
  15 + 'N': 's'
  16 + }
  17 + },
  18 + view: {
  19 + dblClickExpand: false
  20 + },
  21 + data: {
  22 + simpleData: {
  23 + enable: true,
  24 + idKey: "role_id"
  25 + }
  26 + },
  27 + callback: {
  28 + beforeClick: beforeClick_resource,
  29 + onCheck: onCheck_resource
  30 + }
  31 +};
  32 +function beforeClick_resource(treeId, treeNode) {
  33 + var zTree = $.fn.zTree.getZTreeObj('tree_resource');
  34 + zTree.expandNode(treeNode);
  35 + zTree.checkNode(treeNode, !treeNode.checked, null, true);
  36 + return false;
  37 +}
  38 +function selectTreeNode_resource(id) {
  39 + var zTree = $.fn.zTree.getZTreeObj('tree_resource');
  40 + var node = zTree.getNodeByParam('id', id);
  41 + var pNode = node.getParentNode();
  42 + while (pNode != null) {
  43 + pNode = analParentNode(pNode, zTree);
  44 + }
  45 + zTree.cancelSelectedNode();
  46 + zTree.checkNode(node, true);
  47 + zTree.selectNode(node, true);
  48 +}
  49 +function analParentNode(node, zTree) {
  50 + zTree.expandNode(node, true);
  51 + var pNode = node.getParentNode();
  52 + if (pNode) {
  53 + return pNode;
  54 + }
  55 + return null;
  56 +}
  57 +function onClick_resource(e, treeId, treeNode) {
  58 + var zTree = $.fn.zTree.getZTreeObj('tree_resource');
  59 + zTree.expandNode(treeNode);
  60 + zTree.checkNode(treeNode, !treeNode.checked, null, true);
  61 + return false;
  62 +}
  63 +function onCheck_resource(e, treeId, treeNode) {
  64 + var zTree = $.fn.zTree.getZTreeObj('tree_resource'),
  65 + nodes = zTree.getCheckedNodes(true),
  66 + v_txt = '';
  67 + v_value = '';
  68 + v_type = '';
  69 + for (var i = 0,
  70 + l = nodes.length; i < l; i++) {
  71 + v_txt += nodes[i].name + ',';
  72 + v_value += nodes[i].id + ',';
  73 + if (nodes[i].type) {
  74 + v_type += nodes[i].type + ',';
  75 + }
  76 + }
  77 + if (v_txt.length > 0) {
  78 + v_txt = v_txt.substring(0, v_txt.length - 1);
  79 + v_value = v_value.substring(0, v_value.length - 1);
  80 + v_type = v_type.substring(0, v_type.length - 1);
  81 + }
  82 + $('#resource').attr('value', v_value);
  83 + $('#resource_txt').attr('value', v_txt);
  84 + $('#resource_type').attr('value', v_type);
  85 +}
  86 +var zNodes_resource = null;
  87 +var zTree_selectMode_resource = 'all';
  88 +$(function() {
  89 + zNodes_resource = reNodes;
  90 + var zTree = $.fn.zTree.init($('#tree_resource'), setting_resource, zNodes_resource);
  91 +
  92 + //初始化勾选
  93 + var rpValues = $('#resource').val();
  94 + if(rpValues.length > 0){
  95 + var rpArray = rpValues.split(",");
  96 + for(var i = 0 ; i < rpArray.length ;i++){
  97 + var node = zTree.getNodeByParam('id',rpArray[i]);
  98 + if(node != null){
  99 + zTree.checkNode(node,true,true);
  100 + }
  101 + }
  102 + }
  103 +});
  104 +
  105 +</script>
  106 +#end
1 107 #override("body")
2 108 <div class="ibox float-e-margins">
3 109 <div class="ibox-content">
4   - <form id="validForm" class="form-horizontal m-t" novalidate="novalidate">
5   - <input id="resource" name="resource" type="hidden" value="$!rolePermissions"/>
6   - <input type="hidden" id="role.id" name="id" value="$!role.id"/>
  110 + <div class="col-sm-4">
  111 + <form id="validForm" class="form-horizontal m-t" novalidate="novalidate">
  112 + <input id="resource" name="roles" type="hidden" value="$!userRoles"/>
  113 + <input type="hidden" id="user.id" name="id" value="$!user.id"/>
7 114 <div class="form-group">
8 115 <label class="col-sm-3 control-label">账号:</label>
9 116 <div class="col-sm-8">
10 117 <input type="text" placeholder="登录账号" value="$!user.account" aria-required="true" required="true" class="form-control" minlength="2" name="account" id="account">
11 118 </div>
12   - </div>
  119 + </div>
13 120 <div class="form-group">
14 121 <label class="col-sm-3 control-label">用户姓名:</label>
15 122 <div class="col-sm-8">
16 123  
... ... @@ -19,13 +126,13 @@
19 126 <div class="form-group">
20 127 <label class="col-sm-3 control-label">密码:</label>
21 128 <div class="col-sm-8">
22   - <input type="text" placeholder="登录密码" value="" #if("$!user.id" == "") aria-required="true" required="true" minlength="2" #end class="form-control" name="pwd" id="pwd">
  129 + <input type="password" placeholder="登录密码" value="" #if("$!user.id" == "") aria-required="true" required="true" minlength="2" #end class="form-control" name="pwd" id="pwd">
23 130 </div>
24 131 </div>
25 132 <div class="form-group">
26 133 <label class="col-sm-3 control-label">手机号:</label>
27 134 <div class="col-sm-8">
28   - <input type="text" placeholder="手机号" value="$!user.phone" aria-required="true" required="true" class="form-control" minlength="2" name="phone" id="phone">
  135 + <input type="text" placeholder="手机号" value="$!user.phone" aria-required="true" required="true" class="form-control" minlength="11" maxlength="11" name="phone" id="phone">
29 136 </div>
30 137 </div>
31 138 <div class="form-group">
32 139  
... ... @@ -51,11 +158,11 @@
51 158 <div class="col-sm-8">
52 159 <label class="checkbox-inline i-checks">
53 160 <div class="icheckbox_square-green" style="position: relative;">
54   - <input type="checkbox" value="1" name="enable" #if ($user.enable == 1) checked="checked" #end
  161 + <input type="checkbox" value="0" name="enable" #if ($user.enable == 0) checked="checked" #end
55 162 style="position: absolute; opacity: 0;" >
56 163 <ins class="iCheck-helper"
57 164 style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
58   - </div>是否可用(选中可用,不选中不可用)
  165 + </div>是否禁用(选中禁用,不选中可用)
59 166 </label>
60 167 </div>
61 168 </div>
... ... @@ -80,6 +187,12 @@
80 187 </div>
81 188 </div>
82 189 </form>
  190 + </div>
  191 + <div class="col-sm-6">
  192 + <div id="treeContent_resource" class="menuContent">
  193 + <ul id="tree_resource" class="ztree" style="margin-top:0; width:180px; height: 250px;"></ul>
  194 + </div>
  195 + </div>
83 196 </div>
84 197 </div>
85 198 <script type="text/javascript">
center.manager/src/main/webapp/WEB-INF/views/user/user_list.html View file @ d70e57a
... ... @@ -3,17 +3,20 @@
3 3 <div class="col-sm-10">
4 4 <div style="padding-top:30px;">
5 5 <form role="form" class="form-inline">
  6 + <div class="form-group">
  7 + <input type="text" placeholder="登录账号" id="searchAccount" class="form-control">
  8 + </div>
6 9 <div class="form-group">
7   - <input type="text" placeholder="请输入用户名" id="usernameSearch" class="form-control">
  10 + <input type="text" placeholder="用户姓名" id="searchName" class="form-control">
8 11 </div>
9 12 <div class="form-group">
10   - <input type="text" placeholder="请输入ID" id="idSearch" class="form-control">
  13 + <input type="text" placeholder="手机号" id="searchPhone" class="form-control">
11 14 </div>
12 15 </form>
13 16 </div>
14 17 </div>
15 18 <div class="col-sm-2">
16   - <div class="title-action">
  19 + <div class="title-action" onclick="search();">
17 20 <a class="btn btn-primary"><i class="fa fa-search"></i> 查询</a>
18 21 </div>
19 22 </div>
... ... @@ -34,6 +37,16 @@
34 37 #override("js")
35 38 <script type="text/javascript">
36 39 var controllerRequestMappint = "/sysUsers/";
  40 +function search(){
  41 + var queryParams = {
  42 + query:{
  43 + name: $("#searchName").val(),
  44 + account: $("#searchAccount").val(),
  45 + phone: $("#searchPhone").val()
  46 + }
  47 + }
  48 + $('#dataTable').bootstrapTable('refresh', queryParams );
  49 +}
37 50  
38 51 function add() {
39 52 fullWindow("新增用户", APP.PATH + controllerRequestMappint + "0/toEdit");
40 53  
41 54  
... ... @@ -57,25 +70,12 @@
57 70 title: '',
58 71 checkbox: true
59 72 },{
60   - field: 'id',
61   - title: '编号'
  73 + field: 'name',
  74 + title: '姓名'
62 75 },{
63   - field: 'type',
64   - title: '类型',
65   - formatter:function(value,row,index){
66   - if(value == 0){
67   - return '管理员'
68   - }else{
69   - return '用户';
70   - }
71   - }
72   - }, {
73 76 field: 'account',
74 77 title: '帐号'
75 78 },{
76   - field: 'name',
77   - title: '姓名'
78   - },{
79 79 field: 'orgId',
80 80 title: '机构'
81 81 },{
82 82  
... ... @@ -85,9 +85,22 @@
85 85 field: 'phone',
86 86 title: '手机号'
87 87 },{
  88 + field: 'type',
  89 + title: '类型',
  90 + formatter:function(value,row,index){
  91 + if(value == 0){
  92 + return '管理员'
  93 + }else{
  94 + return '用户';
  95 + }
  96 + }
  97 + },{
88 98 field: 'enable',
89 99 title: '启/停用',
90 100 formatter:enableFormatter
  101 + },{
  102 + field: 'id',
  103 + title: '编号'
91 104 }];
92 105 </script>
93 106 #end
center.manager/src/test/java/center/manager/test/user/UserTest.java View file @ d70e57a
... ... @@ -23,14 +23,14 @@
23 23 public void init() {
24 24 user = new SysUsers();
25 25 // user.setId(UUID.randomUUID().toString().replaceAll("-", ""));
26   - user.setName("欧阳拉闸");
  26 + user.setName("fdfjsdlf");
27 27 user.setExpirTime(new Date());
28 28 user.setPhone("18682531229");
29 29 }
30 30  
31 31 @Test
32 32 public void addUserTest() {
33   - boolean tag = userService.addUser(user);
  33 + boolean tag = userService.addUser(user,null);
34 34 System.out.println(tag);
35 35 Assert.assertTrue("添加成功", tag);
36 36 }
37 37  
... ... @@ -40,15 +40,11 @@
40 40  
41 41 SysUsers user = userService.selectById("6204903E7E1741688350349EF920ED88");
42 42 user.setName("hellow");
43   - boolean tag = userService.updateUser(user);
  43 + boolean tag = userService.updateUser(user,null );
44 44 System.out.println(tag);
45 45 }
46 46  
47   - @Test
48   - public void enableUserTest() {
49   - boolean tag = userService.enabled("6204903E7E1741688350349EF920ED88");
50   - System.out.println(tag);
51   - }
  47 +
52 48  
53 49 @Test
54 50 public void selectUserByPage() {