20 Commits

Author SHA1 Message Date
MHW
5c83b561cc 逻辑修改 2026-04-13 17:58:01 +08:00
bb45ff557b 新增根据行为树ID获取下属平台的接口 2026-04-13 17:33:28 +08:00
254401d8f1 支持根据行为树加载下属平台并优化属性面板显示 2026-04-13 17:26:50 +08:00
d8c238a9bb Merge remote-tracking branch 'origin/master' 2026-04-13 17:15:51 +08:00
MHW
aefc2c688e 逻辑修改 2026-04-13 17:13:34 +08:00
MHW
5f1ba38c6b 逻辑修改 2026-04-13 17:10:52 +08:00
MHW
e57f0f19d5 根据场景id显示所有行为树 2026-04-13 17:02:08 +08:00
79364b951d 修复类型导入缺失及Props类型断言格式 2026-04-13 16:41:11 +08:00
1270bd7d02 Merge remote-tracking branch 'origin/master' 2026-04-13 16:40:51 +08:00
MHW
b424774f3b 实体重复修改bug修复 2026-04-13 16:34:05 +08:00
MHW
766425bae5 实体重复修改 2026-04-13 16:31:56 +08:00
MHW
0e6b6d9f45 查询行为树所属平台的下属 2026-04-13 16:16:24 +08:00
50c1cc5bf2 修复行为树复制参数传递错误 2026-04-13 15:33:46 +08:00
7c71a38f68 添加前端行为树复制接口 2026-04-13 15:24:59 +08:00
3946bc561a 添加行为树复制功能 2026-04-13 14:25:50 +08:00
5179ab785c Merge commit '5276a6b16fdf0e345bd0a952abc998c1bf4e3725' 2026-04-13 14:22:14 +08:00
MHW
5276a6b16f 复制行为树 2026-04-13 14:19:18 +08:00
c0da7bd0d9 画布动态尺寸 2026-04-13 12:22:30 +08:00
MHW
dafd7115a8 Merge branch 'refs/heads/develop' 2026-04-13 10:39:47 +08:00
MHW
1061020791 复制行为树 2026-04-13 10:39:37 +08:00
24 changed files with 534 additions and 17 deletions

114
DEPLOY_OFFLINE.md Normal file
View File

@@ -0,0 +1,114 @@
# Docker 离线部署说明(方式 A)
执行 `docker compose up -d` 即可启动。
## 1. 交付清单
请将以下内容放在同一目录(示例:`app/`):
- `docker-compose.yml`
- `.env`(或将 `.env.example` 复制为 `.env` 后修改)
- `bundle-images.tar`(包含 `auto-solution-admin`、`mysql:8.0`、`redis:7-alpine`)
- `docker/mysql/init/01-ruoyi-table.sql`
- `docker/mysql/init/02-ruoyi-extra.sql`
- `docker/mysql/init/03-data.sql`
目录示例:
```text
app/
├─ docker-compose.yml
├─ .env
├─ bundle-images.tar
└─ docker/
└─ mysql/
└─ init/
├─ 00-create-db.sql
├─ 03-data.sql
```
## 2. 首次部署
在 `app` 目录执行:
```bash
docker load -i bundle-images.tar
docker compose down -v
docker compose up -d
```
说明:
- `down -v` 会删除旧数据卷,确保 MySQL 首次初始化时执行 `docker/mysql/init` 下的 SQL。
- SQL 执行顺序按文件名字典序,务必保持 `01 -> 02 -> 03`。
## 3. 启动验证
```bash
docker ps
docker inspect autosolution-mysql --format '{{.State.Health.Status}}'
docker logs --tail 100 autosolution-mysql
docker logs --tail 100 autosolution-app
```
期望结果:
- `autosolution-mysql` 状态为 `healthy`
- `autosolution-app` 状态为 `Up`
## 4. 访问地址
- 后端默认端口:`1777`
- 访问地址:`http://<服务器IP>:1777`
## 5. 常见问题
### 5.1 `Table 'autosolution_db.sys_config' doesn't exist`
原因:初始化 SQL 未执行或执行失败。
处理:
1. 确认 `docker/mysql/init` 下 SQL 文件存在且顺序正确
2. 执行:
```bash
docker compose down -v
docker compose up -d
```
3. 查看 MySQL 日志定位 SQL 报错:
```bash
docker logs --tail 300 autosolution-mysql
```
### 5.2 `dependency failed to start: container autosolution-mysql is unhealthy`
原因:MySQL 未通过健康检查(通常是 SQL 未执行完成或报错)。
处理:
```bash
docker logs --tail 300 autosolution-mysql
```
根据日志修复 SQL 后重新 `down -v` 再启动。
## 6. 版本升级
替换新的 `bundle-images.tar`(及必要 SQL)后执行:
```bash
docker load -i bundle-images.tar
docker compose down
docker compose up -d
```
如果本次升级包含库初始化变更并要求重建,请改用:
```bash
docker compose down -v
docker compose up -d
```

