Lvtianfang
parent
1b0d44ed14
commit
25a64c50d8
@ -1,12 +1,25 @@
|
|||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
// 翻译区域
|
// 翻译区域
|
||||||
export function filterTown(id) {
|
export function filterTown(ids) {
|
||||||
if (id == undefined) return;
|
if (ids && Array.isArray(ids)) {
|
||||||
let name = store.getters.townList.filter((item) => item.value == id);
|
let data = store.getters.townList;
|
||||||
if (name.length > 0) {
|
const targetIds = ids;
|
||||||
return name[0].label;
|
const results = [];
|
||||||
} else {
|
filterNames(data, targetIds, results);
|
||||||
return id;
|
return results.join(" / ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterNames(data, targetIds, results) {
|
||||||
|
// console.log(data, "1", targetIds, "2", results, "3");
|
||||||
|
data.forEach((node, index) => {
|
||||||
|
if (targetIds.includes(node.id)) {
|
||||||
|
results.push(node.label);
|
||||||
|
}
|
||||||
|
const children = node.children;
|
||||||
|
if (Array.isArray(children) && children.length > 0) {
|
||||||
|
filterNames(children, targetIds, results);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue