feat: 校验数据源状态时,同时刷新左侧菜单中数据源的状态

This commit is contained in:
taojinlong
2021-08-23 16:27:05 +08:00
parent 378a034f85
commit 4eaaf2273e
4 changed files with 56 additions and 9 deletions

View File

@@ -50,6 +50,14 @@ export function validateDs(data) {
})
}
export function validateDsById(datasourceId) {
return request({
url: 'datasource/validate/' + datasourceId,
method: 'get',
loading: true
})
}
export function getSchema(data) {
return request({
url: 'datasource/getSchema/',

View File

@@ -100,7 +100,7 @@
<script>
import LayoutContent from '@/components/business/LayoutContent'
import { addDs, editDs, getSchema, validateDs } from '@/api/system/datasource'
import { addDs, editDs, getSchema, validateDs, validateDsById } from '@/api/system/datasource'
import { $confirm } from '@/utils/message'
export default {
@@ -276,9 +276,29 @@ export default {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration)
validateDs(data).then(res => {
this.$success(this.$t('datasource.validate_success'))
})
if(data.showModel === 'show' && !this.canEdit){
validateDsById(data.id).then(res => {
if(res.success === 'true'){
this.$success(this.$t('datasource.validate_success'))
}else {
this.$error(this.$t(res.message))
}
this.refreshTree()
}).catch(res => {
this.$error(res.message)
})
}else {
validateDs(data).then(res => {
if(res.success === 'true'){
this.$success(this.$t('datasource.validate_success'))
}else {
this.$error(this.$t(res.message))
}
}).catch(res => {
this.$error(res.message)
})
}
} else {
return false
}