UPDATE: VERSION-20260315
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { HttpRequestClient } from '@/utils/request';
|
||||
import type { PlatformWithComponentsResponse, ScenarioPageableResponse, ScenarioRequest } from './types';
|
||||
import type { PlatformWithComponentsResponse, ScenarioPageableResponse, ScenarioRequest, Scenario } from './types';
|
||||
import type { BasicResponse } from '@/types';
|
||||
|
||||
const req = HttpRequestClient.create<BasicResponse>({
|
||||
@@ -24,5 +24,9 @@ export const deleteOneScenarioById = (id: number): Promise<BasicResponse> => {
|
||||
};
|
||||
|
||||
export const findPlatformWithComponents = (id: number): Promise<PlatformWithComponentsResponse> => {
|
||||
return req.get(`system/firerule/platforms/${id}`);
|
||||
return req.get(`/system/firerule/platforms/${id}`);
|
||||
};
|
||||
|
||||
export const saveScenario = (scenario: Scenario): Promise<BasicResponse> => {
|
||||
return req.get(`/system/scene/saveSceneConfig`,scenario);
|
||||
};
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="ks-model-builder-body">
|
||||
<div class="ks-model-builder-left">
|
||||
<PlatformCard
|
||||
ref="treesCardRef"
|
||||
ref="scenariosCardRef"
|
||||
@create="handleCreate"
|
||||
@select="handleSelect"
|
||||
/>
|
||||
@@ -52,21 +52,19 @@ import { Wrapper } from '@/components/wrapper';
|
||||
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
|
||||
import Header from '../header.vue';
|
||||
|
||||
import type { Scenario } from './types';
|
||||
import { createLineOptions } from '../builder/line';
|
||||
import type { GraphTaskElement, NodeGraph } from '../builder/element';
|
||||
import { useGraphCanvas } from '../builder/hooks';
|
||||
import { registerNodeElement } from '../builder/register';
|
||||
import { createTree, findOneTreeById, updateTree } from '../designer/api';
|
||||
import { createGraphTaskElement, hasElements, hasRootElementNode, resolveNodeGraph } from '../builder/utils';
|
||||
import { createGraphTaskElementFromTemplate } from '../utils/node';
|
||||
import type { PlatformWithComponents, Scenario } from './types';
|
||||
import { createGraphTaskElement, createLineOptions, type GraphContainer, type GraphTaskElement, hasElements, hasRootElementNode, resolveGraph, useGraphCanvas } from '../graph';
|
||||
|
||||
import { registerScenarioElement } from './register';
|
||||
import { createGraphTaskElementFromScenario } from './utils';
|
||||
|
||||
import PlatformCard from './platform-card.vue';
|
||||
import NodesCard from './nodes-card.vue';
|
||||
import { saveScenario } from '@/views/decision/communication/api.ts';
|
||||
|
||||
const TeleportContainer = defineComponent(getTeleport());
|
||||
|
||||
registerNodeElement();
|
||||
registerScenarioElement();
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -84,15 +82,15 @@ export default defineComponent({
|
||||
const canvas = ref<HTMLDivElement | null>(null);
|
||||
const graph = ref<Graph | null>(null);
|
||||
const currentZoom = ref<number>(1);
|
||||
const draggedNodeData = ref<Scenario | null>(null);
|
||||
const draggedNodeData = ref<PlatformWithComponents | null>(null);
|
||||
const isDraggingOver = ref(false);
|
||||
const currentTreeEditing = ref<boolean>(false);
|
||||
const currentScenarioEditing = ref<boolean>(false);
|
||||
const currentScenario = ref<Scenario | null>(null);
|
||||
const currentNodeGraph = ref<NodeGraph | null>(null);
|
||||
const currentGraph = ref<GraphContainer | null>(null);
|
||||
const selectedModelNode = ref<Node<NodeProperties> | null>(null);
|
||||
const selectedNodeTaskElement = ref<GraphTaskElement | null>(null);
|
||||
const changed = ref<boolean>(false);
|
||||
const treesCardRef = ref<InstanceType<typeof PlatformCard> | null>(null);
|
||||
const scenariosCardRef = ref<InstanceType<typeof PlatformCard> | null>(null);
|
||||
|
||||
const {
|
||||
handleGraphEvent,
|
||||
@@ -105,7 +103,7 @@ export default defineComponent({
|
||||
} = useGraphCanvas();
|
||||
|
||||
// 处理拖动开始
|
||||
const handleDragStart = (nm: Scenario) => {
|
||||
const handleDragStart = (nm: PlatformWithComponents) => {
|
||||
draggedNodeData.value = nm;
|
||||
};
|
||||
|
||||
@@ -142,10 +140,10 @@ export default defineComponent({
|
||||
safePreventDefault(e);
|
||||
safeStopPropagation(e);
|
||||
isDraggingOver.value = false;
|
||||
currentTreeEditing.value = false;
|
||||
currentScenarioEditing.value = false;
|
||||
|
||||
if (!currentScenario.value) {
|
||||
message.error('请先选择或者创建行为树.');
|
||||
message.error('请先选择或者创建场景.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,17 +154,17 @@ export default defineComponent({
|
||||
|
||||
try {
|
||||
// 获取拖动的数据
|
||||
const template = draggedNodeData.value as Scenario;
|
||||
const pwc = draggedNodeData.value as PlatformWithComponents;
|
||||
|
||||
if (!hasElements(graph.value as Graph)) {
|
||||
message.error('请先添加根节点.');
|
||||
return;
|
||||
}
|
||||
// if (!hasElements(graph.value as Graph)) {
|
||||
// message.error('请先添加根节点.');
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (hasRootElementNode(graph.value as Graph)) {
|
||||
message.error('根节点已经存在.');
|
||||
return;
|
||||
}
|
||||
// if (hasRootElementNode(graph.value as Graph)) {
|
||||
// message.error('根节点已经存在.');
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 计算相对于画布的位置(考虑缩放)
|
||||
const rect = canvas.value.getBoundingClientRect();
|
||||
@@ -174,12 +172,12 @@ export default defineComponent({
|
||||
const x = (e.clientX - rect.left) / scale;
|
||||
const y = (e.clientY - rect.top) / scale;
|
||||
|
||||
console.log('放置节点:', { ...template, x, y });
|
||||
console.log('放置节点:', { ...pwc, x, y });
|
||||
|
||||
// 创建节点数据
|
||||
const settingTaskElement: GraphTaskElement = createGraphTaskElementFromTemplate(template, { x, y });
|
||||
const settingTaskElement: GraphTaskElement = createGraphTaskElementFromScenario(pwc, { x, y });
|
||||
// 创建节点
|
||||
const settingTaskNode = createGraphTaskElement(settingTaskElement);
|
||||
const settingTaskNode = createGraphTaskElement(settingTaskElement, 250, 120, 'scenario');
|
||||
console.info('create settingTaskNode: ', settingTaskElement, settingTaskNode);
|
||||
|
||||
// 将节点添加到画布
|
||||
@@ -193,32 +191,27 @@ export default defineComponent({
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelect = (tree: Scenario) => {
|
||||
console.info('handleSelect', tree);
|
||||
findOneTreeById(tree.id).then(r => {
|
||||
if (r.data) {
|
||||
let nodeGraph: NodeGraph | null = null;
|
||||
try {
|
||||
nodeGraph = JSON.parse(r.data?.xmlContent as unknown as string) as unknown as NodeGraph;
|
||||
} catch (e: any) {
|
||||
console.error('parse error,cause:', e);
|
||||
}
|
||||
if (!nodeGraph) {
|
||||
nodeGraph = {
|
||||
nodes: [],
|
||||
edges: [],
|
||||
};
|
||||
}
|
||||
currentScenario.value = {
|
||||
...r.data,
|
||||
graph: nodeGraph,
|
||||
};
|
||||
currentTreeEditing.value = true;
|
||||
createElements();
|
||||
} else {
|
||||
message.error(r.msg ?? '行为树不存在.');
|
||||
}
|
||||
});
|
||||
const handleSelect = (scenario: Scenario) => {
|
||||
console.info('handleSelect', scenario);
|
||||
let nodeGraph: GraphContainer | null = null;
|
||||
try {
|
||||
nodeGraph = JSON.parse(scenario.communicationGraph as unknown as string) as unknown as GraphContainer;
|
||||
} catch (e: any) {
|
||||
console.error('parse error,cause:', e);
|
||||
}
|
||||
if (!nodeGraph) {
|
||||
nodeGraph = {
|
||||
nodes: [],
|
||||
edges: [],
|
||||
};
|
||||
}
|
||||
currentScenario.value = {
|
||||
...scenario,
|
||||
graph: nodeGraph,
|
||||
};
|
||||
currentScenarioEditing.value = true;
|
||||
createElements();
|
||||
|
||||
};
|
||||
|
||||
const createElements = () => {
|
||||
@@ -257,18 +250,15 @@ export default defineComponent({
|
||||
const handleCreate = () => {
|
||||
currentScenario.value = {
|
||||
id: 0,
|
||||
name: '行为树',
|
||||
name: null,
|
||||
description: null,
|
||||
englishName: null,
|
||||
xmlContent: null,
|
||||
createdAt: null,
|
||||
communicationGraph: null,
|
||||
graph: {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
},
|
||||
updatedAt: null,
|
||||
}
|
||||
};
|
||||
currentNodeGraph.value = {
|
||||
currentGraph.value = {
|
||||
edges: [],
|
||||
nodes: [],
|
||||
};
|
||||
@@ -298,7 +288,7 @@ export default defineComponent({
|
||||
handleGraphEvent('blank:click', () => {
|
||||
selectedModelNode.value = null;
|
||||
selectedNodeTaskElement.value = null;
|
||||
currentTreeEditing.value = null !== currentScenario.value;
|
||||
currentScenarioEditing.value = null !== currentScenario.value;
|
||||
});
|
||||
|
||||
handleGraphEvent('node:click', (args: any) => {
|
||||
@@ -348,34 +338,30 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
const graphData: NodeGraph = resolveNodeGraph(graph.value as Graph);
|
||||
const graphData: GraphContainer = resolveGraph(graph.value as Graph);
|
||||
console.info('handleSave', graphData);
|
||||
if (!currentScenario.value) {
|
||||
message.error('当前决策树不存在');
|
||||
return;
|
||||
}
|
||||
const newTree: currentScenario = {
|
||||
const newScenario: Scenario = {
|
||||
...currentScenario.value,
|
||||
graph: graphData,
|
||||
xmlContent: JSON.stringify(graphData),
|
||||
communicationGraph: JSON.stringify(graphData),
|
||||
};
|
||||
if (!newTree.name) {
|
||||
message.error('行为树名称不能为空.');
|
||||
return;
|
||||
}
|
||||
if (!newTree.englishName) {
|
||||
message.error('行为树英文名称不能为空.');
|
||||
if (!newScenario.name) {
|
||||
message.error('场景名称不能为空.');
|
||||
return;
|
||||
}
|
||||
let res = null;
|
||||
if (currentScenario.value.id > 0) {
|
||||
res = createTree(newTree);
|
||||
res = saveScenario(newScenario);
|
||||
} else {
|
||||
res = updateTree(newTree);
|
||||
res = saveScenario(newScenario);
|
||||
}
|
||||
res.then(r => {
|
||||
if (r.code === 200) {
|
||||
treesCardRef.value?.refresh();
|
||||
scenariosCardRef.value?.refresh();
|
||||
message.success(r.msg ?? '操作成功.');
|
||||
} else {
|
||||
message.error(r.msg ?? '操作失败.');
|
||||
@@ -403,11 +389,11 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
return {
|
||||
treesCardRef,
|
||||
scenariosCardRef,
|
||||
handleCreate,
|
||||
currentTreeEditing,
|
||||
currentScenarioEditing,
|
||||
currentScenario,
|
||||
currentNodeGraph,
|
||||
currentGraph,
|
||||
selectedNodeTaskElement,
|
||||
selectedModelNode,
|
||||
graph,
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* This file is part of the kernelstudio package.
|
||||
*
|
||||
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
* that was distributed with this source code.
|
||||
*/
|
||||
427
modeler/src/views/decision/communication/node.vue
Normal file
427
modeler/src/views/decision/communication/node.vue
Normal file
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<a-dropdown :trigger="['contextmenu']" @openChange="handleVisibleChange">
|
||||
<a-card
|
||||
:class="[
|
||||
'ks-scenario-node',
|
||||
`ks-scenario-${element?.category ?? 'model'}-node`,
|
||||
`ks-scenario-group-${element?.group ?? 'general'}`
|
||||
]"
|
||||
hoverable
|
||||
>
|
||||
<template #title>
|
||||
<a-space>
|
||||
<span class="ks-scenario-node-title">{{ element?.name ?? '-' }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<div class="port port-in" data-port="in-0" magnet="passive">
|
||||
<div class="triangle-left"></div>
|
||||
</div>
|
||||
<div class="w-full ks-scenario-node-text">
|
||||
<a-tooltip >
|
||||
<template #title>
|
||||
{{ element?.description ?? element?.name }}
|
||||
</template>
|
||||
<p class="ks-scenario-node-label">
|
||||
{{ substring(element?.name ?? (element?.name ?? '-'), 40) }}
|
||||
</p>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<div class="port port-out" data-port="out-0" magnet="active">
|
||||
<div class="triangle-right" ></div>
|
||||
</div>
|
||||
</a-card>
|
||||
|
||||
<template #overlay>
|
||||
<a-menu @click="handleMenuClick">
|
||||
<a-menu-item key="delete">
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { elementProps, type ModelElement } from '../graph';
|
||||
|
||||
import { DeleteOutlined, SettingOutlined } from '@ant-design/icons-vue';
|
||||
import type { Graph } from '@antv/x6';
|
||||
import { substring } from '@/utils/strings';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelElement',
|
||||
components: {
|
||||
SettingOutlined,
|
||||
DeleteOutlined,
|
||||
},
|
||||
props: elementProps,
|
||||
setup(_props) {
|
||||
const element = ref<ModelElement | null>(
|
||||
_props.node ? (_props.node.getData() as ModelElement) : null,
|
||||
);
|
||||
const updateKey = ref(0);
|
||||
const isMenuVisible = ref(false);
|
||||
|
||||
// 获取画布实例
|
||||
const getGraph = (): Graph | null => {
|
||||
return _props.graph as Graph || null;
|
||||
};
|
||||
|
||||
// 监听节点数据变化
|
||||
const handleDataChange = () => {
|
||||
if (_props.node) {
|
||||
element.value = _props.node.getData() as ModelElement;
|
||||
} else {
|
||||
element.value = null;
|
||||
}
|
||||
updateKey.value++;
|
||||
};
|
||||
|
||||
const handleVisibleChange = (visible: boolean) => {
|
||||
isMenuVisible.value = visible;
|
||||
};
|
||||
|
||||
const handleMenuClick = ({ key }: { key: string }) => {
|
||||
if (key === 'delete') {
|
||||
handleDelete();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
if (!_props.node) return;
|
||||
|
||||
const graph = getGraph();
|
||||
if (graph) {
|
||||
try {
|
||||
// 先删除关联边
|
||||
const connectedEdges = graph.getConnectedEdges(_props.node);
|
||||
connectedEdges.forEach(edge => graph.removeEdge(edge));
|
||||
// 再删除节点
|
||||
graph.removeNode(_props.node);
|
||||
console.info(`节点 ${_props.node.id} 已删除`);
|
||||
} catch (error) {
|
||||
console.error('删除节点失败:', error);
|
||||
}
|
||||
}
|
||||
isMenuVisible.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
_props.node?.on('change:data', handleDataChange);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
_props.node?.off('change:data', handleDataChange);
|
||||
});
|
||||
|
||||
return {
|
||||
element,
|
||||
substring,
|
||||
handleMenuClick,
|
||||
handleVisibleChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.ks-scenario-node {
|
||||
background: linear-gradient(150deg, rgba(108, 99, 255) 1%, rgba(108, 99, 255) 100%);
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
background: #1e2533;
|
||||
border: 1px solid #4a7aff;
|
||||
|
||||
border: 2px solid #000000;
|
||||
|
||||
&:hover {
|
||||
border: 2px solid #4a7aff;
|
||||
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
|
||||
}
|
||||
|
||||
.ant-card-head {
|
||||
border: 0;
|
||||
height: 28px;
|
||||
min-height: 25px;
|
||||
border-radius: 0;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
padding: 0 20px;
|
||||
//background: linear-gradient(to bottom, #3a4c70, #2d3a56);
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
background: linear-gradient(to bottom, rgba(108, 99, 255, 0.15), rgba(108, 99, 255, 0.05));
|
||||
//background: url('@/assets/icons/bg-node-head.png') center / 100% 100%;
|
||||
//background: linear-gradient(to bottom, rgb(234 234 234 / 20%), rgb(191 191 191 / 58%));
|
||||
}
|
||||
|
||||
.ks-scenario-node-icon {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
top: 6px;
|
||||
background: url('@/assets/icons/icon-node.svg') center / 100% 100%;
|
||||
}
|
||||
|
||||
.ks-scenario-node-title {
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
margin-top: -7px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ant-card-body {
|
||||
color: #f5f5f5;
|
||||
height: calc(100% - 25px);
|
||||
border-radius: 0;
|
||||
font-size: 12px;
|
||||
padding: 10px 30px !important;
|
||||
//border-top: 1px solid rgba(108, 99, 255, 0.5);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
|
||||
|
||||
white-space: normal; // 恢复默认的换行行为
|
||||
word-wrap: break-word; // 允许长单词换行
|
||||
word-break: break-all; // 允许在任意字符处换行
|
||||
line-height: 1.4; // 增加行高提升可读性
|
||||
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
|
||||
}
|
||||
|
||||
|
||||
// 连接桩容器样式
|
||||
.ks-scenario-node-content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ks-scenario-node-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.port {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
cursor: crosshair;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 0 0 2px rgb(108, 99, 255, 0.8);
|
||||
z-index: 10;
|
||||
magnet: true;
|
||||
position: relative;
|
||||
|
||||
.triangle-left {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 4px solid transparent;
|
||||
border-right: 5px solid #5da1df;
|
||||
border-bottom: 4px solid transparent;
|
||||
position: absolute;
|
||||
left: -8px;
|
||||
top: 0.5px;
|
||||
magnet: passive;
|
||||
}
|
||||
|
||||
/* 右三角形 */
|
||||
.triangle-right {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 4px solid transparent;
|
||||
border-left: 5px solid #5da1df;
|
||||
border-bottom: 4px solid transparent;
|
||||
position: absolute;
|
||||
right: -8px;
|
||||
top: 0.5px;
|
||||
magnet: passive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 左侧入桩样式
|
||||
.port-in {
|
||||
//background-color: #3c82f6;
|
||||
margin-right: 8px;
|
||||
//border: 1px solid #093866;
|
||||
magnet: passive;
|
||||
box-shadow: none;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
display: block;
|
||||
//background: url('@/assets/icons/point.svg') center / 100% 100%;
|
||||
border: 2px solid #5da1df;
|
||||
|
||||
position: absolute;
|
||||
//top: 7px;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.port-out {
|
||||
margin-left: 8px;
|
||||
margin-right: 5px;
|
||||
magnet: active;
|
||||
box-shadow: none;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
display: block;
|
||||
//background: url('@/assets/icons/point.svg') center / 100% 100%;
|
||||
border: 2px solid #5da1df;
|
||||
background:#5da1df;
|
||||
|
||||
position: absolute;
|
||||
//right: 8px;
|
||||
//top: 7px;
|
||||
top: 50%;
|
||||
right: 6px;
|
||||
|
||||
}
|
||||
|
||||
// 节点文本样式
|
||||
.ks-scenario-node-name {
|
||||
flex: 1;
|
||||
line-height: 24px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
//white-space: nowrap;
|
||||
}
|
||||
|
||||
&.ks-scenario-root-node{
|
||||
.ks-scenario-node-icon {
|
||||
background: url('@/assets/icons/icon-root.svg') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-action-node{
|
||||
.ant-card-head {
|
||||
background: url('@/assets/icons/card-head-red.png') center / 100% 100%;
|
||||
}
|
||||
.ks-scenario-node-icon {
|
||||
background: url('@/assets/icons/icon-action.svg') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-sequence-node{
|
||||
.ks-scenario-node-icon {
|
||||
background: url('@/assets/icons/icon-sequence.svg') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-parallel-node{
|
||||
.ks-scenario-node-icon {
|
||||
background: url('@/assets/icons/icon-parallel.svg') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-precondition-node{
|
||||
.ks-scenario-node-icon {
|
||||
background: url('@/assets/icons/icon-branch.svg') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-group-control,
|
||||
&.ks-scenario-group-condition {
|
||||
.ant-card-head{
|
||||
display:none;
|
||||
}
|
||||
.ant-card-body {
|
||||
height: calc(100%);
|
||||
border-radius: 8px;
|
||||
background: url('@/assets/icons/card-head-gray.png') center / 100% 100%;
|
||||
}
|
||||
|
||||
&.ks-scenario-root-node{
|
||||
.ant-card-body {
|
||||
background: url('@/assets/icons/card-head-dark.png') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
&.ks-scenario-sequence-node{
|
||||
.ant-card-body {
|
||||
background: url('@/assets/icons/card-head-green.png') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-parallel-node{
|
||||
.ant-card-body {
|
||||
background: url('@/assets/icons/card-head-blue.png') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.ks-scenario-precondition-node{
|
||||
.ant-card-body {
|
||||
background: url('@/assets/icons/card-head-dark.png') center / 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.port-in,
|
||||
.port-out {
|
||||
top: 40%;
|
||||
}
|
||||
.ks-scenario-node-text{
|
||||
line-height: 38px;
|
||||
}
|
||||
}
|
||||
|
||||
//&.ks-scenario-precondition-node{
|
||||
// border:0;
|
||||
// box-shadown:none;
|
||||
// &:hover{
|
||||
// border:0;
|
||||
// box-shadown:none;
|
||||
// }
|
||||
// background: url('@/assets/icons/lx.svg') center / 100% 100%;
|
||||
// //transform: rotate(45deg);
|
||||
// .ant-card-body {
|
||||
// border: 0;
|
||||
// box-shadow: none;
|
||||
// height: 95px;
|
||||
// line-height: 80px;
|
||||
// font-size: 10px;
|
||||
// padding: 0 !important;
|
||||
// }
|
||||
// .ant-card-head {
|
||||
// display: none;
|
||||
// }
|
||||
//
|
||||
// .ks-scenario-node-label {
|
||||
// width: 40px; /* 保留原有宽度 */
|
||||
// text-align: center; /* 保留文字居中 */
|
||||
// /* 核心修改:取消固定行高,重置换行相关属性 */
|
||||
// word-wrap: break-word;/* 强制换行(兼容老旧浏览器) */
|
||||
// word-break: break-all;/* 截断长单词/字符,确保在40px内换行 */
|
||||
// white-space: normal; /* 恢复默认换行规则(避免文字不换行) */
|
||||
// /* 可选:添加行间距,提升多行可读性 */
|
||||
// line-height: 1.4; /* 多行时的行间距,可根据需求调整 */
|
||||
// padding: 10px 0; /* 上下内边距,替代原有line-height:98px的垂直居中效果 */
|
||||
// margin: 31% auto;
|
||||
// }
|
||||
//
|
||||
// .port-in {
|
||||
// left: 12px;
|
||||
// top: 42px;
|
||||
// }
|
||||
//
|
||||
// .port-out {
|
||||
// right: 6px;
|
||||
// top: 42px;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
</style>
|
||||
49
modeler/src/views/decision/communication/register.ts
Normal file
49
modeler/src/views/decision/communication/register.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the kernelstudio package.
|
||||
*
|
||||
* (c) 2014-2025 zlin <admin@kernelstudio.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
* that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the kernelstudio package.
|
||||
*
|
||||
* (c) 2014-2025 zlin <admin@kernelstudio.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
* that was distributed with this source code.
|
||||
*/
|
||||
import { register } from '@antv/x6-vue-shape';
|
||||
import ModelElement from './node.vue';
|
||||
|
||||
export const registerScenarioElement = () => {
|
||||
console.info('registerScenarioElement');
|
||||
register({
|
||||
shape: 'scenario',
|
||||
component: ModelElement,
|
||||
width: 120,
|
||||
attrs: {
|
||||
body: {
|
||||
stroke: 'transparent',
|
||||
strokeWidth: 0,
|
||||
fill: 'transparent',
|
||||
rx: 4,
|
||||
ry: 4,
|
||||
},
|
||||
},
|
||||
dragging: {
|
||||
enabled: true,
|
||||
},
|
||||
// 配置端口识别规则,
|
||||
portMarkup: [
|
||||
{
|
||||
tagName: 'div',
|
||||
selector: 'port-body',
|
||||
},
|
||||
],
|
||||
// 告诉 X6 如何识别 Vue 组件内的端口
|
||||
portAttribute: 'data-port',
|
||||
});
|
||||
};
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
|
||||
import type { ApiDataResponse, NullableString, PageableResponse } from '@/types';
|
||||
import type { GraphContainer } from '../graph';
|
||||
|
||||
export interface Scenario {
|
||||
id: number,
|
||||
@@ -16,6 +17,7 @@ export interface Scenario {
|
||||
description: NullableString,
|
||||
// 用于存储场景中的通讯关系
|
||||
communicationGraph: NullableString,
|
||||
graph: GraphContainer
|
||||
}
|
||||
|
||||
export interface ScenarioRequest extends Scenario {
|
||||
|
||||
42
modeler/src/views/decision/communication/utils.ts
Normal file
42
modeler/src/views/decision/communication/utils.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the kernelstudio package.
|
||||
*
|
||||
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
* that was distributed with this source code.
|
||||
*/
|
||||
|
||||
import type { GraphRect, GraphTaskElement } from '../graph';
|
||||
import { generateKey } from '@/utils/strings';
|
||||
import type { PlatformWithComponents } from './types';
|
||||
|
||||
export const createGraphTaskElementFromScenario = (
|
||||
platform: PlatformWithComponents,
|
||||
rect?: GraphRect,
|
||||
): GraphTaskElement => {
|
||||
let realRect = { width: 120, height: 80, x: 0, y: 0, ...rect || {} };
|
||||
console.info('rect', rect);
|
||||
return {
|
||||
id: 0,
|
||||
key: generateKey(),
|
||||
type: 'scenario',
|
||||
template: platform.id,
|
||||
templateType: null,
|
||||
name: null,
|
||||
category: null,
|
||||
group: null,
|
||||
description: platform.description,
|
||||
order: 0,
|
||||
position: {
|
||||
x: realRect.x ?? 0,
|
||||
y: realRect.y ?? 0,
|
||||
},
|
||||
width: realRect.width,
|
||||
height: realRect.height,
|
||||
inputs: null,
|
||||
outputs: null,
|
||||
parameters: [],
|
||||
variables: [],
|
||||
} as GraphTaskElement;
|
||||
};
|
||||
Reference in New Issue
Block a user