forked from github/dataease
fix: 增加或删除数据源,只有一条数据时操作完需要刷新页面才会更新
This commit is contained in:
parent
7052f9b945
commit
940147a687
@ -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 = {}
|
||||
|
Loading…
Reference in New Issue
Block a user