家庭教育手册-学习

This commit is contained in:
zhanglipeng 2021-06-21 09:49:02 +08:00
parent b4a7645469
commit 120d5a007b
8 changed files with 364 additions and 0 deletions

View File

@ -9,6 +9,14 @@ export function listFamilyedu(query) {
});
}
// 查询流程下拉树结构
export function treeselect() {
return request({
url: '/benyi/familyedu/treeselect',
method: 'get'
})
}
// 查询家庭教育详细
export function getFamilyedu(id) {
return request({

View File

@ -0,0 +1,184 @@
<template>
<div class="app-container">
<el-row :gutter="20">
<el-col :span="8" :xs="24">
<div class="head-container">
<el-input
v-model="name"
placeholder="请输入名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container tree">
<el-tree
:data="treeOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
:default-expand-all="false"
@node-click="handleNodeClick"
/>
</div>
</el-col>
<el-col :span="16" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span class="box-card-title">{{ title }}</span>
</div>
<div class="text item" v-show="title1">
<div class="pad-left" v-html="note"></div>
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { treeselect, getFamilyedu } from "@/api/benyi/familyedu";
export default {
name: "familyedu_study",
data() {
return {
//
name: undefined,
// id
id: undefined,
//
title: "本一家庭教育手册",
title1: "",
//
note: "",
//
treeOptions: [],
//
defaultProps: {
children: "children",
label: "label",
},
};
},
watch: {
//
name(val) {
this.$refs.tree.filter(val);
},
},
created() {
this.getTreeselect();
},
methods: {
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then((response) => {
this.treeOptions = response.data;
//console.log(response.data);
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.id = data.id;
console.log(data.id);
if (data.id >= 9999) {
} else {
this.title = data.label;
this.getFamilyeduDetails();
}
// console.log(this.dayflowtaskList[date.id])
// this.getStandardList();
},
getFamilyeduDetails() {
getFamilyedu(this.id).then((response) => {
console.log(response);
this.title1 = response.data.title;
this.note = response.data.content;
});
},
},
};
</script>
<style lang="scss" scoped>
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
line-height: 22px;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both;
}
.box-card-title {
display: flex;
align-items: center;
font-size: 16px;
&::before {
content: "";
margin-right: 8px;
width: 4px;
height: 16px;
background: #1890ff;
}
&.mr {
margin: 10px 0;
}
}
.box-card-case {
margin: 0;
font-size: 14px;
font-weight: 700;
display: flex;
align-items: center;
&::before {
content: "";
margin-right: 8px;
width: 4px;
height: 14px;
background: #2c3e50;
}
&.mr {
margin: 10px 0;
}
}
.box-card-info {
font-size: 14px;
font-weight: 700;
}
.pad-left {
padding-left: 15px;
}
//
div {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.el-tree {
min-width: 100%;
display: inline-block;
}
.tree {
overflow: auto;
max-height: 300px;
}
</style>

View File

@ -73,6 +73,14 @@ public class TreeSelect implements Serializable
this.children = byMicrocourse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
//下拉树构造器
public TreeSelect(ByFamilyedu byFamilyedu) {
this.id = byFamilyedu.getId();
this.label = byFamilyedu.getTitle();
this.children = byFamilyedu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
//下拉树构造器
public TreeSelect(ByMath bymath) {

View File

@ -2,6 +2,7 @@ package com.ruoyi.project.benyi.controller;
import java.util.List;
import com.ruoyi.project.benyi.domain.ByMicrocourse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -44,6 +45,16 @@ public class ByFamilyeduController extends BaseController {
return getDataTable(list);
}
/**
* 查询微型课程列表
*/
@Log(title = "家庭教育", businessType = BusinessType.QUERY)
@GetMapping("/treeselect")
public AjaxResult treeselect(ByFamilyedu byFamilyedu) {
List<ByFamilyedu> list = byFamilyeduService.selectByFamilyeduListTree(byFamilyedu);
return AjaxResult.success(byFamilyeduService.buildFamilyeduTreeSelect(list));
}
/**
* 导出家庭教育列表
*/

View File

@ -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_familyedu
*
@ -43,6 +46,11 @@ public class ByFamilyedu extends BaseEntity {
@Excel(name = "序号")
private Long sort;
/**
* 树状子类
*/
private List<ByFamilyedu> children = new ArrayList<ByFamilyedu>();
public void setId(Long id) {
this.id = id;
}
@ -83,6 +91,14 @@ public class ByFamilyedu extends BaseEntity {
return sort;
}
public List<ByFamilyedu> getChildren() {
return children;
}
public void setChildren(List<ByFamilyedu> children) {
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@ -3,6 +3,7 @@ package com.ruoyi.project.benyi.mapper;
import java.util.List;
import com.ruoyi.project.benyi.domain.ByFamilyedu;
import com.ruoyi.project.benyi.domain.ByMicrocourse;
/**
* 家庭教育Mapper接口
@ -27,6 +28,14 @@ public interface ByFamilyeduMapper {
*/
public List<ByFamilyedu> selectByFamilyeduList(ByFamilyedu byFamilyedu);
/**
* 查询家庭教育列表
*
* @param byFamilyedu 家庭教育
* @return 家庭教育集合
*/
public List<ByFamilyedu> selectByFamilyeduListTree(ByFamilyedu byFamilyedu);
/**
* 新增家庭教育
*

View File

@ -2,7 +2,9 @@ package com.ruoyi.project.benyi.service;
import java.util.List;
import com.ruoyi.framework.web.domain.TreeSelect;
import com.ruoyi.project.benyi.domain.ByFamilyedu;
import com.ruoyi.project.benyi.domain.ByMicrocourse;
/**
* 家庭教育Service接口
@ -27,6 +29,31 @@ public interface IByFamilyeduService {
*/
public List<ByFamilyedu> selectByFamilyeduList(ByFamilyedu byFamilyedu);
/**
* 查询家庭教育列表
*
* @param byFamilyedu 家庭教育
* @return 家庭教育集合
*/
public List<ByFamilyedu> selectByFamilyeduListTree(ByFamilyedu byFamilyedu);
/**
* 构建前端所需要树结构
*
* @param byFamilyedus 部门列表
* @return 树结构列表
*/
public List<ByFamilyedu> buildFamilyeduDetailTree(List<ByFamilyedu> byFamilyedus);
/**
* 构建前端所需要下拉树结构
*
* @param byFamilyedus 部门列表
* @return 下拉树结构列表
*/
public List<TreeSelect> buildFamilyeduTreeSelect(List<ByFamilyedu> byFamilyedus);
/**
* 新增家庭教育
*

View File

@ -1,8 +1,14 @@
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 com.ruoyi.project.benyi.domain.ByMicrocourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.benyi.mapper.ByFamilyeduMapper;
@ -42,6 +48,101 @@ public class ByFamilyeduServiceImpl implements IByFamilyeduService {
return byFamilyeduMapper.selectByFamilyeduList(byFamilyedu);
}
/**
* 查询家庭教育列表
*
* @param byFamilyedu 家庭教育
* @return 家庭教育集合
*/
@Override
public List<ByFamilyedu> selectByFamilyeduListTree(ByFamilyedu byFamilyedu){
return byFamilyeduMapper.selectByFamilyeduList(byFamilyedu);
}
/**
* 构建前端所需要树结构
*
* @param byFamilyedus 家庭教育列表
* @return 树结构列表
*/
@Override
public List<ByFamilyedu> buildFamilyeduDetailTree(List<ByFamilyedu> byFamilyedus) {
//System.out.println("start---");
List<ByFamilyedu> returnList = new ArrayList<ByFamilyedu>();
List<Long> tempList = new ArrayList<Long>();
for (ByFamilyedu item : byFamilyedus) {
tempList.add(item.getId());
}
for (Iterator<ByFamilyedu> iterator = byFamilyedus.iterator(); iterator.hasNext(); ) {
ByFamilyedu item = (ByFamilyedu) iterator.next();
//System.out.println("test==="+!tempList.contains(item.getParentId()));
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(item.getParentid())) {
recursionFn(byFamilyedus, item);
returnList.add(item);
}
}
if (returnList.isEmpty()) {
returnList = byFamilyedus;
}
return returnList;
}
/**
* 构建前端所需要下拉树结构
*
* @param byFamilyedus 部门列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildFamilyeduTreeSelect(List<ByFamilyedu> byFamilyedus) {
List<ByFamilyedu> byFamilyeduTrees = buildFamilyeduDetailTree(byFamilyedus);
return byFamilyeduTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 递归列表
*/
private void recursionFn(List<ByFamilyedu> list, ByFamilyedu t) {
// 得到子节点列表
List<ByFamilyedu> childList = getChildList(list, t);
t.setChildren(childList);
for (ByFamilyedu tChild : childList) {
if (hasChild(list, tChild)) {
// 判断是否有子节点
Iterator<ByFamilyedu> it = childList.iterator();
while (it.hasNext()) {
ByFamilyedu n = (ByFamilyedu) it.next();
recursionFn(list, n);
}
}
}
}
/**
* 得到子节点列表
*/
private List<ByFamilyedu> getChildList(List<ByFamilyedu> list, ByFamilyedu t) {
List<ByFamilyedu> tlist = new ArrayList<ByFamilyedu>();
Iterator<ByFamilyedu> it = list.iterator();
while (it.hasNext()) {
ByFamilyedu n = (ByFamilyedu) it.next();
if (StringUtils.isNotNull(n.getParentid()) && n.getParentid().longValue() == t.getId().longValue()) {
//System.out.println("parentid="+n.getParentId().longValue()+"---"+t.getId().longValue());
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<ByFamilyedu> list, ByFamilyedu t) {
return getChildList(list, t).size() > 0 ? true : false;
}
/**
* 新增家庭教育
*