dataease/frontend/src/views/system/datasource/form.vue

661 lines
21 KiB
Vue
Raw Normal View History

<template>
<layout-content :header="formType=='add' ? $t('datasource.create') : $t('datasource.modify')">
<template v-slot:header>
2021-12-07 17:09:20 +08:00
<el-icon name="back" class="back-button" @click.native="backToList"/>
2021-11-24 18:49:41 +08:00
{{
params && params.id && params.showModel && params.showModel === 'show' && !canEdit ? $t('datasource.show_info') : formType == 'add' ? $t('datasource.create') : $t('datasource.modify')
}}
</template>
<div>
<el-form
ref="dsForm"
:model="form"
:rules="rule"
size="small"
2022-04-17 15:05:01 +08:00
:disabled="params && params.id && params.showModel && params.showModel === 'show' && !canEdit"
label-width="180px"
label-position="right"
>
<el-form-item :label="$t('commons.name')" prop="name">
2021-12-07 17:09:20 +08:00
<el-input v-model="form.name" autocomplete="off"/>
</el-form-item>
<el-form-item :label="$t('commons.description')" prop="desc">
2021-12-07 17:09:20 +08:00
<el-input v-model="form.desc" autocomplete="off"/>
</el-form-item>
<el-form-item :label="$t('datasource.type')" prop="type">
<el-select
v-model="form.type"
:placeholder="$t('datasource.please_choose_type')"
class="select-width"
:disabled="formType=='modify' || (formType==='add' && params && !!params.type)"
@change="changeType()"
2022-02-18 17:59:19 +08:00
filterable
>
<el-option
2022-04-15 16:08:33 +08:00
v-for="item in dsTypes"
:key="item.type"
:label="item.name"
:value="item.type"
/>
</el-select>
</el-form-item>
2022-04-24 14:10:18 +08:00
<ds-configuration ref="dsConfig" v-if="!datasourceType.isPlugin" :datasource-type='datasourceType' :form="form" :disabled="params && params.id && params.showModel && params.showModel === 'show' && !canEdit"></ds-configuration>
2022-04-17 15:05:01 +08:00
<plugin-com ref="pluginDsConfig" v-if="datasourceType.isPlugin" :component-name="datasourceType.type" :obj="{form, disabled }" />
2022-04-15 16:08:33 +08:00
</el-form>
2022-02-18 17:59:19 +08:00
<div v-if="canEdit" slot="footer" class="dialog-footer">
2022-02-18 17:59:19 +08:00
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)"
@click="validaDatasource">{{ $t('commons.validate') }}
2021-11-24 18:49:41 +08:00
</el-button>
2022-02-18 17:59:19 +08:00
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)" type="primary"
@click="save">{{ $t('commons.save') }}
2021-11-24 18:49:41 +08:00
</el-button>
</div>
<div v-else slot="footer" class="dialog-footer">
2022-02-18 17:59:19 +08:00
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)"
@click="validaDatasource">{{ $t('commons.validate') }}
2021-11-24 18:49:41 +08:00
</el-button>
2022-02-18 17:59:19 +08:00
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)" type="primary"
@click="changeEdit">{{ $t('commons.edit') }}
2021-11-24 18:49:41 +08:00
</el-button>
</div>
</div>
</layout-content>
</template>
<script>
import LayoutContent from '@/components/business/LayoutContent'
2022-02-18 17:59:19 +08:00
import {addDs, editDs, getSchema, validateDs, validateDsById, checkApiDatasource} from '@/api/system/datasource'
2021-12-07 17:09:20 +08:00
import {$confirm} from '@/utils/message'
2021-12-01 11:56:05 +08:00
import i18n from '@/lang/index'
2022-02-18 17:59:19 +08:00
import ApiHttpRequestForm from '@/views/system/datasource/ApiHttpRequestForm'
2022-04-15 16:08:33 +08:00
import DsConfiguration from "@/views/system/datasource/DsConfiguration";
2022-04-17 15:05:01 +08:00
import PluginCom from '@/views/system/plugin/PluginCom'
2021-08-03 12:21:10 +08:00
export default {
name: 'DsForm',
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,
PluginCom
2022-02-18 17:59:19 +08:00
},
props: {
params: {
type: Object,
default: null
},
tData: {
type: Array,
default: null
2022-04-15 16:08:33 +08:00
},
dsTypes: {
type: Array,
default: null
}
},
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,
extraParams: '',
2021-08-16 18:05:46 +08:00
minPoolSize: 5,
maxPoolSize: 50,
maxIdleTime: 30,
acquireIncrement: 5,
idleConnectionTestPeriod: 5,
connectTimeout: 5
2022-02-18 17:59:19 +08:00
},
apiConfiguration: []
2021-08-16 18:27:20 +08:00
},
2022-04-17 15:05:01 +08:00
datasourceType: {},
rule: {
2022-03-31 22:51:54 +08:00
name: [{required: true, message: i18n.t('datasource.input_name'), trigger: 'blur'},
{min: 2, max: 25, message: i18n.t('datasource.input_limit_2_25', [2, 25]), trigger: 'blur'}],
2022-01-27 13:31:10 +08:00
desc: [{min: 2, max: 50, message: i18n.t('datasource.input_limit_2_50'), trigger: 'blur'}],
2022-03-31 22:51:54 +08:00
type: [{required: true, message: i18n.t('datasource.please_choose_type'), trigger: 'blur'}],
2021-11-24 18:49:41 +08:00
'configuration.dataBase': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_data_base'),
2021-11-24 18:49:41 +08:00
trigger: 'blur'
}],
'configuration.connectionType': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_select_oracle_type'),
2021-11-24 18:49:41 +08:00
trigger: 'blur'
}],
'configuration.username': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_user_name'),
2021-11-24 18:49:41 +08:00
trigger: 'blur'
}],
'configuration.password': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_password'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
2022-03-31 22:51:54 +08:00
'configuration.host': [{required: true, message: i18n.t('datasource.please_input_host'), trigger: 'blur'}],
'configuration.url': [{required: true, message: i18n.t('datasource.please_input_url'), trigger: 'blur'}],
'configuration.port': [{required: true, message: i18n.t('datasource.please_input_port'), trigger: 'blur'}],
2021-11-24 18:49:41 +08:00
'configuration.initialPoolSize': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_initial_pool_size'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
'configuration.minPoolSize': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_min_pool_size'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
'configuration.maxPoolSize': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_max_pool_size'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
'configuration.maxIdleTime': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_max_idle_time'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
'configuration.acquireIncrement': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_acquire_increment'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2021-11-24 18:49:41 +08:00
}],
'configuration.connectTimeout': [{
required: true,
2021-12-01 11:56:05 +08:00
message: i18n.t('datasource.please_input_connect_timeout'),
2022-03-31 22:51:54 +08:00
trigger: 'blur'
2022-02-18 17:59:19 +08:00
}],
2022-03-31 22:51:54 +08:00
'url': [{required: true, message: i18n.t('datasource.please_input_url'), trigger: 'blur'}],
'dataPath': [{required: true, message: i18n.t('datasource.please_input_dataPath'), trigger: 'blur'}]
},
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: {
name: '',
url: '',
method: 'GET',
request: {
2022-02-23 17:13:34 +08:00
headers: [{}],
2022-02-23 15:02:01 +08:00
body: {
"type": "",
"raw": "",
"kvs": []
}
2022-02-18 17:59:19 +08:00
},
fields: []
},
apiItem: {
2022-02-24 16:43:54 +08:00
status: '',
2022-02-18 17:59:19 +08:00
name: '',
url: '',
method: 'GET',
dataPath: '',
request: {
headers: [],
2022-02-23 15:02:01 +08:00
body: {
"type": "",
"raw": "",
"kvs": []
},
2022-02-18 17:59:19 +08:00
authManager: {}
},
fields: []
},
reqOptions: [{id: 'GET', label: 'GET'}, {id: 'POST', label: 'POST'}],
loading: false,
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
api_table_title: '',
api_step2_active_name: 'first',
fieldTypes: [
{label: this.$t('dataset.text'), value: 0},
{label: this.$t('dataset.time'), value: 1},
{label: this.$t('dataset.value'), value: 2},
{label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 3},
{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,
disabledNext: false
}
},
created() {
if (this.params && this.params.id) {
const row = this.params
this.edit(row)
2022-04-17 15:05:01 +08:00
this.changeType()
} else {
this.create()
2021-06-24 11:09:07 +08:00
if (this.params && this.params.type) {
2022-04-20 20:28:07 +08:00
this.setType()
2022-04-17 15:05:01 +08:00
this.changeType()
2021-06-24 11:09:07 +08:00
}
}
2022-04-15 16:08:33 +08:00
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
},
mounted() {
},
methods: {
2021-06-24 11:09:07 +08:00
setType() {
this.form.type = this.params.type
2021-08-16 18:05:46 +08:00
this.form.configuration = {
initialPoolSize: 5,
extraParams: '',
2021-08-16 18:05:46 +08:00
minPoolSize: 5,
maxPoolSize: 50,
maxIdleTime: 30,
acquireIncrement: 5,
idleConnectionTestPeriod: 5,
connectTimeout: 5
}
2022-04-17 15:05:01 +08:00
2021-06-24 11:09:07 +08:00
},
changeEdit() {
this.canEdit = true
this.formType = 'modify'
2022-04-15 16:08:33 +08:00
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
},
create() {
this.formType = 'add'
this.canEdit = true
2022-04-15 16:08:33 +08:00
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
},
edit(row) {
this.formType = 'modify'
2022-02-18 17:59:19 +08:00
this.form = JSON.parse(JSON.stringify(row))
2021-08-03 12:21:10 +08:00
this.originConfiguration = this.form.configuration
if (row.type === 'api') {
} else {
2022-02-18 17:59:19 +08:00
this.form.configuration = JSON.parse(this.form.configuration)
}
2022-04-15 16:08:33 +08:00
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
},
reset() {
this.$refs.dsForm.resetFields()
},
save() {
2022-01-26 10:37:14 +08:00
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer' || this.form.type === 'pg' || this.form.type === 'redshift' || this.form.type === 'db2')) {
2021-12-01 11:56:05 +08:00
this.$message.error(i18n.t('datasource.please_choose_schema'))
return
}
2022-04-15 16:08:33 +08:00
if (this.form.type !== 'es' && this.form.type !== 'api' && this.form.configuration.port <= 0) {
2021-12-01 11:56:05 +08:00
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
2021-10-11 15:06:18 +08:00
return
}
if (this.form.configuration.initialPoolSize < 0 || this.form.configuration.minPoolSize < 0 || this.form.configuration.maxPoolSize < 0) {
2021-12-01 11:56:05 +08:00
this.$message.error(i18n.t('datasource.no_less_then_0'))
2021-08-16 18:05:46 +08:00
return
}
let repeat = false
let repeatDsName = []
this.tData.forEach(item => {
2022-02-18 17:59:19 +08:00
if (item.id === this.form.type) {
item.children.forEach(child => {
2022-02-18 17:59:19 +08:00
if (this.formType === 'modify' && child.id === this.form.id) {
2022-01-23 15:08:42 +08:00
return
}
let configuration = JSON.parse(child.configuration)
2022-04-01 11:18:08 +08:00
if(!configuration){
return
}
switch (this.form.type) {
case 'mysql':
2022-04-01 11:18:08 +08:00
case 'TiDB':
case 'StarRocks':
case 'hive':
case 'mariadb':
case 'ds_doris':
case 'ck':
case 'mongo':
case 'mariadb':
2022-04-26 15:35:19 +08:00
case 'impala':
2022-02-18 17:59:19 +08:00
if (configuration.host == this.form.configuration.host && configuration.dataBase == this.form.configuration.dataBase && configuration.port == this.form.configuration.port) {
repeat = true
repeatDsName.push(child.name)
}
break
case 'pg':
case 'sqlServer':
case 'redshift':
case 'oracle':
case 'db2':
2022-02-18 17:59:19 +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) {
repeatDsName.push(child.name)
repeat = true
}
break
case 'es':
2022-02-18 17:59:19 +08:00
if (configuration.url == this.form.configuration.url) {
repeatDsName.push(child.name)
repeat = true
}
break
default:
break
}
})
}
})
2022-04-20 20:28:07 +08:00
let status = null;
if(this.datasourceType.isPlugin){
status = this.$refs['pluginDsConfig'].callPluginInner({methodName: 'validate'})
}else {
2022-04-24 14:10:18 +08:00
this.$refs['dsConfig'].$refs['DsConfig'].validate(valid => {
2022-04-20 20:28:07 +08:00
status = valid
})
}
if(!status){
return;
}
this.$refs.dsForm.validate(valid => {
if (!valid) {
return false
}
const method = this.formType === 'add' ? addDs : editDs
const form = JSON.parse(JSON.stringify(this.form))
if (form.type === 'api') {
if (this.form.apiConfiguration.length < 1) {
2022-02-24 16:43:54 +08:00
this.$message.error(i18n.t('datasource.api_table_not_empty'))
return
}
form.apiConfiguration.forEach(item => {
delete item.status
})
2022-02-18 17:59:19 +08:00
form.configuration = JSON.stringify(form.apiConfiguration)
} else {
2022-02-18 17:59:19 +08:00
form.configuration = JSON.stringify(form.configuration)
}
if (this.formType === 'modify' && this.originConfiguration !== form.configuration) {
2022-02-18 17:59:19 +08:00
if (repeat) {
$confirm(i18n.t('datasource.repeat_datasource_msg') + '[' + repeatDsName.join(',') + '], ' + i18n.t('datasource.confirm_save'), () => {
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
this.method(method, form)
2021-08-03 12:21:10 +08:00
})
})
2022-02-18 17:59:19 +08:00
} else {
$confirm(i18n.t('datasource.edit_datasource_msg'), () => {
this.method(method, form)
2021-08-03 12:21:10 +08:00
})
}
return
}
2022-02-18 17:59:19 +08:00
if (repeat) {
$confirm(i18n.t('datasource.repeat_datasource_msg') + '[' + repeatDsName.join(',') + '], ' + i18n.t('datasource.confirm_save'), () => {
this.method(method, form)
})
2022-02-18 17:59:19 +08:00
} else {
this.method(method, form)
}
})
},
2022-02-18 17:59:19 +08:00
method(method, form) {
method(form).then(res => {
this.$success(i18n.t('commons.save_success'))
this.refreshType(form)
this.backToList()
})
},
2021-07-06 16:22:19 +08:00
getSchema() {
this.$refs.dsForm.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
data.configuration = JSON.stringify(data.configuration)
getSchema(data).then(res => {
this.schemas = res.data
2021-12-01 11:56:05 +08:00
this.$success(i18n.t('commons.success'))
})
} else {
return false
}
})
},
validaDatasource() {
2021-07-08 09:54:08 +08:00
if (!this.form.configuration.schema && this.form.type === 'oracle') {
2021-12-01 11:56:05 +08:00
this.$message.error(i18n.t('datasource.please_choose_schema'))
2021-07-08 09:54:08 +08:00
return
}
2022-04-15 16:08:33 +08:00
if (this.form.type !== 'es' && this.form.type !== 'api' && this.form.configuration.port <= 0) {
2021-12-01 11:56:05 +08:00
this.$message.error(i18n.t('datasource.port_no_less_then_0'))
2021-10-11 17:09:29 +08:00
return
}
2022-04-17 15:05:01 +08:00
let status = null;
if(this.datasourceType.isPlugin){
status = this.$refs['pluginDsConfig'].callPluginInner({methodName: 'validate'})
}else {
2022-04-20 20:28:07 +08:00
this.$refs['dsConfig'].$refs['DsConfig'].validate(valid => {
status = valid
if(!valid){
return
}
})
2022-04-17 15:05:01 +08:00
}
if(!status){
return;
}
this.$refs.dsForm.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.form))
if (data.type === 'api') {
2022-02-23 15:02:01 +08:00
data.configuration = JSON.stringify(data.apiConfiguration)
} else {
2022-02-23 15:02:01 +08:00
data.configuration = JSON.stringify(data.configuration)
}
2021-09-03 14:40:47 +08:00
if (data.showModel === 'show' && !this.canEdit) {
validateDsById(data.id).then(res => {
2021-09-03 14:40:47 +08:00
if (res.success) {
2021-12-01 11:56:05 +08:00
this.$success(i18n.t('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) {
this.$error(res.message)
2022-02-18 17:59:19 +08:00
} else {
this.$error(res.message.substring(0, 2500) + '......')
}
}
2021-11-03 10:36:35 +08:00
this.refreshType(data)
})
2021-09-03 14:40:47 +08:00
} else {
validateDs(data).then(res => {
2021-09-03 14:40:47 +08:00
if (res.success) {
2021-12-01 11:56:05 +08:00
this.$success(i18n.t('datasource.validate_success'))
2021-09-03 14:40:47 +08:00
} else {
if (data.type === 'api') {
2022-02-24 16:43:54 +08:00
this.form.apiConfiguration = res.data.apiConfiguration
}
2022-02-18 17:59:19 +08:00
if (res.message.length < 2500) {
this.$error(res.message)
2022-02-18 17:59:19 +08:00
} else {
this.$error(res.message.substring(0, 2500) + '......')
}
}
}).catch(res => {
this.$error(res.message)
})
}
} else {
return false
}
})
},
changeType() {
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) {
if(row.type !== 'api'){
this.form.configuration.extraParams = this.dsTypes[i].extraParams
}
2022-04-17 15:05:01 +08:00
this.datasourceType = this.dsTypes[i]
}
}
},
backToList() {
2021-11-24 18:49:41 +08:00
this.$emit('switch-component', {})
2021-06-17 19:34:46 +08:00
},
refreshType(form) {
this.$emit('refresh-type', form)
2022-02-18 17:59:19 +08:00
},
next() {
if (this.active === 1) {
2022-02-24 16:43:54 +08:00
let hasRepeatName = false
if (this.add_api_item) {
2022-02-24 16:43:54 +08:00
this.form.apiConfiguration.forEach(item => {
if (item.name === this.apiItem.name) {
2022-02-24 16:43:54 +08:00
hasRepeatName = true
}
})
} else {
2022-02-24 16:43:54 +08:00
let index = this.form.apiConfiguration.indexOf(this.apiItem)
for (let i = 0; i < this.form.apiConfiguration.length; i++) {
if (i !== index && this.form.apiConfiguration[i].name === this.apiItem.name) {
2022-02-24 16:43:54 +08:00
hasRepeatName = true
}
}
}
if (hasRepeatName) {
2022-02-24 16:43:54 +08:00
this.$message.error(i18n.t('datasource.has_repeat_name'))
return
}
2022-02-18 17:59:19 +08:00
this.$refs.apiItem.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.apiItem))
data.request = JSON.stringify(data.request)
this.loading = true
2022-04-02 15:41:55 +08:00
this.disabledNext = true
2022-02-18 17:59:19 +08:00
checkApiDatasource(data).then(res => {
this.loading = false
2022-04-02 15:41:55 +08:00
this.disabledNext = false
2022-02-24 16:43:54 +08:00
this.apiItem.status = 'Success'
2022-02-18 17:59:19 +08:00
this.$success(i18n.t('commons.success'))
this.active++
this.apiItem.fields = res.data.fields
this.$refs.plxTable.reloadData(res.data.datas)
}).catch(res => {
this.loading = false
2022-04-02 15:41:55 +08:00
this.disabledNext = false
2022-02-18 17:59:19 +08:00
})
} else {
this.apiItem.fields = []
return false
}
})
}
},
before() {
this.active--
},
closeEditItem() {
this.active = 0
this.edit_api_item = false
},
saveItem() {
this.active = 0
this.edit_api_item = false
if (this.add_api_item) {
2022-02-18 17:59:19 +08:00
this.form.apiConfiguration.push(this.apiItem)
}
},
addApiItem(item) {
2022-03-31 22:51:54 +08:00
this.$nextTick(() => {
this.$refs.apiItem.clearValidate()
})
2022-02-18 17:59:19 +08:00
if (item) {
2022-02-24 16:43:54 +08:00
this.add_api_item = false
2022-02-18 17:59:19 +08:00
this.api_table_title = this.$t('datasource.edit_api_table')
this.apiItem = item
} else {
2022-02-24 16:43:54 +08:00
this.add_api_item = true
2022-02-18 17:59:19 +08:00
this.apiItem = JSON.parse(JSON.stringify(this.defaultApiItem))
this.api_table_title = this.$t('datasource.add_api_table')
}
this.active = 1
this.edit_api_item = true
},
deleteItem(item) {
this.form.apiConfiguration.splice(this.form.apiConfiguration.indexOf(item), 1)
},
validateApi(item) {
if (undefined) {
2022-02-18 17:59:19 +08:00
} else {
2022-02-18 17:59:19 +08:00
this.$refs.apiItem.validate(valid => {
if (valid) {
const data = JSON.parse(JSON.stringify(this.apiItem))
data.request = JSON.stringify(data.request)
this.loading = true
checkApiDatasource(data).then(res => {
this.loading = false
this.$success(i18n.t('commons.success'))
this.apiItem.fields = res.data.fields
this.$refs.plxTable.reloadData(res.data.datas)
}).catch(res => {
this.loading = false
})
} else {
return false
}
})
}
},
handleClick(tab, event) {
}
}
}
</script>
<style scoped>
.el-input {
width: 300px;
}
.el-select {
width: 300px;
}
.ms-http-input {
width: 500px;
margin-top: 5px;
}
2022-02-23 17:13:34 +08:00
.tip {
padding: 3px 5px;
font-size: 16px;
border-radius: 0;
border-left: 4px solid #409EFF;
margin: 5px 5px 10px 5px;
}
.el-select >>> input {
padding-right: 10px;
}
.el-select >>> .el-input__suffix {
right: 0;
}
.dialog-css >>> .el-dialog__header {
padding: 10px 20px 0px;
}
.dialog-css >>> .el-dialog__body {
padding: 10px 20px 10px;
}
.dialog-footer >>> .el-dialog__footer {
padding: 10px 10px 10px;
}
2022-02-23 17:13:34 +08:00
</style>