| | |
| | | |
| | | // 如果第一层是街道 |
| | | if (this.regionTree[this.regionTree.length - 1]?.tier === 3) { |
| | | const streets = this.regionTree.slice(1).map(item => ({ |
| | | name: item.name, |
| | | id: item.id, |
| | | tier: item.tier, |
| | | children: item.children || [] |
| | | })); |
| | | return [{ name: "全部", id: "all", tier: 3, children: [] }, ...streets]; |
| | | } |
| | | // 如果第一层是社区 |
| | | else if (this.regionTree[this.regionTree.length - 1]?.tier === 4) { |
| | | return this.regionTree.slice(1).map(item => ({ |
| | | name: item.name, |
| | | id: item.id, |
| | |
| | | children: item.children || [] |
| | | })); |
| | | } |
| | | |
| | | // 如果当前选中的是区县 |
| | | if (county.tier === 2) { |
| | | else if (county.tier === 2) { |
| | | const streets = county.children.filter((c) => c && c.tier === 3); |
| | | return streets.length |
| | | ? [{ name: "全部", id: "all", tier: 3, children: [] }, ...streets] |
| | |
| | | const communities = street.children?.filter(c => c && c.tier === 4) || []; |
| | | return communities.length ? [{ name: "全部", id: "all", tier: 4 }, ...communities] : []; |
| | | } |
| | | |
| | | // 如果第一层是社区 |
| | | else if (this.regionTree[this.regionTree.length - 1]?.tier === 4) { |
| | | return this.regionTree.slice(1).map(item => ({ |
| | | name: item.name, |
| | | id: item.id, |
| | | tier: item.tier, |
| | | children: item.children || [] |
| | | })); |
| | | } |
| | | // 如果当前选中的是区县 |
| | | if (county.tier === 2) { |
| | | else if (county.tier === 2) { |
| | | // 区县下直接有社区 |
| | | const communities = county.children.filter((c) => c && c.tier === 4); |
| | | if (communities.length) |