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 81d97cc..c97033c 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(() => {