一日流程树状查看部分代码
This commit is contained in:
parent
82b81e3dc4
commit
5b219c87be
@ -50,6 +50,7 @@
|
||||
"@riophae/vue-treeselect": "0.4.0",
|
||||
"axios": "0.18.1",
|
||||
"clipboard": "2.0.4",
|
||||
"driver.js": "^0.9.8",
|
||||
"echarts": "4.2.1",
|
||||
"element-ui": "2.13.0",
|
||||
"file-saver": "2.0.1",
|
||||
|
@ -18,6 +18,14 @@ export function getDetail(id) {
|
||||
})
|
||||
}
|
||||
|
||||
// 查询流程下拉树结构
|
||||
export function treeselect() {
|
||||
return request({
|
||||
url: '/benyi/dayflow/dayflowmanger/treeselect',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增一日流程
|
||||
export function addDetail(data) {
|
||||
return request({
|
||||
|
@ -477,6 +477,7 @@ export default {
|
||||
getTreeselect() {
|
||||
treeselect().then(response => {
|
||||
this.deptOptions = response.data;
|
||||
console.log(this.deptOptions);
|
||||
});
|
||||
},
|
||||
// 筛选节点
|
||||
|
@ -1,77 +1,82 @@
|
||||
package com.ruoyi.framework.web.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.project.system.domain.SysDept;
|
||||
import com.ruoyi.project.system.domain.SysMenu;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class TreeSelect implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 节点ID */
|
||||
private Long id;
|
||||
|
||||
/** 节点名称 */
|
||||
private String label;
|
||||
|
||||
/** 子节点 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
|
||||
public TreeSelect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TreeSelect(SysDept dept)
|
||||
{
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TreeSelect(SysMenu menu)
|
||||
{
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelect> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
package com.ruoyi.framework.web.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.project.benyi.domain.ByDayFlowDetail;
|
||||
import com.ruoyi.project.system.domain.SysDept;
|
||||
import com.ruoyi.project.system.domain.SysMenu;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class TreeSelect implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 节点ID */
|
||||
private Long id;
|
||||
|
||||
/** 节点名称 */
|
||||
private String label;
|
||||
|
||||
/** 子节点 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
|
||||
|
||||
public TreeSelect(SysDept dept)
|
||||
{
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TreeSelect(SysMenu menu)
|
||||
{
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//下拉树构造器
|
||||
public TreeSelect(ByDayFlowDetail byDayFlowDetail) {
|
||||
|
||||
this.id = byDayFlowDetail.getId();
|
||||
this.label = byDayFlowDetail.getName();
|
||||
this.children = byDayFlowDetail.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelect> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,15 @@ public class ByDayFlowDetailController extends BaseController
|
||||
return AjaxResult.success(byDayFlowDetailService.selectByDayFlowDetailById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(ByDayFlowDetail byDayFlowDetail) {
|
||||
List<ByDayFlowDetail> byDayFlowDetails = byDayFlowDetailService.selectByDayFlowDetailList(byDayFlowDetail);
|
||||
return AjaxResult.success(byDayFlowDetailService.buildDayFlowDetailTreeSelect(byDayFlowDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一日流程
|
||||
*/
|
||||
|
@ -5,6 +5,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
||||
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一日流程对象 by_day_flow_detail
|
||||
*
|
||||
@ -18,6 +21,12 @@ public class ByDayFlowDetail extends BaseEntity
|
||||
/** 流程ID */
|
||||
private Long id;
|
||||
|
||||
/** 树状父类ID */
|
||||
private Long parentid;
|
||||
|
||||
/** 树状子类 */
|
||||
private List<ByDayFlowDetail> children = new ArrayList<ByDayFlowDetail>();
|
||||
|
||||
/** 流程序号 */
|
||||
@Excel(name = "流程序号")
|
||||
private Long sortNumber;
|
||||
@ -146,6 +155,23 @@ public class ByDayFlowDetail extends BaseEntity
|
||||
.append("updateUser", getUpdateUser())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("parentid", getParentid())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public Long getParentid() {
|
||||
return parentid;
|
||||
}
|
||||
|
||||
public void setParentid(Long parentid) {
|
||||
this.parentid = parentid;
|
||||
}
|
||||
|
||||
public List<ByDayFlowDetail> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ByDayFlowDetail> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,14 @@ public interface ByDayFlowDetailMapper
|
||||
*/
|
||||
public List<ByDayFlowDetail> selectByDayFlowDetailList(ByDayFlowDetail byDayFlowDetail);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门
|
||||
*
|
||||
* @param id 部门ID
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<ByDayFlowDetail> selectChildrenByDayFlowDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 新增一日流程
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.ruoyi.project.benyi.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.framework.web.domain.TreeSelect;
|
||||
import com.ruoyi.project.benyi.domain.ByDayFlowDetail;
|
||||
|
||||
/**
|
||||
@ -27,6 +29,22 @@ public interface IByDayFlowDetailService
|
||||
*/
|
||||
public List<ByDayFlowDetail> selectByDayFlowDetailList(ByDayFlowDetail byDayFlowDetail);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param byDayFlowDetails 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<ByDayFlowDetail> buildDayFlowDetailTree(List<ByDayFlowDetail> byDayFlowDetails);
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param byDayFlowDetails 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
public List<TreeSelect> buildDayFlowDetailTreeSelect(List<ByDayFlowDetail> byDayFlowDetails);
|
||||
|
||||
/**
|
||||
* 新增一日流程
|
||||
*
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.ruoyi.project.benyi.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.domain.TreeSelect;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.project.benyi.mapper.ByDayFlowDetailMapper;
|
||||
@ -44,6 +50,99 @@ public class ByDayFlowDetailServiceImpl implements IByDayFlowDetailService
|
||||
return byDayFlowDetailMapper.selectByDayFlowDetailList(byDayFlowDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param byDayFlowDetails 部门列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<ByDayFlowDetail> buildDayFlowDetailTree(List<ByDayFlowDetail> byDayFlowDetails) {
|
||||
List<ByDayFlowDetail> returnList = new ArrayList<ByDayFlowDetail>();
|
||||
List<Long> tempList = new ArrayList<Long>();
|
||||
for (ByDayFlowDetail byDayFlowDetail : byDayFlowDetails)
|
||||
{
|
||||
tempList.add(byDayFlowDetail.getParentid());
|
||||
}
|
||||
for (Iterator<ByDayFlowDetail> iterator = byDayFlowDetails.iterator(); iterator.hasNext();)
|
||||
{
|
||||
ByDayFlowDetail byDayFlowDetail = (ByDayFlowDetail) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(byDayFlowDetail.getParentid()))
|
||||
{
|
||||
recursionFn(byDayFlowDetails, byDayFlowDetail);
|
||||
returnList.add(byDayFlowDetail);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = byDayFlowDetails;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要下拉树结构
|
||||
*
|
||||
* @param byDayFlowDetails 部门列表
|
||||
* @return 下拉树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeSelect> buildDayFlowDetailTreeSelect(List<ByDayFlowDetail> byDayFlowDetails)
|
||||
{
|
||||
List<ByDayFlowDetail> dayFlowDetailTrees = buildDayFlowDetailTree(byDayFlowDetails);
|
||||
return dayFlowDetailTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<ByDayFlowDetail> list, ByDayFlowDetail t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<ByDayFlowDetail> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (ByDayFlowDetail tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
// 判断是否有子节点
|
||||
Iterator<ByDayFlowDetail> it = childList.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
ByDayFlowDetail n = (ByDayFlowDetail) it.next();
|
||||
recursionFn(list, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<ByDayFlowDetail> getChildList(List<ByDayFlowDetail> list, ByDayFlowDetail t)
|
||||
{
|
||||
List<ByDayFlowDetail> tlist = new ArrayList<ByDayFlowDetail>();
|
||||
Iterator<ByDayFlowDetail> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
ByDayFlowDetail n = (ByDayFlowDetail) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentid()) && n.getParentid().longValue() == t.getId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<ByDayFlowDetail> list, ByDayFlowDetail t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一日流程
|
||||
*
|
||||
|
@ -42,6 +42,10 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenByDayFlowDetailById" parameterType="Long" resultMap="ByDayFlowDetailResult">
|
||||
select * from sys_dept where find_in_set(#{deptId})
|
||||
</select>
|
||||
|
||||
<insert id="insertByDayFlowDetail" parameterType="ByDayFlowDetail" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into by_day_flow_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -30,11 +30,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectSysDeptList" parameterType="Long" resultMap="SysDeptResult">
|
||||
select * from sys_dept where dept_id in (
|
||||
select dept_id from (
|
||||
select dept_id,user_id from sys_user
|
||||
union all
|
||||
select dept_id,user_id from sys_user_dept) t
|
||||
where t.user_id=#{userId})
|
||||
select dept_id from (
|
||||
select dept_id,user_id from sys_user
|
||||
union all
|
||||
select dept_id,user_id from sys_user_dept) t
|
||||
where t.user_id=#{userId})
|
||||
</select>
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user