UPDATE: VERSION-20260326
This commit is contained in:
21
modeler/src/views/decision/api.ts
Normal file
21
modeler/src/views/decision/api.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 { HttpRequestClient } from '@/utils/request';
|
||||
import type { BasicResponse } from '@/types';
|
||||
import type { PlatformListableResponse } from './types';
|
||||
|
||||
const req = HttpRequestClient.create<BasicResponse>({
|
||||
baseURL: '/api',
|
||||
});
|
||||
|
||||
|
||||
export const findAllBasicPlatforms = (): Promise<PlatformListableResponse> => {
|
||||
return req.get<PlatformListableResponse>('/system/firerule/platforms/basic');
|
||||
};
|
||||
@@ -37,6 +37,7 @@
|
||||
</div>
|
||||
<Properties
|
||||
v-if="graph"
|
||||
:platforms="platforms"
|
||||
:element="selectedNodeTaskElement"
|
||||
:graph="graph as any"
|
||||
:node="selectedModelNode as any"
|
||||
@@ -65,7 +66,8 @@ import { createGraphTaskElementFromTemplate } from './utils';
|
||||
|
||||
import { createGraphTaskElement, createLineOptions, type GraphContainer, type GraphTaskElement, hasElements, hasRootElementNode, resolveGraph, useGraphCanvas } from '../graph';
|
||||
import { registerNodeElement } from './register';
|
||||
|
||||
import { findAllBasicPlatforms } from '../api';
|
||||
import type { Platform } from '../types';
|
||||
import { createTree, findOneTreeById, updateTree } from './api';
|
||||
import TressCard from './trees-card.vue';
|
||||
import NodesCard from './nodes-card.vue';
|
||||
@@ -100,6 +102,7 @@ export default defineComponent({
|
||||
const selectedNodeTaskElement = ref<GraphTaskElement | null>(null);
|
||||
const changed = ref<boolean>(false);
|
||||
const treesCardRef = ref<InstanceType<typeof TressCard> | null>(null);
|
||||
const platforms = ref<Platform[]>([]);
|
||||
|
||||
const {
|
||||
handleGraphEvent,
|
||||
@@ -111,6 +114,13 @@ export default defineComponent({
|
||||
resizeCanvas,
|
||||
} = useGraphCanvas();
|
||||
|
||||
const loadPlatforms = () => {
|
||||
platforms.value = [];
|
||||
findAllBasicPlatforms().then(r => {
|
||||
platforms.value = r.data ?? [];
|
||||
});
|
||||
};
|
||||
|
||||
// 处理拖动开始
|
||||
const handleDragStart = (nm: NodeDragTemplate) => {
|
||||
draggedNodeData.value = nm;
|
||||
@@ -393,6 +403,7 @@ export default defineComponent({
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
init();
|
||||
loadPlatforms();
|
||||
});
|
||||
|
||||
// 清理
|
||||
@@ -410,6 +421,7 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
return {
|
||||
platforms,
|
||||
treesCardRef,
|
||||
handleCreateTree,
|
||||
currentTreeEditing,
|
||||
|
||||
@@ -103,9 +103,16 @@
|
||||
@edit="onEditParameterTab">
|
||||
<a-tab-pane v-for="(grouped,index) in groupedParameters" :key="index" :tab="`平台 ${index + 1}`" :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"
|
||||
<a-input-number v-if="setting.dataType === 'double'"
|
||||
v-model:value="setting.defaultValue"
|
||||
:placeholder="setting.description" size="small" style="width:100%;" />
|
||||
<a-input v-else v-model:value="setting.defaultValue" :placeholder="setting.description" size="small" />
|
||||
<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.id">{{pl.description}}</a-select-option>
|
||||
</a-select>
|
||||
<a-input v-else v-model:value="setting.defaultValue"
|
||||
:placeholder="setting.description" size="small" />
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
<!-- <template #leftExtra>-->
|
||||
@@ -154,6 +161,7 @@ import type { ElementParameter, ElementVariable, GraphTaskElement } from '../gra
|
||||
import type { BehaviorTree } from './tree';
|
||||
import type { Graph, Node, NodeProperties } from '@antv/x6';
|
||||
import { generateKey } from '@/utils/strings';
|
||||
import type { Platform } from '@/views/decision/types';
|
||||
|
||||
const actionSpaceColumns = [
|
||||
{ title: '序号', dataIndex: 'index', key: 'index', width: 40 },
|
||||
@@ -170,9 +178,12 @@ export default defineComponent({
|
||||
treeEditing: { type: Boolean as PropType<boolean>, required: true, default: false },
|
||||
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 },
|
||||
},
|
||||
emits: ['update-element', 'update-tree'],
|
||||
setup(props, { emit }) {
|
||||
const platforms = ref<Platform[]>(props.platforms ?? []);
|
||||
|
||||
const activeTopTabsKey = ref<string>('1');
|
||||
const activeBottomTabsKey = ref<string>('1');
|
||||
const activeBottomTabs2Key = ref<string>('1');
|
||||
@@ -187,6 +198,8 @@ export default defineComponent({
|
||||
const multiableParameters = ref<boolean>(false);
|
||||
const groupedParametersActiveTab = ref<number>(0);
|
||||
|
||||
console.error(platforms.value)
|
||||
|
||||
const createEmptyParameters = (): ElementParameter[] => {
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(currentElement.value?.parameters ?? [])) as ElementParameter[];
|
||||
@@ -359,9 +372,12 @@ export default defineComponent({
|
||||
|
||||
watch(() => currentElement.value, () => updateNode(), { deep: true });
|
||||
|
||||
watch(() => props.platforms, (n: Platform[] | null | undefined) => platforms.value = n ?? [], { deep: true, immediate: true });
|
||||
|
||||
onMounted(() => load());
|
||||
|
||||
return {
|
||||
platforms,
|
||||
addParameterTab,
|
||||
groupedParametersActiveTab,
|
||||
multiableParameters,
|
||||
|
||||
@@ -18,6 +18,10 @@ export interface Platform {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface PlatformListableResponse extends ApiDataResponse<Platform[]> {
|
||||
|
||||
}
|
||||
|
||||
export interface PlatformComponent {
|
||||
id: number,
|
||||
name: NullableString,
|
||||
|
||||
Reference in New Issue
Block a user