/* * @Author: donghao donghao@supervision.ltd * @Date: 2024-04-08 16:57:30 * @LastEditors: donghao donghao@supervision.ltd * @LastEditTime: 2024-07-23 09:29:54 * @FilePath: \general-ai-manage\src\pages\Project\BusinessProject\components\detailServerState.tsx * @Description: 服务器详情 * @交互说明 * */ import { apiEntityNodesBusimodelDeploy, apiEntityNodesDeviceListSimple, } from '@/services/business/entity'; import { isSuccessApi } from '@/utils/forApi'; import { mathConvertCommaSeparatedStringToArray, mathExtractIds } from '@/utils/forMath'; import { isArrayAndNotEmpty } from '@/utils/is'; import { ProCard, ProColumns, ProDescriptions, ProTable } from '@ant-design/pro-components'; import { FormattedMessage, useIntl } from '@umijs/max'; import { Modal, message } from 'antd'; import { useEffect, useRef, useState } from 'react'; import { proFormSmallModelWidth } from '../../../../../config/defaultForm'; import { proTableDefaultOptions } from '../../../../../config/defaultTable'; type ModelDeployConfigProps = { info: Record; nodeInfo: Record; detailOpen: boolean; handleModal: () => void; reload: () => void; }; const ModelDeployConfig: React.FC = ({ info, nodeInfo, detailOpen, reload, handleModal, }) => { /**state */ const intl = useIntl(); const [selectedRows, setSelectedRows] = useState[]>([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const actionRef = useRef(); // 基础配置信息 const detailColumns = [ { title: ( ), dataIndex: 'busi_model_name', }, { title: , dataIndex: 'busi_model_comment', }, { title: ( ), dataIndex: 'linkModels', render: (_, record) => { return (
    {mathConvertCommaSeparatedStringToArray(record?.base_models)?.map((item, index) => { return (
  • {item}
  • ); })}
); }, }, ]; // 模型列表信息 const columns: ProColumns>[] = [ { title: ( ), dataIndex: 'name', hideInSearch: true, key: 'fixedName', fixed: 'left', width: '55%', }, { title: ( ), dataIndex: 'classification_name', hideInSearch: true, }, ]; // 基础模型列表数据api function loadData() { console.log(info?.devices, 'loadData_devices'); if (isArrayAndNotEmpty(info?.devices)) { const selectArr = []; info?.devices.forEach((item) => { selectArr.push(item.device_id); }); setSelectedRowKeys(selectArr); } } useEffect(() => { // eslint-disable-next-line @typescript-eslint/no-unused-expressions info?.busi_model_id && loadData(); }, [info]); // 初始化加载 useEffect(() => { console.log('modelDeployConfig_detailOpen', detailOpen); if (!detailOpen) { actionRef?.current?.clearSelected(); setSelectedRows([]); setSelectedRowKeys([]); } }, [detailOpen]); return ( { handleModal(); }} onOk={async () => { console.log(info, 'onOk_selectedRows', selectedRows); let resp = await apiEntityNodesBusimodelDeploy({ node_id: nodeInfo?.node_id, busi_model_id: info?.busi_model_id, device_ids: mathExtractIds(selectedRows)?.join(','), }); if (isSuccessApi(resp)) { message.success( intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }), ); reload(); handleModal(); } else { message.error( resp?.meta?.message || intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }), ); } }} okText={} cancelText={} >
{ setSelectedRows(selectedRowsData); }, }} tableAlertRender={false} request={async () => { let resp = await apiEntityNodesDeviceListSimple({ node_id: nodeInfo?.node_id }); console.log(resp, 'getAllDeviceList_resp'); return { data: resp.data?.data, success: resp.success, }; }} columns={columns} />
); }; export default ModelDeployConfig;