From a2cccb09f1cea17b322968c21ae26a93dbdfc238 Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Wed, 12 Aug 2026 16:45:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(task):=20=E6=B7=BB=E5=8A=A0=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E5=8F=82=E6=95=B0=E7=BC=96=E8=BE=91=E5=99=A8=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=A7=E8=A1=8C=E5=AE=89=E6=8E=92=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 集成 RuntimeParamsEditor 组件用于编辑运行参数 - 扩展执行安排对话框宽度从 560px 到 820px - 在对话框中添加机器人和设备标题区域 - 添加运行参数标题区域并显示参数编辑器 - 集成 getFlowParamsApi 获取流程参数数据 - 使用 loadFlowItemScopedRuntimeRoles 替代旧的角色加载方法 - 添加 runtimeParamItems 和 runtimeParamsEditorRef 响应式变量 - 实现运行参数验证功能并在提交前检查 - 将运行参数传递给任务启动 API - 优化任务进度更新中的步骤计算逻辑 - 添加运行参数编辑器组件实现参数输入和验证功能 --- .../flow/components/RuntimeParamsEditor.vue | 85 +++++++++++++++++++ src/views/inspection/runTask/index.vue | 40 +++++++-- .../intelligenceTest/runningTask/index.vue | 40 +++++++-- src/views/test/configs/Run.vue | 6 +- 4 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 src/views/flow/components/RuntimeParamsEditor.vue diff --git a/src/views/flow/components/RuntimeParamsEditor.vue b/src/views/flow/components/RuntimeParamsEditor.vue new file mode 100644 index 0000000..9c3e624 --- /dev/null +++ b/src/views/flow/components/RuntimeParamsEditor.vue @@ -0,0 +1,85 @@ + + + + + + + + + {{ row.name }} + * + + + + {{ row.type }} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/views/inspection/runTask/index.vue b/src/views/inspection/runTask/index.vue index e90506c..9a77323 100644 --- a/src/views/inspection/runTask/index.vue +++ b/src/views/inspection/runTask/index.vue @@ -139,14 +139,17 @@ - + + 机器人和设备 + 运行参数 + 取消 @@ -167,10 +170,12 @@ import { ElMessage, ElMessageBox } from "element-plus"; import { formatDate } from "@/utils/index"; import { debounce } from 'lodash'; // 引入 lodash 的防抖函数 import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue' +import RuntimeParamsEditor from '@/views/flow/components/RuntimeParamsEditor.vue' +import { getFlowParamsApi } from '@/api/device/terminal.js' import { createRuntimeAssignments, firstAssignedRobotId, - loadTaskScopedRuntimeRoles, + loadFlowItemScopedRuntimeRoles, } from '@/utils/flowExecution' const topContainerRef = ref(); @@ -183,6 +188,8 @@ const runtimeRoles = ref([]) const runtimeAssignments = ref([]) const runtimeEditorRef = ref() const runtimeMapId = ref('') +const runtimeParamItems = ref([]) +const runtimeParamsEditorRef = ref() const taskStatusMap = { '0': '已完成', @@ -330,10 +337,13 @@ const startTask = async (task) => { return } try { - const roles = await loadTaskScopedRuntimeRoles(taskDefinition.taskConfigId) + const paramsResponse = await getFlowParamsApi(taskDefinition.taskConfigId) + const paramItems = paramsResponse.rows || [] + const roles = await loadFlowItemScopedRuntimeRoles(paramItems) runtimeAssignments.value = createRuntimeAssignments(roles, task.robotIdentity) runtimeMapId.value = taskDefinition.mapId || '' runtimeRoles.value = roles + runtimeParamItems.value = paramItems pendingStartTask.value = task startDialogVisible.value = true } catch (error) { @@ -348,12 +358,18 @@ const confirmStartTask = async () => { ElMessage.warning(assignmentError) return } + const paramsValid = await runtimeParamsEditorRef.value?.validate() + if (paramsValid === false) { + ElMessage.warning('请完整填写运行参数') + return + } startSubmitting.value = true try { const robotId = firstAssignedRobotId(runtimeAssignments.value) const res = await startRunTask(pendingStartTask.value.id, { robotId, - runtimeAssignments: runtimeAssignments.value + runtimeAssignments: runtimeAssignments.value, + runParams: runtimeParamsEditorRef.value?.getRunParams() || {} }) if (res.code === 200) { ElMessage.success('任务已开始') @@ -460,7 +476,10 @@ const subscribeDebounced = debounce(async (sub) => { const callback = (data) => { if (data !== '500') { if (data.status !== 0) { - let activeStep = pointList_runningTask.value[data.taskId].findIndex(item => item.detectItemId === data.itemId) || 0 + const steps = pointList_runningTask.value[data.taskId] || [] + let activeStep = Number.isInteger(data.itemOrder) && data.itemOrder > 0 + ? data.itemOrder - 1 + : Math.max(steps.findIndex(item => item.detectItemId === data.itemId), 0) if (data.progress == 100) { activeStep += 1 } @@ -661,4 +680,15 @@ onUnmounted(() => { padding-right: 6px; overflow-y: auto; } + +.start-section-title { + margin: 16px 0 10px; + color: var(--el-text-color-primary); + font-size: 15px; + font-weight: 600; +} + +.start-section-title--params { + margin-top: 22px; +} diff --git a/src/views/intelligenceTest/runningTask/index.vue b/src/views/intelligenceTest/runningTask/index.vue index 79489a1..c4c7f37 100644 --- a/src/views/intelligenceTest/runningTask/index.vue +++ b/src/views/intelligenceTest/runningTask/index.vue @@ -151,10 +151,13 @@ - + 手机和车辆沿用任务配置,这里只安排执行流程的机器人和设备。 + 机器人和设备 + 运行参数 + 取消 @@ -186,10 +189,12 @@ import { ElMessage, ElMessageBox } from "element-plus"; import { formatDate } from "@/utils/index"; import { debounce } from 'lodash'; // 引入 lodash 的防抖函数 import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue' +import RuntimeParamsEditor from '@/views/flow/components/RuntimeParamsEditor.vue' +import { getFlowParamsApi } from '@/api/device/terminal.js' import { createRuntimeAssignments, firstAssignedRobotId, - loadTaskScopedRuntimeRoles, + loadFlowItemScopedRuntimeRoles, } from '@/utils/flowExecution' const topContainerRef = ref(); @@ -201,6 +206,8 @@ const pendingStartTask = ref(null) const runtimeRoles = ref([]) const runtimeAssignments = ref([]) const runtimeEditorRef = ref() +const runtimeParamItems = ref([]) +const runtimeParamsEditorRef = ref() const taskStatusMap = { '0': '已完成', @@ -372,9 +379,12 @@ const startTask = async (task) => { return } try { - const roles = await loadTaskScopedRuntimeRoles(taskDefinition.taskConfigId) + const paramsResponse = await getFlowParamsApi(taskDefinition.taskConfigId) + const paramItems = paramsResponse.rows || [] + const roles = await loadFlowItemScopedRuntimeRoles(paramItems) runtimeAssignments.value = createRuntimeAssignments(roles) runtimeRoles.value = roles + runtimeParamItems.value = paramItems pendingStartTask.value = task startDialogVisible.value = true } catch (error) { @@ -389,12 +399,18 @@ const confirmStartTask = async () => { ElMessage.warning(assignmentError) return } + const paramsValid = await runtimeParamsEditorRef.value?.validate() + if (paramsValid === false) { + ElMessage.warning('请完整填写运行参数') + return + } startSubmitting.value = true try { const robotId = firstAssignedRobotId(runtimeAssignments.value) const res = await startTaskinstance(pendingStartTask.value.id, { robotId, - runtimeAssignments: runtimeAssignments.value + runtimeAssignments: runtimeAssignments.value, + runParams: runtimeParamsEditorRef.value?.getRunParams() || {} }) if (res.code === 200) { ElMessage.success('任务已开始') @@ -502,7 +518,10 @@ const subscribeDebounced = debounce(async (sub) => { console.log('data', data) if (data !== '500') { if (data.status !== 0) { - let activeStep = pointList_runningTask.value[data.taskId].findIndex(item => item.detectItemId === data.itemId) || 0 + const steps = pointList_runningTask.value[data.taskId] || [] + let activeStep = Number.isInteger(data.itemOrder) && data.itemOrder > 0 + ? data.itemOrder - 1 + : Math.max(steps.findIndex(item => item.detectItemId === data.itemId), 0) if (data.progress == 100) { activeStep += 1 } @@ -714,4 +733,15 @@ onUnmounted(() => { padding-right: 6px; overflow-y: auto; } + +.start-section-title { + margin: 16px 0 10px; + color: var(--el-text-color-primary); + font-size: 15px; + font-weight: 600; +} + +.start-section-title--params { + margin-top: 22px; +} diff --git a/src/views/test/configs/Run.vue b/src/views/test/configs/Run.vue index 1ac79c6..932c7f4 100644 --- a/src/views/test/configs/Run.vue +++ b/src/views/test/configs/Run.vue @@ -124,9 +124,13 @@ const confirm = () => { .validate() .then(async () => { const runParams = {} + const occurrences = new Map() formData.value.tableData.forEach(item => { const data = formatTableData(item.config) - runParams[item.itemId] = data + const itemId = String(item.itemId) + const occurrence = (occurrences.get(itemId) || 0) + 1 + occurrences.set(itemId, occurrence) + runParams[`${itemId}:${occurrence}`] = data }) const assignmentError = runtimeEditorRef.value?.validate() if (assignmentError) {