This commit is contained in:
parent
ef292505e3
commit
58f8115485
|
|
@ -199,6 +199,12 @@ public class AnnouncementController {
|
|||
return service.getCompanyProTree(o);
|
||||
}
|
||||
@LogAnnotation
|
||||
@PostMapping("getPersonTree")
|
||||
@ApiOperation(value = "公司-项目部-人员树")
|
||||
public List<TreeBean> getPersonTree(TreeBean o) {
|
||||
return service.getPersonTree(o);
|
||||
}
|
||||
@LogAnnotation
|
||||
@PostMapping("personTree")
|
||||
@ApiOperation(value = "系统公告-公司-回显人员树")
|
||||
public List<TreeBean> personTree(TreeBean o) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import com.bonus.leader.performance.manager.manager.config.ConstantConfig;
|
||||
import com.bonus.leader.performance.manager.manager.dao.RoleDao;
|
||||
import com.bonus.leader.performance.manager.manager.entity.RoleDto;
|
||||
import com.bonus.leader.performance.manager.manager.entity.TreeBean;
|
||||
import com.bonus.leader.performance.manager.manager.model.Role;
|
||||
import com.bonus.leader.performance.manager.manager.model.RoleBean;
|
||||
import com.bonus.leader.performance.manager.manager.table.PageTableHandler;
|
||||
|
|
@ -16,6 +17,7 @@ import com.bonus.leader.performance.manager.manager.service.RoleService;
|
|||
import com.bonus.leader.performance.manager.manager.utils.AjaxRes;
|
||||
import com.bonus.leader.performance.manager.manager.utils.GlobalConst;
|
||||
import com.bonus.leader.performance.manager.manager.utils.R;
|
||||
import com.bonus.leader.performance.manager.manager.utils.StringHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -27,6 +29,8 @@ import com.google.common.collect.Maps;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import javax.xml.rpc.holders.StringHolder;
|
||||
|
||||
/**
|
||||
* 角色相关接口
|
||||
*
|
||||
|
|
@ -108,9 +112,10 @@ public class RoleController {
|
|||
@ApiOperation(value = "角色管理-列表查询")
|
||||
public R getNewRoleList(RoleBean o) {
|
||||
List<RoleBean> list = roleService.getNewRoleList(o);
|
||||
return list.size() > 0 ? R.okTable(list, list.size()) : R.failTable("暂无数据");
|
||||
return !list.isEmpty() ? R.okTable(list, list.size()) : R.failTable("暂无数据");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "addNewRoleData", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "角色-新增")
|
||||
|
|
@ -223,4 +228,73 @@ public class RoleController {
|
|||
}
|
||||
return ar;
|
||||
}
|
||||
@RequestMapping(value = "updateRolePersonData", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "角色-修改成员角色")
|
||||
@Transactional
|
||||
public AjaxRes updateRolePersonData(@RequestBody RoleBean bean) throws Exception {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
int cb = roleService.updateRolePersonData(bean);
|
||||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||||
if (cb > 0) {
|
||||
ar.setFailMsg(GlobalConst.INIT_SUCCEED);
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织人员树
|
||||
*/
|
||||
@LogAnnotation
|
||||
@PostMapping("getTree")
|
||||
@ApiOperation(value = "组织-人员树")
|
||||
public List<TreeBean> getTree(TreeBean o) {
|
||||
return roleService.getTree(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员列表
|
||||
*/
|
||||
@LogAnnotation
|
||||
@PostMapping("getPersonList")
|
||||
@ApiOperation(value = "角色管理-人员列表查询")
|
||||
public R getPersonList(RoleBean o) {
|
||||
List<RoleBean> list = roleService.getPersonList(o);
|
||||
return !list.isEmpty() ? R.okTable(list, list.size()) : R.failTable("暂无数据");
|
||||
}
|
||||
/**
|
||||
* 获取已经设置当前角色的人员id
|
||||
*/
|
||||
@RequestMapping(value = "getInitPersonId", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "角色-获取已经设置当前角色的人员id")
|
||||
@Transactional
|
||||
public AjaxRes getInitPersonId(TreeBean bean){
|
||||
AjaxRes ar = new AjaxRes();
|
||||
String result = roleService.getInitPersonId(bean);
|
||||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||||
if (StringHelper.isNotEmpty(result)) {
|
||||
Map<String, Object> map = new HashMap<>(100);
|
||||
map.put("result", result);
|
||||
ar.setSucceed(map, GlobalConst.INIT_SUCCEED);
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除角色下的人员
|
||||
*/
|
||||
@LogAnnotation
|
||||
@PostMapping("delPersonById")
|
||||
@ApiOperation(value = "角色-根据ID删除角色下的人员")
|
||||
public AjaxRes delPersonById(RoleBean bean) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
int result = roleService.delPersonById(bean);
|
||||
if (result > 0) {
|
||||
ar.setSucceedMsg(GlobalConst.DATA_SUCCEED);
|
||||
} else {
|
||||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public class UserController {
|
|||
return ar;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getListPerson", method = RequestMethod.POST)
|
||||
@PostMapping("getListPerson")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "个人信息-查询")
|
||||
public AjaxRes getListPerson(){
|
||||
|
|
@ -238,10 +238,10 @@ public class UserController {
|
|||
return ar;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "updateMyInfo", method = RequestMethod.POST)
|
||||
@PostMapping( "updateMyInfo")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "个人信息-修改")
|
||||
public AjaxRes updateMyInfo(@RequestBody SysUser bean) throws Exception {
|
||||
public AjaxRes updateMyInfo(@RequestBody SysUser bean){
|
||||
AjaxRes ar = new AjaxRes();
|
||||
int cb = userService.updateMyInfo(bean);
|
||||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||||
|
|
@ -251,7 +251,7 @@ public class UserController {
|
|||
return ar;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getListById", method = RequestMethod.POST)
|
||||
@PostMapping("getListById")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "用户管理-查询人员信息")
|
||||
public AjaxRes getListById(String id){
|
||||
|
|
@ -270,11 +270,8 @@ public class UserController {
|
|||
@LogAnnotation
|
||||
@PostMapping("delById")
|
||||
@ApiOperation(value = "用户管理-删除")
|
||||
public AjaxRes delById(SysUser bean) throws Exception {
|
||||
public AjaxRes delById(SysUser bean) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
//删除之前先查询出来
|
||||
Long userId = bean.getId();
|
||||
SysUser userDto = userDao.getEyId(userId);
|
||||
int result = userService.delById(bean);
|
||||
if(result==1){
|
||||
ar.setSucceedMsg(GlobalConst.DATA_SUCCEED);
|
||||
|
|
@ -314,17 +311,17 @@ public class UserController {
|
|||
@LogAnnotation
|
||||
@PostMapping("delLeaderById")
|
||||
@ApiOperation(value = "公司领导设置-删除")
|
||||
public AjaxRes delLeaderById(LeaderBean bean) throws Exception {
|
||||
public AjaxRes delLeaderById(LeaderBean bean) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
userService.delLeaderById(bean);
|
||||
ar.setSucceedMsg(GlobalConst.DATA_SUCCEED);
|
||||
return ar;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "insertLeaderData", method = RequestMethod.POST)
|
||||
@PostMapping("insertLeaderData")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "用户管理-选择领导")
|
||||
public AjaxRes insertLeaderData(@RequestBody SysUser bean) throws Exception {
|
||||
public AjaxRes insertLeaderData(@RequestBody SysUser bean){
|
||||
AjaxRes ar = new AjaxRes();
|
||||
int cb = userService.insertLeaderData(bean);
|
||||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||||
|
|
|
|||
|
|
@ -174,5 +174,11 @@ public interface AnnouncementDao {
|
|||
* @return
|
||||
*/
|
||||
AskLeaveBean getAccrossStartData(AskLeaveBean o);
|
||||
/**
|
||||
* 获取人员树
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
List<TreeBean> getPersonTreeForLeader(TreeBean o);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.bonus.leader.performance.manager.manager.entity.RoleDto;
|
||||
import com.bonus.leader.performance.manager.manager.entity.TreeBean;
|
||||
import com.bonus.leader.performance.manager.manager.model.Role;
|
||||
import com.bonus.leader.performance.manager.manager.model.RoleBean;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
|
@ -162,9 +163,34 @@ public interface RoleDao {
|
|||
int insertRolePersonData(String roleId, String id);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param roleId
|
||||
* @param id
|
||||
* 根据id删除数据
|
||||
* @param roleId 角色id
|
||||
* @param id 人员id
|
||||
*/
|
||||
void deleteRoleUserId(String roleId, String id);
|
||||
/**
|
||||
* 获取组织人员数
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
List<TreeBean> getTree(TreeBean o);
|
||||
/**
|
||||
* 获取成员列表数据
|
||||
* @param o RoleBean
|
||||
* @return List<RoleBean>
|
||||
*/
|
||||
List<RoleBean> getPersonList(RoleBean o);
|
||||
/**
|
||||
* 获取已经设置当前角色的人员id
|
||||
* @param bean TreeBean
|
||||
* @return String
|
||||
*/
|
||||
String getInitPersonId(TreeBean bean);
|
||||
|
||||
/**
|
||||
* 根据ID删除角色下的人员
|
||||
* @param roleId 角色id
|
||||
* @param userId 人员id
|
||||
*/
|
||||
void updateSysUser(String roleId, String userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import lombok.Data;
|
|||
public class TreeBean {
|
||||
private String id;
|
||||
private String title;
|
||||
private String value;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private String level;
|
||||
private String subId;
|
||||
|
|
@ -21,4 +23,5 @@ public class TreeBean {
|
|||
private String personType;
|
||||
private String type;
|
||||
private String parentName;
|
||||
private String roleId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ public class RoleBean {
|
|||
private String roleId;
|
||||
private String userId;
|
||||
private String name;
|
||||
private String postName;
|
||||
private String description;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
private String status;
|
||||
private String membersNum;
|
||||
private String dataPermissions;
|
||||
private String keyWord;
|
||||
private String roleLevel;
|
||||
private String personNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,4 +116,11 @@ public interface AnnouncementService {
|
|||
* @return
|
||||
*/
|
||||
List<AskLeaveBean> getAskLeaveList(AskLeaveBean o);
|
||||
|
||||
/**
|
||||
* 获取人员树
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
List<TreeBean> getPersonTree(TreeBean o);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.leader.performance.manager.manager.service;
|
||||
|
||||
import com.bonus.leader.performance.manager.manager.entity.RoleDto;
|
||||
import com.bonus.leader.performance.manager.manager.entity.TreeBean;
|
||||
import com.bonus.leader.performance.manager.manager.model.RoleBean;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -26,4 +27,34 @@ public interface RoleService {
|
|||
int updateRoleLevel(RoleDto bean);
|
||||
|
||||
int insertRolePersonData(RoleBean bean);
|
||||
|
||||
/**
|
||||
* 获取组织人员树
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
List<TreeBean> getTree(TreeBean o);
|
||||
|
||||
/**
|
||||
* 获取成员列表数据
|
||||
* @param o RoleBean
|
||||
* @return List<RoleBean>
|
||||
*/
|
||||
List<RoleBean> getPersonList(RoleBean o);
|
||||
|
||||
/**
|
||||
* 获取已经设置当前角色的人员id
|
||||
* @param bean TreeBean
|
||||
* @return String
|
||||
*/
|
||||
String getInitPersonId(TreeBean bean);
|
||||
|
||||
/**
|
||||
* 根据ID删除角色下的人员
|
||||
* @param bean RoleBean
|
||||
* @return int
|
||||
*/
|
||||
int delPersonById(RoleBean bean);
|
||||
|
||||
int updateRolePersonData(RoleBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,4 +173,13 @@ public class AnnouncementServiceImpl implements AnnouncementService {
|
|||
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 获取人员树
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
@Override
|
||||
public List<TreeBean> getPersonTree(TreeBean o) {
|
||||
return dao.getPersonTreeForLeader(o);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.leader.performance.manager.manager.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
import com.bonus.leader.performance.manager.manager.dao.RoleDao;
|
||||
import com.bonus.leader.performance.manager.manager.entity.TreeBean;
|
||||
import com.bonus.leader.performance.manager.manager.model.Role;
|
||||
import com.bonus.leader.performance.manager.manager.model.RoleBean;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -137,14 +138,63 @@ public class RoleServiceImpl implements RoleService {
|
|||
String[] userIdArr = userId.split(",");
|
||||
int code = 0;
|
||||
for (String id : userIdArr) {
|
||||
id = id.replace("p","");
|
||||
int num = roleDao.getIsExistRelation(bean.getRoleId(), id);
|
||||
if (num > 0){
|
||||
roleDao.deleteRoleUserId(bean.getRoleId(), id);
|
||||
code = roleDao.insertRolePersonData(bean.getRoleId(), id);
|
||||
}else {
|
||||
code = roleDao.insertRolePersonData(bean.getRoleId(), id);
|
||||
}
|
||||
roleDao.updateSysUser(bean.getRoleId(), id);
|
||||
code = roleDao.insertRolePersonData(bean.getRoleId(), id);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
/**
|
||||
* 获取组织人员数
|
||||
* @param o TreeBean
|
||||
* @return List<TreeBean>
|
||||
*/
|
||||
@Override
|
||||
public List<TreeBean> getTree(TreeBean o) {
|
||||
return roleDao.getTree(o);
|
||||
}
|
||||
/**
|
||||
* 获取成员列表数据
|
||||
* @param o RoleBean
|
||||
* @return List<RoleBean>
|
||||
*/
|
||||
@Override
|
||||
public List<RoleBean> getPersonList(RoleBean o) {
|
||||
return roleDao.getPersonList(o);
|
||||
}
|
||||
/**
|
||||
* 获取已经设置当前角色的人员id
|
||||
* @param bean TreeBean
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getInitPersonId(TreeBean bean) {
|
||||
return roleDao.getInitPersonId(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除角色下的人员
|
||||
* @param bean RoleBean
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public int delPersonById(RoleBean bean) {
|
||||
String userId = bean.getUserId();
|
||||
String[] userIdArr = userId.split(",");
|
||||
for (String id : userIdArr) {
|
||||
roleDao.deleteRoleUserId(bean.getRoleId(), id);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRolePersonData(RoleBean bean) {
|
||||
roleDao.deleteRoleUserId(bean.getId(), bean.getUserId());
|
||||
roleDao.updateSysUser(bean.getId(), bean.getUserId());
|
||||
return roleDao.insertRolePersonData(bean.getRoleId(), bean.getUserId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
@Override
|
||||
public int delById(SysUser bean) {
|
||||
userDao.deleteUserRole(bean.getId());
|
||||
return userDao.delById(bean);
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +178,7 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
@Override
|
||||
public int setSort(LeaderBean bean) {
|
||||
int code = 0;
|
||||
int code;
|
||||
if(Integer.parseInt(bean.getOldSort()) > Integer.parseInt(bean.getSort())) {
|
||||
code = userDao.setOtherSort(bean);
|
||||
}else {
|
||||
|
|
@ -207,7 +208,7 @@ public class UserServiceImpl implements UserService {
|
|||
int code = 0;
|
||||
for (String id : userArr) {
|
||||
sort++;
|
||||
bean.setUserId(id);
|
||||
bean.setUserId(id.replace("p",""));
|
||||
bean.setSort(String.valueOf(sort));
|
||||
code = userDao.insertLeaderData(bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
values (#{fileName}, #{filePath}, #{userId}, #{userName})
|
||||
</insert>
|
||||
<insert id="addTreeChild">
|
||||
insert into sys_organization(org_name, parent_id, level, is_active, is_enable)
|
||||
values (#{title}, #{parentId}, #{level}, '1', '1')
|
||||
insert into sys_organization(org_name,parent_id,level,is_active,is_enable,org_type,leader_type)
|
||||
values(#{title},#{parentId},#{level},'1','1',#{type},#{personType})
|
||||
</insert>
|
||||
<update id="updateCateManage">
|
||||
update sys_data_dict
|
||||
|
|
@ -323,5 +323,28 @@
|
|||
|
||||
order by al.id asc limit 1
|
||||
</select>
|
||||
<select id="getPersonTreeForLeader"
|
||||
resultType="com.bonus.leader.performance.manager.manager.entity.TreeBean">
|
||||
SELECT
|
||||
id,
|
||||
org_name AS title,
|
||||
parent_id AS parentId,
|
||||
LEVEL,
|
||||
org_type AS type
|
||||
FROM
|
||||
sys_organization
|
||||
WHERE
|
||||
is_active = '1'
|
||||
AND is_enable = '1'
|
||||
union all
|
||||
select
|
||||
CONCAT('p',id) as id,
|
||||
username as title,
|
||||
org_id as parentId,
|
||||
'p' as level,
|
||||
'' as type
|
||||
from sys_user
|
||||
where is_active = '1' and `status`='1'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -16,11 +16,14 @@
|
|||
<update id="updateRolePersonData">
|
||||
update sys_role_user set userId = #{id} where roleId = #{roleId}
|
||||
</update>
|
||||
<update id="updateSysUser">
|
||||
update sys_user set role_id = #{roleId} where id = #{userId}
|
||||
</update>
|
||||
<delete id="delNewById">
|
||||
update sys_role set is_active = '0' where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteRoleUserId">
|
||||
delete from sys_role_user where roleId = #{roleId} and userId = #{id}
|
||||
delete from sys_role_user where userId = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="count" resultType="int">
|
||||
|
|
@ -37,8 +40,25 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getNewRoleList" resultType="com.bonus.leader.performance.manager.manager.model.RoleBean">
|
||||
select * from sys_role t
|
||||
where t.is_active = '1'
|
||||
SELECT
|
||||
t.id,
|
||||
t.`name`,
|
||||
t.`status`,
|
||||
t.description,
|
||||
t.create_time as createTime,
|
||||
count(sru.userId) as personNum,
|
||||
t.role_level as roleLevel
|
||||
FROM
|
||||
sys_role t
|
||||
left join sys_role_user sru on sru.roleId = t.id
|
||||
left join sys_user su on sru.userId = su.id and su.is_active = '1' and su.status = '1'
|
||||
WHERE
|
||||
t.is_active = '1'
|
||||
<if test="name != null and name != ''">
|
||||
and t.name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
GROUP BY t.id
|
||||
|
||||
</select>
|
||||
<select id="getRoleIdByName" resultType="java.lang.String">
|
||||
select id from sys_role t
|
||||
|
|
@ -46,10 +66,45 @@
|
|||
</select>
|
||||
<select id="getIsExistRelation" resultType="java.lang.Integer">
|
||||
select count(1) from sys_role_user t
|
||||
where t.roleId = #{roleId} and t.userId = #{id}
|
||||
where t.userId = #{id}
|
||||
</select>
|
||||
<select id="getTree" resultType="com.bonus.leader.performance.manager.manager.entity.TreeBean">
|
||||
SELECT
|
||||
id as value,
|
||||
parent_id as parentId,
|
||||
org_name as name,
|
||||
'0' as level
|
||||
FROM
|
||||
sys_organization
|
||||
where is_active = '1'
|
||||
UNION ALL
|
||||
select
|
||||
CONCAT('p',id)as value,
|
||||
org_id as parentId,
|
||||
username as name,
|
||||
'1' as level
|
||||
from
|
||||
sys_user
|
||||
where is_active = '1' and status = '1'
|
||||
</select>
|
||||
<select id="getPersonList" resultType="com.bonus.leader.performance.manager.manager.model.RoleBean">
|
||||
select u.username as name,o.org_name as postName,t.userId,t.roleId from sys_role_user t
|
||||
left join sys_user u on t.userId = u.id and u.is_active = '1' and u.status = '1'
|
||||
left join sys_organization o on u.org_id = o.id and o.is_active = '1'
|
||||
where t.roleId = #{roleId} and u.username is not null;
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and u.username like concat('%', #{keyWord}, '%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getInitPersonId" resultType="java.lang.String">
|
||||
SELECT
|
||||
GROUP_CONCAT('p',userId) as value
|
||||
|
||||
from sys_role_user
|
||||
where roleId = #{roleId}
|
||||
</select>
|
||||
|
||||
<insert id="saveRolePermission">
|
||||
<insert id="saveRolePermission">
|
||||
insert into sys_role_permission(roleId, permissionId) values
|
||||
<foreach collection="permissionIds" item="permissionId"
|
||||
separator=",">
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@
|
|||
<if test="roleId != null and roleId != ''">
|
||||
and t.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="orgId != null and orgId != ''">
|
||||
and t.org_id = #{orgId}
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
and t.org_id = #{departmentId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getEyId" resultType="com.bonus.leader.performance.manager.manager.model.SysUser">
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
order by sl.sort
|
||||
</select>
|
||||
<select id="getMaxLeaderSort" resultType="java.lang.Integer">
|
||||
select max(sort) from sys_leader where is_active = '1'
|
||||
select IFNULL(max(sort),-1) from sys_leader where is_active = '1'
|
||||
</select>
|
||||
|
||||
<insert id="saveUserRoles">
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
var oldKeyWord;
|
||||
var oldDepartment;
|
||||
var oldDepartmentId;
|
||||
var oldRoleId;
|
||||
var oldRoleName;
|
||||
let oldKeyWord;
|
||||
let oldDepartment;
|
||||
let oldDepartmentId;
|
||||
let oldRoleId;
|
||||
let laydate;
|
||||
let oldRoleName;
|
||||
layui.use(['table', 'layer', 'laydate', 'jquery', 'form','notice','layNotify'], function () {
|
||||
var table = layui.table;
|
||||
var laydate = layui.laydate;
|
||||
let form = layui.form;
|
||||
table = layui.table;
|
||||
laydate = layui.laydate;
|
||||
form = layui.form;
|
||||
notice = layui.notice;
|
||||
layNotify = layui.layNotify;
|
||||
|
||||
|
|
@ -183,10 +184,10 @@ function openForm(id,title){
|
|||
* 删除功能
|
||||
*/
|
||||
function del(id) {
|
||||
layer.confirm('确定要删除吗?', {
|
||||
var index = layer.confirm('确定要删除吗?', {
|
||||
btn : [ '确定', '取消' ]
|
||||
}, function() {
|
||||
ajaxCommonMethods('/users/delById',{'id': id},"删除成功","删除失败","1");
|
||||
ajaxCommonMethods('/users/delById',{'id': id},"删除成功","删除失败","1",index);
|
||||
layer.close(1);
|
||||
});
|
||||
}
|
||||
|
|
@ -197,7 +198,7 @@ function del(id) {
|
|||
* @param id
|
||||
*/
|
||||
function resetPassword(id){
|
||||
layer.prompt({
|
||||
var index = layer.prompt({
|
||||
formType: 0,
|
||||
value: '',
|
||||
title: '请输入重置后密码',
|
||||
|
|
@ -208,7 +209,7 @@ function resetPassword(id){
|
|||
thisTip('提示','密码过于简单,必须包含数字,特殊符号,大写或小写!','warning')
|
||||
return false;
|
||||
}
|
||||
ajaxCommonMethods('/users/resetPassword',{'id': id,'password':value},"重置成功","重置失败","1");
|
||||
ajaxCommonMethods('/users/resetPassword',{'id': id,'password':value},"重置成功","重置失败","1",index);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +303,7 @@ function clickRole(e, treeId, treeNode) {
|
|||
* @param error
|
||||
* @param type 1 父页面 2 子页面
|
||||
*/
|
||||
function ajaxCommonMethods(url, data, success, error, type) {
|
||||
function ajaxCommonMethods(url, data, success, error, type,index) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
|
|
@ -311,9 +312,25 @@ function ajaxCommonMethods(url, data, success, error, type) {
|
|||
dataType: 'json', // 服务器返回数据类型
|
||||
data: data, //获取提交的表单字段
|
||||
success: function (data) {
|
||||
layer.close(index)
|
||||
var resMsg = data.resMsg;
|
||||
if ("数据获取成功" == resMsg) {
|
||||
thisTip('提示', success, 'success');
|
||||
setTimeout(function (){
|
||||
table.reload('menuTable', {
|
||||
url: ctxPath + '/users/getUserList'
|
||||
, method: 'post' //方式默认是get
|
||||
, page: true
|
||||
, where: {
|
||||
username: "",
|
||||
keyWord: "",
|
||||
department: "",
|
||||
departmentId: "",
|
||||
roleId: ""
|
||||
} //设定异步数据接口的额外参数
|
||||
});
|
||||
|
||||
})
|
||||
} else {
|
||||
thisTip('提示', error, 'error');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form','notice', 'layNotify'],
|
|||
var id = data.id
|
||||
if (layEvent === 'sort') {
|
||||
//排序
|
||||
layer.prompt({
|
||||
var index = layer.prompt({
|
||||
formType: 0,
|
||||
value: '',
|
||||
title: '请输入排序序号',
|
||||
|
|
@ -67,7 +67,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form','notice', 'layNotify'],
|
|||
parentTip('提示',"序号必须是正整数!", "error");
|
||||
return false;
|
||||
}
|
||||
ajaxCommonMethods('/users/setSort',{'id': id,'sort':value,'oldSort':data.sort},"设置成功","设置失败","1");
|
||||
ajaxCommonMethods('/users/setSort',{'id': id,'sort':value,'oldSort':data.sort},"设置成功","设置失败","1",index);
|
||||
});
|
||||
} else if (layEvent === 'del') {
|
||||
del(id,data.sort);
|
||||
|
|
@ -128,16 +128,16 @@ function openForm(id, title) {
|
|||
* 删除功能
|
||||
*/
|
||||
function del(id,sort) {
|
||||
layer.confirm('确定要删除吗?', {
|
||||
var index = layer.confirm('确定要删除吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
ajaxCommonMethods('/users/delLeaderById', {'id': id,'sort':sort}, "删除成功", "删除失败", "1");
|
||||
ajaxCommonMethods('/users/delLeaderById', {'id': id,'sort':sort}, "删除成功", "删除失败", "1",index);
|
||||
layer.close(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function ajaxCommonMethods(url, data, success, error, type) {
|
||||
function ajaxCommonMethods(url, data, success, error, type,index) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
|
|
@ -146,6 +146,7 @@ function ajaxCommonMethods(url, data, success, error, type) {
|
|||
dataType: 'json', // 服务器返回数据类型
|
||||
data: data, //获取提交的表单字段
|
||||
success: function (data) {
|
||||
layer.close(index);
|
||||
var resMsg = data.resMsg;
|
||||
if ("数据获取成功" == resMsg) {
|
||||
parentTip('提示', success, "success");
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
padding: 0px 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
#dataTree2{
|
||||
max-width: 350px;
|
||||
width: auto !important;
|
||||
}
|
||||
</style>
|
||||
<body style="margin-left: 15px">
|
||||
<form class="layui-form" action="" onsubmit="return false">
|
||||
|
|
@ -71,7 +75,7 @@
|
|||
type: 'post',
|
||||
url: ctxPath + '/announcement/tree',//数据接口
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
async: true,
|
||||
async: false,
|
||||
data: {},
|
||||
success: function (data) {
|
||||
var result = [];
|
||||
|
|
@ -122,9 +126,7 @@
|
|||
content: "./organizationalForm.html",
|
||||
area: ['60%', '45%'],
|
||||
maxmin: false,
|
||||
end: function () {
|
||||
initData();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -141,9 +143,7 @@
|
|||
content: "./organizationalForm.html",
|
||||
area: ['60%', '45%'],
|
||||
maxmin: false,
|
||||
end: function () {
|
||||
initData();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
bottom: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
.layui-table-tool-temp{
|
||||
display: none !important;
|
||||
}
|
||||
/*.layui-input, .layui-textarea {*/
|
||||
/* display: block;*/
|
||||
/* width: 100% !important;*/
|
||||
|
|
@ -39,13 +42,14 @@
|
|||
<label class="layui-form-label"><i class="tip-required"
|
||||
style="color: red;font-size: 20px">*</i>角色名称:</label>
|
||||
<div class="layui-input-inline" style="width:50%">
|
||||
<input type="text" id="name" name="name" autocomplete="off" class="layui-input" lay-required="true"
|
||||
<input type="text" id="name" name="name" autocomplete="off" class="layui-input"
|
||||
lay-required="true"
|
||||
placeholder="请输入角色名称">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-top: 1%;">
|
||||
<label class="layui-form-label"><i class="tip-required"
|
||||
style="color: red;font-size: 20px">*</i>类型属性:</label>
|
||||
<label class="layui-form-label"><i class="tip-required"
|
||||
style="color: red;font-size: 20px">*</i>类型属性:</label>
|
||||
<div class="layui-input-inline" style="border: 0px dashed dimgrey;width: 74%;">
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="启用" checked>
|
||||
|
|
@ -55,7 +59,7 @@
|
|||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">角色描述:</label>
|
||||
<label class="layui-form-label">角色描述:</label>
|
||||
<div class="layui-input-inline" style="width:50%">
|
||||
<textarea class="layui-input" placeholder="输入内容" type="text" name="description" id="description"
|
||||
style="height: 94px;width: 100%;"></textarea>
|
||||
|
|
@ -114,23 +118,23 @@
|
|||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<form class="layui-form" action="" onsubmit="return false">
|
||||
<div class="layui-form-item" style="margin-bottom: 0px;">
|
||||
<div class="layui-form-item" style="margin-bottom: 0;">
|
||||
<div class="layui-inline" style="margin-top: 10px;">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="keyWord" placeholder="请输入姓名" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 70px;margin-top: 2px">
|
||||
<button id="searchBt" class="layui-btn layui-btn-sm">查询</button>
|
||||
<button id="personSearchBtn" class="layui-btn layui-btn-sm">查询</button>
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 70px;margin-top: 2px">
|
||||
<button id="addBt" class="layui-btn layui-btn-sm">添加人员</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="float: right;">
|
||||
<button id="selectAllBtn" class="layui-btn layui-btn">选择全部</button>
|
||||
<button id="reverseSelectBtn" class="layui-btn layui-btn">反向选择</button>
|
||||
<button id="delSelectBtn" class="layui-btn layui-btn">删除选择</button>
|
||||
<div style="float: right;margin-top: 10px;">
|
||||
<button id="selectAllBtn" class="layui-btn layui-btn-sm">选择全部</button>
|
||||
<button id="reverseSelectBtn" class="layui-btn layui-btn-sm">反向选择</button>
|
||||
<button id="delSelectBtn" class="layui-btn layui-btn-sm">删除选择</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -150,20 +154,28 @@
|
|||
<script type="text/javascript" src="../../js/dict.js"></script>
|
||||
<script type="text/javascript" src="../../js/libs/jquery.ztree.all-3.5.min.js"></script>
|
||||
<script type="text/javascript" src="../../js/my/ztree-menu.js"></script>
|
||||
<script type="text/html" id="toolsBar">
|
||||
<a lay-event="edit" style="color: #009688;cursor: pointer;font-size: 16px">编辑</a>
|
||||
<span> | </span>
|
||||
<a lay-event="del" style="color: #009688;cursor: pointer;font-size: 16px">删除</a>
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
var token = localStorage.getItem('token')
|
||||
var id = localStorage.getItem("roleId");
|
||||
var table;
|
||||
var tableIns;
|
||||
layui.use(['form','layer', 'laydate','notice','layNotify','table'], function () {
|
||||
let token = localStorage.getItem('token')
|
||||
let id = localStorage.getItem("roleId");
|
||||
let selectValue = [];
|
||||
var userValue = [];
|
||||
let table;
|
||||
let tableIns;
|
||||
layui.use(['form', 'layer', 'laydate', 'notice', 'layNotify', 'table'], function () {
|
||||
form = layui.form;
|
||||
notice = layui.notice;
|
||||
layNotify = layui.layNotify;
|
||||
table = layui.table;
|
||||
table = layui.table;
|
||||
form.render();
|
||||
form.verify({});
|
||||
if(id != ""){
|
||||
if (id !== "") {
|
||||
initData();
|
||||
}
|
||||
initPersonTable();
|
||||
|
|
@ -184,9 +196,63 @@
|
|||
data.field.id = id;
|
||||
updateLevel(data); //新增方法
|
||||
});
|
||||
$("#addBt").click(function (){
|
||||
$("#addBt").click(function () {
|
||||
openForm("", '添加人员');
|
||||
})
|
||||
$("#personSearchBtn").click(function () {
|
||||
table.reload('personTable', {
|
||||
url: ctxPath + '/roles/getPersonList'
|
||||
, method: 'post' //方式默认是get
|
||||
, page: true
|
||||
, where: {
|
||||
keyWord: $("#keyWord").val(),
|
||||
roleId : localStorage.getItem('roleId')
|
||||
} //设定异步数据接口的额外参数
|
||||
});
|
||||
})
|
||||
// 监听全选
|
||||
table.on('checkbox(test)', function (obj) {
|
||||
if (obj.type === 'all') {
|
||||
// 全选
|
||||
selectValue = [];
|
||||
if (obj.checked) {
|
||||
selectValue = userValue;
|
||||
}
|
||||
} else {
|
||||
// 单选
|
||||
if (obj.checked) {
|
||||
if (!selectValue.includes(obj.data.userId)) {
|
||||
selectValue.push(obj.data.userId);
|
||||
}
|
||||
} else {
|
||||
selectValue.splice(selectValue.indexOf(obj.data.userId), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#selectAllBtn").click(function () {
|
||||
selectValue = [];
|
||||
selectValue = userValue;
|
||||
console.log('selectValue'+ selectValue);
|
||||
// 重新渲染表格
|
||||
table.reload('personTable');
|
||||
})
|
||||
$("#reverseSelectBtn").click(function () {
|
||||
// 用于存储选中的值
|
||||
selectValue = userValue.filter(item => !selectValue.includes(item));
|
||||
table.reload('personTable');
|
||||
})
|
||||
$("#delSelectBtn").click(function (){
|
||||
var index = layer.confirm('确定要删除吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
ajaxCommonMethods('/roles/delPersonById', {
|
||||
'userId': selectValue.toString(),
|
||||
'roleId': localStorage.getItem('roleId')
|
||||
}, "删除成功", "删除失败", index);
|
||||
layer.close(index);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
//头监听事件 -- checkBox 选中行和选中条数
|
||||
|
|
@ -198,19 +264,19 @@
|
|||
console.log(eventName)
|
||||
switch (eventName) {
|
||||
case "searchBt":
|
||||
table.reload('menuTable', {
|
||||
table.reload('personTable', {
|
||||
url: ctxPath + '/users/getLeaderList'
|
||||
, method: 'post' //方式默认是get
|
||||
, page: true
|
||||
, where: {
|
||||
keyWord: $("#keyWord").val(),
|
||||
keyWord: $('#keyWord').val(),
|
||||
} //设定异步数据接口的额外参数
|
||||
});
|
||||
/**二次赋值-- 点击搜索按钮之后会进行一次刷新操作*/
|
||||
break;
|
||||
case "resetBt":
|
||||
$("#keyWord").val("");
|
||||
table.reload('menuTable', {
|
||||
table.reload('personTable', {
|
||||
url: ctxPath + '/users/getLeaderList'
|
||||
, method: 'post' //方式默认是get
|
||||
, page: true
|
||||
|
|
@ -228,33 +294,35 @@
|
|||
|
||||
|
||||
function openForm(id, title) {
|
||||
localStorage.setItem("roleName", $("#name").val());
|
||||
layerOpenForm(title, "./addUser.html", "70%", "85%")
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
* @param data
|
||||
*/
|
||||
function updateLevel(data) {
|
||||
var formUrl = ctxPath + "/roles/updateRoleLevel";
|
||||
var tip = '保存';
|
||||
if (id != null && id != "") {
|
||||
const formUrl = ctxPath + "/roles/updateRoleLevel";
|
||||
let tip = '保存';
|
||||
if (id != null && id !== "") {
|
||||
tip = '修改';
|
||||
}
|
||||
// 获取选中的值
|
||||
var selectedValue = '';
|
||||
var radios = document.getElementsByName('type');
|
||||
for (var i = 0; i < radios.length; i++) {
|
||||
let selectedValue = '';
|
||||
const radios = document.getElementsByName('type');
|
||||
for (let i = 0; i < radios.length; i++) {
|
||||
if (radios[i].checked) {
|
||||
selectedValue = radios[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var uploadData = {
|
||||
const uploadData = {
|
||||
level: selectedValue,
|
||||
id : id
|
||||
}
|
||||
id: id
|
||||
};
|
||||
// 加载提示
|
||||
var addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
const addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
|
|
@ -268,10 +336,10 @@
|
|||
dataType: 'json', // 服务器返回数据类型
|
||||
data: JSON.stringify(uploadData), //获取提交的表单字段
|
||||
success: function (data) {
|
||||
if (data.resMsg == "发起成功") {
|
||||
if (data.resMsg === "发起成功") {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + "提示", tip + "成功", "success");
|
||||
}else {
|
||||
} else {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + "提示", tip + "失败", "error");
|
||||
}
|
||||
|
|
@ -287,30 +355,30 @@
|
|||
* 上传角色信息
|
||||
* @param data
|
||||
*/
|
||||
function addBasicRoleData(data){
|
||||
var formUrl = ctxPath + "/roles/addNewRoleData";
|
||||
var tip = '保存';
|
||||
if (id != null && id != "") {
|
||||
function addBasicRoleData(data) {
|
||||
let formUrl = ctxPath + "/roles/addNewRoleData";
|
||||
let tip = '保存';
|
||||
if (id != null && id !== "") {
|
||||
formUrl = ctxPath + "/roles/updateNewRoleData";
|
||||
tip = '修改';
|
||||
}
|
||||
// 获取选中的值
|
||||
var selectedValue = '';
|
||||
var radios = document.getElementsByName('status');
|
||||
for (var i = 0; i < radios.length; i++) {
|
||||
let selectedValue = '';
|
||||
const radios = document.getElementsByName('status');
|
||||
for (let i = 0; i < radios.length; i++) {
|
||||
if (radios[i].checked) {
|
||||
selectedValue = radios[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var uploadData = {
|
||||
const uploadData = {
|
||||
status: selectedValue,
|
||||
name: $("#name").val(),
|
||||
description : $("#description").val(),
|
||||
id : id
|
||||
}
|
||||
description: $("#description").val(),
|
||||
id: id
|
||||
};
|
||||
// 加载提示
|
||||
var addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
const addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
|
|
@ -326,11 +394,11 @@
|
|||
success: function (data) {
|
||||
if (data.resMsg == "发起成功") {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
localStorage.setItem("roleId",data.obj.roleId);
|
||||
localStorage.setItem("roleId", data.obj.roleId);
|
||||
id = data.obj.roleId;
|
||||
$("#commit").css("display","none");
|
||||
$("#commit").css("display", "none");
|
||||
parentTip(tip + "提示", tip + "成功", "success");
|
||||
}else if (data.resMsg === "角色已存在") {
|
||||
} else if (data.resMsg === "角色已存在") {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip, data.resMsg, 'error');
|
||||
} else {
|
||||
|
|
@ -352,12 +420,12 @@
|
|||
function addPermission(formData) {
|
||||
var tip = '保存';
|
||||
var formUrl = ctxPath + "/roles/uploadPermission";
|
||||
if (id != '') {
|
||||
if (id !== '') {
|
||||
formUrl = ctxPath + "/roles/updatePermission";
|
||||
tip = '修改';
|
||||
}
|
||||
// 加载提示
|
||||
addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
let addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
|
|
@ -374,7 +442,7 @@
|
|||
if (data.resMsg === "发起成功") {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip, tip + '成功', 'success');
|
||||
}else {
|
||||
} else {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + "提示", tip + "失败", "success");
|
||||
}
|
||||
|
|
@ -385,11 +453,12 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化操作权限数据
|
||||
*/
|
||||
function initData() {
|
||||
if (id != "") {
|
||||
if (id !== "") {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: ctxPath + '/roles/' + id,
|
||||
|
|
@ -398,17 +467,17 @@
|
|||
$("#id").val(data.id);
|
||||
$("#name").val(data.name);
|
||||
$("#description").val(data.description);
|
||||
var radio = document.getElementsByName('status');
|
||||
let radio = document.getElementsByName('status');
|
||||
// 遍历单选框并根据值设置选中状态
|
||||
for (var i = 0; i < radio.length; i++) {
|
||||
for (let i = 0; i < radio.length; i++) {
|
||||
if (radio[i].value === data.status) {
|
||||
radio[i].checked = true; // 设置value为2的单选框为选中状态
|
||||
}
|
||||
}
|
||||
var radios = document.getElementsByName('type');
|
||||
// 遍历单选框并根据值设置选中状态
|
||||
for (var i = 0; i < radios.length; i++) {
|
||||
if (radios[i].value === data.level){
|
||||
for (let i = 0; i < radios.length; i++) {
|
||||
if (radios[i].value === data.level) {
|
||||
radios[i].checked = true; // 设置value为2的单选框为选中状态
|
||||
}
|
||||
}
|
||||
|
|
@ -421,32 +490,50 @@
|
|||
}
|
||||
|
||||
|
||||
function initPersonTable(){
|
||||
function initPersonTable() {
|
||||
//渲染表格
|
||||
tableIns = table.render({
|
||||
elem: '#personTable'
|
||||
, url: ctxPath + '/announcement/getAnnouncementList' //数据接口
|
||||
, url: ctxPath + '/roles/getPersonList' //数据接口
|
||||
|
||||
, method: 'post' //方式默认是get
|
||||
, toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
|
||||
, where: {} //post请求必须加where ,post请求需要的参数
|
||||
, where: {
|
||||
roleId: localStorage.getItem("roleId")
|
||||
} //post请求必须加where ,post请求需要的参数
|
||||
, cellMinWidth: 80
|
||||
, cols: [[ //表头
|
||||
{type: 'checkbox'}
|
||||
,{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'}
|
||||
, {field: 'number', width: 80, title: '序号', align: 'center', type: 'numbers'}
|
||||
, {field: 'name', align: 'center', title: '姓名'}
|
||||
, {field: 'postName', align: 'center', title: '组织岗位'}
|
||||
, {field: 'createTime', align: 'center', title: '添加时间'}
|
||||
, {fixed: 'right', title: '操作', align: 'center', toolbar: '#toolsBar'}
|
||||
]]
|
||||
, id: 'menuTable'
|
||||
, done: function (res) {
|
||||
$.each(res.data, function (index, val) {
|
||||
for (let mn of selectValue) {
|
||||
if (mn === val.userId) {
|
||||
$('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
|
||||
}
|
||||
}
|
||||
//刷新checkbox选择框渲染
|
||||
form.render('checkbox');
|
||||
});
|
||||
}
|
||||
, id: 'personTable'
|
||||
, page: true //开启分页
|
||||
, loading: true //数据加载中。。。
|
||||
, limits: [5, 10, 20] //一页选择显示3,5或10条数据
|
||||
, limits: [10, 20, 50] //一页选择显示3,5或10条数据
|
||||
, limit: 10 //一页显示5条数据
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据
|
||||
userValue = [];
|
||||
if (res.data !== '' && res.data != null && res.data !== "null") {
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
userValue.push(res.data[i].userId);
|
||||
}
|
||||
}
|
||||
let result;
|
||||
if (res.data !== '' && res.data != null && res.data !== "null") {
|
||||
if (this.page.curr) {
|
||||
|
|
@ -462,9 +549,55 @@
|
|||
"data": result, //解析数据列表
|
||||
};
|
||||
},
|
||||
toolbar: "#toolbar"
|
||||
});
|
||||
/**
|
||||
* 监听工具条
|
||||
*/
|
||||
table.on('tool(test)', function (obj) {
|
||||
let data = obj.data //获得当前行数据
|
||||
let layEvent = obj.event; //获得 lay-event 对应的值
|
||||
let userId = data.userId;
|
||||
if (layEvent === 'edit') {
|
||||
localStorage.setItem("userId", userId);
|
||||
localStorage.setItem("userName", data.name);
|
||||
localStorage.setItem("roleName", $("#name").val());
|
||||
layerOpenForm('修改', "./updateRole.html", "70%", "85%")
|
||||
} else if (layEvent === 'del') {
|
||||
var index = layer.confirm('确定要删除吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
ajaxCommonMethods('/roles/delPersonById', {
|
||||
'userId': userId,
|
||||
'roleId': localStorage.getItem('roleId')
|
||||
}, "删除成功", "删除失败", index);
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function ajaxCommonMethods(url, data, success, error, index) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
url: ctxPath + url,// 请求地址
|
||||
contentType: "application/x-www-form-urlencoded",
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
data: data, //获取提交的表单字段
|
||||
success: function (data) {
|
||||
layer.close(index);
|
||||
var resMsg = data.resMsg;
|
||||
if ("数据获取成功" === resMsg) {
|
||||
parentTip("提示", success, "success");
|
||||
setTimeout(function () {
|
||||
table.reload('personTable');
|
||||
}, 500);
|
||||
} else {
|
||||
parentTip("提示", error, "error");
|
||||
layer.msg(error, {icon: 2});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,31 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增角色---添加人员</title>
|
||||
<link rel="stylesheet" href="../../js/layui-v2.9.6/css/layui.css" media="all"/>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增角色---添加人员</title>
|
||||
<link rel="stylesheet" href="../../js/layui-v2.9.6/css/layui.css" media="all"/>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="" onsubmit="return false">
|
||||
<div class="layui-form-item" style="margin-top: 3%;">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label">角色名称:</label>
|
||||
<input type="text" name="roleName" lay-verify="required" style="width: 60%;"
|
||||
id="roleName" class="layui-input">
|
||||
<div class="layui-form-item" style="margin-top: 3%;">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label">角色名称:</label>
|
||||
<input type="text" name="roleName" lay-verify="required" style="width: 60%;"
|
||||
id="roleName" readonly disabled class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-top: 1%">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label"><i class="tip-required" style="color: red;font-size: 20px">*</i>选择用户:</label>
|
||||
<div id="selectUser" class="xm-select-demo" style="width: 60%;margin-left: 10%;"></div>
|
||||
<div class="layui-form-item" style="margin-top: 1%">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label"><i class="tip-required"
|
||||
style="color: red;font-size: 20px">*</i>选择用户:</label>
|
||||
<div id="selectUser" class="xm-select-demo" style="width: 60%;margin-left: 10%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: none">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
|
||||
</button>
|
||||
<div class="layui-form-item" style="display: none">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -38,96 +39,146 @@
|
|||
<script type="text/javascript" src="../../js/my/permission.js"></script>
|
||||
|
||||
<script>
|
||||
var roleId = localStorage.getItem("roleId");
|
||||
layui.use(['form','xmSelect'], function () {
|
||||
xmSelect = layui.xmSelect;
|
||||
form = layui.form;
|
||||
let roleId = localStorage.getItem("roleId");
|
||||
let roleName = localStorage.getItem("roleName");
|
||||
let currentXmSelect;
|
||||
let treeData;
|
||||
layui.use(['form', 'xmSelect'], function () {
|
||||
xmSelect = layui.xmSelect;
|
||||
form = layui.form;
|
||||
$("#roleName").val(roleName);
|
||||
form.on('submit(formDemo)', function () {
|
||||
addInfo(); //新增方法
|
||||
});
|
||||
|
||||
form.on('submit(formDemo)', function (data) {
|
||||
addInfo(); //新增方法
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: ctxPath + '/roles/getTree',//数据接口
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
async: true,
|
||||
data: {},
|
||||
success: function (data) {
|
||||
treeData = getTreeList(data, '0');
|
||||
treeData = getNewTreeData(treeData);
|
||||
currentXmSelect = xmSelect.render({
|
||||
el: '#selectUser',
|
||||
autoRow: true,
|
||||
tree: {
|
||||
show: true,
|
||||
showFolderIcon: true,
|
||||
showLine: true,
|
||||
indent: 20,
|
||||
expandedKeys: true,
|
||||
},
|
||||
toolbar: {
|
||||
show: true,
|
||||
list: ['ALL', 'REVERSE', 'CLEAR']
|
||||
},
|
||||
filterable: true,
|
||||
height: 'auto',
|
||||
data: treeData,
|
||||
})
|
||||
},
|
||||
error: function (err) {
|
||||
console.log("获取工程下拉列表出错:", err);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 获取已经设置该角色的人员进行赋值
|
||||
*/
|
||||
setTimeout(function () {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: ctxPath + '/roles/getInitPersonId',//数据接口
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
async: true,
|
||||
data: {
|
||||
roleId: roleId
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.resMsg === '发起成功'){
|
||||
currentXmSelect.setValue(data.obj.result.split(','));
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
console.log("获取工程下拉列表出错:", err);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#selectUser',
|
||||
autoRow: true,
|
||||
filterable: true,
|
||||
tree: {
|
||||
show: true,
|
||||
showFolderIcon: true,
|
||||
showLine: true,
|
||||
indent: 20,
|
||||
expandedKeys: [ -3 ],
|
||||
},
|
||||
toolbar: {
|
||||
show: true,
|
||||
list: ['ALL', 'REVERSE', 'CLEAR']
|
||||
},
|
||||
filterable: true,
|
||||
height: 'auto',
|
||||
data: function(){
|
||||
return [
|
||||
{name: '销售员', value: -1, disabled: true, children: [
|
||||
{name: '张三1', value: 1, selected: true, children: []},
|
||||
{name: '李四1', value: 2, selected: true},
|
||||
{name: '王五1', value: 3, disabled: true},
|
||||
]},
|
||||
{name: '奖品', value: -2, children: [
|
||||
{name: '奖品3', value: -3, children: [
|
||||
{name: '苹果3', value: 14, selected: true},
|
||||
{name: '香蕉3', value: 15},
|
||||
{name: '葡萄3', value: 16},
|
||||
]},
|
||||
{name: '苹果2', value: 4, selected: true, disabled: true},
|
||||
{name: '香蕉2', value: 5},
|
||||
{name: '葡萄2', value: 6},
|
||||
]},
|
||||
]
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function addInfo() {
|
||||
var selectUser = xmSelect.get('#selectUser', true);
|
||||
var selectUserArr = selectUser.getValue('value');
|
||||
var data = {
|
||||
roleId : roleId,
|
||||
userId: selectUserArr.toString()
|
||||
};
|
||||
if (selectUserArr.length === 0) {
|
||||
parentTip("提示", "请选择人员", "warning");
|
||||
return false;
|
||||
}
|
||||
var tip = '保存';
|
||||
var formUrl = ctxPath + "/roles/insertRolePersonData";
|
||||
// 加载提示
|
||||
addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
shade: [0.8, '#393D49']
|
||||
});
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
url: formUrl, // 请求地址
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
data: JSON.stringify(data), //获取提交的表单字段
|
||||
success: function (data) {
|
||||
if (data.resMsg === "发起成功") {
|
||||
parent.layer.closeAll();
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '成功', 'success');
|
||||
parent.tableIns.reload('personTable');
|
||||
}else {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '失败', 'error');
|
||||
function addInfo() {
|
||||
const selectUser = xmSelect.get('#selectUser', true);
|
||||
const selectUserArr = selectUser.getValue('value');
|
||||
const data = {
|
||||
roleId: roleId,
|
||||
userId: selectUserArr.toString()
|
||||
};
|
||||
if (roleId === null || roleId === '') {
|
||||
parentTip("提示", "角色ID为空,请先创建角色!", "warning");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, e) {
|
||||
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
}
|
||||
});
|
||||
}
|
||||
if (selectUserArr.length === 0) {
|
||||
parentTip("提示", "请选择人员", "warning");
|
||||
return false;
|
||||
}
|
||||
const tip = '保存';
|
||||
const formUrl = ctxPath + "/roles/insertRolePersonData";
|
||||
// 加载提示
|
||||
const addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
shade: [0.8, '#393D49']
|
||||
});
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
url: formUrl, // 请求地址
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
data: JSON.stringify(data), //获取提交的表单字段
|
||||
success: function (data) {
|
||||
if (data.resMsg === "发起成功") {
|
||||
parent.layer.closeAll();
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '成功', 'success');
|
||||
parent.initPersonTable();
|
||||
} else {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '失败', 'error');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getTreeList(rootList, id) {
|
||||
let List = [];
|
||||
for (let item of rootList) {
|
||||
if (item.parentId === id) {
|
||||
let newItem = { ...item, children: [] }; // 使用对象解构来创建一个新的对象,避免直接修改原始对象
|
||||
List.push(newItem);
|
||||
let ids = newItem.value;
|
||||
newItem.children = getTreeList(rootList, ids);
|
||||
}
|
||||
}
|
||||
return List;
|
||||
}
|
||||
|
||||
function getNewTreeData(dataList) {
|
||||
for (let i = dataList.length - 1; i >= 0; i--) {
|
||||
const item = dataList[i];
|
||||
if (item.children.length > 0 && item.level === '0') {
|
||||
getNewTreeData(item.children);
|
||||
} else if (item.children.length === 0 && item.level === '0') {
|
||||
dataList.splice(i, 1);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
</script>
|
||||
|
|
@ -80,18 +80,30 @@
|
|||
{field: 'number', title: '序号', align: 'center', type: 'numbers'}
|
||||
, {field: 'name', align: 'center', title: '角色名称'}
|
||||
, {
|
||||
field: 'status', align: 'center', title: '状态', template: function () {
|
||||
if (d.status === 1) {
|
||||
return '<span style="color: #5FB878;">启用</span>';
|
||||
field: 'status', align: 'center', title: '状态',width:80,templet: d => {
|
||||
if (d.status === '1') {
|
||||
return '<span><span class="layui-badge-dot layui-bg-green"></span>启用</span>';
|
||||
} else {
|
||||
return '<span style="color: #FF5722;">禁用</span>';
|
||||
return '<span><span class="layui-badge-dot"></span>禁用</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
, {field: 'personNum', align: 'center',width:130, title: '成员数量'}
|
||||
, {
|
||||
field: 'roleLevel', align: 'center', title: '数据权限', templet: d => {
|
||||
if (d.roleLevel === '1') {
|
||||
return '<span>只能操作自己和下属的数据</span>';
|
||||
} else if (d.roleLevel === '2') {
|
||||
return '<span>能操作自己、下属、和自己所属部门的数据</span>';
|
||||
} else if (d.roleLevel === '3') {
|
||||
return '<span>能操作自己、下属、和自己所属部门及其下属的数据</span>';
|
||||
} else if (d.roleLevel === '4') {
|
||||
return '<span>能操作全公司的数据</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
, {field: 'membersNum', align: 'center', title: '成员数量'}
|
||||
, {field: 'dataPermissions', align: 'center', title: '数据权限'}
|
||||
, {field: 'description', align: 'center', title: '角色描述'}
|
||||
, {field: 'updateTime', align: 'center', title: '更新时间'}
|
||||
, {field: 'createTime', align: 'center',width:150, title: '更新时间'}
|
||||
, {fixed: 'right', title: '操作', align: 'center', toolbar: '#toolsBar'}
|
||||
]],
|
||||
done: function () {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增角色---编辑人员权限</title>
|
||||
<link rel="stylesheet" href="../../js/layui-v2.9.6/css/layui.css" media="all"/>
|
||||
<style>
|
||||
|
||||
.layui-form-select .layui-edge {
|
||||
left: 67%;
|
||||
}
|
||||
.layui-input {
|
||||
width: 60%;
|
||||
}
|
||||
.layui-form-select dl {
|
||||
min-width: 60%;
|
||||
}
|
||||
.layui-form-select dl {
|
||||
position: absolute;
|
||||
left: 10.3%;
|
||||
top: 40px;
|
||||
padding: 5px 0;
|
||||
z-index: 899;
|
||||
min-width: 60%;
|
||||
border: 1px solid #eee;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 1px 1px 4px rgb(0 0 0 / 8%);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="" onsubmit="return false">
|
||||
<div class="layui-form-item" style="margin-top: 3%;">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label">用户名称:</label>
|
||||
<input type="text" name="userName" lay-verify="required" style="width: 60%;"
|
||||
id="userName" readonly disabled class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-top: 1%">
|
||||
<div class="layui-inline" style="width: 99%;">
|
||||
<label class="layui-form-label"><i class="tip-required"
|
||||
style="color: red;font-size: 20px">*</i>选择角色:</label>
|
||||
<select id="roleId" class="layui-select" name="roleId" lay-verify="required"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: none">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
<script src="../../js/jquery-3.6.0.js"></script>
|
||||
<script src="../../js/layui-v2.9.6/layui.js"></script>
|
||||
<script type="text/javascript" src="../../js/jq.js"></script>
|
||||
<script src="../../js/common_methon.js"></script>
|
||||
<script type="text/javascript" src="../../js/publicJs.js"></script>
|
||||
<script type="text/javascript" src="../../js/select.js"></script>
|
||||
<script type="text/javascript" src="../../js/my/permission.js"></script>
|
||||
|
||||
<script>
|
||||
let roleId = localStorage.getItem("roleId");
|
||||
let userId = localStorage.getItem("userId");
|
||||
let userName = localStorage.getItem("userName");
|
||||
let treeData;
|
||||
layui.use(['form'], function () {
|
||||
form = layui.form;
|
||||
$("#userName").val(userName);
|
||||
form.on('submit(formDemo)', function () {
|
||||
addInfo(); //新增方法
|
||||
});
|
||||
getRole(form,roleId);
|
||||
});
|
||||
|
||||
function addInfo() {
|
||||
const data = {
|
||||
roleId: $('#roleId').val(),
|
||||
id : localStorage.getItem('roleId'),
|
||||
userId: userId
|
||||
};
|
||||
if ($("#roleId").val() === "" || $("#roleId").val() === null) {
|
||||
parentTip("提示", "请先选择角色", "warning");
|
||||
return false;
|
||||
}
|
||||
const tip = '保存';
|
||||
const formUrl = ctxPath + "/roles/updateRolePersonData";
|
||||
// 加载提示
|
||||
const addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
shade: [0.8, '#393D49']
|
||||
});
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
async: false, // 默认异步true,false表示同步
|
||||
url: formUrl, // 请求地址
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
data: JSON.stringify(data), //获取提交的表单字段
|
||||
success: function (data) {
|
||||
if (data.resMsg === "发起成功") {
|
||||
parent.layer.closeAll();
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '成功', 'success');
|
||||
parent.initPersonTable();
|
||||
} else {
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
parentTip(tip + '提示', tip + '失败', 'error');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
|
||||
top.layer.close(addLoadingMsg); //再执行关闭
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>用户查询--公司领导设置</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="../../js/layui-v2.9.6/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="../../css/publicStyles.css">
|
||||
<link rel="stylesheet" href="../../css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
|
||||
<style>
|
||||
body {
|
||||
|
|
@ -142,13 +141,9 @@
|
|||
<div class="layui-input-inline" style="margin-top: 2px;margin-left: 1%;">
|
||||
<input type="text" id="keyWord" placeholder="用户名" autocomplete="off" class="layui-input" style="width: 100%">
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px">
|
||||
<div class="layui-inline" style="width: 20%;margin-top: 4px">
|
||||
<button id="searchBt" class="layui-btn layui-btn-sm" lay-event="searchBt">查询</button>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px;margin-left: 10px;">
|
||||
<button id="resetBt" class="layui-btn layui-btn-sm" lay-event="resetBt">重置</button>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px;margin-left: 10px;">
|
||||
<button id="addBtn" class="layui-btn layui-btn-sm" lay-event="addBtn" style="width:120px
|
||||
!important">添加公司领导</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
*/
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: ctxPath + '/announcement/tree',//数据接口
|
||||
url: ctxPath + '/announcement/getPersonTree',//数据接口
|
||||
dataType: 'json', // 服务器返回数据类型
|
||||
async: true,
|
||||
data: {},
|
||||
|
|
@ -130,8 +130,7 @@
|
|||
* 升序
|
||||
**/
|
||||
window.upSort = function () {
|
||||
debugger
|
||||
if(rightId.length == 0){
|
||||
if(rightId.length === 0){
|
||||
return;
|
||||
}
|
||||
// 获取元素在数组中的索引位置
|
||||
|
|
@ -146,16 +145,15 @@
|
|||
}
|
||||
$("#personDiv").empty();
|
||||
updatePerson();
|
||||
$("#" + upId).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$('#' + upId).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$("#" + upId).addClass("layui-btn layui-btn-primary layui-border-red");
|
||||
};
|
||||
/**
|
||||
* 降序
|
||||
**/
|
||||
window.downSort = function () {
|
||||
debugger
|
||||
// 获取元素在数组中的索引位置
|
||||
if(rightId.length == 0){
|
||||
if(rightId.length === 0){
|
||||
return;
|
||||
}
|
||||
var index = rightId.indexOf(downId);
|
||||
|
|
@ -170,7 +168,7 @@
|
|||
|
||||
$("#personDiv").empty();
|
||||
updatePerson();
|
||||
$("#" + downId).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$('#' + downId).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$("#" + downId).addClass(
|
||||
"layui-btn layui-btn-primary layui-border-red"
|
||||
);
|
||||
|
|
@ -183,7 +181,7 @@
|
|||
window.updatePerson = function () {
|
||||
let personDiv = $("#personDiv");
|
||||
personDiv.empty();
|
||||
if (rightData.length != 0) {
|
||||
if (rightData.length !== 0) {
|
||||
let html = "";
|
||||
rightData.forEach(function (item) {
|
||||
html +=
|
||||
|
|
@ -201,14 +199,14 @@
|
|||
}
|
||||
};
|
||||
}
|
||||
var upId = "";
|
||||
var downId = "";
|
||||
let upId = "";
|
||||
let downId = "";
|
||||
/**
|
||||
* 更改选择人员的颜色
|
||||
**/
|
||||
window.selectThis = function (obj) {
|
||||
var id = obj.getAttribute("value"); // 获取按钮的 value 属性,即 item.id
|
||||
var index = rightId.indexOf(parseInt(id));
|
||||
let id = obj.getAttribute("value"); // 获取按钮的 value 属性,即 item.id
|
||||
let index = rightId.indexOf(parseInt(id));
|
||||
if (index === rightId.length - 1) {
|
||||
$("#downSort").addClass("disabled-span");
|
||||
} else {
|
||||
|
|
@ -223,14 +221,14 @@
|
|||
downId = id;
|
||||
$("#personDiv").empty();
|
||||
updatePerson();
|
||||
$("#" + id).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$('#' + id).removeClass(); // 通过 ID 选择器找到对应的元素并移除
|
||||
$("#" + id).addClass("layui-btn layui-btn-primary layui-border-red");
|
||||
};
|
||||
|
||||
//右侧按钮组--删除事件
|
||||
window.deletePersonBtn = function (obj) {
|
||||
//获取当前选中的下标
|
||||
let index = rightData.findIndex((item) => item.id == obj);
|
||||
let index = rightData.findIndex((item) => item.id === obj);
|
||||
//从数组中根据下标移除,删除的长度为1
|
||||
rightData.splice(index, 1);
|
||||
rightId.splice(index, 1);
|
||||
|
|
@ -256,18 +254,20 @@
|
|||
} else {
|
||||
let title = childJson.title;
|
||||
let id = childJson.id;
|
||||
if (!rightData.some((item) => item.id === id)) {
|
||||
rightData.push({
|
||||
id: id,
|
||||
title: title,
|
||||
});
|
||||
if (!rightId.includes(id)) {
|
||||
rightId.push(id);
|
||||
if (childJson.level === 'p'){
|
||||
if (!rightData.some((item) => item.id === id)) {
|
||||
rightData.push({
|
||||
id: id,
|
||||
title: title,
|
||||
});
|
||||
if (!rightId.includes(id)) {
|
||||
rightId.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
console.log('error', "递归获取选择人员出错");
|
||||
}
|
||||
}
|
||||
$("#personDiv").empty();
|
||||
|
|
@ -284,7 +284,7 @@
|
|||
|
||||
function getTreeList(rootList, id, List) {
|
||||
for (let item of rootList) {
|
||||
if (item.parentId == id) {
|
||||
if (item.parentId === id) {
|
||||
let newItem = Object.assign({}, item); // 创建一个新的对象,避免直接修改原始对象
|
||||
newItem.spread = true;
|
||||
newItem.children = [];
|
||||
|
|
@ -302,17 +302,17 @@
|
|||
parentTip("提示", "请选择人员", "warning");
|
||||
return false;
|
||||
}
|
||||
var tip = '保存';
|
||||
var formUrl = ctxPath + "/users/insertLeaderData";
|
||||
let tip = '保存';
|
||||
let formUrl = ctxPath + "/users/insertLeaderData";
|
||||
// 加载提示
|
||||
addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
let addLoadingMsg = top.layer.msg('数据上传中,请稍候...', {
|
||||
icon: 16,
|
||||
scrollbar: false,
|
||||
time: 0,
|
||||
shade: [0.8, '#393D49']
|
||||
});
|
||||
|
||||
var formData = {
|
||||
let formData = {
|
||||
userId: rightId.toString(),
|
||||
};
|
||||
$.ajax({
|
||||
|
|
@ -339,4 +339,5 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>用户查询--用户列表</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="../../js/layui-v2.9.6/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="../../css/publicStyles.css">
|
||||
<link rel="stylesheet" href="../../css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
|
||||
<style>
|
||||
body {
|
||||
|
|
@ -147,7 +146,7 @@
|
|||
<div class="layui-input-inline" style="margin-top: 2px;margin-left: 1%;">
|
||||
<input type="text" id="keyWord" placeholder="用户名" autocomplete="off" class="layui-input" style="width: 100%">
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 276px;margin-left: 18px;">
|
||||
<div class="layui-input-inline" style="margin-top: 2px;width: 276px;margin-left: 18px;">
|
||||
<select id="roleId" class="layui-select" lay-search=""></select>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
|
|
@ -157,16 +156,10 @@
|
|||
<ul id="departmentTree" class="ztree accountOrgTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px">
|
||||
<div class="layui-inline" style="width: 30%;margin-top: 2px">
|
||||
<button id="searchBt" class="layui-btn layui-btn-sm" lay-event="searchBt">查询</button>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px;margin-left: 10px;">
|
||||
<button id="resetBt" class="layui-btn layui-btn-sm" lay-event="resetBt">重置</button>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 5%;margin-top: 4px;margin-left: 10px;">
|
||||
<button id="addBtn" class="layui-btn layui-btn-sm" lay-event="addBtn">新 增</button>
|
||||
</div>
|
||||
<div class="layui-inline" style="width: 10%;margin-top: 4px;margin-left: 10px;">
|
||||
<button id="leaderSetBtn" class="layui-btn layui-btn-sm" lay-event="leaderSetBtn" style="width:120px
|
||||
!important">公司领导设置
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue