From 0b535104d8170fb9b58e0ec78d0ce5a00eea93a5 Mon Sep 17 00:00:00 2001 From: donghao Date: Mon, 22 Jan 2024 10:50:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B9=E7=9B=AE=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Setting/AlgorithmSetting.tsx | 221 +++++++++++++++---------- 1 file changed, 137 insertions(+), 84 deletions(-) diff --git a/src/pages/Setting/AlgorithmSetting.tsx b/src/pages/Setting/AlgorithmSetting.tsx index dbd41f3..2785e5c 100644 --- a/src/pages/Setting/AlgorithmSetting.tsx +++ b/src/pages/Setting/AlgorithmSetting.tsx @@ -118,108 +118,161 @@ const AlgorithmSetting: React.FC = () => { setCurrentRow(resp.data.deviceGroup); } - // TODO 左侧图标目前写死,需替换 - // 操作左侧网点数据节点, 项目列表数据变更 - function fetchProjectByGroupId(record: Record) { - postProjectGetProjectByGroupId({ id: record.key }).then((resp) => { - let tab_data = (resp?.data?.list || []).map((v: any) => { - console.log(resp.data.list); + // 设置modelData 需要使用content的来填充数据 + function initModelList(list: Record[], key: React.SetStateAction) { + list.map((v) => { + if (v.id === key) { let model_data = ([...v?.models] || []).map((item: any) => ({ content: ( - +
-
-
- -
- +
+
- - + +
+ + ), })); - setModelData(model_data); - return { - label: v.name, - key: v.id, - }; - }); - if (tab_data.length) { - setTab(tab_data[0].key); + setModelData(() => [...model_data]); } - setTabs(tab_data); }); } - // TODO 需联调 + // TODO 需联调 // 操作项目列表数据类别切换, 项目列表数据变更 function changeProjectTab(key: React.SetStateAction) { console.log('changeProjectTab_key', key); - let model_ids: number[] = projectData[key as string]?.inferConfig?.models || []; - postModelVersionGetModelVersionListByIds({ ids: model_ids }).then((resp) => { - let version_model_data = (resp?.data?.list || []).map((item: Record) => { + initModelList(tabs, key); + // let model_ids: number[] = projectData[key as string]?.inferConfig?.models || []; + // postModelVersionGetModelVersionListByIds({ ids: model_ids }).then((resp) => { + // let version_model_data = (resp?.data?.list || []).map((item: Record) => { + // return { + // subTitle: 经典算法, + // avatar: 'https://gw.alipayobjects.com/zos/antfincdn/UCSiy1j6jx/xingzhuang.svg', + // content: ( + // + //
+ //
+ //
{JSON.stringify(item.configId)}
+ // + //
+ // + //
+ // + //
+ // ), + // }; + // }); + // setModelVersionData(version_model_data); + // console.log(modelVersionData); + // }); + setTab(key); + } + + // TODO 左侧图标目前写死,需替换 + // 操作左侧网点数据节点, 项目列表数据变更 + function fetchProjectByGroupId(record: Record) { + postProjectGetProjectByGroupId({ id: record.key }).then((resp) => { + let tab_data = (resp?.data?.list || []).map((v: any) => { + // console.log(resp.data.list); + // let model_data = ([...v?.models] || []).map((item: any) => ({ + // content: ( + // + //
+ //
+ // + //
+ // + //
+ // + //
+ // ), + // })); + // setModelData(model_data); return { - subTitle: 经典算法, - avatar: 'https://gw.alipayobjects.com/zos/antfincdn/UCSiy1j6jx/xingzhuang.svg', - content: ( - -
-
-
{JSON.stringify(item.configId)}
- -
- -
- -
- ), + label: v.name, + key: v.id, + id: v.id, + models: v?.models, }; }); - setModelVersionData(version_model_data); - console.log(modelVersionData); + if (Array.isArray(resp?.data?.list) && resp?.data?.list.length) { + initModelList(resp?.data?.list, resp?.data?.list[0]?.id); + } + if (tab_data.length) { + setTab(tab_data[0].key); + } + setTabs(tab_data); }); - setTab(key); } + + // 切换展示 项目|告警 function changeMode(info: tabModeListProps) { console.log(info, 'changeMode_info');