Browse Source

Dependency workflow add dependency correction value (#1072)

pull/2/head
break60 5 years ago committed by lgcareer
parent
commit
90f092f5ac
  1. 250
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue

250
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 el.definitionList || []" :key="item.id" :value="item.id" :label="item.name"> <x-option v-for="item in definitionList" :key="item.value" :value="item.value" :label="item.label">
</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">
@ -46,7 +46,7 @@
</template> </template>
<span class="operation"> <span class="operation">
<a href="javascript:" class="delete" @click="!isDetails && _remove($index)"> <a href="javascript:" class="delete" @click="!isDetails && _remove($index)">
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" data-container="body" :title="$t('delete')">&#xe611;</i> <i class="iconfont" :class="_isDetails" data-toggle="tooltip" data-container="body" :title="$t('delete')" >&#xe611;</i>
</a> </a>
<a href="javascript:" class="add" @click="!isDetails && _add()" v-if="$index === (dependItemList.length - 1)"> <a href="javascript:" class="add" @click="!isDetails && _add()" v-if="$index === (dependItemList.length - 1)">
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" data-container="body" :title="$t('Add')">&#xe636;</i> <i class="iconfont" :class="_isDetails" data-toggle="tooltip" data-container="body" :title="$t('Add')">&#xe636;</i>
@ -56,12 +56,12 @@
</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 () {
return { return {
list: [], list: [],
definitionList: [], definitionList: [],
@ -69,13 +69,13 @@
cycleList: cycleList, cycleList: cycleList,
isInstance: false, isInstance: false,
itemIndex: null itemIndex: null
}; }
}, },
mixins: [disabledState], mixins: [disabledState],
props: { props: {
dependItemList: Array, dependItemList: Array,
index: Number, index: Number,
dependTaskList: Array dependTaskList:Array
}, },
model: { model: {
prop: 'dependItemList', prop: 'dependItemList',
@ -85,144 +85,122 @@
/** /**
* add task * add task
*/ */
_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 val = this.definitionList[0].value; let noArr = _.filter(this.definitionList, v => !is(v.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 => { this.$nextTick(() => {
val = definitionList[0].id; this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(val, depTasksList,projectId)))
this.$nextTick(() => { })
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.$emit('getDependTaskList', dependTaskList) this._removeTip()
// 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.projectAll), v => { this.projectList = _.map(_.cloneDeep(this.store.state.dag.projectListS), v => {
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
}; }
}); })
resolve(); resolve()
}); })
}, },
/** /**
* get processlist * get processlist
*/ */
_getProcessList () {
_getProcessByProjectId(id) { 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) {
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 => {
this.definitionList = _.map(_.cloneDeep(res), v => { this.definitionList = _.map(_.cloneDeep(res), v => {
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
}; }
}); })
resolve(res); resolve(res)
}); })
}); })
}, },
/** /**
* get dependItemList * get dependItemList
*/ */
_getDependItemList(ids, is = true) { _getDependItemList (ids, is = true) {
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 this.store.dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids }).then(res => {
.dispatch('dag/getTaskListDefIdAll', { processDefinitionIdList: ids }) resolve(res)
.then(res => { })
resolve(res);
});
} }
}); })
}, },
/** /**
* change process get dependItemList * change process get dependItemList
*/ */
_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.$set(this.dependItemList, this.itemIndex, this._cpOldParams(value,definitionId, definitionList,depTasksList, item))
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.$set(this.dependItemList, this.itemIndex, this._rtOldParams(value, depTasksList, item))
this.dependItemList, })
this.itemIndex,
this._rtOldParams(value, depTasksList, item)
);
});
},
_onChangeCycle({ value }) {
let list = _.cloneDeep(dateValueList[value]);
this.$set(this.dependItemList[this.itemIndex], 'dateValue', list[0].value);
this.$set(this.dependItemList[this.itemIndex], 'dateValueList', list);
}, },
_rtNewParams(value, depTasksList, projectId, definitionList) { _onChangeCycle ({ value }) {
return { let list = _.cloneDeep(dateValueList[value])
projectId: projectId, this.$set(this.dependItemList[this.itemIndex], 'dateValue', list[0].value)
definitionId: value, this.$set(this.dependItemList[this.itemIndex], 'dateValueList', list)
depTasks: 'ALL',
definitionList,
depTasksList: depTasksList,
cycle: 'day',
dateValue: 'today',
dateValueList: _.cloneDeep(dateValueList['day']),
state: ''
};
}, },
_cpNewParams(value, depTasksList, projectId) { _rtNewParams (value, depTasksList,projectId) {
return { return {
projectId: projectId, projectId: projectId,
definitionId: value, definitionId: value,
@ -232,23 +210,22 @@
dateValue: 'today', dateValue: 'today',
dateValueList: _.cloneDeep(dateValueList['day']), dateValueList: _.cloneDeep(dateValueList['day']),
state: '' 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) {
return { return {
projectId: value, projectId: value,
definitionList: definitionList, definitionList: definitionList,
@ -259,71 +236,50 @@
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') $('body').find('.tooltip.fade.top.in').remove()
.find('.tooltip.fade.top.in')
.remove();
} }
}, },
watch: {}, watch: {
beforeCreate() {}, },
created() { beforeCreate () {
},
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 => {
console.log(definitionList); let value = this.definitionList[0].value
if (definitionList.length > 0) { this._getDependItemList(value).then(depTasksList => {
let value = this.definitionList[0].value; this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(value, depTasksList,projectId)))
this._getDependItemList(value).then(depTasksList => { })
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">
@ -363,7 +319,7 @@
color: #888888; color: #888888;
} }
&.icon-FAILED { &.icon-FAILED {
color: #f31322; color: #F31322;
} }
} }
} }

Loading…
Cancel
Save