| | |
| | | let cur = node; |
| | | while (cur && cur.parent) { |
| | | if (isLeaf(cur.data)) { |
| | | tokens.push(cur.label, leafMarker); |
| | | const leafValue = cur.data && cur.data.standardMethodId |
| | | ? (cur.data.value || cur.label) |
| | | : cur.label; |
| | | tokens.push(leafValue, leafMarker); |
| | | } else { |
| | | tokens.push(cur.label); |
| | | } |
| | |
| | | // 去掉路径末段,用于「当前是叶子但查不到标准」时回退到父级查询 |
| | | export function dropLastLabel(path) { |
| | | if (!path) return ''; |
| | | const idx = path.lastIndexOf(' - '); |
| | | return idx === -1 ? '' : path.slice(0, idx); |
| | | const tokens = path.split(' - '); |
| | | if (tokens.length <= 1) return ''; |
| | | // 叶子路径格式为“行业 - null - 标准”或“行业 - - 标准”。 |
| | | // 去掉标准名后还要去掉仅用于标识叶子的占位段,父路径才是真实的行业路径。 |
| | | tokens.pop(); |
| | | const marker = tokens[tokens.length - 1]; |
| | | if (marker === '' || marker === 'null') { |
| | | tokens.pop(); |
| | | } |
| | | return tokens.join(' - '); |
| | | } |