[Fix] [UI Next][V1.0.0-Alpha] Fix the pre task options missing in dag page. (#8876)

* [Fix] [UI Next][V1.0.0-Alpha] Fix pre task options missing  in dag page bug.

* [Feature][UI Next][V1.0.0-Alpha] Remove the useless code parameter in task node component.
This commit is contained in:
Amy0104 2022-03-15 08:51:09 +08:00 committed by GitHub
parent b04a535744
commit 3bc527ff7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 136 additions and 121 deletions

View File

@ -60,6 +60,9 @@ const props = {
type: Number as PropType<number>,
default: 0
},
definition: {
type: Object as PropType<any>
},
processInstance: {
type: Object as PropType<any>
},
@ -152,7 +155,8 @@ const NodeDetailModal = defineComponent({
projectCode: props.projectCode,
data: props.data,
from: props.from,
readonly: props.readonly
readonly: props.readonly,
definition: props.definition
}))
)
@ -160,7 +164,6 @@ const NodeDetailModal = defineComponent({
() => [props.show, props.data],
async () => {
if (!props.show) return
initHeaderLinks(props.processInstance, props.data.taskType)
await nextTick()
detailRef.value.value.setValues(formatModel(props.data))

View File

@ -26,6 +26,7 @@ interface IDetailPanel {
readonly: false
from: number
detailRef?: Ref
definition?: object
}
const NodeDetail = defineComponent({
@ -41,13 +42,14 @@ const NodeDetail = defineComponent({
readonly: false,
from: 0
}
const { data, projectCode, from, readonly } = unref(detailData)
const { data, projectCode, from, readonly, definition } = unref(detailData)
const { elementsRef, rulesRef, model } = useTask({
data,
projectCode,
from,
readonly
readonly,
definition
})
watch(
() => model.taskType,

View File

@ -17,25 +17,39 @@
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { uniqBy } from 'lodash'
import type { IJsonItem } from '../types'
export function usePreTasks(model: { [field: string]: any }): IJsonItem {
export function usePreTasks(
model: { [field: string]: any },
code?: number
): IJsonItem {
const { t } = useI18n()
const options = ref([])
const options = ref([] as { value: number; label: string }[])
const getOptions = () => {
if (!model.preTaskOptions?.length) return []
return model.preTaskOptions.map((task: { code: number; name: 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.preTaskOptions,
() => {
options.value = getOptions()
() => model.definition,
(value) => {
if (!value) return
const {
preTaskOptions,
preTasks = [],
postTaskOptions = []
} = getTaskOptions(value, code)
model.preTasks = preTasks
model.postTaskOptions = postTaskOptions
options.value = getOptions(preTaskOptions)
}
)
@ -51,3 +65,64 @@ export function usePreTasks(model: { [field: string]: any }): IJsonItem {
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
}
}

View File

@ -17,7 +17,6 @@
import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { uniqBy } from 'lodash'
import {
querySimpleList,
queryProcessDefinitionByCode
@ -29,15 +28,13 @@ export function useProcessName({
projectCode,
isCreate,
from,
processName,
code
processName
}: {
model: { [field: string]: any }
projectCode: number
isCreate: boolean
from?: number
processName?: number
code?: number
}): IJsonItem {
const { t } = useI18n()
@ -57,56 +54,7 @@ export function useProcessName({
const getProcessListByCode = async (processCode: number) => {
if (!processCode) return
const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(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
model.definition = res
}
const onChange = (code: number) => {

View File

@ -58,8 +58,7 @@ export function useConditions({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -76,7 +75,7 @@ export function useConditions({
...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(),
...Fields.useConditions(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -67,8 +67,7 @@ export function useDataQuality({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -109,7 +108,7 @@ export function useDataQuality({
field: 'localParams',
isSimple: true
}),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -75,8 +75,7 @@ export function useDataX({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -95,7 +94,7 @@ export function useDataX({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useDataX(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -61,8 +61,7 @@ export function useDependent({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -94,7 +93,7 @@ export function useDependent({
...Fields.useTaskGroup(model, projectCode),
...Fields.useFailed(),
...Fields.useDependent(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -55,8 +55,7 @@ export function useEmr({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -75,7 +74,7 @@ export function useEmr({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useEmr(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -62,8 +62,7 @@ export function useFlink({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -82,7 +81,7 @@ export function useFlink({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useFlink(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -62,8 +62,7 @@ export function useHttp({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -82,7 +81,7 @@ export function useHttp({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useHttp(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -55,8 +55,7 @@ export function useMr({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -75,7 +74,7 @@ export function useMr({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useMr(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -54,8 +54,7 @@ export function usePigeon({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -74,7 +73,7 @@ export function usePigeon({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
Fields.useTargetTaskName(),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -58,8 +58,7 @@ export function useProcedure({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -80,7 +79,7 @@ export function useProcedure({
Fields.useDatasourceType(model),
Fields.useDatasource(model),
...Fields.useProcedure(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -56,8 +56,7 @@ export function usePython({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -76,7 +75,7 @@ export function usePython({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useShell(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -60,8 +60,7 @@ export function useSeaTunnel({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -80,7 +79,7 @@ export function useSeaTunnel({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useSeaTunnel(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -56,8 +56,7 @@ export function useShell({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -76,7 +75,7 @@ export function useShell({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useShell(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -62,8 +62,7 @@ export function useSpark({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -82,7 +81,7 @@ export function useSpark({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useSpark(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -65,8 +65,7 @@ export function useSql({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -88,7 +87,7 @@ export function useSql({
Fields.useDatasource(model),
Fields.useSqlType(model),
...Fields.useSql(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -74,8 +74,7 @@ export function useSqoop({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -94,7 +93,7 @@ export function useSqoop({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useSqoop(model),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -55,8 +55,7 @@ export function useSubProcess({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -79,7 +78,7 @@ export function useSubProcess({
processName: data?.processName,
code: data?.code
}),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -58,8 +58,7 @@ export function useSwitch({
projectCode,
isCreate: !data?.id,
from,
processName: data?.processName,
code: data?.code
processName: data?.processName
})
]
}
@ -78,7 +77,7 @@ export function useSwitch({
Fields.useDelayTime(model),
...Fields.useTimeoutAlarm(model),
...Fields.useSwitch(model, projectCode),
Fields.usePreTasks(model)
Fields.usePreTasks(model, data?.code)
] as IJsonItem[],
model
}

View File

@ -315,6 +315,7 @@ interface INodeData
masterUrl?: string
resourceFiles?: { id: number; fullName: string }[] | null
relation?: RelationType
definition?: object
}
interface ITaskData

View File

@ -23,12 +23,14 @@ export function useTask({
data,
projectCode,
from,
readonly
readonly,
definition
}: {
data: ITaskData
projectCode: number
from?: number
readonly?: boolean
definition?: object
}): {
elementsRef: Ref<IFormItem[]>
rulesRef: Ref<FormRules>
@ -47,6 +49,7 @@ export function useTask({
const { model, json } = nodes[data.taskType || 'SHELL'](params)
jsonRef.value = json
model.definition = definition
const getElements = () => {
const { rules, elements } = getElementByJson(jsonRef.value, model)

View File

@ -287,6 +287,7 @@ export default defineComponent({
taskInstance={currentTaskInstance.value}
onViewLog={handleViewLog}
data={currTask.value as any}
definition={props.definition}
onSubmit={taskConfirm}
onCancel={taskCancel}
/>