diff --git a/src/views/modules/logistics-fare/logistics-template/index.vue b/src/views/modules/logistics-fare/logistics-template/index.vue index f29fa41..b958aa4 100644 --- a/src/views/modules/logistics-fare/logistics-template/index.vue +++ b/src/views/modules/logistics-fare/logistics-template/index.vue @@ -110,31 +110,41 @@ export default { } }); const findLabelsByCode = (tree, codes) => { - const labels = []; - // console.log("row.cityCodes",row.cityCodes); - //全国范围 + // 记录找到的路径 + let paths = []; + if (codes == "0") { - return "中国"; + return ["中国"]; } - function searchTree(node) { - // 如果当前节点的 code 在 codes 数组中,添加其 label - if (codes?.includes(node.code)) { - labels.push(node.name); + + // 在树中搜索节点的递归函数 + function searchTree(node, currentPath) { + // 将当前节点添加到路径中 + currentPath.push(node.name); + + // 如果当前节点的 code 在 codes 数组中,记录路径 + if (codes.includes(node.code)) { + paths.push([...currentPath]); // 深拷贝当前路径 } + // 如果有子节点,继续递归查找 if (node.children) { for (let child of node.children) { - searchTree(child); + searchTree(child, currentPath); } } + + // 回溯,移除当前节点 + currentPath.pop(); } // 对树的每个顶层节点调用 searchTree for (let node of tree) { - searchTree(node); + searchTree(node, []); } - return labels.join(","); + // 将所有找到的路径合并成字符串返回 + return paths.map((path) =>

{path.join("/")}

); }; const appointMapper = { @@ -176,10 +186,16 @@ export default { }; //打开弹窗预览 const openPreview = (str) => { - this.$confirm(str, "详情", { - showCancelButton: false, - confirmButtonText:"好的" - }); + this.$confirm( +
+ {str} +
, + "详情", + { + showCancelButton: false, + confirmButtonText: "好的", + } + ); }; return (