Skip to content

Commit

Permalink
add child node project
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahhhz committed Jun 12, 2024
1 parent fd5a182 commit 99c17ea
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 29 deletions.
6 changes: 5 additions & 1 deletion dolphinscheduler-ui/src/locales/en_US/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion dolphinscheduler-ui/src/locales/zh_CN/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '线上',
Expand Down Expand Up @@ -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: '运行标志',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 }) => ({
Expand All @@ -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'))
}
}
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ interface ITaskParams {
executionTimeout?: string
startTimeout?: string
processDefinitionCode?: number
childNodeProjectCode?: number | null
conditionResult?: {
successNode?: number[]
failedNode?: number[]
Expand Down

0 comments on commit 99c17ea

Please sign in to comment.