提交 66d29c24 编写于 作者: doc_wei's avatar doc_wei

部门信息管理后台完成

上级 35fe4900
package com.skyeye.company.dao;
import java.util.List;
import java.util.Map;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
public interface CompanyDepartmentDao {
public List<Map<String, Object>> queryCompanyDepartmentList(Map<String, Object> map, PageBounds pageBounds) throws Exception;
public int insertCompanyDepartmentMation(Map<String, Object> map) throws Exception;
public Map<String, Object> queryCompanyDepartmentMationByName(Map<String, Object> map) throws Exception;
public int deleteCompanyDepartmentMationById(Map<String, Object> map) throws Exception;
public Map<String, Object> queryCompanyDepartmentMationToEditById(Map<String, Object> map) throws Exception;
public Map<String, Object> queryCompanyDepartmentMationByNameAndId(Map<String, Object> map) throws Exception;
public int editCompanyDepartmentMationById(Map<String, Object> map) throws Exception;
public Map<String, Object> queryCompanyDepartmentUserMationById(Map<String, Object> map) throws Exception;
}
package com.skyeye.company.service;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
public interface CompanyDepartmentService {
public void queryCompanyDepartmentList(InputObject inputObject, OutputObject outputObject) throws Exception;
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception;
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void queryCompanyDepartmentMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
}
package com.skyeye.company.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.skyeye.company.dao.CompanyDepartmentDao;
import com.skyeye.company.service.CompanyDepartmentService;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.ToolUtil;
@Service
public class CompanyDepartmentServiceImpl implements CompanyDepartmentService{
@Autowired
private CompanyDepartmentDao companyDepartmentDao;
/**
*
* @Title: queryCompanyDepartmentList
* @Description: 获取公司部门信息列表
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void queryCompanyDepartmentList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
List<Map<String, Object>> beans = companyDepartmentDao.queryCompanyDepartmentList(map,
new PageBounds(Integer.parseInt(map.get("page").toString()), Integer.parseInt(map.get("limit").toString())));
PageList<Map<String, Object>> beansPageList = (PageList<Map<String, Object>>)beans;
int total = beansPageList.getPaginator().getTotalCount();
outputObject.setBeans(beans);
outputObject.settotal(total);
}
/**
*
* @Title: insertCompanyDepartmentMation
* @Description: 添加公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentMationByName(map);
if(bean == null){
Map<String, Object> user = inputObject.getLogParams();
map.put("id", ToolUtil.getSurFaceId());
map.put("createId", user.get("id"));
map.put("pId", "0");
map.put("createTime", ToolUtil.getTimeAndToString());
companyDepartmentDao.insertCompanyDepartmentMation(map);
}else{
outputObject.setreturnMessage("该公司部门信息名称已存在,不可进行二次保存");
}
}
/**
*
* @Title: deleteCompanyDepartmentMationById
* @Description: 删除公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentUserMationById(map);
if(Integer.parseInt(bean.get("childsNum").toString()) == 0){
companyDepartmentDao.deleteCompanyDepartmentMationById(map);
}else{
outputObject.setreturnMessage("该部门下存在员工,无法直接删除。");
}
}
/**
*
* @Title: queryCompanyDepartmentMationToEditById
* @Description: 编辑公司部门信息信息时进行回显
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void queryCompanyDepartmentMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentMationToEditById(map);
outputObject.setBean(bean);
outputObject.settotal(1);
}
/**
*
* @Title: editCompanyDepartmentMationById
* @Description: 编辑公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = companyDepartmentDao.queryCompanyDepartmentMationByNameAndId(map);
if(bean == null){
companyDepartmentDao.editCompanyDepartmentMationById(map);
}else{
outputObject.setreturnMessage("该公司部门信息名称已存在,不可进行二次保存");
}
}
}
package com.skyeye.company.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.skyeye.company.service.CompanyDepartmentService;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
@Controller
public class CompanyDepartmentController {
@Autowired
private CompanyDepartmentService companyDepartmentService;
/**
*
* @Title: queryCompanyDepartmentList
* @Description: 获取公司部门信息列表
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentList")
@ResponseBody
public void queryCompanyDepartmentList(InputObject inputObject, OutputObject outputObject) throws Exception{
companyDepartmentService.queryCompanyDepartmentList(inputObject, outputObject);
}
/**
*
* @Title: insertCompanyDepartmentMation
* @Description: 添加公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/CompanyDepartmentController/insertCompanyDepartmentMation")
@ResponseBody
public void insertCompanyDepartmentMation(InputObject inputObject, OutputObject outputObject) throws Exception{
companyDepartmentService.insertCompanyDepartmentMation(inputObject, outputObject);
}
/**
*
* @Title: deleteCompanyDepartmentMationById
* @Description: 删除公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/CompanyDepartmentController/deleteCompanyDepartmentMationById")
@ResponseBody
public void deleteCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
companyDepartmentService.deleteCompanyDepartmentMationById(inputObject, outputObject);
}
/**
*
* @Title: queryCompanyDepartmentMationToEditById
* @Description: 编辑公司部门信息信息时进行回显
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/CompanyDepartmentController/queryCompanyDepartmentMationToEditById")
@ResponseBody
public void queryCompanyDepartmentMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception{
companyDepartmentService.queryCompanyDepartmentMationToEditById(inputObject, outputObject);
}
/**
*
* @Title: editCompanyDepartmentMationById
* @Description: 编辑公司部门信息信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/CompanyDepartmentController/editCompanyDepartmentMationById")
@ResponseBody
public void editCompanyDepartmentMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
companyDepartmentService.editCompanyDepartmentMationById(inputObject, outputObject);
}
}
<?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.skyeye.company.dao.CompanyDepartmentDao">
<select id="queryCompanyDepartmentList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.department_name departmentName,
a.department_desc departmentDesc,
(SELECT COUNT(*) FROM company_user b WHERE b.department_id = a.id) userNum,
CONVERT(a.create_time, char) createTime
FROM
company_department a
WHERE a.company_id = #{companyId}
ORDER BY a.create_time DESC
</select>
<select id="queryCompanyDepartmentMationByName" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.department_name departmentName
FROM
company_department a
WHERE
a.company_id = #{companyId}
AND a.department_name = #{departmentName}
</select>
<insert id="insertCompanyDepartmentMation" parameterType="java.util.Map">
INSERT into
(id, company_id, department_name, department_desc, p_id, create_id, create_time)
VALUES
(#{id}, #{companyId}, #{departmentName}, #{departmentDesc}, #{pId}, #{createId}, #{createTime})
</insert>
<select id="queryCompanyDepartmentUserMationById" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
COUNT(*) childsNum
FROM
company_user b
WHERE b.department_id = #{id}
</select>
<delete id="deleteCompanyDepartmentMationById" parameterType="java.util.Map">
DELETE
FROM
company_department
WHERE
id = #{id}
</delete>
<select id="queryCompanyDepartmentMationToEditById" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.department_name departmentName,
a.department_desc departmentDesc
FROM
company_department a
WHERE a.id = #{id}
</select>
<select id="queryCompanyDepartmentMationByNameAndId" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.department_name departmentName
FROM
company_department a
WHERE
a.company_id = #{companyId}
AND a.department_name = #{departmentName}
AND a.id != #{id}
</select>
<update id="editCompanyDepartmentMationById" parameterType="java.util.Map">
UPDATE company_department
<set>
<if test="departmentName != '' and departmentName != null">
department_name = #{departmentName},
</if>
department_desc = #{departmentDesc},
</set>
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
......@@ -765,6 +765,22 @@
</url>
<url id="companymation006" path="/post/CompanyMationController/queryOverAllCompanyMationList" val="获取总公司信息列表" allUse="1">
</url>
<url id="companydepartment001" path="/post/CompanyDepartmentController/queryCompanyDepartmentList" val="获取公司部门信息列表" allUse="1">
<property id="limit" name="limit" ref="required,num" var="分页参数,每页多少条数据" />
<property id="page" name="page" ref="required,num" var="分页参数,第几页"/>
</url>
<url id="companydepartment002" path="/post/CompanyDepartmentController/insertCompanyDepartmentMation" val="添加公司部门信息信息" allUse="1">
</url>
<url id="companydepartment003" path="/post/CompanyDepartmentController/deleteCompanyDepartmentMationById" val="删除公司部门信息信息" allUse="1">
<property id="rowId" name="id" ref="required" var="公司部门信息id"/>
</url>
<url id="companydepartment004" path="/post/CompanyDepartmentController/queryCompanyDepartmentMationToEditById" val="编辑公司部门信息信息时进行回显" allUse="1">
<property id="rowId" name="id" ref="required" var="公司部门信息id"/>
</url>
<url id="companydepartment005" path="/post/CompanyDepartmentController/editCompanyDepartmentMationById" val="编辑公司部门信息信息" allUse="1">
<property id="rowId" name="id" ref="required" var="公司部门信息id"/>
</url>
<!-- 公司管理结束 -->
</controller>
\ No newline at end of file
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['jquery', 'winui'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var $ = layui.$,
form = layui.form;
form.render();
form.on('submit(formAddBean)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
var params = {
};
AjaxPostUtil.request({url:reqBasePath "icon002", params:params, type:'json', callback:function(json){
if(json.returnCode == 0){
parent.layer.close(index);
parent.refreshCode = '0';
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
}
return false;
});
//取消
$("body").on("click", "#cancle", function(){
parent.layer.close(index);
});
});
});
\ No newline at end of file
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['jquery', 'winui'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var $ = layui.$,
form = layui.form;
showGrid({
id: "showForm",
url: reqBasePath "icon004",
params: {rowId: parent.rowId},
pagination: false,
template: getFileContent('tpl/companydepartment/companydepartmenteditTemplate.tpl'),
ajaxSendLoadBefore: function(hdb){
},
ajaxSendAfter:function(json){
form.render();
form.on('submit(formEditBean)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
var params = {
};
AjaxPostUtil.request({url:reqBasePath "icon005", params:params, type:'json', callback:function(json){
if(json.returnCode == 0){
parent.layer.close(index);
parent.refreshCode = '0';
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
}
return false;
});
}
});
//取消
$("body").on("click", "#cancle", function(){
parent.layer.close(index);
});
});
});
\ No newline at end of file
var rowId = "";
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['table', 'jquery', 'winui', 'form'], function (exports) {
winui.renderColor();
var $ = layui.$,
form = layui.form,
table = layui.table;
//表格渲染
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: reqBasePath 'rmxcx001',
where:{},
even:true, //隔行变色
page: true,
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
cols: [[
{ title: '序号', type: 'numbers'},
{ field: 'createTime', title: '创建时间', width: 180 },
{ title: '操作', fixed: 'right', align: 'center', width: 240, toolbar: '#tableBar'}
]]
});
table.on('tool(messageTable)', function (obj) { //注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'del') { //删除
del(data, obj);
}else if (layEvent === 'edit') { //编辑
edit(data);
}
});
//搜索表单
form.render();
form.on('submit(formSearch)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
loadTable();
}
return false;
});
//删除
function del(data, obj){
var msg = obj ? '确认删除公司部门信息【' obj.data.rmTypeName '】吗?' : '确认删除选中数据吗?';
layer.confirm(msg, { icon: 3, title: '删除公司部门信息' }, function (index) {
layer.close(index);
//向服务端发送删除指令
AjaxPostUtil.request({url:reqBasePath "rmxcx003", params:{rowId: data.id}, type:'json', callback:function(json){
if(json.returnCode == 0){
top.winui.window.msg("删除成功", {icon: 1,time: 2000});
loadTable();
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
}});
});
}
//编辑分类
function edit(data){
rowId = data.id;
_openNewWindows({
url: "../../tpl/companydepartment/companydepartmentedit.html",
title: "编辑公司部门信息",
pageId: "companydepartmentedit",
callBack: function(refreshCode){
if (refreshCode == '0') {
top.winui.window.msg("操作成功", {icon: 1,time: 2000});
loadTable();
} else if (refreshCode == '-9999') {
top.winui.window.msg("操作失败", {icon: 2,time: 2000});
}
}});
}
//刷新数据
$("body").on("click", "#reloadTable", function(){
loadTable();
});
//新增
$("body").on("click", "#addBean", function(){
_openNewWindows({
url: "../../tpl/companydepartment/companydepartmentadd.html",
title: "新增公司部门信息",
pageId: "companydepartmentadd",
callBack: function(refreshCode){
if (refreshCode == '0') {
top.winui.window.msg("操作成功", {icon: 1,time: 2000});
loadTable();
} else if (refreshCode == '-9999') {
top.winui.window.msg("操作失败", {icon: 2,time: 2000});
}
}});
});
function loadTable(){
table.reload("messageTable", {where:{}});
}
exports('companydepartmentlist', {});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;margin:0 auto;padding-top:20px;">
<form class="layui-form" action="" id="showForm" autocomplete="off">
<div class="layui-form-item">
<div class="layui-input-block">
<button class="winui-btn" id="cancle">取消</button>
<button class="winui-btn" lay-submit lay-filter="formAddBean">保存</button>
</div>
</div>
</form>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/companydepartment/'}).use('companydepartmentadd');
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;margin:0 auto;padding-top:20px;">
<form class="layui-form" action="" id="showForm" autocomplete="off">
</form>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/companydepartment/'}).use('companydepartmentedit');
</script>
</body>
</html>
\ No newline at end of file
{{#bean}}
<div class="layui-form-item">
<div class="layui-input-block">
<button class="winui-btn" id="cancle">取消</button>
<button class="winui-btn" lay-submit lay-filter="formEditBean">保存</button>
</div>
</div>
{{/bean}}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="txtcenter" style="width:700px;margin:0 auto;padding-top:20px;">
<form class="layui-form layui-form-pane" action="" autocomplete="off">
<div class="layui-form-item">
<div class="layui-inline">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block" style="margin:0;">
<button class="layui-btn" lay-submit lay-filter="formSearch">搜索</button>
</div>
</div>
</form>
</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn"><i class="fa fa-refresh" aria-hidden="true"></i>刷新数据</button>
<button id="addBean" class="winui-toolbtn"><i class="fa fa-plus" aria-hidden="true"></i>新增公司部门信息</button>
</div>
</div>
<div style="margin:auto 10px;">
<table id="messageTable" lay-filter="messageTable"></table>
<script type="text/html" id="tableBar">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/companydepartment/'}).use('companydepartmentlist');
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册