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 3301f58..e862b4c 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) {