dept
This commit is contained in:
@@ -41,5 +41,4 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
* @return
|
||||
*/
|
||||
String findAllChild(String pid);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -94,11 +97,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
if (query.getPid() == null){
|
||||
query.setPidIsNull(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
query.setPidIsNull(null);
|
||||
}
|
||||
}
|
||||
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName())){
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||
}
|
||||
return page;
|
||||
@@ -140,7 +145,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
verification(deptIds);
|
||||
Set<String> depts = new HashSet<>();
|
||||
Set<String> pids = new HashSet<>();
|
||||
List<SysDept> deptList = sysDeptMapper.selectList(new QueryWrapper<SysDept>().in("dept_id", deptIds));
|
||||
for (String deptId : deptIds) {
|
||||
depts.add(deptId);
|
||||
String allChild = sysDeptMapper.findAllChild(deptId);
|
||||
if (StringUtils.isNotEmpty(allChild)){
|
||||
String[] split = allChild.split(",");
|
||||
@@ -148,9 +156,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
}
|
||||
this.remove(new QueryWrapper<SysDept>().in("dept_id", depts));
|
||||
for (String deptId : deptIds) {
|
||||
sysDeptMapper.updateSubCount(deptId);
|
||||
}
|
||||
deptList.forEach(dept -> {
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){sysDeptMapper.updateSubCount(dept.getPid());}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verification(Set<String> depeIds) {
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="外部标识" prop="extId">
|
||||
<el-input v-model="form.ext_id" style="width: 370px;" />
|
||||
<el-input v-model="form.extId" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="顶级部门">
|
||||
<el-radio-group v-model="form.isTop" style="width: 140px">
|
||||
@@ -61,13 +61,11 @@
|
||||
<el-radio label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-form-item label="状态" prop="isUesd">
|
||||
<el-switch
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.isTop === '0'" style="margin-bottom: 0;" label="上级部门" prop="pid">
|
||||
@@ -110,8 +108,6 @@
|
||||
:disabled="scope.row.id === 1"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
@change="changeEnabled(scope.row, scope.row.isUsed,)"
|
||||
/>
|
||||
</template>
|
||||
@@ -153,8 +149,8 @@ const defaultForm = {
|
||||
sub_count: 0,
|
||||
pid: null,
|
||||
deptSort: 999,
|
||||
isUsed: '1',
|
||||
ext_id: null
|
||||
isUsed: true,
|
||||
extId: null
|
||||
}
|
||||
export default {
|
||||
name: 'Dept',
|
||||
@@ -182,8 +178,8 @@ export default {
|
||||
del: ['admin', 'dept:del']
|
||||
},
|
||||
enabledTypeOptions: [
|
||||
{ key: '1', display_name: '正常' },
|
||||
{ key: '0', display_name: '禁用' }
|
||||
{ key: true, display_name: '启用' },
|
||||
{ key: false, display_name: '禁用' }
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -228,7 +224,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getDepts() {
|
||||
crudDept.getDeptvo({ isUsed: '1' }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: true }).then(res => {
|
||||
this.depts = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
@@ -240,7 +236,7 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudDept.getDeptvo({ isUsed: '1', pid: parentNode.deptId }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: true, pid: parentNode.deptId }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
return obj
|
||||
@@ -267,19 +263,18 @@ export default {
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将 "' + this.dict.label.dept_status[val] + '" ' + data.name + '部门, 是否继续?', '提示', {
|
||||
const satus = this.enabledTypeOptions.find(item => { return item.key == data.isUsed })
|
||||
debugger
|
||||
this.$confirm('此操作将 "' + satus.display_name + '" ' + data.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)
|
||||
this.crud.notify(satus.display_name + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
data.isUsed = !data.isUsed
|
||||
})
|
||||
},
|
||||
checkboxT(row, rowIndex) {
|
||||
|
||||
Reference in New Issue
Block a user