Lvtianfang
parent
1b0d44ed14
commit
25a64c50d8
@ -1,12 +1,25 @@
|
||||
import store from "@/store";
|
||||
|
||||
// 翻译区域
|
||||
export function filterTown(id) {
|
||||
if (id == undefined) return;
|
||||
let name = store.getters.townList.filter((item) => item.value == id);
|
||||
if (name.length > 0) {
|
||||
return name[0].label;
|
||||
} else {
|
||||
return id;
|
||||
export function filterTown(ids) {
|
||||
if (ids && Array.isArray(ids)) {
|
||||
let data = store.getters.townList;
|
||||
const targetIds = ids;
|
||||
const results = [];
|
||||
filterNames(data, targetIds, results);
|
||||
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