UPDATE: VERSION-20260331
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { HttpRequestClient } from '@/utils/request';
|
import { HttpRequestClient } from '@/utils/request';
|
||||||
import type { Scenario, ScenarioPageableResponse, ScenarioRequest } from './types';
|
import type { Scenario, ScenarioDetailsResponse, ScenarioPageableResponse, ScenarioRequest } from './types';
|
||||||
import type { PlatformWithComponentsResponse } from '../types';
|
import type { PlatformWithComponentsResponse } from '../types';
|
||||||
import type { BasicResponse } from '@/types';
|
import type { BasicResponse } from '@/types';
|
||||||
|
|
||||||
@@ -17,17 +17,21 @@ const req = HttpRequestClient.create<BasicResponse>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const findScenarioByQuery = (_query: Partial<ScenarioRequest> = {}): Promise<ScenarioPageableResponse> => {
|
export const findScenarioByQuery = (_query: Partial<ScenarioRequest> = {}): Promise<ScenarioPageableResponse> => {
|
||||||
return req.get('/system/scene/list', _query);
|
return req.get<ScenarioPageableResponse>('/system/scene/list', _query);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const findOneScenarioById = (id: number): Promise<ScenarioDetailsResponse> => {
|
||||||
|
return req.get<ScenarioDetailsResponse>(`/system/scene/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteOneScenarioById = (id: number): Promise<BasicResponse> => {
|
export const deleteOneScenarioById = (id: number): Promise<BasicResponse> => {
|
||||||
return req.delete(`/system/behaviortree/${id}`);
|
return req.delete<BasicResponse>(`/system/behaviortree/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findPlatformWithComponents = (id: number): Promise<PlatformWithComponentsResponse> => {
|
export const findPlatformWithComponents = (id: number): Promise<PlatformWithComponentsResponse> => {
|
||||||
return req.get(`/system/firerule/platforms/${id}`);
|
return req.get<PlatformWithComponentsResponse>(`/system/firerule/platforms/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const saveScenario = (scenario: Scenario): Promise<BasicResponse> => {
|
export const saveScenario = (scenario: Scenario): Promise<BasicResponse> => {
|
||||||
return req.postJson(`/system/scene/saveSceneConfig`,scenario);
|
return req.postJson<BasicResponse>(`/system/scene/saveSceneConfig`,scenario);
|
||||||
};
|
};
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
import { defineComponent, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||||
import {useRouter} from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { getTeleport } from '@antv/x6-vue-shape';
|
import { getTeleport } from '@antv/x6-vue-shape';
|
||||||
import { Graph, Node, type NodeProperties } from '@antv/x6';
|
import { Graph, Node, type NodeProperties } from '@antv/x6';
|
||||||
@@ -64,7 +64,7 @@ import { createGraphScenarioElement, createGraphTaskElementFromScenario } from '
|
|||||||
|
|
||||||
import PlatformCard from './platform-card.vue';
|
import PlatformCard from './platform-card.vue';
|
||||||
import NodesCard from './nodes-card.vue';
|
import NodesCard from './nodes-card.vue';
|
||||||
import { saveScenario } from './api';
|
import { findOneScenarioById, saveScenario } from './api';
|
||||||
import { resolveConnectionRelation } from './relation';
|
import { resolveConnectionRelation } from './relation';
|
||||||
|
|
||||||
const TeleportContainer = defineComponent(getTeleport());
|
const TeleportContainer = defineComponent(getTeleport());
|
||||||
@@ -84,7 +84,7 @@ export default defineComponent({
|
|||||||
TeleportContainer,
|
TeleportContainer,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const router = useRouter();
|
const currentRoute = useRoute();
|
||||||
const canvas = ref<HTMLDivElement | null>(null);
|
const canvas = ref<HTMLDivElement | null>(null);
|
||||||
const graph = ref<Graph | null>(null);
|
const graph = ref<Graph | null>(null);
|
||||||
const currentZoom = ref<number>(1);
|
const currentZoom = ref<number>(1);
|
||||||
@@ -97,6 +97,7 @@ export default defineComponent({
|
|||||||
const selectedNodeTaskElement = ref<GraphTaskElement | null>(null);
|
const selectedNodeTaskElement = ref<GraphTaskElement | null>(null);
|
||||||
const changed = ref<boolean>(false);
|
const changed = ref<boolean>(false);
|
||||||
const scenariosCardRef = ref<InstanceType<typeof PlatformCard> | null>(null);
|
const scenariosCardRef = ref<InstanceType<typeof PlatformCard> | null>(null);
|
||||||
|
const currentScenarioId = ref<number | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleGraphEvent,
|
handleGraphEvent,
|
||||||
@@ -313,11 +314,7 @@ export default defineComponent({
|
|||||||
const node = args.node as Node<NodeProperties>;
|
const node = args.node as Node<NodeProperties>;
|
||||||
const element = node.getData() as GraphTaskElement;
|
const element = node.getData() as GraphTaskElement;
|
||||||
console.error('element',element)
|
console.error('element',element)
|
||||||
if(element && element.platformId ){
|
window.location.href = `/app/decision/designer?scenario=${currentScenario.value?.id}&platform=${element?.platformId?? ''}`
|
||||||
window.location.href = `/app/decision/designer?platform=${element.platformId}`
|
|
||||||
} else {
|
|
||||||
window.location.href = '/app/decision/designer'
|
|
||||||
}
|
|
||||||
|
|
||||||
// destroy()
|
// destroy()
|
||||||
// window.location.href = '/app/decision/designer'
|
// window.location.href = '/app/decision/designer'
|
||||||
@@ -358,6 +355,15 @@ export default defineComponent({
|
|||||||
initGraph();
|
initGraph();
|
||||||
window.addEventListener('resize', handleResize);
|
window.addEventListener('resize', handleResize);
|
||||||
console.log('节点挂载完成');
|
console.log('节点挂载完成');
|
||||||
|
|
||||||
|
let scenarioId = Number(currentRoute.query.scenario);
|
||||||
|
if (!isNaN(scenarioId)) {
|
||||||
|
findOneScenarioById(scenarioId).then(r=> {
|
||||||
|
if(r.data){
|
||||||
|
handleSelect(r.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<a-list :data-source="scenario || []" size="small" style="min-height: 25vh">
|
<a-list :data-source="scenario || []" size="small" style="min-height: 25vh">
|
||||||
<template #renderItem="{ item }">
|
<template #renderItem="{ item }">
|
||||||
<a-list-item>
|
<a-list-item @click="()=> handleSelect(item)">
|
||||||
<a-flex>
|
<a-flex>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip placement="bottom">
|
||||||
<template #title>
|
<template #title>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<span>{{ substring(item.name, 15) }}</span>
|
<span>{{ substring(item.name, 15) }}</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-flex class="ks-tree-actions">
|
<a-flex class="ks-tree-actions">
|
||||||
<span style="margin-right: 10px" @click="()=> handleSelect(item)"><EditFilled /></span>
|
<!-- <span style="margin-right: 10px" @click="()=> handleSelect(item)"><EditFilled /></span>-->
|
||||||
<!-- <a-popconfirm-->
|
<!-- <a-popconfirm-->
|
||||||
<!-- title="确定删除?"-->
|
<!-- title="确定删除?"-->
|
||||||
<!-- @confirm="()=> handleDelete(item)"-->
|
<!-- @confirm="()=> handleDelete(item)"-->
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import type { NullableString, PageableResponse } from '@/types';
|
import type { ApiDataResponse, NullableString, PageableResponse } from '@/types';
|
||||||
import type { GraphContainer } from '../graph';
|
import type { GraphContainer } from '../graph';
|
||||||
import type { Platform, PlatformComponent } from '../types';
|
import type { Platform, PlatformComponent } from '../types';
|
||||||
|
|
||||||
@@ -44,3 +44,7 @@ export interface ScenarioPageableResponse extends PageableResponse<Scenario> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ScenarioDetailsResponse extends ApiDataResponse<Scenario> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,11 @@
|
|||||||
<CheckOutlined />
|
<CheckOutlined />
|
||||||
<span>保存</span>
|
<span>保存</span>
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
||||||
|
<a-button v-if="currentScenarioId" class="ks-model-builder-save" size="small" @click="handleGoback">
|
||||||
|
<BackwardFilled />
|
||||||
|
<span>返回</span>
|
||||||
|
</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -56,7 +61,7 @@ import { useRoute } from 'vue-router';
|
|||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { getTeleport } from '@antv/x6-vue-shape';
|
import { getTeleport } from '@antv/x6-vue-shape';
|
||||||
import { Graph, Node, type NodeProperties } from '@antv/x6';
|
import { Graph, Node, type NodeProperties } from '@antv/x6';
|
||||||
import { CheckCircleOutlined, CheckOutlined, RollbackOutlined, SaveOutlined } from '@ant-design/icons-vue';
|
import { CheckCircleOutlined, CheckOutlined, RollbackOutlined, SaveOutlined, BackwardFilled } from '@ant-design/icons-vue';
|
||||||
import { Wrapper } from '@/components/wrapper';
|
import { Wrapper } from '@/components/wrapper';
|
||||||
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
|
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
|
||||||
import Header from '../header.vue';
|
import Header from '../header.vue';
|
||||||
@@ -69,7 +74,7 @@ import { createGraphTaskElement, createLineOptions, type GraphContainer, type Gr
|
|||||||
import { registerNodeElement } from './register';
|
import { registerNodeElement } from './register';
|
||||||
import { findAllBasicPlatforms } from '../api';
|
import { findAllBasicPlatforms } from '../api';
|
||||||
import type { Platform } from '../types';
|
import type { Platform } from '../types';
|
||||||
import { createTree, findOneTreeById, updateTree, findOneTreeByPlatformId } from './api';
|
import { createTree, findOneTreeById, findOneTreeByPlatformId, updateTree } from './api';
|
||||||
import TressCard from './trees-card.vue';
|
import TressCard from './trees-card.vue';
|
||||||
import NodesCard from './nodes-card.vue';
|
import NodesCard from './nodes-card.vue';
|
||||||
|
|
||||||
@@ -88,6 +93,7 @@ export default defineComponent({
|
|||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
CheckOutlined,
|
CheckOutlined,
|
||||||
RollbackOutlined,
|
RollbackOutlined,
|
||||||
|
BackwardFilled,
|
||||||
TeleportContainer,
|
TeleportContainer,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
@@ -105,6 +111,7 @@ export default defineComponent({
|
|||||||
const changed = ref<boolean>(false);
|
const changed = ref<boolean>(false);
|
||||||
const treesCardRef = ref<InstanceType<typeof TressCard> | null>(null);
|
const treesCardRef = ref<InstanceType<typeof TressCard> | null>(null);
|
||||||
const platforms = ref<Platform[]>([]);
|
const platforms = ref<Platform[]>([]);
|
||||||
|
const currentScenarioId = ref<number | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleGraphEvent,
|
handleGraphEvent,
|
||||||
@@ -335,6 +342,7 @@ export default defineComponent({
|
|||||||
handleGraphEvent('node:click', (args: any) => {
|
handleGraphEvent('node:click', (args: any) => {
|
||||||
const node = args.node as Node<NodeProperties>;
|
const node = args.node as Node<NodeProperties>;
|
||||||
const newElement = node.getData() as GraphTaskElement;
|
const newElement = node.getData() as GraphTaskElement;
|
||||||
|
console.error('ddd', args);
|
||||||
|
|
||||||
selectedModelNode.value = node;
|
selectedModelNode.value = node;
|
||||||
selectedNodeTaskElement.value = JSON.parse(JSON.stringify(newElement || {})) as GraphTaskElement;
|
selectedNodeTaskElement.value = JSON.parse(JSON.stringify(newElement || {})) as GraphTaskElement;
|
||||||
@@ -365,16 +373,24 @@ export default defineComponent({
|
|||||||
window.addEventListener('resize', handleResize);
|
window.addEventListener('resize', handleResize);
|
||||||
console.log('节点挂载完成');
|
console.log('节点挂载完成');
|
||||||
|
|
||||||
const platformId = currentRoute.query.platform;
|
let scenarioId = Number(currentRoute.query.scenario);
|
||||||
if (platformId) {
|
if (!isNaN(scenarioId)) {
|
||||||
const id = Number(platformId);
|
currentScenarioId.value = scenarioId;
|
||||||
if (!isNaN(id)) {
|
} else {
|
||||||
findOneTreeByPlatformId(id).then(r => {
|
currentScenarioId.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let platformId = Number(currentRoute.query.platform);
|
||||||
|
if (!isNaN(platformId)) {
|
||||||
|
findOneTreeByPlatformId(platformId).then(r => {
|
||||||
if (r.data) {
|
if (r.data) {
|
||||||
handleSelectTree(r.data);
|
handleSelectTree(r.data);
|
||||||
|
} else {
|
||||||
|
handleCreateTree();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
|
handleCreateTree();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -390,6 +406,10 @@ export default defineComponent({
|
|||||||
changed.value = true;
|
changed.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleGoback = ()=> {
|
||||||
|
window.location.href = `/app/decision/communication?scenario=${currentScenarioId.value}`
|
||||||
|
}
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
const graphData: GraphContainer = resolveGraph(graph.value as Graph);
|
const graphData: GraphContainer = resolveGraph(graph.value as Graph);
|
||||||
console.info('handleSave', graphData);
|
console.info('handleSave', graphData);
|
||||||
@@ -436,6 +456,7 @@ export default defineComponent({
|
|||||||
onBeforeUnmount(() => destroy());
|
onBeforeUnmount(() => destroy());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
currentScenarioId,
|
||||||
platforms,
|
platforms,
|
||||||
treesCardRef,
|
treesCardRef,
|
||||||
handleCreateTree,
|
handleCreateTree,
|
||||||
@@ -459,6 +480,7 @@ export default defineComponent({
|
|||||||
handleSave,
|
handleSave,
|
||||||
handleUpdateElement,
|
handleUpdateElement,
|
||||||
handleSelectTree,
|
handleSelectTree,
|
||||||
|
handleGoback,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user