98 lines
2.2 KiB
Vue
98 lines
2.2 KiB
Vue
<template>
|
|
<a-collapse v-model:activeKey="activeKey" :accordion="false">
|
|
<a-collapse-panel key="1">
|
|
<template #header>
|
|
<span class="ks-model-builder-title-icon icon-model"></span>我的行为树
|
|
</template>
|
|
<a-list size="small" :data-source="behaviorTrees || []" style="min-height: 25vh">
|
|
<template #renderItem="{ item }">
|
|
<a-tooltip placement="right">
|
|
<template #title>
|
|
<p>名称: {{ item.name }}</p>
|
|
<p>说明: {{item.description}}</p>
|
|
</template>
|
|
<a-list-item @click="()=> handleSelect(item)">
|
|
{{ substring(item.name, 25) }}
|
|
</a-list-item>
|
|
</a-tooltip>
|
|
</template>
|
|
</a-list>
|
|
</a-collapse-panel>
|
|
</a-collapse>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, onMounted, ref } from 'vue';
|
|
import { PlusOutlined } from '@ant-design/icons-vue';
|
|
import type { BehaviorTree } from './types';
|
|
import { findTreesByQuery } from './api';
|
|
import {substring} from '@/utils/strings'
|
|
|
|
export default defineComponent({
|
|
emits: ['select-tree'],
|
|
components: {
|
|
PlusOutlined
|
|
},
|
|
setup(_props, { emit }) {
|
|
const behaviorTrees = ref<BehaviorTree[]>([]);
|
|
const behaviorTreeQuery = ref<Partial<BehaviorTree>>({});
|
|
const activeKey = ref<number>(1)
|
|
const loadTress = () => {
|
|
findTreesByQuery(behaviorTreeQuery.value).then(r => {
|
|
behaviorTrees.value = r.rows;
|
|
});
|
|
};
|
|
|
|
const columns = [
|
|
{
|
|
title: '名称',
|
|
dataIndex: 'name',
|
|
},
|
|
];
|
|
|
|
const handleSelect = (record: BehaviorTree) => {
|
|
emit('select-tree', record);
|
|
}
|
|
|
|
const customRow = (record: BehaviorTree) => {
|
|
return {
|
|
onClick: (event: any) => {
|
|
emit('select-tree', record, event);
|
|
},
|
|
};
|
|
};
|
|
|
|
onMounted(() => {
|
|
loadTress();
|
|
});
|
|
|
|
return {
|
|
substring,
|
|
activeKey,
|
|
behaviorTrees,
|
|
behaviorTreeQuery,
|
|
loadTress,
|
|
columns,
|
|
customRow,
|
|
handleSelect,
|
|
};
|
|
},
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.create-tree-icon{
|
|
cursor: pointer;
|
|
}
|
|
.ant-list-item {
|
|
padding: 5px 5px;
|
|
cursor: pointer;
|
|
color: rgb(130 196 233);
|
|
|
|
&:hover {
|
|
background: #0d2d4e;
|
|
}
|
|
}
|
|
</style> |