import { postDeviceGroupGetDeviceGroupById, postDeviceGroupGetDeviceGroupTree, } from '@/services/device/DeviceGroup'; import TreeAndTableList, { ProCardTypeProps } from '@/layouts/treeAndTableList'; import { postProjectGetProjectByGroupId } from '@/services/project/Project'; import { postModelVersionGetModelVersionListByIds } from '@/services/resource/ModelVersion'; import { FormattedMessage } from '@@/exports'; import { CaretRightOutlined, PauseOutlined } from '@ant-design/icons'; import type { ActionType } from '@ant-design/pro-components'; import { PageContainer, ProCard, ProDescriptions, ProList } from '@ant-design/pro-components'; import { useAccess, useIntl } from '@umijs/max'; import { Button, Tag, message } from 'antd'; import Tree, { DataNode } from 'antd/es/tree'; import React, { useEffect, useRef, useState } from 'react'; import ProjectCard from './components/ProjectCard'; import UpdateForm from './components/UpdateForm'; const AlgorithmSetting: React.FC = () => { /** * @en-US Pop-up window of new window * @zh-CN 新建窗口的弹窗 * */ /** * @en-US International configuration * @zh-CN 国际化配置 * */ const access = useAccess(); const intl = useIntl(); const projectCardListRef = useRef(null); const actionRef = useRef(); const [updateModalOpen, setUpdateModalOpen] = useState(false); const [hasInit, setHasInit] = useState(false); const [nodeTreeData, setNodeTreeData] = React.useState([]); const [selectNodes, setSelectNodes] = React.useState([]); const [currentRow, setCurrentRow] = useState(); const [currentCard, setCurrentCard] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); const [tabs, setTabs] = useState([]); const [cardActionProps, setCardActionProps] = useState<'actions' | 'extra'>('extra'); const [modelVersionData, setModelVersionData] = useState([]); const [projectData, setProjectData] = useState>({}); const [targetKeys, setTargetKeys] = useState([]); const [projectConfigId, setProjectConfigId] = useState(0); const handleUpdateModal = () => { if (updateModalOpen) { setUpdateModalOpen(false); setProjectConfigId(0); } else { setUpdateModalOpen(true); } }; const [tab, setTab] = useState(''); // const columns1: ProColumns[] = [ // { // title: '全选', // dataIndex: 'name', // hideInSearch: true, // }, // ]; const columns = [ // { // title: , // dataIndex: 'id', // sorter: true, // }, { title: , dataIndex: 'name', hideInSearch: true, }, { title: , dataIndex: 'isEnable', filters: true, onFilter: true, hideInSearch: true, valueType: 'switch', }, { title: ( ), dataIndex: 'createTime', sorter: true, hideInSearch: true, valueType: 'dateTime', }, { title: ( ), dataIndex: 'updateTime', sorter: true, hideInSearch: true, valueType: 'dateTime', }, { title: , dataIndex: 'code', hideInSearch: true, }, { title: , dataIndex: 'address', hideInSearch: true, }, // { // title: ( // // ), // dataIndex: 'telephone', // hideInSearch: true, // }, // { // title: , // dataIndex: 'lon', // hideInSearch: true, // }, // { // title: , // dataIndex: 'lat', // hideInSearch: true, // }, // { // title: ( // // ), // dataIndex: 'managerName', // hideInSearch: true, // }, // { // title: ( // // ), // dataIndex: 'managerPhone', // hideInSearch: true, // }, // { // title: , // dataIndex: 'remark', // hideInSearch: true, // }, ]; // 项目信息展示 async function fetchProjectInfoByGroupId(record: Record) { const resp = await postDeviceGroupGetDeviceGroupById({ id: record.key }); console.log('fetchProjectInfoByGroupId_resp', resp.data.deviceGroup); setCurrentRow(resp.data.deviceGroup); } // TODO 左侧图标目前写死,需替换 // 操作左侧网点数据节点, 项目列表数据变更 function fetchProjectByGroupId(record: Record) { // console.log('clickTreeNode', projectCardListRef.current) 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: (
), })); // console.log(88, model_data); // setProjectData({...projectData, [v.id]: v}) return { label: `项目:${v.name}`, key: v.id, children: ( className="gn" ghost={true} itemCardProps={{ ghost: true, bodyStyle: { padding: 0, margin: 0 }, }} pagination={{ defaultPageSize: 6, showSizeChanger: false, }} showActions="hover" grid={{ gutter: 8, xs: 1, md: 2, xl: 3, xxl: 4 }} metas={{ type: {}, content: {}, actions: { cardActionProps, }, }} headerTitle="项目模型列表" toolBarRender={(action, rows) => { console.log(action, rows, 'toolBarRender'); // TODO 需要对接接口 const isProcess: boolean = false; return isProcess ? ( ) : ( ); }} dataSource={model_data} /> ), }; }); if (tab_data.length) { setTab(tab_data[0].key); } setTabs(tab_data); }); } // TODO 需联调 // 操作项目列表数据类别切换, 项目列表数据变更 function changeProjectTab(key: React.SetStateAction) { let model_ids = projectData[key]?.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(99, modelVersionData); }); setTab(key); } useEffect(() => { postDeviceGroupGetDeviceGroupTree() .then((resp) => { setNodeTreeData(resp.data.tree); setHasInit(true); }) .catch(() => { message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); }); }, []); return ( { // TODO_1 此处接口需要重新联调 console.log(info.node, 'onSelect_info'); setSelectNodes(selectKeys); fetchProjectInfoByGroupId(info?.node); fetchProjectByGroupId(info?.node); actionRef.current?.reload(); }} checkStrictly={false} /> ) } rightDom={
{ changeProjectTab(key); }, }} >
} >
{/* */} } updateModalOpen={updateModalOpen} handleModal={handleUpdateModal} groupId={currentRow?.id || 0} reload={actionRef.current?.reload} projectModelConfigId={projectConfigId} />
); }; export default AlgorithmSetting;