fix error
This commit is contained in:
1 parent
e2e17eef96
commit
b55ace7c8e
2 files changed
+26
-27
No files matched your search
+23
-19
@@ -19,18 +19,7 @@
|
|||||||
<small>{{ $t('application.message.notApplied') }}</small>
|
<small>{{ $t('application.message.notApplied') }}</small>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
<router-link
|
<el-button size="small" type="primary" @click="onApply">{{ $t('common.button.apply') }}</el-button>
|
||||||
:to="{
|
|
||||||
name: 'service-detail',
|
|
||||||
params: {
|
|
||||||
id: service?.id
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
class="inline-block"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<el-button size="small" type="primary">{{ $t('common.button.apply') }}</el-button>
|
|
||||||
</router-link>
|
|
||||||
</p>
|
</p>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-input
|
<el-input
|
||||||
@@ -89,10 +78,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { ISchema } from '@/operators/api/models';
|
import { ISchema } from '@/operators/api/models';
|
||||||
import { IService } from '@/operators/service/models';
|
import { applicationOperator, IApi, IApplication, IApplicationType } from '@/operators';
|
||||||
import { IApplication } from '@/operators';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
import { ElPopover, ElInput, ElSelect, ElButton, ElTooltip, ElOption } from 'element-plus';
|
import { ElPopover, ElInput, ElSelect, ElButton, ElTooltip, ElOption, ElMessage } from 'element-plus';
|
||||||
|
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
value: {
|
value: {
|
||||||
@@ -116,8 +105,8 @@ export default defineComponent({
|
|||||||
type: Object as () => ISchema | undefined,
|
type: Object as () => ISchema | undefined,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
service: {
|
api: {
|
||||||
type: Object as () => IService | undefined,
|
type: Object as () => IApi | undefined,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
applications: {
|
applications: {
|
||||||
@@ -133,10 +122,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isApplied() {
|
isApplied() {
|
||||||
return this.applications.filter((application) => application.service?.id === this.service?.id).length > 0;
|
return this.applications.filter((application) => application.api?.id === this.api?.id).length > 0;
|
||||||
},
|
},
|
||||||
appliedApplication(): IApplication | undefined {
|
appliedApplication(): IApplication | undefined {
|
||||||
const applications = this.applications.filter((application) => application.service?.id === this.service?.id);
|
const applications = this.applications.filter((application) => application.api?.id === this.api?.id);
|
||||||
if (applications.length > 0) {
|
if (applications.length > 0) {
|
||||||
return applications[0];
|
return applications[0];
|
||||||
}
|
}
|
||||||
@@ -157,6 +146,21 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
onRefreshApplications() {
|
onRefreshApplications() {
|
||||||
this.$emit('refresh-applications');
|
this.$emit('refresh-applications');
|
||||||
|
},
|
||||||
|
onApply() {
|
||||||
|
applicationOperator
|
||||||
|
.create({
|
||||||
|
type: IApplicationType.API,
|
||||||
|
api_id: this.api?.id
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$emit('refresh-applications');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
|
||||||
|
ElMessage.error(this.$t('application.message.alreadyApplied'));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<api-form
|
<api-form
|
||||||
v-model:form="formValue.queries"
|
v-model:form="formValue.queries"
|
||||||
:schema="api?.request?.queries"
|
:schema="api?.request?.queries"
|
||||||
:service="api?.service"
|
:api="api"
|
||||||
:applications="applications"
|
:applications="applications"
|
||||||
@refresh-applications="getApplications"
|
@refresh-applications="getApplications"
|
||||||
/>
|
/>
|
||||||
@@ -22,18 +22,13 @@
|
|||||||
<api-form
|
<api-form
|
||||||
v-model:form="formValue.headers"
|
v-model:form="formValue.headers"
|
||||||
:schema="api?.request?.headers"
|
:schema="api?.request?.headers"
|
||||||
:service="api?.service"
|
:api="api"
|
||||||
:applications="applications"
|
:applications="applications"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h2 class="title">{{ $t('api.entity.requestBody') }}</h2>
|
<h2 class="title">{{ $t('api.entity.requestBody') }}</h2>
|
||||||
<api-form
|
<api-form v-model:form="formValue.body" :schema="api?.request?.body" :api="api" :applications="applications" />
|
||||||
v-model:form="formValue.body"
|
|
||||||
:schema="api?.request?.body"
|
|
||||||
:service="api?.service"
|
|
||||||
:applications="applications"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="api?.responses" class="responses">
|
<div v-if="api?.responses" class="responses">
|
||||||
<h2 class="title">{{ $t('api.entity.response') }}</h2>
|
<h2 class="title">{{ $t('api.entity.response') }}</h2>
|
||||||
|
|||||||
Reference in new issue
Block a user