feat: 更新数据源,左侧树状结构保持不变

This commit is contained in:
taojinlong 2021-11-02 15:42:52 +08:00
parent 0d8df94bcb
commit 76141c85dc
7 changed files with 51 additions and 15 deletions

View File

@ -331,7 +331,10 @@ public class ExcelXlsReader implements HSSFListener {
totalSheets.add(excelSheetData);
}else {
List<String> tmp = new ArrayList<>(cellList);
totalSheets.stream().filter(s->s.getExcelLable().equalsIgnoreCase(sheetName)).collect(Collectors.toList()).get(0).getData().add(tmp);
if(totalSheets.stream().filter(s->s.getExcelLable().equalsIgnoreCase(sheetName)).collect(Collectors.toList()).get(0).getData().size() < 100){
totalSheets.stream().filter(s->s.getExcelLable().equalsIgnoreCase(sheetName)).collect(Collectors.toList()).get(0).getData().add(tmp);
}
totalRows++;
}
}

View File

@ -20,6 +20,7 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Api(tags = "数据源:数据源管理")
@ApiSupport(order = 30)
@ -32,7 +33,7 @@ public class DatasourceController {
@ApiOperation("新增数据源")
@PostMapping("/add")
public Datasource addDatasource(@RequestBody Datasource datasource) {
public Datasource addDatasource(@RequestBody Datasource datasource) throws Exception{
return datasourceService.addDatasource(datasource);
}
@ -57,6 +58,12 @@ public class DatasourceController {
return datasourceService.getDatasourceList(request);
}
@ApiOperation("查询当前用户数据源")
@GetMapping("/list/{type}")
public List<DatasourceDTO> getDatasourceListByType(@PathVariable String type) throws Exception {
return getDatasourceList().stream().filter(datasourceDTO -> datasourceDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList());
}
@ApiIgnore
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<DatasourceDTO>> getDatasourceList(@RequestBody BaseGridRequest request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception {

View File

@ -57,7 +57,7 @@ public class DatasourceService {
@Resource
private CommonThreadPool commonThreadPool;
public Datasource addDatasource(Datasource datasource) {
public Datasource addDatasource(Datasource datasource) throws Exception{
checkName(datasource);
long currentTimeMillis = System.currentTimeMillis();
datasource.setId(UUID.randomUUID().toString());

View File

@ -15,6 +15,13 @@ export function listDatasource() {
method: 'get'
})
}
export function listDatasourceByType(type) {
return request({
url: '/datasource/list/' + type,
loading: true,
method: 'get'
})
}
export function addDs(data) {
return request({
url: 'datasource/add/',

View File

@ -1,10 +1,10 @@
<template>
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
<de-aside-container style="padding: 0 0;">
<ds-tree ref="dsTree" @switch-main="switchMain" />
<ds-tree ref="dsTree" :datasource="datasource" @switch-main="switchMain" />
</de-aside-container>
<de-main-container>
<component :is="component" v-if="!!component" :params="param" @refresh-left-tree="refreshTree" @switch-component="switchMain" />
<component :is="component" v-if="!!component" :params="param" @refresh-type="refreshType" @switch-component="switchMain" />
</de-main-container>
</de-container>
</template>
@ -22,6 +22,7 @@ export default {
data() {
return {
component: DataHome,
datasource: {},
param: null
}
},
@ -53,8 +54,9 @@ export default {
}
})
},
refreshTree() {
this.$refs.dsTree && this.$refs.dsTree.queryTreeDatas()
refreshType(datasource) {
this.datasource = datasource;
this.$refs.dsTree && this.$refs.dsTree.refreshType(datasource)
},
msg2Current(sourceParam) {
this.$refs.dsTree && this.$refs.dsTree.markInvalid(sourceParam)

View File

@ -87,10 +87,16 @@
</el-col>
</template>
<script>
import { listDatasource, delDs } from '@/api/system/datasource'
import { listDatasource, listDatasourceByType, delDs } from '@/api/system/datasource'
export default {
name: 'DsTree',
props: {
datasource: {
type: Object,
default: null
}
},
data() {
return {
expandedArray: [],
@ -106,7 +112,6 @@ export default {
},
mounted() {
this.queryTreeDatas()
// console.log('permis:' + JSON.stringify(this.$store.getters.permissions))
},
methods: {
filterNode(value, data) {
@ -124,6 +129,19 @@ export default {
listDatasource().then(res => {
this.tData = this.buildTree(res.data)
})
},
refreshType(datasource) {
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
}
}
})
},
buildTree(array) {
const types = {}
@ -212,7 +230,7 @@ export default {
}).then(() => {
delDs(datasource.id).then(res => {
this.$success(this.$t('commons.delete_success'))
this.queryTreeDatas()
this.refreshType(datasource)
})
}).catch(() => {
this.$message({

View File

@ -235,14 +235,14 @@ export default {
$confirm(this.$t('datasource.edit_datasource_msg'), () => {
method(form).then(res => {
this.$success(this.$t('commons.save_success'))
this.refreshTree()
this.refreshType(form)
this.backToList()
})
})
} else {
method(form).then(res => {
this.$success(this.$t('commons.save_success'))
this.refreshTree()
this.refreshType(form)
this.backToList()
})
}
@ -315,10 +315,9 @@ export default {
},
backToList() {
this.$emit('switch-component', { })
// this.$router.push({ name: 'datasource' })
},
refreshTree() {
this.$emit('refresh-left-tree')
refreshType(form) {
this.$emit('refresh-type', form)
}
}
}