提交 18c957ce authored 作者: taojinlong's avatar taojinlong

feat: 重复的数据源连接,保存时增加提示

上级 e4f44bd2
...@@ -1269,6 +1269,8 @@ export default { ...@@ -1269,6 +1269,8 @@ export default {
get_schema: 'Get Schema', get_schema: 'Get Schema',
schema: 'Database Schema', schema: 'Database Schema',
please_choose_schema: 'Please select Schema', please_choose_schema: 'Please select Schema',
edit_datasource_msg: 'Modifying the data source information may make the data set under the modified data source unavailable. Confirm the modification?',
repeat_datasource_msg: 'Data source information with the same configuration already exists. Confirm?',
in_valid: 'Invalid datasource', in_valid: 'Invalid datasource',
initial_pool_size: 'Initial connections', initial_pool_size: 'Initial connections',
min_pool_size: 'Minimum of connections', min_pool_size: 'Minimum of connections',
......
...@@ -1271,6 +1271,7 @@ export default { ...@@ -1271,6 +1271,7 @@ export default {
schema: '數據庫 Schema', schema: '數據庫 Schema',
please_choose_schema: '請選擇數據庫 Schema', please_choose_schema: '請選擇數據庫 Schema',
edit_datasource_msg: '修改數據源信息,可能會導致改數據源下的數據集不可用,確認修改?', edit_datasource_msg: '修改數據源信息,可能會導致改數據源下的數據集不可用,確認修改?',
repeat_datasource_msg: '已經存在相同配置的數據源信息,確認?',
in_valid: '無效數據源', in_valid: '無效數據源',
initial_pool_size: '初始連接數', initial_pool_size: '初始連接數',
min_pool_size: '最小連接數', min_pool_size: '最小連接數',
......
...@@ -1275,6 +1275,7 @@ export default { ...@@ -1275,6 +1275,7 @@ export default {
schema: '数据库 Schema', schema: '数据库 Schema',
please_choose_schema: '请选择数据库 Schema', please_choose_schema: '请选择数据库 Schema',
edit_datasource_msg: '修改数据源信息,可能会导致该数据源下的数据集不可用,确认修改?', edit_datasource_msg: '修改数据源信息,可能会导致该数据源下的数据集不可用,确认修改?',
repeat_datasource_msg: '已经存在相同配置的数据源信息,确认?',
in_valid: '无效数据源', in_valid: '无效数据源',
initial_pool_size: '初始连接数', initial_pool_size: '初始连接数',
min_pool_size: '最小连接数', min_pool_size: '最小连接数',
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<ds-tree ref="dsTree" :datasource="datasource" @switch-main="switchMain"/> <ds-tree ref="dsTree" :datasource="datasource" @switch-main="switchMain"/>
</de-aside-container> </de-aside-container>
<de-main-container> <de-main-container>
<component :is="component" v-if="!!component" :params="param" @refresh-type="refreshType" <component :is="component" v-if="!!component" :params="param" :tData="tData" @refresh-type="refreshType"
@switch-component="switchMain"/> @switch-component="switchMain"/>
</de-main-container> </de-main-container>
</de-container> </de-container>
...@@ -25,7 +25,8 @@ export default { ...@@ -25,7 +25,8 @@ export default {
return { return {
component: DataHome, component: DataHome,
datasource: {}, datasource: {},
param: null param: null,
tData: null
} }
}, },
computed: {}, computed: {},
...@@ -36,7 +37,8 @@ export default { ...@@ -36,7 +37,8 @@ export default {
methods: { methods: {
// 切换main区内容 // 切换main区内容
switchMain(param) { switchMain(param) {
const {component, componentParam} = param console.log(param)
const {component, componentParam, tData} = param
this.component = DataHome this.component = DataHome
this.param = null this.param = null
this.$nextTick(() => { this.$nextTick(() => {
...@@ -44,6 +46,7 @@ export default { ...@@ -44,6 +46,7 @@ export default {
case 'DsForm': case 'DsForm':
this.component = DsForm this.component = DsForm
this.param = componentParam this.param = componentParam
this.tData = tData
break break
default: default:
this.component = DataHome this.component = DataHome
......
...@@ -216,10 +216,10 @@ export default { ...@@ -216,10 +216,10 @@ export default {
}, },
addFolder() { addFolder() {
this.switchMain('DsForm') this.switchMain('DsForm', {}, this.tData)
}, },
addFolderWithType(data) { addFolderWithType(data) {
this.switchMain('DsForm', {type: data.id}) this.switchMain('DsForm', {type: data.id}, this.tData)
}, },
nodeClick(node, data) { nodeClick(node, data) {
if (node.type === 'folder') return if (node.type === 'folder') return
...@@ -243,11 +243,11 @@ export default { ...@@ -243,11 +243,11 @@ export default {
return {optType, data, node} return {optType, data, node}
}, },
edit(row) { edit(row) {
this.switchMain('DsForm', row) this.switchMain('DsForm', row, this.tData)
}, },
showInfo(row) { showInfo(row) {
const param = {...row.data, ...{showModel: 'show'}} const param = {...row.data, ...{showModel: 'show'}}
this.switchMain('DsForm', param) this.switchMain('DsForm', param, this.tData)
}, },
_handleDelete(datasource) { _handleDelete(datasource) {
this.$confirm(this.$t('datasource.delete_warning'), '', { this.$confirm(this.$t('datasource.delete_warning'), '', {
...@@ -257,7 +257,7 @@ export default { ...@@ -257,7 +257,7 @@ export default {
}).then(() => { }).then(() => {
delDs(datasource.id).then(res => { delDs(datasource.id).then(res => {
this.$success(this.$t('commons.delete_success')) this.$success(this.$t('commons.delete_success'))
this.switchMain('DataHome') this.switchMain('DataHome', {}, this.tData)
this.refreshType(datasource) this.refreshType(datasource)
}) })
}).catch(() => { }).catch(() => {
...@@ -267,10 +267,12 @@ export default { ...@@ -267,10 +267,12 @@ export default {
}) })
}) })
}, },
switchMain(component, componentParam) { switchMain(component, componentParam, tData) {
console.log(tData)
this.$emit('switch-main', { this.$emit('switch-main', {
component, component,
componentParam componentParam,
tData
}) })
}, },
markInvalid(msgParam) { markInvalid(msgParam) {
......
...@@ -192,6 +192,10 @@ export default { ...@@ -192,6 +192,10 @@ export default {
params: { params: {
type: Object, type: Object,
default: null default: null
},
tData: {
type: Array,
default: null
} }
}, },
data() { data() {
...@@ -346,31 +350,81 @@ export default { ...@@ -346,31 +350,81 @@ export default {
this.$message.error(i18n.t('datasource.no_less_then_0')) this.$message.error(i18n.t('datasource.no_less_then_0'))
return return
} }
let repeat = false
this.tData.forEach(item => {
if(item.id === this.form.type){
item.children.forEach(child => {
let configuration = JSON.parse(child.configuration)
switch (this.form.type) {
case 'mysql':
case 'hive':
case 'mariadb':
case 'ds_doris':
case 'ck':
case 'mongo':
case 'mariadb':
if(configuration.host == this.form.configuration.host && configuration.dataBase == this.form.configuration.dataBase && configuration.port == this.form.configuration.port){
repeat = true
}
break
case 'pg':
case 'sqlServer':
case 'redshift':
case 'oracle':
case 'db2':
if(configuration.host == this.form.configuration.host && configuration.dataBase == this.form.configuration.dataBase && configuration.port == this.form.configuration.port && configuration.schema == this.form.configuration.schema){
repeat = true
}
break
case 'es':
if(configuration.url == this.form.configuration.url){
repeat = true
}
break
default:
break
}
})
}
})
this.$refs.dsForm.validate(valid => { this.$refs.dsForm.validate(valid => {
if (valid) { if (!valid) {
const method = this.formType === 'add' ? addDs : editDs return false
const form = JSON.parse(JSON.stringify(this.form)) }
form.configuration = JSON.stringify(form.configuration) const method = this.formType === 'add' ? addDs : editDs
if (this.formType !== 'add' && this.originConfiguration !== form.configuration) { const form = JSON.parse(JSON.stringify(this.form))
$confirm(i18n.t('datasource.edit_datasource_msg'), () => { form.configuration = JSON.stringify(form.configuration)
method(form).then(res => { if (this.formType === 'modify' && this.originConfiguration !== form.configuration) {
this.$success(i18n.t('commons.save_success')) if(repeat){
this.refreshType(form) $confirm(i18n.t('datasource.repeat_datasource_msg'), () => {
this.backToList() $confirm(i18n.t('datasource.edit_datasource_msg'), () => {
this.method(method, form)
}) })
}) })
} else { }else {
method(form).then(res => { $confirm(i18n.t('datasource.edit_datasource_msg'), () => {
this.$success(i18n.t('commons.save_success')) this.method(method, form)
this.refreshType(form)
this.backToList()
}) })
} }
} else { return
return false }
if(repeat){
$confirm(i18n.t('datasource.repeat_datasource_msg'), () => {
this.method(method, form)
})
}else {
this.method(method, form)
} }
}) })
}, },
method(method, form){
method(form).then(res => {
this.$success(i18n.t('commons.save_success'))
this.refreshType(form)
this.backToList()
})
},
getSchema() { getSchema() {
this.$refs.dsForm.validate(valid => { this.$refs.dsForm.validate(valid => {
if (valid) { if (valid) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论