Browse Source

fix the bug #1816 (#1834)

pull/2/head
zhukai 5 years ago committed by qiaozhanwei
parent
commit
be4fa728e9
  1. 50
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue

50
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.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">
@ -64,7 +64,6 @@
data () { data () {
return { return {
list: [], list: [],
definitionList: [],
projectList: [], projectList: [],
cycleList: cycleList, cycleList: cycleList,
isInstance: false, isInstance: false,
@ -88,16 +87,19 @@
_add () { _add () {
// btn loading // btn loading
this.isLoading = true this.isLoading = true
// dependItemList index
let is = (value) => _.some(this.dependItemList, { definitionId: 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._getProcessByProjectId(projectId).then(definitionList => {
this.$nextTick(() => { // dependItemList index
this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(val, depTasksList,projectId))) let is = (value) => _.some(this.dependItemList, { definitionId: value })
let noArr = _.filter(definitionList, v => !is(v.value))
let value = noArr[0] && noArr[0].value || null
let val = value || definitionList[0].value
this._getDependItemList(val).then(depTasksList => {
this.$nextTick(() => {
this.$emit('dependItemListEvent', _.concat(this.dependItemList, this._rtNewParams(val, definitionList, depTasksList, projectId)))
})
}) })
}) })
// remove tooltip // remove tooltip
@ -131,25 +133,25 @@
*/ */
_getProcessList () { _getProcessList () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.definitionList = _.map(_.cloneDeep(this.store.state.dag.processListS), v => { let definitionList = _.map(_.cloneDeep(this.store.state.dag.processListS), v => {
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
} }
}) })
resolve() resolve(definitionList)
}) })
}, },
_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 => {
this.definitionList = _.map(_.cloneDeep(res), v => { let definitionList = _.map(_.cloneDeep(res), v => {
return { return {
value: v.id, value: v.id,
label: v.name label: v.name
} }
}) })
resolve(res) resolve(definitionList)
}) })
}) })
}, },
@ -175,7 +177,7 @@
_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].value
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
@ -192,7 +194,7 @@
// 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, item.definitionList, depTasksList, item))
}) })
}, },
_onChangeCycle ({ value }) { _onChangeCycle ({ value }) {
@ -200,10 +202,12 @@
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, definitionList, depTasksList, projectId) {
return { return {
projectId: projectId, projectId: projectId,
definitionId: value, definitionId: value,
// dependItem need private definitionList
definitionList: definitionList,
depTasks: 'ALL', depTasks: 'ALL',
depTasksList: depTasksList, depTasksList: depTasksList,
cycle: 'day', cycle: 'day',
@ -212,10 +216,12 @@
state: '' state: ''
} }
}, },
_rtOldParams (value,depTasksList, item) { _rtOldParams (value, definitionList, depTasksList, item) {
return { return {
projectId: item.projectId, projectId: item.projectId,
definitionId: value, definitionId: value,
// dependItem need private definitionList
definitionList: definitionList,
depTasks: item.depTasks || 'ALL', depTasks: item.depTasks || 'ALL',
depTasksList: depTasksList, depTasksList: depTasksList,
cycle: item.cycle, cycle: item.cycle,
@ -254,12 +260,12 @@
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
if (!this.dependItemList.length) { if (!this.dependItemList.length) {
let projectId = this.projectList[0].value
this._getProcessByProjectId(projectId).then(definitionList => { this._getProcessByProjectId(projectId).then(definitionList => {
let value = this.definitionList[0].value let value = 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, definitionList, depTasksList, projectId)))
}) })
}) })
} else { } else {
@ -269,7 +275,7 @@
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)) this.$set(this.dependItemList, i, this._rtOldParams(v.definitionId, definitionList, ['ALL'].concat(_.map(res[v.definitionId] || [], v => v.name)), v))
}) })
}) })
}) })

Loading…
Cancel
Save