完善优化
This commit is contained in:
parent
eb370cd4ed
commit
b691702778
|
@ -110,31 +110,41 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const findLabelsByCode = (tree, codes) => {
|
const findLabelsByCode = (tree, codes) => {
|
||||||
const labels = [];
|
// 记录找到的路径
|
||||||
// console.log("row.cityCodes",row.cityCodes);
|
let paths = [];
|
||||||
//全国范围
|
|
||||||
if (codes == "0") {
|
if (codes == "0") {
|
||||||
return "中国";
|
return ["中国"];
|
||||||
}
|
}
|
||||||
function searchTree(node) {
|
|
||||||
// 如果当前节点的 code 在 codes 数组中,添加其 label
|
// 在树中搜索节点的递归函数
|
||||||
if (codes?.includes(node.code)) {
|
function searchTree(node, currentPath) {
|
||||||
labels.push(node.name);
|
// 将当前节点添加到路径中
|
||||||
|
currentPath.push(node.name);
|
||||||
|
|
||||||
|
// 如果当前节点的 code 在 codes 数组中,记录路径
|
||||||
|
if (codes.includes(node.code)) {
|
||||||
|
paths.push([...currentPath]); // 深拷贝当前路径
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有子节点,继续递归查找
|
// 如果有子节点,继续递归查找
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
for (let child of node.children) {
|
for (let child of node.children) {
|
||||||
searchTree(child);
|
searchTree(child, currentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 回溯,移除当前节点
|
||||||
|
currentPath.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对树的每个顶层节点调用 searchTree
|
// 对树的每个顶层节点调用 searchTree
|
||||||
for (let node of tree) {
|
for (let node of tree) {
|
||||||
searchTree(node);
|
searchTree(node, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
return labels.join(",");
|
// 将所有找到的路径合并成字符串返回
|
||||||
|
return paths.map((path) =><p>{path.join("/")}</p>);
|
||||||
};
|
};
|
||||||
|
|
||||||
const appointMapper = {
|
const appointMapper = {
|
||||||
|
@ -176,10 +186,16 @@ export default {
|
||||||
};
|
};
|
||||||
//打开弹窗预览
|
//打开弹窗预览
|
||||||
const openPreview = (str) => {
|
const openPreview = (str) => {
|
||||||
this.$confirm(str, "详情", {
|
this.$confirm(
|
||||||
|
<div style="max-height:50vh;overflow-y:auto;line-height:1.5rem;">
|
||||||
|
{str}
|
||||||
|
</div>,
|
||||||
|
"详情",
|
||||||
|
{
|
||||||
showCancelButton: false,
|
showCancelButton: false,
|
||||||
confirmButtonText:"好的"
|
confirmButtonText: "好的",
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
|
|
Loading…
Reference in New Issue