Browse Source

getNode

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

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

@ -159,14 +159,30 @@ export default {
}, },
methods: { 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() { handleAuto() {
@ -180,7 +196,7 @@ export default {
await FetchFindAllSubsetById({ id: fieldInfo.dictionaryConfigId.id }).then(res => { await FetchFindAllSubsetById({ id: fieldInfo.dictionaryConfigId.id }).then(res => {
const option = this.getNode(res, this.addOrUpdateForm[val.fieldName]) const option = this.getNode(res, this.addOrUpdateForm[val.fieldName])
if (option) { if (option) {
string += '' + option.dicCode + val.connector
string += '' + option[0].dicCode + val.connector
} }
}) })
} else { } else {

Loading…
Cancel
Save