add unit support

This commit is contained in:
AceDataCloud committed 2023-02-26 23:12:11 +08:00
1 parent 46da57bbf9
commit 25649410bc
11 files changed
+79 -126

No files matched your search

+13 -5
View File
@@ -27,7 +27,7 @@
class-name="text-center"
>
<template #default="scope">
<span>{{ getRemainingCount(scope.row) }}</span>
<span>{{ getCount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column
@@ -35,7 +35,11 @@
:label="$t('application.field.usedCount')"
width="100px"
class-name="text-center"
/>
>
<template #default="scope">
<span>{{ getCount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('application.field.credential')" class-name="credential" width="380px">
<template #default="scope">
<div v-if="scope?.row?.credential?.type === credentialType.TOKEN">
@@ -230,12 +234,16 @@ export default defineComponent({
this.loading = false;
});
},
getRemainingCount(application: IApplication) {
getCount(application: IApplication) {
if (application.type === IApplicationType.API) {
return application.remaining_count;
const unit = this.$t(`api.unit.${application?.api?.unit}`);
return `${application.remaining_count}${unit}`;
}
if (application.type === IApplicationType.PROXY) {
return `${((application.remaining_count || 0) / 1024 / 1024).toFixed(2)}MB`;
const unit = this.$t(`proxy.unit.${application?.proxy?.unit}`);
if (unit === 'MB') {
return `${((application.remaining_count || 0) / 1024 / 1024).toFixed(2)}${unit}`;
}
}
}
}
+6 -1
View File
@@ -33,7 +33,12 @@
{{ order?.application?.proxy?.title }}
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.amount')">
{{ order?.amount }}
<span v-if="order?.application?.type === applicationType.API">
{{ order?.amount }}{{ $t(`api.unit.${order?.application?.api?.unit}`) }}
</span>
<span v-if="order?.application?.type === applicationType.PROXY">
{{ order?.amount }}{{ $t(`proxy.unit.${order?.application?.proxy?.unit}`) }}
</span>
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.createdAt')">
{{ $dayjs.format(order?.created_at) }}