新增部门管理 (新增、删除、修改、查询)

This commit is contained in:
RuoYi 2018-03-04 17:02:45 +08:00
parent ab230a3e32
commit ba90fdb78c
20 changed files with 880 additions and 43 deletions

View File

@ -3,29 +3,28 @@
-- ---------------------------- -- ----------------------------
drop table if exists sys_dept; drop table if exists sys_dept;
create table sys_dept ( create table sys_dept (
dept_id int(11) not null auto_increment comment '部门ID', dept_id int(11) not null auto_increment comment '部门ID',
parent_id int(11) default 0 comment '父部门ID', parent_id int(11) default 0 comment '父部门ID',
dept_name varchar(30) default '' comment '部门名称', dept_name varchar(30) default '' comment '部门名称',
order_num int(4) default null comment '显示顺序', order_num int(4) default null comment '显示顺序',
status int(1) default 0 comment '部门状态:0正常,1停用', status int(1) default 0 comment '部门状态:0正常,1停用',
create_time timestamp default current_timestamp comment '创建时间',
primary key (dept_id) primary key (dept_id)
) engine=innodb auto_increment=100 default charset=utf8; ) engine=innodb auto_increment=100 default charset=utf8;
-- ---------------------------- -- ----------------------------
-- 初始化-部门表数据 -- 初始化-部门表数据
-- ---------------------------- -- ----------------------------
insert into sys_dept values('1', '0', '研发部门', '1', '0'); insert into sys_dept values(1, 0, '若依集团', 1, 0, '2018-03-01');
insert into sys_dept values('2', '0', '测试部门', '2', '0'); insert into sys_dept values(2, 1, '研发部门', 2, 0, '2018-03-01');
insert into sys_dept values('3', '0', '市场部门', '3', '0'); insert into sys_dept values(3, 1, '市场部门', 4, 0, '2018-03-01');
insert into sys_dept values(4, 1, '测试部门', 3, 0, '2018-03-01');
insert into sys_dept values('4', '1', '研发一部', '1', '0'); insert into sys_dept values(5, 1, '财务部门', 5, 1, '2018-03-01');
insert into sys_dept values('5', '1', '研发二部', '2', '0'); insert into sys_dept values(6, 1, '运维部门', 6, 1, '2018-03-01');
insert into sys_dept values('6', '1', '研发三部', '3', '0'); insert into sys_dept values(7, 2, '研发一部', 1, 0, '2018-03-01');
insert into sys_dept values('7', '2', '测试一部', '1', '0'); insert into sys_dept values(8, 2, '研发二部', 2, 1, '2018-03-01');
insert into sys_dept values('8', '2', '测试二部', '2', '0'); insert into sys_dept values(9, 3, '市场一部', 1, 0, '2018-03-01');
insert into sys_dept values('9', '3', '市场一部', '1', '0'); insert into sys_dept values(10, 3, '市场二部', 2, 1, '2018-03-01');
insert into sys_dept values('10', '3', '市场二部', '2', '0');
-- ---------------------------- -- ----------------------------
-- 2、用户信息表 -- 2、用户信息表
@ -49,8 +48,8 @@ create table sys_user (
-- ---------------------------- -- ----------------------------
-- 初始化-用户信息表数据 -- 初始化-用户信息表数据
-- ---------------------------- -- ----------------------------
insert into sys_user values('1', '1', 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '172eee54aa664e9dd0536b063796e54e', '', 0, '维护中', '2018-03-01'); insert into sys_user values('1', '4', 'admin', '若依', 'yzz_ivy@163.com', '15088888888', '172eee54aa664e9dd0536b063796e54e', '', 0, '维护中', '2018-03-01');
insert into sys_user values('2', '1', 'ry', '若依', 'ry@163.com', '15288888888', '2f59d63eddd54f3977d6fe25aec8b2bc', '', 1, '锁定中', '2018-03-01'); insert into sys_user values('2', '4', 'ry', '若依', 'ry@163.com', '15288888888', '2f59d63eddd54f3977d6fe25aec8b2bc', '', 1, '锁定中', '2018-03-01');
@ -106,22 +105,27 @@ create table sys_menu (
insert into sys_menu values('1', '系统管理', '0', '1', '#', 'M', '0', '#', 'fa fa-gear', '2018-03-01', '', 'admin', '系统管理目录'); insert into sys_menu values('1', '系统管理', '0', '1', '#', 'M', '0', '#', 'fa fa-gear', '2018-03-01', '', 'admin', '系统管理目录');
insert into sys_menu values('2', '系统监控', '0', '2', '#', 'M', '0', '#', 'fa fa-video-camera', '2018-03-01', '', 'admin', '系统监控目录'); insert into sys_menu values('2', '系统监控', '0', '2', '#', 'M', '0', '#', 'fa fa-video-camera', '2018-03-01', '', 'admin', '系统监控目录');
-- 二级菜单 -- 二级菜单
insert into sys_menu values('3', '用户管理', '1', '1', '/system/user/userList', 'C', '0', 'system:user:view', '#', '2018-03-01', '', 'admin', '用户管理菜单'); insert into sys_menu values('3', '用户管理', '1', '1', '/system/user', 'C', '0', 'system:user:view', '#', '2018-03-01', '', 'admin', '用户管理菜单');
insert into sys_menu values('4', '角色管理', '1', '2', '/system/role/roleList', 'C', '0', 'system:role:view', '#', '2018-03-01', '', 'admin', '角色管理菜单'); insert into sys_menu values('4', '角色管理', '1', '2', '/system/role', 'C', '0', 'system:role:view', '#', '2018-03-01', '', 'admin', '角色管理菜单');
insert into sys_menu values('5', '菜单管理', '1', '3', '/system/menu/menuList', 'C', '0', 'system:menu:view', '#', '2018-03-01', '', 'admin', '菜单管理菜单'); insert into sys_menu values('5', '菜单管理', '1', '3', '/system/menu', 'C', '0', 'system:menu:view', '#', '2018-03-01', '', 'admin', '菜单管理菜单');
insert into sys_menu values('6', '部门管理', '1', '3', '/system/dept/deptList', 'C', '0', 'system:dept:view', '#', '2018-03-01', '', 'admin', '部门管理菜单'); insert into sys_menu values('6', '部门管理', '1', '3', '/system/dept', 'C', '0', 'system:dept:view', '#', '2018-03-01', '', 'admin', '部门管理菜单');
insert into sys_menu values('7', '操作日志', '2', '1', '/monitor/operlog', 'C', '0', 'monitor:operlog:view', '#', '2018-03-01', '', 'admin', '操作日志菜单'); insert into sys_menu values('7', '操作日志', '2', '1', '/monitor/operlog', 'C', '0', 'monitor:operlog:view', '#', '2018-03-01', '', 'admin', '操作日志菜单');
insert into sys_menu values('8', '登录日志', '2', '2', '/monitor/logininfor', 'C', '0', 'monitor:logininfor:view', '#', '2018-03-01', '', 'admin', '登录日志菜单'); insert into sys_menu values('8', '登录日志', '2', '2', '/monitor/logininfor', 'C', '0', 'monitor:logininfor:view', '#', '2018-03-01', '', 'admin', '登录日志菜单');
insert into sys_menu values('9', '在线用户', '2', '3', '/monitor/online', 'C', '0', 'monitor:online:view', '#', '2018-03-01', '', 'admin', '在线用户菜单'); insert into sys_menu values('9', '在线用户', '2', '3', '/monitor/online', 'C', '0', 'monitor:online:view', '#', '2018-03-01', '', 'admin', '在线用户菜单');
insert into sys_menu values('10', '数据监控', '2', '4', '/monitor/data', 'C', '0', 'monitor:data:xxxx', '#', '2018-03-01', '', 'admin', '数据监控菜单'); insert into sys_menu values('10', '数据监控', '2', '4', '/monitor/data', 'C', '0', 'monitor:data:xxxx', '#', '2018-03-01', '', 'admin', '数据监控菜单');
-- 部门管理按钮
insert into sys_menu values('11', '部门新增', '6', '1', '/system/dept/add', 'F', '0', 'system:dept:add', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('12', '部门修改', '6', '2', '/system/dept/edit', 'F', '0', 'system:dept:edit', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('13', '部门删除', '6', '3', '/system/dept/remove', 'F', '0', 'system:dept:remove', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('14', '部门保存', '6', '4', '/system/dept/save', 'F', '0', 'system:dept:save', '#', '2018-03-01', '', 'admin', '');
-- 操作日志按钮 -- 操作日志按钮
insert into sys_menu values('11', '批量删除', '7', '1', '/monitor/operlog/batchRemove', 'F', '0', 'monitor:operlog:batchRemove', '#', '2018-03-01', '', 'admin', ''); insert into sys_menu values('15', '批量删除', '7', '1', '/monitor/operlog/batchRemove', 'F', '0', 'monitor:operlog:batchRemove', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('12', '详细信息', '7', '2', '/monitor/operlog/detail', 'F', '0', 'monitor:operlog:detail', '#', '2018-03-01', '', 'admin', ''); insert into sys_menu values('16', '详细信息', '7', '2', '/monitor/operlog/detail', 'F', '0', 'monitor:operlog:detail', '#', '2018-03-01', '', 'admin', '');
-- 登录日志按钮 -- 登录日志按钮
insert into sys_menu values('13', '批量删除', '8', '1', '/monitor/logininfor/batchRemove', 'F', '0', 'monitor:logininfor:batchRemove', '#', '2018-03-01', '', 'admin', ''); insert into sys_menu values('17', '批量删除', '8', '1', '/monitor/logininfor/batchRemove', 'F', '0', 'monitor:logininfor:batchRemove', '#', '2018-03-01', '', 'admin', '');
-- 在线用户按钮 -- 在线用户按钮
insert into sys_menu values('14', '批量强退', '9', '1', '/monitor/online/batchForceLogout', 'F', '0', 'monitor:online:batchForceLogout', '#', '2018-03-01', '', 'admin', ''); insert into sys_menu values('18', '批量强退', '9', '1', '/monitor/online/batchForceLogout', 'F', '0', 'monitor:online:batchForceLogout', '#', '2018-03-01', '', 'admin', '');
insert into sys_menu values('15', '单条强退', '9', '2', '/monitor/online/forceLogout', 'F', '0', 'monitor:online:forceLogout', '#', '2018-03-01', '', 'admin', ''); insert into sys_menu values('19', '单条强退', '9', '2', '/monitor/online/forceLogout', 'F', '0', 'monitor:online:forceLogout', '#', '2018-03-01', '', 'admin', '');
-- ---------------------------- -- ----------------------------
-- 5、用户和角色关联表 用户N-1角色 -- 5、用户和角色关联表 用户N-1角色
@ -169,7 +173,10 @@ insert into sys_role_menu values ('1', '12');
insert into sys_role_menu values ('1', '13'); insert into sys_role_menu values ('1', '13');
insert into sys_role_menu values ('1', '14'); insert into sys_role_menu values ('1', '14');
insert into sys_role_menu values ('1', '15'); insert into sys_role_menu values ('1', '15');
insert into sys_role_menu values ('1', '16');
insert into sys_role_menu values ('1', '17');
insert into sys_role_menu values ('1', '18');
insert into sys_role_menu values ('1', '19');
-- ---------------------------- -- ----------------------------
-- 7、操作日志记录 -- 7、操作日志记录
-- ---------------------------- -- ----------------------------

View File

@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>RuoYi</artifactId> <artifactId>RuoYi</artifactId>
<version>1.0.1</version> <version>1.0.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>RuoYi</name> <name>RuoYi</name>

View File

@ -140,6 +140,19 @@ public class DynamicObjectBaseDao
return sqlSessionTemplate.selectOne(str, obj); return sqlSessionTemplate.selectOne(str, obj);
} }
/**
* 查找总数
*
* @param str mapper 节点
* @param obj 对象
* @return 结果
* @throws Exception
*/
public int count(String str, Object obj)
{
return sqlSessionTemplate.selectOne(str, obj);
}
/** /**
* 查找对象 - 无条件 * 查找对象 - 无条件
* *

View File

@ -73,6 +73,6 @@ public class OperlogController extends BaseController
{ {
OperLog operLog = operLogService.selectOperLogById(deptId); OperLog operLog = operLogService.selectOperLogById(deptId);
model.addAttribute("operLog", operLog); model.addAttribute("operLog", operLog);
return prefix + "/view"; return prefix + "/detail";
} }
} }

View File

@ -0,0 +1,116 @@
package com.ruoyi.project.system.dept.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.domain.JSON;
import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.dept.service.IDeptService;
/**
* 部门信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/dept")
public class DeptController
{
private String prefix = "system/dept";
@Autowired
private IDeptService deptService;
@RequiresPermissions("system:dept:view")
@GetMapping()
public String dept()
{
return prefix + "/dept";
}
@RequiresPermissions("system:dept:view")
@GetMapping("/list")
@ResponseBody
public List<Dept> list()
{
List<Dept> deptList = deptService.selectDeptAll();
return deptList;
}
/**
* 修改
*/
@Log(title = "系统管理", action = "部门管理-修改部门")
@RequiresPermissions("system:dept:edit")
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, Model model)
{
Dept dept = deptService.selectDeptById(deptId);
model.addAttribute("dept", dept);
return prefix + "/edit";
}
/**
* 新增
*/
@Log(title = "系统管理", action = "部门管理-新增部门")
@RequiresPermissions("system:dept:add")
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, Model model)
{
Dept dept = deptService.selectDeptById(parentId);
model.addAttribute("dept", dept);
return prefix + "/add";
}
/**
* 保存
*/
@Log(title = "系统管理", action = "部门管理-保存部门")
@RequiresPermissions("system:dept:save")
@PostMapping("/save")
@ResponseBody
public JSON save(Dept sysDept)
{
if (deptService.saveDept(sysDept) > 0)
{
return JSON.ok();
}
return JSON.error();
}
/**
* 删除
*/
@Log(title = "系统管理", action = "部门管理-删除部门")
@RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}")
@ResponseBody
public JSON remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
return JSON.error(1, "存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return JSON.error(1, "部门存在用户,不允许删除");
}
if (deptService.deleteDeptById(deptId) > 0)
{
return JSON.ok();
}
return JSON.error();
}
}