View File

@@ -97,6 +97,19 @@ public class BehaviortreeController extends BaseController
return toAjax(behaviortreeProcessor.create(behaviortree));
}
/**
* 复制行为树
*/
@ApiOperation("复制行为树")
@PreAuthorize("@ss.hasPermi('system:behaviortree:add')")
@Log(title = "行为树主", businessType = BusinessType.INSERT)
@PostMapping("/copy")
public AjaxResult copy(@RequestBody Behaviortree behaviortree)
{
//return toAjax(behaviortreeService.copy(behaviortree));
return toAjax(behaviortreeProcessor.copy(behaviortree));
}
/**
* 修改行为树主
*/
@@ -121,4 +134,18 @@ public class BehaviortreeController extends BaseController
return toAjax(behaviortreeService.deleteBehaviortreeByIds(ids));
}
/**
* 根据行为树id获取该行为树的下属
* @param treeId
* @return
*/
@ApiOperation("根据行为树id获取该行为树的下属")
@PreAuthorize("@ss.hasPermi('system:behaviortree:query')")
@GetMapping("/underling/{treeId}")
public AjaxResult getUnderling(@PathVariable Integer treeId)
{
return success(behaviortreeService.getUnderling(treeId));
}
}

View File

@@ -55,4 +55,13 @@ public class SceneController extends BaseController {
{
return success(sceneService.findOneById(id));
}
/**
* 根据场景id获取场景下所有行为树
*/
@GetMapping("/getAllTree/{id}")
@ApiOperation("根据场景id获取场景下所有行为树")
public AjaxResult getAllTree(@PathVariable Integer id){
return success(sceneService.getAllTree(id));
}
}

View File

