import { Spin, Row, Col, Switch } from 'antd'; import { CheckCircleFilled } from '@ant-design/icons'; import { PREFIX_CLS, MsgContentTypeEnum } from '../../common/constants'; import { MsgDataType } from '../../common/type'; import ChatMsg from '../ChatMsg'; import WebPage from '../ChatMsg/WebPage'; import Loading from './Loading'; import React, { ReactNode, useState } from 'react'; type Props = { queryId?: number; queryMode?: string; executeLoading: boolean; entitySwitchLoading: boolean; chartIndex: number; executeTip?: string; executeItemNode?: ReactNode; renderCustomExecuteNode?: boolean; data?: MsgDataType; triggerResize?: boolean; isDeveloper?: boolean; isSimpleMode?: boolean; }; const ExecuteItem: React.FC = ({ queryId, queryMode, executeLoading, entitySwitchLoading, chartIndex, executeTip, executeItemNode, renderCustomExecuteNode, data, triggerResize, isDeveloper, isSimpleMode, }) => { const prefixCls = `${PREFIX_CLS}-item`; const [showMsgContentTable, setShowMsgContentTable] = useState(false); const [msgContentType, setMsgContentType] = useState(); const getNodeTip = (title: ReactNode, tip?: string) => { return ( <>
{title} {!tip && }
{tip &&
{tip}
} ); }; if (executeLoading) { if (queryMode === 'PLAIN_TEXT') { return ; } return getNodeTip('数据查询中'); } if (executeTip) { return getNodeTip( <> 数据查询失败 {data?.queryTimeCost && isDeveloper && ( (耗时: {data.queryTimeCost}ms) )} , executeTip ); } if (!data) { return null; } if (data.queryMode === 'PLAIN_TEXT') { return <>{data.textResult}; } return ( <>
数据查询 {data?.queryTimeCost && isDeveloper && ( (耗时: {data.queryTimeCost}ms) )} {[MsgContentTypeEnum.METRIC_TREND, MsgContentTypeEnum.METRIC_BAR].includes( msgContentType as MsgContentTypeEnum ) && ( { setShowMsgContentTable(checked); }} /> )}
{data.queryAuthorization?.message && (
提示:{data.queryAuthorization.message}
)} {renderCustomExecuteNode && executeItemNode ? ( executeItemNode ) : data?.queryMode === 'WEB_PAGE' ? ( ) : ( { setMsgContentType(type); }} /> )}
); }; export default ExecuteItem;