CMVR-IOT-UI/src/views/flow/components/params/useQuote.js

44 lines
1014 B
JavaScript
Raw Normal View History

2026-07-06 11:11:59 +08:00
import { ref } from 'vue'
import { getUpstreamInput } from '@/utils/flow'
2026-07-06 11:11:59 +08:00
export function useQuote(nodeId) {
const quoteOptions = ref([])
const cascaderRefs = ref([])
const refreshQuoteOptions = () => {
quoteOptions.value = getUpstreamInput(nodeId) || []
}
// The option tree must exist before Cascader can render a persisted path.
refreshQuoteOptions()
const handleTypeChange = (property) => {
if (!property) return
if (property.type === 'input') {
property.quote = []
2026-07-06 11:11:59 +08:00
} else {
property.input = ''
refreshQuoteOptions()
2026-07-06 11:11:59 +08:00
}
}
const cascaderChange = (value, property) => {
if (!property) return
property.quote = Array.isArray(value) ? [...value] : []
property.quoteType = value?.[1] === 'input' ? 'input' : 'output'
2026-07-06 11:11:59 +08:00
}
const visibleChange = (visible) => {
if (visible) refreshQuoteOptions()
2026-07-06 11:11:59 +08:00
}
return {
quoteOptions,
cascaderRefs,
handleTypeChange,
cascaderChange,
visibleChange,
refreshQuoteOptions,
2026-07-06 11:11:59 +08:00
}
2026-08-07 14:38:16 +08:00
}