支持根据行为树加载下属平台并优化属性面板显示
This commit is contained in:
@@ -101,7 +101,7 @@
|
||||
size="small"
|
||||
type="editable-card"
|
||||
@edit="onEditParameterTab">
|
||||
<a-tab-pane v-for="(grouped,index) in groupedParameters" :key="index" :tab="`平台 ${index + 1}`" :closable="true">
|
||||
<a-tab-pane v-for="(grouped,index) in groupedParameters" :key="index" :tab="getPlatformTabName(index)" :closable="true">
|
||||
<a-form-item v-for="setting in grouped" :label="setting.description">
|
||||
<a-input-number v-if="setting.dataType === 'double'"
|
||||
v-model:value="setting.defaultValue"
|
||||
@@ -109,7 +109,7 @@
|
||||
<a-select :placeholder="`请选择${setting.description}`"
|
||||
allow-clear
|
||||
v-else-if="setting.paramKey === 'platforms'" v-model:value="setting.defaultValue">
|
||||
<a-select-option v-for="pl in platforms" :value="pl.name">{{pl.description}}</a-select-option>
|
||||
<a-select-option v-for="pl in getAvailablePlatforms()" :value="pl.name">{{pl.description}}</a-select-option>
|
||||
</a-select>
|
||||
<a-select :placeholder="`请选择${setting.description}`"
|
||||
allow-clear
|
||||
@@ -194,11 +194,13 @@ export default defineComponent({
|
||||
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
|
||||
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
|
||||
platforms: { type: Array as PropType<Platform[]>, required: true },
|
||||
subPlatforms: { type: Array as PropType<Platform[]>, required: false, default: () => [] },
|
||||
nodeCommands: { type: Array as PropType<NodeCommand[]>, required: true },
|
||||
},
|
||||
emits: ['update-element', 'update-tree'],
|
||||
setup(props, { emit }) {
|
||||
const platforms = ref<Platform[]>(props.platforms ?? []);
|
||||
const subPlatforms = ref<Platform[]>(props.subPlatforms ?? []);
|
||||
const nodeCommands = ref<NodeCommand[]>(props.nodeCommands ?? []);
|
||||
|
||||
const activeTopTabsKey = ref<string>('1');
|
||||
@@ -299,6 +301,41 @@ export default defineComponent({
|
||||
multiableParameters.value = multiable === true && groupedParameters.value.length > 0;
|
||||
};
|
||||
|
||||
// 获取平台Tab显示名称
|
||||
const getPlatformTabName = (index: number): string => {
|
||||
if (!currentTree.value?.platformId) {
|
||||
return `平台 ${index + 1}`;
|
||||
}
|
||||
|
||||
// 查找当前行为树绑定的平台
|
||||
const currentPlatform = platforms.value.find(p => p.id === currentTree.value?.platformId);
|
||||
if (!currentPlatform) {
|
||||
return `平台 ${index + 1}`;
|
||||
}
|
||||
|
||||
// 如果有多个分组,显示平台名称和索引
|
||||
if (groupedParameters.value.length > 1) {
|
||||
return `${currentPlatform.name || '未知平台'}-${index + 1}`;
|
||||
}
|
||||
|
||||
return currentPlatform.name || '平台';
|
||||
};
|
||||
|
||||
// 获取可用的平台列表(包括当前平台和其下属平台)
|
||||
const getAvailablePlatforms = (): Platform[] => {
|
||||
if (!currentTree.value?.platformId) {
|
||||
return platforms.value;
|
||||
}
|
||||
|
||||
// 如果有下属平台,返回下属平台列表
|
||||
if (subPlatforms.value && subPlatforms.value.length > 0) {
|
||||
return subPlatforms.value;
|
||||
}
|
||||
|
||||
// 否则返回所有平台
|
||||
return platforms.value;
|
||||
};
|
||||
|
||||
|
||||
const resolveNode = (n?: Node | null | undefined) => {
|
||||
groupedParametersActiveTab.value = 0;
|
||||
@@ -389,6 +426,7 @@ export default defineComponent({
|
||||
|
||||
watch(() => props.nodeCommands, (n: NodeCommand[] | null | undefined) => nodeCommands.value = n ?? [], { deep: true, immediate: true });
|
||||
watch(() => props.platforms, (n: Platform[] | null | undefined) => platforms.value = n ?? [], { deep: true, immediate: true });
|
||||
watch(() => props.subPlatforms, (n: Platform[] | null | undefined) => subPlatforms.value = n ?? [], { deep: true, immediate: true });
|
||||
|
||||
onMounted(() => load());
|
||||
|
||||
@@ -400,6 +438,8 @@ export default defineComponent({
|
||||
multiableParameters,
|
||||
onEditParameterTab,
|
||||
groupedParameters,
|
||||
getPlatformTabName,
|
||||
getAvailablePlatforms,
|
||||
actionSpaceColumns,
|
||||
activeTopTabsKey,
|
||||
activeBottomTabsKey,
|
||||
|
||||
Reference in New Issue
Block a user