会员使用系统的组织结构

This commit is contained in:
zhujj 2018-12-29 15:11:01 +08:00
parent b7b36301c0
commit 596bf815a1
12 changed files with 6 additions and 1203 deletions

View File

@ -1,153 +0,0 @@
package com.ruoyi.vip.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.util.ShiroUtils;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import com.ruoyi.vip.service.IVipDeptService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 部门信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/vip/dept")
public class VipDeptController extends BaseController
{
private String prefix = "vip/dept";
@Autowired
private IVipDeptService deptService;
@RequiresPermissions("vip:dept:view")
@GetMapping()
public String dept()
{
return prefix + "/dept";
}
@RequiresPermissions("vip:dept:list")
@GetMapping("/list")
@ResponseBody
public List<VipDept> list(VipDept dept)
{
List<VipDept> deptList = deptService.selectDeptList(dept);
return deptList;
}
/**
* 新增部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
/**
* 新增保存部门
*/
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("vip:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(VipDept dept)
{
dept.setCreateBy(ShiroUtils.getLoginName());
return toAjax(deptService.insertDept(dept));
}
/**
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
VipDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("");
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("vip:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(VipDept dept)
{
dept.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(deptService.updateDept(dept));
}
/**
* 删除
*/
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@RequiresPermissions("vip:dept:remove")
@PostMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
return error(1, "存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return error(1, "部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));
}
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(VipDept dept)
{
return deptService.checkDeptNameUnique(dept);
}
/**
* 选择部门树
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(deptId));
return prefix + "/tree";
}
/**
* 加载部门列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Map<String, Object>> treeData()
{
List<Map<String, Object>> tree = deptService.selectDeptTree();
return tree;
}
}

View File

@ -1,124 +0,0 @@
package com.ruoyi.vip.domain;
import com.ruoyi.common.base.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 部门表 sys_dept
*
* @author ruoyi
*/
public class VipDept extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 部门ID */
@Id
private Long deptId;
/** 父部门ID */
private Long parentId;
/** 祖级列表 */
private String parentIds;
/** 部门名称 */
private String deptName;
/** 显示顺序 */
private String orderNum;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 父部门名称 */
private String parentName;
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getParentIds() {
return parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
public String getDeptName()
{
return deptName;
}
public void setDeptName(String deptName)
{
this.deptName = deptName;
}
public String getOrderNum()
{
return orderNum;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getParentIds())
.append("deptName", getDeptName())
.append("orderNum", getOrderNum())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.vip.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -75,7 +76,7 @@ public class VipUser extends BaseEntity
private Date loginDate;
/** 部门对象 */
private VipDept dept;
private SysDept dept;
public Long getId() {
@ -226,12 +227,12 @@ public class VipUser extends BaseEntity
this.loginDate = loginDate;
}
public VipDept getDept()
public SysDept getDept()
{
return dept;
}
public void setDept(VipDept dept)
public void setDept(SysDept dept)
{
this.dept = dept;
}

View File

@ -1,96 +0,0 @@
package com.ruoyi.vip.mapper;
import com.ruoyi.framework.web.base.MyMapper;
import com.ruoyi.vip.domain.VipDept;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 部门管理 数据层
*
* @author ruoyi
*/
public interface VipDeptMapper extends MyMapper<VipDept>
{
/**
* 查询部门人数
*
* @param dept 部门信息
* @return 结果
*/
public int selectDeptCount(VipDept dept);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
public int checkDeptExistUser(Long deptId);
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<VipDept> selectDeptList(VipDept dept);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 新增部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int insertDept(VipDept dept);
/**
* 修改部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int updateDept(VipDept dept);
/**
* 修改子元素关系
*
* @param depts 子元素
* @return 结果
*/
public int updateDeptChildren(@Param("depts") List<VipDept> depts);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public VipDept selectDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param deptName 部门名称
* @param parentId 父部门ID
* @return 结果
*/
public VipDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
/**
* 根据角色ID查询部门
*
* @param roleId 角色ID
* @return 部门列表
*/
public List<String> selectRoleDeptTree(Long roleId);
}

View File

@ -1,89 +0,0 @@
package com.ruoyi.vip.service;
import com.ruoyi.framework.web.base.AbstractBaseService;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import java.util.List;
import java.util.Map;
/**
* 部门管理 服务层
*
* @author ruoyi
*/
public interface IVipDeptService extends AbstractBaseService<VipDept>
{
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<VipDept> selectDeptList(VipDept dept);
/**
* 查询部门管理树
*
* @return 所有部门信息
*/
public List<Map<String, Object>> selectDeptTree();
/**
* 查询部门人数
*
* @param parentId 父部门ID
* @return 结果
*/
public int selectDeptCount(Long parentId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
public boolean checkDeptExistUser(Long deptId);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int insertDept(VipDept dept);
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int updateDept(VipDept dept);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public VipDept selectDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
public String checkDeptNameUnique(VipDept dept);
}

View File

@ -1,193 +0,0 @@
package com.ruoyi.vip.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import com.ruoyi.vip.mapper.VipDeptMapper;
import com.ruoyi.vip.service.IVipDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 部门管理 服务实现
*
* @author ruoyi
*/
@Service
public class VipDeptServiceImpl extends AbstractBaseServiceImpl<VipDeptMapper, VipDept> implements IVipDeptService {
@Autowired
private VipDeptMapper deptMapper;
/**
* 查询部门管理数据
*
* @return 部门信息集合
*/
@Override
@DataScope(tableAlias = "d")
public List<VipDept> selectDeptList(VipDept dept) {
return mapper.selectDeptList( dept );
}
/**
* 查询部门管理树
*
* @return 所有部门信息
*/
@Override
public List<Map<String, Object>> selectDeptTree() {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<VipDept> deptList = selectDeptList( new VipDept() );
trees = getTrees( deptList, false, null );
return trees;
}
/**
* 对象转部门树
*
* @param deptList 部门列表
* @param isCheck 是否需要选中
* @param roleDeptList 角色已存在菜单列表
* @return
*/
public List<Map<String, Object>> getTrees(List<VipDept> deptList, boolean isCheck, List<String> roleDeptList) {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (VipDept dept : deptList) {
if (UserConstants.DEPT_NORMAL.equals( dept.getDelFlag() )) {
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put( "id", dept.getDeptId() );
deptMap.put( "pId", dept.getParentId() );
deptMap.put( "name", dept.getDeptName() );
deptMap.put( "title", dept.getDeptName() );
if (isCheck) {
deptMap.put( "checked", roleDeptList.contains( dept.getDeptId() + dept.getDeptName() ) );
} else {
deptMap.put( "checked", false );
}
trees.add( deptMap );
}
}
return trees;
}
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
@Override
public int selectDeptCount(Long parentId) {
VipDept dept = new VipDept();
dept.setParentId( parentId );
return deptMapper.selectDeptCount( dept );
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId) {
int result = deptMapper.checkDeptExistUser( deptId );
return result > 0 ? true : false;
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId) {
return deptMapper.deleteDeptById( deptId );
}
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(VipDept dept) {
VipDept info = deptMapper.selectDeptById( dept.getParentId() );
dept.setParentIds( info.getParentIds() + "," + dept.getParentId() );
return deptMapper.insertDept( dept );
}
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int updateDept(VipDept dept) {
VipDept info = deptMapper.selectDeptById( dept.getParentId() );
if (StringUtils.isNotNull( info )) {
String ancestors = info.getParentIds() + "," + dept.getParentId();
dept.setParentIds( ancestors );
updateDeptChildren( dept.getDeptId(), ancestors );
}
return deptMapper.updateDept( dept );
}
/**
* 修改子元素关系
*
* @param deptId 部门ID
* @param ancestors 元素列表
*/
public void updateDeptChildren(Long deptId, String ancestors) {
VipDept dept = new VipDept();
dept.setParentId( deptId );
List<VipDept> childrens = deptMapper.selectDeptList( dept );
for (VipDept children : childrens) {
children.setParentIds( ancestors + "," + dept.getParentId() );
}
if (childrens.size() > 0) {
deptMapper.updateDeptChildren( childrens );
}
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public VipDept selectDeptById(Long deptId) {
return deptMapper.selectDeptById( deptId );
}
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
@Override
public String checkDeptNameUnique(VipDept dept) {
Long deptId = StringUtils.isNull( dept.getDeptId() ) ? -1L : dept.getDeptId();
VipDept info = deptMapper.checkDeptNameUnique( dept.getDeptName(), dept.getParentId() );
if (StringUtils.isNotNull( info ) && info.getDeptId().longValue() != deptId.longValue()) {
return UserConstants.DEPT_NAME_NOT_UNIQUE;
}
return UserConstants.DEPT_NAME_UNIQUE;
}
}

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.vip.mapper.VipDeptMapper">
<resultMap type="VipDept" id="VipDeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="parentIds" column="parent_ids" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.parent_ids, d.dept_name, d.order_num, d.del_flag, d.create_by, d.create_time
from vip_dept d
</sql>
<select id="selectRoleDeptTree" parameterType="Long" resultType="String">
select concat(d.dept_id, d.dept_name) as dept_name
from vip_dept d
left join sys_role_dept rd on d.dept_id = rd.dept_id
where d.del_flag = '0' and rd.role_id = #{roleId}
order by d.parent_id, d.order_num
</select>
<select id="selectDeptList" parameterType="VipDept" resultMap="VipDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="selectDeptCount" parameterType="VipDept" resultType="int">
select count(1) from vip_dept
where del_flag = '0'
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
</select>
<select id="checkDeptNameUnique" resultMap="VipDeptResult">
<include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId}
</select>
<select id="selectDeptById" parameterType="Long" resultMap="VipDeptResult">
select d.dept_id, d.parent_id, d.parent_ids, d.dept_name, d.order_num,
(select dept_name from vip_dept where dept_id = d.parent_id) parent_name
from vip_dept d
where d.dept_id = #{deptId}
</select>
<insert id="insertDept" parameterType="VipDept">
insert into vip_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="parentIds != null and parentIds != ''">parent_ids,</if>
<if test="orderNum != null and orderNum != ''">order_num,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="parentIds != null and parentIds != ''">#{parentIds},</if>
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="VipDept">
update vip_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="parentIds != null and parentIds != ''">parent_ids = #{parentIds},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update vip_dept set parent_ids =
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.parent_ids}
</foreach>
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.deptId}
</foreach>
</update>
<delete id="deleteDeptById" parameterType="Long">
update vip_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
</mapper>

