|
|
@ -16,13 +16,13 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import { ref, onMounted, watch } from 'vue' |
|
|
|
import { ref, onMounted, watch } from 'vue' |
|
|
|
import type { Ref } from 'vue' |
|
|
|
import { remove } from 'lodash' |
|
|
|
import type { Graph } from '@antv/x6' |
|
|
|
|
|
|
|
import type { Coordinate, NodeData } from './types' |
|
|
|
|
|
|
|
import { TaskType } from '@/views/projects/task/constants/task-type' |
|
|
|
import { TaskType } from '@/views/projects/task/constants/task-type' |
|
|
|
import { formatParams } from '@/views/projects/task/components/node/format-data' |
|
|
|
import { formatParams } from '@/views/projects/task/components/node/format-data' |
|
|
|
import { useCellUpdate } from './dag-hooks' |
|
|
|
import { useCellUpdate } from './dag-hooks' |
|
|
|
import { WorkflowDefinition } from './types' |
|
|
|
import type { Ref } from 'vue' |
|
|
|
|
|
|
|
import type { Graph } from '@antv/x6' |
|
|
|
|
|
|
|
import type { Coordinate, NodeData, WorkflowDefinition } from './types' |
|
|
|
|
|
|
|
|
|
|
|
interface Options { |
|
|
|
interface Options { |
|
|
|
graph: Ref<Graph | undefined> |
|
|
|
graph: Ref<Graph | undefined> |
|
|
@ -36,8 +36,7 @@ interface Options { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function useTaskEdit(options: Options) { |
|
|
|
export function useTaskEdit(options: Options) { |
|
|
|
const { graph, definition } = options |
|
|
|
const { graph, definition } = options |
|
|
|
const { addNode, setNodeName } = useCellUpdate({ graph }) |
|
|
|
const { addNode, setNodeName, setNodeEdge } = useCellUpdate({ graph }) |
|
|
|
|
|
|
|
|
|
|
|
const taskDefinitions = ref<NodeData[]>( |
|
|
|
const taskDefinitions = ref<NodeData[]>( |
|
|
|
definition.value?.taskDefinitionList || [] |
|
|
|
definition.value?.taskDefinitionList || [] |
|
|
|
) |
|
|
|
) |
|
|
@ -122,6 +121,7 @@ export function useTaskEdit(options: Options) { |
|
|
|
taskDefinitions.value = taskDefinitions.value.map((task) => { |
|
|
|
taskDefinitions.value = taskDefinitions.value.map((task) => { |
|
|
|
if (task.code === currTask.value?.code) { |
|
|
|
if (task.code === currTask.value?.code) { |
|
|
|
setNodeName(task.code + '', taskDef.name) |
|
|
|
setNodeName(task.code + '', taskDef.name) |
|
|
|
|
|
|
|
updatePreTasks(data.preTasks, task.code) |
|
|
|
return { |
|
|
|
return { |
|
|
|
...taskDef, |
|
|
|
...taskDef, |
|
|
|
version: task.version, |
|
|
|
version: task.version, |
|
|
@ -141,6 +141,28 @@ export function useTaskEdit(options: Options) { |
|
|
|
taskModalVisible.value = false |
|
|
|
taskModalVisible.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updatePreTasks(preTasks: number[], code: number) { |
|
|
|
|
|
|
|
if (!preTasks?.length) return |
|
|
|
|
|
|
|
setNodeEdge(String(code), preTasks) |
|
|
|
|
|
|
|
if (definition.value?.processTaskRelationList?.length) { |
|
|
|
|
|
|
|
remove( |
|
|
|
|
|
|
|
definition.value.processTaskRelationList, |
|
|
|
|
|
|
|
(process) => process.postTaskCode === code |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
preTasks.forEach((task) => { |
|
|
|
|
|
|
|
definition.value?.processTaskRelationList.push({ |
|
|
|
|
|
|
|
postTaskCode: code, |
|
|
|
|
|
|
|
preTaskCode: task, |
|
|
|
|
|
|
|
name: '', |
|
|
|
|
|
|
|
preTaskVersion: 1, |
|
|
|
|
|
|
|
postTaskVersion: 1, |
|
|
|
|
|
|
|
conditionType: 'NONE', |
|
|
|
|
|
|
|
conditionParams: {} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
if (graph.value) { |
|
|
|
if (graph.value) { |
|
|
|
graph.value.on('cell:dblclick', ({ cell }) => { |
|
|
|
graph.value.on('cell:dblclick', ({ cell }) => { |
|
|
|