提交 940147a6 authored 作者: taojinlong's avatar taojinlong

fix: 增加或删除数据源,只有一条数据时操作完需要刷新页面才会更新

上级 7052f9b9
......@@ -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 = {}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论