diff --git a/dolphinscheduler-ui-next/src/store/project/task-node.ts b/dolphinscheduler-ui-next/src/store/project/task-node.ts new file mode 100644 index 0000000000..9d8ec7e95e --- /dev/null +++ b/dolphinscheduler-ui-next/src/store/project/task-node.ts @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { defineStore } from 'pinia' +import { uniqBy } from 'lodash' +import type { TaskNodeState, EditWorkflowDefinition, IOption } from './types' + +export const useTaskNodeStore = defineStore({ + id: 'project-task', + state: (): TaskNodeState => ({ + preTaskOptions: [], + postTaskOptions: [], + preTasks: [] + }), + persist: true, + getters: { + getPreTaskOptions(): IOption[] { + return this.preTaskOptions + }, + getPostTaskOptions(): IOption[] { + return this.postTaskOptions + }, + getPreTasks(): number[] { + return this.preTasks + } + }, + actions: { + updateDefinition(definition?: EditWorkflowDefinition, code?: number) { + if (!definition) return + const { processTaskRelationList = [], taskDefinitionList = [] } = + definition + + const preTaskOptions: { value: number; label: string }[] = [] + const tasks: { [field: number]: string } = {} + taskDefinitionList.forEach( + (task: { code: number; taskType: string; name: string }) => { + tasks[task.code] = task.name + if (task.code === code) return + if ( + task.taskType === 'CONDITIONS' && + processTaskRelationList.filter( + (relation: { preTaskCode: number }) => + relation.preTaskCode === task.code + ).length >= 2 + ) { + return + } + preTaskOptions.push({ + value: task.code, + label: task.name + }) + } + ) + + this.preTaskOptions = uniqBy(preTaskOptions, 'value') + if (!code) return + const preTasks: number[] = [] + const postTaskOptions: { value: number; label: string }[] = [] + processTaskRelationList.forEach( + (relation: { preTaskCode: number; postTaskCode: number }) => { + if (relation.preTaskCode === code) { + postTaskOptions.push({ + value: relation.postTaskCode, + label: tasks[relation.postTaskCode] + }) + } + if (relation.postTaskCode === code && relation.preTaskCode !== 0) { + preTasks.push(relation.preTaskCode) + } + } + ) + this.preTasks = preTasks + this.postTaskOptions = postTaskOptions + } + } +}) diff --git a/dolphinscheduler-ui-next/src/store/project/types.ts b/dolphinscheduler-ui-next/src/store/project/types.ts new file mode 100644 index 0000000000..38b8803d78 --- /dev/null +++ b/dolphinscheduler-ui-next/src/store/project/types.ts @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { EditWorkflowDefinition } from '@/views/projects/workflow/components/dag/types' +import type { IOption } from '@/components/form/types' + +interface TaskNodeState { + postTaskOptions: IOption[] + preTaskOptions: IOption[] + preTasks: number[] +} +export { TaskNodeState, EditWorkflowDefinition, IOption } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx b/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx index 615466d1cd..c76b37ee67 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx @@ -23,13 +23,13 @@ import { nextTick, provide, computed, - h + h, + Ref } from 'vue' import { useI18n } from 'vue-i18n' import Modal from '@/components/modal' import Detail from './detail' import { formatModel } from './format-data' -import type { ITaskData, ITaskType } from './types' import { HistoryOutlined, ProfileOutlined, @@ -38,10 +38,13 @@ import { import { NIcon } from 'naive-ui' import { TASK_TYPES_MAP } from '../../constants/task-type' import { Router, useRouter } from 'vue-router' -import { +import type { + ITaskData, + ITaskType, + EditWorkflowDefinition, IWorkflowTaskInstance, WorkflowInstance -} from '@/views/projects/workflow/components/dag/types' +} from './types' const props = { show: { @@ -65,7 +68,7 @@ const props = { default: 0 }, definition: { - type: Object as PropType + type: Object as PropType> }, processInstance: { type: Object as PropType diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx b/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx index 69093077c8..8cf7bac541 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/detail.tsx @@ -18,7 +18,7 @@ import { defineComponent, ref, watch, inject, Ref, unref } from 'vue' import Form from '@/components/form' import { useTask } from './use-task' -import type { ITaskData } from './types' +import type { ITaskData, EditWorkflowDefinition } from './types' interface IDetailPanel { projectCode: number @@ -26,7 +26,7 @@ interface IDetailPanel { readonly: false from: number detailRef?: Ref - definition?: object + definition?: EditWorkflowDefinition } const NodeDetail = defineComponent({ diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts index 349e7f0504..7b14fb3b85 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-conditions.ts @@ -15,48 +15,23 @@ * limitations under the License. */ -import { ref, watch } from 'vue' import { useI18n } from 'vue-i18n' +import { useTaskNodeStore } from '@/store/project/task-node' import { useRelationCustomParams, useTimeoutAlarm } from '.' import type { IJsonItem } from '../types' export function useConditions(model: { [field: string]: any }): IJsonItem[] { const { t } = useI18n() + const taskStore = useTaskNodeStore() - const taskCodeOptions = ref([] as { label: string; value: number }[]) - const postTasksOptions = ref([] as { label: string; value: number }[]) + const preTaskOptions = taskStore.preTaskOptions.filter((option) => + taskStore.preTasks.includes(Number(option.value)) + ) const stateOptions = [ { label: t('project.node.success'), value: 'success' }, { label: t('project.node.failed'), value: 'failed' } ] - watch( - () => model.preTasks, - () => { - taskCodeOptions.value = - model.preTaskOptions - ?.filter((task: { code: number }) => - model.preTasks?.includes(task.code) - ) - .map((task: { code: number; name: string }) => ({ - value: task.code, - label: task.name - })) || [] - } - ) - - watch( - () => model.postTaskOptions, - () => { - postTasksOptions.value = model.postTasksOptions.map( - (task: { code: number; name: string }) => ({ - value: task.code, - label: task.name - }) - ) - } - ) - return [ { type: 'select', @@ -76,7 +51,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] { props: { clearable: true }, - options: postTasksOptions + options: taskStore.getPostTaskOptions }, { type: 'select', @@ -96,7 +71,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] { props: { clearable: true }, - options: postTasksOptions + options: taskStore.getPostTaskOptions }, ...useTimeoutAlarm(model), ...useRelationCustomParams({ @@ -110,7 +85,7 @@ export function useConditions(model: { [field: string]: any }): IJsonItem[] { type: 'select', field: 'depTaskCode', span: 10, - options: taskCodeOptions + options: preTaskOptions }, { type: 'select', diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts index 39d95f0597..5a472d92ae 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-pre-tasks.ts @@ -15,43 +15,13 @@ * limitations under the License. */ -import { ref, watch } from 'vue' import { useI18n } from 'vue-i18n' -import { uniqBy } from 'lodash' +import { useTaskNodeStore } from '@/store/project/task-node' import type { IJsonItem } from '../types' -export function usePreTasks( - model: { [field: string]: any }, - code?: number -): IJsonItem { +export function usePreTasks(): IJsonItem { const { t } = useI18n() - - const options = ref([] as { value: number; label: string }[]) - - const getOptions = ( - options: { code: number; name: string }[] - ): { value: number; label: string }[] => { - if (!options?.length) return [] - return options.map((task: { code: number; name: string }) => ({ - value: task.code, - label: task.name - })) - } - - watch( - () => model.definition, - (value) => { - if (!value) return - const { - preTaskOptions, - preTasks = [], - postTaskOptions = [] - } = getTaskOptions(value, code) - model.preTasks = preTasks - model.postTaskOptions = postTaskOptions - options.value = getOptions(preTaskOptions) - } - ) + const taskStore = useTaskNodeStore() return { type: 'select', @@ -63,67 +33,6 @@ export function usePreTasks( multiple: true, filterable: true }, - options - } -} - -function getTaskOptions( - processDefinition: { - processTaskRelationList: [] - taskDefinitionList: [] - }, - code?: number -): { - preTaskOptions: { code: number; name: string }[] - preTasks?: number[] - postTaskOptions?: { code: number; name: string }[] -} { - const { processTaskRelationList = [], taskDefinitionList = [] } = - processDefinition - - const preTaskOptions: { code: number; name: string }[] = [] - const tasks: { [field: number]: string } = {} - taskDefinitionList.forEach( - (task: { code: number; taskType: string; name: string }) => { - tasks[task.code] = task.name - if (task.code === code) return - if ( - task.taskType === 'CONDITIONS' && - processTaskRelationList.filter( - (relation: { preTaskCode: number }) => - relation.preTaskCode === task.code - ).length >= 2 - ) { - return - } - preTaskOptions.push({ - code: task.code, - name: task.name - }) - } - ) - if (!code) - return { - preTaskOptions: uniqBy(preTaskOptions, 'code') - } - const preTasks: number[] = [] - const postTaskOptions: { code: number; name: string }[] = [] - processTaskRelationList.forEach( - (relation: { preTaskCode: number; postTaskCode: number }) => { - if (relation.preTaskCode === code) { - postTaskOptions.push({ - code: relation.postTaskCode, - name: tasks[relation.postTaskCode] - }) - } - if (relation.postTaskCode === code && relation.preTaskCode !== 0) { - preTasks.push(relation.preTaskCode) - } - } - ) - return { - preTaskOptions: uniqBy(preTaskOptions, 'code'), - preTasks, - postTaskOptions + options: taskStore.getPreTaskOptions } } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts index 79f6876c0c..2dfdb03efc 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-conditions.ts @@ -75,7 +75,7 @@ export function useConditions({ ...Fields.useTaskGroup(model, projectCode), ...Fields.useFailed(), ...Fields.useConditions(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts index 3ae8b91e42..0b73730ed0 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-data-quality.ts @@ -108,7 +108,7 @@ export function useDataQuality({ field: 'localParams', isSimple: true }), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts index 41227365ac..9faf1856a9 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-datax.ts @@ -94,7 +94,7 @@ export function useDataX({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useDataX(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts index 2ac5bcc1de..c0694cb33f 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-dependent.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { ref, reactive, watch } from 'vue' +import { reactive } from 'vue' import * as Fields from '../fields/index' import type { IJsonItem, INodeData, ITaskData } from '../types' @@ -30,7 +30,6 @@ export function useDependent({ readonly?: boolean data?: ITaskData }) { - const taskCodeOptions = ref([] as { label: string; value: number }[]) const model = reactive({ taskType: 'DEPENDENT', name: '', @@ -66,21 +65,6 @@ export function useDependent({ ] } - watch( - () => model.preTasks, - () => { - taskCodeOptions.value = - model.preTaskOptions - ?.filter((task: { code: number }) => - model.preTasks?.includes(task.code) - ) - .map((task: { code: number; name: string }) => ({ - value: task.code, - label: task.name - })) || [] - } - ) - return { json: [ Fields.useName(), @@ -93,7 +77,7 @@ export function useDependent({ ...Fields.useTaskGroup(model, projectCode), ...Fields.useFailed(), ...Fields.useDependent(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts index ae1ce1ba05..24de66d106 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-emr.ts @@ -74,7 +74,7 @@ export function useEmr({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useEmr(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts index 812210680b..c62f1db756 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-flink.ts @@ -81,7 +81,7 @@ export function useFlink({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useFlink(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts index dea9365157..a41f3fb1b3 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-http.ts @@ -81,7 +81,7 @@ export function useHttp({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useHttp(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts index 60eb7ff92b..496a88ecec 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-mr.ts @@ -74,7 +74,7 @@ export function useMr({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useMr(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts index a0c330f70b..cad4d31195 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-pigeon.ts @@ -73,7 +73,7 @@ export function usePigeon({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), Fields.useTargetTaskName(), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts index 26465b193e..df3f11ae3a 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-procedure.ts @@ -79,7 +79,7 @@ export function useProcedure({ Fields.useDatasourceType(model), Fields.useDatasource(model), ...Fields.useProcedure(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts index ce44c09e76..c9cb89b3d8 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-python.ts @@ -75,7 +75,7 @@ export function usePython({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useShell(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts index 30432a11da..e14d4349d9 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sea-tunnel.ts @@ -79,7 +79,7 @@ export function useSeaTunnel({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useSeaTunnel(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts index 33423eefb9..86812baddf 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-shell.ts @@ -75,7 +75,7 @@ export function useShell({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useShell(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts index d44bbd78a8..6ca7a05ecc 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-spark.ts @@ -81,7 +81,7 @@ export function useSpark({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useSpark(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts index b155ee4fa0..639ae73c82 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sql.ts @@ -87,7 +87,7 @@ export function useSql({ Fields.useDatasource(model), Fields.useSqlType(model), ...Fields.useSql(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts index 00f751341d..6d272f29a8 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sqoop.ts @@ -93,7 +93,7 @@ export function useSqoop({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useSqoop(model), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts index e698a49d4f..f2b85987e8 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts @@ -81,7 +81,7 @@ export function useSubProcess({ processName: data?.processName, code: from === 1 ? 0 : Number(workflowCode) }), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts index 9944c94bba..1408f369ad 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-switch.ts @@ -77,7 +77,7 @@ export function useSwitch({ Fields.useDelayTime(model), ...Fields.useTimeoutAlarm(model), ...Fields.useSwitch(model, projectCode), - Fields.usePreTasks(model, data?.code) + Fields.usePreTasks() ] as IJsonItem[], model } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts index 1509969dde..bab4a2886d 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts @@ -17,7 +17,6 @@ import { VNode } from 'vue' import type { SelectOption } from 'naive-ui' - import type { TaskType } from '@/views/projects/task/constants/task-type' import type { IDataBase } from '@/service/modules/data-source/types' import type { @@ -26,6 +25,11 @@ import type { FormRules, IJsonItemParams } from '@/components/form/types' +export type { EditWorkflowDefinition } from '@/views/projects/workflow/components/dag/types' +export type { + IWorkflowTaskInstance, + WorkflowInstance +} from '@/views/projects/workflow/components/dag/types' type ProgramType = 'JAVA' | 'SCALA' | 'PYTHON' type SourceType = 'MYSQL' | 'HDFS' | 'HIVE' diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts index 00153e003c..82c01e6f92 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/use-task.ts @@ -14,10 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ref, Ref, watch } from 'vue' +import { ref, Ref, unref, watch } from 'vue' import nodes from './tasks' import getElementByJson from '@/components/form/get-elements-by-json' -import { IFormItem, IJsonItem, INodeData, ITaskData, FormRules } from './types' +import { useTaskNodeStore } from '@/store/project/task-node' +import type { + IFormItem, + IJsonItem, + INodeData, + ITaskData, + FormRules, + EditWorkflowDefinition +} from './types' export function useTask({ data, @@ -30,15 +38,19 @@ export function useTask({ projectCode: number from?: number readonly?: boolean - definition?: object + definition?: EditWorkflowDefinition }): { elementsRef: Ref rulesRef: Ref model: INodeData } { + const taskStore = useTaskNodeStore() + taskStore.updateDefinition(unref(definition), data?.code) + const jsonRef = ref([]) as Ref const elementsRef = ref([]) as Ref const rulesRef = ref({}) + const params = { projectCode, from, @@ -49,7 +61,7 @@ export function useTask({ const { model, json } = nodes[data.taskType || 'SHELL'](params) jsonRef.value = json - model.definition = definition + model.preTasks = taskStore.getPreTasks const getElements = () => { const { rules, elements } = getElementByJson(jsonRef.value, model) diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts index f001924e41..8069ac924e 100644 --- a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts +++ b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-cell-update.ts @@ -99,9 +99,9 @@ export function useCellUpdate(options: Options) { if (!edges.length) return [] const targets = [] as number[] edges.forEach((edge) => { - const targetNode = edge.getSourceNode() - if (targetNode) { - targets.push(Number(targetNode.id)) + const sourceNode = edge.getSourceNode() + if (sourceNode && sourceNode.id !== id) { + targets.push(Number(sourceNode.id)) } }) return targets