Browse Source

[BUG][#1036]repair cross-project dependency cascading exception (#1037)

(修复跨项目流依赖级联异常)
pull/2/head
黄聪 5 years ago committed by dailidong
parent
commit
1ba7d7a841
  1. 210
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue
  2. 3
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue

210
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue

@ -22,7 +22,7 @@
</x-option> </x-option>
</x-select> </x-select>
<x-select filterable :style="{width:isInstance ? '450px' : '450px'}" :disabled="isDetails" v-model="el.definitionId" @on-change="_onChangeDefinitionId"> <x-select filterable :style="{width:isInstance ? '450px' : '450px'}" :disabled="isDetails" v-model="el.definitionId" @on-change="_onChangeDefinitionId">
<x-option v-for="item in definitionList" :key="item.value" :value="item.value" :label="item.label"> <x-option v-for="item in el.definitionList || []" :key="item.id" :value="item.id" :label="item.name">
</x-option> </x-option>
</x-select> </x-select>
<x-select filterable :style="{width:isInstance ? '450px' : '450px'}" :disabled="isDetails" v-model="el.depTasks"> <x-select filterable :style="{width:isInstance ? '450px' : '450px'}" :disabled="isDetails" v-model="el.depTasks">
@ -56,9 +56,9 @@
</div> </div>
</template> </template>
<script> <script>
import _ from 'lodash' import _ from 'lodash';
import { cycleList, dateValueList } from './commcon' import { cycleList, dateValueList } from './commcon';
import disabledState from '@/module/mixin/disabledState' import disabledState from '@/module/mixin/disabledState';
export default { export default {
name: 'dep-list', name: 'dep-list',
data() { data() {
@ -69,7 +69,7 @@
cycleList: cycleList, cycleList: cycleList,
isInstance: false, isInstance: false,
itemIndex: null itemIndex: null
} };
}, },
mixins: [disabledState], mixins: [disabledState],
props: { props: {
@ -87,59 +87,58 @@
*/ */
_add() { _add() {
// btn loading // btn loading
this.isLoading = true this.isLoading = true;
// dependItemList index // dependItemList index
let is = (value) => _.some(this.dependItemList, { definitionId: value }) let is = value => _.some(this.dependItemList, { definitionId: value });
let noArr = _.filter(this.definitionList, v => !is(v.value)) let val = this.definitionList[0].value;
let value = noArr[0] && noArr[0].value || null
let val = value || this.definitionList[0].value
// add task list // add task list
let projectId = this.projectList[0].value let projectId = this.projectList[0].value;
this._getDependItemList(val).then(depTasksList => { this._getDependItemList(val).then(depTasksList => {
this._getProcessByProjectId(projectId).then(definitionList => {
val = definitionList[0].id;
this.$nextTick(() => { this.$nextTick(() => {
this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(val, depTasksList,projectId))) this.$emit(
}) 'dependItemListEvent',
}) _.concat(
this.dependItemList,
this._rtNewParams(val, depTasksList, projectId, definitionList)
)
);
});
});
});
// remove tooltip // remove tooltip
this._removeTip() this._removeTip();
}, },
/** /**
* remove task * remove task
*/ */
_remove(i) { _remove(i) {
this.dependTaskList[this.index].dependItemList.splice(i,1) this.dependTaskList[this.index].dependItemList.splice(i, 1);
this._removeTip() // this.$emit('getDependTaskList', dependTaskList)
// this.dependItemList.splice(i, 1)
this._removeTip();
if (!this.dependItemList.length || this.dependItemList.length === 0) { if (!this.dependItemList.length || this.dependItemList.length === 0) {
this.$emit('on-delete-all', { this.$emit('on-delete-all', {
index: this.index index: this.index
}) });
} }
}, },
_getProjectList() { _getProjectList() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.projectList = _.map(_.cloneDeep(this.store.state.dag.projectListS), v => { this.projectList = _.map(_.cloneDeep(this.store.state.dag.projectAll), v => {
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
} };
}) });
resolve() resolve();
}) });
}, },
/** /**
* get processlist * get processlist
*/ */
_getProcessList () {
return new Promise((resolve, reject) => {
this.definitionList = _.map(_.cloneDeep(this.store.state.dag.processListS), v => {
return {
value: v.id,
label: v.name
}
})
resolve()
})
},
_getProcessByProjectId(id) { _getProcessByProjectId(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.store.dispatch('dag/getProcessByProjectId', { projectId: id }).then(res => { this.store.dispatch('dag/getProcessByProjectId', { projectId: id }).then(res => {
@ -147,11 +146,11 @@
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
} };
}) });
resolve(res) resolve(res);
}) });
}) });
}, },
/** /**
* get dependItemList * get dependItemList
@ -160,14 +159,16 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (is) { if (is) {
this.store.dispatch('dag/getProcessTasksList', { processDefinitionId: ids }).then(res => { this.store.dispatch('dag/getProcessTasksList', { processDefinitionId: ids }).then(res => {
resolve(['ALL'].concat(_.map(res, v => v.name))) resolve(['ALL'].concat(_.map(res, v => v.name)));
}) });
} else { } else {
this.store.dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids }).then(res => { this.store
resolve(res) .dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids })
}) .then(res => {
resolve(res);
});
} }
}) });
}, },
/** /**
* change process get dependItemList * change process get dependItemList
@ -175,54 +176,76 @@
_onChangeProjectId({ value }) { _onChangeProjectId({ value }) {
this._getProcessByProjectId(value).then(definitionList => { this._getProcessByProjectId(value).then(definitionList => {
/*this.$set(this.dependItemList, this.itemIndex, this._dlOldParams(value, definitionList, item))*/ /*this.$set(this.dependItemList, this.itemIndex, this._dlOldParams(value, definitionList, item))*/
let definitionId = definitionList[0].id let definitionId = definitionList[0].id;
this._getDependItemList(definitionId).then(depTasksList => { this._getDependItemList(definitionId).then(depTasksList => {
let item = this.dependItemList[this.itemIndex] let item = this.dependItemList[this.itemIndex];
// init set depTasks All // init set depTasks All
item.depTasks = 'ALL' item.depTasks = 'ALL';
// set dependItemList item data // set dependItemList item data
this.$set(this.dependItemList, this.itemIndex, this._cpOldParams(value,definitionId, definitionList,depTasksList, item)) this.$set(
}) this.dependItemList,
}) this.itemIndex,
this._cpOldParams(value, definitionId, definitionList, depTasksList, item)
);
});
});
}, },
_onChangeDefinitionId({ value }) { _onChangeDefinitionId({ value }) {
// get depItem list data // get depItem list data
this._getDependItemList(value).then(depTasksList => { this._getDependItemList(value).then(depTasksList => {
let item = this.dependItemList[this.itemIndex] let item = this.dependItemList[this.itemIndex];
// init set depTasks All // init set depTasks All
item.depTasks = 'ALL' item.depTasks = 'ALL';
// set dependItemList item data // set dependItemList item data
this.$set(this.dependItemList, this.itemIndex, this._rtOldParams(value, depTasksList, item)) this.$set(
}) this.dependItemList,
this.itemIndex,
this._rtOldParams(value, depTasksList, item)
);
});
}, },
_onChangeCycle({ value }) { _onChangeCycle({ value }) {
let list = _.cloneDeep(dateValueList[value]) let list = _.cloneDeep(dateValueList[value]);
this.$set(this.dependItemList[this.itemIndex], 'dateValue', list[0].value) this.$set(this.dependItemList[this.itemIndex], 'dateValue', list[0].value);
this.$set(this.dependItemList[this.itemIndex], 'dateValueList', list) this.$set(this.dependItemList[this.itemIndex], 'dateValueList', list);
}, },
_rtNewParams (value, depTasksList,projectId) { _rtNewParams(value, depTasksList, projectId, definitionList) {
return { return {
projectId: projectId, projectId: projectId,
definitionId: value, definitionId: value,
depTasks: 'ALL', depTasks: 'ALL',
definitionList,
depTasksList: depTasksList, depTasksList: depTasksList,
cycle: 'day', cycle: 'day',
dateValue: 'today', dateValue: 'today',
dateValueList: _.cloneDeep(dateValueList['day']), dateValueList: _.cloneDeep(dateValueList['day']),
state: '' state: ''
} };
},
_cpNewParams(value, depTasksList, projectId) {
return {
projectId: projectId,
definitionId: value,
depTasks: 'ALL',
depTasksList: depTasksList,
cycle: 'day',
dateValue: 'today',
dateValueList: _.cloneDeep(dateValueList['day']),
state: ''
};
}, },
_rtOldParams(value, depTasksList, item) { _rtOldParams(value, depTasksList, item) {
return { return {
projectId: item.projectId, projectId: item.projectId,
definitionId: value, definitionId: value,
definitionList: item.definitionList,
depTasks: item.depTasks || 'ALL', depTasks: item.depTasks || 'ALL',
depTasksList: depTasksList, depTasksList: depTasksList,
cycle: item.cycle, cycle: item.cycle,
dateValue: item.dateValue, dateValue: item.dateValue,
dateValueList: _.cloneDeep(dateValueList[item.cycle]), dateValueList: _.cloneDeep(dateValueList[item.cycle]),
state: item.state state: item.state
} };
}, },
_cpOldParams(value, definitionId, definitionList, depTasksList, item) { _cpOldParams(value, definitionId, definitionList, depTasksList, item) {
@ -236,50 +259,71 @@
dateValue: item.dateValue, dateValue: item.dateValue,
dateValueList: _.cloneDeep(dateValueList[item.cycle]), dateValueList: _.cloneDeep(dateValueList[item.cycle]),
state: item.state state: item.state
} };
}, },
/** /**
* remove tip * remove tip
*/ */
_removeTip() { _removeTip() {
$('body').find('.tooltip.fade.top.in').remove() $('body')
.find('.tooltip.fade.top.in')
.remove();
} }
}, },
watch: { watch: {},
}, beforeCreate() {},
beforeCreate () {
},
created() { created() {
// is type projects-instance-details // is type projects-instance-details
this.isInstance = this.router.history.current.name === 'projects-instance-details' this.isInstance = this.router.history.current.name === 'projects-instance-details';
// get processlist // get processlist
this._getProjectList().then(() => { this._getProjectList().then(() => {
let projectId = this.projectList[0].value let projectId = this.projectList[0].value;
if (!this.dependItemList.length) { if (!this.dependItemList.length) {
this._getProcessByProjectId(projectId).then(definitionList => { this._getProcessByProjectId(projectId).then(definitionList => {
let value = this.definitionList[0].value console.log(definitionList);
if (definitionList.length > 0) {
let value = this.definitionList[0].value;
this._getDependItemList(value).then(depTasksList => { this._getDependItemList(value).then(depTasksList => {
this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(value, depTasksList,projectId))) this.$emit(
}) 'dependItemListEvent',
}) _.concat(
this.dependItemList,
this._rtNewParams(value, depTasksList, projectId, definitionList)
)
);
});
}
});
} else { } else {
// get definitionId ids // get definitionId ids
let ids = _.map(this.dependItemList, v => v.definitionId).join(',') let ids = _.map(this.dependItemList, v => v.definitionId).join(',');
// get item list // get item list
this._getProjectList().then(() => {
this._getDependItemList(ids, false).then(res => { this._getDependItemList(ids, false).then(res => {
_.map(this.dependItemList, (v, i) => { _.map(this.dependItemList, (v, i) => {
this._getProcessByProjectId(v.projectId).then(definitionList => { this._getProcessByProjectId(v.projectId).then(definitionList => {
this.$set(this.dependItemList, i, this._rtOldParams(v.definitionId, ['ALL'].concat(_.map(res[v.definitionId] || [], v => v.name)), v)) v.definitionList = Object.values(definitionList);
}) v.depTasksList = Object.values(res)[0];
}) console.log(v);
}) this.$set(
this.dependItemList,
i,
this._rtOldParams(
v.definitionId,
['ALL'].concat(_.map(res[v.definitionId] || [], v => v.name)),
v
)
);
});
});
});
});
} }
}) });
},
mounted () {
}, },
mounted() {},
components: {} components: {}
} };
</script> </script>
<style lang="scss" rel="stylesheet/scss"> <style lang="scss" rel="stylesheet/scss">
@ -319,7 +363,7 @@
color: #888888; color: #888888;
} }
&.icon-FAILED { &.icon-FAILED {
color: #F31322; color: #f31322;
} }
} }
} }

3
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/dependent.vue

@ -107,6 +107,7 @@
this.dependTaskList.splice(i,1) this.dependTaskList.splice(i,1)
} }
}) })
// this._deleteDep(i)
}, },
_setGlobalRelation () { _setGlobalRelation () {
this.relation = this.relation === 'AND' ? 'OR' : 'AND' this.relation = this.relation === 'AND' ? 'OR' : 'AND'
@ -131,7 +132,7 @@
} }
}, },
watch: { watch: {
dependTaskList () { dependTaskList (e) {
setTimeout(() => { setTimeout(() => {
this.isLoading = false this.isLoading = false
}, 600) }, 600)

Loading…
Cancel
Save