Browse Source

[Bug-13008] [UI] When using the complement function, turn on the dependent mode to generate multiple unrelated workflow instances (#13009)

* Fix dirty data generated by dependent nodes.
3.2.0-release
Kerwin 2 years ago committed by GitHub
parent
commit
597ae5ff7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts
  2. 19
      dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts
  3. 19
      dolphinscheduler-ui/src/views/projects/task/components/node/types.ts

39
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-dependent.ts

@ -29,7 +29,9 @@ import {
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import type { import type {
IJsonItem, IJsonItem,
IDependpendItem, IDependentItem,
IDependentItemOptions,
IDependTaskOptions,
IDependTask, IDependTask,
ITaskState, ITaskState,
IDateType IDateType
@ -49,6 +51,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
const taskCache = {} as { const taskCache = {} as {
[key: number]: { label: string; value: number }[] [key: number]: { label: string; value: number }[]
} }
const selectOptions = ref([] as IDependTaskOptions[])
const CYCLE_LIST = [ const CYCLE_LIST = [
{ {
@ -236,25 +239,30 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
watch( watch(
() => model.dependTaskList, () => model.dependTaskList,
(value) => { (value) => {
value.forEach((item: IDependTask) => { selectOptions.value = []
value.forEach((item: IDependTask, taskIndex: number) => {
if (!item.dependItemList?.length) return if (!item.dependItemList?.length) return
item.dependItemList?.forEach(async (dependItem: IDependpendItem) => { const itemListOptions = ref([] as IDependentItemOptions[])
item.dependItemList?.forEach(async (dependItem: IDependentItem, itemIndex: number) => {
itemListOptions.value[itemIndex] = {}
if (dependItem.projectCode) { if (dependItem.projectCode) {
dependItem.definitionCodeOptions = await getProcessList( itemListOptions.value[itemIndex].definitionCodeOptions = await getProcessList(
dependItem.projectCode dependItem.projectCode
) )
} }
if (dependItem.projectCode && dependItem.definitionCode) { if (dependItem.projectCode && dependItem.definitionCode) {
dependItem.depTaskCodeOptions = await getTaskList( itemListOptions.value[itemIndex].depTaskCodeOptions = await getTaskList(
dependItem.projectCode, dependItem.projectCode,
dependItem.definitionCode dependItem.definitionCode
) )
} }
if (dependItem.cycle) { if (dependItem.cycle) {
dependItem.dateOptions = DATE_LIST[dependItem.cycle] itemListOptions.value[itemIndex].dateOptions = DATE_LIST[dependItem.cycle]
} }
}) })
selectOptions.value[taskIndex] = {} as IDependTaskOptions
selectOptions.value[taskIndex].dependItemList = itemListOptions.value
}) })
} }
) )
@ -277,7 +285,13 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
filterable: true, filterable: true,
onUpdateValue: async (projectCode: number) => { onUpdateValue: async (projectCode: number) => {
const item = model.dependTaskList[i].dependItemList[j] const item = model.dependTaskList[i].dependItemList[j]
item.definitionCodeOptions = await getProcessList(projectCode) const options = selectOptions?.value[i] || {}
const itemListOptions = options?.dependItemList || []
const itemOptions = {} as IDependentItemOptions
itemOptions.definitionCodeOptions = await getProcessList(projectCode)
itemListOptions[j] = itemOptions
options.dependItemList = itemListOptions
selectOptions.value[i] = options
item.depTaskCode = null item.depTaskCode = null
item.definitionCode = null item.definitionCode = null
} }
@ -303,15 +317,14 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
filterable: true, filterable: true,
onUpdateValue: async (processCode: number) => { onUpdateValue: async (processCode: number) => {
const item = model.dependTaskList[i].dependItemList[j] const item = model.dependTaskList[i].dependItemList[j]
item.depTaskCodeOptions = await getTaskList( selectOptions.value[i].dependItemList[j].depTaskCodeOptions = await getTaskList(
item.projectCode, item.projectCode,
processCode processCode
) )
item.depTaskCode = 0 item.depTaskCode = 0
} }
}, },
options: options: selectOptions.value[i]?.dependItemList[j]
model.dependTaskList[i]?.dependItemList[j]
?.definitionCodeOptions || [], ?.definitionCodeOptions || [],
path: `dependTaskList.${i}.dependItemList.${j}.definitionCode`, path: `dependTaskList.${i}.dependItemList.${j}.definitionCode`,
rule: { rule: {
@ -333,7 +346,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
filterable: true filterable: true
}, },
options: options:
model.dependTaskList[i]?.dependItemList[j]?.depTaskCodeOptions || selectOptions.value[i]?.dependItemList[j]?.depTaskCodeOptions ||
[], [],
path: `dependTaskList.${i}.dependItemList.${j}.depTaskCode`, path: `dependTaskList.${i}.dependItemList.${j}.depTaskCode`,
rule: { rule: {
@ -353,7 +366,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
name: t('project.node.cycle_time'), name: t('project.node.cycle_time'),
props: { props: {
onUpdateValue: (value: IDateType) => { onUpdateValue: (value: IDateType) => {
model.dependTaskList[i].dependItemList[j].dateOptions = selectOptions.value[i].dependItemList[j].dateOptions =
DATE_LIST[value] DATE_LIST[value]
model.dependTaskList[i].dependItemList[j].dateValue = null model.dependTaskList[i].dependItemList[j].dateValue = null
} }
@ -376,7 +389,7 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
span: 10, span: 10,
name: ' ', name: ' ',
options: options:
model.dependTaskList[i]?.dependItemList[j]?.dateOptions || [], selectOptions.value[i]?.dependItemList[j]?.dateOptions || [],
path: `dependTaskList.${i}.dependItemList.${j}.dateValue`, path: `dependTaskList.${i}.dependItemList.${j}.dateValue`,
rule: { rule: {
trigger: ['input', 'blur'], trigger: ['input', 'blur'],

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

@ -15,15 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { omit, cloneDeep } from 'lodash' import { omit } from 'lodash'
import type { import type {
INodeData, INodeData,
ITaskData, ITaskData,
ITaskParams, ITaskParams,
ISqoopTargetParams, ISqoopTargetParams,
ISqoopSourceParams, ISqoopSourceParams,
ILocalParam, ILocalParam
IDependTask
} from './types' } from './types'
export function formatParams(data: INodeData): { export function formatParams(data: INodeData): {
@ -270,21 +269,9 @@ export function formatParams(data: INodeData): {
taskParams.xmx = data.xmx taskParams.xmx = data.xmx
} }
if (data.taskType === 'DEPENDENT') { if (data.taskType === 'DEPENDENT') {
const dependTaskList = cloneDeep(data.dependTaskList)?.map(
(taskItem: IDependTask) => {
if (taskItem.dependItemList?.length) {
taskItem.dependItemList.forEach((dependItem) => {
delete dependItem.definitionCodeOptions
delete dependItem.depTaskCodeOptions
delete dependItem.dateOptions
})
}
return taskItem
}
)
taskParams.dependence = { taskParams.dependence = {
relation: data.relation, relation: data.relation,
dependTaskList: dependTaskList dependTaskList: data.dependTaskList
} }
} }
if (data.taskType === 'DATA_QUALITY') { if (data.taskType === 'DATA_QUALITY') {

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

@ -66,12 +66,19 @@ interface IResponseJsonItem extends Omit<IJsonItemParams, 'type'> {
emit: 'change'[] emit: 'change'[]
} }
interface IDependpendItem { interface IDependentItemOptions {
depTaskCode?: number
status?: 'SUCCESS' | 'FAILURE'
definitionCodeOptions?: IOption[] definitionCodeOptions?: IOption[]
depTaskCodeOptions?: IOption[] depTaskCodeOptions?: IOption[]
dateOptions?: IOption[] dateOptions?: IOption[]
}
interface IDependTaskOptions {
dependItemList: IDependentItemOptions[]
}
interface IDependentItem {
depTaskCode?: number
status?: 'SUCCESS' | 'FAILURE'
projectCode?: number projectCode?: number
definitionCode?: number definitionCode?: number
cycle?: 'month' | 'week' | 'day' | 'hour' cycle?: 'month' | 'week' | 'day' | 'hour'
@ -82,7 +89,7 @@ interface IDependTask {
condition?: string condition?: string
nextNode?: number nextNode?: number
relation?: RelationType relation?: RelationType
dependItemList?: IDependpendItem[] dependItemList?: IDependentItem[]
} }
interface ISwitchResult { interface ISwitchResult {
@ -481,7 +488,9 @@ export {
ISqoopSourceParams, ISqoopSourceParams,
ISqoopTargetParams, ISqoopTargetParams,
IDependTask, IDependTask,
IDependpendItem, IDependentItem,
IDependentItemOptions,
IDependTaskOptions,
IFormItem, IFormItem,
IJsonItem, IJsonItem,
FormRules, FormRules,

Loading…
Cancel
Save