diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue index 883b13a678..643bac89c6 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue @@ -76,7 +76,8 @@ props: { dependItemList: Array, index: Number, - dependTaskList: Array + dependTaskList: Array, + projectDefinitionsCache: Object }, model: { prop: 'dependItemList', @@ -136,6 +137,9 @@ }) }, _getProcessByProjectCode (code) { + if (this.projectDefinitionsCache[code]) { + return Promise.resolve(this.projectDefinitionsCache[code]) + } return new Promise((resolve, reject) => { this.store.dispatch('dag/getProcessByProjectCode', code).then(res => { let definitionList = _.map(_.cloneDeep(res), v => { @@ -144,6 +148,10 @@ label: v.processDefinition.name } }) + this.$emit('addProjectDefinitionsCache', { + projectCode: code, + definitionList + }) resolve(definitionList) }) }) @@ -281,16 +289,26 @@ } }) } else { - // get definitionCode codes - let codes = _.map(this.dependItemList, v => v.definitionCode).join(',') - // get item list - this._getDependItemList(codes, false).then(res => { - _.map(this.dependItemList, (v, i) => { - this._getProcessByProjectCode(v.projectCode).then(definitionList => { - this.$set(this.dependItemList, i, this._rtOldParams(v.definitionCode, definitionList, [_.cloneDeep(DEP_ALL_TASK)].concat(_.map(res[v.definitionCode] || [], v => ({ code: v.code, name: v.name }))), v)) + // Get uniq definitionCodes and projectCodes + const definitionCodes = _.uniq(this.dependItemList.map(dep => dep.definitionCode)).join(',') + + // Query all tasks by definitionCodes, definitionCodes can cross projects + this._getDependItemList(definitionCodes, false) + .then(definitionTasks => { + _.map(this.dependItemList, (dep, i) => { + const definitionList = this.projectDefinitionsCache[dep.projectCode] + const depTasksList = (definitionTasks[dep.definitionCode] || []) + .map(task => ({ code: task.code, name: task.name })) + .concat(_.cloneDeep(DEP_ALL_TASK)) + + this.$set(this.dependItemList, i, this._rtOldParams( + dep.definitionCode, + definitionList, + depTasksList, + dep + )) }) }) - }) } }) }, diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue index b0b46e74cc..5f03ba6d53 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue @@ -27,7 +27,7 @@ -