Browse Source

[Fix][UI Next][V1.0.0-Alpha] Fix saving a sub process workflow failure. (#8908)

3.0.0/version-upgrade
Amy0104 3 years ago committed by GitHub
parent
commit
9a93910ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 63
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-child-node.ts
  2. 7
      dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts
  3. 7
      dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts
  4. 1
      dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts

63
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-child-node.ts

@ -17,7 +17,6 @@
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { uniqBy } from 'lodash'
import { import {
querySimpleList, querySimpleList,
queryProcessDefinitionByCode queryProcessDefinitionByCode
@ -46,69 +45,25 @@ export function useChildNode({
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true
const res = await querySimpleList(projectCode) const res = await querySimpleList(projectCode)
options.value = res.map((option: { name: string; code: number }) => ({ options.value = res
.filter((option: { name: string; code: number }) => option.code !== code)
.map((option: { name: string; code: number }) => ({
label: option.name, label: option.name,
value: option.code value: option.code
})) }))
loading.value = false loading.value = false
if (!model.processDefinitionCode) {
model.processDefinitionCode = options.value[0].value
}
} }
const getProcessListByCode = async (processCode: number) => { const getProcessListByCode = async (processCode: number) => {
if (!processCode) return if (!processCode) return
const res = await queryProcessDefinitionByCode(processCode, projectCode) const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(res) model.definition = res
}
const getTaskOptions = (processDefinition: {
processTaskRelationList: []
taskDefinitionList: []
}) => {
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
})
}
)
model.preTaskOptions = uniqBy(preTaskOptions, 'code')
if (!code) return
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)
}
}
)
model.preTasks = preTasks
model.postTaskOptions = postTaskOptions
} }
const onChange = (code: number) => { const onChange = (code: number, options: { label: string }) => {
getProcessListByCode(code) model.name = options.label
} }
onMounted(() => { onMounted(() => {

7
dolphinscheduler-ui-next/src/views/projects/task/components/node/format-data.ts

@ -32,6 +32,9 @@ export function formatParams(data: INodeData): {
taskDefinitionJsonObj: object taskDefinitionJsonObj: object
} { } {
const taskParams: ITaskParams = {} const taskParams: ITaskParams = {}
if (data.taskType === 'SUB_PROCESS') {
taskParams.processDefinitionCode = data.processDefinitionCode
}
if ( if (
data.taskType === 'SPARK' || data.taskType === 'SPARK' ||
data.taskType === 'MR' || data.taskType === 'MR' ||
@ -457,6 +460,10 @@ export function formatModel(data: ITaskData) {
params.jobFlowDefineJson = data.taskParams.jobFlowDefineJson params.jobFlowDefineJson = data.taskParams.jobFlowDefineJson
} }
if (data.taskParams?.processDefinitionCode) {
params.processDefinitionCode = data.taskParams.processDefinitionCode
}
return params return params
} }

7
dolphinscheduler-ui-next/src/views/projects/task/components/node/tasks/use-sub-process.ts

@ -17,6 +17,7 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import * as Fields from '../fields/index' import * as Fields from '../fields/index'
import { useRouter } from 'vue-router'
import type { IJsonItem, INodeData, ITaskData } from '../types' import type { IJsonItem, INodeData, ITaskData } from '../types'
export function useSubProcess({ export function useSubProcess({
@ -30,6 +31,8 @@ export function useSubProcess({
readonly?: boolean readonly?: boolean
data?: ITaskData data?: ITaskData
}) { }) {
const router = useRouter()
const workflowCode = router.currentRoute.value.params.code
const model = reactive({ const model = reactive({
taskType: 'SUB_PROCESS', taskType: 'SUB_PROCESS',
name: '', name: '',
@ -43,7 +46,7 @@ export function useSubProcess({
workerGroup: 'default', workerGroup: 'default',
delayTime: 0, delayTime: 0,
timeout: 30, timeout: 30,
processDefinitionCode: '' processDefinitionCode: 0
} as INodeData) } as INodeData)
let extra: IJsonItem[] = [] let extra: IJsonItem[] = []
@ -76,7 +79,7 @@ export function useSubProcess({
projectCode, projectCode,
from, from,
processName: data?.processName, processName: data?.processName,
code: data?.code code: from === 1 ? 0 : Number(workflowCode)
}), }),
Fields.usePreTasks(model, data?.code) Fields.usePreTasks(model, data?.code)
] as IJsonItem[], ] as IJsonItem[],

1
dolphinscheduler-ui-next/src/views/projects/task/components/node/types.ts

@ -271,6 +271,7 @@ interface ITaskParams {
ruleId?: number ruleId?: number
ruleInputParameter?: IRuleParameters ruleInputParameter?: IRuleParameters
jobFlowDefineJson?: string jobFlowDefineJson?: string
processDefinitionCode?: number
} }
interface INodeData interface INodeData

Loading…
Cancel
Save