forked from github/dataease
refactor: 国际化处理
This commit is contained in:
parent
49ab2d678f
commit
90ab87c86b
@ -132,6 +132,7 @@
|
|||||||
import LayoutContent from '@/components/business/LayoutContent'
|
import LayoutContent from '@/components/business/LayoutContent'
|
||||||
import {addDs, editDs, getSchema, validateDs, validateDsById} from '@/api/system/datasource'
|
import {addDs, editDs, getSchema, validateDs, validateDsById} from '@/api/system/datasource'
|
||||||
import {$confirm} from '@/utils/message'
|
import {$confirm} from '@/utils/message'
|
||||||
|
import i18n from '@/lang/index'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DsForm',
|
name: 'DsForm',
|
||||||
@ -157,61 +158,61 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
rule: {
|
rule: {
|
||||||
name: [{required: true, message: this.$t('datasource.input_name'), trigger: 'blur'},
|
name: [{required: true, message: i18n.t('datasource.input_name'), trigger: 'blur'},
|
||||||
{min: 2, max: 25, message: this.$t('datasource.input_limit_2_25', [2, 25]), trigger: 'blur'}],
|
{min: 2, max: 25, message: i18n.t('datasource.input_limit_2_25', [2, 25]), trigger: 'blur'}],
|
||||||
desc: [{min: 0, max: 50, message: this.$t('datasource.input_limit_0_50'), trigger: 'blur'}],
|
desc: [{min: 0, max: 50, message: i18n.t('datasource.input_limit_0_50'), trigger: 'blur'}],
|
||||||
type: [{required: true, message: this.$t('datasource.please_choose_type'), trigger: 'change'}],
|
type: [{required: true, message: i18n.t('datasource.please_choose_type'), trigger: 'change'}],
|
||||||
'configuration.dataBase': [{
|
'configuration.dataBase': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_data_base'),
|
message: i18n.t('datasource.please_input_data_base'),
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}],
|
}],
|
||||||
'configuration.connectionType': [{
|
'configuration.connectionType': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_select_oracle_type'),
|
message: i18n.t('datasource.please_select_oracle_type'),
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}],
|
}],
|
||||||
'configuration.username': [{
|
'configuration.username': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_user_name'),
|
message: i18n.t('datasource.please_input_user_name'),
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}],
|
}],
|
||||||
'configuration.password': [{
|
'configuration.password': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_password'),
|
message: i18n.t('datasource.please_input_password'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.host': [{required: true, message: this.$t('datasource.please_input_host'), trigger: 'change'}],
|
'configuration.host': [{required: true, message: i18n.t('datasource.please_input_host'), trigger: 'change'}],
|
||||||
'configuration.url': [{required: true, message: this.$t('datasource.please_input_url'), trigger: 'change'}],
|
'configuration.url': [{required: true, message: i18n.t('datasource.please_input_url'), trigger: 'change'}],
|
||||||
'configuration.port': [{required: true, message: this.$t('datasource.please_input_port'), trigger: 'change'}],
|
'configuration.port': [{required: true, message: i18n.t('datasource.please_input_port'), trigger: 'change'}],
|
||||||
'configuration.initialPoolSize': [{
|
'configuration.initialPoolSize': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_initial_pool_size'),
|
message: i18n.t('datasource.please_input_initial_pool_size'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.minPoolSize': [{
|
'configuration.minPoolSize': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_min_pool_size'),
|
message: i18n.t('datasource.please_input_min_pool_size'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.maxPoolSize': [{
|
'configuration.maxPoolSize': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_max_pool_size'),
|
message: i18n.t('datasource.please_input_max_pool_size'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.maxIdleTime': [{
|
'configuration.maxIdleTime': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_max_idle_time'),
|
message: i18n.t('datasource.please_input_max_idle_time'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.acquireIncrement': [{
|
'configuration.acquireIncrement': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_acquire_increment'),
|
message: i18n.t('datasource.please_input_acquire_increment'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}],
|
}],
|
||||||
'configuration.connectTimeout': [{
|
'configuration.connectTimeout': [{
|
||||||
required: true,
|
required: true,
|
||||||
message: this.$t('datasource.please_input_connect_timeout'),
|
message: i18n.t('datasource.please_input_connect_timeout'),
|
||||||
trigger: 'change'
|
trigger: 'change'
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
@ -296,15 +297,15 @@ export default {
|
|||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer')) {
|
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer')) {
|
||||||
this.$message.error(this.$t('datasource.please_choose_schema'))
|
this.$message.error(i18n.t('datasource.please_choose_schema'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
|
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
|
||||||
this.$message.error(this.$t('datasource.port_no_less_then_0'))
|
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.form.configuration.initialPoolSize < 0 || this.form.configuration.minPoolSize < 0 || this.form.configuration.maxPoolSize < 0) {
|
if (this.form.configuration.initialPoolSize < 0 || this.form.configuration.minPoolSize < 0 || this.form.configuration.maxPoolSize < 0) {
|
||||||
this.$message.error(this.$t('datasource.no_less_then_0'))
|
this.$message.error(i18n.t('datasource.no_less_then_0'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$refs.dsForm.validate(valid => {
|
this.$refs.dsForm.validate(valid => {
|
||||||
@ -313,16 +314,16 @@ export default {
|
|||||||
const form = JSON.parse(JSON.stringify(this.form))
|
const form = JSON.parse(JSON.stringify(this.form))
|
||||||
form.configuration = JSON.stringify(form.configuration)
|
form.configuration = JSON.stringify(form.configuration)
|
||||||
if (this.formType !== 'add' && this.originConfiguration !== form.configuration) {
|
if (this.formType !== 'add' && this.originConfiguration !== form.configuration) {
|
||||||
$confirm(this.$t('datasource.edit_datasource_msg'), () => {
|
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
||||||
method(form).then(res => {
|
method(form).then(res => {
|
||||||
this.$success(this.$t('commons.save_success'))
|
this.$success(i18n.t('commons.save_success'))
|
||||||
this.refreshType(form)
|
this.refreshType(form)
|
||||||
this.backToList()
|
this.backToList()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
method(form).then(res => {
|
method(form).then(res => {
|
||||||
this.$success(this.$t('commons.save_success'))
|
this.$success(i18n.t('commons.save_success'))
|
||||||
this.refreshType(form)
|
this.refreshType(form)
|
||||||
this.backToList()
|
this.backToList()
|
||||||
})
|
})
|
||||||
@ -339,7 +340,7 @@ export default {
|
|||||||
data.configuration = JSON.stringify(data.configuration)
|
data.configuration = JSON.stringify(data.configuration)
|
||||||
getSchema(data).then(res => {
|
getSchema(data).then(res => {
|
||||||
this.schemas = res.data
|
this.schemas = res.data
|
||||||
this.$success(this.$t('commons.success'))
|
this.$success(i18n.t('commons.success'))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -348,11 +349,11 @@ export default {
|
|||||||
},
|
},
|
||||||
validaDatasource() {
|
validaDatasource() {
|
||||||
if (!this.form.configuration.schema && this.form.type === 'oracle') {
|
if (!this.form.configuration.schema && this.form.type === 'oracle') {
|
||||||
this.$message.error(this.$t('datasource.please_choose_schema'))
|
this.$message.error(i18n.t('datasource.please_choose_schema'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
|
if (this.form.configuration.dataSourceType === 'jdbc' && this.form.configuration.port <= 0) {
|
||||||
this.$message.error(this.$t('datasource.port_no_less_then_0'))
|
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$refs.dsForm.validate(valid => {
|
this.$refs.dsForm.validate(valid => {
|
||||||
@ -362,9 +363,9 @@ export default {
|
|||||||
if (data.showModel === 'show' && !this.canEdit) {
|
if (data.showModel === 'show' && !this.canEdit) {
|
||||||
validateDsById(data.id).then(res => {
|
validateDsById(data.id).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$success(this.$t('datasource.validate_success'))
|
this.$success(i18n.t('datasource.validate_success'))
|
||||||
} else {
|
} else {
|
||||||
this.$error(this.$t(res.message))
|
this.$error(res.message)
|
||||||
}
|
}
|
||||||
this.refreshType(data)
|
this.refreshType(data)
|
||||||
}).catch(res => {
|
}).catch(res => {
|
||||||
@ -373,9 +374,9 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
validateDs(data).then(res => {
|
validateDs(data).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$success(this.$t('datasource.validate_success'))
|
this.$success(i18n.t('datasource.validate_success'))
|
||||||
} else {
|
} else {
|
||||||
this.$error(this.$t(res.message))
|
this.$error(res.message)
|
||||||
}
|
}
|
||||||
}).catch(res => {
|
}).catch(res => {
|
||||||
this.$error(res.message)
|
this.$error(res.message)
|
||||||
|
Loading…
Reference in New Issue
Block a user