forked from github/dataease
feat: 整合xpack'组织管理'
This commit is contained in:
parent
dccfd6ec27
commit
1ffbe36c3c
@ -0,0 +1,80 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.sys.response.DeptNodeResponse;
|
||||
import io.dataease.plugins.common.entity.XpackGridRequest;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dept.dto.request.XpackCreateDept;
|
||||
import io.dataease.plugins.xpack.dept.dto.request.XpackDeleteDept;
|
||||
import io.dataease.plugins.xpack.dept.dto.response.XpackDeptTreeNode;
|
||||
import io.dataease.plugins.xpack.dept.dto.response.XpackSysDept;
|
||||
import io.dataease.plugins.xpack.dept.service.DeptXpackService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RequestMapping("/plugin/dept")
|
||||
@RestController
|
||||
public class DeptServer {
|
||||
|
||||
@PostMapping("/childNodes/{pid}")
|
||||
public List<DeptNodeResponse> childNodes(@PathVariable("pid") Long pid){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
List<XpackSysDept> nodes = deptService.nodesByPid(pid);
|
||||
List<DeptNodeResponse> nodeResponses = nodes.stream().map(node -> {
|
||||
DeptNodeResponse deptNodeResponse = BeanUtils.copyBean(new DeptNodeResponse(), node);
|
||||
deptNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
deptNodeResponse.setLeaf(node.getSubCount() == 0);
|
||||
deptNodeResponse.setTop(node.getPid() == 0L);
|
||||
return deptNodeResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@PostMapping("/search")
|
||||
public List<DeptNodeResponse> search(@RequestBody XpackGridRequest request){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
List<XpackSysDept> ndoes = deptService.nodesTreeByCondition(request);
|
||||
List<DeptNodeResponse> nodeResponses = ndoes.stream().map(node -> {
|
||||
DeptNodeResponse deptNodeResponse = BeanUtils.copyBean(new DeptNodeResponse(), node);
|
||||
deptNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
deptNodeResponse.setLeaf(node.getSubCount() == 0);
|
||||
deptNodeResponse.setTop(node.getPid() == 0L);
|
||||
return deptNodeResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
@PostMapping("/root")
|
||||
public List<XpackSysDept> rootData(){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
List<XpackSysDept> nodes = deptService.nodesByPid(null);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody XpackCreateDept dept){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
deptService.add(dept);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody List<XpackDeleteDept> requests){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
deptService.batchDelete(requests);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody XpackCreateDept dept){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
deptService.update(dept);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/nodesByDeptId/{deptId}")
|
||||
public List<XpackDeptTreeNode> nodesByDeptId(@PathVariable("deptId") Long deptId){
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
return deptService.searchTree(deptId);
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ import filter from '@/filter/filter'
|
||||
import directives from './directive'
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
import widgets from '@/components/widget'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import './utils/dialog'
|
||||
|
||||
import '@/components/canvas/custom-component' // 注册自定义组件
|
||||
@ -62,6 +64,7 @@ Vue.use(VueAxios, axios)
|
||||
Vue.use(filter)
|
||||
Vue.use(directives)
|
||||
Vue.use(message)
|
||||
Vue.component('Treeselect', Treeselect)
|
||||
Vue.config.productionTip = false
|
||||
|
||||
Vue.prototype.hasDataPermission = function(pTarget, pSource) {
|
||||
@ -70,6 +73,15 @@ Vue.prototype.hasDataPermission = function(pTarget, pSource) {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Vue.prototype.checkPermission = function(pers) {
|
||||
const permissions = store.getters.permissions
|
||||
const hasPermission = pers.every(needP => {
|
||||
const result = permissions.includes(needP)
|
||||
return result
|
||||
})
|
||||
return hasPermission
|
||||
}
|
||||
new Vue({
|
||||
|
||||
router,
|
||||
|
@ -41,13 +41,10 @@
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { getDeptTree, treeByDeptId, addDept, editDept } from '@/api/system/dept'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent, Treeselect },
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
defaultForm: { deptId: null, top: true, pid: null },
|
||||
@ -100,7 +97,7 @@ export default {
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS && !this.form.pid) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS' && !this.form.pid) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
@ -114,7 +111,7 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
|
@ -92,10 +92,8 @@
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import TreeTable from '@/components/business/tree-table'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
import { getDeptTree, addDept, editDept, delDept, loadTable } from '@/api/system/dept'
|
||||
|
||||
@ -103,8 +101,7 @@ export default {
|
||||
name: 'MsOrganization',
|
||||
components: {
|
||||
LayoutContent,
|
||||
TreeTable,
|
||||
Treeselect
|
||||
TreeTable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -361,7 +358,7 @@ export default {
|
||||
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS') {
|
||||
const _self = this
|
||||
!this.depts && getDeptTree('0').then(res => {
|
||||
_self.depts = res.data.map(node => _self.normalizer(node))
|
||||
@ -369,7 +366,7 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
|
@ -71,16 +71,17 @@
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
// import Treeselect from '@riophae/vue-treeselect'
|
||||
// import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
// import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
import { allRoles } from '@/api/system/role'
|
||||
import { addUser, editUser } from '@/api/system/user'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent, Treeselect },
|
||||
// components: { LayoutContent, Treeselect },
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
@ -211,7 +212,7 @@ export default {
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_ROOT_OPTIONS && !this.form.deptId) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS' && !this.form.deptId) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
@ -225,7 +226,7 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
@ -279,6 +280,9 @@ export default {
|
||||
this.$router.push({ name: 'system-user' })
|
||||
},
|
||||
filterData(instanceId) {
|
||||
if (!this.depts) {
|
||||
return
|
||||
}
|
||||
const results = this.depts.map(node => {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
|
@ -162,7 +162,7 @@
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import ComplexTable from '@/components/business/complex-table'
|
||||
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
// import { checkPermission } from '@/utils/permission'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
@ -183,13 +183,13 @@ export default {
|
||||
buttons: [
|
||||
{
|
||||
label: this.$t('commons.edit'), icon: 'el-icon-edit', type: 'primary', click: this.edit,
|
||||
show: checkPermission(['user:edit'])
|
||||
show: this.checkPermission(['user:edit'])
|
||||
}, {
|
||||
label: this.$t('commons.delete'), icon: 'el-icon-delete', type: 'danger', click: this.del,
|
||||
show: checkPermission(['user:del'])
|
||||
show: this.checkPermission(['user:del'])
|
||||
}, {
|
||||
label: this.$t('member.edit_password'), icon: 'el-icon-s-tools', type: 'success', click: this.editPassword,
|
||||
show: checkPermission(['user:editPwd'])
|
||||
show: this.checkPermission(['user:editPwd'])
|
||||
}
|
||||
],
|
||||
searchConfig: {
|
||||
|
Loading…
Reference in New Issue
Block a user