mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 11:24:17 +00:00
fix: 解决冲突
This commit is contained in:
@@ -63,109 +63,6 @@ export default {
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
setUpdateBtn() {
|
||||
const permRequired = `rbac.change_${this.object.scope}role`
|
||||
if (this.$hasPerm(permRequired)) {
|
||||
this.isDisabled = false
|
||||
}
|
||||
},
|
||||
parsePerm(perm) {
|
||||
if (!perm) {
|
||||
this.$log.debug('No app code: ', perm)
|
||||
return
|
||||
}
|
||||
const [app, code] = perm.split('.')
|
||||
if (!app || !code) {
|
||||
this.$log.debug('App or code not found')
|
||||
return
|
||||
}
|
||||
const [action, resource] = code.split('_')
|
||||
if (!action || !resource) {
|
||||
return
|
||||
}
|
||||
return { action, resource, app }
|
||||
},
|
||||
checkActionDeps(node) {
|
||||
if (node.isParent) {
|
||||
this.$log.debug('Is parent')
|
||||
return
|
||||
}
|
||||
const data = this.parsePerm(node.title)
|
||||
if (!data) {
|
||||
this.$log.error('Parse perm error: ', node.title)
|
||||
return
|
||||
}
|
||||
|
||||
const { app, action, resource } = data
|
||||
const ztree = this.$refs.tree.zTree
|
||||
const viewId = `${app}.view_${resource}`
|
||||
const viewNode = ztree.getNodeByParam('title', viewId)
|
||||
if (!viewNode) {
|
||||
return
|
||||
}
|
||||
|
||||
const viewIgnoreAction = ['match']
|
||||
const checked = node.checked
|
||||
if (action === 'view') {
|
||||
// 选中 view node 不需要处理, 不选中的话去掉 兄弟节点选中
|
||||
if (checked) {
|
||||
return
|
||||
}
|
||||
const parent = viewNode.getParentNode()
|
||||
const actionNodes = parent.children
|
||||
for (const node of actionNodes) {
|
||||
const d = this.parsePerm(node.title)
|
||||
if (!d) {
|
||||
continue
|
||||
}
|
||||
const { action: act, resource: res } = d
|
||||
// 忽略的 action 不用处理, resource 不相同的不用处理
|
||||
this.$log.debug('Action: ', act, d)
|
||||
if (act === 'view' || viewIgnoreAction.indexOf(act) > -1 || res !== resource) {
|
||||
continue
|
||||
}
|
||||
ztree.checkNode(node, false)
|
||||
}
|
||||
} else if (viewIgnoreAction.indexOf(action) > -1) {
|
||||
this.$log.debug('Action is ignore: ', action)
|
||||
} else {
|
||||
if (!checked) {
|
||||
return
|
||||
}
|
||||
this.$log.debug('Select view node: ', viewNode)
|
||||
ztree.checkNode(viewNode, true)
|
||||
}
|
||||
},
|
||||
checkSpecDeps() {
|
||||
const ztree = this.$refs.tree.zTree
|
||||
const depsId = ztree.getCheckedNodes().filter(i => {
|
||||
return !!this.nodesDeps[i.title]
|
||||
}).reduce((result, v) => {
|
||||
return [...result, ...this.nodesDeps[v.title]]
|
||||
}, [])
|
||||
this.$log.debug('Select nodes should try: ', depsId)
|
||||
|
||||
for (const i of depsId) {
|
||||
const depNode = this.ztree.getNodeByParam('title', i)
|
||||
this.ztree.checkNode(depNode, true)
|
||||
}
|
||||
},
|
||||
updatePermissions() {
|
||||
const ztree = this.$refs.tree.zTree
|
||||
const checkedNodes = ztree.getCheckedNodes()
|
||||
const permNodes = checkedNodes.filter(node => !node.isParent)
|
||||
const permIds = permNodes.map(node => node.id)
|
||||
const roleDetailUrl = `/api/v1/rbac/${this.object.scope}-roles/${this.object.id}/`
|
||||
const data = {
|
||||
permissions: permIds
|
||||
}
|
||||
this.$axios.patch(roleDetailUrl, data).then(() => {
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
}).catch(error => {
|
||||
this.$message.error(this.$t('common.updateErrorMsg') + error)
|
||||
this.$log.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user