From 9d2806a17a090c89ccbe877df920bb120f3cd6bf Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Wed, 2 Dec 2026 20:36:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(touch):=20=E5=AE=8C=E5=96=84=E8=A7=A6?= =?UTF-8?q?=E6=8E=A7=E7=BC=96=E6=8E=92=E3=80=81=E5=AA=92=E4=BD=93=E5=88=86?= =?UTF-8?q?=E6=9E=90=E4=B8=8E=E7=81=B5=E5=B7=A7=E6=89=8B=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/flow/flow.js | 2 + src/components/IPlayer/index.vue | 3 +- src/components/Video/index.vue | 6 +- src/utils/flowResources.js | 19 +++ src/utils/robotDevice.js | 63 ++++++++ src/utils/touchFlow.js | 56 +++++++ src/utils/workflowVideo.js | 6 + .../components/RuntimeAssignmentsEditor.vue | 75 +++++++-- .../flow/components/TaskExecutionLog.vue | 6 +- src/views/flow/components/WorkflowImage.vue | 64 ++++++++ .../components/params/BasicNodeParams.vue | 111 +++++++++++-- .../components/params/MediaAnalysisParams.vue | 64 ++++++-- .../flow/components/params/StartParams.vue | 11 ++ .../params/VehicleVersionSelect.vue | 51 ++++++ src/views/flow/config.js | 148 ++++++++++++++++-- src/views/flow/index.vue | 17 +- src/views/flow/nodes/common/serviceNode.vue | 3 +- src/views/flow/standalone.test.mjs | 6 +- .../is/func/FunctionTable/FunctionTable.vue | 29 +--- src/views/is/im/Table/FunctionSelection.vue | 35 +---- src/views/is/im/Table/Table.vue | 29 +--- .../is/project/TouchFunctionSequence.vue | 117 ++++++++++++++ src/views/is/project/evaluate/Run.vue | 13 +- src/views/is/project/index.vue | 73 +++------ tests/dexHandPosition.test.mjs | 55 +++++++ tests/resourceMigration.test.mjs | 41 +++++ 26 files changed, 903 insertions(+), 200 deletions(-) create mode 100644 src/utils/touchFlow.js create mode 100644 src/utils/workflowVideo.js create mode 100644 src/views/flow/components/WorkflowImage.vue create mode 100644 src/views/flow/components/params/VehicleVersionSelect.vue create mode 100644 src/views/is/project/TouchFunctionSequence.vue create mode 100644 tests/dexHandPosition.test.mjs diff --git a/src/api/flow/flow.js b/src/api/flow/flow.js index e2b9851..2b7826d 100644 --- a/src/api/flow/flow.js +++ b/src/api/flow/flow.js @@ -102,6 +102,8 @@ export function flowAction(data) { return request({ url: '/flow/action', method: 'post', + // 留出后端返回边端超时结果的时间。 + timeout: ['TOUCH', 'DEX_HAND_GET_STATE'].includes(data?.action) ? 65000 : undefined, data: data }) } diff --git a/src/components/IPlayer/index.vue b/src/components/IPlayer/index.vue index 55be899..5fe07d4 100644 --- a/src/components/IPlayer/index.vue +++ b/src/components/IPlayer/index.vue @@ -8,6 +8,7 @@ import { ref, onMounted } from 'vue'; import Player, { Events } from 'xgplayer'; // 引入西瓜视频模块 import 'xgplayer/dist/index.min.css'; // 引入西瓜视频样式 +import { workflowVideoUrl } from "@/utils/workflowVideo"; const { videoUrl } = defineProps({ videoUrl: { @@ -30,7 +31,7 @@ const init = () => { // width: 600, // height: 400, // 视频宽高尺寸 isLive: false, - url: videoUrl, // 视频源 + url: workflowVideoUrl(videoUrl), // 视频源 // poster: "http://ashuai.work/static/img/avantar.png", // 视频封面 ...conf, }); diff --git a/src/components/Video/index.vue b/src/components/Video/index.vue index 5ed53a4..226b09c 100644 --- a/src/components/Video/index.vue +++ b/src/components/Video/index.vue @@ -1,12 +1,14 @@ \ No newline at end of file + diff --git a/src/utils/flowResources.js b/src/utils/flowResources.js index 6bf9af2..83ad438 100644 --- a/src/utils/flowResources.js +++ b/src/utils/flowResources.js @@ -1,4 +1,5 @@ import { getDeviceKindForAction, getRequiredDeviceIdForAction, isNeckDeviceId, NECK_DEVICE_ID } from '@/utils/robotDevice' +import { mergeTouchOutputs, touchCoordinatesInput, touchPathSearchOutputs, touchPathStepOutputs, touchRetryInput, touchRetryOutput } from '@/utils/touchFlow' export const FLOW_SCHEMA_VERSION = 2 export const DEFAULT_ROLE_KEY = 'default_executor' @@ -24,6 +25,7 @@ const DEVICE_KIND_META = Object.freeze({ 2: { key: 'arm', name: '机械臂' }, 4: { key: 'bio_head', name: '仿生头' }, 5: { key: 'camera', name: '摄像头' }, + 7: { key: 'dex_hand', name: '灵巧手' }, 9: { key: 'microphone', name: '麦克风' }, 12: { key: 'robot', name: '机器人本体' }, 13: { key: 'speaker', name: '扬声器' }, @@ -143,6 +145,23 @@ export const normalizeFlowResourceSchema = (sourceGraph) => { node.type = LEGACY_NODE_TYPE_ALIASES[node.type] || node.type // 早期图片分析图数据可能只保存节点类型,加载时补齐运行端识别所需的协议字段。 const properties = node.properties || (node.properties = {}) + if (properties.action === 'TI_PATH_SEARCH') { + properties.outputParams = mergeTouchOutputs(properties.outputParams, touchPathSearchOutputs()) + } + if (properties.action === 'GET_CURRENT_OBJECT' && (properties.loopValueType === 'touchPathStep' || + properties.outputParams?.some(field => field.name === 'object' && + field.children?.some(child => child.name === 'functionName' && child.type === 'string')))) { + properties.outputParams = mergeTouchOutputs(properties.outputParams, touchPathStepOutputs()) + } + if (properties.action === 'TOUCH') { + const params = properties.nodeParams || (properties.nodeParams = []) + const coordinates = params.find(param => param.name === 'touchCoordinates') + if (!coordinates) params.push(touchCoordinatesInput()) + if (!params.some(param => param.name === 'retryCount')) params.push(touchRetryInput()) + const legacy = params.find(param => param.name === 'touchParams') + if (legacy) legacy.required = false + properties.outputParams = mergeTouchOutputs(properties.outputParams, [touchRetryOutput()]) + } if (['AGV_MOVE_TO_POINT', 'AGV_MOVE_TO_STATION'].includes(properties.action)) { properties.nodeParams = Array.isArray(properties.nodeParams) ? properties.nodeParams : [] if (!properties.nodeParams.some((param) => param?.name === 'blockedTimeoutMs')) { diff --git a/src/utils/robotDevice.js b/src/utils/robotDevice.js index d205f03..0bc8cd1 100644 --- a/src/utils/robotDevice.js +++ b/src/utils/robotDevice.js @@ -7,6 +7,7 @@ export const DEVICE_KIND = Object.freeze({ ARM: 2, BIO_HEAD: 4, CAMERA: 5, + DEX_HAND: 7, MICROPHONE: 9, ROBOT: 12, SPEAKER: 13, @@ -14,6 +15,61 @@ export const DEVICE_KIND = Object.freeze({ export const NECK_DEVICE_ID = 'neck_arm' export const isNeckDeviceId = (deviceId) => deviceId === NECK_DEVICE_ID || deviceId === 'xiaozhao_head' +export const dexHandAxisLabels = Object.freeze(['小拇指', '无名指', '中指', '食指', '大拇指弯曲', '大拇指旋转']) + +const DEX_HAND_POSITION_LIMIT = 2000 +const DEX_HAND_ANGLE_COMMAND_LIMIT = 1000 +const DEX_HAND_AXIS_COUNT = 6 + +function dexHandAxes(state, captureKind) { + const model = String(state?.model || '').trim() + if (!/^(ROH-(LiteS001|AP001)|OYMotionAP001)$/i.test(model)) { + throw new Error(model ? `当前机型 ${model} 不支持${captureKind}回填` : `设备未上报支持${captureKind}回填的机型`) + } + if (state.initialized !== true) throw new Error('灵巧手尚未初始化') + if (!Array.isArray(state.hands) || state.hands.length !== DEX_HAND_AXIS_COUNT) { + throw new Error('灵巧手未返回完整的六轴位置') + } + + const axes = Array(DEX_HAND_AXIS_COUNT).fill(null) + for (const axis of state.hands) { + const { id, position, error, errorMessages } = axis || {} + if (!Number.isInteger(id) || id < 0 || id >= DEX_HAND_AXIS_COUNT || axes[id] !== null + || !Number.isInteger(position) || position < 0 || position > DEX_HAND_POSITION_LIMIT) { + throw new Error('灵巧手反馈中的自由度编号或位置无效') + } + if (error || errorMessages?.length) throw new Error(`灵巧手存在故障,无法保存当前${captureKind}`) + axes[id] = axis + } + return axes +} + +function dexHandTarget(id, units, limit) { + const ratio = units / limit + // The edge truncates a float32 product. Nudge ratios that would land one register unit below. + const value = Math.fround(Math.fround(ratio) * limit) < units ? ratio + 0.0000001 : ratio + return { id, value } +} + +export function dexHandPositionTargets(state) { + return dexHandAxes(state, '位置').map(({ id, position }) => dexHandTarget(id, position, DEX_HAND_POSITION_LIMIT)) +} + +export function dexHandAngleSnapshot(state) { + const axes = dexHandAxes(state, '角度') + if (axes.some(axis => !Number.isInteger(axis.angle))) { + throw new Error('灵巧手未返回完整的六轴实测角度') + } + return { + angles: axes.map(({ id, angle }) => ({ id, degrees: angle / 100 })), + // The ROH angle command drives logical travel, while angle feedback is in centidegrees. + values: axes.map(({ id, position }) => dexHandTarget( + id, + Math.round(position * DEX_HAND_ANGLE_COMMAND_LIMIT / DEX_HAND_POSITION_LIMIT), + DEX_HAND_ANGLE_COMMAND_LIMIT, + )), + } +} /** * 流程动作到所需设备类型的全局映射。 @@ -35,6 +91,13 @@ export const DEVICE_KIND_BY_ACTION = Object.freeze({ ARM_NECK_STOP: DEVICE_KIND.ARM, ARM_NECK_ENABLE: DEVICE_KIND.ARM, ARM_NECK_DISABLE: DEVICE_KIND.ARM, + DEX_HAND_GET_STATE: DEVICE_KIND.DEX_HAND, + DEX_HAND_SET_ANGLE: DEVICE_KIND.DEX_HAND, + DEX_HAND_SET_POSITION: DEVICE_KIND.DEX_HAND, + DEX_HAND_SET_FORCE: DEVICE_KIND.DEX_HAND, + DEX_HAND_SET_SPEED: DEVICE_KIND.DEX_HAND, + DEX_HAND_PLAY_PRESET: DEVICE_KIND.DEX_HAND, + DEX_HAND_GET_TACTILE: DEVICE_KIND.DEX_HAND, TOUCH: DEVICE_KIND.ARM, BIO_HEAD_SPEAK_START: DEVICE_KIND.BIO_HEAD, BIO_HEAD_SPEAK_STOP: DEVICE_KIND.BIO_HEAD, diff --git a/src/utils/touchFlow.js b/src/utils/touchFlow.js new file mode 100644 index 0000000..b012b87 --- /dev/null +++ b/src/utils/touchFlow.js @@ -0,0 +1,56 @@ +export const touchProjectInputs = () => [ + { name: 'vehicleConfigId', type: 'number', desc: '车机版本,由触控项目传入', required: true, disabled: true }, + { name: 'funcIds', type: 'array', desc: '功能列表,按项目编排顺序传入,可重复', required: true, disabled: true }, +] + +export const touchPathStepFields = () => [ + { name: 'sourceUiName', type: 'string', desc: '本步所在界面' }, + { name: 'sourceUiCandidates', type: 'array', desc: '本步可能所在的界面,以拍照识别结果为准' }, + { name: 'functionName', type: 'string', desc: '本步点击的功能' }, + { name: 'targetUiName', type: 'string', desc: '本步预期到达的界面' }, + { name: 'targetUiCandidates', type: 'array', desc: '本步可能到达的界面' }, + { name: 'iconUrl', type: 'string', desc: '按钮参考图' }, + { name: 'operationType', type: 'string', desc: '动作类型' }, + { name: 'repeatCount', type: 'number', desc: '重复次数' }, + { name: 'waitMs', type: 'number', desc: '动作等待毫秒' }, + { name: 'isLastStep', type: 'boolean', desc: '本路径的最后一步,点击成功后可结束循环' }, +] + +export const touchPathSearchOutputs = () => [ + { name: 'nextLocation', type: 'string', desc: '下一步点击的功能', disabled: true }, + { name: 'isEnd', type: 'boolean', desc: '本次搜索是否只剩最后一步', disabled: true }, + { name: 'iconUrl', type: 'string', desc: '按钮参考图', disabled: true }, + { name: 'pathLength', type: 'number', desc: '路径步数', disabled: true }, + { name: 'path', type: 'array', desc: '完整点击路径,供内层循环引用', disabled: true, children: touchPathStepFields() }, +] + +export const touchPathStepOutputs = () => [ + { name: 'index', type: 'number', desc: '索引', disabled: true }, + { name: 'object', type: 'object', desc: '当前点击步骤', disabled: true, children: touchPathStepFields() }, +] + +export const touchCoordinatesInput = () => ({ + name: 'touchCoordinates', displayName: '触控坐标', type: 'input', input: '', + desc: '引用获取功能坐标的 point', disabled: true, required: false, +}) + +export const touchRetryInput = () => ({ + name: 'retryCount', displayName: '失败重试次数', type: 'input', componentType: 'number', + input: 0, min: 0, stepStrictly: true, disabled: true, required: false, +}) + +export const touchRetryOutput = () => ({ + name: 'retryAttempts', type: 'number', desc: '本次触控实际重试的次数', disabled: true, +}) + +export function mergeTouchOutputs(saved, fields) { + const definitions = new Map((saved || []).map(field => [field.name, field])) + for (const field of fields) { + const old = definitions.get(field.name) + definitions.set(field.name, { + ...old, ...field, + ...(field.children ? { children: mergeTouchOutputs(old?.children, field.children) } : {}), + }) + } + return [...definitions.values()] +} diff --git a/src/utils/workflowVideo.js b/src/utils/workflowVideo.js new file mode 100644 index 0000000..0d162f7 --- /dev/null +++ b/src/utils/workflowVideo.js @@ -0,0 +1,6 @@ +export function workflowVideoUrl(value) { + if (typeof value !== 'string') return '' + const match = /^https?:\/\/minio(?::\d+)?\/[^/]+\/(VIDEO\/\d{8}\/[\w.-]+\.mp4)(?:\?.*)?$/i.exec(value) + if (!match) return value + return `${import.meta.env.VITE_APP_BASE_API}/system/file/workflow-video?object=${encodeURIComponent(match[1])}` +} diff --git a/src/views/flow/components/RuntimeAssignmentsEditor.vue b/src/views/flow/components/RuntimeAssignmentsEditor.vue index bce34d0..35c4ad4 100644 --- a/src/views/flow/components/RuntimeAssignmentsEditor.vue +++ b/src/views/flow/components/RuntimeAssignmentsEditor.vue @@ -29,18 +29,18 @@ - + -
+
该机器人没有匹配的在线设备
@@ -55,7 +55,7 @@ diff --git a/src/views/flow/components/params/BasicNodeParams.vue b/src/views/flow/components/params/BasicNodeParams.vue index 9706696..a48213b 100644 --- a/src/views/flow/components/params/BasicNodeParams.vue +++ b/src/views/flow/components/params/BasicNodeParams.vue @@ -27,18 +27,36 @@ - + - + - + - +
+ +
+ 实测角度(°) +
+ + {{ dexHandAxisLabels[axis.id] }} {{ axis.degrees.toFixed(2) }}° + +
+
+
+ @@ -124,16 +143,18 @@ import { computed, ref, reactive, watch } from 'vue' import { Plus, Minus } from '@element-plus/icons-vue' import FormItemRecursive from '../FormItemRecursive.vue' import RobotExecutionTarget from './RobotExecutionTarget.vue' +import VehicleVersionSelect from './VehicleVersionSelect.vue' import { useQuote } from './useQuote.js' -import { getArmStatus, getArmJointState, getAgvStatus, getAgvStations } from '@/api/flow/flow' +import { flowAction, getArmStatus, getArmJointState, getAgvStatus, getAgvStations } from '@/api/flow/flow' import { getRobotList, getRobotDevicesByRobotId } from '@/api/resource/robot' import { ElMessage } from 'element-plus' -import { deviceMatchesSlot, getDeviceKindForAction, getRequiredDeviceIdForAction, toDeviceOptions } from '@/utils/robotDevice' +import { dexHandAngleSnapshot, dexHandAxisLabels, dexHandPositionTargets, deviceMatchesSlot, getDeviceKindForAction, getRequiredDeviceIdForAction, toDeviceOptions } from '@/utils/robotDevice' import { actionRequiresDevice } from '@/utils/flowResources' const props = defineProps({ data: Object }) +const isVehicleVersionField = (param) => props.data.properties?.action === 'TI_PATH_SEARCH' && param.name === 'vehicleConfigId' const emit = defineEmits(['save-success', 'save-error']) @@ -151,6 +172,10 @@ const activeNames = ref(['1', '2']) // 使用共享的 quote 逻辑 const { quoteOptions, cascaderRefs, handleTypeChange, cascaderChange, visibleChange } = useQuote(props.data.id) +const changeParamType = (property) => { + delete property.measuredAngles + handleTypeChange(property) +} // 添加表单项 /** @@ -310,6 +335,9 @@ const loadRobotDevices = async (robotId) => { * @param {*} property 参数属性 */ const testRule = (property) => { + if (isVehicleVersionField(property)) { + return [{ required: true, message: '请选择车机版本', trigger: 'change' }] + } if (property?.name === 'stationId' && props.data.properties.action === 'AGV_MOVE_TO_STATION') { return [ { required: true, message: '请从站点列表中选择站点', trigger: 'change' }, @@ -354,21 +382,27 @@ const testRule = (property) => { const robotFormAction = ref() const robotFormLoading = ref(false) const NECK_MOVE_ACTION = 'ARM_NECK_MOVE_J' +const DEX_HAND_POSITION_ACTION = 'DEX_HAND_SET_POSITION' +const DEX_HAND_ANGLE_ACTION = 'DEX_HAND_SET_ANGLE' +const isDexHandReadback = (action) => [DEX_HAND_POSITION_ACTION, DEX_HAND_ANGLE_ACTION].includes(action) 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) + isDexHandReadback(props.data.properties.action) || POSITION_ACTIONS.includes(props.data.properties.action) || props.data.properties.action === 'AGV_MOVE_TO_STATION' )) const robotActionButtonText = computed(() => { if (props.data.properties.action === 'AGV_MOVE_TO_STATION') return '选择机器人并加载站点' - if (props.data.properties.action === NECK_MOVE_ACTION) return '获取当前位置' + if (props.data.properties.action === DEX_HAND_ANGLE_ACTION) return '获取当前角度' + if ([DEX_HAND_POSITION_ACTION, NECK_MOVE_ACTION].includes(props.data.properties.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 === DEX_HAND_ANGLE_ACTION) return '读取灵巧手当前角度' + if (robotFormAction.value === DEX_HAND_POSITION_ACTION) return '读取灵巧手当前位置' if (robotFormAction.value === NECK_MOVE_ACTION) return '读取颈部当前位置' if (POSITION_ACTIONS.includes(robotFormAction.value)) return '选择机器人并读取当前位置' return '选择机器人设备' @@ -378,7 +412,47 @@ const robotDialogTitle = computed(() => { * 处理 submitRobotForm 对应的数据或交互;作用范围仅限当前组件或模块。 */ const submitRobotForm = () => { - if (robotFormAction.value === 'AGV_MOVE_TO_POINT') { + const action = robotFormAction.value + if (isDexHandReadback(action)) { + const captureAngle = action === DEX_HAND_ANGLE_ACTION + const captureKind = captureAngle ? '角度' : '位置' + robotFormRef.value.validate(async (valid) => { + if (!valid) return + const { robotId, deviceId } = robotForm + const nodeId = props.data.id + robotFormLoading.value = true + try { + const { data } = await flowAction({ + action: 'DEX_HAND_GET_STATE', + payload: { robotId, deviceId }, + }) + if (!dialogVisible.value || props.data.id !== nodeId || props.data.properties.action !== action + || robotForm.robotId !== robotId || robotForm.deviceId !== deviceId) return + + const state = typeof data === 'string' ? JSON.parse(data) : data + const snapshot = captureAngle ? dexHandAngleSnapshot(state) : { values: dexHandPositionTargets(state) } + let batchParam = formData.nodeParams.find(param => param.name === 'values') + if (!batchParam) { + formData.nodeParams.push({ name: 'values', displayName: '多自由度参数', disabled: true, required: false }) + batchParam = formData.nodeParams.at(-1) + } + for (const param of formData.nodeParams) { + if (!['id', 'value', 'values'].includes(param.name)) continue + param.type = 'input' + param.quote = [] + delete param.quoteType + param.input = param === batchParam ? JSON.stringify(snapshot.values) : null + } + if (captureAngle) batchParam.measuredAngles = snapshot.angles + dialogVisible.value = false + ElMessage.success(`已回填 ${snapshot.values.length} 个自由度的${captureKind}目标,请保存节点`) + } catch (error) { + ElMessage.error(error?.message || `读取灵巧手当前${captureKind}失败`) + } finally { + robotFormLoading.value = false + } + }) + } else if (robotFormAction.value === 'AGV_MOVE_TO_POINT') { robotFormRef.value.validate(async (valid) => { if (valid) { try { @@ -565,6 +639,23 @@ defineExpose({ validateAndSave }) width: 160px; } + .dex-hand-values { + width: 280px; + max-width: 100%; + } + + .measured-angles { + margin-top: 8px; + color: var(--el-text-color-secondary); + line-height: 1.6; + } + + .measured-angle-list { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 4px 12px; + } + } diff --git a/src/views/flow/components/params/MediaAnalysisParams.vue b/src/views/flow/components/params/MediaAnalysisParams.vue index b4fd83e..5736ef0 100644 --- a/src/views/flow/components/params/MediaAnalysisParams.vue +++ b/src/views/flow/components/params/MediaAnalysisParams.vue @@ -86,18 +86,32 @@
开启后分析在后台并行执行,流程结束前统一等待分析结果。
- - - + @@ -203,7 +217,9 @@ const formData = reactive({ mediaQuote: [], mediaQuoteType: 'output', mediaUrl: '', + instructionMode: 'input', instruction: '', + instructionQuote: [], analysisMode: 'AUTO', detailedOutput: false, asynchronous: false, @@ -228,6 +244,10 @@ const mediaModes = [ { label: '引用节点输出', value: 'quote' }, { label: '直接输入地址', value: 'input' }, ] +const instructionModes = [ + { label: '手动输入', value: 'input' }, + { label: '引用节点参数', value: 'quote' }, +] const analysisModes = [ { label: '快速', value: 'FAST' }, { label: '均衡', value: 'AUTO' }, @@ -313,11 +333,18 @@ const rules = { trigger: 'blur', }], instruction: [{ - validator: (_, value) => !isVideo.value || String(value || '').trim() + validator: (_, value) => String(value || '').trim() ? Promise.resolve() - : Promise.reject(new Error('请输入明确的通过标准')), + : Promise.reject(new Error('请输入评判标准')), trigger: 'blur', }], + instructionQuote: [{ + validator: (_, value) => Array.isArray(value) && value.length >= 3 + && ['input', 'output'].includes(value[1]) + ? Promise.resolve() + : Promise.reject(new Error('请选择评判标准引用的字段')), + trigger: 'change', + }], } // 使用 Object.assign 保留 analysisTuning 的响应式引用,只覆盖当前模式定义的预设字段。 @@ -415,7 +442,9 @@ const initData = () => { formData.mediaQuote = Array.isArray(media?.quote) ? [...media.quote] : [] formData.mediaQuoteType = media?.quoteType || 'output' formData.mediaUrl = media?.input || '' - formData.instruction = instruction?.input || '' + formData.instructionMode = instruction?.type === 'quote' ? 'quote' : 'input' + formData.instruction = typeof instruction?.input === 'string' ? instruction.input : '' + formData.instructionQuote = Array.isArray(instruction?.quote) ? [...instruction.quote] : [] formData.analysisMode = analysisPresets[analysisMode?.input] ? analysisMode.input : 'AUTO' // 兼容旧流程或外部写入的字符串值,表单内部统一使用布尔值驱动开关。 formData.detailedOutput = detailedOutput?.input === true || detailedOutput?.input === 'true' @@ -496,8 +525,11 @@ const validateAndSave = async () => { if (isVideo.value) { nodeParams.push({ name: 'instruction', - type: 'input', - input: formData.instruction.trim(), + displayName: '评判标准', + type: formData.instructionMode, + ...(formData.instructionMode === 'quote' + ? { quote: [...formData.instructionQuote], quoteType: formData.instructionQuote[1] } + : { input: formData.instruction.trim() }), required: true, disabled: true, }) diff --git a/src/views/flow/components/params/StartParams.vue b/src/views/flow/components/params/StartParams.vue index c9a0013..67a2618 100644 --- a/src/views/flow/components/params/StartParams.vue +++ b/src/views/flow/components/params/StartParams.vue @@ -37,6 +37,7 @@