Browse Source

getNode

master
xuhuajiao 3 years ago
parent
commit
9d3e84a886
  1. 32
      src/views/components/category/PreviewForm.vue

32
src/views/components/category/PreviewForm.vue

@ -159,14 +159,30 @@ export default {
},
methods: {
//
getNode(tree, dicName) {
for (let i = 0; i < tree.length; i++) {
if (tree[i].dicName === dicName) {
return tree[i]
} else if (tree[i].childMenus) {
return this.getNode(tree[i].childMenus, dicName)
// getNode(tree, dicName) {
// for (let i = 0; i < tree.length; i++) {
// if (tree[i].dicName === dicName) {
// return tree[i]
// } else {
// if (tree[i].childMenus) {
// return this.getNode(tree[i].childMenus, dicName)
// }
// }
// }
// },
getNode(list, dicName) {
let data;
(list || []).map(item => {
if (item.dicName === dicName) {
data = [item]
} else {
const child = this.getNode(item.childMenus, dicName)
if (child) {
data = child
}
}
}
})
return data
},
//
handleAuto() {
@ -180,7 +196,7 @@ export default {
await FetchFindAllSubsetById({ id: fieldInfo.dictionaryConfigId.id }).then(res => {
const option = this.getNode(res, this.addOrUpdateForm[val.fieldName])
if (option) {
string += '' + option.dicCode + val.connector
string += '' + option[0].dicCode + val.connector
}
})
} else {

Loading…
Cancel
Save