diff --git a/frontend/src/views/system/datasource/DsTree.vue b/frontend/src/views/system/datasource/DsTree.vue index 0eb2d25e51..4ac6672f37 100644 --- a/frontend/src/views/system/datasource/DsTree.vue +++ b/frontend/src/views/system/datasource/DsTree.vue @@ -140,14 +140,26 @@ export default { let typeData = [] listDatasourceByType(datasource.type).then(res => { typeData = this.buildTree(res.data) - for (let index = 0; index < this.tData.length; index++) { - if (typeData[0].id === this.tData[index].id) { - this.tData[index].children = typeData[0].children + if(typeData.length === 0){ + let index = this.tData.findIndex(item => { + if ( item.id === datasource.type) { + return true; + } + }) + this.tData.splice(index,1) + }else { + let find = false; + for (let index = 0; index < this.tData.length; index++) { + if (typeData[0].id === this.tData[index].id) { + this.tData[index].children = typeData[0].children + find = true + } + } + if(!find){ + this.tData.push(typeData[0]) } } }) - - }, buildTree(array) { const types = {}