fix:部门管理列表
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.nl.modules.system.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.nl.modules.system.service.dto.MenuDto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2019-03-25
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DeptVo implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
private Long dept_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer dept_sort;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "部门名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
private Boolean is_used;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级部门")
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||||
|
private Integer sub_count = 0;
|
||||||
|
//前端显示
|
||||||
|
private Boolean hasChildren =Boolean.FALSE;
|
||||||
|
|
||||||
|
private List<DeptVo> children;
|
||||||
|
|
||||||
|
public void setSub_count(Integer sub_count) {
|
||||||
|
this.sub_count = sub_count;
|
||||||
|
if (sub_count>0){
|
||||||
|
this.hasChildren=Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,10 +28,12 @@ import org.nl.modules.common.exception.BadRequestException;
|
|||||||
import org.nl.modules.common.utils.PageUtil;
|
import org.nl.modules.common.utils.PageUtil;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
import org.nl.modules.system.domain.Dept;
|
import org.nl.modules.system.domain.Dept;
|
||||||
|
import org.nl.modules.system.domain.vo.DeptVo;
|
||||||
import org.nl.modules.system.service.DeptService;
|
import org.nl.modules.system.service.DeptService;
|
||||||
import org.nl.modules.system.service.dto.DeptDto;
|
import org.nl.modules.system.service.dto.DeptDto;
|
||||||
import org.nl.modules.system.service.dto.DeptQueryCriteria;
|
import org.nl.modules.system.service.dto.DeptQueryCriteria;
|
||||||
import org.nl.modules.system.service.dto.DeptTree;
|
import org.nl.modules.system.service.dto.DeptTree;
|
||||||
|
import org.nl.modules.system.util.CopyUtil;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -60,6 +62,18 @@ public class DeptController {
|
|||||||
return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK);
|
return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询部门")
|
||||||
|
@GetMapping("/vo")
|
||||||
|
public ResponseEntity<Object> queryvo(DeptQueryCriteria criteria) throws Exception {
|
||||||
|
if (criteria.getPid() == null){
|
||||||
|
criteria.setPidIsNull(true);
|
||||||
|
}
|
||||||
|
List<Dept> deptDtos = deptService.queryAll(criteria, true);
|
||||||
|
List<DeptVo> deptVos = CopyUtil.copyList(deptDtos, DeptVo.class);
|
||||||
|
return new ResponseEntity<>(PageUtil.toPage(deptVos, deptVos.size()),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("查询所有部门树")
|
@ApiOperation("查询所有部门树")
|
||||||
@GetMapping("/allTree")
|
@GetMapping("/allTree")
|
||||||
public ResponseEntity<Object> allTree(DeptQueryCriteria criteria) throws Exception {
|
public ResponseEntity<Object> allTree(DeptQueryCriteria criteria) throws Exception {
|
||||||
@@ -80,6 +94,7 @@ public class DeptController {
|
|||||||
List<DeptTree> superior = deptService.getSuperior(deptTree, new ArrayList<>());
|
List<DeptTree> superior = deptService.getSuperior(deptTree, new ArrayList<>());
|
||||||
deptDtos.addAll(superior);
|
deptDtos.addAll(superior);
|
||||||
}
|
}
|
||||||
|
List<DeptVo> deptVos = CopyUtil.copyList(deptDtos, DeptVo.class);
|
||||||
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptDtos)),HttpStatus.OK);
|
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptDtos)),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +113,7 @@ public class DeptController {
|
|||||||
@Log("修改部门")
|
@Log("修改部门")
|
||||||
@ApiOperation("修改部门")
|
@ApiOperation("修改部门")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@SaCheckPermission("dept:edit")
|
// @SaCheckPermission("dept:edit")
|
||||||
public ResponseEntity<Object> update(@RequestBody Dept resources){
|
public ResponseEntity<Object> update(@RequestBody Dept resources){
|
||||||
deptService.update(resources);
|
deptService.update(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
}
|
}
|
||||||
Dept dept = findById(resources.getDept_id());
|
Dept dept = findById(resources.getDept_id());
|
||||||
resources.setDept_id(dept.getDept_id());
|
resources.setDept_id(dept.getDept_id());
|
||||||
WQLObject.getWQLObject("sys_user").update((JSONObject)JSON.toJSON(resources),"dept_id = '"+resources.getDept_id()+"'");
|
WQLObject.getWQLObject("sys_dept").update((JSONObject)JSON.toJSON(resources),"dept_id = '"+resources.getDept_id()+"'");
|
||||||
// 更新父节点中子节点数目
|
// 更新父节点中子节点数目
|
||||||
updateSubCnt(oldPid);
|
updateSubCnt(oldPid);
|
||||||
updateSubCnt(newPid);
|
updateSubCnt(newPid);
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package org.nl.modules.system.util;
|
|||||||
|
|
||||||
import org.nl.modules.system.service.GenCodeService;
|
import org.nl.modules.system.service.GenCodeService;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
|
|
||||||
public class CodeUtil {
|
public class CodeUtil {
|
||||||
|
|
||||||
@@ -15,4 +16,5 @@ public class CodeUtil {
|
|||||||
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
|
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.nl.modules.system.util;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2022/12/1 3:35 下午
|
||||||
|
*/
|
||||||
|
public class CopyUtil {
|
||||||
|
public static <F, T> List<T> copyList(final Collection<F> sources, final Class<T> clazz) {
|
||||||
|
if (sources == null) {
|
||||||
|
return new ArrayList(0);
|
||||||
|
} else {
|
||||||
|
List<T> list = new ArrayList(sources.size());
|
||||||
|
Iterator var3 = sources.iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
Object source = var3.next();
|
||||||
|
|
||||||
|
try {
|
||||||
|
T dest = clazz.newInstance();
|
||||||
|
BeanUtils.copyProperties(source, dest);
|
||||||
|
list.add(dest);
|
||||||
|
} catch (Throwable var6) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
sys_dept
|
sys_dept
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
OPTION 输入.pid <> ""
|
OPTION 输入.pid <> ""
|
||||||
pid = 输入.id
|
pid = 输入.pid
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
OPTION 输入.name <> ""
|
OPTION 输入.name <> ""
|
||||||
name = 输入.name
|
name = 输入.name
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default {
|
|||||||
this.timmer = setTimeout(() => {
|
this.timmer = setTimeout(() => {
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
this.logout()
|
this.logout()
|
||||||
}, 1000 * 60 * 15) // 15分钟 https://blog.csdn.net/qq_42345108/article/details/103496456
|
}, 1000 * 60 * 151) // 15分钟 https://blog.csdn.net/qq_42345108/article/details/103496456
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ export function getDeptSuperior(ids) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDeptvo(params) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept/vo',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function add(data) {
|
export function add(data) {
|
||||||
return request({
|
return request({
|
||||||
url: 'api/dept',
|
url: 'api/dept',
|
||||||
@@ -49,4 +57,4 @@ export function edit(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { add, edit, del, getDepts, getDeptSuperior }
|
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo }
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!--表格渲染-->
|
<!--表格渲染 :load="getDeptDatas" 点击事件 row-key需要指定唯一的数据id-->
|
||||||
<el-table
|
<el-table
|
||||||
ref="table"
|
ref="table"
|
||||||
v-loading="crud.loading"
|
v-loading="crud.loading"
|
||||||
@@ -93,13 +93,13 @@
|
|||||||
:load="getDeptDatas"
|
:load="getDeptDatas"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
:data="crud.data"
|
:data="crud.data"
|
||||||
row-key="id"
|
row-key="dept_id"
|
||||||
@select="crud.selectChange"
|
@select="crud.selectChange"
|
||||||
@select-all="crud.selectAllChange"
|
@select-all="crud.selectAllChange"
|
||||||
@selection-change="crud.selectionChangeHandler"
|
@selection-change="crud.selectionChangeHandler"
|
||||||
>
|
>
|
||||||
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
||||||
<!-- <el-table-column label="编码" prop="code" />-->
|
<!-- <el-table-column label="编码" prop="code" />-->
|
||||||
<el-table-column label="名称" prop="name" />
|
<el-table-column label="名称" prop="name" />
|
||||||
<el-table-column label="排序" prop="deptSort" />
|
<el-table-column label="排序" prop="deptSort" />
|
||||||
<el-table-column label="状态" align="center" prop="enabled">
|
<el-table-column label="状态" align="center" prop="enabled">
|
||||||
@@ -146,6 +146,7 @@ import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
|||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
|
import { getDeptvo } from '../../../api/system/dept'
|
||||||
|
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
id: null,
|
id: null,
|
||||||
@@ -163,7 +164,7 @@ export default {
|
|||||||
name: 'Dept',
|
name: 'Dept',
|
||||||
components: { Treeselect, crudOperation, rrOperation, udOperation },
|
components: { Treeselect, crudOperation, rrOperation, udOperation },
|
||||||
cruds() {
|
cruds() {
|
||||||
return CRUD({ title: '部门', url: 'api/dept', crudMethod: { ...crudDept }})
|
return CRUD({ title: '部门', url: 'api/dept/vo', crudMethod: { ...crudDept }})
|
||||||
},
|
},
|
||||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
// 设置数据字典
|
// 设置数据字典
|
||||||
@@ -195,9 +196,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDeptDatas(tree, treeNode, resolve) {
|
getDeptDatas(tree, treeNode, resolve) {
|
||||||
const params = { pid: tree.id }
|
const params = { pid: tree.dept_id }
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
crudDept.getDepts(params).then(res => {
|
crudDept.getDeptvo(params).then(res => {
|
||||||
resolve(res.content)
|
resolve(res.content)
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
@@ -235,6 +236,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getDepts() {
|
getDepts() {
|
||||||
crudDept.getDepts({ enabled: true }).then(res => {
|
crudDept.getDepts({ enabled: true }).then(res => {
|
||||||
|
debugger
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user