添加部门树

This commit is contained in:
zhangzhiqiang
2022-12-01 08:51:50 +08:00
parent f0c119865d
commit e306540bb8
3 changed files with 23 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ import java.util.Objects;
public class DeptTree implements Serializable { public class DeptTree implements Serializable {
private Long Dept_id; private Long Dept_id;
private Long pid; private Long pid;
private String name; private String name;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)

View File

@@ -92,3 +92,20 @@
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
IF 输入.flag = "2"
PAGEQUERY
SELECT
max(t3.childId)
from
(
select *,
if( find_in_set(t1.pid, @p) > 0,@p := concat(@p,',',id),0 ) as childId
from
(select dept_id as id, pid from sys_dept t order by id) t1,
(select @p := '输入.pid') t2
) t3
where childId != '0'
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -78,10 +78,9 @@
<el-input v-model="form.email" style="width: 200px;" /> <el-input v-model="form.email" style="width: 200px;" />
</el-form-item> </el-form-item>
<el-form-item label="部门" prop="dept.id" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]"> <el-form-item label="部门" prop="dept.id" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<treeselect <el-tree-select
v-model="form.dept.id" v-model="form.dept.id"
:options="depts" :data="deptDatas"
:load-options="loadDepts"
style="width: 200px" style="width: 200px"
placeholder="选择部门" placeholder="选择部门"
/> />
@@ -365,7 +364,6 @@ export default {
getDeptTree() { getDeptTree() {
setTimeout(() => { setTimeout(() => {
getDeptTreee().then(res => { getDeptTreee().then(res => {
debugger
this.deptDatas = res.content this.deptDatas = res.content
}) })
}, 100) }, 100)
@@ -374,6 +372,7 @@ export default {
console.log('获取部门') console.log('获取部门')
getDepts({ is_used: 1 }).then(res => { getDepts({ is_used: 1 }).then(res => {
console.log('获取的部门信息', res) console.log('获取的部门信息', res)
this.depts = res.content.map(function(obj) { this.depts = res.content.map(function(obj) {
if (obj.hasChildren) { if (obj.hasChildren) {
obj.children = null obj.children = null
@@ -402,6 +401,7 @@ export default {
}, },
// 获取弹窗内部门数据 // 获取弹窗内部门数据
loadDepts({ action, parentNode, callback }) { loadDepts({ action, parentNode, callback }) {
debugger
if (action === LOAD_CHILDREN_OPTIONS) { if (action === LOAD_CHILDREN_OPTIONS) {
getDepts({ is_used: 1, pid: parentNode.id }).then(res => { getDepts({ is_used: 1, pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) { parentNode.children = res.content.map(function(obj) {