mdf:部门页面修改
This commit is contained in:
@@ -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<Dept> deptDtos = deptService.queryAll(criteria, true);
|
||||
List<DeptVo> 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<Object> 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);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
width="500px"
|
||||
>
|
||||
<el-form ref="form" inline :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="部门编码" prop="code">
|
||||
<el-form-item v-if="!crud.status.add" label="部门编码" prop="code">
|
||||
<el-input v-model="form.code" :disabled="true" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
@@ -103,34 +103,28 @@
|
||||
<!-- <el-table-column label="编码" prop="code" />-->
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="排序" prop="dept_sort" />
|
||||
<el-table-column label="状态" align="center" prop="is_used">
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_used"
|
||||
:disabled="scope.row.id === 1"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
@change="changeEnabled(scope.row, scope.row.enabled,)"
|
||||
/>
|
||||
<span :style="{'color': caseStatusColorFilter(scope.row.is_used)}">{{ enabledTypeOptions.find(item => {return item.key == scope.row.is_used}).display_name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="create_time" label="创建日期" />
|
||||
<el-table-column
|
||||
v-permission="['admin','dept:edit','dept:del']"
|
||||
label="操作"
|
||||
width="130px"
|
||||
width="200"
|
||||
align="center"
|
||||
fixed="right"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
:disabled-dle="scope.row.id === 1"
|
||||
msg="确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!"
|
||||
/>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handdeleted(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini">
|
||||
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item icon="el-icon-key"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.is_used}).display_name }}部门</span></el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -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) {
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
width="200"
|
||||
>
|
||||
<template v-if="scope.row.userId !== 1" slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handdeleted(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini">
|
||||
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
||||
@@ -178,7 +178,7 @@
|
||||
<span @click="openDrawer(scope.row)">部门权限</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key">数据权限</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key"><span @click="changeEnabled(scope.row)">锁定账号</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.is_used}).display_name }}账号</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-circle-check">分配角色</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
@@ -466,15 +466,16 @@ export default {
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(row) {
|
||||
this.$confirm('此操作将停用账号:' + row.username + ', 是否继续?', '提示', {
|
||||
const satus = this.enabledTypeOptions.find(item => { return item.key !== row.is_used })
|
||||
this.$confirm('此操作将' + satus.display_name + '账号:' + row.username + ', 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
row.is_used = '0'
|
||||
row.is_used = satus.key
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('账号' + row.username + '已锁定')
|
||||
this.crud.notify('账号' + row.username + '已' + satus.display_name)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user