123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import {defineStore} from "pinia";
- export const useWorkflowStore = defineStore('workflow', {
- state: () => ({
- graph: <any>null,
- panel: {
- node: <any>null,
- show: false
- },
- systemVars: [
- {label: '查询内容', key: 'sys.query', type: 'String'},
- {label: '用户ID', key: 'sys.user_id', type: 'String'},
- ]
- }),
- getters: {
- },
- actions: {
- init(graph) {
- this.graph = graph
- },
- nodePanel(node) {
- this.panel.node = node
- this.panel.show = true
- },
- nodePanelClose() {
- this.panel.node = null
- this.panel.show = false
- },
- layoutPort(nodeId: string, portId: string) {
- const dom = document.getElementById(portId)
- const node = this.graph.getCellById(nodeId)
- if (dom && node) {
- node.portProp(portId, ['args', 'dy'], dom.offsetTop + 17)
- }
- },
- getInVars(node) {
- const pathNodes = this.graph.getPredecessors(node).reverse()
- const options: any = []
- pathNodes.forEach(n => {
- const wd = n.data.workflowData
- const group = {
- label: wd.subTitle || wd.title,
- key: wd.id,
- options: [
- ...(wd.outVars?.map(v => {
- v.nodeId = wd.id
- return v
- }) || []),
- ...(wd.sysVars?.map(v => {
- v.nodeId = wd.id
- return v
- }) || []),
- ]
- }
- if (group.options.length > 0) {
- options.push(group)
- }
- })
- return options
- }
- },
- })
|