From e22f3008b1b4925f7a641514874c70e13da9bbb7 Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Wed, 7 Dec 2022 18:38:11 +0800 Subject: [PATCH] =?UTF-8?q?mdf:=E9=83=A8=E9=97=A8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nl/sso/system/rest/DeptController.java | 16 +++-- .../src/views/system/dept/index.vue | 63 +++++++++++-------- .../src/views/system/user/index.vue | 11 ++-- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java index 16c26be11..7276e421f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java @@ -17,13 +17,12 @@ package org.nl.sso.system.rest; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaMode; -import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; -import org.nl.modules.common.exception.BadRequestException; +import org.apache.commons.lang3.StringUtils; import org.nl.modules.common.utils.PageUtil; import org.nl.modules.logging.annotation.Log; import org.nl.sso.system.domain.Dept; @@ -66,8 +65,18 @@ public class DeptController { if (criteria.getPid() == null){ criteria.setPidIsNull(true); } + Boolean hasChild = false; + if (StringUtils.isNotEmpty(criteria.getName()) || StringUtils.isNotEmpty(criteria.getIs_used())){ + criteria.setPidIsNull(null); + hasChild=true; + } List deptDtos = deptService.queryAll(criteria, true); List deptVos = CopyUtil.copyList(deptDtos, DeptVo.class); + if (hasChild){ + deptVos.forEach(a->{ + a.setHasChildren(false); + }); + } return new ResponseEntity<>(PageUtil.toPage(deptVos, deptVos.size()),HttpStatus.OK); } @@ -101,9 +110,6 @@ public class DeptController { @PostMapping // @SaCheckPermission("dept:add") public ResponseEntity create(@Validated @RequestBody Dept resources){ - if (resources.getDept_id() != null) { - throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); - } deptService.create(resources); return new ResponseEntity<>(HttpStatus.CREATED); } diff --git a/lms/nladmin-ui/src/views/system/dept/index.vue b/lms/nladmin-ui/src/views/system/dept/index.vue index 17409c6b7..63ebcd416 100644 --- a/lms/nladmin-ui/src/views/system/dept/index.vue +++ b/lms/nladmin-ui/src/views/system/dept/index.vue @@ -37,7 +37,7 @@ width="500px" > - + @@ -103,34 +103,28 @@ - + @@ -182,12 +176,18 @@ export default { del: ['admin', 'dept:del'] }, enabledTypeOptions: [ - { key: '1', display_name: '正常' }, + { key: '1', display_name: '启用' }, { key: '0', display_name: '禁用' } ] } }, methods: { + caseStatusColorFilter(is_used) { + if (is_used === '1') { + return '#378be2' + } + return '#F56C6C' + }, getDeptDatas(tree, treeNode, resolve) { const params = { pid: tree.dept_id } setTimeout(() => { @@ -266,20 +266,29 @@ export default { return true }, // 改变状态 - changeEnabled(data, val) { - this.$confirm('此操作将 "' + this.dict.label.dept_status[val] + '" ' + data.name + '部门, 是否继续?', '提示', { + changeEnabled(row) { + const satus = this.enabledTypeOptions.find(item => { return item.key !== row.is_used }) + this.$confirm('此操作将' + satus.display_name + '部门:' + row.name + ', 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - crudDept.edit(data).then(res => { - this.crud.notify(this.dict.label.dept_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS) - }).catch(err => { - data.enabled = !data.enabled - console.log(err.response.data.message) + row.is_used = satus.key + crudDept.edit(row).then(res => { + this.crud.toQuery() + this.crud.notify('部门' + row.name + '已' + satus.display_name) }) + }) + }, + handdeleted(datas) { + this.$confirm(`删除该部门将连带删除所有子部门,确认删除?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.crud.delAllLoading = true + this.crud.doDelete(datas) }).catch(() => { - data.enabled = !data.enabled }) }, checkboxT(row, rowIndex) { diff --git a/lms/nladmin-ui/src/views/system/user/index.vue b/lms/nladmin-ui/src/views/system/user/index.vue index 645774fa9..c8c34bd4c 100644 --- a/lms/nladmin-ui/src/views/system/user/index.vue +++ b/lms/nladmin-ui/src/views/system/user/index.vue @@ -168,7 +168,7 @@ width="200" >