feat(touch): 支持检测项执行、视频报告和头颈组件
This commit is contained in:
parent
c256cd62ef
commit
8c1cde3f2a
@ -16,10 +16,11 @@ export const addProject = (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const updateProject = (data) => {
|
||||
export const updateProject = (data, params) => {
|
||||
return request({
|
||||
url: '/ti/project',
|
||||
method: 'put',
|
||||
params,
|
||||
data
|
||||
})
|
||||
}
|
||||
@ -47,6 +48,11 @@ export const getExecuteRunParams = (params) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const getProjectDetectionItems = () => request({
|
||||
url: '/ti/project/detectionItems',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const projectExecute = (data) => {
|
||||
return request({
|
||||
url: '/ti/project/execute',
|
||||
|
||||
@ -35,7 +35,8 @@ const assertCompatibleDefinitions = (roleGroups) => {
|
||||
const slotsByKey = new Map((existing.deviceSlots || []).map((slot) => [slot.slotKey, slot]))
|
||||
;(role.deviceSlots || []).forEach((slot) => {
|
||||
const existingSlot = slotsByKey.get(slot.slotKey)
|
||||
if (existingSlot && String(existingSlot.deviceKind ?? '') !== String(slot.deviceKind ?? '')) {
|
||||
if (existingSlot && (String(existingSlot.deviceKind ?? '') !== String(slot.deviceKind ?? '')
|
||||
|| existingSlot.requiredDeviceId !== slot.requiredDeviceId)) {
|
||||
throw new Error(`机器人角色“${existing.displayName}”的设备用途“${slot.displayName}”在不同流程中类型不一致`)
|
||||
}
|
||||
if (!existingSlot) existing.deviceSlots.push(clone([slot])[0])
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { getDeviceKindForAction } from '@/utils/robotDevice'
|
||||
import { getDeviceKindForAction, getRequiredDeviceIdForAction, isNeckDeviceId, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
||||
|
||||
export const FLOW_SCHEMA_VERSION = 2
|
||||
export const DEFAULT_ROLE_KEY = 'default_executor'
|
||||
@ -51,27 +51,39 @@ export const createDefaultRobotRole = (legacyRobotId = '') => ({
|
||||
...(legacyRobotId ? { legacyRobotId } : {}),
|
||||
})
|
||||
|
||||
export const createDeviceSlot = (deviceKind, existingSlots = [], displayName = '') => {
|
||||
const meta = DEVICE_KIND_META[Number(deviceKind)] || { key: 'device', name: '执行设备' }
|
||||
export const createDeviceSlot = (deviceKind, existingSlots = [], displayName = '', requiredDeviceId) => {
|
||||
const meta = requiredDeviceId === NECK_DEVICE_ID
|
||||
? { key: 'neck', name: '颈部' }
|
||||
: DEVICE_KIND_META[Number(deviceKind)] || { key: 'device', name: '执行设备' }
|
||||
const usedKeys = new Set(existingSlots.map((slot) => slot.slotKey))
|
||||
let index = 1
|
||||
let slotKey = meta.key
|
||||
while (usedKeys.has(slotKey)) slotKey = `${meta.key}_${++index}`
|
||||
const sameKindCount = existingSlots.filter((slot) => Number(slot.deviceKind) === Number(deviceKind)).length
|
||||
const sameKindCount = existingSlots.filter((slot) => (
|
||||
Number(slot.deviceKind) === Number(deviceKind) && slot.requiredDeviceId === requiredDeviceId
|
||||
)).length
|
||||
return {
|
||||
slotKey,
|
||||
displayName: displayName || `${meta.name}${sameKindCount ? sameKindCount + 1 : ''}`,
|
||||
deviceKind: deviceKind == null ? null : Number(deviceKind),
|
||||
...(requiredDeviceId ? { requiredDeviceId } : {}),
|
||||
required: true,
|
||||
allowReuse: false,
|
||||
}
|
||||
}
|
||||
|
||||
export const getStartNode = (graph = globalThis.lf?.getGraphData?.()) => (
|
||||
// Resolve the live editor in the function body so the production transform
|
||||
// preserves the receiver for the optional getGraphData call.
|
||||
const getLiveGraph = () => {
|
||||
const editor = globalThis.lf
|
||||
return editor && typeof editor.getGraphData === 'function' ? editor.getGraphData() : undefined
|
||||
}
|
||||
|
||||
export const getStartNode = (graph = getLiveGraph()) => (
|
||||
graph?.nodes?.find((node) => node.type === 'start')
|
||||
)
|
||||
|
||||
export const getResourceRoles = (graph = globalThis.lf?.getGraphData?.()) => (
|
||||
export const getResourceRoles = (graph = getLiveGraph()) => (
|
||||
clone(getStartNode(graph)?.properties?.resourceRoles || []) || []
|
||||
)
|
||||
|
||||
@ -95,6 +107,17 @@ const resolveLegacyRobotId = (startProperties) => (
|
||||
|
||||
const findOrCreateLegacySlot = (role, node, legacySlotByIdentity, legacyDeviceId = '') => {
|
||||
const kind = getDeviceKindForAction(node.properties?.action)
|
||||
const requiredDeviceId = getRequiredDeviceIdForAction(node.properties?.action)
|
||||
if (requiredDeviceId) {
|
||||
const existing = role.deviceSlots.find((slot) => (
|
||||
slot.requiredDeviceId === requiredDeviceId && Number(slot.deviceKind) === kind
|
||||
))
|
||||
if (existing) return existing
|
||||
const slot = createDeviceSlot(kind, role.deviceSlots, '', requiredDeviceId)
|
||||
slot.managedBy = FLOW_NODE_RESOURCE_OWNER
|
||||
role.deviceSlots.push(slot)
|
||||
return slot
|
||||
}
|
||||
const normalizedDeviceId = normalizedText(legacyDeviceId)
|
||||
const identity = `${role.roleKey}:${kind ?? 'any'}:${normalizedDeviceId || 'default'}`
|
||||
if (legacySlotByIdentity.has(identity)) return legacySlotByIdentity.get(identity)
|
||||
@ -176,7 +199,10 @@ export const normalizeFlowResourceSchema = (sourceGraph) => {
|
||||
role.required = role.required !== false
|
||||
role.quantity ||= { min: 1, max: 1 }
|
||||
role.deviceSlots = Array.isArray(role.deviceSlots) ? role.deviceSlots : []
|
||||
role.deviceSlots.forEach((slot) => delete slot.requiredCapabilities)
|
||||
role.deviceSlots.forEach((slot) => {
|
||||
delete slot.requiredCapabilities
|
||||
if (isNeckDeviceId(slot.requiredDeviceId)) slot.requiredDeviceId = NECK_DEVICE_ID
|
||||
})
|
||||
})
|
||||
|
||||
startProperties.schemaVersion = FLOW_SCHEMA_VERSION
|
||||
@ -186,6 +212,7 @@ export const normalizeFlowResourceSchema = (sourceGraph) => {
|
||||
const defaultRole = roles[0]
|
||||
const legacySlotByIdentity = new Map()
|
||||
roles.forEach((role) => role.deviceSlots.forEach((slot) => {
|
||||
if (slot.requiredDeviceId) return
|
||||
const identity = `${role.roleKey}:${slot.deviceKind ?? 'any'}:${slot.legacyDeviceId || 'default'}`
|
||||
legacySlotByIdentity.set(identity, slot)
|
||||
}))
|
||||
@ -215,7 +242,7 @@ export const normalizeFlowResourceSchema = (sourceGraph) => {
|
||||
const legacyDeviceId = normalizedText(properties.nodeParams
|
||||
?.find((param) => param.name === spec.parameterName)?.input)
|
||||
const matchingSlots = targetRole.deviceSlots.filter((slot) => (
|
||||
Number(slot.deviceKind) === spec.deviceKind
|
||||
!slot.requiredDeviceId && Number(slot.deviceKind) === spec.deviceKind
|
||||
&& (!legacyDeviceId || !slot.legacyDeviceId || slot.legacyDeviceId === legacyDeviceId)
|
||||
))
|
||||
let slot = matchingSlots.length === 1 ? matchingSlots[0] : null
|
||||
@ -228,7 +255,13 @@ export const normalizeFlowResourceSchema = (sourceGraph) => {
|
||||
if (slot) target.deviceBindings.push({ parameterName: spec.parameterName, slotKey: slot.slotKey })
|
||||
})
|
||||
}
|
||||
if (nodeRequiresDevice(node) && !target.deviceSlotKey) {
|
||||
const requiredDeviceId = getRequiredDeviceIdForAction(properties.action)
|
||||
const selectedSlot = targetRole.deviceSlots.find((slot) => slot.slotKey === target.deviceSlotKey)
|
||||
const needsSpecificSlot = requiredDeviceId && (
|
||||
selectedSlot?.requiredDeviceId !== requiredDeviceId
|
||||
|| Number(selectedSlot?.deviceKind) !== getDeviceKindForAction(properties.action)
|
||||
)
|
||||
if (nodeRequiresDevice(node) && (!target.deviceSlotKey || needsSpecificSlot)) {
|
||||
const slot = findOrCreateLegacySlot(targetRole, node, legacySlotByIdentity, deviceParam?.input)
|
||||
if (slot) target.deviceSlotKey = slot.slotKey
|
||||
}
|
||||
@ -484,13 +517,25 @@ export const mergeCopiedResourceRoles = (targetGraph, sourceRoles = [], copiedNo
|
||||
|
||||
// 设备用途可能只存在于来源流程,粘贴后需要映射到目标流程中可用的 slotKey。
|
||||
const remapSlot = (slotKey) => {
|
||||
if (!slotKey || targetRole.deviceSlots?.some((slot) => slot.slotKey === slotKey)) return slotKey
|
||||
if (!slotKey) return slotKey
|
||||
const sourceSlot = sourceRole?.deviceSlots?.find((slot) => slot.slotKey === slotKey)
|
||||
if (targetRole.deviceSlots?.some((slot) => (
|
||||
slot.slotKey === slotKey && slot.requiredDeviceId === sourceSlot?.requiredDeviceId
|
||||
))) return slotKey
|
||||
const sameSlot = targetRole.deviceSlots?.find((slot) => (
|
||||
sourceSlot && slot.displayName === sourceSlot.displayName && Number(slot.deviceKind) === Number(sourceSlot.deviceKind)
|
||||
&& slot.requiredDeviceId === sourceSlot.requiredDeviceId
|
||||
))
|
||||
if (sameSlot) return sameSlot.slotKey
|
||||
const newSlot = sourceSlot ? clone(sourceSlot) : createDeviceSlot(getDeviceKindForAction(node.properties?.action), targetRole.deviceSlots)
|
||||
const newSlot = sourceSlot ? clone(sourceSlot) : createDeviceSlot(
|
||||
getDeviceKindForAction(node.properties?.action),
|
||||
targetRole.deviceSlots,
|
||||
'',
|
||||
getRequiredDeviceIdForAction(node.properties?.action),
|
||||
)
|
||||
if (targetRole.deviceSlots.some((slot) => slot.slotKey === newSlot.slotKey)) {
|
||||
newSlot.slotKey = createResourceKey('device')
|
||||
}
|
||||
newSlot.managedBy = FLOW_NODE_RESOURCE_OWNER
|
||||
delete newSlot.legacyDeviceId
|
||||
targetRole.deviceSlots.push(newSlot)
|
||||
|
||||
@ -12,6 +12,9 @@ export const DEVICE_KIND = Object.freeze({
|
||||
SPEAKER: 13,
|
||||
})
|
||||
|
||||
export const NECK_DEVICE_ID = 'neck_arm'
|
||||
export const isNeckDeviceId = (deviceId) => deviceId === NECK_DEVICE_ID || deviceId === 'xiaozhao_head'
|
||||
|
||||
/**
|
||||
* 流程动作到所需设备类型的全局映射。
|
||||
* 作用范围为所有根据 action 判断执行设备的流程模块;未列出的动作视为没有固定设备类型。
|
||||
@ -25,10 +28,28 @@ export const DEVICE_KIND_BY_ACTION = Object.freeze({
|
||||
// 这样运行前的资源校验和设备下拉筛选才能为节点分配正确的机械臂终端。
|
||||
ARM_ENABLE: DEVICE_KIND.ARM,
|
||||
ARM_DISABLE: DEVICE_KIND.ARM,
|
||||
ARM_NECK_GET_INFO: DEVICE_KIND.ARM,
|
||||
ARM_NECK_GET_JOINT_STATE: DEVICE_KIND.ARM,
|
||||
ARM_NECK_GET_STATE: DEVICE_KIND.ARM,
|
||||
ARM_NECK_MOVE_J: DEVICE_KIND.ARM,
|
||||
ARM_NECK_STOP: DEVICE_KIND.ARM,
|
||||
ARM_NECK_ENABLE: DEVICE_KIND.ARM,
|
||||
ARM_NECK_DISABLE: DEVICE_KIND.ARM,
|
||||
TOUCH: DEVICE_KIND.ARM,
|
||||
BIO_HEAD_SPEAK_START: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_SPEAK_STOP: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_SPECIAL_EXPRESSION: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_GET_STATE: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_MOVE: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_HOME: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_RECONNECT: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_MODE: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_CONSTRAINTS: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_POSITION_GAIN: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_UPDATE_PERIOD: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_SET_EXPRESSION: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_PLAY_EXPRESSION: DEVICE_KIND.BIO_HEAD,
|
||||
BIO_HEAD_JOINT_CANCEL_EXPRESSION: DEVICE_KIND.BIO_HEAD,
|
||||
CAMERA_START: DEVICE_KIND.CAMERA,
|
||||
CAMERA_STOP: DEVICE_KIND.CAMERA,
|
||||
CAMERA_GETRGBIMAGE: DEVICE_KIND.CAMERA,
|
||||
@ -46,6 +67,16 @@ export const DEVICE_KIND_BY_ACTION = Object.freeze({
|
||||
*/
|
||||
export const getDeviceKindForAction = (action) => DEVICE_KIND_BY_ACTION[action]
|
||||
|
||||
export const getRequiredDeviceIdForAction = (action) => (
|
||||
typeof action === 'string' && action.startsWith('ARM_NECK_') ? NECK_DEVICE_ID : undefined
|
||||
)
|
||||
|
||||
export const deviceMatchesSlot = (device, slot) => Boolean(device?.deviceId)
|
||||
&& (slot.deviceKind == null || Number(device.deviceKind) === Number(slot.deviceKind))
|
||||
&& (!slot.requiredDeviceId || (isNeckDeviceId(slot.requiredDeviceId)
|
||||
? isNeckDeviceId(device.deviceId)
|
||||
: device.deviceId === slot.requiredDeviceId))
|
||||
|
||||
/**
|
||||
* 将机器人设备接口数据转换为 Element Plus 下拉框选项,供全局设备选择器复用。
|
||||
* 每项以 deviceId 作为值;设备名有效且不同于 ID 时展示“名称 (ID)”,否则仅展示 ID。
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
<script setup>
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
||||
import { toDeviceOptions } from '@/utils/robotDevice'
|
||||
import { deviceMatchesSlot, toDeviceOptions } from '@/utils/robotDevice'
|
||||
|
||||
/**
|
||||
* roles 来自流程起点的 resourceRoles,描述本次任务需要哪些机器人角色和设备用途。
|
||||
@ -161,11 +161,6 @@ const itemScopeOf = (role) => role.itemId == null
|
||||
? 'task'
|
||||
: `${role.itemId}:${role.itemOccurrence || 1}`
|
||||
|
||||
const deviceMatchesSlot = (device, slot) => {
|
||||
return Boolean(device?.deviceId)
|
||||
&& (slot.deviceKind == null || Number(device.deviceKind) === Number(slot.deviceKind))
|
||||
}
|
||||
|
||||
/**
|
||||
* 在不修改当前表单的前提下,为一个角色预演设备选择。
|
||||
*
|
||||
|
||||
@ -94,7 +94,7 @@ import { flowExecuteTrial } from '@/api/flow/flow'
|
||||
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
||||
import { emitter } from '@/utils/eventBus'
|
||||
import { formatTableData, getStartNodeFormData } from '@/utils/flow'
|
||||
import { toDeviceOptions } from '@/utils/robotDevice'
|
||||
import { deviceMatchesSlot, toDeviceOptions } from '@/utils/robotDevice'
|
||||
import {
|
||||
getResourceRoles,
|
||||
normalizeFlowResourceSchema,
|
||||
@ -165,9 +165,9 @@ const loadRobotOptions = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getSlotOptions = (role, slot) => toDeviceOptions((devicesByRole[role.roleKey] || []).filter((device) => (
|
||||
slot.deviceKind == null || Number(device.deviceKind) === Number(slot.deviceKind)
|
||||
)))
|
||||
const getSlotOptions = (role, slot) => toDeviceOptions(
|
||||
(devicesByRole[role.roleKey] || []).filter((device) => deviceMatchesSlot(device, slot)),
|
||||
)
|
||||
|
||||
const loadRoleDevices = async (role, preserveValues = true) => {
|
||||
const member = getMember(role)
|
||||
|
||||
@ -236,7 +236,9 @@ const stepHelperLabel = (type) => ({
|
||||
AGV_NAVIGATE_TO_STATION: '加载底盘站点',
|
||||
}[type] || '')
|
||||
const selectedRole = () => roles.value.find((role) => role.roleKey === formData.executionTarget.roleKey)
|
||||
const matchingSlots = (type) => (selectedRole()?.deviceSlots || []).filter((slot) => Number(slot.deviceKind) === deviceKindForType(type))
|
||||
const matchingSlots = (type) => (selectedRole()?.deviceSlots || []).filter((slot) => (
|
||||
!slot.requiredDeviceId && Number(slot.deviceKind) === deviceKindForType(type)
|
||||
))
|
||||
|
||||
const normalizeStep = (source = {}, index = 0) => {
|
||||
const params = { ...(defaultParams[source.type || 'DELAY'] || {}), ...(source.params || {}) }
|
||||
|
||||
@ -40,13 +40,13 @@
|
||||
:prop="`nodeParams.${index}.input`">
|
||||
<el-input-number class="param-value" v-if="property.componentType === 'number'"
|
||||
v-model="property.input" :min="property.min ?? 0" :max="property.max || Infinity"
|
||||
:controls="property?.controls || true" :step-strictly="true" :step="property.step || 1" placeholder="请输入" clearable />
|
||||
:controls="property?.controls || true" :step-strictly="property.stepStrictly ?? true" :step="property.step || 1" placeholder="请输入" clearable />
|
||||
<el-select v-model="property.input" class="param-value"
|
||||
v-else-if="property.componentType === 'select'">
|
||||
<el-option v-for="item in property.selectOptions" :key="item.value"
|
||||
:label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-input class="param-value" v-else v-model="property.input" placeholder="请输入"
|
||||
<el-input class="param-value" v-else v-model="property.input" :placeholder="property.desc || '请输入'"
|
||||
clearable />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="property.type === 'quote'"
|
||||
@ -114,7 +114,7 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="stationListLoading" @click="submitRobotForm">确认</el-button>
|
||||
<el-button type="primary" :loading="robotFormLoading" @click="submitRobotForm">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@ -128,7 +128,7 @@ import { useQuote } from './useQuote.js'
|
||||
import { getArmStatus, getArmJointState, getAgvStatus, getAgvStations } from '@/api/flow/flow'
|
||||
import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getDeviceKindForAction, toDeviceOptions } from '@/utils/robotDevice'
|
||||
import { deviceMatchesSlot, getDeviceKindForAction, getRequiredDeviceIdForAction, toDeviceOptions } from '@/utils/robotDevice'
|
||||
import { actionRequiresDevice } from '@/utils/flowResources'
|
||||
|
||||
const props = defineProps({
|
||||
@ -292,10 +292,11 @@ const loadRobotDevices = async (robotId) => {
|
||||
if (!robotId) return
|
||||
deviceLoading.value = true
|
||||
try {
|
||||
const response = await getRobotDevicesByRobotId(robotId, {
|
||||
deviceKind: getDeviceKindForAction(robotFormAction.value)
|
||||
})
|
||||
const devices = Array.isArray(response.data) ? response.data : []
|
||||
const deviceKind = getDeviceKindForAction(robotFormAction.value)
|
||||
const requiredDeviceId = getRequiredDeviceIdForAction(robotFormAction.value)
|
||||
const response = await getRobotDevicesByRobotId(robotId, { deviceKind })
|
||||
const devices = (Array.isArray(response.data) ? response.data : [])
|
||||
.filter((device) => !requiredDeviceId || deviceMatchesSlot(device, { deviceKind, requiredDeviceId }))
|
||||
deviceOptions.value = toDeviceOptions(devices)
|
||||
if (devices.length > 0) robotForm.deviceId = devices[0].deviceId
|
||||
if (devices.length === 0) ElMessage.warning('当前机器人没有匹配的在线设备')
|
||||
@ -351,8 +352,10 @@ const testRule = (property) => {
|
||||
}
|
||||
|
||||
const robotFormAction = ref()
|
||||
const stationListLoading = ref(false)
|
||||
const POSITION_ACTIONS = ['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT', 'ARM_MOVE_TO_J']
|
||||
const robotFormLoading = ref(false)
|
||||
const NECK_MOVE_ACTION = 'ARM_NECK_MOVE_J'
|
||||
const XIAOZHAO_NECK_JOINTS = ['neck-joint1', 'neck-joint2', 'neck-joint3']
|
||||
const POSITION_ACTIONS = ['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT', 'ARM_MOVE_TO_J', NECK_MOVE_ACTION]
|
||||
const isRobotNode = computed(() => props.data.properties?.nodeType === 'EDGE')
|
||||
const hasDeviceDebugAction = computed(() => (
|
||||
POSITION_ACTIONS.includes(props.data.properties.action)
|
||||
@ -360,11 +363,13 @@ const hasDeviceDebugAction = computed(() => (
|
||||
))
|
||||
const robotActionButtonText = computed(() => {
|
||||
if (props.data.properties.action === 'AGV_MOVE_TO_STATION') return '选择机器人并加载站点'
|
||||
if (props.data.properties.action === NECK_MOVE_ACTION) return '获取当前位置'
|
||||
if (POSITION_ACTIONS.includes(props.data.properties.action)) return '选择机器人并获取位置'
|
||||
return '选择机器人设备'
|
||||
})
|
||||
const robotDialogTitle = computed(() => {
|
||||
if (robotFormAction.value === 'AGV_MOVE_TO_STATION') return '选择AGV并加载站点'
|
||||
if (robotFormAction.value === NECK_MOVE_ACTION) return '读取颈部当前位置'
|
||||
if (POSITION_ACTIONS.includes(robotFormAction.value)) return '选择机器人并读取当前位置'
|
||||
return '选择机器人设备'
|
||||
})
|
||||
@ -401,7 +406,7 @@ const submitRobotForm = () => {
|
||||
} else if (robotFormAction.value === 'AGV_MOVE_TO_STATION') {
|
||||
robotFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
stationListLoading.value = true
|
||||
robotFormLoading.value = true
|
||||
try {
|
||||
const response = await getAgvStations({
|
||||
deviceId: robotForm.deviceId,
|
||||
@ -424,7 +429,7 @@ const submitRobotForm = () => {
|
||||
console.error('加载AGV站点列表失败:', error)
|
||||
ElMessage.error(error?.message || '加载AGV站点列表失败')
|
||||
} finally {
|
||||
stationListLoading.value = false
|
||||
robotFormLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -456,25 +461,51 @@ const submitRobotForm = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if (robotFormAction.value === 'ARM_MOVE_TO_J') {
|
||||
} else if (robotFormAction.value === 'ARM_MOVE_TO_J' || robotFormAction.value === NECK_MOVE_ACTION) {
|
||||
const isNeck = robotFormAction.value === NECK_MOVE_ACTION
|
||||
robotFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
const { deviceId, robotId } = robotForm
|
||||
const nodeId = props.data.id
|
||||
robotFormLoading.value = true
|
||||
try {
|
||||
const response = await getArmJointState({
|
||||
deviceId: robotForm.deviceId,
|
||||
robotId: robotForm.robotId
|
||||
})
|
||||
if (response && response.data) {
|
||||
const target = response.data.position || response.data.positions
|
||||
if (!Array.isArray(target) || target.length === 0) {
|
||||
throw new Error('机械臂未返回有效的关节位置')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
const targetParam = formData.nodeParams.find(param => param.name === 'target')
|
||||
if (targetParam) targetParam.input = JSON.stringify(target)
|
||||
const { data } = await getArmJointState({ deviceId, robotId })
|
||||
const positions = data?.position || data?.positions
|
||||
if (!Array.isArray(positions) || positions.length === 0) {
|
||||
throw new Error(isNeck ? '颈部未返回有效的关节位置' : '机械臂未返回有效的关节位置')
|
||||
}
|
||||
let target = positions
|
||||
if (isNeck) {
|
||||
const names = data?.name
|
||||
if (!Array.isArray(names) || names.length !== 3 || positions.length !== 3) {
|
||||
throw new Error('颈部反馈缺少完整的三轴关节位置')
|
||||
}
|
||||
if (deviceId === 'xiaozhao_head') {
|
||||
target = XIAOZHAO_NECK_JOINTS.map(name => positions[names.indexOf(name)])
|
||||
}
|
||||
if (new Set(names).size !== names.length
|
||||
|| !names.every(name => typeof name === 'string' && name.trim())
|
||||
|| !target.every(Number.isFinite)) {
|
||||
throw new Error('颈部反馈中的关节名称或位置无效')
|
||||
}
|
||||
}
|
||||
if (!dialogVisible.value || props.data.id !== nodeId
|
||||
|| robotForm.deviceId !== deviceId || robotForm.robotId !== robotId) return
|
||||
const targetParam = formData.nodeParams.find(param => param.name === 'target')
|
||||
if (targetParam) {
|
||||
if (isNeck) {
|
||||
targetParam.type = 'input'
|
||||
targetParam.quote = []
|
||||
delete targetParam.quoteType
|
||||
}
|
||||
targetParam.input = JSON.stringify(target)
|
||||
}
|
||||
dialogVisible.value = false
|
||||
} catch (error) {
|
||||
console.error('获取机械臂关节位置失败:', error)
|
||||
console.error('获取关节位置失败:', error)
|
||||
if (isNeck) ElMessage.error(error?.message || '读取颈部当前位置失败')
|
||||
} finally {
|
||||
robotFormLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { getDeviceKindForAction } from '@/utils/robotDevice'
|
||||
import { getDeviceKindForAction, getRequiredDeviceIdForAction } from '@/utils/robotDevice'
|
||||
import { actionRequiresDevice, getDeviceKindName, getResourceRoles } from '@/utils/flowResources'
|
||||
|
||||
const props = defineProps({
|
||||
@ -53,11 +53,13 @@ const hasDeviceParameter = computed(() => (
|
||||
actionRequiresDevice(props.data.properties?.action)
|
||||
))
|
||||
const requiredDeviceKind = computed(() => getDeviceKindForAction(props.data.properties?.action))
|
||||
const requiredDeviceId = computed(() => getRequiredDeviceIdForAction(props.data.properties?.action))
|
||||
const selectedRole = computed(() => roles.value.find((role) => role.roleKey === localTarget.roleKey))
|
||||
const matchingSlots = computed(() => (selectedRole.value?.deviceSlots || []).filter((slot) => (
|
||||
requiredDeviceKind.value == null
|
||||
|| slot.deviceKind == null
|
||||
|| Number(slot.deviceKind) === Number(requiredDeviceKind.value)
|
||||
slot.requiredDeviceId === requiredDeviceId.value
|
||||
&& (requiredDeviceKind.value == null
|
||||
|| slot.deviceKind == null
|
||||
|| Number(slot.deviceKind) === Number(requiredDeviceKind.value))
|
||||
)))
|
||||
|
||||
const emitTarget = () => {
|
||||
|
||||
@ -19,12 +19,16 @@
|
||||
<div v-if="!role.deviceSlots.length" class="empty-tip">当前角色暂不需要设备</div>
|
||||
<div v-for="(slot, slotIndex) in role.deviceSlots" :key="slot.slotKey" class="device-row">
|
||||
<el-input v-model="slot.displayName" maxlength="30" placeholder="例如:前方摄像头" />
|
||||
<el-select v-model="slot.deviceKind" placeholder="设备类型">
|
||||
<el-select v-model="slot.deviceKind" placeholder="设备类型" :disabled="Boolean(slot.requiredDeviceId)">
|
||||
<el-option v-for="item in deviceKinds" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button circle :icon="Minus" aria-label="删除设备用途" @click="deleteDeviceSlot(role, slotIndex)" />
|
||||
</div>
|
||||
<el-button text type="primary" :icon="Plus" @click="addDeviceSlot(role)">添加设备用途</el-button>
|
||||
<el-button
|
||||
v-if="!role.deviceSlots.some((slot) => slot.requiredDeviceId === NECK_DEVICE_ID)"
|
||||
text type="primary" :icon="Plus" @click="addDeviceSlot(role, NECK_DEVICE_ID)"
|
||||
>添加颈部用途</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" plain :icon="Plus" @click="addRole">添加机器人角色</el-button>
|
||||
@ -64,6 +68,7 @@ import { reactive, ref, watch } from 'vue'
|
||||
import { Delete, Minus, Plus } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||
import { DEVICE_KIND, NECK_DEVICE_ID } from '@/utils/robotDevice'
|
||||
import {
|
||||
createDefaultRobotRole,
|
||||
createDeviceSlot,
|
||||
@ -98,9 +103,9 @@ const addRole = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const addDeviceSlot = (role) => {
|
||||
const addDeviceSlot = (role, requiredDeviceId) => {
|
||||
role.deviceSlots.push({
|
||||
...createDeviceSlot(null, role.deviceSlots),
|
||||
...createDeviceSlot(requiredDeviceId ? DEVICE_KIND.ARM : null, role.deviceSlots, '', requiredDeviceId),
|
||||
managedBy: USER_RESOURCE_OWNER,
|
||||
})
|
||||
}
|
||||
|
||||
@ -241,7 +241,9 @@ const form = reactive({
|
||||
const resource = reactive({ roleKey: '', cameraSlotKey: '', armSlotKey: '' })
|
||||
const selectedRole = computed(() => roles.value.find(role => role.roleKey === resource.roleKey))
|
||||
const cameraSlots = computed(() => (selectedRole.value?.deviceSlots || []).filter(slot => Number(slot.deviceKind) === DEVICE_KIND.CAMERA))
|
||||
const armSlots = computed(() => (selectedRole.value?.deviceSlots || []).filter(slot => Number(slot.deviceKind) === DEVICE_KIND.ARM))
|
||||
const armSlots = computed(() => (selectedRole.value?.deviceSlots || []).filter(slot => (
|
||||
!slot.requiredDeviceId && Number(slot.deviceKind) === DEVICE_KIND.ARM
|
||||
)))
|
||||
const configModeDescription = computed(() => configMode.value === 'BASIC'
|
||||
? '选择设备、工具和目标即可,标定矩阵由系统自动匹配。'
|
||||
: '用于调整识别、平面拟合和异常距离校验。')
|
||||
|
||||
@ -50,6 +50,80 @@ const httpMethodOptions = () => {
|
||||
/**
|
||||
* 处理与 express options 相关的状态或数据,该影响范围仅限当前模块。
|
||||
*/
|
||||
const headParam = (name, input = '', desc = '') => ({
|
||||
name, type: 'input', input, desc, disabled: true,
|
||||
})
|
||||
const headNumber = (name, desc = '') => ({
|
||||
...headParam(name, undefined, desc), input: undefined, componentType: 'number', step: 0.01, stepStrictly: false,
|
||||
})
|
||||
const headDuration = () => ({
|
||||
...headNumber('transitionDurationS', '秒'), input: 0.5, min: 0.2, max: 5,
|
||||
})
|
||||
const headOutput = ([name, type, desc]) => ({ name, type, desc, disabled: true })
|
||||
const headJointNodes = [
|
||||
{ name: '查询头部关节状态', action: 'BIO_HEAD_JOINT_GET_STATE', desc: '读取关节配置、最近确认的目标和预设表情', nodeParams: [],
|
||||
outputParams: [["connected","boolean","串口连接状态"],["jointInfo","array<object>","关节配置与限位"],["targets","array<object>","最近获确认的命令目标"],["lastCommandOutcome","string","最近命令结果"],["lastError","string","最近错误"],["positionFeedbackAvailable","boolean","是否提供真实位置反馈"],["expressions","array<object>","配置中的预设表情"],["expressionBaselineReady","boolean","表情过渡基准是否就绪"],["hardwareEmergencyStopAvailable","boolean","是否有硬件急停"]].map(headOutput) },
|
||||
{ name: '头部关节运动', action: 'BIO_HEAD_JOINT_MOVE', desc: '向指定关节下发弧度目标,确认不代表机械到位', nodeParams: [headParam('targets', '', 'JSON 数组,例如 [{"id":"关节ID","positionRad":0}]')] },
|
||||
{ name: '头部关节回零', action: 'BIO_HEAD_JOINT_HOME', desc: '移动到设备配置的 home 位置', nodeParams: [] },
|
||||
{ name: '重连头部设备', action: 'BIO_HEAD_JOINT_RECONNECT', desc: '重开连接并探测设备,不下发位置目标', nodeParams: [] },
|
||||
{ name: '设置头部运动模式', action: 'BIO_HEAD_JOINT_MODE', desc: '选择立即、S 曲线或跟随', nodeParams: [{ ...headParam('mode', 0), componentType: 'select', selectOptions: [{ label: '立即', value: 0 }, { label: 'S 曲线', value: 1 }, { label: '跟随', value: 2 }] }] },
|
||||
{ name: '设置头部关节约束', action: 'BIO_HEAD_JOINT_CONSTRAINTS', desc: '设置关节最大速度、加速度与加加速度', nodeParams: [headParam('id'), headNumber('maxVelocityRadS', 'rad/s'), headNumber('maxAccelerationRadS2', 'rad/s²'), headNumber('maxJerkRadS3', 'rad/s³')] },
|
||||
{ name: '设置头部位置增益', action: 'BIO_HEAD_JOINT_POSITION_GAIN', desc: '设置指定关节的增益,0 是有效值', nodeParams: [headParam('id'), headParam('gain', '', '输入增益,0 是有效值')] },
|
||||
{ name: '设置头部更新周期', action: 'BIO_HEAD_JOINT_UPDATE_PERIOD', desc: '设置设备更新周期,单位毫秒', nodeParams: [{ ...headNumber('periodMs', 'ms'), step: 1, min: 1, max: 4294967295 }] },
|
||||
{ name: '设置头部关节表情', action: 'BIO_HEAD_JOINT_SET_EXPRESSION', desc: '过渡到完整的五关节目标', nodeParams: [headParam('targets', '', '五个不同关节组成的 JSON 数组,包含 id 和 positionRad'), headDuration()] },
|
||||
{ name: '播放头部预设表情', action: 'BIO_HEAD_JOINT_PLAY_EXPRESSION', desc: '精确使用预设 ID 或名称,两者只填一个', nodeParams: [{ ...headParam('expressionId', '', 'ID 与名称只填一个'), required: false }, { ...headParam('expressionName', '', 'ID 与名称只填一个'), required: false }, headDuration()],
|
||||
outputParams: [['expressionId', 'string', '预设 ID'], ['expressionName', 'string', '预设名称']].map(headOutput) },
|
||||
{ name: '取消后续头部表情帧', action: 'BIO_HEAD_JOINT_CANCEL_EXPRESSION', desc: '取消尚未发送的表情帧,不会停止已下发的动作', nodeParams: [] },
|
||||
].map(node => ({ icon: expressionSvg, type: 'serviceNode', nodeType: 'EDGE', outputType: 'json', ...node }))
|
||||
|
||||
const neckNodes = [
|
||||
{
|
||||
name: '查询颈部关节配置', action: 'ARM_NECK_GET_INFO', desc: '读取设备型号、关节顺序和可用的位置限位',
|
||||
outputParams: [
|
||||
['deviceId', 'string', '设备 ID'], ['model', 'string', '型号'], ['dof', 'number', '关节数'],
|
||||
['jointNames', 'array<string>', '关节顺序'],
|
||||
].map(headOutput).concat({
|
||||
...headOutput(['jointLimits', 'array<object>', '关节限位']),
|
||||
children: [
|
||||
['jointName', 'string', '关节名称'], ['available', 'boolean', '限位是否可用'],
|
||||
['lowerRad', 'number', '下限(rad)'], ['upperRad', 'number', '上限(rad)'],
|
||||
['source', 'string', '限位来源'],
|
||||
].map(headOutput),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: '查询颈部关节状态', action: 'ARM_NECK_GET_JOINT_STATE', desc: '读取三个关节的实际角度和反馈',
|
||||
outputParams: [
|
||||
['jointNames', 'array<string>', '关节顺序'], ['positionRad', 'array<number>', '角度(rad)'],
|
||||
['velocityRadS', 'array<number>', '角速度(rad/s)'], ['effortNm', 'array<number>', '力矩(N·m)'],
|
||||
['currentMa', 'array<number>', '电流(mA)'], ['timestampS', 'number', '边端读取时间(Unix 秒)'],
|
||||
].map(headOutput),
|
||||
},
|
||||
{
|
||||
name: '查询颈部运行状态', action: 'ARM_NECK_GET_STATE', desc: '读取连接、上电、运行和保护状态',
|
||||
outputParams: [
|
||||
['connected', 'boolean', '已连接'], ['poweredOn', 'boolean', '已上电'], ['moving', 'boolean', '运动中'],
|
||||
['fault', 'boolean', '故障'], ['protectiveStopped', 'boolean', '保护停止'],
|
||||
['emergencyStopped', 'boolean', '急停状态'], ['robotMode', 'string', '运行模式'],
|
||||
['safetyMode', 'string', '安全模式'], ['controlMode', 'string', '控制模式'],
|
||||
].map(headOutput),
|
||||
},
|
||||
{
|
||||
name: '颈部三轴关节运动', action: 'ARM_NECK_MOVE_J', desc: '按设备上报的关节顺序填写三个目标角度(rad)',
|
||||
nodeParams: [
|
||||
{ ...headParam('target', '', '按设备关节顺序填写三个弧度值组成的 JSON 数组'), required: true },
|
||||
{ ...headNumber('velocity', '可选,rad/s'), input: 0.25 },
|
||||
{ ...headNumber('acceleration', '可选,rad/s²'), input: 0.5 },
|
||||
],
|
||||
},
|
||||
{ name: '停止颈部运动', action: 'ARM_NECK_STOP', desc: '请求边端停止当前颈部运动' },
|
||||
{ name: '开启颈部使能', action: 'ARM_NECK_ENABLE', desc: '调用边端为颈部设备上电并使能' },
|
||||
{ name: '关闭颈部使能', action: 'ARM_NECK_DISABLE', desc: '调用边端关闭颈部设备使能' },
|
||||
].map(node => ({
|
||||
icon: expressionSvg, type: 'serviceNode', nodeType: 'EDGE', outputType: 'json',
|
||||
nodeParams: [], outputParams: [], ...node,
|
||||
}))
|
||||
|
||||
const expressOptions = () => {
|
||||
return [{
|
||||
value: 1,
|
||||
@ -514,6 +588,7 @@ function handler(params) {
|
||||
},
|
||||
],
|
||||
},
|
||||
{ collapseTitle: '颈部', nodeList: neckNodes },
|
||||
{
|
||||
collapseTitle: "音频",
|
||||
nodeList: [
|
||||
@ -752,6 +827,7 @@ function handler(params) {
|
||||
],
|
||||
outputType: 'json',
|
||||
},
|
||||
...headJointNodes,
|
||||
{
|
||||
icon: touchSvg,
|
||||
name: "路径搜索",
|
||||
|
||||
@ -285,10 +285,10 @@
|
||||
<el-input-number
|
||||
v-if="field.param.componentType === 'number'"
|
||||
v-model="field.param.input"
|
||||
:min="0"
|
||||
:min="field.param.min ?? 0"
|
||||
:max="field.param.max || Infinity"
|
||||
:step="field.param.step || 1"
|
||||
:step-strictly="true"
|
||||
:step-strictly="field.param.stepStrictly ?? true"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
/>
|
||||
@ -364,7 +364,7 @@
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, reactive, ref, watch, onMounted, onUnmounted, nextTick } from "vue";
|
||||
import { computed, h, reactive, ref, watch, onMounted, onUnmounted, nextTick } from "vue";
|
||||
import { MarkerType, VueFlow, useVueFlow } from "@vue-flow/core";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { Background } from "@vue-flow/background";
|
||||
@ -2329,7 +2329,16 @@ const execute = async () => {
|
||||
: buildSingleNodePayload(formData.nodeParams),
|
||||
});
|
||||
if (res.code === 200) {
|
||||
ElMessage.success("执行成功");
|
||||
if (['BIO_HEAD_JOINT_GET_STATE', 'BIO_HEAD_JOINT_PLAY_EXPRESSION'].includes(nodeAction.value)) {
|
||||
let result = res.data;
|
||||
if (typeof result === 'string') {
|
||||
try { result = JSON.parse(result); } catch { /* display the returned text */ }
|
||||
}
|
||||
await ElMessageBox.alert(h('pre', { style: 'max-height: 50vh; overflow: auto; white-space: pre-wrap' },
|
||||
typeof result === 'string' ? result : JSON.stringify(result, null, 2)), '头部执行结果');
|
||||
} else {
|
||||
ElMessage.success("执行成功");
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.msg);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="props.drawer" title="执行" :before-close="handleClose">
|
||||
<el-drawer :model-value="props.drawer" title="执行" :before-close="handleClose">
|
||||
<el-form
|
||||
ref="ruleFormRef"
|
||||
style="max-width: 600px"
|
||||
@ -7,8 +7,17 @@
|
||||
:rules="rules"
|
||||
label-width="auto"
|
||||
>
|
||||
<div class="run-section-title">本次执行安排</div>
|
||||
<RuntimeAssignmentsEditor ref="runtimeEditorRef" v-model="runtimeAssignments" :roles="roles" />
|
||||
<el-form-item label="检测项" required>
|
||||
<el-select v-model="selectedItemId" filterable placeholder="请选择已发布的检测项"
|
||||
:loading="loadingItems" :disabled="submitting" style="width: 100%" @change="loadSelection">
|
||||
<el-option v-for="item in items" :key="item.itemId" :value="item.itemId"
|
||||
:label="`${item.itemName} · V${item.versionNo}`" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-empty v-if="!loadingItems && !items.length" description="暂无启用且已发布的检测项" />
|
||||
<template v-if="preparedItem">
|
||||
<div v-if="roles.length" class="run-section-title">本次执行安排</div>
|
||||
<RuntimeAssignmentsEditor v-if="roles.length" ref="runtimeEditorRef" v-model="runtimeAssignments" :roles="roles" />
|
||||
<div class="run-section-title run-section-title--params">运行参数</div>
|
||||
<el-table
|
||||
:data="formData.tableData"
|
||||
@ -56,10 +65,11 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="方案名称" prop="itemName" />
|
||||
</el-table>
|
||||
</template>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">关闭</el-button>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
<el-button :disabled="submitting" @click="handleClose">关闭</el-button>
|
||||
<el-button type="primary" :loading="submitting" :disabled="!preparedItem || loadingSelection" @click="confirm">开始执行</el-button>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
@ -67,12 +77,11 @@
|
||||
import { ref, watch } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { addValueProperty, formatTableData } from "@/utils/flow";
|
||||
import { getExecuteRunParams, projectExecute } from "@/api/is/project/index.js";
|
||||
import { getProjectDetectionItems, projectExecute } from "@/api/is/project/index.js";
|
||||
import { flowVersionDetail } from '@/api/flow/flow'
|
||||
import RuntimeAssignmentsEditor from '@/views/flow/components/RuntimeAssignmentsEditor.vue'
|
||||
import {
|
||||
firstAssignedRobotId,
|
||||
loadFlowItemRuntimeRoles,
|
||||
} from '@/utils/flowExecution'
|
||||
import { firstAssignedRobotId } from '@/utils/flowExecution'
|
||||
import { getResourceRoles, normalizeFlowResourceSchema, validateFlowResources } from '@/utils/flowResources'
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
@ -91,76 +100,98 @@ const formData = ref({
|
||||
const roles = ref([])
|
||||
const runtimeAssignments = ref([])
|
||||
const runtimeEditorRef = ref()
|
||||
const items = ref([])
|
||||
const selectedItemId = ref('')
|
||||
const preparedItem = ref(null)
|
||||
const loadingItems = ref(false)
|
||||
const loadingSelection = ref(false)
|
||||
const submitting = ref(false)
|
||||
let selectionRequest = 0
|
||||
let listRequest = 0
|
||||
|
||||
const getProjectParams = async () => {
|
||||
const res = await getExecuteRunParams({ projectId: props.projectId });
|
||||
if (res.code === 200) {
|
||||
const data = parseConfig(res.data)
|
||||
formData.value.tableData = data
|
||||
runtimeAssignments.value = []
|
||||
roles.value = await loadFlowItemRuntimeRoles(data)
|
||||
}
|
||||
};
|
||||
|
||||
const parseConfig = (arr) => {
|
||||
arr.forEach(item => {
|
||||
if (item.config) {
|
||||
item.config = addValueProperty(JSON.parse(item.config), item.schemeId)
|
||||
} else {
|
||||
item.config = []
|
||||
}
|
||||
})
|
||||
return arr
|
||||
const clearSelection = () => {
|
||||
preparedItem.value = null
|
||||
roles.value = []
|
||||
runtimeAssignments.value = []
|
||||
formData.value.tableData = []
|
||||
}
|
||||
|
||||
const confirm = () => {
|
||||
ruleFormRef.value
|
||||
.validate()
|
||||
.then(async () => {
|
||||
const runParams = {}
|
||||
formData.value.tableData.forEach(item => {
|
||||
const data = formatTableData(item.config)
|
||||
runParams[item.itemId] = data
|
||||
})
|
||||
const assignmentError = runtimeEditorRef.value?.validate()
|
||||
if (assignmentError) {
|
||||
ElMessage.warning(assignmentError)
|
||||
return
|
||||
}
|
||||
const robotId = firstAssignedRobotId(runtimeAssignments.value)
|
||||
const res = await projectExecute({
|
||||
runParams,
|
||||
projectId: props.projectId,
|
||||
robotId,
|
||||
runtimeAssignments: runtimeAssignments.value
|
||||
})
|
||||
if (res.code === 200) {
|
||||
ruleFormRef.value.resetFields();
|
||||
ElMessage.success(`任务已启动,执行实例:${res.data}`)
|
||||
emits("close");
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
const loadSelection = async (itemId) => {
|
||||
const requestId = ++selectionRequest
|
||||
clearSelection()
|
||||
const item = items.value.find(option => option.itemId === itemId)
|
||||
if (!item) return
|
||||
loadingSelection.value = true
|
||||
try {
|
||||
const response = await flowVersionDetail(item.versionId)
|
||||
if (requestId !== selectionRequest) return
|
||||
const version = response.data
|
||||
if (!version?.flowData) throw new Error('此发布版本没有工作流定义')
|
||||
const graph = normalizeFlowResourceSchema(JSON.parse(version.flowData))
|
||||
const validation = validateFlowResources(graph)
|
||||
if (validation.errors.length) throw new Error(validation.errors[0].message)
|
||||
const config = version.config ? addValueProperty(JSON.parse(version.config)) : []
|
||||
roles.value = getResourceRoles(validation.graph)
|
||||
formData.value.tableData = [{ ...item, config }]
|
||||
preparedItem.value = item
|
||||
} catch (error) {
|
||||
if (requestId === selectionRequest) ElMessage.error(error.message || '无法加载检测项发布版本')
|
||||
} finally {
|
||||
if (requestId === selectionRequest) loadingSelection.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const confirm = async () => {
|
||||
if (submitting.value || !preparedItem.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
if (!await ruleFormRef.value.validate().catch(() => false)) return
|
||||
const assignmentError = runtimeEditorRef.value?.validate()
|
||||
if (assignmentError) {
|
||||
ElMessage.warning(assignmentError)
|
||||
return
|
||||
}
|
||||
const { itemId, versionId } = preparedItem.value
|
||||
const res = await projectExecute({
|
||||
projectId: props.projectId,
|
||||
itemId,
|
||||
versionId,
|
||||
runParams: { [itemId]: formatTableData(formData.value.tableData[0].config) },
|
||||
robotId: firstAssignedRobotId(runtimeAssignments.value),
|
||||
runtimeAssignments: runtimeAssignments.value
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
if (res.code !== 200) throw new Error(res.msg)
|
||||
ElMessage.success(`任务已启动,执行实例:${res.data}`)
|
||||
emits('close')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '启动检测项失败')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
ruleFormRef.value.resetFields();
|
||||
emits("close");
|
||||
if (!submitting.value) emits("close");
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.drawer,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
getProjectParams().catch((error) => {
|
||||
roles.value = []
|
||||
runtimeAssignments.value = []
|
||||
ElMessage.error(error.message || '工作流执行资源加载失败')
|
||||
})
|
||||
async (open) => {
|
||||
const requestId = ++listRequest
|
||||
++selectionRequest
|
||||
loadingSelection.value = false
|
||||
selectedItemId.value = ''
|
||||
items.value = []
|
||||
clearSelection()
|
||||
loadingItems.value = open
|
||||
if (!open) return
|
||||
try {
|
||||
const res = await getProjectDetectionItems()
|
||||
if (requestId === listRequest) items.value = res.data || []
|
||||
} catch (error) {
|
||||
if (requestId === listRequest) ElMessage.error(error.message || '检测项加载失败')
|
||||
} finally {
|
||||
if (requestId === listRequest) loadingItems.value = false
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<div class="report-item">总数:{{ reportData?.totalCount ?? '--' }}</div>
|
||||
<div class="report-item report-item--success">通过:{{ reportData?.successCount ?? '--' }}</div>
|
||||
<div class="report-item report-item--failed">失败:{{ reportData?.failureCount ?? '--' }}</div>
|
||||
<div v-if="isVideoReport" class="report-item report-item--failed">分析异常:{{ reportData.analysisErrorCount }}</div>
|
||||
<div class="report-item">
|
||||
成功率:{{ reportData?.successRate == null ? '--' : `${reportData.successRate}%` }}
|
||||
</div>
|
||||
@ -16,6 +17,10 @@
|
||||
|
||||
<el-descriptions v-if="reportData" :column="2" border class="execution-summary">
|
||||
<el-descriptions-item label="执行实例">{{ reportData.instId }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="isVideoReport" label="检测项">
|
||||
{{ reportData.detectionItemName }}
|
||||
<span v-if="reportData.workflowVersionNo != null"> · V{{ reportData.workflowVersionNo }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="执行状态">
|
||||
{{ executionStatusText[reportData.executionStatus] || reportData.executionStatus }}
|
||||
</el-descriptions-item>
|
||||
@ -23,9 +28,28 @@
|
||||
<el-descriptions-item label="结束时间">{{ formatTime(reportData.endTime) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-table v-loading="loading" :data="tableData" style="width: 100%">
|
||||
<el-table v-loading="loading" :data="tableData" row-key="aeId"
|
||||
:empty-text="isVideoReport ? '本次执行暂无视频分析结果' : '暂无测试结果'" style="width: 100%">
|
||||
<el-table-column v-if="isVideoReport" type="expand">
|
||||
<template #default="{ row }">
|
||||
<div class="analysis-evidence">
|
||||
<div><strong>通过标准</strong><p>{{ row.expectedResult || '未配置' }}</p></div>
|
||||
<div><strong>实际结论</strong><p>{{ row.executionDetail || row.failureReason || '—' }}</p></div>
|
||||
<div v-if="row.modelName"><strong>模型</strong><p>{{ row.modelName }}</p></div>
|
||||
<div v-if="row.videoEvents?.length">
|
||||
<strong>关键时间段</strong>
|
||||
<ul>
|
||||
<li v-for="(event, index) in row.videoEvents" :key="index">
|
||||
{{ event.timeRange }} {{ event.event }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="aeId" width="150" show-overflow-tooltip label="结果ID" />
|
||||
<el-table-column prop="content" label="功能" width="220" show-overflow-tooltip />
|
||||
<el-table-column prop="content" :label="isVideoReport ? '分析节点' : '功能'" width="220" show-overflow-tooltip />
|
||||
<el-table-column v-if="isVideoReport" prop="iteration" label="轮次" width="90" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusType[row.status] || 'info'">
|
||||
@ -46,7 +70,7 @@
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="itemResponseTime" label="响应时间(ms)" width="130">
|
||||
<el-table-column prop="itemResponseTime" :label="isVideoReport ? '分析耗时(ms)' : '响应时间(ms)'" width="138">
|
||||
<template #default="{ row }">{{ row.itemResponseTime ?? '--' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="failureReason" label="失败原因" min-width="180" show-overflow-tooltip>
|
||||
@ -79,13 +103,15 @@ try {
|
||||
const tableData = ref([])
|
||||
const reportData = ref(null)
|
||||
const loading = ref(false)
|
||||
const isVideoReport = computed(() => reportData.value?.analysisErrorCount != null)
|
||||
|
||||
const statusType = {
|
||||
0: 'info',
|
||||
1: 'warning',
|
||||
2: 'success',
|
||||
3: 'danger',
|
||||
4: 'danger'
|
||||
4: 'danger',
|
||||
5: 'warning'
|
||||
}
|
||||
|
||||
const statusTypeContext = {
|
||||
@ -93,7 +119,8 @@ const statusTypeContext = {
|
||||
1: '执行中',
|
||||
2: '通过',
|
||||
3: '失败',
|
||||
4: '失败'
|
||||
4: '失败',
|
||||
5: '分析异常'
|
||||
}
|
||||
|
||||
const executionStatusText = {
|
||||
@ -107,7 +134,7 @@ const executionStatusText = {
|
||||
const getReport = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getValuationProject(projectData.projectId, route.query.instId)
|
||||
const res = await getValuationProject(route.params.id || projectData.projectId, route.query.instId)
|
||||
if (res.code === 200) {
|
||||
reportData.value = res.data
|
||||
tableData.value = res.data?.itemDetails || []
|
||||
@ -136,6 +163,12 @@ onMounted(getReport)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.analysis-evidence {
|
||||
padding: 12px 24px;
|
||||
p { margin: 5px 0 12px; white-space: pre-wrap; }
|
||||
ul { margin: 6px 0 0; padding-left: 20px; }
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@ -10,23 +10,7 @@
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">测试人员:</div>
|
||||
<div class="text">{{ infoData.tester }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">计划测试时间:</div>
|
||||
<div class="text">{{ parseTime(infoData.planStart) }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">样品名称:</div>
|
||||
<div class="text" :title="infoData.sampleName">{{ infoData.sampleName }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">委托单位:</div>
|
||||
<div class="text">{{ infoData.entrustUnit }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">送样日期:</div>
|
||||
<div class="text">{{ parseTime(infoData.sampleDate) }}</div>
|
||||
<div class="text">{{ infoData.tester || '—' }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="label">项目描述:</div>
|
||||
|
||||
@ -78,26 +78,6 @@
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="测试人员" align="center" prop="tester" />
|
||||
<el-table-column
|
||||
label="计划测试开始时间"
|
||||
align="center"
|
||||
prop="planStart"
|
||||
width="180"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ parseTime(row.planStart) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="计划测试结束时间"
|
||||
align="center"
|
||||
prop="planEnd"
|
||||
width="180"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ parseTime(row.planEnd) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="项目描述"
|
||||
width="200"
|
||||
@ -191,6 +171,7 @@
|
||||
node-key="id"
|
||||
:data="treeData"
|
||||
:render-after-expand="false"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@change="vehicleConfigChange"
|
||||
/>
|
||||
@ -201,6 +182,7 @@
|
||||
<el-select
|
||||
v-model="form.testFuncIds"
|
||||
:multiple="true"
|
||||
:disabled="!form.vehicleConfigId"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
@ -217,45 +199,11 @@
|
||||
<el-input v-model="form.tester" placeholder="请输入测试人员" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计划开始时间" prop="planStart">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.planStart"
|
||||
type="datetime"
|
||||
placeholder="请选择计划测试开始时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计划结束时间" prop="planEnd">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.planEnd"
|
||||
type="datetime"
|
||||
placeholder="请选择计划测试结束时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="form.sort" placeholder="排序" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="评价指标" prop="indicatorId">
|
||||
<el-tree-select
|
||||
v-model="form.indicatorId"
|
||||
:data="indicatorData"
|
||||
:props="{ label: 'name', value: 'id', children: 'children' }"
|
||||
:render-after-expand="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="项目描述" prop="remark">
|
||||
<el-input
|
||||
@ -267,70 +215,6 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="form-title">样品信息</div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="样品名称" prop="sampleName">
|
||||
<el-input v-model="form.sampleName" placeholder="请输入样品名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商标" prop="trademark">
|
||||
<el-input v-model="form.trademark" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="型号规格" prop="modelSpec">
|
||||
<el-input v-model="form.modelSpec" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="样品数量" prop="quantity">
|
||||
<el-input-number
|
||||
v-model="form.quantity"
|
||||
:min="1"
|
||||
:step="1"
|
||||
:step-strictly="true"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="委托单位" prop="entrustUnit">
|
||||
<el-input v-model="form.entrustUnit" placeholder="请输入委托单位" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="生产单位" prop="productionUnit">
|
||||
<el-input v-model="form.productionUnit" placeholder="请输入生产单位" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="送样日期" prop="sampleDate">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.sampleDate"
|
||||
type="datetime"
|
||||
placeholder="请选择送样日期"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="生产日期" prop="productionDate">
|
||||
<el-date-picker
|
||||
clearable
|
||||
v-model="form.productionDate"
|
||||
type="datetime"
|
||||
placeholder="请选择生产日期"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@ -383,7 +267,6 @@ import TableSearch from "@/components/TableSearch/index.vue";
|
||||
import { useContainerHeight } from "@/hooks/tableHeight";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { getTreeDataApi } from '@/api/is/func/index'
|
||||
import { getChildrenByParentIdWithLevelLimitApi } from "@/api/evaluate/indicator.js";
|
||||
import { getFunction } from "@/api/is/func/index.js";
|
||||
import {
|
||||
addProject,
|
||||
@ -413,22 +296,11 @@ const data = reactive({
|
||||
form: {
|
||||
projectName: null,
|
||||
tester: null,
|
||||
planStart: null,
|
||||
vehicleConfigId: null,
|
||||
testFuncIds: null,
|
||||
indicatorId: null,
|
||||
planEnd: null,
|
||||
sort: null,
|
||||
remark: null,
|
||||
status: null,
|
||||
sampleName: null,
|
||||
trademark: null,
|
||||
modelSpec: null,
|
||||
quantity: null,
|
||||
entrustUnit: null,
|
||||
productionUnit: null,
|
||||
sampleDate: null,
|
||||
productionDate: null,
|
||||
},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@ -436,23 +308,7 @@ const data = reactive({
|
||||
projectName: null,
|
||||
},
|
||||
rules: {
|
||||
projectName: [{ required: true, message: "项目名称不能为空", trigger: "blur" }],
|
||||
tester: [{ required: true, message: "请输入测试人员", trigger: "blur" }],
|
||||
planStart: [{ required: true, message: "请输入计划测试开始时间", trigger: "blur" }],
|
||||
planEnd: [{ required: true, message: "请输入计划测试结束时间", trigger: "blur" }],
|
||||
vehicleConfigId: [{ required: true, message: "请选择车机版本", trigger: "blur" }],
|
||||
testFuncIds: [{ required: true, message: "请选择功能", trigger: "blur" }],
|
||||
indicatorId: [{ required: true, message: "请选择评价指标", trigger: "blur" }],
|
||||
sampleName: [{ required: true, message: "请输入样品名称", trigger: "blur" }],
|
||||
trademark: [{ required: true, message: "请输入样品商标", trigger: "blur" }],
|
||||
modelSpec: [{ required: true, message: "请输入样品型号规格", trigger: "blur" }],
|
||||
entrustUnit: [{ required: true, message: "请输入样品委托单位", trigger: "blur" }],
|
||||
productionUnit: [{ required: true, message: "请输入样品生产单位", trigger: "blur" }],
|
||||
quantity: [
|
||||
{ required: true, message: "请输入样品数量" },
|
||||
{ type: 'number', message: '请输入样品数量' },],
|
||||
sampleDate: [{ required: true, message: "请输入样品送达日期", trigger: "blur" }],
|
||||
productionDate: [{ required: true, message: "请输入样品生产日期", trigger: "blur" }],
|
||||
projectName: [{ required: true, whitespace: true, message: "项目名称不能为空", trigger: "blur" }],
|
||||
},
|
||||
});
|
||||
|
||||
@ -514,22 +370,11 @@ function reset() {
|
||||
projectId: null,
|
||||
projectName: null,
|
||||
tester: null,
|
||||
planStart: null,
|
||||
planEnd: null,
|
||||
vehicleConfigId: null,
|
||||
testFuncIds: null,
|
||||
indicatorId: null,
|
||||
sort: null,
|
||||
remark: null,
|
||||
status: null,
|
||||
sampleName: null,
|
||||
trademark: null,
|
||||
modelSpec: null,
|
||||
quantity: null,
|
||||
entrustUnit: null,
|
||||
productionUnit: null,
|
||||
sampleDate: null,
|
||||
productionDate: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
@ -577,7 +422,12 @@ const submitForm = async () => {
|
||||
? form.value.testFuncIds
|
||||
: [];
|
||||
const payload = {
|
||||
...form.value,
|
||||
projectId: form.value.projectId,
|
||||
projectName: form.value.projectName.trim(),
|
||||
tester: form.value.tester?.trim() || "",
|
||||
vehicleConfigId: form.value.vehicleConfigId || null,
|
||||
sort: form.value.sort,
|
||||
remark: form.value.remark,
|
||||
testFuncIds: JSON.stringify(testFuncIds),
|
||||
};
|
||||
|
||||
@ -585,7 +435,7 @@ const submitForm = async () => {
|
||||
try {
|
||||
const res = isAdd.value
|
||||
? await addProject(payload)
|
||||
: await updateProject(payload);
|
||||
: await updateProject(payload, { clearVehicleConfig: payload.vehicleConfigId == null });
|
||||
if (res.code !== 200) {
|
||||
ElMessage.error(res.msg || (isAdd.value ? "添加失败" : "修改失败"));
|
||||
return;
|
||||
@ -633,21 +483,6 @@ const handleDelete = (row) => {
|
||||
});
|
||||
};
|
||||
|
||||
const indicatorData = ref([]);
|
||||
const getIndicatorData = () => {
|
||||
getChildrenByParentIdWithLevelLimitApi(0,2, 1)
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
indicatorData.value = res.data || [];
|
||||
} else {
|
||||
ElMessage.error(res.msg || "加载评价指标失败");
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("获取评价指标异常:", err);
|
||||
ElMessage.error("网络异常,加载评价指标失败");
|
||||
});
|
||||
}
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { ti_function_config } = proxy.useDict("ti_function_config")
|
||||
const funcIdOptions = ref([])
|
||||
@ -714,11 +549,9 @@ const handleOpenExecution = async (row) => {
|
||||
latestInstId.value = ''
|
||||
executionFlows.value = []
|
||||
try {
|
||||
const [flowRes, instRes] = await Promise.all([
|
||||
getExecuteRunParams({ projectId: row.projectId }),
|
||||
queryExecuteInstId(row.projectId),
|
||||
])
|
||||
const instRes = await queryExecuteInstId(row.projectId)
|
||||
latestInstId.value = instRes.data || ''
|
||||
const flowRes = await getExecuteRunParams({ projectId: row.projectId, instId: latestInstId.value })
|
||||
executionFlows.value = (flowRes.data || []).map((item) => ({
|
||||
id: item.itemId,
|
||||
name: item.itemName || '触控交互流程',
|
||||
@ -752,7 +585,6 @@ const closeRun = () => {
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getTreeData();
|
||||
getIndicatorData();
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -49,3 +49,31 @@ test('通用设备指令仍分配机械臂用途,触控及通用音频硬件
|
||||
assert.equal(robot.getDeviceKindForAction('MICROPHONE_START'), 9)
|
||||
assert.equal(robot.getDeviceKindForAction('SPEAKER_PLAYAUDIO'), 13)
|
||||
})
|
||||
|
||||
test('颈部节点共用独立颈部用途,不能绑定同类型的普通机械臂', async () => {
|
||||
const { robot, resource } = await loadResourceModules()
|
||||
const makeNode = (id, action) => ({
|
||||
id, type: 'serviceNode', properties: { action, nodeType: 'EDGE' },
|
||||
})
|
||||
const graph = resource.sanitizeFlowResourceDefinition({ nodes: [
|
||||
{ id: 'start', type: 'start', properties: {} },
|
||||
makeNode('arm', 'ARM_MOVE_TO_J'),
|
||||
makeNode('moveNeck', 'ARM_NECK_MOVE_J'),
|
||||
makeNode('stopNeck', 'ARM_NECK_STOP'),
|
||||
], edges: [] })
|
||||
const [armSlot, neckSlot] = graph.nodes[0].properties.resourceRoles[0].deviceSlots
|
||||
assert.equal(armSlot.slotKey, 'arm')
|
||||
assert.equal(neckSlot.slotKey, 'neck')
|
||||
assert.equal(neckSlot.deviceKind, robot.DEVICE_KIND.ARM)
|
||||
assert.equal(neckSlot.requiredDeviceId, robot.NECK_DEVICE_ID)
|
||||
assert.deepEqual(graph.nodes.slice(1).map((node) => node.properties.executionTarget.deviceSlotKey), [
|
||||
'arm', 'neck', 'neck',
|
||||
])
|
||||
assert.equal(robot.deviceMatchesSlot({ deviceKind: 2, deviceId: 'arm-1' }, neckSlot), false)
|
||||
assert.equal(robot.deviceMatchesSlot({ deviceKind: 2, deviceId: 'neck_arm' }, neckSlot), true)
|
||||
assert.equal(robot.deviceMatchesSlot({ deviceKind: 2, deviceId: 'xiaozhao_head' }, neckSlot), true)
|
||||
neckSlot.requiredDeviceId = 'xiaozhao_head'
|
||||
const updated = resource.normalizeFlowResourceSchema(graph)
|
||||
assert.equal(updated.nodes[0].properties.resourceRoles[0].deviceSlots[1].requiredDeviceId, 'neck_arm')
|
||||
assert.equal(updated.nodes[2].properties.executionTarget.deviceSlotKey, 'neck')
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user