1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 12:01:57 +08:00

fix: Relations in context menu. (#553)

This commit is contained in:
Elsio Sanchez 2020-12-02 12:59:54 -04:00 committed by GitHub
parent 2802e06030
commit 0384ab8568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 26 deletions

View File

@ -29,7 +29,7 @@ export default {
// uuid of the component where it is called
containerUuid: {
type: String,
required: true
default: undefined
},
panelType: {
type: String,

View File

@ -8,12 +8,13 @@ export default {
menuUuid = this.menuParentUuid
}
const relations = this.$store.getters.getRelations(menuUuid)
if (!this.isEmptyValue(relations.children)) {
return relations.children
}
if (relations.meta && !this.isEmptyValue(relations.meta.childs)) {
return relations.meta.childs
if (!this.isEmptyValue(relations)) {
if (!this.isEmptyValue(relations.children)) {
return relations.children
}
if (relations.meta && !this.isEmptyValue(relations.meta.childs)) {
return relations.meta.childs
}
}
return []
},

View File

@ -6,6 +6,7 @@ import Layout from '@/layout'
/**
* Get Menu from server
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
* @param {string} sessionUuid
* @param {string} roleUuid
@ -63,6 +64,7 @@ export function loadMainMenu({
/**
* Get Only Child
* @author Elsio Sanchez <elsiosanches@gmail.com>
* @author Edwin Betancourt <EdwinBetanc0urt@outlook.com>
* @param {object} menu
* @param {number} index

View File

@ -188,24 +188,20 @@ export const recursiveTreeSearch = ({
treeData,
attributeValue,
attributeName = 'id',
secondAttributeName = '',
secondAttribute = false,
attributeChilds = 'childsList',
isParent = false
}) => {
if (Array.isArray(treeData)) {
// search in childs attribute
let index = 0
const length = treeData.length
while (index < length) {
let value = treeData[index]
if (!isEmptyValue(value) &&
Object.prototype.hasOwnProperty.call(value, attributeName)) {
if (!isEmptyValue(value) && Object.prototype.hasOwnProperty.call(value, attributeName)) {
value = value[attributeName]
}
if (!isEmptyValue(value) &&
secondAttributeName &&
Object.prototype.hasOwnProperty.call(value, secondAttributeName)) {
value = value[secondAttributeName]
if (!isEmptyValue(value) && secondAttribute && Object.prototype.hasOwnProperty.call(value, secondAttribute)) {
value = value[secondAttribute]
}
// compare item to search
@ -214,12 +210,11 @@ export const recursiveTreeSearch = ({
}
if (treeData[index] && treeData[index][attributeChilds]) {
const newTree = treeData[index][attributeChilds]
const found = recursiveTreeSearch({
treeData: newTree,
treeData: treeData[index][attributeChilds],
attributeValue,
attributeName,
secondAttributeName,
secondAttribute,
attributeChilds,
isParent
})
@ -230,16 +225,12 @@ export const recursiveTreeSearch = ({
index++
}
} else {
// search into meta attribute
let value = treeData
if (!isEmptyValue(value) &&
Object.prototype.hasOwnProperty.call(value, attributeName)) {
if (!isEmptyValue(value) && Object.prototype.hasOwnProperty.call(value, attributeName)) {
value = value[attributeName]
}
if (!isEmptyValue(value) &&
secondAttributeName &&
Object.prototype.hasOwnProperty.call(value, secondAttributeName)) {
value = value[secondAttributeName]
if (!isEmptyValue(value) && secondAttribute && Object.prototype.hasOwnProperty.call(value, secondAttribute)) {
value = value[secondAttribute]
}
// compare item to search
@ -251,7 +242,7 @@ export const recursiveTreeSearch = ({
treeData: treeData[attributeChilds],
attributeValue,
attributeName,
secondAttributeName,
secondAttribute,
attributeChilds
})
return found