View File

@ -0,0 +1,99 @@
package com.ruoyi.project.system.dept.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
import com.ruoyi.project.system.dept.domain.Dept;
/**
* 部门管理 数据实现层
*
* @author ruoyi
*/
@Repository("deptDao")
public class DeptDaoImpl extends DynamicObjectBaseDao implements IDeptDao
{
/**
* 新增部门管理
*
* @param dept 部门对象
*/
public int insertDept(Dept dept)
{
return this.save("SystemDeptMapper.insertDept", dept);
}
/**
* 查询部门管理集合
*
* @return 所有部门信息
*/
public List<Dept> selectDeptAll()
{
List<Dept> deptList = null;
try
{
deptList = this.findForList("SystemDeptMapper.selectDeptAll");
}
catch (Exception e)
{
e.printStackTrace();
}
return deptList;
}
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
public int selectDeptCount(Dept dept)
{
return this.count("SystemDeptMapper.selectDeptCount", dept);
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
public int checkDeptExistUser(Long deptId)
{
return this.count("SystemDeptMapper.checkDeptExistUser", deptId);
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId)
{
return this.delete("SystemDeptMapper.deleteDeptById", deptId);
}
/**
* 保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int saveDept(Dept dept)
{
return this.save("SystemDeptMapper.saveDept", dept);
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public Dept selectDeptById(Long deptId)
{
return this.findForObject("SystemDeptMapper.selectDeptById", deptId);
}
}

View File

@ -0,0 +1,66 @@
package com.ruoyi.project.system.dept.dao;
import java.util.List;
import com.ruoyi.project.system.dept.domain.Dept;
/**
* 部门管理 数据层
*
* @author ruoyi
*/
public interface IDeptDao
{
/**
* 新增部门管理
*
* @param dept 部门对象
*/
public int insertDept(Dept dept);
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
public int selectDeptCount(Dept dept);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
public int checkDeptExistUser(Long deptId);
/**
* 查询部门管理集合
*
* @return 所有部门信息
*/
public List<Dept> selectDeptAll();
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int saveDept(Dept dept);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public Dept selectDeptById(Long deptId);
}

View File

@ -19,6 +19,8 @@ public class Dept
/** 显示顺序 */ /** 显示顺序 */
private String orderNum; private String orderNum;
/** 部门状态:0正常,1停用 */ /** 部门状态:0正常,1停用 */
private String status; private int status;
/** 父部门名称 */
private String parentName;
} }

