From 2b6e87710836dcfa1f33a9c01371c363132fd02b Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Fri, 28 Mar 2025 14:39:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E8=A6=81=E6=B1=82=E8=AE=A1=E7=AE=97=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E8=A7=84=E6=A0=BCid=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/components/ParameterSelect/index.tsx | 15 +++++++++++++-- .../components/PipelineNodeDrawer/index.tsx | 5 +++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/react-ui/src/components/ParameterSelect/index.tsx b/react-ui/src/components/ParameterSelect/index.tsx index 36b75d30..c9a78069 100644 --- a/react-ui/src/components/ParameterSelect/index.tsx +++ b/react-ui/src/components/ParameterSelect/index.tsx @@ -16,13 +16,17 @@ export type ParameterSelectObject = { [key: string]: any; }; +export type ParameterSelectDataType = 'dataset' | 'model' | 'service' | 'resource'; + export interface ParameterSelectProps extends SelectProps { /** 类型 */ - dataType: 'dataset' | 'model' | 'service' | 'resource'; + dataType: ParameterSelectDataType; /** 是否只是展示信息 */ display?: boolean; /** 值,支持对象,对象必须包含 value */ value?: string | ParameterSelectObject; + /** 用于流水线, 流水线资源规格要求 id 为字符串 */ + isPipeline?: boolean; /** 修改后回调 */ onChange?: (value: string | ParameterSelectObject) => void; } @@ -32,6 +36,7 @@ function ParameterSelect({ dataType, display = false, value, + isPipeline = false, onChange, ...rest }: ParameterSelectProps) { @@ -39,6 +44,12 @@ function ParameterSelect({ const propsConfig = paramSelectConfig[dataType]; const valueText = typeof value === 'object' && value !== null ? value.value : value; const [resourceStandardList] = useComputingResource(); + const computingResource = isPipeline + ? resourceStandardList.map((v) => ({ + ...v, + id: String(v.id), + })) + : resourceStandardList; useEffect(() => { // 获取下拉数据 @@ -56,7 +67,7 @@ function ParameterSelect({ getSelectOptions(); }, [propsConfig]); - const selectOptions = dataType === 'resource' ? resourceStandardList : options; + const selectOptions = dataType === 'resource' ? computingResource : options; const handleChange = (text: string) => { if (typeof value === 'object' && value !== null) { diff --git a/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx b/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx index 8defc169..44b35d2b 100644 --- a/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx +++ b/react-ui/src/pages/Pipeline/components/PipelineNodeDrawer/index.tsx @@ -1,7 +1,7 @@ import CodeSelectorModal from '@/components/CodeSelectorModal'; import KFIcon from '@/components/KFIcon'; import ParameterInput, { requiredValidator } from '@/components/ParameterInput'; -import ParameterSelect from '@/components/ParameterSelect'; +import ParameterSelect, { type ParameterSelectDataType } from '@/components/ParameterSelect'; import ResourceSelectorModal, { ResourceSelectorType, selectorTypeConfig, @@ -520,7 +520,8 @@ const PipelineNodeParameter = forwardRef(({ onFormChange }: PipelineNodeParamete {item.value.type === 'select' ? ( ['dataset', 'model', 'service', 'resource'].includes(item.value.item_type) ? ( ) : null