Merge remote-tracking branch 'origin/lxl-dev' into lxl-dev
This commit is contained in:
commit
bffa17a6a2
@ -7,8 +7,8 @@ VITE_APP_ENV = 'development'
|
|||||||
# 招商车研物联网平台/开发环境
|
# 招商车研物联网平台/开发环境
|
||||||
VITE_APP_BASE_API = '/dev-api'
|
VITE_APP_BASE_API = '/dev-api'
|
||||||
|
|
||||||
VITE_API_URL = http://localhost:13080
|
VITE_API_URL = http://192.168.0.222:13080
|
||||||
VITE_WS_URL = ws://localhost:13080/ws
|
VITE_WS_URL = ws://192.168.0.222:13080/ws
|
||||||
VITE_PORT = 80
|
VITE_PORT = 80
|
||||||
VITE_INSPECTION_TYPE = "inspection"
|
VITE_INSPECTION_TYPE = "inspection"
|
||||||
VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/"
|
VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/"
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,3 +21,5 @@ selenium-debug.log
|
|||||||
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
|
.history
|
||||||
|
|||||||
@ -69,3 +69,11 @@ export function getArmStatus(params) {
|
|||||||
params: params
|
params: params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAgvStatus(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/agv/getRuntimeState',
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -31,6 +31,7 @@ import CodeNodeParams from './params/CodeNodeParams.vue'
|
|||||||
import HttpNodeParams from './params/HttpNodeParams.vue'
|
import HttpNodeParams from './params/HttpNodeParams.vue'
|
||||||
import SdAgentNodeParams from './params/SdAgentNodeParams.vue'
|
import SdAgentNodeParams from './params/SdAgentNodeParams.vue'
|
||||||
import RecognizeNodeParams from './params/RecognizeNodeParams.vue'
|
import RecognizeNodeParams from './params/RecognizeNodeParams.vue'
|
||||||
|
import DeviceUniversal from './params/device_universal.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
drawer: Boolean,
|
drawer: Boolean,
|
||||||
@ -49,6 +50,7 @@ const currentComponent = computed(() => {
|
|||||||
if (type === 'http') return HttpNodeParams
|
if (type === 'http') return HttpNodeParams
|
||||||
if (type === 'sdAgent') return SdAgentNodeParams
|
if (type === 'sdAgent') return SdAgentNodeParams
|
||||||
if (type === 'recognize') return RecognizeNodeParams
|
if (type === 'recognize') return RecognizeNodeParams
|
||||||
|
if (type === 'device_universal') return DeviceUniversal
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ import { Plus, Minus } from '@element-plus/icons-vue'
|
|||||||
import FormItemRecursive from '../FormItemRecursive.vue'
|
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||||
import { getInput } from '@/utils/flow'
|
import { getInput } from '@/utils/flow'
|
||||||
import { useQuote } from './useQuote.js'
|
import { useQuote } from './useQuote.js'
|
||||||
import { getArmStatus } from '@/api/device/flow'
|
import { getArmStatus, getAgvStatus } from '@/api/device/flow'
|
||||||
import { de } from 'element-plus/es/locale/index.mjs'
|
import { de } from 'element-plus/es/locale/index.mjs'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -219,7 +219,21 @@ const testRule = (property) => {
|
|||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('加速度必须大于速度'))
|
return Promise.reject(new Error('加速度必须大于速度'))
|
||||||
}
|
}
|
||||||
}, trigger: 'blur' }
|
}, trigger: 'change' }
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property?.name === 'velocity') {
|
||||||
|
return [
|
||||||
|
{ required: true, message: '请输入参数值', trigger: 'blur' },
|
||||||
|
{ validator: () => {
|
||||||
|
if (formData.nodeParams.find(param => param.name === 'acceleration')?.input > formData.nodeParams.find(param => param.name === 'velocity')?.input) {
|
||||||
|
return Promise.resolve()
|
||||||
|
} else {
|
||||||
|
return Promise.reject(new Error('加速度必须大于速度'))
|
||||||
|
}
|
||||||
|
}, trigger: 'change' }
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -230,7 +244,31 @@ const robotFormAction = ref()
|
|||||||
|
|
||||||
const submitRobotForm = () => {
|
const submitRobotForm = () => {
|
||||||
if (robotFormAction.value === 'AGV_MOVE_TO_POINT') {
|
if (robotFormAction.value === 'AGV_MOVE_TO_POINT') {
|
||||||
|
robotFormRef.value.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
try {
|
||||||
|
const response = await getAgvStatus({ deviceId: robotForm.deviceId, terminalId: robotForm.terminalId })
|
||||||
|
if (response && response.data) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
const { x, y, theta } = response.data.pose
|
||||||
|
const testMap = {
|
||||||
|
x: x,
|
||||||
|
y: y,
|
||||||
|
theta: theta,
|
||||||
|
deviceId: robotForm.deviceId
|
||||||
|
}
|
||||||
|
// 将获取到的位置信息设置到 formData 中
|
||||||
|
formData.nodeParams.forEach(param => {
|
||||||
|
if (testMap.hasOwnProperty(param.name)) {
|
||||||
|
param.input = testMap[param.name]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取位置信息失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if (robotFormAction.value === 'ARM_MOVE_TO_POINT') {
|
} else if (robotFormAction.value === 'ARM_MOVE_TO_POINT') {
|
||||||
robotFormRef.value.validate(async (valid) => {
|
robotFormRef.value.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|||||||
463
src/views/flow/components/params/Device_universal.vue
Normal file
463
src/views/flow/components/params/Device_universal.vue
Normal file
@ -0,0 +1,463 @@
|
|||||||
|
<template>
|
||||||
|
<el-collapse v-model="activeNames">
|
||||||
|
<el-collapse v-model="activeNames">
|
||||||
|
<el-collapse-item name="1" icon-position="left">
|
||||||
|
<template #title>
|
||||||
|
输入参数
|
||||||
|
<el-tooltip
|
||||||
|
class="box-item"
|
||||||
|
effect="dark"
|
||||||
|
content="这里输入的变量可以被下方的代码引用。"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-icon class="header-icon" style="margin-left: 6px">
|
||||||
|
<info-filled />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<div class="form__container">
|
||||||
|
<el-form
|
||||||
|
:inline="true"
|
||||||
|
:model="formData"
|
||||||
|
:rules="rules"
|
||||||
|
ref="dynamicFormRef"
|
||||||
|
label-position="top"
|
||||||
|
label-width="auto"
|
||||||
|
>
|
||||||
|
<div v-for="(property, index) in formData.nodeParams" :key="index">
|
||||||
|
<el-row v-if="property.name !== 'requestJson'">
|
||||||
|
<el-form-item
|
||||||
|
:label="index === 0 ? '参数名' : ''"
|
||||||
|
:prop="`nodeParams.${index}.name`"
|
||||||
|
:rules="[
|
||||||
|
{ required: true, message: '请输入参数名', trigger: 'blur' },
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
:disabled="property?.disabled || false"
|
||||||
|
class="param-name"
|
||||||
|
v-model="property.name"
|
||||||
|
placeholder="请输入"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
:label="index === 0 ? '参数值' : ''"
|
||||||
|
:prop="`nodeParams.${index}.type`"
|
||||||
|
>
|
||||||
|
<el-select
|
||||||
|
v-model="property.type"
|
||||||
|
class="param-type"
|
||||||
|
@change="handleTypeChange(index)"
|
||||||
|
>
|
||||||
|
<el-option label="引用" value="quote" />
|
||||||
|
<el-option label="输入" value="input" />
|
||||||
|
</el-select>
|
||||||
|
<el-form-item
|
||||||
|
v-if="property.type === 'input'"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: property?.required ?? true,
|
||||||
|
message: '请输入参数值',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
:prop="`nodeParams.${index}.input`"
|
||||||
|
>
|
||||||
|
<el-input-number
|
||||||
|
class="param-value"
|
||||||
|
v-if="property.componentType === 'number'"
|
||||||
|
v-model="property.input"
|
||||||
|
:min="0"
|
||||||
|
:max="property.max || Infinity"
|
||||||
|
:controls="false"
|
||||||
|
:step-strictly="true"
|
||||||
|
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="请输入"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
v-if="property.type === 'quote'"
|
||||||
|
:rules="[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择参数值',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
:prop="`nodeParams.${index}.quote`"
|
||||||
|
>
|
||||||
|
<el-cascader
|
||||||
|
:ref="
|
||||||
|
(el) => {
|
||||||
|
if (el) cascaderRefs[index] = el;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
v-model="property.quote"
|
||||||
|
:checkStrictly="true"
|
||||||
|
:options="quoteOptions"
|
||||||
|
placeholder="请选择"
|
||||||
|
@visible-change="
|
||||||
|
(visible) => visibleChange(visible, index, property.quote)
|
||||||
|
"
|
||||||
|
@change="(value) => cascaderChange(value, index, formData, 'nodeParams')"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form-item>
|
||||||
|
<el-button
|
||||||
|
:icon="Minus"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="handleDelete(index)"
|
||||||
|
:disabled="property?.disabled || false"
|
||||||
|
class="deleteBtn"
|
||||||
|
/>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item title="JSON" name="2" icon-position="left">
|
||||||
|
<div class="code__container">
|
||||||
|
<div ref="codeRef" style="width: 100%; height: 100%"></div>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item name="3" icon-position="left">
|
||||||
|
<template #title>
|
||||||
|
输出参数
|
||||||
|
<el-tooltip
|
||||||
|
class="box-item"
|
||||||
|
effect="dark"
|
||||||
|
content="这里定义的输出变量可以被后续节点引用。"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-icon class="header-icon" style="margin-left: 6px">
|
||||||
|
<info-filled />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-button
|
||||||
|
:circle="true"
|
||||||
|
size="small"
|
||||||
|
@click="(e) => addFormItem(e, 'outputParams')"
|
||||||
|
class="addFormItem"
|
||||||
|
>
|
||||||
|
<el-icon :size="14"><Plus /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<div class="form__container">
|
||||||
|
<el-form
|
||||||
|
:inline="true"
|
||||||
|
:model="formData"
|
||||||
|
label-position="top"
|
||||||
|
label-width="auto"
|
||||||
|
:rules="outputRules"
|
||||||
|
ref="outputFormRef"
|
||||||
|
>
|
||||||
|
<FormItemRecursive
|
||||||
|
formType="output"
|
||||||
|
:current-list="formData.outputParams"
|
||||||
|
prop-path="outputParams"
|
||||||
|
:depth="0"
|
||||||
|
:is-first-level="true"
|
||||||
|
:endDepth="2"
|
||||||
|
:parent-path="[]"
|
||||||
|
@delete-item="(path) => deleteTopLevelItem(path, 'outputParams')"
|
||||||
|
/>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
</el-collapse>
|
||||||
|
</el-collapse>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, reactive, watch, nextTick, onBeforeUnmount, onMounted } from 'vue'
|
||||||
|
import { Plus, Minus } from '@element-plus/icons-vue'
|
||||||
|
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||||
|
import * as monaco from 'monaco-editor';
|
||||||
|
import { getInput } from '@/utils/flow'
|
||||||
|
import { useQuote } from './useQuote.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
data: Object
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['save-success', 'save-error'])
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
nodeParams: [],
|
||||||
|
outputParams: []
|
||||||
|
})
|
||||||
|
|
||||||
|
const codeRef = ref()
|
||||||
|
let editorInstance
|
||||||
|
|
||||||
|
function hasErrors() {
|
||||||
|
const model = editorInstance.getModel();
|
||||||
|
if (!model) return false;
|
||||||
|
|
||||||
|
// 获取当前模型的所有标记
|
||||||
|
const markers = monaco.editor.getModelMarkers({ resource: model.uri });
|
||||||
|
// 检查是否存在错误级别标记
|
||||||
|
return markers.some(marker => marker.severity === monaco.MarkerSeverity.Error);
|
||||||
|
}
|
||||||
|
const initEditor = (type) => {
|
||||||
|
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||||
|
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
||||||
|
allowNonTsExtensions: true, // 允许非 ts 扩展名(.js)
|
||||||
|
checkJs: true, // 对 .js 文件进行类型检查
|
||||||
|
strict: true, // 启用所有严格检查
|
||||||
|
noImplicitAny: false, // 禁止隐式 any
|
||||||
|
noUnusedLocals: true, // 未使用的局部变量报错(可选)
|
||||||
|
noUnusedParameters: true, // 未使用的参数报错(可选)
|
||||||
|
});
|
||||||
|
|
||||||
|
// 确保语义验证开启(默认就是开启的,但可以显式设置)
|
||||||
|
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||||
|
noSemanticValidation: false, // 开启语义检查
|
||||||
|
noSyntaxValidation: false, // 开启语法检查
|
||||||
|
});
|
||||||
|
|
||||||
|
editorInstance = monaco.editor.create(codeRef.value, {
|
||||||
|
value: ['{}'].join('\n'),
|
||||||
|
language: type === 'code' ? 'javascript' : 'json',
|
||||||
|
fontSize: 14,
|
||||||
|
lineNumbers: 'on',
|
||||||
|
roundedSelection: true,
|
||||||
|
scrollBeyondLastLine: false,
|
||||||
|
formatOnPaste: true,
|
||||||
|
formatOnType: true,
|
||||||
|
quickSuggestions: true,
|
||||||
|
suggestOnTriggerCharacters: true,
|
||||||
|
// 自动完成
|
||||||
|
suggest: {
|
||||||
|
showWords: true,
|
||||||
|
showFunctions: true,
|
||||||
|
showVariables: true,
|
||||||
|
showClasses: true,
|
||||||
|
showModules: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置代码值
|
||||||
|
const setValue = (value) => {
|
||||||
|
if (editorInstance) {
|
||||||
|
editorInstance.setValue(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 销毁编辑器
|
||||||
|
const disposeEditor = () => {
|
||||||
|
if (editorInstance) {
|
||||||
|
editorInstance.dispose()
|
||||||
|
editorInstance = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rules = reactive({})
|
||||||
|
const outputRules = reactive({})
|
||||||
|
const dynamicFormRef = ref()
|
||||||
|
const outputFormRef = ref()
|
||||||
|
const activeNames = ref(['1', '2'])
|
||||||
|
|
||||||
|
// 使用共享的 quote 逻辑
|
||||||
|
const { quoteOptions, cascaderRefs, handleTypeChange, cascaderChange, visibleChange } = useQuote(props.data.id)
|
||||||
|
|
||||||
|
// 添加表单项
|
||||||
|
const addFormItem = (e, type) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
const obj = {
|
||||||
|
name: '',
|
||||||
|
type: type === 'nodeParams' ? 'input' : 'string',
|
||||||
|
required: false,
|
||||||
|
children: [],
|
||||||
|
input: ''
|
||||||
|
}
|
||||||
|
if (!formData[type]) formData[type] = []
|
||||||
|
formData[type].push(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除输入参数(非递归)
|
||||||
|
const handleDelete = (index) => {
|
||||||
|
formData.nodeParams.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除顶层输出参数(递归删除通过 FormItemRecursive 的 emit 处理)
|
||||||
|
const deleteTopLevelItem = (fullPath, propPath) => {
|
||||||
|
let currentLevel = formData[propPath]
|
||||||
|
for (let i = 0; i < fullPath.length - 1; i++) {
|
||||||
|
currentLevel = currentLevel[fullPath[i]].children
|
||||||
|
}
|
||||||
|
const lastIndex = fullPath[fullPath.length - 1]
|
||||||
|
currentLevel.splice(lastIndex, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
const initData = () => {
|
||||||
|
const nodeParams = JSON.parse(JSON.stringify(props.data.properties.nodeParams || []))
|
||||||
|
const outputParams = JSON.parse(JSON.stringify(props.data.properties.outputParams || []))
|
||||||
|
formData.nodeParams = nodeParams;
|
||||||
|
formData.outputParams = outputParams;
|
||||||
|
const codeParams = props.data.properties.nodeParams.find(item => item.name === 'requestJson')
|
||||||
|
if (codeParams) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (editorInstance) {
|
||||||
|
setValue(codeParams.input)
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存验证
|
||||||
|
const validateAndSave = async () => {
|
||||||
|
const targetObj = formData.nodeParams.find(item => item.name === 'requestJson');
|
||||||
|
if (targetObj) {
|
||||||
|
// 存在:修改该对象的 input 属性
|
||||||
|
targetObj.input = editorInstance.getValue();
|
||||||
|
} else {
|
||||||
|
formData.nodeParams.push(
|
||||||
|
{ name: "requestJson", type: "input", input: editorInstance.getValue() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let inputValid = true
|
||||||
|
let outputValid = true
|
||||||
|
if (dynamicFormRef.value) {
|
||||||
|
await dynamicFormRef.value.validate((valid) => { if (!valid) inputValid = false })
|
||||||
|
}
|
||||||
|
if (outputFormRef.value) {
|
||||||
|
await outputFormRef.value.validate((valid) => { if (!valid) outputValid = false })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存到 lf
|
||||||
|
lf.setProperties(props.data.id, {
|
||||||
|
...props.data.properties,
|
||||||
|
...formData
|
||||||
|
})
|
||||||
|
|
||||||
|
if (hasErrors()) {
|
||||||
|
emit('save-error')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputValid && outputValid) {
|
||||||
|
emit('save-success')
|
||||||
|
} else {
|
||||||
|
emit('save-error')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
nextTick(() => {
|
||||||
|
initEditor('requestJson')
|
||||||
|
initData()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({ validateAndSave })
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
disposeEditor()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.form__container {
|
||||||
|
margin: 12px 0;
|
||||||
|
|
||||||
|
:deep(.el-row) {
|
||||||
|
align-items: end;
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.param-name {
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.param-type {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.param-value {
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.sub-properties {
|
||||||
|
margin-left: 10px;
|
||||||
|
.zw {
|
||||||
|
margin-left: 15px;
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: -4px;
|
||||||
|
width: 10px;
|
||||||
|
border-left: 1px solid gray;
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
background-color: transparent;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.gSon-properties {
|
||||||
|
margin-left: 10px;
|
||||||
|
.zw {
|
||||||
|
margin-left: 15px;
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: -4px;
|
||||||
|
width: 10px;
|
||||||
|
border-left: 1px solid gray;
|
||||||
|
border-bottom: 1px solid gray;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
background-color: transparent;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteBtn {
|
||||||
|
margin-bottom: 22px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.code__container {
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
text-align: initial;
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
margin: 12px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -323,6 +323,23 @@ function handler(params) {
|
|||||||
],
|
],
|
||||||
outputType: 'json'
|
outputType: 'json'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: cameraSvg,
|
||||||
|
name: "通用指令",
|
||||||
|
type: "device_universal",
|
||||||
|
desc: "执行设备通用指令",
|
||||||
|
action: 'DEVICE_EXECUTE_JSON_COMMAND',
|
||||||
|
nodeType: 'EDGE',
|
||||||
|
nodeParams: [
|
||||||
|
{ name: "terminalId", type: "input", input: "", disabled: true },
|
||||||
|
{ name: "deviceId", type: "input", input: "", required: false, disabled: true },
|
||||||
|
{ name: "requestJson", type: "input", input: `{
|
||||||
|
"a":123
|
||||||
|
}`, required: false, disabled: true },
|
||||||
|
],
|
||||||
|
outputParams: [],
|
||||||
|
outputType: 'json'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: videoSvg,
|
icon: videoSvg,
|
||||||
name: "机械臂",
|
name: "机械臂",
|
||||||
|
|||||||
@ -193,7 +193,8 @@
|
|||||||
v-if="property.componentType === 'number'"
|
v-if="property.componentType === 'number'"
|
||||||
v-model="property.input"
|
v-model="property.input"
|
||||||
:min="0"
|
:min="0"
|
||||||
:controls="false"
|
:max="property.max || Infinity"
|
||||||
|
:step="property.step || 1"
|
||||||
:step-strictly="true"
|
:step-strictly="true"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
clearable
|
clearable
|
||||||
@ -880,6 +881,7 @@ const nodeAction = ref("");
|
|||||||
|
|
||||||
const singleNodeExecution = (e) => {
|
const singleNodeExecution = (e) => {
|
||||||
const { name, nodeType, nodeParams, action } = e.detail;
|
const { name, nodeType, nodeParams, action } = e.detail;
|
||||||
|
console.log('nodeParams', nodeParams)
|
||||||
nodeName.value = name;
|
nodeName.value = name;
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
nodeAction.value = action;
|
nodeAction.value = action;
|
||||||
@ -932,11 +934,80 @@ const clearRun = () => {
|
|||||||
totalRunningTime.value = 0;
|
totalRunningTime.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDeleteKey = (event) => {
|
const NODE_PASTE_OFFSET = 40;
|
||||||
const activeElement = document.activeElement;
|
const NON_COPYABLE_NODE_TYPES = new Set(["start", "end", "selectArea"]);
|
||||||
if (["INPUT", "TEXTAREA"].includes(activeElement?.tagName) || activeElement?.isContentEditable) return;
|
let copiedNodes = [];
|
||||||
|
let pasteCount = 0;
|
||||||
|
|
||||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "z") {
|
const isTextEditing = (event) => {
|
||||||
|
const element = event.target || document.activeElement;
|
||||||
|
return ["INPUT", "TEXTAREA", "SELECT"].includes(element?.tagName)
|
||||||
|
|| element?.isContentEditable;
|
||||||
|
};
|
||||||
|
|
||||||
|
const copySelectedNodes = (event) => {
|
||||||
|
const nodes = lf.getSelectElements().nodes.filter(
|
||||||
|
(node) => !NON_COPYABLE_NODE_TYPES.has(node.type),
|
||||||
|
);
|
||||||
|
if (!nodes.length) return;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
copiedNodes = JSON.parse(JSON.stringify(nodes));
|
||||||
|
pasteCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const pasteCopiedNodes = (event) => {
|
||||||
|
if (!copiedNodes.length || flowStore.disableForm) return;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
pasteCount += 1;
|
||||||
|
const offset = NODE_PASTE_OFFSET * pasteCount;
|
||||||
|
const pastedNodes = copiedNodes.map((sourceNode) => {
|
||||||
|
const properties = JSON.parse(JSON.stringify(sourceNode.properties || {}));
|
||||||
|
const parentId = properties.parentId;
|
||||||
|
delete properties.parentId;
|
||||||
|
|
||||||
|
const newNode = lf.addNode({
|
||||||
|
type: sourceNode.type,
|
||||||
|
x: Number(sourceNode.x || 0) + offset,
|
||||||
|
y: Number(sourceNode.y || 0) + offset,
|
||||||
|
properties,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (sourceNode.type === "branch" && Array.isArray(properties.anchor)) {
|
||||||
|
const oldElseId = `${sourceNode.id}_else`;
|
||||||
|
const newElseId = `${newNode.id}_else`;
|
||||||
|
const anchors = properties.anchor.map((anchor) => (
|
||||||
|
anchor.id === oldElseId ? { ...anchor, id: newElseId } : anchor
|
||||||
|
));
|
||||||
|
lf.setProperties(newNode.id, { ...properties, anchor: anchors });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentId && lf.getNodeModelById(parentId)) {
|
||||||
|
lf.addToGroup(parentId, newNode.id, { x: newNode.x, y: newNode.y });
|
||||||
|
}
|
||||||
|
return newNode;
|
||||||
|
});
|
||||||
|
|
||||||
|
lf.clearSelectElements();
|
||||||
|
if (pastedNodes.length === 1) lf.selectElementById(pastedNodes[0].id);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyboardShortcut = (event) => {
|
||||||
|
if (isTextEditing(event)) return;
|
||||||
|
|
||||||
|
const isModifierKey = event.ctrlKey || event.metaKey;
|
||||||
|
const key = event.key.toLowerCase();
|
||||||
|
if (isModifierKey && key === "c") {
|
||||||
|
if (!flowStore.disableForm) copySelectedNodes(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isModifierKey && key === "v") {
|
||||||
|
pasteCopiedNodes(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isModifierKey && key === "z") {
|
||||||
if (flowStore.disableForm) return;
|
if (flowStore.disableForm) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (event.shiftKey) lf.redo();
|
if (event.shiftKey) lf.redo();
|
||||||
@ -972,7 +1043,7 @@ onMounted(() => {
|
|||||||
initFlow();
|
initFlow();
|
||||||
document.addEventListener("singleNodeExecution", singleNodeExecution);
|
document.addEventListener("singleNodeExecution", singleNodeExecution);
|
||||||
registerBeforeUnload();
|
registerBeforeUnload();
|
||||||
window.addEventListener("keydown", handleDeleteKey);
|
window.addEventListener("keydown", handleKeyboardShortcut);
|
||||||
|
|
||||||
onFlowEvent("openParamsDrawer", (node) => {
|
onFlowEvent("openParamsDrawer", (node) => {
|
||||||
showParamsDrawer.value = true;
|
showParamsDrawer.value = true;
|
||||||
@ -1024,7 +1095,7 @@ onUnmounted(() => {
|
|||||||
if (window.lf === lf) delete window.lf;
|
if (window.lf === lf) delete window.lf;
|
||||||
|
|
||||||
window.removeEventListener("beforeunload", handleBeforeUnload);
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
||||||
window.removeEventListener("keydown", handleDeleteKey);
|
window.removeEventListener("keydown", handleKeyboardShortcut);
|
||||||
document.removeEventListener("singleNodeExecution", singleNodeExecution);
|
document.removeEventListener("singleNodeExecution", singleNodeExecution);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
135
src/views/flow/nodes/function/device_universal.vue
Normal file
135
src/views/flow/nodes/function/device_universal.vue
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<div class="node__container" :class="props.model.id">
|
||||||
|
<NodeState :state="nodeOperatingStatus" :runtimes="runtimes" ref="nodeStateRef">
|
||||||
|
<template #input>
|
||||||
|
<JsonViewer :value="inputJsonData" copyable boxed sort theme="light" />
|
||||||
|
</template>
|
||||||
|
<template #output>
|
||||||
|
<div v-if="nodeOperatingStatus != 'FAILED'">
|
||||||
|
<JsonViewer
|
||||||
|
v-if="!['img', 'video'].includes(props.properties.outputType)"
|
||||||
|
:value="outputJsonData"
|
||||||
|
copyable
|
||||||
|
boxed
|
||||||
|
sort
|
||||||
|
theme="light"
|
||||||
|
/>
|
||||||
|
<el-image
|
||||||
|
v-if="props.properties.outputType === 'img'"
|
||||||
|
v-for="item in outputJsonData.imageUrl"
|
||||||
|
style="width: 60px; height: 60px"
|
||||||
|
:src="item"
|
||||||
|
:preview-src-list="outputJsonData.imageUrl"
|
||||||
|
:preview-teleported="true"
|
||||||
|
show-progress
|
||||||
|
fit="fill"
|
||||||
|
/>
|
||||||
|
<IPlayer
|
||||||
|
v-if="props.properties.outputType === 'video'"
|
||||||
|
v-for="item in outputJsonData.videoUrl"
|
||||||
|
:videoUrl="item"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div v-else>{{ errorInfoData }}</div>
|
||||||
|
</template>
|
||||||
|
</NodeState>
|
||||||
|
<NodeTitle
|
||||||
|
:icon="props.properties.icon"
|
||||||
|
:nodeId="props.model.id"
|
||||||
|
:nodeProperties="props.properties"
|
||||||
|
:nodeType="props.properties.nodeType || 'NONE'"
|
||||||
|
:nodeName="props.properties.name"
|
||||||
|
:nodeDesc="props.properties.desc"
|
||||||
|
@setNodeName="setNodeName"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
import NodeTitle from "../../components/NodeTitle.vue";
|
||||||
|
import NodeState from "../../components/NodeState.vue";
|
||||||
|
import { useFlowEvents } from "../../composables/useFlowEvents.js";
|
||||||
|
import IPlayer from "@/components/IPlayer/index.vue";
|
||||||
|
|
||||||
|
const { onFlowEvent } = useFlowEvents();
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
model: Object,
|
||||||
|
properties: Object,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emits = defineEmits(["contentChange"]);
|
||||||
|
|
||||||
|
const setNodeName = (name) => {
|
||||||
|
const properties = lf.getProperties(props.model.id);
|
||||||
|
lf.setProperties(props.model.id, {
|
||||||
|
...properties,
|
||||||
|
name
|
||||||
|
});
|
||||||
|
emits("contentChange");
|
||||||
|
}
|
||||||
|
|
||||||
|
const nodeOperatingStatus = ref("NORMAL");
|
||||||
|
const runtimes = ref(0);
|
||||||
|
const inputJsonData = ref({});
|
||||||
|
const outputJsonData = ref({});
|
||||||
|
const errorInfoData = ref('');
|
||||||
|
|
||||||
|
const nodeStateRef = ref(null);
|
||||||
|
|
||||||
|
const closePopover = () => {
|
||||||
|
if (nodeStateRef.value) {
|
||||||
|
nodeStateRef.value.closePopover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
onFlowEvent("changeNodeState", (data) => {
|
||||||
|
if (data.nodeId === props.model.id) {
|
||||||
|
nodeOperatingStatus.value = data.status;
|
||||||
|
if (data.endTime && data.startTime) {
|
||||||
|
runtimes.value = data.endTime - data.startTime;
|
||||||
|
}
|
||||||
|
let inputData = {};
|
||||||
|
let output = {};
|
||||||
|
errorInfoData.value = data?.message || ''
|
||||||
|
try {
|
||||||
|
inputData = JSON.parse(data.paramsIn) || {};
|
||||||
|
output = JSON.parse(data.paramsOut) || {};
|
||||||
|
} catch (error) {
|
||||||
|
inputData = data.paramsIn || {};
|
||||||
|
output = data.paramsOut || {};
|
||||||
|
}
|
||||||
|
inputJsonData.value = inputData;
|
||||||
|
outputJsonData.value = output;
|
||||||
|
emits("contentChange");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onFlowEvent("contentChange", (data) => {
|
||||||
|
if (data.id === props.model.id) {
|
||||||
|
nodeOperatingStatus.value = "NORMAL";
|
||||||
|
inputJsonData.value = {};
|
||||||
|
outputJsonData.value = {};
|
||||||
|
emits("contentChange");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onFlowEvent("setProperties", (data) => {
|
||||||
|
if (data.id === props.model.id) {
|
||||||
|
emits("contentChange");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({ closePopover })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.node__container {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -74,6 +74,7 @@ import CodeNode from "../nodes/function/codeNode.vue";
|
|||||||
import CurrentLoopNode from "../nodes/function/currentLoop.vue";
|
import CurrentLoopNode from "../nodes/function/currentLoop.vue";
|
||||||
import SdAgentNode from "../nodes/function/sdAgent.vue";
|
import SdAgentNode from "../nodes/function/sdAgent.vue";
|
||||||
import RecognizeNode from "../nodes/function/recognize.vue";
|
import RecognizeNode from "../nodes/function/recognize.vue";
|
||||||
|
import DeviceUniversal from "../nodes/function/device_universal.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: String,
|
id: String,
|
||||||
@ -98,6 +99,7 @@ const componentMap = {
|
|||||||
currentLoop: CurrentLoopNode,
|
currentLoop: CurrentLoopNode,
|
||||||
sdAgent: SdAgentNode,
|
sdAgent: SdAgentNode,
|
||||||
recognize: RecognizeNode,
|
recognize: RecognizeNode,
|
||||||
|
device_universal: DeviceUniversal,
|
||||||
};
|
};
|
||||||
|
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
|
|||||||
@ -170,9 +170,6 @@
|
|||||||
border
|
border
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
>
|
>
|
||||||
<el-descriptions-item label="日志等级">{{
|
|
||||||
item.logLevel
|
|
||||||
}}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="节点类型">{{
|
<el-descriptions-item label="节点类型">{{
|
||||||
item.nodeType
|
item.nodeType
|
||||||
}}</el-descriptions-item>
|
}}</el-descriptions-item>
|
||||||
@ -180,7 +177,10 @@
|
|||||||
item.message
|
item.message
|
||||||
}}</el-descriptions-item>
|
}}</el-descriptions-item>
|
||||||
<el-descriptions-item label="执行参数">
|
<el-descriptions-item label="执行参数">
|
||||||
<pre>{{ JSON.parse(item.params) }}</pre>
|
<pre>{{ JSON.parse(item.paramsIn) }}</pre>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="返回结果">
|
||||||
|
<pre>{{ JSON.parse(item.paramsOut) }}</pre>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</el-timeline-item>
|
</el-timeline-item>
|
||||||
@ -297,6 +297,7 @@ function getInstList() {
|
|||||||
function cancel() {
|
function cancel() {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
reset();
|
reset();
|
||||||
|
console.log(open.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单重置
|
// 表单重置
|
||||||
@ -404,6 +405,8 @@ function getLogList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleOpenLogDialog(row) {
|
function handleOpenLogDialog(row) {
|
||||||
|
console.log(row)
|
||||||
|
console.log('open', open.value)
|
||||||
logQueryParams.value.instId = row.id;
|
logQueryParams.value.instId = row.id;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user