优化场景和行为树列表项的选中状态显示
This commit is contained in:
@@ -154,23 +154,6 @@
|
|||||||
<a-input v-else v-model:value="setting.defaultValue" :placeholder="setting.description" size="small" />
|
<a-input v-else v-model:value="setting.defaultValue" :placeholder="setting.description" size="small" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
<template>
|
|
||||||
<a-form-item v-for="setting in currentElement.parameters" :label="setting.description">
|
|
||||||
<a-input-number v-if="setting.dataType === 'double'" v-model:value="setting.defaultValue"
|
|
||||||
:placeholder="setting.description" size="small" style="width:100%;" />
|
|
||||||
<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 getAvailablePlatforms()" :value="pl.name">{{ pl.description }}</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
<a-select :placeholder="`请选择${setting.description}`"
|
|
||||||
allow-clear
|
|
||||||
v-else-if="setting.paramKey === 'command'" v-model:value="setting.defaultValue">
|
|
||||||
<a-select-option v-for="pl in nodeCommands" :value="pl.command">{{pl.chineseName}}</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
<a-input v-else v-model:value="setting.defaultValue" :placeholder="setting.description" size="small" />
|
|
||||||
</a-form-item>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<a-list :data-source="scenarios || []" size="small" style="min-height: 25vh">
|
<a-list :data-source="scenarios || []" size="small" style="min-height: 25vh">
|
||||||
<template #renderItem="{ item }">
|
<template #renderItem="{ item }">
|
||||||
<a-list-item @click="()=> handleSelect(item)">
|
<a-list-item :class="{ 'ks-item-selected': selectedId === item.id }" @click="()=> handleSelect(item)">
|
||||||
<a-flex>
|
<a-flex>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip placement="bottom">
|
||||||
<template #title>
|
<template #title>
|
||||||
@@ -23,20 +23,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<span>{{ substring(item.name, 15) }}</span>
|
<span>{{ substring(item.name, 15) }}</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-flex class="ks-tree-actions">
|
|
||||||
<a-popconfirm
|
|
||||||
title="确定复制?"
|
|
||||||
@confirm="()=> handleCopy(item)"
|
|
||||||
>
|
|
||||||
<span class="ks-tree-action ks-tree-action-copy" @click.stop style="margin-right: 10px"><CopyOutlined /></span>
|
|
||||||
</a-popconfirm>
|
|
||||||
<a-popconfirm
|
|
||||||
title="确定删除?"
|
|
||||||
@confirm="()=> handleDelete(item)"
|
|
||||||
>
|
|
||||||
<span class="ks-tree-action ks-tree-action-delete" @click.stop><DeleteOutlined /></span>
|
|
||||||
</a-popconfirm>
|
|
||||||
</a-flex>
|
|
||||||
</a-flex>
|
</a-flex>
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
</template>
|
</template>
|
||||||
@@ -74,6 +60,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
const activeKey = ref<number>(0);
|
const activeKey = ref<number>(0);
|
||||||
const totalScenarios = ref<number>(0);
|
const totalScenarios = ref<number>(0);
|
||||||
|
const selectedId = ref<number | null>(null);
|
||||||
|
|
||||||
const loadScenarios = (cb?: () => void) => {
|
const loadScenarios = (cb?: () => void) => {
|
||||||
findScenarioByQuery(scenarioQuery.value).then(r => {
|
findScenarioByQuery(scenarioQuery.value).then(r => {
|
||||||
@@ -89,19 +76,8 @@ export default defineComponent({
|
|||||||
loadScenarios();
|
loadScenarios();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (item: Scenario) => {
|
|
||||||
// TODO: 实现删除场景的API调用
|
|
||||||
console.log('删除场景:', item);
|
|
||||||
loadScenarios();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCopy = (item: Scenario) => {
|
|
||||||
// TODO: 实现复制场景的API调用
|
|
||||||
console.log('复制场景:', item);
|
|
||||||
loadScenarios();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelect = (record: Scenario) => {
|
const handleSelect = (record: Scenario) => {
|
||||||
|
selectedId.value = record.id;
|
||||||
emit('select-scenario', record);
|
emit('select-scenario', record);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,6 +86,7 @@ export default defineComponent({
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadScenarios(() => {
|
loadScenarios(() => {
|
||||||
if(scenarios.value.length > 0){
|
if(scenarios.value.length > 0){
|
||||||
|
selectedId.value = scenarios.value[0]!.id;
|
||||||
emit('select-scenario', scenarios.value[0]);
|
emit('select-scenario', scenarios.value[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -120,42 +97,18 @@ export default defineComponent({
|
|||||||
totalScenarios,
|
totalScenarios,
|
||||||
substring,
|
substring,
|
||||||
activeKey,
|
activeKey,
|
||||||
|
selectedId,
|
||||||
scenarios,
|
scenarios,
|
||||||
scenarioQuery,
|
scenarioQuery,
|
||||||
loadScenarios,
|
loadScenarios,
|
||||||
handleSelect,
|
handleSelect,
|
||||||
handleChange,
|
handleChange,
|
||||||
handleDelete,
|
|
||||||
handleCopy,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.ks-tree-actions {
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ks-tree-action {
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 2px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ks-tree-action:hover {
|
|
||||||
background-color: rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ks-tree-action-copy {
|
|
||||||
color: #1890ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ks-tree-action-delete {
|
|
||||||
color: #ff4d4f;
|
|
||||||
}
|
|
||||||
|
|
||||||
.a-list-item {
|
.a-list-item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
@@ -166,14 +119,16 @@ export default defineComponent({
|
|||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.a-list-item:hover .ks-tree-actions {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-scenario::before {
|
.icon-scenario::before {
|
||||||
content: '\e6b8';
|
content: '\e6b8';
|
||||||
font-family: 'iconfont';
|
font-family: 'iconfont';
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
color: #82c4e9;
|
color: #82c4e9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.ant-list-item.ks-item-selected) {
|
||||||
|
background-color: rgba(130, 196, 233, 0.15);
|
||||||
|
border-left: 3px solid #82c4e9;
|
||||||
|
padding-left: 9px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<a-list :data-source="behaviorTrees || []" size="small" style="min-height: 25vh">
|
<a-list :data-source="behaviorTrees || []" size="small" style="min-height: 25vh">
|
||||||
<template #renderItem="{ item }">
|
<template #renderItem="{ item }">
|
||||||
<a-list-item @click="()=> handleSelect(item)">
|
<a-list-item :class="{ 'ks-item-selected': selectedId === item.id }" @click="()=> handleSelect(item)">
|
||||||
<a-flex>
|
<a-flex>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip placement="bottom">
|
||||||
<template #title>
|
<template #title>
|
||||||
@@ -86,10 +86,12 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
const activeKey = ref<number>(1);
|
const activeKey = ref<number>(1);
|
||||||
const totalTress = ref<number>(0);
|
const totalTress = ref<number>(0);
|
||||||
|
const selectedId = ref<number | null>(null);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => _props.scenarioId,
|
() => _props.scenarioId,
|
||||||
() => {
|
() => {
|
||||||
|
selectedId.value = null;
|
||||||
if (!_props.scenarioId) {
|
if (!_props.scenarioId) {
|
||||||
behaviorTrees.value = [];
|
behaviorTrees.value = [];
|
||||||
totalTress.value = 0;
|
totalTress.value = 0;
|
||||||
@@ -139,6 +141,7 @@ export default defineComponent({
|
|||||||
];
|
];
|
||||||
|
|
||||||
const handleSelect = (record: BehaviorTree) => {
|
const handleSelect = (record: BehaviorTree) => {
|
||||||
|
selectedId.value = record.id;
|
||||||
emit('select-tree', record);
|
emit('select-tree', record);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,6 +160,7 @@ export default defineComponent({
|
|||||||
totalTress,
|
totalTress,
|
||||||
substring,
|
substring,
|
||||||
activeKey,
|
activeKey,
|
||||||
|
selectedId,
|
||||||
behaviorTrees,
|
behaviorTrees,
|
||||||
behaviorTreeQuery,
|
behaviorTreeQuery,
|
||||||
loadTress,
|
loadTress,
|
||||||
@@ -172,3 +176,11 @@ export default defineComponent({
|
|||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.ant-list-item.ks-item-selected) {
|
||||||
|
background-color: rgba(130, 196, 233, 0.15);
|
||||||
|
border-left: 3px solid #82c4e9;
|
||||||
|
padding-left: 9px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user