2026-07-28 16:26:07 +08:00
|
|
|
<template>
|
|
|
|
|
<el-drawer
|
2026-07-29 16:17:39 +08:00
|
|
|
:model-value="props.drawer"
|
2026-07-28 16:26:07 +08:00
|
|
|
title="试运行"
|
|
|
|
|
:before-close="handleClose"
|
|
|
|
|
>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="ruleFormRef"
|
|
|
|
|
style="max-width: 600px"
|
|
|
|
|
:model="{ tableData }"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
label-width="auto"
|
|
|
|
|
>
|
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
style="width: 100%; margin-bottom: 20px"
|
|
|
|
|
row-key="name"
|
|
|
|
|
default-expand-all
|
|
|
|
|
>
|
|
|
|
|
<el-table-column prop="name" label="入参名称">
|
|
|
|
|
<template #default="{row}">
|
|
|
|
|
<span>{{ row.name }}</span>
|
|
|
|
|
<span v-if="row.required" style="color: #f56c6c; margin-left: 8px;">*</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="type" label="入参类型">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tag>{{ scope.row.type }}</el-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="value" label="入参值">
|
|
|
|
|
<template #default="{ row, column, $index }">
|
2026-08-04 17:29:07 +08:00
|
|
|
<el-form-item v-if="row.name === 'terminalId' || row.name === 'robotId'" label="" :prop="`tableData${row.propPath}value`" :rules="row.required ? [{ required: true, message: '请选择执行机器人', trigger: 'change' }] : []">
|
2026-07-28 16:26:07 +08:00
|
|
|
<el-select v-model="row.value" style="width: 200px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in terminalIdOptions"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item v-else-if="row.type !== 'object' && !row.type.includes('array')" label="" :prop="`tableData${row.propPath}value`" :rules="row.required ? [{ required: true, message: '请输入变量名', trigger: 'blur' }] : []">
|
|
|
|
|
<el-input v-if="row.type === 'string'" v-model="row.value" />
|
|
|
|
|
<el-input-number v-if="row.type === 'number'" :controls="false" v-model="row.value" />
|
|
|
|
|
<el-switch v-if="row.type === 'boolean'" v-model="row.value" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item v-else-if="row.type !== 'object' && row.type.includes('array')" label="" :prop="`tableData${row.propPath}value`" :rules="row.required ? [{ required: true, message: '请输入变量名', trigger: 'blur' }] : []">
|
|
|
|
|
<el-input v-model="row.value" placeholder="请输入数组值,格式如:[1,2,3]" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="handleClose">关闭</el-button>
|
|
|
|
|
<el-button type="primary" @click="confirm">确定</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-drawer>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2026-07-29 16:17:39 +08:00
|
|
|
import { ref, watch } from 'vue'
|
2026-07-28 16:26:07 +08:00
|
|
|
import { getStartNodeFormData, formatTableData } from '@/utils/flow'
|
|
|
|
|
// import { Plus, Minus } from '@element-plus/icons-vue'
|
2026-08-04 16:30:00 +08:00
|
|
|
import { flowExecuteTrial } from '@/api/flow/flow'
|
2026-07-28 16:26:07 +08:00
|
|
|
import { emitter } from '@/utils/eventBus';
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
2026-08-04 17:29:07 +08:00
|
|
|
import { getRobotList } from '@/api/inspection/robot'
|
2026-07-28 16:26:07 +08:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
drawer: Boolean,
|
|
|
|
|
flowId: String
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const ruleFormRef = ref()
|
|
|
|
|
const rules = ref({});
|
|
|
|
|
const tableData = ref([])
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['close', 'changeState'])
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
2026-07-29 16:17:39 +08:00
|
|
|
ruleFormRef.value?.resetFields()
|
2026-07-28 16:26:07 +08:00
|
|
|
emits('close')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(() => props.drawer,
|
|
|
|
|
(newVal) => {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
const data = getStartNodeFormData()
|
|
|
|
|
tableData.value = data
|
|
|
|
|
handleGetTerminalGroup()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const confirm = () => {
|
|
|
|
|
lf.fitView()
|
|
|
|
|
ruleFormRef.value.validate().then(async () => {
|
|
|
|
|
const formData = formatTableData(tableData.value)
|
|
|
|
|
const { nodes } = lf.getGraphData()
|
|
|
|
|
nodes.forEach(item => {
|
|
|
|
|
emitter.emit('contentChange', { id: item.id})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const flowData = JSON.stringify(lf.getGraphData())
|
2026-08-04 17:29:07 +08:00
|
|
|
const { terminalId, robotId, ...runParams } = formData
|
2026-07-28 16:26:07 +08:00
|
|
|
const res = await flowExecuteTrial({
|
|
|
|
|
flowData,
|
|
|
|
|
itemId: props.flowId,
|
2026-08-04 17:29:07 +08:00
|
|
|
robotId: robotId || terminalId,
|
2026-07-28 16:26:07 +08:00
|
|
|
runParams
|
|
|
|
|
})
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
emits('changeState', {
|
|
|
|
|
type: 'testRunning',
|
|
|
|
|
instId: res.msg
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-07-29 16:17:39 +08:00
|
|
|
.catch(() => {})
|
2026-07-28 16:26:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const terminalIdOptions = ref([])
|
|
|
|
|
|
|
|
|
|
/** 获取设备终端列表 */
|
|
|
|
|
const handleGetTerminalGroup = async (row) => {
|
2026-08-04 17:29:07 +08:00
|
|
|
const res = await getRobotList({ pageNum: 1, pageSize: 1000, connectStatus: '1' })
|
2026-07-28 16:26:07 +08:00
|
|
|
if (res.code === 200) {
|
|
|
|
|
terminalIdOptions.value = res.rows?.map((item) => {
|
|
|
|
|
return {
|
2026-08-04 17:29:07 +08:00
|
|
|
label: `${item.robotName || item.robotId} (${item.robotId})`,
|
|
|
|
|
value: item.robotId
|
2026-07-28 16:26:07 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 16:17:39 +08:00
|
|
|
</script>
|