lxl-dev #3
@ -80,6 +80,7 @@ export const loadFlowItemScopedRuntimeRoles = async (items = []) => {
|
|||||||
roleKey: `${item.itemId}:${occurrence}:${role.roleKey}`,
|
roleKey: `${item.itemId}:${occurrence}:${role.roleKey}`,
|
||||||
sourceRoleKey: role.roleKey,
|
sourceRoleKey: role.roleKey,
|
||||||
itemId: item.itemId,
|
itemId: item.itemId,
|
||||||
|
itemOccurrence: occurrence,
|
||||||
itemName: item.itemName || String(item.itemId),
|
itemName: item.itemName || String(item.itemId),
|
||||||
displayName: `${item.itemName || item.itemId} / ${role.displayName}`,
|
displayName: `${item.itemName || item.itemId} / ${role.displayName}`,
|
||||||
}))
|
}))
|
||||||
@ -103,6 +104,7 @@ export const createRuntimeAssignments = (roles = [], primaryRobotId = '') => rol
|
|||||||
roleKey: role.roleKey,
|
roleKey: role.roleKey,
|
||||||
...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}),
|
...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}),
|
||||||
...(role.itemId != null ? { itemId: role.itemId } : {}),
|
...(role.itemId != null ? { itemId: role.itemId } : {}),
|
||||||
|
...(role.itemOccurrence != null ? { itemOccurrence: role.itemOccurrence } : {}),
|
||||||
members: [{
|
members: [{
|
||||||
memberKey: `${role.roleKey}_1`,
|
memberKey: `${role.roleKey}_1`,
|
||||||
robotId: index === 0 ? primaryRobotId || role.legacyRobotId || '' : role.legacyRobotId || '',
|
robotId: index === 0 ? primaryRobotId || role.legacyRobotId || '' : role.legacyRobotId || '',
|
||||||
|
|||||||
@ -156,6 +156,7 @@ const initialize = async () => {
|
|||||||
roleKey: role.roleKey,
|
roleKey: role.roleKey,
|
||||||
...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}),
|
...(role.sourceRoleKey ? { sourceRoleKey: role.sourceRoleKey } : {}),
|
||||||
...(role.itemId != null ? { itemId: role.itemId } : {}),
|
...(role.itemId != null ? { itemId: role.itemId } : {}),
|
||||||
|
...(role.itemOccurrence != null ? { itemOccurrence: role.itemOccurrence } : {}),
|
||||||
members: [{
|
members: [{
|
||||||
...existingMember,
|
...existingMember,
|
||||||
memberKey: `${role.roleKey}_1`,
|
memberKey: `${role.roleKey}_1`,
|
||||||
@ -182,7 +183,12 @@ const validate = () => {
|
|||||||
if (slot.required && !member.devices[slot.slotKey]) return `请为“${role.displayName}”选择“${slot.displayName}”`
|
if (slot.required && !member.devices[slot.slotKey]) return `请为“${role.displayName}”选择“${slot.displayName}”`
|
||||||
const deviceId = member.devices[slot.slotKey]
|
const deviceId = member.devices[slot.slotKey]
|
||||||
if (!deviceId) continue
|
if (!deviceId) continue
|
||||||
const physicalKey = `${member.robotId}:${deviceId}`
|
// 不同检测项按顺序独立执行,可以复用同一台机器人及其设备。
|
||||||
|
// 仅同一检测项内部的多个角色/用途需要遵守设备复用规则。
|
||||||
|
const itemScope = role.itemId == null
|
||||||
|
? 'task'
|
||||||
|
: `${role.itemId}:${role.itemOccurrence || 1}`
|
||||||
|
const physicalKey = `${itemScope}:${member.robotId}:${deviceId}`
|
||||||
const existingUse = physicalDeviceUses.get(physicalKey)
|
const existingUse = physicalDeviceUses.get(physicalKey)
|
||||||
if (existingUse && (!slot.allowReuse || !existingUse.allowReuse)) {
|
if (existingUse && (!slot.allowReuse || !existingUse.allowReuse)) {
|
||||||
return `“${existingUse.roleName} / ${existingUse.slotName}”和“${role.displayName} / ${slot.displayName}”不能使用同一个设备`
|
return `“${existingUse.roleName} / ${existingUse.slotName}”和“${role.displayName} / ${slot.displayName}”不能使用同一个设备`
|
||||||
|
|||||||
@ -356,21 +356,28 @@ const deleteTopLevelItem = (fullPath, propPath) => {
|
|||||||
* 初始化 initData 对应的数据或交互;作用范围仅限当前组件或模块。
|
* 初始化 initData 对应的数据或交互;作用范围仅限当前组件或模块。
|
||||||
*/
|
*/
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
const nodeParams = JSON.parse(JSON.stringify(props.data.properties.nodeParams || []))
|
const properties = props.data?.properties || {}
|
||||||
const outputParams = JSON.parse(JSON.stringify(props.data.properties.outputParams || []))
|
const nodeParams = JSON.parse(JSON.stringify(properties.nodeParams || []))
|
||||||
|
const outputParams = JSON.parse(JSON.stringify(properties.outputParams || []))
|
||||||
formData.nodeParams = nodeParams;
|
formData.nodeParams = nodeParams;
|
||||||
formData.outputParams = outputParams;
|
formData.outputParams = outputParams;
|
||||||
formData.executionTarget = JSON.parse(JSON.stringify(props.data.properties.executionTarget || {}));
|
formData.executionTarget = JSON.parse(JSON.stringify(properties.executionTarget || {}));
|
||||||
const codeParams = props.data.properties.nodeParams.find(item => item.name === 'requestJson')
|
const codeParams = nodeParams.find(item => item.name === 'requestJson')
|
||||||
if (codeParams) {
|
if (codeParams) {
|
||||||
setTimeout(() => {
|
nextTick(() => {
|
||||||
if (editorInstance) {
|
if (editorInstance) {
|
||||||
setValue(codeParams.input)
|
setValue(codeParams.input)
|
||||||
}
|
}
|
||||||
}, 100)
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.data,
|
||||||
|
initData,
|
||||||
|
{ immediate: true, deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
// 保存验证
|
// 保存验证
|
||||||
/**
|
/**
|
||||||
* 校验 validateAndSave 对应的数据或交互;作用范围仅限当前组件或模块。
|
* 校验 validateAndSave 对应的数据或交互;作用范围仅限当前组件或模块。
|
||||||
@ -420,7 +427,8 @@ const validateAndSave = async () => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
initEditor('requestJson')
|
initEditor('requestJson')
|
||||||
initData()
|
const codeParams = formData.nodeParams.find(item => item.name === 'requestJson')
|
||||||
|
if (codeParams) setValue(codeParams.input)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ const handleRoleChange = () => {
|
|||||||
emitTarget()
|
emitTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
const init = () => {
|
const syncFromModel = () => {
|
||||||
roles.value = getResourceRoles()
|
roles.value = getResourceRoles()
|
||||||
const value = props.modelValue || {}
|
const value = props.modelValue || {}
|
||||||
localTarget.roleKey = roles.value.some((role) => role.roleKey === value.roleKey)
|
localTarget.roleKey = roles.value.some((role) => role.roleKey === value.roleKey)
|
||||||
@ -88,10 +88,13 @@ const init = () => {
|
|||||||
localTarget.dispatchPolicy = value.dispatchPolicy || 'ONE'
|
localTarget.dispatchPolicy = value.dispatchPolicy || 'ONE'
|
||||||
deviceSlotKey.value = value.deviceSlotKey || value.deviceBindings?.[0]?.slotKey || ''
|
deviceSlotKey.value = value.deviceSlotKey || value.deviceBindings?.[0]?.slotKey || ''
|
||||||
selectDefaultSlot()
|
selectDefaultSlot()
|
||||||
emitTarget()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.data.id, init, { immediate: true })
|
watch(
|
||||||
|
[() => props.data.id, () => props.modelValue],
|
||||||
|
syncFromModel,
|
||||||
|
{ immediate: true, deep: true }
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user