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