diff --git a/dolphinscheduler-ui/src/locales/en_US/project.ts b/dolphinscheduler-ui/src/locales/en_US/project.ts index 68eb7b3102..b8ab673a91 100644 --- a/dolphinscheduler-ui/src/locales/en_US/project.ts +++ b/dolphinscheduler-ui/src/locales/en_US/project.ts @@ -250,7 +250,8 @@ export default { 'The downstream dependent tasks exists. You can not delete the task.', warning_delete_scheduler_dependent_tasks_desc: 'The downstream dependent tasks exists. Are you sure to delete the scheduler?', - warning_too_large_parallelism_number: 'The parallelism number is too large. It is better not to be over 10.' + warning_too_large_parallelism_number: + 'The parallelism number is too large. It is better not to be over 10.' }, task: { on_line: 'Online', @@ -387,6 +388,9 @@ export default { task_type_tips: 'Please select a task type (required)', workflow_name: 'Workflow Name', workflow_name_tips: 'Please select a workflow (required)', + child_node_project: 'Child Node Project', + child_node_project_tips: + 'Select this field for choose different project child node', child_node: 'Child Node', child_node_tips: 'Please select a child node (required)', run_flag: 'Run flag', diff --git a/dolphinscheduler-ui/src/locales/zh_CN/project.ts b/dolphinscheduler-ui/src/locales/zh_CN/project.ts index e1bfd6f672..436120b3d3 100644 --- a/dolphinscheduler-ui/src/locales/zh_CN/project.ts +++ b/dolphinscheduler-ui/src/locales/zh_CN/project.ts @@ -247,7 +247,7 @@ export default { '下游存在依赖,你不能删除该任务.', warning_delete_scheduler_dependent_tasks_desc: '下游存在依赖, 删除定时可能会对下游任务产生影响. 你确定要删除该定时嘛?', - warning_too_large_parallelism_number: '并行度设置太大了, 最好不要超过10.', + warning_too_large_parallelism_number: '并行度设置太大了, 最好不要超过10.' }, task: { on_line: '线上', @@ -383,6 +383,8 @@ export default { task_type_tips: '请选择任务类型(必选)', workflow_name: '工作流名称', workflow_name_tips: '请选择工作流(必选)', + child_node_project: '子节点项目名', + child_node_project_tips: '选择项目名,获取目标项目中的子节点', child_node: '子节点', child_node_tips: '请选择子节点(必选)', run_flag: '运行标志', diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/detail-modal.tsx b/dolphinscheduler-ui/src/views/projects/task/components/node/detail-modal.tsx index e6d9398ece..b4a5ecc331 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/detail-modal.tsx +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/detail-modal.tsx @@ -194,14 +194,24 @@ const NodeDetailModal = defineComponent({ ).then((res: any) => { router.push({ name: 'workflow-instance-detail', - params: { id: res.subProcessInstanceId }, + params: { + id: res.subProcessInstanceId, + projectCode: + props.data.taskParams?.childNodeProjectCode || + props.projectCode + }, query: { code: props.data.taskParams?.processDefinitionCode } }) }) } else { router.push({ name: 'workflow-definition-detail', - params: { code: props.data.taskParams?.processDefinitionCode } + params: { + code: props.data.taskParams?.processDefinitionCode, + projectCode: + props.data.taskParams?.childNodeProjectCode || + props.projectCode + } }) } }, diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-child-node.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-child-node.ts index 98b232f271..07c268cc82 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-child-node.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-child-node.ts @@ -15,13 +15,15 @@ * limitations under the License. */ -import { ref, onMounted } from 'vue' +import { ref, onMounted, watch } from 'vue' import { useI18n } from 'vue-i18n' import { querySimpleList, queryProcessDefinitionByCode } from '@/service/modules/process-definition' import type { IJsonItem } from '../types' +import { queryProjectListPaging } from '@/service/modules/projects' +import type { ProjectRes, ProjectList } from '@/service/modules/projects/types' export function useChildNode({ model, @@ -35,16 +37,18 @@ export function useChildNode({ from?: number processName?: number code?: number -}): IJsonItem { +}): IJsonItem[] { const { t } = useI18n() const options = ref([] as { label: string; value: string }[]) + const accessibleProjectList = ref([] as ProjectList[]) const loading = ref(false) - const getProcessList = async () => { - if (loading.value) return + const diffCode = ref(0) + + const getProcessList = async (project_code: number) => { loading.value = true - const res = await querySimpleList(projectCode) + const res = await querySimpleList(project_code) options.value = res .filter((option: { name: string; code: number }) => option.code !== code) .map((option: { name: string; code: number }) => ({ @@ -59,32 +63,79 @@ export function useChildNode({ model.definition = res } + const getAccessibleProjectList = async () => { + queryProjectListPaging({ + pageNo: 1, + pageSize: 999 + }) + .then((res: ProjectRes) => { + accessibleProjectList.value = res.totalList + }) + .catch(() => { + accessibleProjectList.value = [] + }) + } + + watch( + () => model?.childNodeProjectCode, + (val) => { + diffCode.value = val || projectCode + } + ) + onMounted(() => { if (from === 1 && processName) { getProcessListByCode(processName) } - getProcessList() + getAccessibleProjectList() + + getProcessList(projectCode).then(() => { + if (diffCode.value && diffCode.value != projectCode) { + getProcessList(diffCode.value) + } + }) }) - return { - type: 'select', - field: 'processDefinitionCode', - span: 24, - name: t('project.node.child_node'), - props: { - loading: loading, - filterable: true + return [ + { + type: 'select', + field: 'childNodeProjectCode', + span: 24, + name: t('project.node.child_node_project'), + props: { + 'label-field': 'name', + 'value-field': 'code', + 'onUpdate:value': (value: any) => { + model.processDefinitionCode = null + getProcessList(value || projectCode) + }, + filterable: true, + clearable: true, + placeholder: t('project.node.child_node_project_tips') + }, + options: accessibleProjectList, + class: 'select-project-name' }, - options: options, - class: 'select-child-node', - validate: { - trigger: ['input', 'blur'], - required: true, - validator(unuse: any, value: number) { - if (!value) { - return Error(t('project.node.child_node_tips')) + { + type: 'select', + field: 'processDefinitionCode', + span: 24, + name: t('project.node.child_node'), + props: { + loading: loading, + filterable: true + }, + options: options, + class: 'select-child-node', + validate: { + trigger: ['input', 'blur'], + required: true, + validator(unuse: any, value: number) { + if (!value) { + return Error(t('project.node.child_node_tips')) + } } } } - } + ] } diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts index 2ab1712b6f..303f3640eb 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts @@ -36,6 +36,7 @@ export function formatParams(data: INodeData): { const taskParams: ITaskParams = {} if (data.taskType === 'SUB_PROCESS' || data.taskType === 'DYNAMIC') { taskParams.processDefinitionCode = data.processDefinitionCode + taskParams.childNodeProjectCode = data.childNodeProjectCode || null } if (data.taskType === 'JAVA') { diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts index 8f498fbfe9..170de0f19f 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-dynamic.ts @@ -68,7 +68,7 @@ export function useDynamic({ Fields.useEnvironmentName(model, !data?.id), ...Fields.useTaskGroup(model, projectCode), ...Fields.useTimeoutAlarm(model), - Fields.useChildNode({ + ...Fields.useChildNode({ model, projectCode, from, diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts index 8c855666bc..b7d89d32ae 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/tasks/use-sub-process.ts @@ -60,7 +60,7 @@ export function useSubProcess({ Fields.useEnvironmentName(model, !data?.id), ...Fields.useTaskGroup(model, projectCode), ...Fields.useTimeoutAlarm(model), - Fields.useChildNode({ + ...Fields.useChildNode({ model, projectCode, from, diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts index 606339b16f..9fba40241e 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts @@ -366,6 +366,7 @@ interface ITaskParams { executionTimeout?: string startTimeout?: string processDefinitionCode?: number + childNodeProjectCode?: number | null conditionResult?: { successNode?: number[] failedNode?: number[]