From c17197d6e59d9b6322935beda72e34c0dac8ca75 Mon Sep 17 00:00:00 2001 From: libertyspy Date: Mon, 16 Mar 2026 15:48:23 +0800 Subject: [PATCH 01/29] UPDATE: VERSION-20260316 --- auto-solution-scene/pom.xml | 6 + .../scene/controller/SceneController.java | 3 +- .../scene/domain/AfsimScenarioForm.java | 25 ++++ .../scene/domain/ScenarioRelation.java | 108 ++++++++++++++++++ .../solution/scene/mapper/SceneMapper.java | 5 +- .../solution/scene/service/SceneService.java | 7 +- .../scene/service/impl/SceneServiceImpl.java | 7 +- 7 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java create mode 100644 auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java diff --git a/auto-solution-scene/pom.xml b/auto-solution-scene/pom.xml index d494b0d..842a4ce 100644 --- a/auto-solution-scene/pom.xml +++ b/auto-solution-scene/pom.xml @@ -18,6 +18,12 @@ + + + com.solution + solution-rule + + com.solution diff --git a/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java b/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java index a255588..5825964 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/controller/SceneController.java @@ -6,6 +6,7 @@ import com.solution.common.core.domain.AjaxResult; import com.solution.common.core.page.TableDataInfo; import com.solution.common.enums.BusinessType; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import com.solution.scene.service.SceneService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,7 +33,7 @@ public class SceneController extends BaseController { @ApiOperation("保存场景配置") @PostMapping("/saveSceneConfig") @Log(title = "行为树主", businessType = BusinessType.INSERT) - public AjaxResult saveSceneConfig(@RequestBody AfsimScenario afsimScenario) + public AjaxResult saveSceneConfig(@RequestBody AfsimScenarioForm afsimScenario) { return toAjax(sceneService.saveOrUpdate(afsimScenario)); } diff --git a/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java new file mode 100644 index 0000000..5d96fd5 --- /dev/null +++ b/auto-solution-scene/src/main/java/com/solution/scene/domain/AfsimScenarioForm.java @@ -0,0 +1,25 @@ +package com.solution.scene.domain; +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import java.util.List; + +public class AfsimScenarioForm extends AfsimScenario { + + private List relations; + + public List getRelations() { + return relations; + } + + public void setRelations(List relations) { + this.relations = relations; + } + +} diff --git a/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java b/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java new file mode 100644 index 0000000..cd1ddb0 --- /dev/null +++ b/auto-solution-scene/src/main/java/com/solution/scene/domain/ScenarioRelation.java @@ -0,0 +1,108 @@ +package com.solution.scene.domain; +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import com.solution.rule.domain.Platform; +import com.solution.rule.domain.PlatformComponent; + +import java.io.Serializable; + +public class ScenarioRelation implements Serializable { + + private String edgeId; + + private String sourceId; + + private String sourcePort; + + private Platform sourcePlatform; + + private PlatformComponent sourceComponent; + + private String targetId; + + private String targetPort; + + private Platform targetPlatform; + + private PlatformComponent targetComponent; + + public String getEdgeId() { + return edgeId; + } + + public void setEdgeId(String edgeId) { + this.edgeId = edgeId; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourcePort() { + return sourcePort; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public Platform getSourcePlatform() { + return sourcePlatform; + } + + public void setSourcePlatform(Platform sourcePlatform) { + this.sourcePlatform = sourcePlatform; + } + + public PlatformComponent getSourceComponent() { + return sourceComponent; + } + + public void setSourceComponent(PlatformComponent sourceComponent) { + this.sourceComponent = sourceComponent; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + public String getTargetPort() { + return targetPort; + } + + public void setTargetPort(String targetPort) { + this.targetPort = targetPort; + } + + public Platform getTargetPlatform() { + return targetPlatform; + } + + public void setTargetPlatform(Platform targetPlatform) { + this.targetPlatform = targetPlatform; + } + + public PlatformComponent getTargetComponent() { + return targetComponent; + } + + public void setTargetComponent(PlatformComponent targetComponent) { + this.targetComponent = targetComponent; + } + +} diff --git a/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java b/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java index 4b6585d..03bec24 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/mapper/SceneMapper.java @@ -1,6 +1,7 @@ package com.solution.scene.mapper; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -13,9 +14,9 @@ public interface SceneMapper { * @param afsimScenario * @return */ - int insert(AfsimScenario afsimScenario); + int insert(AfsimScenarioForm afsimScenario); - int update(AfsimScenario afsimScenario); + int update(AfsimScenarioForm afsimScenario); /** diff --git a/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java b/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java index 67305b3..15a4933 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/service/SceneService.java @@ -1,6 +1,7 @@ package com.solution.scene.service; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import java.util.List; @@ -11,11 +12,11 @@ public interface SceneService { * @param afsimScenario * @return */ - int insert(AfsimScenario afsimScenario); + int insert(AfsimScenarioForm afsimScenario); - int update(AfsimScenario afsimScenario); + int update(AfsimScenarioForm afsimScenario); - int saveOrUpdate(AfsimScenario afsimScenario); + int saveOrUpdate(AfsimScenarioForm afsimScenario); /** * 获取场景列表 diff --git a/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java b/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java index f1a43fa..75deac0 100644 --- a/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java +++ b/auto-solution-scene/src/main/java/com/solution/scene/service/impl/SceneServiceImpl.java @@ -1,6 +1,7 @@ package com.solution.scene.service.impl; import com.solution.scene.domain.AfsimScenario; +import com.solution.scene.domain.AfsimScenarioForm; import com.solution.scene.mapper.SceneMapper; import com.solution.scene.service.SceneService; import org.springframework.beans.factory.annotation.Autowired; @@ -16,17 +17,17 @@ public class SceneServiceImpl implements SceneService { private SceneMapper sceneMapper; @Override - public int insert(AfsimScenario afsimScenario) { + public int insert(AfsimScenarioForm afsimScenario) { return sceneMapper.insert(afsimScenario); } @Override - public int update(AfsimScenario afsimScenario) { + public int update(AfsimScenarioForm afsimScenario) { return sceneMapper.update(afsimScenario); } @Override - public int saveOrUpdate(AfsimScenario afsimScenario) { + public int saveOrUpdate(AfsimScenarioForm afsimScenario) { if (null != afsimScenario.getId() && afsimScenario.getId() > 0) { return sceneMapper.update(afsimScenario); } From 8dc867acb676747ebe9d384783cdab88d603e72f Mon Sep 17 00:00:00 2001 From: libertyspy Date: Mon, 16 Mar 2026 15:48:33 +0800 Subject: [PATCH 02/29] UPDATE: VERSION-20260316 --- .../decision/communication/communication.vue | 13 +- .../src/views/decision/communication/node.vue | 5 +- .../decision/communication/nodes-card.vue | 30 ++-- .../decision/communication/platform-card.vue | 1 + .../views/decision/communication/relation.ts | 134 ++++++++++++++++++ .../src/views/decision/communication/types.ts | 18 ++- .../src/views/decision/communication/utils.ts | 49 +++++++ modeler/src/views/decision/graph/canvas.ts | 2 +- modeler/src/views/decision/graph/element.ts | 2 +- modeler/src/views/decision/graph/hooks.ts | 1 + modeler/src/views/decision/graph/index.ts | 14 +- modeler/src/views/decision/graph/utils.ts | 4 +- 12 files changed, 239 insertions(+), 34 deletions(-) create mode 100644 modeler/src/views/decision/communication/relation.ts diff --git a/modeler/src/views/decision/communication/communication.vue b/modeler/src/views/decision/communication/communication.vue index 061844a..757fe09 100644 --- a/modeler/src/views/decision/communication/communication.vue +++ b/modeler/src/views/decision/communication/communication.vue @@ -63,6 +63,7 @@ import { createGraphScenarioElement, createGraphTaskElementFromScenario } from ' import PlatformCard from './platform-card.vue'; import NodesCard from './nodes-card.vue'; import { saveScenario } from './api'; +import {resolveConnectionRelation} from './relation' const TeleportContainer = defineComponent(getTeleport()); @@ -194,7 +195,6 @@ export default defineComponent({ }; 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; @@ -210,10 +210,10 @@ export default defineComponent({ currentScenario.value = { ...scenario, graph: nodeGraph, + relations: [] }; currentScenarioEditing.value = true; createElements(); - }; const createElements = () => { @@ -228,7 +228,6 @@ export default defineComponent({ if (currentScenario.value?.graph.nodes) { currentScenario.value?.graph.nodes.forEach(ele => { const node = createGraphScenarioElement(ele as GraphTaskElement); - console.info('create node: ', ele); // 将节点添加到画布 graph.value?.addNode(node as Node); }); @@ -255,10 +254,11 @@ export default defineComponent({ name: null, description: null, communicationGraph: null, + relations: [], graph: { edges: [], nodes: [], - } + }, }; currentGraph.value = { edges: [], @@ -341,6 +341,10 @@ export default defineComponent({ const handleSave = () => { const graphData: GraphContainer = resolveGraph(graph.value as Graph); + + const relations = resolveConnectionRelation(graph.value as Graph); + console.error('relations',relations) + console.info('handleSave', graphData); if (!currentScenario.value) { message.error('当前决策树不存在'); @@ -350,6 +354,7 @@ export default defineComponent({ ...currentScenario.value, graph: graphData, communicationGraph: JSON.stringify(graphData), + relations: relations }; if (!newScenario.name) { message.error('场景名称不能为空.'); diff --git a/modeler/src/views/decision/communication/node.vue b/modeler/src/views/decision/communication/node.vue index edd3b0f..cc074e7 100644 --- a/modeler/src/views/decision/communication/node.vue +++ b/modeler/src/views/decision/communication/node.vue @@ -23,9 +23,11 @@ >
@@ -38,9 +40,11 @@
@@ -130,7 +134,6 @@ export default defineComponent({ onMounted(() => { _props.node?.on('change:data', handleDataChange); - console.error('element',element.value) }); onUnmounted(() => { diff --git a/modeler/src/views/decision/communication/nodes-card.vue b/modeler/src/views/decision/communication/nodes-card.vue index da38e98..745febd 100644 --- a/modeler/src/views/decision/communication/nodes-card.vue +++ b/modeler/src/views/decision/communication/nodes-card.vue @@ -27,7 +27,7 @@ \ No newline at end of file diff --git a/modeler/src/views/decision/rule/api.ts b/modeler/src/views/decision/rule/api.ts index 30b1d34..d7d2ae3 100644 --- a/modeler/src/views/decision/rule/api.ts +++ b/modeler/src/views/decision/rule/api.ts @@ -9,6 +9,7 @@ import { HttpRequestClient } from '@/utils/request'; import type { FireRule, FireRulePageableResponse, FireRuleRequest } from './types'; +import type { PlatformWithComponentsResponse } from '../types'; import type { BasicResponse } from '@/types'; const req = HttpRequestClient.create({ @@ -31,5 +32,8 @@ export const deleteFireRule = (id: number): Promise => { return req.delete(`/system/rule/${id}`); }; +export const findAllPlatformWithComponents = (): Promise => { + return req.get(`/system/firerule/platforms`); +}; \ No newline at end of file diff --git a/modeler/src/views/decision/rule/management.vue b/modeler/src/views/decision/rule/management.vue index ab2d29a..24cca0b 100644 --- a/modeler/src/views/decision/rule/management.vue +++ b/modeler/src/views/decision/rule/management.vue @@ -75,18 +75,52 @@ - + +
+
+ + + + + + + + + + + +
+
+
- + +
+
+ + + + + + + + + + + +
+
+
import { onMounted, ref } from 'vue'; import { type FormInstance, message } from 'ant-design-vue'; -import { PlusOutlined } from '@ant-design/icons-vue'; +import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue'; import Layout from '../layout.vue'; import { createFireRule, deleteFireRule, findFireRuleByQuery, updateFireRule } from './api'; import type { FireRule, FireRuleRequest } from './types'; import { substring } from '@/utils/strings'; +import PlatformSelect from './PlatformSelect.vue'; +import type { PlatformComponentPayload } from '../types'; const query = ref>({ pageNum: 1, @@ -155,8 +191,20 @@ const defaultFireRule: FireRule = { sceneType: null, // 触发条件(JSON格式) conditions: null, + conditionsArray: [ + { + platform: null, + component: null, + } + ], // 响应动作(JSON格式) actions: null, + actionsArray: [ + { + platform: null, + component: null, + } + ], // 优先级(数值越小优先级越高) priority: 0, // 是否启用(0禁用,1启用) @@ -174,20 +222,47 @@ const getSceneTypeName = (item: FireRule): string => { }; const resolveItem = (item: FireRule) => { - let newItem = JSON.parse(JSON.stringify(item)); + let newItem = JSON.parse(JSON.stringify(item)) as FireRule; + try{ + newItem.conditionsArray = JSON.parse(newItem.conditions as string); + } catch(e: any){ + } + if(!newItem.conditionsArray) { + newItem.conditionsArray = [] + } + if(newItem.conditionsArray.length===0){ + newItem.conditionsArray.push({ + platform: null, + component: null, + }) + } + + try{ + newItem.actionsArray = JSON.parse(newItem.actions as string); + } catch(e: any){ + } + if(!newItem.actionsArray){ + newItem.actionsArray = [] + } + if(newItem.actionsArray.length===0){ + newItem.actionsArray.push({ + platform: null, + component: null, + }) + } return newItem; }; const datasource = ref([]); const datasourceTotal = ref(0); -const selectedFireRule = ref(resolveItem(defaultFireRule)); +const selectedFireRule = ref({...defaultFireRule}); const formRef = ref(null); const load = () => { datasource.value = []; datasourceTotal.value = 0; formRef.value?.resetFields(); - selectedFireRule.value = resolveItem(defaultFireRule); + selectedFireRule.value = {...defaultFireRule}; findFireRuleByQuery(query.value).then(r => { datasource.value = r.rows ?? []; @@ -197,7 +272,7 @@ const load = () => { const handleCreate = () => { - selectedFireRule.value = resolveItem(defaultFireRule); + selectedFireRule.value = {...defaultFireRule}; }; const handleSelect = (item: FireRule) => { @@ -223,6 +298,8 @@ const handleSave = () => { formRef.value.validate().then(() => { let res = null; let savedValue: FireRule = JSON.parse(JSON.stringify(selectedFireRule.value)) as any as FireRule; + savedValue.conditions = JSON.stringify(savedValue.conditionsArray ?? null) as string; + savedValue.actions = JSON.stringify(savedValue.actionsArray ?? null) as string; if (savedValue.id > 0) { res = updateFireRule(savedValue); } else { @@ -242,6 +319,65 @@ const handleSave = () => { } }; +const handleMinusCondition = (index: number) => { + if(selectedFireRule.value){ + const paramList = selectedFireRule.value.conditionsArray; + if (index === 0 && selectedFireRule.value.conditionsArray.length === 1) { + selectedFireRule.value.conditionsArray = [{ + platform: null, + component: null, + }]; + } else if (index >= 0 && index < paramList.length && paramList.length > 1) { + paramList.splice(index, 1); + selectedFireRule.value.conditionsArray = [...paramList]; + } + } +} + +const handleAddCondition = (index: number)=> { + if(selectedFireRule.value){ + selectedFireRule.value.conditionsArray.push({ + platform: null, + component: null, + }) + } +} + +const handleMinusAction = (index: number) => { + if(selectedFireRule.value){ + const paramList = selectedFireRule.value.actionsArray; + if (index === 0 && selectedFireRule.value.actionsArray.length === 1) { + selectedFireRule.value.actionsArray = [{ + platform: null, + component: null, + }]; + } else if (index >= 0 && index < paramList.length && paramList.length > 1) { + paramList.splice(index, 1); + selectedFireRule.value.actionsArray = [...paramList]; + } + } +} + +const handleAddAction = (_index: number)=> { + if(selectedFireRule.value){ + selectedFireRule.value.actionsArray.push({ + platform: null, + component: null, + }) + } +} + +const handleUpdateCondition = (payload: PlatformComponentPayload, index: number)=> { + if(selectedFireRule.value && selectedFireRule.value.conditionsArray[index]){ + selectedFireRule.value.conditionsArray[index] = payload; + } +} + +const handleUpdateAction = (payload: PlatformComponentPayload, index: number)=> { + if(selectedFireRule.value && selectedFireRule.value.actionsArray[index]){ + selectedFireRule.value.actionsArray[index] = payload; + } +} const handleChange = (page: number, pageSize: number) => { query.value.pageNum = page; diff --git a/modeler/src/views/decision/rule/types.ts b/modeler/src/views/decision/rule/types.ts index 37c80a1..721326b 100644 --- a/modeler/src/views/decision/rule/types.ts +++ b/modeler/src/views/decision/rule/types.ts @@ -8,6 +8,7 @@ */ import type { NullableString, PageableResponse } from '@/types'; +import type { PlatformComponentPayload } from '../types'; export interface FireRule { id: number, @@ -17,8 +18,10 @@ export interface FireRule { sceneType: Number | null, // 触发条件(JSON格式) conditions: NullableString, - // 响应动作(JSON格式) - actions: NullableString, + conditionsArray: PlatformComponentPayload[], + // 响应动作(JSON格式) + actions: NullableString, + actionsArray: PlatformComponentPayload[], // 优先级(数值越小优先级越高) priority: number, // 是否启用(0禁用,1启用) diff --git a/modeler/src/views/decision/types/index.ts b/modeler/src/views/decision/types/index.ts new file mode 100644 index 0000000..0a425d0 --- /dev/null +++ b/modeler/src/views/decision/types/index.ts @@ -0,0 +1,10 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +export * from './platform' \ No newline at end of file diff --git a/modeler/src/views/decision/types/platform.ts b/modeler/src/views/decision/types/platform.ts new file mode 100644 index 0000000..02707a5 --- /dev/null +++ b/modeler/src/views/decision/types/platform.ts @@ -0,0 +1,40 @@ +/* + * This file is part of the kernelstudio package. + * + * (c) 2014-2026 zlin + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +import type { ApiDataResponse, NullableString } from '@/types'; + +export interface Platform { + id: number, + name: NullableString, + description: NullableString, + scenarioId: number, + + [key: string]: unknown; +} + +export interface PlatformComponent { + id: number, + name: NullableString, + type: NullableString, + description: NullableString, + platformId: number, +} + +export interface PlatformWithComponents extends Platform { + components: PlatformComponent[], +} + +export interface PlatformComponentPayload { + platform: Platform | null; + component: PlatformComponent | null; +} + +export interface PlatformWithComponentsResponse extends ApiDataResponse { + +} From 6dd4392f0c231110545989f473904b5ce7cb9795 Mon Sep 17 00:00:00 2001 From: libertyspy Date: Tue, 17 Mar 2026 00:36:16 +0800 Subject: [PATCH 05/29] UPDATE: VERSION-20260317 --- .../views/decision/rule/PlatformSelect.vue | 168 +++++++++--------- .../src/views/decision/rule/management.vue | 40 +++-- modeler/src/views/decision/types/platform.ts | 3 + 3 files changed, 114 insertions(+), 97 deletions(-) diff --git a/modeler/src/views/decision/rule/PlatformSelect.vue b/modeler/src/views/decision/rule/PlatformSelect.vue index 3df5295..5aa60af 100644 --- a/modeler/src/views/decision/rule/PlatformSelect.vue +++ b/modeler/src/views/decision/rule/PlatformSelect.vue @@ -20,10 +20,10 @@ style="width:280px;" v-model:value="selectedComponentId" :placeholder="'请选择组件'" - :disabled="!selectedPlatformId" + :disabled="!selectedPlatform" > @@ -44,124 +44,124 @@ export default defineComponent({ type: String, default: '', }, - platform: { - type: [Object,null] as PropType, + payload: { + type: [Object,null] as PropType, required: false, - default: () => ({}), // 设置默认空对象,避免undefined - }, - component: { - type: [Object, null] as PropType, - required: false, - default: () => ({}), // 设置默认空对象,避免undefined + default: ({ + platform: null, + component: null, + }), }, }, emits: [ - // 只保留统一的update事件 - 'update', + 'change', ], setup(props, { emit }) { - // 平台列表 const platforms = ref([]); - // 选中的平台ID(兼容props初始值) - const selectedPlatformId = ref(props.platform?.id); - // 选中的组件ID(兼容props初始值) - const selectedComponentId = ref(props.component?.id); - - // 平台映射表 const platformMapping = ref>(new Map()); + const componentsMapping = ref>(new Map()); - // 计算属性:根据选中的平台过滤对应的组件列表 - const filteredComponents = computed(() => { - if (!selectedPlatformId.value) return []; - const currentPlatform = platformMapping.value.get(selectedPlatformId.value); - return currentPlatform?.components ?? []; - }); + const selectedPlatformComponents = ref([]) - // 封装统一的update事件触发函数 - const triggerUpdateEvent = () => { - // 获取当前选中的平台对象 - const selectedPlatform = selectedPlatformId.value - ? platformMapping.value.get(selectedPlatformId.value) || ({} as Platform) - : ({} as Platform); + const selectedPlatform = ref(null); + const selectedPlatformId = ref(null); - // 获取当前选中的组件对象 - const selectedComponent = selectedComponentId.value - ? filteredComponents.value.find(item => item.id === selectedComponentId.value) || ({} as PlatformComponent) - : ({} as PlatformComponent); + const selectedComponent = ref(null); + const selectedComponentId = ref(null); - // 触发统一的update事件,传递平台和组件信息 - emit('update', { - platform: { - id: selectedPlatform.id, - name: selectedPlatform.name, - description: selectedPlatform.description, - }, - component: selectedComponent, - } as PlatformComponentPayload); - }; - - // 加载平台和组件数据 const load = () => { platforms.value = []; platformMapping.value.clear(); + componentsMapping.value.clear(); findAllPlatformWithComponents().then(re => { platforms.value = re.data ?? []; - - // 构建平台映射表 platforms.value.forEach(platform => { platformMapping.value.set(platform.id, platform); - }); - - // 数据加载完成后,若有初始平台值,自动匹配组件列表 - if (props.platform?.id) { - selectedPlatformId.value = props.platform.id; - // 若有初始组件值,校验是否属于当前平台 - if (props.component?.id) { - const currentComponents = filteredComponents.value; - const hasComponent = currentComponents.some(item => item.id === Number(props.component?.id ?? 0)); - // 若初始组件不属于当前平台,清空组件选中值 - if (!hasComponent) { - selectedComponentId.value = undefined; - } + if(platform.components){ + platform.components.forEach(comp=> { + componentsMapping.value.set(comp.id, comp) + }) } - } - // 数据加载完成后触发一次update事件 - triggerUpdateEvent(); + }); }).catch(err => { console.error('加载平台组件数据失败:', err); }); }; - // 监听平台选择变化 - watch(selectedPlatformId, () => { - // 平台变更时,清空组件选中值 - selectedComponentId.value = undefined; - // 触发统一的update事件 - triggerUpdateEvent(); - }); + const triggerChange = ()=> { + emit('change', { + platform: selectedPlatform.value ? { + id: selectedPlatform.value?.id, + name: selectedPlatform.value?.name, + description: selectedPlatform.value?.description, + } : null, + component: selectedComponent.value ? { + id: selectedComponent.value.id, + name: selectedComponent.value.name, + description: selectedComponent.value.description, + num: selectedComponent.value.num, + platformId: selectedComponent.value.platformId, + type: selectedComponent.value.type, + } : null, + }) + } - // 监听组件选择变化 - watch(selectedComponentId, () => { - // 触发统一的update事件 - triggerUpdateEvent(); - }); + watch(()=> props.payload, (n: PlatformComponentPayload | null | undefined)=> { + if(n && n.platform){ + selectedPlatform.value = platformMapping.value.get(n.platform?.id) ?? null; + selectedPlatformId.value = selectedPlatform.value?.id ?? null; + selectedPlatformComponents.value = selectedPlatform.value?.components ?? [] + } else { + selectedPlatform.value = null; + selectedPlatformId.value = null; + selectedPlatformComponents.value = [] + } - watch(() => props.platform?.id, (newVal) => { - selectedPlatformId.value = newVal; - }, { immediate: true }); // 立即执行,确保初始值同步 + if(n && n.component){ + selectedComponent.value = n.component; + selectedComponentId.value = selectedComponent.value?.id ?? null; + } else { + selectedComponent.value = null; + selectedComponentId.value = null; + } - watch(() => props.component?.id, (newVal) => { - selectedComponentId.value = newVal; - }, { immediate: true }); // 立即执行,确保初始值同步 + console.error('watch',n) + }, {deep: true, immediate: true}) + + + watch(()=> selectedPlatformId.value,(n: null | number)=> { + if(n && platformMapping.value.get(n)){ + selectedPlatform.value = platformMapping.value.get(n) ?? null; + selectedPlatformComponents.value = selectedPlatform.value?.components ?? [] + } else { + selectedPlatform.value = null; + selectedPlatformComponents.value = [] + } + selectedComponentId.value = null; + + triggerChange(); + }) + + watch(()=> selectedComponentId.value,(n: null | number)=> { + if(n && componentsMapping.value.get(n)){ + selectedComponent.value = componentsMapping.value.get(n) ?? null; + } else { + selectedComponent.value = null; + } + + triggerChange(); + }) onMounted(() => load()); return { platforms, + selectedPlatformComponents, + selectedPlatform, selectedPlatformId, + selectedComponent, selectedComponentId, - filteredComponents, }; }, }); diff --git a/modeler/src/views/decision/rule/management.vue b/modeler/src/views/decision/rule/management.vue index 24cca0b..24d54ad 100644 --- a/modeler/src/views/decision/rule/management.vue +++ b/modeler/src/views/decision/rule/management.vue @@ -83,8 +83,8 @@
- + @@ -108,8 +108,8 @@
- + @@ -168,7 +168,7 @@ \ No newline at end of file diff --git a/modeler/src/views/decision/rule/management.vue b/modeler/src/views/decision/rule/management.vue index 24d54ad..c802453 100644 --- a/modeler/src/views/decision/rule/management.vue +++ b/modeler/src/views/decision/rule/management.vue @@ -32,9 +32,7 @@
- -
- 通用 @@ -73,23 +70,32 @@ +
-
+
- + + - - + + @@ -98,23 +104,32 @@ +
-
+
- + + - - + + @@ -126,24 +141,21 @@ - + 保存规则 - 删除规则 - - -
- -
\ No newline at end of file From c724a7acf7026e862877360a4ff1b7e6d47ed4f0 Mon Sep 17 00:00:00 2001 From: libertyspy Date: Tue, 17 Mar 2026 10:21:00 +0800 Subject: [PATCH 10/29] UPDATE: VERSION-20260317 --- modeler/src/style.less | 8 ++- .../views/decision/rule/PlatformSelect.vue | 45 ++----------- modeler/src/views/decision/rule/store.ts | 64 +++++++++++++++++++ 3 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 modeler/src/views/decision/rule/store.ts diff --git a/modeler/src/style.less b/modeler/src/style.less index 48e7e4c..ad463ef 100644 --- a/modeler/src/style.less +++ b/modeler/src/style.less @@ -1291,6 +1291,10 @@ } } +.ant-select:not(.ant-select-customize-input) .ant-select-selector{ + border: 1px solid #475f71 +} + .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill, .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:hover, .ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:focus, @@ -1504,9 +1508,7 @@ border-inline-end-width: 1px; } } -.ant-select:not(.ant-select-customize-input) .ant-select-selector{ - border: 1px solid #2c2a2a; -} + .ant-select .ant-select-selection-placeholder, .ant-select .ant-select-selection-search-input{ background: transparent diff --git a/modeler/src/views/decision/rule/PlatformSelect.vue b/modeler/src/views/decision/rule/PlatformSelect.vue index d556b94..0b3ddb6 100644 --- a/modeler/src/views/decision/rule/PlatformSelect.vue +++ b/modeler/src/views/decision/rule/PlatformSelect.vue @@ -35,9 +35,9 @@