Compare commits
No commits in common. "e6d379f5711e10e5613ce45d27c994931f6433a3" and "80583a526d883d8c9e59c7854ba44b64088eb241" have entirely different histories.
e6d379f571
...
80583a526d
@ -87,22 +87,7 @@ const isEditing = ref(false);
|
||||
const localName = ref("");
|
||||
const nameInputRef = ref();
|
||||
const isSelectArea = computed(() => props.nodeType === "selectArea");
|
||||
const flowContextActions = new Set([
|
||||
"NONE",
|
||||
"START",
|
||||
"END",
|
||||
"SUB_START",
|
||||
"SUB_END",
|
||||
"START_LOOP",
|
||||
"STOP_LOOP",
|
||||
"BRANCH",
|
||||
"GET_CURRENT_OBJECT",
|
||||
]);
|
||||
const canExecute = computed(() => {
|
||||
if (isSelectArea.value) return false;
|
||||
const action = String(props.nodeProperties?.action || "").toUpperCase();
|
||||
return Boolean(action) && !flowContextActions.has(action);
|
||||
});
|
||||
const canExecute = computed(() => Boolean(props.nodeType) && !["NONE", "selectArea"].includes(props.nodeType));
|
||||
const typeLabel = computed(() => {
|
||||
if (!props.nodeType || ["NONE", "selectArea"].includes(props.nodeType)) return "";
|
||||
return { EDGE: "设备", LLM: "模型", AE: "评估" }[props.nodeType] || props.nodeType;
|
||||
|
||||
@ -3,6 +3,8 @@ import videoSvg from './icon/video.svg'
|
||||
import loopSvg from './icon/loop.svg'
|
||||
import stopLoopSvg from './icon/stopLoop.svg'
|
||||
import switchSvg from './icon/switch.svg'
|
||||
import startSvg from './icon/start.svg'
|
||||
import endSvg from './icon/end.svg'
|
||||
import microphoneSvg from './icon/microphone.svg'
|
||||
import sleepSvg from './icon/sleep.svg'
|
||||
import planSvg from './icon/plan.svg'
|
||||
@ -12,6 +14,11 @@ import audioSvg from './icon/audio.svg'
|
||||
import touchSvg from './icon/touch.svg'
|
||||
import expressionSvg from './icon/expression.svg'
|
||||
|
||||
const booleanOptions = () => [
|
||||
{ value: false, label: '否' },
|
||||
{ value: true, label: '是' }
|
||||
]
|
||||
|
||||
const httpMethodOptions = () => {
|
||||
return [{
|
||||
value: 'POST',
|
||||
@ -457,10 +464,8 @@ function handler(params) {
|
||||
type: "serviceNode",
|
||||
desc: "用于播放音频的节点",
|
||||
action: 'SPEAKER_PLAYAUDIO',
|
||||
nodeType: 'EDGE',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: [], disabled: true },
|
||||
{ name: "audioPath", type: "input", input: "", disabled: true }
|
||||
{ name: "deviceId", type: "input", input: "", componentType: 'select', selectOptions: [], disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
|
||||
@ -180,15 +180,17 @@
|
||||
label-width="auto"
|
||||
:disabled="flowStore.disableForm"
|
||||
>
|
||||
<div v-for="(field, index) in singleNodeFields" :key="field.key">
|
||||
<div v-for="(property, index) in formData.nodeParams" :key="index">
|
||||
<el-row class="single-node-param-row">
|
||||
<el-form-item
|
||||
class="single-node-param-name"
|
||||
:label="index === 0 ? '参数名' : ''"
|
||||
:prop="`nodeParams.${index}.name`"
|
||||
:rules="[{ required: true, message: '请输入参数名', trigger: 'blur' }]"
|
||||
>
|
||||
<el-input
|
||||
:disabled="field.param?.disabled || false"
|
||||
v-model="field.param.name"
|
||||
:disabled="property?.disabled || false"
|
||||
v-model="property.name"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
/>
|
||||
@ -196,25 +198,27 @@
|
||||
<el-form-item
|
||||
class="single-node-param-value"
|
||||
:label="index === 0 ? '参数值' : ''"
|
||||
:prop="`nodeParams.${index}.input`"
|
||||
:rules="[{ required: true, message: '请输入参数值', trigger: 'blur' }]"
|
||||
>
|
||||
<el-input-number
|
||||
v-if="field.param.componentType === 'number'"
|
||||
v-model="field.param.input"
|
||||
v-if="property.componentType === 'number'"
|
||||
v-model="property.input"
|
||||
:min="0"
|
||||
:max="field.param.max || Infinity"
|
||||
:step="field.param.step || 1"
|
||||
:max="property.max || Infinity"
|
||||
:step="property.step || 1"
|
||||
:step-strictly="true"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
/>
|
||||
<el-select
|
||||
v-model="field.param.input"
|
||||
v-else-if="field.param.componentType === 'select'"
|
||||
:disabled="field.param.deviceLocked"
|
||||
@change="field.param.name === 'robotId' && handleSingleNodeRobotChange(field.param.input)"
|
||||
v-model="property.input"
|
||||
v-else-if="property.componentType === 'select'"
|
||||
:disabled="property.deviceLocked"
|
||||
@change="property.name === 'robotId' && handleSingleNodeRobotChange(property.input)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in field.param.selectOptions"
|
||||
v-for="item in property.selectOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
@ -222,14 +226,14 @@
|
||||
</el-select>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="field.param.input"
|
||||
v-model="property.input"
|
||||
autosize
|
||||
type="textarea"
|
||||
resize="none"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
/>
|
||||
<div v-if="field.param.name === 'deviceId' && field.param.deviceLocked" class="device-lock-hint">
|
||||
<div v-if="property.name === 'deviceId' && property.deviceLocked" class="device-lock-hint">
|
||||
已自动匹配当前机器人设备
|
||||
</div>
|
||||
</el-form-item>
|
||||
@ -239,7 +243,7 @@
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="singleNodeExecuting" @click="execute"> 确定 </el-button>
|
||||
<el-button type="primary" @click="execute"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@ -624,9 +628,7 @@ const validEdge = (data) => {
|
||||
}
|
||||
|
||||
if (sourceName === "right" && targetName === "left") {
|
||||
if (hasSameEdge(data, data.id)) {
|
||||
lf.deleteEdge(data.id);
|
||||
}
|
||||
if (hasSameEdge(data, data.id)) lf.deleteEdge(data.id);
|
||||
return;
|
||||
} else if (
|
||||
(sourceName === "right" && targetName === "right") ||
|
||||
@ -652,7 +654,8 @@ const validEdge = (data) => {
|
||||
|
||||
const instId = ref(null);
|
||||
const changeState = (value) => {
|
||||
oldFlowData = JSON.parse(JSON.stringify(lf.getGraphData()));
|
||||
const flowData = JSON.parse(JSON.stringify(lf.getGraphData()));
|
||||
oldFlowData = flowData;
|
||||
isOpen.value = false;
|
||||
flowStore.updateDisableForm(true);
|
||||
flowState.value = value.type;
|
||||
@ -760,7 +763,7 @@ const registerBeforeUnload = () => {
|
||||
window.addEventListener("beforeunload", handleBeforeUnload);
|
||||
};
|
||||
|
||||
const handleBeforeUnload = (_event) => {
|
||||
const handleBeforeUnload = (event) => {
|
||||
if (flowState.value === "pause" && !flowInfoData.value.isLog) {
|
||||
flowStopFn();
|
||||
}
|
||||
@ -876,7 +879,8 @@ const defaultProps = {
|
||||
};
|
||||
const showNodeRelationship = () => {
|
||||
const { nodes } = lf.getGraphData();
|
||||
treeData.value = convertToTree(nodes);
|
||||
const outputData = convertToTree(nodes);
|
||||
treeData.value = outputData;
|
||||
};
|
||||
|
||||
const handleTreeNodeClick = (node) => {
|
||||
@ -898,47 +902,8 @@ const formData = reactive({
|
||||
const rules = reactive({});
|
||||
const executeForm = ref();
|
||||
const nodeAction = ref("");
|
||||
const singleNodeExecuting = ref(false);
|
||||
const stationLoading = ref(false);
|
||||
const singleNodeRobotOptions = ref([]);
|
||||
const flattenSingleNodeParams = (params, parentPath = [], fields = []) => {
|
||||
(params || []).forEach((param, index) => {
|
||||
const name = String(param?.name || "").trim();
|
||||
const path = [...parentPath, name || `param-${index}`];
|
||||
if (Array.isArray(param?.children)) {
|
||||
flattenSingleNodeParams(param.children, path, fields);
|
||||
return;
|
||||
}
|
||||
if (!name && (param?.input === "" || param?.input === null || param?.input === undefined)) return;
|
||||
fields.push({ key: `${path.join(".")}-${index}`, param });
|
||||
});
|
||||
return fields;
|
||||
};
|
||||
const singleNodeFields = computed(() => flattenSingleNodeParams(formData.nodeParams));
|
||||
const buildSingleNodePayload = (params) => {
|
||||
const payload = {};
|
||||
(params || []).forEach((param) => {
|
||||
const name = String(param?.name || "").trim();
|
||||
if (!name) return;
|
||||
payload[name] = Array.isArray(param.children)
|
||||
? buildSingleNodePayload(param.children)
|
||||
: param.input;
|
||||
});
|
||||
return payload;
|
||||
};
|
||||
const validateSingleNodeParams = () => {
|
||||
for (const { param } of singleNodeFields.value) {
|
||||
if (!String(param?.name || "").trim()) {
|
||||
ElMessage.warning("请输入参数名");
|
||||
return false;
|
||||
}
|
||||
if (param.input === "" || param.input === null || param.input === undefined) {
|
||||
ElMessage.warning(`请输入参数 ${param.name} 的值`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const singleNodeRobotId = computed(() =>
|
||||
formData.nodeParams.find((item) => item.name === "robotId")?.input
|
||||
);
|
||||
@ -1037,14 +1002,11 @@ const loadSingleNodeRobots = async () => {
|
||||
const singleNodeExecution = async (e) => {
|
||||
const { name, nodeType, nodeParams, action } = e.detail;
|
||||
const executionParams = JSON.parse(JSON.stringify(nodeParams || []));
|
||||
const normalizedAction = String(action || "").toUpperCase();
|
||||
const effectiveNodeType = nodeType || (getDeviceKindForAction(normalizedAction) ? "EDGE" : "");
|
||||
nodeName.value = name;
|
||||
visible.value = true;
|
||||
nodeAction.value = normalizedAction;
|
||||
singleNodeExecuting.value = false;
|
||||
nodeAction.value = action;
|
||||
stationLoading.value = false;
|
||||
if (effectiveNodeType === "EDGE") {
|
||||
if (nodeType === "EDGE") {
|
||||
await loadSingleNodeRobots();
|
||||
formData.nodeParams = [
|
||||
{
|
||||
@ -1060,7 +1022,7 @@ const singleNodeExecution = async (e) => {
|
||||
} else {
|
||||
formData.nodeParams = executionParams;
|
||||
}
|
||||
if (nodeAction.value === "AGV_MOVE_TO_STATION") {
|
||||
if (action === "AGV_MOVE_TO_STATION") {
|
||||
const stationParam = formData.nodeParams.find((item) => item.name === "stationId");
|
||||
if (stationParam) {
|
||||
stationParam.input = "";
|
||||
@ -1080,22 +1042,21 @@ const execute = async () => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!validateSingleNodeParams()) return;
|
||||
singleNodeExecuting.value = true;
|
||||
try {
|
||||
const result = await executeForm.value.validate();
|
||||
if (result) {
|
||||
const obj = {};
|
||||
formData.nodeParams.forEach((item) => {
|
||||
obj[item.name] = item.input;
|
||||
});
|
||||
const res = await flowAction({
|
||||
action: nodeAction.value,
|
||||
payload: buildSingleNodePayload(formData.nodeParams),
|
||||
payload: obj,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
ElMessage.success("执行成功");
|
||||
} else {
|
||||
ElMessage.error(res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("单节点执行失败:", error);
|
||||
} finally {
|
||||
singleNodeExecuting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1386,6 +1347,7 @@ onUnmounted(() => {
|
||||
.single-node-param-row {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 24px;
|
||||
align-items: start;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user