Commit 1e3c13c4 by caowenda

添加组织 添加人员流程修改 页面修改

parent abcb2e34
package com.bbd.bpm.controller.user;
import com.bbd.bpm.base.PageBean;
import com.bbd.bpm.result.RespCode;
import com.bbd.bpm.result.Result;
import com.bbd.bpm.result.ResultUtil;
import com.bbd.bpm.service.UserInfoService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -58,14 +60,14 @@ public class userController {
**/
@RequestMapping(value = "getOrganization")
@ResponseBody
public Result getOrganization(PageBean pageBean,Integer id,Integer pId){
public Result getOrganization(PageBean pageBean,Integer id,Integer pId,String name){
if(pageBean.getPageNum()==0){
pageBean.setPageNum(1);
}
if (pageBean.getPageSize()==0) {
pageBean.setPageSize(10);
}
Result result= userInfoService.getOrganization(pageBean,id,pId);
Result result= userInfoService.getOrganization(pageBean,id,pId,name);
return result;
}
......@@ -110,9 +112,9 @@ public class userController {
**/
@RequestMapping(value = "addOrganizationMember")
@ResponseBody
public Result addOrganizationMember(String name, String position, Long pId, Integer id){
public Result addOrganizationMember(String name, String position, Long pId, Integer id,Integer department,Integer type){
//获取session中的值
Result result = userInfoService.addOrganizationMember(name,position,pId,id);
Result result = userInfoService.addOrganizationMember(name,position,pId,id,department,type);
return result;
}
......@@ -131,4 +133,32 @@ public class userController {
return result;
}
/**
* 删除组织及下级
* @param id
* @param pId
* @return
*/
@RequestMapping(value = "deleteOrganization")
@ResponseBody
public Result deleteOrganization(Long id,Integer pId){
Result result = userInfoService.deleteOrganization(id,pId);
return result;
}
/**
* 获取下级部门信息
* @return
*/
@RequestMapping(value = "getAreaAll")
@ResponseBody
public Result getAreaAll(Integer id){
Result areaList = userInfoService.getAreaAll(id);
return areaList;
}
}
......@@ -14,5 +14,13 @@ import java.util.Map;
@Repository
public interface MemberMapper extends BaseMapper<BpmEmployee>{
List<BpmCompanyVo> getMemberList(@Param("id") Integer id);
List<BpmCompanyVo> getMemberList(@Param("id") Integer id, @Param("name") String name);
void deletedMember(@Param("id") Long id);
void deletedMembers(@Param("id") Long id);
List<BpmCompanyVo> getAllMemberList(@Param("id") Integer id, @Param("name") String name);
List<Map<String,Object>> getAreaAll(@Param("id") Integer id);
}
......@@ -18,5 +18,48 @@
LEFT JOIN bpm_company c ON c.id = a.code_id
WHERE
a.`status` = 0 and department=#{id}
<if test="name!=null">
and a.name LIKE CONCAT('%',#{name},'%')
</if>
</select>
<select id="getAllMemberList" resultType="com.bbd.bpm.vo.BpmEmployeeVo">
SELECT
a.id,
a.created_time createdTime,
a.update_time updateTime,
a.`name`,
a.position,
b.`name` department,
c.`code`
FROM
bpm_employee a
LEFT JOIN bpm_company b ON b.id = a.department
LEFT JOIN bpm_company c ON c.id = a.code_id
WHERE
a.`status` = 0 and code_id=#{id}
<if test="name!=null">
and a.name LIKE CONCAT('%',#{name},'%')
</if>
</select>
<update id="deletedMember">
update bpm_employee set status=2 where code_id=#{id}
</update>
<update id="deletedMembers">
update bpm_employee set status=2 where department=#{id}
</update>
<select id="getAreaAll" resultType="map">
SELECT
id,
`name`
FROM
bpm_company
WHERE
parent_id=#{id}
</select>
</mapper>
\ No newline at end of file
......@@ -4,7 +4,6 @@ package com.bbd.bpm.dao;
import com.bbd.bpm.base.BaseMapper;
import com.bbd.bpm.domain.BpmCompany;
import com.bbd.bpm.vo.BpmCompanyVo;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -14,7 +13,7 @@ import java.util.Map;
@Repository
public interface UserInfoMapper extends BaseMapper<BpmCompany>{
List<BpmCompanyVo> getOrganization(@Param("id") Integer id);
List<BpmCompanyVo> getOrganization(@Param("id") Integer id, @Param("name") String name);
List<Map<String,Object>> getOrganizationList();
......@@ -23,4 +22,8 @@ public interface UserInfoMapper extends BaseMapper<BpmCompany>{
String getOrganizationRelation(@Param("id") Integer id);
Map<String,Object> getOrganizationInfo(@Param("id") Integer id);
void deleteDepartment(@Param("id") Long id);
void deleteDepartments(@Param("id") Long id);
}
......@@ -20,6 +20,9 @@
<if test="id!=null">
and parent_id=#{id}
</if>
<if test="name!=null">
and name LIKE CONCAT('%',#{name},'%')
</if>
</select>
<!--组织架构菜单-->
......@@ -63,4 +66,12 @@
id = #{id}
</select>
<update id="deleteDepartment">
update bpm_company set status=2 where parent_id=#{id}
</update>
<update id="deleteDepartments">
update bpm_company set status=2 where id=#{id}
</update>
</mapper>
\ No newline at end of file
......@@ -6,12 +6,12 @@ import com.bbd.bpm.result.Result;
public interface UserInfoService {
/**
* @Author:cwd
* @Description:获取组织列表
* @Description:获取组织列表
* @Date: 2019/03/04 22:53
* @Param:
* @return
**/
Result getOrganization(PageBean pageBean, Integer id, Integer pId);
Result getOrganization(PageBean pageBean, Integer id, Integer pId, String name);
/**
* @Author:cwd
* @Description:加载ztree
......@@ -35,7 +35,7 @@ public interface UserInfoService {
* @Param:
* @return
**/
Result addOrganizationMember(String name, String position, Long pId, Integer id);
Result addOrganizationMember(String name, String position, Long pId, Integer id, Integer department, Integer type);
/**
* @Author:cwd
* @Description:获取组织详情
......@@ -52,4 +52,18 @@ public interface UserInfoService {
* @return
**/
Result editOrganization(String name, String abbreviationName, Integer id);
/**
* 删除组织及下级
* @param id
* @param pId
* @return
*/
Result deleteOrganization(Long id, Integer pId);
/**
* 获取组织下级部门
* @param id
* @param pId
* @return
*/
Result getAreaAll(Integer id);
}
......@@ -33,7 +33,7 @@ public class UserInfoServiceImpl implements UserInfoService{
* @return
**/
@Override
public Result getOrganization(PageBean pageBean, Integer id, Integer pId) {
public Result getOrganization(PageBean pageBean, Integer id, Integer pId, String name) {
try{
if(pId==null){
......@@ -41,7 +41,7 @@ public class UserInfoServiceImpl implements UserInfoService{
if(id==null){
id=1;
}
List<BpmCompanyVo> list = userInfoMapper.getOrganization(id);
List<BpmCompanyVo> list = userInfoMapper.getOrganization(id,name);
BpmCompanyVo bpmCompanyVo;
for (int i=0;i<list.size();i++){
Integer pIds = list.get(i).getPId();
......@@ -56,22 +56,15 @@ public class UserInfoServiceImpl implements UserInfoService{
return ResultUtil.getResult(RespCode.Code.SUCCESS, map);
}else if(pId==1){
PageHelper.startPage(pageBean.getPageNum(), pageBean.getPageSize());
List<BpmCompanyVo> list = userInfoMapper.getOrganization(id);
BpmCompanyVo bpmCompanyVo;
for (int i=0;i<list.size();i++){
Integer pIds = list.get(i).getPId();
bpmCompanyVo=userInfoMapper.getParentName(pIds);
//根据pid获取上级组织名称
list.get(i).setParentName(bpmCompanyVo.getName());
}
List<BpmCompanyVo> list = memberMapper.getAllMemberList(id,name);
PageInfo<BpmCompanyVo> pageInfo = new PageInfo<>(list);
Map<String, Object> map = new HashMap<>(16);
map.put("pageInfo", pageInfo);
map.put("type", 1);
map.put("type", 2);
return ResultUtil.getResult(RespCode.Code.SUCCESS, map);
}else{
PageHelper.startPage(pageBean.getPageNum(), pageBean.getPageSize());
List<BpmCompanyVo> list = memberMapper.getMemberList(id);
List<BpmCompanyVo> list = memberMapper.getMemberList(id,name);
PageInfo<BpmCompanyVo> pageInfo = new PageInfo<>(list);
Map<String, Object> map = new HashMap<>(16);
map.put("pageInfo", pageInfo);
......@@ -151,14 +144,20 @@ public class UserInfoServiceImpl implements UserInfoService{
* @return
**/
@Override
public Result addOrganizationMember(String name, String position, Long pId, Integer id) {
public Result addOrganizationMember(String name, String position, Long pId, Integer id, Integer department, Integer type) {
try {
BpmEmployee bpmEmployee=new BpmEmployee();
bpmEmployee.setCreateTime(new Date());
bpmEmployee.setUpdateTime(new Date());
bpmEmployee.setName(name);
bpmEmployee.setCodeId(pId.intValue());
bpmEmployee.setDepartment(id);
if(type!=null){
bpmEmployee.setDepartment(department);
bpmEmployee.setCodeId(id);
}else {
bpmEmployee.setDepartment(id);
bpmEmployee.setCodeId(pId.intValue());
}
bpmEmployee.setPosition(position);
bpmEmployee.setStatus(0);
memberMapper.insert(bpmEmployee);
......@@ -207,4 +206,49 @@ public class UserInfoServiceImpl implements UserInfoService{
return ResultUtil.getResult(RespCode.Code.INTERNAL_SERVER_ERROR);
}
}
/**
* 删除组织及下级
* @param id
* @param pId
* @return
*/
@Override
public Result deleteOrganization(Long id, Integer pId) {
try{
//pId为0删除的是组织,部门,人员 为1删除的是部门和人员
if(pId==0){
//通过id删除组织,下级部门,人员
BpmCompany bpmCompany=new BpmCompany();
bpmCompany.setId(id);
bpmCompany.setStatus(2);
//删除当前组织
userInfoMapper.updateByPrimaryKeySelective(bpmCompany);
//删除组织下的部门
userInfoMapper.deleteDepartment(id);
//删除人员(人员所属组织编码id 放的组织的id可以直接删除 status为2)
memberMapper.deletedMember(id);
}else if(pId==1){
//删除部门
userInfoMapper.deleteDepartments(id);
//删除部门人员
memberMapper.deletedMembers(id);
}
return ResultUtil.getResult(RespCode.Code.SUCCESS);
}catch (Exception e){
e.printStackTrace();
return ResultUtil.getResult(RespCode.Code.INTERNAL_SERVER_ERROR);
}
}
@Override
public Result getAreaAll(Integer id) {
try {
List<Map<String,Object>> list=this.memberMapper.getAreaAll(id);
return ResultUtil.getResult(RespCode.Code.SUCCESS,list);
}catch (Exception e){
e.printStackTrace();
return ResultUtil.getResult(RespCode.Code.INTERNAL_SERVER_ERROR);
}
}
}
......@@ -82,8 +82,8 @@
<p class="search_pro" style="height: auto;overflow: hidden;display: block; padding: 0;">
<span ><b id="spanB">组织名称:</b><input type="text" value="" placeholder="请输入" name="name" style="color: black"/></span>
<span style="width: 200px;"><button style=" border: 1px solid #000000;background-color: #2b2b2b;width: 64px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;" onclick="queryDeviceRecords()">查询</button></span><span style="width: 67px;float: right" id="add">
<button id="addOr" style=" border: 1px solid #000000;background-color: #2b2b2b;width: 64px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;" onclick="add()">添加</button></span>
<button id="addMe" style="float: right;margin-top: 7px; border: 1px solid #000000;background-color: #2b2b2b;width: 64px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;" onclick="add()">添加</button></span>
<button id="addOr" style=" border: 1px solid #000000;background-color: #2b2b2b;width: 70px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;margin-left: -1px;" onclick="add(1)">添加组织</button></span>
<button id="addMe" style="float: right;margin-top: 7px; border: 1px solid #000000;background-color: #2b2b2b;width: 70px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;" onclick="add(2)">添加人员</button></span>
</p>
</div>
......@@ -287,7 +287,7 @@
var content = '';
if (type == 2){
$("#addMe").show();
$("#addOr").hide();
$("#addOr").show();
$("#spanB").html("人员信息:")
$("#type").val(1);
content += "<tr><th>人员编号</th><th>人员名称</th><th>职位</th><th>部门</th><th>所属组织编码</th><th>加入时间</th><th >操作</th></tr>";
......@@ -301,7 +301,7 @@
if(data!=null){
if (type==2) {
for (var i in data) {
content += "<tr><td>"+ data[i].id + "</td><td>" + data[i].name + "</td><td>" + data[i].position + "</td><td>" + data[i].department + "</td><td>" + data[i].code +"</td><td>" + data[i].createdTime + "</td><td><a href='#' onclick='toTeamInfo(" + data[i].id + ")'>查看</a></td></tr>";
content += "<tr><td>"+ data[i].id + "</td><td>" + data[i].name + "</td><td>" + data[i].position + "</td><td>" + data[i].department + "</td><td>" + data[i].code +"</td><td>" + data[i].createdTime + "</td><td>" + "<a href='#' onclick='gotoDetails(\"" + data[i].name + "\",\"" + data[i].position + "\",\"" + data[i].department + "\",\"" + data[i].code + "\",\"" + data[i].createdTime + "\")'>查看</a></td></tr>";
}
}else{
for (var i in data) {
......@@ -322,14 +322,15 @@
$('table').html(content);
}
function toTeamInfo(teamId) {
location.href="/teamManage/goTeamInfo?teamId="+teamId+"&status="+status;
function gotoDetails(name,position,department,code,createdTime){
var content = '<div><p>人员名称:'+name+'</p><p>职位:'+position+'</p><p>部门:'+department+'</p><p>所属组织编码:'+code+'</p><p>加入时间:'+createdTime+'</p></div>';
layer.alert(content)
}
/*条件查询砍价商品*/
/*
/*条件查询*/
function queryDeviceRecords() {
var id = $("#pid").val();
var pId = $("#pid").val();
var id = $("#id").val();
var type = $("#type").val();
var name = $("[name='name']").val();
$.post(
......@@ -337,6 +338,7 @@
{
pageSize:10,
pageNum:1,
pId:pId,
id:id,
name:name,
type:type
......@@ -346,7 +348,7 @@
if (!data.data.pageInfo.pages){
size = 0;
}
/!*分页*!/
/*分页*/
$(".pagediv").createPage({
pageNum: size,//总页码
current: 1,//当前页
......@@ -359,11 +361,12 @@
});
},'json')
}
*/
function dele(id,name) {
var pId = $("#pid").val();
alert(pId)
if(pId==''){
pId=0;
}
layer.open({
id:1,
type: 1,
......@@ -376,8 +379,9 @@
btn1: function (index,layero) {
$.post(
"/bpm/user/deleteOrganization",
{"id":id},
{"id":id,"pId":pId},
function (data) {
console.log(data)
if (data.code==200){
layer.msg('操作成功',{icon:1,time:1000},function () {
location.reload();
......@@ -526,15 +530,18 @@
}
function add() {
function add(type) {
var pId = $("#pid").val();
var id = $("#id").val();
alert(id);
alert(pId)
if (pId==1 || pId==''){
if (type==1){
var content = '<div style="margin-top: 13px;margin-left: 27px;"><span ><b>组织名称:</b><input type="text" value="" placeholder="请输入组织名称" name="oName" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px;margin-left: 26px;"/></span><br>\n' +
'\t\t<span ><b>组织简写(英):</b><input type="text" value="" placeholder="请输入组织简写" name="abbreviationName" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px;"/></span><br>\n';
}else {
}else if (pId==1&& type==2){
var content = '<div style="margin-top: 13px;margin-left: 27px;"><span ><b>人员名称:</b><input type="text" value="" placeholder="请输入人员名称" name="oName" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px;margin-left: 16px;"/></span><br>\n' +
'\t\t<span ><b>所在部门:</b><select name="areaId" id="areaId" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px;margin-left: 16px;width: 159px;"></select></span><br>\n' +
'\t\t<span ><b style="margin-left: 32px;">职位:</b><input type="text" value="" placeholder="请输入职位" name="position" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px; margin-left: 16px;"/></span><br>\n';
}
else {
var content = '<div style="margin-top: 13px;margin-left: 27px;"><span ><b>人员名称:</b><input type="text" value="" placeholder="请输入人员名称" name="oName" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px;margin-left: 16px;"/></span><br>\n' +
'\t\t<span ><b style="margin-left: 32px;">职位:</b><input type="text" value="" placeholder="请输入职位" name="position" style="color: black;height: 30px;border: 1px solid #EEEEEE;text-indent: 5px; margin-left: 16px;"/></span><br>\n';
}
......@@ -542,7 +549,25 @@
var tel=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
var phones=/^(\d3,4\d3,4|\d{3,4}-)?\d{7,8}$/;
if(pId==1 || pId==''){
if (pId==1){
var desc = "<option value=''>"+'请选择'+"</option>";
$.post(
"/bpm/user/getAreaAll",
{
"id":id
},
function (data) {
data=data.data
for(var i in data){
desc+="<option value='"+data[i].id+"'>"+data[i].name+"</option>";
}
$("#areaId").html(desc)
},'json'
)
}
if(type==1){
layer.open({
id:1,
type: 1,
......@@ -585,6 +610,53 @@
layer.close(index);
}
});
}
else if(pId==1 && type==2){
layer.open({
id:1,
type: 1,
title:'添加部门人员',
skin:'layui-layer-rim',
area:['360px', '330px'],
content: content
,
btn:['保存','取消'],
btn1: function (index,layero) {
var name = $("[name='oName']").val();
var position = $("[name='position']").val();
var areaId = $("[name='areaId']").val();
if (name==''){
layer.msg("人员名称不能为空");
}else if (position==''){
layer.msg("职位");
}else {
$.post(
"/bpm/user/addOrganizationMember",
{
"type":1,
"department":areaId,
"name":name,
"position":position,
"pId":pId,
"id":id
},
function (data) {
if (data.code==200){
layer.msg('操作成功',{icon:1,time:1000},function () {
location.reload();
})
}else{
layer.msg(data.message,{icon:2,time:1000});
}
},'json'
)
}
},
btn2:function (index,layero) {
layer.close(index);
}
});
}else{
layer.open({
id:1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment