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