View File

@ -0,0 +1,99 @@
package com.ruoyi.project.system.dept.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ruoyi.project.system.dept.dao.IDeptDao;
import com.ruoyi.project.system.dept.domain.Dept;
/**
* 部门管理 服务实现
*
* @author ruoyi
*/
@Repository("deptService")
public class DeptServiceImpl implements IDeptService
{
@Autowired
private IDeptDao deptDao;
/**
* 新增部门管理
*
* @param dept 部门对象
*/
public int insertDept(Dept dept)
{
return deptDao.insertDept(dept);
}
/**
* 查询部门管理集合
*
* @return 所有部门信息
*/
public List<Dept> selectDeptAll()
{
return deptDao.selectDeptAll();
}
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
public int selectDeptCount(Long parentId)
{
Dept dept = new Dept();
dept.setParentId(parentId);
return deptDao.selectDeptCount(dept);
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
public boolean checkDeptExistUser(Long deptId)
{
int result = deptDao.checkDeptExistUser(deptId);
return result > 0 ? true : false;
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId)
{
return deptDao.deleteDeptById(deptId);
}
/**
* 保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int saveDept(Dept dept)
{
return deptDao.saveDept(dept);
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public Dept selectDeptById(Long deptId)
{
return deptDao.selectDeptById(deptId);
}
}

View File

@ -0,0 +1,66 @@
package com.ruoyi.project.system.dept.service;
import java.util.List;
import com.ruoyi.project.system.dept.domain.Dept;
/**
* 部门管理 服务层
*
* @author ruoyi
*/
public interface IDeptService
{
/**
* 新增部门管理
*
* @param dept 部门对象
*/
public int insertDept(Dept dept);
/**
* 查询部门管理集合
*
* @return 所有部门信息
*/
public List<Dept> selectDeptAll();
/**
* 查询部门人数
*
* @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 saveDept(Dept dept);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public Dept selectDeptById(Long deptId);
}

View File

@ -0,0 +1,48 @@
<?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="SystemDeptMapper">
<resultMap type="Dept" id="DeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="status" column="status" />
<result property="parentName" column="parent_name" />
</resultMap>
<select id="selectDeptAll" resultMap="DeptResult">
select * from sys_dept
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(*) from sys_user where dept_id = #{deptId}
</select>
<select id="selectDeptCount" parameterType="Dept" resultType="int">
select count(*) from sys_dept
<where>
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
</where>
</select>
<select id="selectDeptById" parameterType="Long" resultMap="DeptResult">
select t.dept_id, t.parent_id, t.dept_name, t.order_num, t.status,
(select dept_name from sys_dept where dept_id = t.parent_id) parent_name
from sys_dept t
where dept_id = #{deptId}
</select>
<insert id="saveDept" parameterType="Dept">
replace into sys_dept(dept_id, parent_id, dept_name, order_num, status)
values (#{deptId}, #{parentId}, #{deptName}, #{orderNum}, #{status})
</insert>
<delete id="deleteDeptById" parameterType="Long">
delete from sys_dept where dept_id = #{deptId}
</delete>
</mapper>

View File

@ -37,6 +37,23 @@ function initTable(_columns, _url) {
}); });
} }
//初始化表格树
function initTreeTable(_id, _parentId, _columns, _url) {
$('.bootstrap-table').bootstrapTreeTable({
code : _id, // 用于设置父子关系
parentCode : _parentId, // 用于设置父子关系
type: 'get', // 请求方式(*
url: _url, // 请求后台的URL*
ajaxParams : {}, // 请求数据的ajax的data属性
expandColumn : '1', // 在哪一列上面显示展开按钮
striped : false, // 是否各行渐变色
bordered : true, // 是否显示边框
expandAll : false, // 是否全部展开
showRefresh: true, // 是否显示刷新按钮
columns: _columns
});
}
// 刷新 // 刷新
function refresh() { function refresh() {
$('.bootstrap-table').bootstrapTable('refresh'); $('.bootstrap-table').bootstrapTable('refresh');

View File

@ -0,0 +1,45 @@
$("#form-dept-add").validate({
rules:{
deptName:{
required:true,
},
orderNum:{
required:true,
},
},
submitHandler:function(form){
update();
}
});
function update() {
var parentId = $("input[name='parentId']").val();
var orderNum = $("input[name='orderNum']").val();
var deptName = $("input[name='deptName']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
$.ajax({
cache : true,
type : "POST",
url : "/system/dept/save",
data : {
"parentId": parentId,
"deptName": deptName,
"orderNum": orderNum,
"status": status
},
async : false,
error : function(request) {
parent.layer.alert("系统错误");
},
success : function(data) {
if (data.code == 0) {
parent.layer.msg('新增成功',{icon:1,time:1000});
layer_close();
parent.loading();
} else {
parent.layer.alert(data.m , {icon: 2,title:"系统提示"});
}
}
});
}

View File

@ -0,0 +1,82 @@
var prefix = "/system/dept"
window.onload = function() {
loading();
};
function loading() {
var columns = [{
title : '部门编号',
field : 'deptId',
visible : false,
align : 'center',
valign : 'middle',
width : '10%'
},
{
field : 'deptName',
title : '部门名称'
},
{
field : 'orderNum',
title : '排序'
},
{
field : 'status',
title : '状态',
align : 'center',
formatter : function(item, index) {
if (item.status == '0') {
return '<span class="label label-primary">正常</span>';
} else if (item.status == '1') {
return '<span class="label label-danger">禁用</span>';
}
}
},
{
title : '操作',
align : 'center',
formatter : function(row, index) {
if(row.parentId != 0) {
var edit = '<a class="btn btn-primary btn-sm" href="#" title="编辑" mce_href="#" onclick="edit(\'' + row.deptId + '\')"><i class="fa fa-edit"></i></a> ';
var add = '<a class="btn btn-primary btn-sm" href="#" title="增加下級" mce_href="#" onclick="add(\'' + row.deptId + '\')"><i class="fa fa-plus"></i></a> ';
var del = '<a class="btn btn-warning btn-sm" href="#" title="删除" mce_href="#" onclick="remove(\'' + row.deptId + '\')"><i class="fa fa-remove"></i></a> ';
return edit + add + del;
} else {
return "";
}
}
}];
var url = prefix + "/list";
initTreeTable('deptId', 'parentId', columns, url);
}
/*部门管理-新增*/
function add(deptId) {
var url = prefix + '/add/' + deptId;
layer_show("新增部门管理", url, '800', '500');
}
/*部门管理-修改*/
function edit(deptId) {
var url = prefix + '/edit/' + deptId;
layer_show("修改部门管理", url, '800', '400');
}
/*部门管理-删除*/
function remove(deptId) {
layer.confirm("确定要删除部门吗?",{icon: 3, title:'提示'},function(index){
$.ajax({
type : 'get',
url: prefix + "/remove/" + deptId,
success : function(r) {
if (r.code == 0) {
layer.msg(r.msg, { icon: 1, time: 1000 });
loading();
} else {
layer.alert(r.msg, { icon: 2, title: "系统提示" });
}
}
});
});
}

View File

@ -0,0 +1,47 @@
$("#form-dept-edit").validate({
rules:{
deptName:{
required:true,
},
orderNum:{
required:true,
},
},
submitHandler:function(form){
update();
}
});
function update() {
var deptId = $("input[name='deptId']").val();
var parentId = $("input[name='parentId']").val();
var orderNum = $("input[name='orderNum']").val();
var deptName = $("input[name='deptName']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
$.ajax({
cache : true,
type : "POST",
url : "/system/dept/save",
data : {
"deptId": deptId,
"parentId": parentId,
"deptName": deptName,
"orderNum": orderNum,
"status": status
},
async : false,
error : function(request) {
parent.layer.alert("系统错误");
},
success : function(data) {
if (data.code == 0) {
parent.layer.msg('修改成功',{icon:1,time:1000});
layer_close();
parent.loading();
} else {
parent.layer.alert(data.m , {icon: 2,title:"系统提示"});
}
}
});
}

View File

@ -35,7 +35,7 @@
<h2>若依后台管理框架</h2> <h2>若依后台管理框架</h2>
<p>一直想做一款后台管理系统看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。她可以用于所有的Web应用程序<b>网站管理后台</b><b>网站会员中心</b><b>CMS</b><b>CRM</b><b>OA</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错效率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。</p> <p>一直想做一款后台管理系统看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。她可以用于所有的Web应用程序<b>网站管理后台</b><b>网站会员中心</b><b>CMS</b><b>CRM</b><b>OA</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错效率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。</p>
<p> <p>
<b>当前版本:</b>v1.0.1 <b>当前版本:</b>v1.0.2
</p> </p>
<p> <p>
<span class="label label-warning">&yen;免费开源</span> <span class="label label-warning">&yen;免费开源</span>
@ -94,13 +94,27 @@
<div class="ibox-content no-padding"> <div class="ibox-content no-padding">
<div class="panel-body"> <div class="panel-body">
<div class="panel-group" id="version"> <div class="panel-group" id="version">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v02">v1.0.2</a><code class="pull-right">2018.03.04</code>
</h5>
</div>
<div id="v02" class="panel-collapse collapse in">
<div class="panel-body">
<ol>
<li>新增部门管理 (新增、删除、修改、查询)</li>
</ol>
</div>
</div>
</div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h5 class="panel-title"> <h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v11">v1.0.1</a><code class="pull-right">2018.03.03</code> <a data-toggle="collapse" data-parent="#version" href="#v01">v1.0.1</a><code class="pull-right">2018.03.03</code>
</h5> </h5>
</div> </div>
<div id="v11" class="panel-collapse collapse in"> <div id="v01" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
<ol> <ol>
<li>新增在线用户 (批量强退、单条强退、查询)</li> <li>新增在线用户 (批量强退、单条强退、查询)</li>
@ -114,10 +128,10 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h4 class="panel-title"> <h4 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v10">v1.0.0</a><code class="pull-right">2018.03.01</code> <a data-toggle="collapse" data-parent="#version" href="#v00">v1.0.0</a><code class="pull-right">2018.03.01</code>
</h4> </h4>
</div> </div>
<div id="v10" class="panel-collapse collapse"> <div id="v00" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
<ol> <ol>
<li>若依管理系统正式发布。</li> <li>若依管理系统正式发布。</li>

View File

@ -43,7 +43,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-control-static col-sm-offset-9"> <div class="form-control-static col-sm-offset-9">
<button onClick="layer_close();" class="btn btn-danger" type="submit">关闭</button> <button class="btn btn-danger" type="submit">关闭</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<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 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" 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">
<div class="onoffswitch">
<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status" name="status">
<label class="onoffswitch-label" for="status">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/ruoyi/system/dept/add.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
<table class="bootstrap-table" data-mobile-responsive="true">
</table>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" src="/ruoyi/system/dept/dept.js"></script>
</body>
</html>

View File

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<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">
<input name="deptId" type="hidden" th:value="${dept.deptId}" />
<input name="parentId" type="hidden" th:value="${dept.parentId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级部门:</label>
<div class="col-sm-8">
<input class="form-control" type="text" readonly="true" th:value="${dept.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" id="deptName" 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="orderNum" th:value="${dept.orderNum}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
<div class="onoffswitch">
<input type="checkbox" th:checked="${dept.status == 0 ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
<label class="onoffswitch-label" for="status">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/ruoyi/system/dept/edit.js">
</script>
</body>
</html>