Add application selection (#186)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
7af0e714cd
commit
d357d1c857
24 files changed
+266
-48
No files matched your search
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<span v-if="application.type === 'Period'" class="info">
|
||||
<el-tag v-if="showType" type="primary" class="mr-1" effect="dark">
|
||||
{{ $t('application.type.period') }}
|
||||
</el-tag>
|
||||
{{ $t('common.message.expiredAt') }}:
|
||||
{{ $dayjs.format(application.expired_at) }}
|
||||
<p v-if="showId" class="subtitle">ID: {{ application.id }}</p>
|
||||
</span>
|
||||
<span v-if="application.type === 'Usage'" type="success" class="info" effect="dark">
|
||||
<el-tag v-if="showType" class="mr-1">
|
||||
{{ $t('application.type.usage') }}
|
||||
</el-tag>
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
<p v-if="showId" class="subtitle">ID: {{ application.id }}</p>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApplication } from '@/models';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationInfo',
|
||||
components: {
|
||||
ElTag
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication,
|
||||
required: true
|
||||
},
|
||||
showType: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showId: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.info {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-primary);
|
||||
text-align: center;
|
||||
line-height: 28px;
|
||||
}
|
||||
.subtitle {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -8,15 +8,21 @@
|
||||
</el-skeleton>
|
||||
</div>
|
||||
<div v-else-if="application" class="status">
|
||||
<span v-if="application.type === 'Period'" class="info">
|
||||
{{ $t('common.message.expiredAt') }}:
|
||||
{{ $dayjs.format(application.expired_at) }}
|
||||
</span>
|
||||
<span v-if="application.type === 'Usage'" class="info">
|
||||
{{ $t('common.message.remainingAmount') }}:
|
||||
{{ application?.remaining_amount?.toFixed(6) }}
|
||||
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
|
||||
</span>
|
||||
<el-dropdown @command="onSelectApplication">
|
||||
<span class="el-dropdown-link">
|
||||
<application-info :application="application" />
|
||||
<el-icon v-if="applications && applications.length > 0" class="el-icon--right">
|
||||
<arrow-down />
|
||||
</el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu v-if="applications && applications.length > 0">
|
||||
<el-dropdown-item v-for="(app, index) in applications" :key="index" :command="app">
|
||||
<application-info :application="app" :show-type="true" :show-id="true" />
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span class="actions">
|
||||
<el-button round size="small" type="primary" class="mr-1" @click="onBuyMore(application)">{{
|
||||
$t('common.button.buyMore')
|
||||
@@ -49,12 +55,23 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { applicationOperator, credentialOperator } from '@/operators';
|
||||
import { ElButton, ElMessage, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import {
|
||||
ElButton,
|
||||
ElMessage,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem,
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElIcon,
|
||||
ElDropdownMenu
|
||||
} from 'element-plus';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
|
||||
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
|
||||
import { ROUTE_CONSOLE_APPLICATION_SUBSCRIBE } from '@/router';
|
||||
import ApiPrice from '@/components/api/Price.vue';
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
import ApplicationInfo from './Info.vue';
|
||||
|
||||
export interface IData {
|
||||
confirming: boolean;
|
||||
@@ -63,12 +80,28 @@ export interface IData {
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationStatus',
|
||||
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem, ApiPrice },
|
||||
components: {
|
||||
ElButton,
|
||||
ApplicationInfo,
|
||||
ApplicationConfirm,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem,
|
||||
ApiPrice,
|
||||
ElDropdown,
|
||||
ElDropdownMenu,
|
||||
ElDropdownItem,
|
||||
ArrowDown,
|
||||
ElIcon
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Array as () => IApplication[] | undefined,
|
||||
default: undefined
|
||||
},
|
||||
initializing: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -86,7 +119,7 @@ export default defineComponent({
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['apply', 'refresh', 'applied', 'update:application'],
|
||||
emits: ['apply', 'refresh', 'applied', 'update:application', 'select'],
|
||||
data(): IData {
|
||||
return {
|
||||
confirming: this.needApply,
|
||||
@@ -143,6 +176,9 @@ export default defineComponent({
|
||||
this.$emit('applied');
|
||||
});
|
||||
},
|
||||
onSelectApplication(application: IApplication) {
|
||||
this.$emit('select', application);
|
||||
},
|
||||
onApply() {
|
||||
applicationOperator
|
||||
.create({
|
||||
@@ -175,12 +211,15 @@ export default defineComponent({
|
||||
display: block;
|
||||
width: fit-content;
|
||||
margin: auto;
|
||||
.el-icon {
|
||||
position: relative;
|
||||
top: 0.2em;
|
||||
}
|
||||
.el-dropdown {
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin: 0 5px;
|
||||
display: inline-block;
|
||||
|
||||
@@ -39,14 +39,13 @@ export default defineComponent({
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
height: 80px;
|
||||
// height: 80px;
|
||||
font-size: 14px;
|
||||
background-color: var(--el-color-color);
|
||||
color: var(--el-text-color-primary);
|
||||
|
||||
Reference in new issue
Block a user