@@ -8,8 +8,10 @@ package com.solution.web.core;
* that was distributed with this source code.
*/
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.solution.common.constant.ExceptionConstants;
import com.solution.system.domain.*;
import com.solution.system.service.IBehaviortreeService;
import com.solution.system.service.INodeconnectionService;
@@ -20,6 +22,7 @@ import com.solution.web.core.graph.GraphEdge;
import com.solution.web.core.graph.GraphNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
@@ -56,6 +59,7 @@ public class BehaviortreeProcessor {
return result;
}
@Transactional(rollbackFor = Exception.class)
public int update(Behaviortree behaviortree) {
int result = behaviortreeService.updateBehaviortree(behaviortree);
@@ -74,7 +78,7 @@ public class BehaviortreeProcessor {
}
private void processGraph(Behaviortree behaviortree) {
//代码丢失 原:libertyspy 改:MHW
Graph graph = null;
try {
graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class);
@@ -223,4 +227,23 @@ public class BehaviortreeProcessor {
}
/**
* 复制行为树
* @param behaviortree
* @return
*/
public int copy(Behaviortree behaviortree) {
if(ObjectUtil.isEmpty(behaviortree)){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
String name = behaviortree.getName();
String newName = name + "_" + behaviortree.getId();
String englishName = behaviortree.getEnglishName();
String newEnglishName = englishName + "_" + behaviortree.getId();
behaviortree.setEnglishName(newEnglishName);
behaviortree.setName(newName);
return this.create(behaviortree);
}
}

View File

@@ -49,6 +49,17 @@ public class Behaviortree extends BaseEntity
@Excel(name = "平台ID")
private Integer platformId;
@Excel(name = "场景ID")
private Integer scenarioId;
public Integer getScenarioId() {
return scenarioId;
}
public void setScenarioId(Integer scenarioId) {
this.scenarioId = scenarioId;
}
public Integer getPlatformId() {
return platformId;
}

View File

@@ -0,0 +1,40 @@
package com.solution.system.domain;
import lombok.Data;
/**
* 平台通信关系表
*/
@Data
public class PlatformCommunication {
/**
* 主键ID
*/
private Integer id;
/**
* 指挥平台名称/ID
*/
private String commandPlatform;
/**
* 下属平台名称/ID
*/
private String subordinatePlatform;
/**
* 指挥通信方式/内容
*/
private String commandComm;
/**
* 下属通信方式/内容
*/
private String subordinateComm;
/**
* 想定ID
*/
private Integer scenaryId;
}

View File

@@ -0,0 +1,31 @@
package com.solution.system.domain;
import lombok.Data;
/**
* 平台表
*/
@Data
public class PlatformTree {
/**
* 主键
*/
private Integer id;
/**
* 平台名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 平台出现在想定上的想定id
*/
private Integer scenarioId;
}

View File

@@ -0,0 +1,16 @@
package com.solution.system.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PlatformCommunicationMapper {
/**
* 根据平台name获取平台下属英文名
* @param name
* @return
*/
List<String> getUnderlingBytreeId(String name);
}

View File

@@ -0,0 +1,24 @@
package com.solution.system.mapper;
import com.solution.system.domain.PlatformTree;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PlatformMapper {
/**
* 根据行为树id获取行为树所属平台
* @param id
* @return
*/
PlatformTree getPlatformByTreeId(Integer id);
/**
* 根据下属平台英文名获取中文名返回
* @param underlingEnglishName
* @return
*/
List<String> selectPlatformChineseName(List<String> underlingEnglishName);
}

View File

@@ -62,4 +62,11 @@ public interface IBehaviortreeService
* @return 结果
*/
public int deleteBehaviortreeById(Long id);
/**
* 根据行为树id获取该行为树的下属
* @param treeId
* @return
*/
List<String> getUnderling(Integer treeId);
}

View File

@@ -2,8 +2,12 @@ package com.solution.system.service.impl;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.system.domain.PlatformTree;
import com.solution.system.mapper.PlatformCommunicationMapper;
import com.solution.system.mapper.PlatformMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.solution.system.mapper.BehaviortreeMapper;
@@ -22,6 +26,12 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
@Autowired
private BehaviortreeMapper behaviortreeMapper;
@Autowired
private PlatformCommunicationMapper platformCommunicationMapper;
@Autowired
private PlatformMapper platformMapper;
@Override
public Behaviortree findOneByPlatformId(Integer platformId)
{
@@ -99,4 +109,30 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
{
return behaviortreeMapper.deleteBehaviortreeById(id);
}
/**
* 根据行为树id获取该行为树的下属
* @param treeId
* @return
*/
@Override
public List<String> getUnderling(Integer treeId) {
if(null == treeId){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
Behaviortree behaviortree = behaviortreeMapper.selectBehaviortreeById(Long.valueOf(treeId));
if(ObjectUtil.isEmpty(behaviortree) || null == behaviortree.getId()){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
//根据行为树id获取行为树所属平台
PlatformTree platform = platformMapper.getPlatformByTreeId(behaviortree.getPlatformId());
//根据平台name获取平台下属英文名
List<String> underlingEnglishName = platformCommunicationMapper.getUnderlingBytreeId(platform.getName());
//根据下属平台英文名获取中文名返回
List<String> underlingChineseName = platformMapper.selectPlatformChineseName(underlingEnglishName);
if(CollUtil.isEmpty(underlingChineseName)){
throw new RuntimeException("该平台暂无下属");
}
return underlingChineseName;
}
}

View File

@@ -5,13 +5,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.solution.system.mapper.BehaviortreeMapper">
<resultMap type="Behaviortree" id="BehaviortreeResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="description" column="description" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="englishName" column="english_name" />
<result property="xmlContent" column="xml_content" />
<result property="id" column="id" />
<result property="name" column="name" />
<result property="description" column="description" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="englishName" column="english_name"/>
<result property="xmlContent" column="xml_content" />
<result property="platformId" column="platform_id" />
<result property="scenarioId" column="scenario_id" />
</resultMap>
<select id="findOneByPlatformId" resultMap="BehaviortreeResult">
@@ -37,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectBehaviortreeById" parameterType="Long" resultMap="BehaviortreeResult">
<include refid="selectBehaviortreeVo"/>
select id, name, description, created_at, updated_at, english_name,graph, xml_content ,platform_id, scenario_id from behaviortree
where id = #{id}
</select>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.system.mapper.PlatformCommunicationMapper">
<select id="getUnderlingBytreeId" resultType="java.lang.String" parameterType="java.lang.Integer">
SELECT subordinate_platform
FROM platform_communication
WHERE subordinate_platform = #{name}
</select>
</mapper>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.solution.system.mapper.PlatformMapper">
<select id="getPlatformByTreeId" resultType="com.solution.system.domain.PlatformTree"
parameterType="java.lang.Integer">
SELECT id , name , description, scenario_id
FROM platform
WHERE id = #{id}
</select>
<select id="selectPlatformChineseName" resultType="java.lang.String"
parameterType="java.util.List">
SELECT description
FROM platform
WHERE name IN
<foreach item="item" collection="underlingEnglishName" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -36,6 +36,11 @@
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.solution</groupId>
<artifactId>solution-behaviour</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -2,6 +2,7 @@ package com.solution.scene.mapper;
import com.solution.scene.domain.AfsimScenario;
import com.solution.scene.domain.AfsimScenarioForm;
import com.solution.system.domain.Behaviortree;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -26,4 +27,11 @@ public interface SceneMapper {
List<AfsimScenario> selectSceneList();
AfsimScenario findOneById(Long id);
/**
* 根据场景id获取场景下所有行为树
* @param id
* @return
*/
List<Behaviortree> selectAllTreeBySceneId(Integer id);
}

View File

@@ -2,6 +2,7 @@ package com.solution.scene.service;
import com.solution.scene.domain.AfsimScenario;
import com.solution.scene.domain.AfsimScenarioForm;
import com.solution.system.domain.Behaviortree;
import java.util.List;
@@ -25,4 +26,11 @@ public interface SceneService {
List<AfsimScenario> selectSceneList();
AfsimScenario findOneById(Long id);
/**
* 根据场景id获取场景下所有行为树
* @param id
* @return
*/
List<Behaviortree> getAllTree(Integer id);
}

View File

@@ -1,10 +1,13 @@
package com.solution.scene.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.scene.domain.AfsimScenario;
import com.solution.scene.domain.AfsimScenarioForm;
import com.solution.scene.mapper.PlatFormCommunicationMapper;
import com.solution.scene.mapper.SceneMapper;
import com.solution.scene.service.SceneService;
import com.solution.system.domain.Behaviortree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -70,4 +73,21 @@ public class SceneServiceImpl implements SceneService {
return sceneMapper.findOneById(id);
}
/**
* 根据场景id获取场景下所有行为树
* @param id
* @return
*/
@Override
public List<Behaviortree> getAllTree(Integer id) {
if(null == id || id <= 0){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
List<Behaviortree> allTree = sceneMapper.selectAllTreeBySceneId(id);
if(CollUtil.isEmpty(allTree)){
throw new RuntimeException("该场景下不存在行为树");
}
return allTree;
}
}

View File

@@ -25,6 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSceneList" resultMap="SceneMap">
SELECT id, name, description, scenario_path, communication_graph FROM afsim_scenario
</select>
<select id="selectAllTreeBySceneId" resultType="com.solution.system.domain.Behaviortree"
parameterType="java.lang.Integer">
SELECT id, name, description, created_at, updated_at, english_name, graph,xml_content,platform_id,scenario_id
FROM behaviortree
WHERE scenario_id=#{id}
</select>
<insert id="update" parameterType="com.solution.scene.domain.AfsimScenario">
update afsim_scenario

View File

@@ -28,6 +28,10 @@ export const findOneTreeByPlatformId = (platformId: number): Promise<BehaviorTre
return req.get(`/system/behaviortree/platform/${platformId}`);
};
export const findSubPlatforms = (treeId: number): Promise<BehaviorTreeDetailsResponse> => {
return req.get(`/system/behaviortree/underling/${treeId}`);
};
export const findOneTreeById = (id: number): Promise<BehaviorTreeDetailsResponse> => {
return req.get(`/system/behaviortree/${id}`);
};
@@ -40,6 +44,10 @@ export const updateTree = (rt: Partial<BehaviorTree>): Promise<BasicResponse> =>
return req.postJson(`/system/behaviortree`, rt);
};
export const copyTree = (rt: Partial<BehaviorTree>): Promise<BasicResponse> => {
return req.postJson(`/system/behaviortree/copy`, rt);
};
export const createTree = (rt: Partial<BehaviorTree>): Promise<BasicResponse> => {
return req.putJson(`/system/behaviortree`, rt);
};

View File

@@ -43,10 +43,11 @@
<Properties
v-if="graph"
:platforms="platforms"
:sub-platforms="subPlatforms"
:nodeCommands="nodeCommands"
:element="selectedNodeTaskElement"
:graph="graph as any"
:node="selectedModelNode as any"
:graph="(graph as any)"
:node="(selectedModelNode as any)"
:tree="currentBehaviorTree"
:tree-editing="currentTreeEditing"
@update-element="handleUpdateElement" />
@@ -74,8 +75,8 @@ import { createGraphTaskElementFromTemplate } from './utils';
import { createGraphTaskElement, createLineOptions, type GraphContainer, type GraphTaskElement, hasElements, hasRootElementNode, resolveGraph, useGraphCanvas } from '../graph';
import { registerNodeElement } from './register';
import { findAllBasicPlatforms, findAllNodeCommands } from '../api';
import type { Platform } from '../types';
import { createTree, findOneTreeById, findOneTreeByPlatformId, updateTree } from './api';
import type { NodeCommand, Platform } from '../types';
import { createTree, findOneTreeById, findOneTreeByPlatformId, updateTree, findSubPlatforms } from './api';
import TressCard from './trees-card.vue';
import NodesCard from './nodes-card.vue';
@@ -112,6 +113,7 @@ export default defineComponent({
const changed = ref<boolean>(false);
const treesCardRef = ref<InstanceType<typeof TressCard> | null>(null);
const platforms = ref<Platform[]>([]);
const subPlatforms = ref<Platform[]>([]);
const nodeCommands = ref<NodeCommand[]>([])
const currentScenarioId = ref<number | null>(null);
const currentPlatformId = ref<number | null>(null);
@@ -153,6 +155,27 @@ export default defineComponent({
loadNodeCommands();
}
// 加载下属平台
const loadSubPlatforms = (treeId: number) => {
console.log(treeId);
if (!treeId || treeId <= 0) {
subPlatforms.value = [];
return;
}
findSubPlatforms(treeId).then(r => {
if (r.data && Array.isArray(r.data)) {
subPlatforms.value = r.data as Platform[];
} else {
subPlatforms.value = [];
}
}).catch(err => {
console.error('加载下属平台失败:', err);
subPlatforms.value = [];
});
};
// 处理拖动开始
const handleDragStart = (nm: NodeDragTemplate) => {
draggedNodeData.value = nm;
@@ -267,6 +290,10 @@ export default defineComponent({
graph: nodeGraph,
};
currentTreeEditing.value = true;
// 加载下属平台
loadSubPlatforms(r.data.id);
nextTick(() => {
initGraph();
});
@@ -343,6 +370,7 @@ export default defineComponent({
};
selectedModelNode.value = null;
selectedNodeTaskElement.value = null;
subPlatforms.value = []; // 重置下属平台
nextTick(() => {
initGraph();
@@ -487,6 +515,7 @@ export default defineComponent({
nodeCommands,
currentScenarioId,
platforms,
subPlatforms,
treesCardRef,
handleCreateTree,
currentTreeEditing,

View File

@@ -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,

View File

@@ -29,6 +29,12 @@
</a-tooltip>
<a-flex class="ks-tree-actions">
<!-- <span style="margin-right: 10px"><EditFilled /></span>-->
<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)"
@@ -51,15 +57,16 @@
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import { CheckOutlined, DeleteOutlined, EditFilled, PlusOutlined } from '@ant-design/icons-vue';
import { CheckOutlined, CopyOutlined, DeleteOutlined, EditFilled, PlusOutlined } from '@ant-design/icons-vue';
import type { BehaviorTree, BehaviorTreeRequest } from './tree';
import { deleteOneTreeById, findTreesByQuery } from './api';
import { copyTree, deleteOneTreeById, findTreesByQuery } from './api';
import { substring } from '@/utils/strings';
export default defineComponent({
emits: ['select-tree', 'create-tree'],
components: {
CheckOutlined,
CopyOutlined,
PlusOutlined,
DeleteOutlined,
EditFilled,
@@ -95,6 +102,14 @@ export default defineComponent({
});
};
const handleCopy = (item: BehaviorTree) => {
copyTree(item).then(r => {
if (r.code === 200) {
loadTress();
}
});
};
const columns = [
{
title: '名称',
@@ -133,6 +148,7 @@ export default defineComponent({
handleSelect,
handleChange,
handleDelete,
handleCopy,
};
},
});

View File

@@ -104,6 +104,7 @@ export const createGraphConnectingAttributes = (): Partial<Connecting> => {
export const createGraphCanvas = (container: HTMLDivElement, readonly: boolean = false): Graph => {
const graph = new Graph({
container: container,
autoResize: true,
grid: {
size: 20,
visible: true,