update pay function
This commit is contained in:
@@ -300,8 +300,8 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"分类树"
|
"分类树"
|
||||||
],
|
],
|
||||||
"summary": "获取特定节点及其子树",
|
"summary": "获取节点及其直接子节点(第一层)",
|
||||||
"description": "根据路径获取树中的特定节点及其所有子节点。\n\n## 使用场景\n- 懒加载:用户点击节点时动态加载子节点\n- 子树查询:获取某个分类下的所有数据\n- 面包屑导航:根据路径定位节点\n\n## 路径格式\n使用竖线(|)分隔层级,例如:\n- 一级: \"钴\"\n- 二级: \"钴|钴化合物\"\n- 三级: \"钴|钴化合物|硫酸钴\"\n",
|
"description": "根据路径获取树中的特定节点,**只返回直接子节点**(不包括孙节点及更深层级)。\n\n## 功能特点\n- **分层懒加载**: 每次只返回下一层,避免一次性加载过多数据\n- **性能优化**: 减少数据传输量,提升响应速度\n- **无限层级**: 支持任意深度的节点展开\n\n## 使用场景\n- 用户点击节点时,动态加载该节点的直接子节点\n- 逐层展开树形结构\n- 按需加载,提升用户体验\n\n## 返回数据说明\n- 返回该节点的基本信息\n- 返回该节点的直接子节点列表\n- 每个子节点的`children`数组为空`[]`\n- 通过`has_children`字段判断子节点是否可继续展开\n\n## 路径格式\n使用竖线(|)分隔层级,例如:\n- 第1层: \"小金属\"\n- 第2层: \"小金属|钴\"\n- 第3层: \"小金属|钴|钴化合物\"\n",
|
||||||
"operationId": "getCategoryTreeNode",
|
"operationId": "getCategoryTreeNode",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@@ -337,15 +337,75 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/TreeNode"
|
"$ref": "#/components/schemas/TreeNode"
|
||||||
},
|
},
|
||||||
"example": {
|
"examples": {
|
||||||
"name": "硫酸钴",
|
"展开第1层节点": {
|
||||||
"path": "钴|钴化合物|硫酸钴",
|
"value": {
|
||||||
"level": 3,
|
"name": "小金属",
|
||||||
|
"path": "小金属",
|
||||||
|
"level": 1,
|
||||||
|
"has_children": true,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
|
"name": "钴",
|
||||||
|
"path": "小金属|钴",
|
||||||
|
"level": 2,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [],
|
||||||
|
"metrics": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "锂",
|
||||||
|
"path": "小金属|锂",
|
||||||
|
"level": 2,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [],
|
||||||
|
"metrics": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "镍",
|
||||||
|
"path": "小金属|镍",
|
||||||
|
"level": 2,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [],
|
||||||
|
"metrics": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metrics": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"展开第2层节点": {
|
||||||
|
"value": {
|
||||||
|
"name": "钴",
|
||||||
|
"path": "小金属|钴",
|
||||||
|
"level": 2,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "钴化合物",
|
||||||
|
"path": "小金属|钴|钴化合物",
|
||||||
|
"level": 3,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [],
|
||||||
|
"metrics": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "钴矿",
|
||||||
|
"path": "小金属|钴|钴矿",
|
||||||
|
"level": 3,
|
||||||
|
"has_children": true,
|
||||||
|
"children": [],
|
||||||
|
"metrics": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metrics": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"叶子节点(含指标)": {
|
||||||
|
"value": {
|
||||||
"name": "产量",
|
"name": "产量",
|
||||||
"path": "钴|钴化合物|硫酸钴|产量",
|
"path": "小金属|钴|钴化合物|硫酸钴|产量",
|
||||||
"level": 4,
|
"level": 5,
|
||||||
|
"has_children": false,
|
||||||
"children": [],
|
"children": [],
|
||||||
"metrics": [
|
"metrics": [
|
||||||
{
|
{
|
||||||
@@ -358,7 +418,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,7 +433,7 @@
|
|||||||
"examples": {
|
"examples": {
|
||||||
"节点不存在": {
|
"节点不存在": {
|
||||||
"value": {
|
"value": {
|
||||||
"detail": "未找到路径 '钴|不存在的节点' 对应的节点"
|
"detail": "未找到路径 '小金属|不存在的节点' 对应的节点"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"数据源不存在": {
|
"数据源不存在": {
|
||||||
|
|||||||
@@ -87,16 +87,18 @@ export const fetchCategoryTree = async (
|
|||||||
* 获取特定节点及其子树
|
* 获取特定节点及其子树
|
||||||
* @param path 节点完整路径(用 | 分隔)
|
* @param path 节点完整路径(用 | 分隔)
|
||||||
* @param source 数据源类型 ('SMM' | 'Mysteel')
|
* @param source 数据源类型 ('SMM' | 'Mysteel')
|
||||||
|
* @param maxDepth 返回的子树最大层级深度(默认1层,只返回直接子节点)
|
||||||
* @returns 节点数据及其子树
|
* @returns 节点数据及其子树
|
||||||
*/
|
*/
|
||||||
export const fetchCategoryNode = async (
|
export const fetchCategoryNode = async (
|
||||||
path: string,
|
path: string,
|
||||||
source: 'SMM' | 'Mysteel'
|
source: 'SMM' | 'Mysteel',
|
||||||
|
maxDepth: number = 1
|
||||||
): Promise<TreeNode> => {
|
): Promise<TreeNode> => {
|
||||||
try {
|
try {
|
||||||
const encodedPath = encodeURIComponent(path);
|
const encodedPath = encodeURIComponent(path);
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/category-api/api/category-tree/node?path=${encodedPath}&source=${source}`,
|
`/category-api/api/category-tree/node?path=${encodedPath}&source=${source}&max_depth=${maxDepth}`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -349,10 +349,11 @@ const DataBrowser: React.FC = () => {
|
|||||||
return newSet;
|
return newSet;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 展开节点 - 检查是否需要加载子节点
|
// 展开节点 - 始终尝试加载子节点(如果还没加载过)
|
||||||
const needsLoading = !node.children || node.children.length === 0;
|
const hasChildren = node.children && node.children.length > 0;
|
||||||
|
|
||||||
if (needsLoading) {
|
// 如果没有子节点数据,尝试从服务器加载
|
||||||
|
if (!hasChildren) {
|
||||||
// 添加加载状态
|
// 添加加载状态
|
||||||
setLoadingNodes((prev) => new Set(prev).add(node.path));
|
setLoadingNodes((prev) => new Set(prev).add(node.path));
|
||||||
|
|
||||||
@@ -711,6 +712,14 @@ const DataBrowser: React.FC = () => {
|
|||||||
unit: result.unit,
|
unit: result.unit,
|
||||||
description: result.description,
|
description: result.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 更新面包屑导航为搜索结果的路径
|
||||||
|
const pathParts = result.category_path.split(' > ');
|
||||||
|
setBreadcrumbs(pathParts);
|
||||||
|
|
||||||
|
// 清空搜索框,显示树结构
|
||||||
|
setSearchQuery('');
|
||||||
|
|
||||||
handleMetricClick(metric);
|
handleMetricClick(metric);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user