00f3bd22 by yangwei

字典递归过滤

1 parent f82fd6cd
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-03 08:59:06
* @LastEditTime: 2023-08-16 11:30:45
*/
import store from '@/store'
......@@ -27,12 +27,18 @@ export function getSjlx (level) {
*/
export function getDictLeabel (level, code) {
const resultMap = store.getters.dictData[code]
const desiredObject = resultMap.find(obj => obj.dcode === level);
if (desiredObject) {
const desiredName = desiredObject.dname;
return desiredName
} else {
return ''
function findNode(tree, func) {
for (const node of tree) {
if (func(node)) return node
if (node.children) {
const res = findNode(node.children, func)
if (res) return res
}
}
return {dname:""}
}
let data = findNode(resultMap, (node) => {
return node.dcode === level
})
return data.dname
}
\ No newline at end of file
......