View File

@ -24,10 +24,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" column="dept_id" javaType="VipDept" resultMap="deptResult" />
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
</resultMap>
<resultMap id="deptResult" type="VipDept">
<resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />

View File

@ -1,124 +0,0 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-add">
<input id="treeId" name="parentId" type="hidden" th:value="${dept.deptId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级部门:</label>
<div class="col-sm-8">
<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${dept.deptName}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="deptName" id="deptName">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示排序:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="orderNum">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">负责人:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="leader">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">联系电话:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="phone">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">邮箱:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="email">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.isDefault == 'Y' ? true : false}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "vip/dept";
$("#form-dept-add").validate({
rules:{
deptName:{
required:true,
remote: {
url: prefix + "/checkDeptNameUnique",
type: "post",
dataType: "json",
data: {
"parentId": function() {
return $("input[name='parentId']").val();
},
"deptName" : function() {
return $.common.trim($("#deptName").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
orderNum:{
required:true,
digits:true
},
email:{
email:true,
},
phone:{
isPhone:true,
},
},
messages: {
"deptName": {
remote: "部门已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-dept-add').serialize());
}
}
/*部门管理-新增-选择父部门树*/
function selectDeptTree() {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
</script>
</body>
</html>

View File

@ -1,115 +0,0 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="dept-form">
<div class="select-list">
<ul>
<li>
部门名称:<input type="text" name="deptName"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="vip:dept:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary" onclick="$.operate.editTree()" shiro:hasPermission="vip:dept:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('vip:dept:add')}]];
var editFlag = [[${@permission.hasPermi('vip:dept:edit')}]];
var removeFlag = [[${@permission.hasPermi('vip:dept:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "vip/dept"
$(function() {
var options = {
code: "deptId",
parentCode: "parentId",
uniqueId: "deptId",
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",
modalName: "部门",
columns: [{
field: 'selectItem',
radio: true
},
{
field: 'deptName',
title: '部门名称',
align: "left"
},
{
field: 'orderNum',
title: '排序',
align: "left"
},
{
field: 'createTime',
title: '创建时间',
align: "left"
},
{
title: '操作',
align: 'left',
formatter: function(value, row, index) {
if (row.parentId != 0) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.deptId + '\')"><i class="fa fa-edit">编辑</i></a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="#" onclick="$.operate.add(\'' + row.deptId + '\')"><i class="fa fa-plus">新增</i></a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="remove(\'' + row.deptId + '\')"><i class="fa fa-remove">删除</i></a>');
return actions.join('');
} else {
return "";
}
}
}]
};
$.treeTable.init(options);
});
function remove(id) {
$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() {
$.ajax({
type : 'post',
url: prefix + "/remove/" + id,
success : function(result) {
if (result.code == web_status.SUCCESS) {
$.modal.msgSuccess(result.msg);
$.treeTable.refresh();
} else {
$.modal.msgError(result.msg);
}
}
});
});
}
</script>
</body>
</html>

View File

@ -1,133 +0,0 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
<input name="deptId" type="hidden" th:field="*{deptId}" />
<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级部门:</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parentName}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="deptName" th:field="*{deptName}" id="deptName">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示排序:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="orderNum" th:field="*{orderNum}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">负责人:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="leader" th:field="*{leader}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">联系电话:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="phone" th:field="*{phone}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">邮箱:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="email" th:field="*{email}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "vip/dept";
$("#form-dept-edit").validate({
rules:{
deptName:{
required:true,
remote: {
url: prefix + "/checkDeptNameUnique",
type: "post",
dataType: "json",
data: {
"deptId": function() {
return $("#deptId").val();
},
"parentId": function() {
return $("input[name='parentId']").val();
},
"deptName": function() {
return $.common.trim($("#deptName").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
orderNum:{
required:true,
digits:true
},
email:{
email:true,
},
phone:{
isPhone:true,
},
},
messages: {
"deptName": {
remote: "部门已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
}
}
/*部门管理-修改-选择部门树*/
function selectDeptTree() {
var deptId = $("#treeId").val();
if(deptId > 0) {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
} else {
$.modal.alertError("父部门不能选择");
}
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
</script>
</body>
</html>

View File

@ -1,48 +0,0 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<style>
body{height:auto;font-family: "Microsoft YaHei";}
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
</style>
<body class="hold-transition box box-main">
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
<input id="treeName" name="treeName" type="hidden" th:value="${dept.deptName}"/>
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
<label id="btnShow" title="显示搜索" style="display:none;"></label>
<label id="btnHide" title="隐藏搜索"></label>
</div>
<div class="treeSearchInput" id="search">
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
</div>
<div class="treeExpandCollapse">
<a href="#" onclick="$.tree.expand()">展开</a> /
<a href="#" onclick="$.tree.collapse()">折叠</a>
</div>
<div id="tree" class="ztree treeselect"></div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
$(function() {
var url = ctx + "vip/dept/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
});
function zOnClick(event, treeId, treeNode) {
var treeId = treeNode.id;
var treeName = treeNode.name;
$("#treeId").val(treeId);
$("#treeName").val(treeName);
}
</script>
</body>
</html>