2021-04-29 15:38:03 +08:00
|
|
|
<template>
|
2022-09-20 11:53:57 +08:00
|
|
|
<div class="de-ds-form">
|
|
|
|
<div class="de-ds-top">
|
|
|
|
<span class="name">
|
|
|
|
<i @click="backToList" class="el-icon-arrow-left"></i>
|
|
|
|
{{
|
|
|
|
params &&
|
|
|
|
params.id &&
|
|
|
|
params.showModel &&
|
2022-09-21 11:55:39 +08:00
|
|
|
params.showModel === 'show' &&
|
2022-09-20 11:53:57 +08:00
|
|
|
!canEdit
|
2022-09-21 11:55:39 +08:00
|
|
|
? $t('datasource.show_info')
|
|
|
|
: formType == 'add'
|
|
|
|
? $t('datasource.create')
|
|
|
|
: $t('datasource.modify')
|
2022-09-20 11:53:57 +08:00
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
<div class="apply">
|
|
|
|
<template v-if="canEdit">
|
|
|
|
<deBtn secondary @click="backToList"
|
2022-09-21 11:55:39 +08:00
|
|
|
>{{ $t('commons.cancel') }}
|
2022-09-20 11:53:57 +08:00
|
|
|
</deBtn>
|
|
|
|
<deBtn
|
|
|
|
secondary
|
|
|
|
v-if="
|
|
|
|
formType === 'add' ||
|
|
|
|
hasDataPermission('manage', params.privileges)
|
|
|
|
"
|
|
|
|
@click="validaDatasource"
|
2022-09-21 11:55:39 +08:00
|
|
|
>{{ $t('commons.validate') }}
|
2022-09-20 11:53:57 +08:00
|
|
|
</deBtn>
|
|
|
|
<deBtn
|
|
|
|
v-if="
|
|
|
|
formType === 'add' ||
|
|
|
|
hasDataPermission('manage', params.privileges)
|
|
|
|
"
|
|
|
|
type="primary"
|
|
|
|
@click="save"
|
2022-09-21 11:55:39 +08:00
|
|
|
>{{ $t('commons.save') }}
|
2022-09-20 11:53:57 +08:00
|
|
|
</deBtn>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<deBtn
|
|
|
|
v-if="
|
|
|
|
formType === 'add'
|
|
|
|
? true
|
|
|
|
: hasDataPermission('manage', params.privileges)
|
|
|
|
"
|
|
|
|
@click="validaDatasource"
|
2022-09-21 11:55:39 +08:00
|
|
|
>{{ $t('commons.validate') }}
|
2022-09-20 11:53:57 +08:00
|
|
|
</deBtn>
|
|
|
|
<deBtn
|
|
|
|
v-if="
|
|
|
|
formType === 'add' ||
|
|
|
|
hasDataPermission('manage', params.privileges)
|
|
|
|
"
|
|
|
|
type="primary"
|
|
|
|
@click="changeEdit"
|
2022-09-21 11:55:39 +08:00
|
|
|
>{{ $t('commons.edit') }}
|
2022-09-20 11:53:57 +08:00
|
|
|
</deBtn>
|
|
|
|
</template>
|
|
|
|
</div>
|
2022-09-19 17:07:50 +08:00
|
|
|
</div>
|
2022-09-20 11:53:57 +08:00
|
|
|
<div class="de-ds-cont">
|
|
|
|
<div class="de-ds-inner">
|
|
|
|
<div class="w600">
|
|
|
|
<el-form
|
|
|
|
ref="dsForm"
|
|
|
|
:model="form"
|
|
|
|
:rules="rule"
|
|
|
|
size="small"
|
|
|
|
:disabled="
|
|
|
|
params &&
|
|
|
|
params.id &&
|
|
|
|
params.showModel &&
|
|
|
|
params.showModel === 'show' &&
|
|
|
|
!canEdit
|
|
|
|
"
|
|
|
|
class="de-form-item"
|
|
|
|
label-width="180px"
|
|
|
|
label-position="right"
|
2022-05-20 00:31:17 +08:00
|
|
|
>
|
2022-09-20 11:53:57 +08:00
|
|
|
<el-form-item :label="$t('datasource.display_name')" prop="name">
|
|
|
|
<el-input
|
|
|
|
v-model="form.name"
|
|
|
|
autocomplete="off"
|
|
|
|
:placeholder="$t('commons.input_name')"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('commons.description')" prop="desc">
|
|
|
|
<deTextarea
|
|
|
|
class="w100-textarea"
|
|
|
|
v-model="form.desc"
|
|
|
|
></deTextarea>
|
|
|
|
</el-form-item>
|
2022-04-17 15:05:01 +08:00
|
|
|
|
2022-09-20 11:53:57 +08:00
|
|
|
<el-form-item
|
|
|
|
v-if="datasourceType.isJdbc"
|
|
|
|
:label="$t('driver.driver')"
|
|
|
|
>
|
|
|
|
<el-select
|
|
|
|
v-model="form.configuration.customDriver"
|
|
|
|
:placeholder="$t('driver.please_choose_driver')"
|
|
|
|
class="select-width"
|
|
|
|
style="width: 100%"
|
|
|
|
filterable
|
|
|
|
>
|
|
|
|
<el-option
|
|
|
|
v-for="item in driverList"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
|
|
|
:disabled="!item.driverClass"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2021-07-05 12:17:16 +08:00
|
|
|
|
2022-09-20 11:53:57 +08:00
|
|
|
<ds-configuration
|
|
|
|
v-if="!datasourceType.isPlugin"
|
|
|
|
ref="dsConfig"
|
|
|
|
:datasource-type="datasourceType"
|
|
|
|
:form="form"
|
|
|
|
:disabled="
|
|
|
|
params &&
|
|
|
|
params.id &&
|
|
|
|
params.showModel &&
|
|
|
|
params.showModel === 'show' &&
|
|
|
|
!canEdit
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
<plugin-com
|
|
|
|
v-if="datasourceType.isPlugin"
|
|
|
|
ref="pluginDsConfig"
|
|
|
|
:component-name="datasourceType.type"
|
|
|
|
:obj="{ form, disabled }"
|
|
|
|
/>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
2021-06-22 11:54:53 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-20 11:53:57 +08:00
|
|
|
</div>
|
2021-04-29 15:38:03 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-09-21 11:55:39 +08:00
|
|
|
import LayoutContent from '@/components/business/LayoutContent'
|
2022-05-20 00:31:17 +08:00
|
|
|
import {
|
|
|
|
addDs,
|
|
|
|
editDs,
|
|
|
|
getSchema,
|
|
|
|
validateDs,
|
|
|
|
validateDsById,
|
|
|
|
checkApiDatasource,
|
2022-09-20 11:53:57 +08:00
|
|
|
listDriverByType,
|
2022-09-21 11:55:39 +08:00
|
|
|
getDatasourceDetail
|
|
|
|
} from '@/api/system/datasource'
|
|
|
|
import { $confirm } from '@/utils/message'
|
|
|
|
import i18n from '@/lang/index'
|
|
|
|
import ApiHttpRequestForm from '@/views/system/datasource/ApiHttpRequestForm'
|
|
|
|
import DsConfiguration from '@/views/system/datasource/DsConfiguration'
|
|
|
|
import PluginCom from '@/views/system/plugin/PluginCom'
|
|
|
|
import { listDatasourceType, listDatasource } from '@/api/system/datasource'
|
|
|
|
import deTextarea from '@/components/deCustomCm/deTextarea.vue'
|
|
|
|
import msgCfm from '@/components/msgCfm'
|
2021-04-29 15:38:03 +08:00
|
|
|
export default {
|
2022-09-21 11:55:39 +08:00
|
|
|
name: 'DsForm',
|
2022-09-20 11:53:57 +08:00
|
|
|
mixins: [msgCfm],
|
2022-02-18 17:59:19 +08:00
|
|
|
components: {
|
2022-04-15 16:08:33 +08:00
|
|
|
DsConfiguration,
|
2022-02-18 17:59:19 +08:00
|
|
|
LayoutContent,
|
2022-04-17 15:05:01 +08:00
|
|
|
ApiHttpRequestForm,
|
2022-09-20 11:53:57 +08:00
|
|
|
PluginCom,
|
2022-09-21 11:55:39 +08:00
|
|
|
deTextarea
|
2021-06-17 18:58:46 +08:00
|
|
|
},
|
2021-04-29 15:38:03 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2022-04-17 15:05:01 +08:00
|
|
|
disabled: false,
|
2021-08-16 18:27:20 +08:00
|
|
|
form: {
|
|
|
|
configuration: {
|
2021-08-16 18:05:46 +08:00
|
|
|
initialPoolSize: 5,
|
2022-09-21 11:55:39 +08:00
|
|
|
extraParams: '',
|
2021-08-16 18:05:46 +08:00
|
|
|
minPoolSize: 5,
|
|
|
|
maxPoolSize: 50,
|
|
|
|
maxIdleTime: 30,
|
|
|
|
acquireIncrement: 5,
|
|
|
|
idleConnectionTestPeriod: 5,
|
2022-05-23 23:19:03 +08:00
|
|
|
connectTimeout: 5,
|
2022-09-21 11:55:39 +08:00
|
|
|
customDriver: 'default',
|
2022-09-20 11:53:57 +08:00
|
|
|
queryTimeout: 30,
|
2022-09-21 11:55:39 +08:00
|
|
|
host: ''
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
apiConfiguration: []
|
2021-08-16 18:27:20 +08:00
|
|
|
},
|
2022-04-17 15:05:01 +08:00
|
|
|
datasourceType: {},
|
2021-04-29 15:38:03 +08:00
|
|
|
rule: {
|
2022-09-20 11:53:57 +08:00
|
|
|
name: [
|
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.input_name'),
|
|
|
|
trigger: 'blur'
|
2022-09-20 11:53:57 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
min: 2,
|
|
|
|
max: 25,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.input_limit_2_25', [2, 25]),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
|
|
|
desc: [
|
|
|
|
{
|
|
|
|
min: 2,
|
|
|
|
max: 50,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.input_limit_2_50'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
|
|
|
type: [
|
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_choose_type'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.dataBase': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_data_base'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.connectionType': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_select_oracle_type'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.username': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_user_name'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.password': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_password'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.host': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_host'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.url': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_url'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.port': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_port'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.initialPoolSize': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_initial_pool_size'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.minPoolSize': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_min_pool_size'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.maxPoolSize': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_max_pool_size'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.maxIdleTime': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_max_idle_time'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.acquireIncrement': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_acquire_increment'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-09-21 11:55:39 +08:00
|
|
|
'configuration.connectTimeout': [
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_connect_timeout'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
|
|
|
url: [
|
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_url'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
|
|
|
dataPath: [
|
|
|
|
{
|
|
|
|
required: true,
|
2022-09-21 11:55:39 +08:00
|
|
|
message: i18n.t('datasource.please_input_dataPath'),
|
|
|
|
trigger: 'blur'
|
|
|
|
}
|
|
|
|
]
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
2021-07-05 12:17:16 +08:00
|
|
|
schemas: [],
|
2021-08-03 12:21:10 +08:00
|
|
|
canEdit: false,
|
2022-02-18 17:59:19 +08:00
|
|
|
originConfiguration: {},
|
|
|
|
edit_api_item: false,
|
2022-02-24 16:43:54 +08:00
|
|
|
add_api_item: true,
|
2022-02-18 17:59:19 +08:00
|
|
|
active: 0,
|
|
|
|
defaultApiItem: {
|
2022-09-21 11:55:39 +08:00
|
|
|
name: '',
|
|
|
|
url: '',
|
|
|
|
method: 'GET',
|
2022-02-18 17:59:19 +08:00
|
|
|
request: {
|
2022-02-23 17:13:34 +08:00
|
|
|
headers: [{}],
|
2022-02-23 15:02:01 +08:00
|
|
|
body: {
|
2022-09-21 11:55:39 +08:00
|
|
|
type: '',
|
|
|
|
raw: '',
|
|
|
|
kvs: []
|
|
|
|
}
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
fields: []
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
apiItem: {
|
2022-09-21 11:55:39 +08:00
|
|
|
status: '',
|
|
|
|
name: '',
|
|
|
|
url: '',
|
|
|
|
method: 'GET',
|
|
|
|
dataPath: '',
|
2022-02-18 17:59:19 +08:00
|
|
|
request: {
|
|
|
|
headers: [],
|
2022-02-23 15:02:01 +08:00
|
|
|
body: {
|
2022-09-21 11:55:39 +08:00
|
|
|
type: '',
|
|
|
|
raw: '',
|
|
|
|
kvs: []
|
2022-02-23 15:02:01 +08:00
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
authManager: {}
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
fields: []
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
2022-09-20 11:53:57 +08:00
|
|
|
reqOptions: [
|
2022-09-21 11:55:39 +08:00
|
|
|
{ id: 'GET', label: 'GET' },
|
|
|
|
{ id: 'POST', label: 'POST' }
|
2022-09-20 11:53:57 +08:00
|
|
|
],
|
2022-02-18 17:59:19 +08:00
|
|
|
loading: false,
|
2022-09-21 11:55:39 +08:00
|
|
|
responseData: { type: 'HTTP', responseResult: {}, subRequestResults: [] },
|
|
|
|
api_table_title: '',
|
|
|
|
api_step2_active_name: 'first',
|
2022-02-18 17:59:19 +08:00
|
|
|
fieldTypes: [
|
2022-09-21 11:55:39 +08:00
|
|
|
{ label: this.$t('dataset.text'), value: 0 },
|
|
|
|
{ label: this.$t('dataset.time'), value: 1 },
|
|
|
|
{ label: this.$t('dataset.value'), value: 2 },
|
2022-09-20 11:53:57 +08:00
|
|
|
{
|
|
|
|
label:
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')',
|
|
|
|
value: 3
|
2022-09-20 11:53:57 +08:00
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
{ label: this.$t('dataset.location'), value: 5 }
|
2022-02-18 17:59:19 +08:00
|
|
|
],
|
2022-04-02 15:41:55 +08:00
|
|
|
height: 500,
|
2022-05-20 00:31:17 +08:00
|
|
|
disabledNext: false,
|
2022-09-20 11:53:57 +08:00
|
|
|
driverList: [],
|
|
|
|
tData: [],
|
|
|
|
dsTypes: [],
|
2022-09-21 11:55:39 +08:00
|
|
|
msgNodeId: '',
|
2022-09-20 11:53:57 +08:00
|
|
|
params: {},
|
2022-09-21 11:55:39 +08:00
|
|
|
formType: 'add'
|
|
|
|
}
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
2022-09-20 11:53:57 +08:00
|
|
|
async created() {
|
2022-09-21 11:55:39 +08:00
|
|
|
await this.datasourceTypes()
|
|
|
|
this.queryTreeDatas()
|
|
|
|
const { id, showModel, msgNodeId, type } = this.$route.query
|
|
|
|
this.params = this.$route.query
|
2022-09-20 11:53:57 +08:00
|
|
|
if (id) {
|
2022-09-21 11:55:39 +08:00
|
|
|
await this.getDatasourceDetail(id, showModel)
|
|
|
|
this.edit(this.params)
|
|
|
|
this.changeType(true)
|
2021-04-29 15:38:03 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.canEdit = true
|
|
|
|
this.disabled = false
|
2022-09-20 11:53:57 +08:00
|
|
|
if (type) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.setType()
|
|
|
|
this.changeType()
|
2021-06-24 11:09:07 +08:00
|
|
|
}
|
2021-04-29 15:38:03 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
this.disabled = Boolean(id) && showModel === 'show' && !this.canEdit
|
2021-06-17 18:58:46 +08:00
|
|
|
},
|
2021-04-29 15:38:03 +08:00
|
|
|
methods: {
|
2022-09-20 11:53:57 +08:00
|
|
|
datasourceTypes() {
|
|
|
|
return listDatasourceType().then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.dsTypes = res.data || []
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getDatasourceDetail(id, showModel) {
|
|
|
|
return getDatasourceDetail(id).then((res) => {
|
|
|
|
this.params = {...res.data, showModel}
|
|
|
|
})
|
2022-09-19 17:07:50 +08:00
|
|
|
},
|
2022-09-20 11:53:57 +08:00
|
|
|
queryTreeDatas() {
|
|
|
|
listDatasource().then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.tData = this.buildTree(res.data)
|
|
|
|
})
|
2022-09-19 17:07:50 +08:00
|
|
|
},
|
2022-09-20 11:53:57 +08:00
|
|
|
buildTree(array) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const types = {}
|
|
|
|
const newArr = []
|
2022-09-20 11:53:57 +08:00
|
|
|
for (let index = 0; index < array.length; index++) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const element = array[index]
|
2022-09-20 11:53:57 +08:00
|
|
|
if (this.msgNodeId) {
|
|
|
|
if (element.id === this.msgNodeId) {
|
2022-09-21 11:55:39 +08:00
|
|
|
element.msgNode = true
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(element.type in types)) {
|
2022-09-21 11:55:39 +08:00
|
|
|
types[element.type] = []
|
2022-09-20 11:53:57 +08:00
|
|
|
// newArr.push(...element, ...{ children: types[element.type] })
|
|
|
|
newArr.push({
|
|
|
|
id: element.type,
|
|
|
|
name: element.typeDesc,
|
2022-09-21 11:55:39 +08:00
|
|
|
type: 'folder',
|
|
|
|
children: types[element.type]
|
|
|
|
})
|
2022-09-19 17:07:50 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
types[element.type].push(element)
|
2022-09-20 11:53:57 +08:00
|
|
|
// newArr.children.push({ id: element.id, label: element.name })
|
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
return newArr
|
2022-09-19 17:07:50 +08:00
|
|
|
},
|
2021-06-24 11:09:07 +08:00
|
|
|
setType() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.form.type = this.params.type
|
2021-08-16 18:05:46 +08:00
|
|
|
this.form.configuration = {
|
|
|
|
initialPoolSize: 5,
|
2022-09-21 11:55:39 +08:00
|
|
|
extraParams: '',
|
2021-08-16 18:05:46 +08:00
|
|
|
minPoolSize: 5,
|
|
|
|
maxPoolSize: 50,
|
|
|
|
maxIdleTime: 30,
|
|
|
|
acquireIncrement: 5,
|
|
|
|
idleConnectionTestPeriod: 5,
|
2022-05-25 20:24:51 +08:00
|
|
|
connectTimeout: 5,
|
2022-09-21 11:55:39 +08:00
|
|
|
customDriver: 'default',
|
|
|
|
queryTimeout: 30
|
|
|
|
}
|
2021-06-24 11:09:07 +08:00
|
|
|
},
|
2021-06-22 11:54:53 +08:00
|
|
|
changeEdit() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.canEdit = true
|
|
|
|
this.formType = 'modify'
|
2022-09-20 11:53:57 +08:00
|
|
|
this.disabled =
|
|
|
|
this.params &&
|
|
|
|
this.params.id &&
|
|
|
|
this.params.showModel &&
|
2022-09-21 11:55:39 +08:00
|
|
|
this.params.showModel === 'show' &&
|
|
|
|
!this.canEdit
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
|
|
|
edit(row) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.formType = 'modify'
|
|
|
|
this.form = JSON.parse(JSON.stringify(row))
|
|
|
|
if (row.type === 'api') {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.originConfiguration = JSON.parse(
|
|
|
|
JSON.stringify(this.form.apiConfiguration)
|
2022-09-21 11:55:39 +08:00
|
|
|
)
|
2022-09-20 11:53:57 +08:00
|
|
|
this.originConfiguration.forEach((item) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
delete item.status
|
|
|
|
})
|
|
|
|
this.originConfiguration = JSON.stringify(this.originConfiguration)
|
2022-03-14 21:30:22 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.form.configuration = JSON.parse(this.form.configuration)
|
|
|
|
this.originConfiguration = JSON.stringify(this.form.configuration)
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
this.disabled =
|
|
|
|
this.params &&
|
|
|
|
this.params.id &&
|
|
|
|
this.params.showModel &&
|
2022-09-21 11:55:39 +08:00
|
|
|
this.params.showModel === 'show' &&
|
|
|
|
!this.canEdit
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
|
|
|
reset() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$refs.dsForm.resetFields()
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
|
|
|
save() {
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
|
|
|
!this.form.configuration.schema &&
|
2022-09-21 11:55:39 +08:00
|
|
|
(this.form.type === 'oracle' ||
|
|
|
|
this.form.type === 'sqlServer' ||
|
|
|
|
this.form.type === 'pg' ||
|
|
|
|
this.form.type === 'redshift' ||
|
|
|
|
this.form.type === 'db2')
|
2022-09-20 11:53:57 +08:00
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$message.error(i18n.t('datasource.please_choose_schema'))
|
|
|
|
return
|
2021-07-05 12:17:16 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
2022-09-21 11:55:39 +08:00
|
|
|
this.form.type !== 'es' &&
|
|
|
|
this.form.type !== 'api' &&
|
2022-09-20 11:53:57 +08:00
|
|
|
this.form.configuration.port <= 0
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
|
|
|
|
return
|
2021-10-11 15:06:18 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
|
|
|
this.form.configuration.initialPoolSize < 0 ||
|
|
|
|
this.form.configuration.minPoolSize < 0 ||
|
|
|
|
this.form.configuration.maxPoolSize < 0
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$message.error(i18n.t('datasource.no_less_then_0'))
|
|
|
|
return
|
2021-08-16 18:05:46 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
let repeat = false
|
|
|
|
const repeatDsName = []
|
2022-09-20 11:53:57 +08:00
|
|
|
if (!this.datasourceType.isPlugin) {
|
|
|
|
this.tData.forEach((item) => {
|
2022-07-06 13:47:41 +08:00
|
|
|
if (item.id === this.form.type) {
|
2022-09-20 11:53:57 +08:00
|
|
|
item.children.forEach((child) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
if (this.formType === 'modify' && child.id === this.form.id) {
|
|
|
|
return
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
const configuration = JSON.parse(child.configuration)
|
2022-07-06 13:47:41 +08:00
|
|
|
if (!configuration) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
|
|
|
switch (this.form.type) {
|
2022-09-21 11:55:39 +08:00
|
|
|
case 'mysql':
|
|
|
|
case 'TiDB':
|
|
|
|
case 'StarRocks':
|
|
|
|
case 'hive':
|
|
|
|
case 'mariadb':
|
|
|
|
case 'ds_doris':
|
|
|
|
case 'ck':
|
|
|
|
case 'mongo':
|
|
|
|
case 'mariadb':
|
|
|
|
case 'impala':
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
|
|
|
configuration.host == this.form.configuration.host &&
|
|
|
|
configuration.dataBase ==
|
|
|
|
this.form.configuration.dataBase &&
|
|
|
|
configuration.port == this.form.configuration.port
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
repeat = true
|
|
|
|
repeatDsName.push(child.name)
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
break
|
|
|
|
case 'pg':
|
|
|
|
case 'sqlServer':
|
|
|
|
case 'redshift':
|
|
|
|
case 'oracle':
|
|
|
|
case 'db2':
|
2022-09-20 11:53:57 +08:00
|
|
|
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
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
repeatDsName.push(child.name)
|
|
|
|
repeat = true
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
break
|
|
|
|
case 'es':
|
2022-07-06 13:47:41 +08:00
|
|
|
if (configuration.url == this.form.configuration.url) {
|
2022-09-21 11:55:39 +08:00
|
|
|
repeatDsName.push(child.name)
|
|
|
|
repeat = true
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
break
|
2022-07-06 13:47:41 +08:00
|
|
|
default:
|
2022-09-21 11:55:39 +08:00
|
|
|
break
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-09-20 11:53:57 +08:00
|
|
|
} else {
|
|
|
|
if (this.datasourceType.isJdbc) {
|
|
|
|
this.tData.forEach((item) => {
|
|
|
|
if (item.id === this.form.type) {
|
|
|
|
item.children.forEach((child) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
if (this.formType === 'modify' && child.id === this.form.id) {
|
|
|
|
return
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
const configuration = JSON.parse(child.configuration)
|
2022-09-20 11:53:57 +08:00
|
|
|
if (!configuration) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
|
|
|
if (configuration.schema != null) {
|
|
|
|
if (
|
|
|
|
configuration.schema == this.form.configuration.schema &&
|
|
|
|
configuration.host == this.form.configuration.host &&
|
|
|
|
configuration.dataBase ==
|
|
|
|
this.form.configuration.dataBase &&
|
|
|
|
configuration.port == this.form.configuration.port
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
repeat = true
|
|
|
|
repeatDsName.push(child.name)
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (
|
|
|
|
configuration.host == this.form.configuration.host &&
|
|
|
|
configuration.dataBase ==
|
|
|
|
this.form.configuration.dataBase &&
|
|
|
|
configuration.port == this.form.configuration.port
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
repeat = true
|
|
|
|
repeatDsName.push(child.name)
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-07-06 13:47:41 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
let status = null
|
2022-05-29 10:00:46 +08:00
|
|
|
if (this.datasourceType.isPlugin) {
|
2022-09-21 11:55:39 +08:00
|
|
|
status = this.$refs['pluginDsConfig'].callPluginInner({
|
|
|
|
methodName: 'validate'
|
|
|
|
})
|
2022-05-29 10:00:46 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$refs['dsConfig'].$refs['DsConfig'].validate((valid) => {
|
|
|
|
status = valid
|
|
|
|
})
|
2022-04-20 20:28:07 +08:00
|
|
|
}
|
2022-05-29 10:00:46 +08:00
|
|
|
if (!status) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2022-09-19 17:07:50 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
this.$refs.dsForm.validate((valid) => {
|
2022-01-18 16:06:28 +08:00
|
|
|
if (!valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return false
|
2022-01-18 16:06:28 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
const method = this.formType === 'add' ? addDs : editDs
|
|
|
|
const form = JSON.parse(JSON.stringify(this.form))
|
|
|
|
if (form.type === 'api') {
|
2022-03-14 21:30:22 +08:00
|
|
|
if (this.form.apiConfiguration.length < 1) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$message.error(i18n.t('datasource.api_table_not_empty'))
|
|
|
|
return
|
2022-02-24 16:43:54 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
form.apiConfiguration.forEach((item) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
delete item.status
|
|
|
|
})
|
|
|
|
form.configuration = JSON.stringify(form.apiConfiguration)
|
2022-03-14 21:30:22 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
form.configuration = JSON.stringify(form.configuration)
|
2022-09-19 17:07:50 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
2022-09-21 11:55:39 +08:00
|
|
|
this.formType === 'modify' &&
|
2022-09-20 11:53:57 +08:00
|
|
|
this.originConfiguration !== form.configuration
|
|
|
|
) {
|
2022-02-18 17:59:19 +08:00
|
|
|
if (repeat) {
|
2022-09-20 11:53:57 +08:00
|
|
|
$confirm(
|
2022-09-21 11:55:39 +08:00
|
|
|
i18n.t('datasource.repeat_datasource_msg') +
|
|
|
|
'[' +
|
|
|
|
repeatDsName.join(',') +
|
|
|
|
'], ' +
|
|
|
|
i18n.t('datasource.confirm_save'),
|
2022-09-20 11:53:57 +08:00
|
|
|
() => {
|
2022-09-21 11:55:39 +08:00
|
|
|
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
|
|
|
this.method(method, form)
|
|
|
|
})
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
)
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
|
|
|
|
this.method(method, form)
|
|
|
|
})
|
2021-08-03 12:21:10 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2021-04-29 15:38:03 +08:00
|
|
|
}
|
2022-02-18 17:59:19 +08:00
|
|
|
if (repeat) {
|
2022-09-20 11:53:57 +08:00
|
|
|
$confirm(
|
2022-09-21 11:55:39 +08:00
|
|
|
i18n.t('datasource.repeat_datasource_msg') +
|
|
|
|
'[' +
|
|
|
|
repeatDsName.join(',') +
|
|
|
|
'], ' +
|
|
|
|
i18n.t('datasource.confirm_save'),
|
2022-09-20 11:53:57 +08:00
|
|
|
() => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.method(method, form)
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
)
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.method(method, form)
|
2022-01-18 16:06:28 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-01-18 16:06:28 +08:00
|
|
|
},
|
2022-02-18 17:59:19 +08:00
|
|
|
method(method, form) {
|
2022-09-20 11:53:57 +08:00
|
|
|
method(form).then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$success(i18n.t('commons.save_success'))
|
|
|
|
this.refreshType(form)
|
|
|
|
this.backToList()
|
|
|
|
})
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
2021-07-06 16:22:19 +08:00
|
|
|
getSchema() {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.$refs.dsForm.validate((valid) => {
|
2021-07-05 12:17:16 +08:00
|
|
|
if (valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const data = JSON.parse(JSON.stringify(this.form))
|
|
|
|
data.configuration = JSON.stringify(data.configuration)
|
2022-09-20 11:53:57 +08:00
|
|
|
getSchema(data).then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.schemas = res.data
|
|
|
|
this.openMessageSuccess('commons.success')
|
|
|
|
})
|
2021-07-05 12:17:16 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
return false
|
2021-07-05 12:17:16 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2021-07-05 12:17:16 +08:00
|
|
|
},
|
2021-04-29 15:38:03 +08:00
|
|
|
validaDatasource() {
|
2022-09-21 11:55:39 +08:00
|
|
|
if (!this.form.configuration.schema && this.form.type === 'oracle') {
|
|
|
|
this.openMessageSuccess('datasource.please_choose_schema', 'error')
|
|
|
|
return
|
2021-07-08 09:54:08 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
2022-09-21 11:55:39 +08:00
|
|
|
this.form.type !== 'es' &&
|
|
|
|
this.form.type !== 'api' &&
|
2022-09-20 11:53:57 +08:00
|
|
|
this.form.configuration.port <= 0
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.openMessageSuccess('datasource.port_no_less_then_0', 'error')
|
|
|
|
return
|
2021-10-11 17:09:29 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
let status = null
|
2022-05-29 10:00:46 +08:00
|
|
|
if (this.datasourceType.isPlugin) {
|
2022-09-21 11:55:39 +08:00
|
|
|
status = this.$refs['pluginDsConfig'].callPluginInner({
|
|
|
|
methodName: 'validate'
|
|
|
|
})
|
2022-05-29 10:00:46 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$refs['dsConfig'].$refs['DsConfig'].validate((valid) => {
|
|
|
|
status = valid
|
2022-05-29 10:00:46 +08:00
|
|
|
if (!valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2022-04-20 20:28:07 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-04-17 15:05:01 +08:00
|
|
|
}
|
2022-05-29 10:00:46 +08:00
|
|
|
if (!status) {
|
2022-09-21 11:55:39 +08:00
|
|
|
return
|
2022-04-17 15:05:01 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
this.$refs.dsForm.validate((valid) => {
|
2021-04-29 15:38:03 +08:00
|
|
|
if (valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const data = JSON.parse(JSON.stringify(this.form))
|
|
|
|
if (data.type === 'api') {
|
|
|
|
data.configuration = JSON.stringify(data.apiConfiguration)
|
2022-03-14 21:30:22 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
data.configuration = JSON.stringify(data.configuration)
|
2022-02-23 15:02:01 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
if (data.showModel === 'show' && !this.canEdit) {
|
2022-09-20 11:53:57 +08:00
|
|
|
validateDsById(data.id).then((res) => {
|
2021-09-03 14:40:47 +08:00
|
|
|
if (res.success) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.openMessageSuccess('datasource.validate_success')
|
2021-09-03 14:40:47 +08:00
|
|
|
} else {
|
2022-02-18 17:59:19 +08:00
|
|
|
if (res.message.length < 2500) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.openMessageSuccess(res.message, 'error')
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.openMessageSuccess(
|
2022-09-21 11:55:39 +08:00
|
|
|
res.message.substring(0, 2500) + '......',
|
|
|
|
'danger'
|
|
|
|
)
|
2022-01-05 21:30:03 +08:00
|
|
|
}
|
2021-08-23 16:27:05 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
this.refreshType(data)
|
|
|
|
})
|
2021-09-03 14:40:47 +08:00
|
|
|
} else {
|
2022-09-20 11:53:57 +08:00
|
|
|
validateDs(data)
|
|
|
|
.then((res) => {
|
|
|
|
if (res.success) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$success(i18n.t('datasource.validate_success'))
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
if (data.type === 'api') {
|
|
|
|
this.form.apiConfiguration = res.data.apiConfiguration
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
|
|
|
if (res.message.length < 2500) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.openMessageSuccess(res.message, 'error')
|
2022-09-20 11:53:57 +08:00
|
|
|
} else {
|
|
|
|
this.openMessageSuccess(
|
2022-09-21 11:55:39 +08:00
|
|
|
res.message.substring(0, 2500) + '......',
|
|
|
|
'danger'
|
|
|
|
)
|
2022-09-20 11:53:57 +08:00
|
|
|
}
|
2022-01-05 21:30:03 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
})
|
|
|
|
.catch((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.openMessageSuccess(res.message, 'error')
|
|
|
|
})
|
2021-08-23 16:27:05 +08:00
|
|
|
}
|
2021-04-29 15:38:03 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
return false
|
2021-04-29 15:38:03 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2021-04-29 15:38:03 +08:00
|
|
|
},
|
2022-05-20 00:31:17 +08:00
|
|
|
changeType(init) {
|
2022-04-15 16:08:33 +08:00
|
|
|
for (let i = 0; i < this.dsTypes.length; i++) {
|
|
|
|
if (this.dsTypes[i].type === this.form.type) {
|
2022-09-21 11:55:39 +08:00
|
|
|
if (this.form.type !== 'api' && !init) {
|
|
|
|
this.form.configuration.extraParams = this.dsTypes[i].extraParams
|
|
|
|
this.form.configuration.customDriver = 'default'
|
2022-04-26 18:57:42 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
this.datasourceType = this.dsTypes[i]
|
2022-05-29 10:00:46 +08:00
|
|
|
if (this.datasourceType.isJdbc) {
|
2022-09-20 11:53:57 +08:00
|
|
|
listDriverByType(this.datasourceType.type).then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.driverList = []
|
2022-09-20 11:53:57 +08:00
|
|
|
this.driverList.push({
|
2022-09-21 11:55:39 +08:00
|
|
|
id: 'default',
|
|
|
|
name: 'Default',
|
|
|
|
driverClass: 'Default'
|
|
|
|
})
|
|
|
|
this.driverList = this.driverList.concat(res.data)
|
|
|
|
})
|
2022-05-20 00:31:17 +08:00
|
|
|
}
|
2021-04-29 15:38:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
backToList() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$router.push('/datasource/index')
|
2021-06-17 19:34:46 +08:00
|
|
|
},
|
2021-11-02 15:42:52 +08:00
|
|
|
refreshType(form) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$emit('refresh-type', form)
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
next() {
|
2022-03-14 21:30:22 +08:00
|
|
|
if (this.active === 1) {
|
2022-09-21 11:55:39 +08:00
|
|
|
let hasRepeatName = false
|
2022-03-14 21:30:22 +08:00
|
|
|
if (this.add_api_item) {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.form.apiConfiguration.forEach((item) => {
|
2022-03-14 21:30:22 +08:00
|
|
|
if (item.name === this.apiItem.name) {
|
2022-09-21 11:55:39 +08:00
|
|
|
hasRepeatName = true
|
2022-02-24 16:43:54 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-03-14 21:30:22 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
const index = this.form.apiConfiguration.indexOf(this.apiItem)
|
2022-03-14 21:30:22 +08:00
|
|
|
for (let i = 0; i < this.form.apiConfiguration.length; i++) {
|
2022-09-20 11:53:57 +08:00
|
|
|
if (
|
|
|
|
i !== index &&
|
|
|
|
this.form.apiConfiguration[i].name === this.apiItem.name
|
|
|
|
) {
|
2022-09-21 11:55:39 +08:00
|
|
|
hasRepeatName = true
|
2022-02-24 16:43:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-14 21:30:22 +08:00
|
|
|
if (hasRepeatName) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$message.error(i18n.t('datasource.has_repeat_name'))
|
|
|
|
return
|
2022-02-24 16:43:54 +08:00
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
this.$refs.apiItem.validate((valid) => {
|
2022-02-18 17:59:19 +08:00
|
|
|
if (valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const data = JSON.parse(JSON.stringify(this.apiItem))
|
|
|
|
data.request = JSON.stringify(data.request)
|
|
|
|
this.loading = true
|
|
|
|
this.disabledNext = true
|
2022-09-20 11:53:57 +08:00
|
|
|
checkApiDatasource(data)
|
|
|
|
.then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.loading = false
|
|
|
|
this.disabledNext = false
|
|
|
|
this.apiItem.status = 'Success'
|
|
|
|
this.$success(i18n.t('commons.success'))
|
|
|
|
this.active++
|
|
|
|
this.apiItem.fields = res.data.fields
|
|
|
|
this.$refs.plxTable.reloadData(res.data.datas)
|
2022-09-20 11:53:57 +08:00
|
|
|
})
|
|
|
|
.catch((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.loading = false
|
|
|
|
this.disabledNext = false
|
|
|
|
})
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.apiItem.fields = []
|
|
|
|
return false
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
before() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.active--
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
closeEditItem() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.active = 0
|
|
|
|
this.edit_api_item = false
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
saveItem() {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.active = 0
|
|
|
|
this.edit_api_item = false
|
2022-03-14 21:30:22 +08:00
|
|
|
if (this.add_api_item) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.form.apiConfiguration.push(this.apiItem)
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
addApiItem(item) {
|
2022-03-31 22:51:54 +08:00
|
|
|
this.$nextTick(() => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.$refs.apiItem.clearValidate()
|
|
|
|
})
|
2022-02-18 17:59:19 +08:00
|
|
|
if (item) {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.add_api_item = false
|
|
|
|
this.api_table_title = this.$t('datasource.edit_api_table')
|
|
|
|
this.apiItem = item
|
2022-03-14 21:30:22 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.add_api_item = true
|
|
|
|
this.apiItem = JSON.parse(JSON.stringify(this.defaultApiItem))
|
|
|
|
this.api_table_title = this.$t('datasource.add_api_table')
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
this.active = 1
|
|
|
|
this.edit_api_item = true
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
deleteItem(item) {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.form.apiConfiguration.splice(
|
|
|
|
this.form.apiConfiguration.indexOf(item),
|
|
|
|
1
|
2022-09-21 11:55:39 +08:00
|
|
|
)
|
2022-02-18 17:59:19 +08:00
|
|
|
},
|
|
|
|
validateApi(item) {
|
2022-03-14 21:30:22 +08:00
|
|
|
if (undefined) {
|
|
|
|
} else {
|
2022-09-20 11:53:57 +08:00
|
|
|
this.$refs.apiItem.validate((valid) => {
|
2022-02-18 17:59:19 +08:00
|
|
|
if (valid) {
|
2022-09-21 11:55:39 +08:00
|
|
|
const data = JSON.parse(JSON.stringify(this.apiItem))
|
|
|
|
data.request = JSON.stringify(data.request)
|
|
|
|
this.loading = true
|
2022-09-20 11:53:57 +08:00
|
|
|
checkApiDatasource(data)
|
|
|
|
.then((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.loading = false
|
|
|
|
this.$success(i18n.t('commons.success'))
|
|
|
|
this.apiItem.fields = res.data.fields
|
|
|
|
this.$refs.plxTable.reloadData(res.data.datas)
|
2022-09-20 11:53:57 +08:00
|
|
|
})
|
|
|
|
.catch((res) => {
|
2022-09-21 11:55:39 +08:00
|
|
|
this.loading = false
|
|
|
|
})
|
2022-02-18 17:59:19 +08:00
|
|
|
} else {
|
2022-09-21 11:55:39 +08:00
|
|
|
return false
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
2022-09-21 11:55:39 +08:00
|
|
|
})
|
2022-02-18 17:59:19 +08:00
|
|
|
}
|
|
|
|
},
|
2022-09-21 11:55:39 +08:00
|
|
|
handleClick(tab, event) {}
|
|
|
|
}
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.de-ds-form {
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
.de-ds-top {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
height: 56px;
|
|
|
|
padding: 12px 24px;
|
|
|
|
box-shadow: 0px 2px 4px rgba(31, 35, 41, 0.08);
|
|
|
|
.name {
|
2022-09-21 11:55:39 +08:00
|
|
|
font-family: 'PingFang SC';
|
2022-09-20 11:53:57 +08:00
|
|
|
font-style: normal;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 24px;
|
|
|
|
color: var(--deTextPrimary, #1f2329);
|
|
|
|
}
|
|
|
|
i {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.de-ds-cont {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100% - 56px);
|
|
|
|
padding: 12px 24px 24px 24px;
|
|
|
|
background: #f5f6f7;
|
|
|
|
.de-ds-inner {
|
|
|
|
width: 100%;
|
|
|
|
height: 100;
|
|
|
|
background: #fff;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
.w600 {
|
|
|
|
width: 600px;
|
|
|
|
height: 100%;
|
|
|
|
padding-top: 24px;
|
2021-04-29 15:38:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-20 11:53:57 +08:00
|
|
|
</style>
|