/* * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-30 10:02:29 * @LastEditors: donghao donghao@supervision.ltd * @LastEditTime: 2024-07-22 11:40:49 * @FilePath: \general-ai-platform-web\src\pages\Business\DeviceGroup\components\modelSetting.tsx * @Description: 业务模型部署 * @交互说明 * 1、业务模型部署列表的分页展示 * 2、配置参数功能 */ import TableActionCard from '@/components/TableActionCard'; import { apiEntityNodesDeviceModels } from '@/services/business/entity'; import { isSuccessApi } from '@/utils/forApi'; import type { ProColumns } from '@ant-design/pro-components'; import { ProList, ProTable } from '@ant-design/pro-components'; import { FormattedMessage } from '@umijs/max'; import { Button } from 'antd'; import { proTableDefaultOptions } from '../../../../../config/defaultTable'; import { useEffect, useState } from 'react'; // import CreateForm from './components/createForm'; import CreateModelParams from './createModelParams'; type ModelSettingProps = { info: Record; commInfo: Record; nodeInfo: Record; }; const ModelSetting: React.FC = (props) => { /**state */ const [modelData, setModelData] = useState[]>([]); // 列表数据 // const intl = useIntl(); const [createModalOpen, setCreateModalOpen] = useState(false); // const [categoryFkIdIds, setCategoryFkIdIds] = useState([]); // 动态设置每页数量 const [currentRow, setCurrentRow] = useState>({}); /**配置参数 */ const handleCreateModal = () => { setCreateModalOpen(!createModalOpen); }; // 业务模型列表信息 const columns: ProColumns>[] = [ { title: , dataIndex: 'model_name', hideInSearch: true, key: 'fixedName', fixed: 'left', width: '30%', }, { title: , dataIndex: 'model_version', hideInSearch: true, width: '20%', }, { title: ( ), dataIndex: 'model_hub_image', hideInSearch: true, render: (dom, record) => { return (
{record.model_hub_image ? ( dom ) : (
)}
); }, }, { title: , dataIndex: 'option', valueType: 'option', fixed: 'right', key: 'option', render: (_, record) => [ { setCurrentRow({ ...record, base_model_id: record.model_id, busi_model_id: record?.parentInfo?.busi_model_id, }); handleCreateModal(); }} > ), }, ]} >, ], }, ]; // 将数据组装成reactDom // eslint-disable-next-line @typescript-eslint/no-unused-vars function toListDomByData(record) { let startList = [...record]; let finalList = startList.map((item) => ({ content: (
{item?.busi_model_name}
// // {item.name} //
// } cardProps={{ bodyStyle: { padding: 0, margin: 0 }, }} // 标题栏 search={false} options={{ fullScreen: false, setting: false, density: false, reload: false }} rowKey="model_id" onDataSourceChange={(data) => { console.log(data, 'onDataSourceChange_data'); }} pagination={false} columnsState={{ persistenceKey: 'algorithm_model_list', persistenceType: 'localStorage', }} dataSource={item.base_models.map((baseModelItem) => { const { base_models, ...restInfo } = item; console.log(base_models, 'base_models'); baseModelItem.parentInfo = restInfo; return baseModelItem; })} columns={columns} /> ), })); setModelData(finalList); console.log(finalList, 'toListDomByData_finalList'); } // 基础模型列表数据api async function fetchData() { const resp = await apiEntityNodesDeviceModels({ pageNo: 1, pageSize: 100, device_id: props.info.device_id, }); if (isSuccessApi(resp)) { toListDomByData(resp.data.data); } } function reloadList() { fetchData(); } // 初始化加载 useEffect(() => { console.log(props.info, 'useEffect_info'); fetchData(); }, [props.info]); return (
{...proTableDefaultOptions} itemLayout="vertical" itemCardProps={{ ghost: true, bodyStyle: { padding: 0, margin: 0 }, style: { width: '100%', border: 0, }, }} cardProps={{ style: { padding: 0, margin: 0 }, // 设置卡片的内外边距为 0 bodyStyle: { padding: 0, margin: 0, height: 'calc(100vh - 420px)', overflow: 'scroll', }, }} rowKey="model_id" dataSource={modelData} pagination={false} rowSelection={false} metas={{ content: { style: { margin: 0, padding: 0 }, }, }} />
); }; export default ModelSetting;