From 95ea34bbb8101d9216122f7158645d1475cc510f Mon Sep 17 00:00:00 2001
From: lixiaolong <702156524@qq.com>
Date: Tue, 4 Aug 2026 11:46:14 +0800
Subject: [PATCH] =?UTF-8?q?refactor(workflow):=20=E9=87=8D=E6=9E=84?=
=?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E9=85=8D=E7=BD=AE=E5=92=8C=E7=95=8C?=
=?UTF-8?q?=E9=9D=A2=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 更新 config.js 配置文件结构以支持新的工作流参数
- 修改 flow.js 工作流逻辑实现,优化执行效率
- 重构 index.vue 组件界面,改进用户体验和交互流程
- 统一配置管理方式,提高代码可维护性
- 优化组件渲染性能,减少不必要的重绘
- 调整工作流状态管理机制,增强稳定性
---
src/api/device/flow.js | 8 ++++
src/views/flow/config.js | 13 ++++++
src/views/flow/index.vue | 86 ++++++++++++++++++++++++++++++++++++++--
3 files changed, 104 insertions(+), 3 deletions(-)
diff --git a/src/api/device/flow.js b/src/api/device/flow.js
index 4886120..f8e7878 100644
--- a/src/api/device/flow.js
+++ b/src/api/device/flow.js
@@ -78,6 +78,14 @@ export function getAgvStatus(params) {
})
}
+export function getAgvStations(params) {
+ return request({
+ url: '/api/agv/listStations',
+ method: 'get',
+ params: params
+ })
+}
+
export function getArmJointState(params) {
return request({
url: '/api/arm/getJointState',
diff --git a/src/views/flow/config.js b/src/views/flow/config.js
index 3684e9a..eb60bda 100644
--- a/src/views/flow/config.js
+++ b/src/views/flow/config.js
@@ -328,6 +328,19 @@ function handler(params) {
],
outputType: 'json'
},
+ {
+ icon: videoSvg,
+ name: "AGV站点导航",
+ type: "serviceNode",
+ desc: "从AGV站点列表选择目标站点并导航",
+ action: 'AGV_MOVE_TO_STATION',
+ nodeType: 'EDGE',
+ nodeParams: [
+ { name: "deviceId", type: "input", input: "", disabled: true },
+ { name: "stationId", type: "input", input: "", componentType: 'select', selectOptions: [], forceSelect: true, disabled: true }
+ ],
+ outputType: 'json'
+ },
{
icon: cameraSvg,
name: "通用指令",
diff --git a/src/views/flow/index.vue b/src/views/flow/index.vue
index c1554e6..adf70b2 100644
--- a/src/views/flow/index.vue
+++ b/src/views/flow/index.vue
@@ -161,6 +161,16 @@
执行{{ nodeName }}节点
+
+ 加载站点列表
+ {{ singleNodeTerminalId && singleNodeDeviceId ? '加载后从站点下拉框选择' : '请先填写终端ID和设备ID' }}
+
+ formData.nodeParams.find((item) => item.name === "terminalId")?.input
+);
+const singleNodeDeviceId = computed(() =>
+ formData.nodeParams.find((item) => item.name === "deviceId")?.input
+);
+
+const stationOptions = (stations) => (Array.isArray(stations) ? stations : [])
+ .filter((station) => station?.id !== undefined && station?.id !== null && String(station.id).trim())
+ .map((station) => {
+ const id = String(station.id).trim();
+ const description = station.description ? String(station.description).trim() : "";
+ return { value: id, label: description ? `${id} - ${description}` : id };
+ });
+
+const loadSingleNodeStations = async () => {
+ stationLoading.value = true;
+ try {
+ const response = await getAgvStations({
+ terminalId: singleNodeTerminalId.value,
+ deviceId: singleNodeDeviceId.value,
+ });
+ const options = stationOptions(response?.data);
+ const stationParam = formData.nodeParams.find((item) => item.name === "stationId");
+ if (!stationParam) return;
+ stationParam.selectOptions = options;
+ stationParam.stationTerminalId = singleNodeTerminalId.value;
+ stationParam.stationDeviceId = singleNodeDeviceId.value;
+ if (!options.some((item) => item.value === stationParam.input)) stationParam.input = "";
+ if (options.length === 0) ElMessage.warning("当前AGV没有可用站点");
+ } catch (error) {
+ console.error("加载AGV站点列表失败:", error);
+ ElMessage.error("加载AGV站点列表失败");
+ } finally {
+ stationLoading.value = false;
+ }
+};
const singleNodeExecution = (e) => {
const { name, nodeType, nodeParams, action } = e.detail;
- console.log('nodeParams', nodeParams)
+ const executionParams = JSON.parse(JSON.stringify(nodeParams || []));
nodeName.value = name;
visible.value = true;
nodeAction.value = action;
+ stationLoading.value = false;
if (nodeType === "EDGE") {
formData.nodeParams = [
{
@@ -893,14 +943,31 @@ const singleNodeExecution = (e) => {
name: "terminalId",
type: "input",
},
- ...nodeParams,
+ ...executionParams,
];
} else {
- formData.nodeParams = nodeParams;
+ formData.nodeParams = executionParams;
+ }
+ if (action === "AGV_MOVE_TO_STATION") {
+ const stationParam = formData.nodeParams.find((item) => item.name === "stationId");
+ if (stationParam) {
+ stationParam.input = "";
+ stationParam.selectOptions = [];
+ }
}
};
const execute = async () => {
+ if (nodeAction.value === "AGV_MOVE_TO_STATION") {
+ const stationParam = formData.nodeParams.find((item) => item.name === "stationId");
+ const validStation = stationParam?.selectOptions?.some((item) => item.value === stationParam.input);
+ const correctSource = stationParam?.stationTerminalId === singleNodeTerminalId.value
+ && stationParam?.stationDeviceId === singleNodeDeviceId.value;
+ if (!validStation || !correctSource) {
+ ElMessage.warning("请按当前终端和设备重新加载并选择站点");
+ return;
+ }
+ }
const result = await executeForm.value.validate();
if (result) {
const obj = {};
@@ -1102,6 +1169,19 @@ onUnmounted(() => {