add count management

This commit is contained in:
AceDataCloud committed 2023-03-28 10:30:41 +08:00
1 parent fcb056bb54
commit 523ab178a4
11 files changed
+196 -19

No files matched your search

+29 -14
View File
@@ -33,7 +33,12 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ROUTE_CONSOLE_APPLICATION_LIST, ROUTE_CONSOLE_ORDER_LIST, ROUTE_INDEX } from '@/router';
import {
ROUTE_CONSOLE_ADMIN_APPLICATION,
ROUTE_CONSOLE_APPLICATION_LIST,
ROUTE_CONSOLE_ORDER_LIST,
ROUTE_INDEX
} from '@/router';
import { ElRow, ElCol } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { getAuthBaseUrl } from '@/utils';
@@ -44,10 +49,7 @@ interface ILink {
name?: string;
href?: string;
icon: string;
}
interface IData {
links: ILink[];
admin?: boolean;
}
export default defineComponent({
@@ -57,9 +59,15 @@ export default defineComponent({
ElCol,
FontAwesomeIcon
},
data(): IData {
return {
links: [
computed: {
active() {
return this.$route.matched[0].path;
},
user() {
return this.$store.getters.user;
},
links(): ILink[] {
let commonLinks: ILink[] = [
{
key: 'profile',
text: this.$t('console.menu.userProfile'),
@@ -84,12 +92,19 @@ export default defineComponent({
name: ROUTE_CONSOLE_ORDER_LIST,
icon: 'fa-solid fa-store'
}
]
};
},
computed: {
active() {
return this.$route.matched[0].path;
];
let adminLinks: ILink[] = [
{
key: 'admin-application',
text: this.$t('console.menu.manageApplication'),
name: ROUTE_CONSOLE_ADMIN_APPLICATION,
icon: 'fa-solid fa-cubes'
}
];
if (this.user.is_superuser) {
return [...commonLinks, ...adminLinks];
}
return commonLinks;
}
},
mounted() {},
+2 -1
View File
@@ -2,5 +2,6 @@ export default {
goDocument: '查看文档',
buyMore: '购买更多',
createOrder: '创建订单',
custom: '自定义'
custom: '自定义',
query: '查询'
};
+3 -1
View File
@@ -15,5 +15,7 @@ export default {
rotateCredentialConfirm: '你确定要重置密钥吗?重置后不可恢复',
idDoesNotExist: '申请不存在',
rotateCredentialSuccessfully: '密钥重置成功',
rotateCredentialFailed: '密钥重置失败,请联系处理'
rotateCredentialFailed: '密钥重置失败,请联系处理',
updateFailed: '修改失败',
updateSuccessfully: '修改成功'
};
+3 -1
View File
@@ -1,3 +1,5 @@
export default {
buyService: '购买服务'
buyService: '购买服务',
applicationRemainingCount: '次数修改',
manageApplication: '申请管理'
};
+2 -1
View File
@@ -25,5 +25,6 @@ export default {
applied: '已申请',
acquire: '获取',
fillExample: '填写样例',
buyMore: '购买更多'
buyMore: '购买更多',
update: '更新'
};
+2 -1
View File
@@ -2,5 +2,6 @@ export default {
orderList: '订单列表',
applicationList: '申请列表',
userProfile: '个人信息',
idVerify: '实名认证'
idVerify: '实名认证',
manageApplication: '申请管理'
};
+4
View File
@@ -39,6 +39,10 @@ class ApplicationOperator {
async rotateCredential(id: string): Promise<AxiosResponse<IApplicationDetailResponse>> {
return await httpClient.post(`/${this.key}/${id}/rotate-credential/`);
}
async updateRemainingAmount(id: string, data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
return await httpClient.post(`/${this.key}/${id}/update-remaining-amount/`, data);
}
}
export const applicationOperator = new ApplicationOperator();
+142
View File
@@ -0,0 +1,142 @@
<template>
<el-row class="panel">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('application.title.manageApplication') }}</h2>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-card shadow="hover">
<el-row>
<el-col :span="12" :offset="6">
<el-form :inline="true" label-width="120px">
<el-form-item :label="$t('application.field.id')">
<el-input v-model="id" />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="loading" @click="onQuery">
{{ $t('application.button.query') }}
</el-button>
</el-form-item>
</el-form>
<el-divider border-style="dashed" />
<el-form v-if="application" :inline="true" label-width="120px">
<el-form-item :label="$t('application.field.remainingAmount')">
<el-input v-model="application.remaining_amount" />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="updating" @click="onUpdateRemainingAmount">
{{ $t('common.button.update') }}
</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</el-card>
</el-col>
</el-row>
</el-col>
</el-row>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { applicationOperator, IApplication, IApplicationDetailResponse } from '@/operators';
import { ElRow, ElCol, ElCard, ElForm, ElFormItem, ElInput, ElButton, ElDivider, ElMessage } from 'element-plus';
interface IData {
application: IApplication | undefined;
loading: boolean;
updating: boolean;
id: string | undefined;
}
export default defineComponent({
name: 'ConsoleApplication',
components: {
ElRow,
ElCol,
ElCard,
ElForm,
ElFormItem,
ElInput,
ElButton,
ElDivider
},
data(): IData {
return {
application: undefined,
id: undefined,
loading: false,
updating: false
};
},
computed: {},
methods: {
onQuery() {
if (!this.id) {
return;
}
this.loading = true;
applicationOperator
.get(this.id)
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
this.application = data;
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
onUpdateRemainingAmount() {
if (!this.id) {
return;
}
this.updating = true;
applicationOperator
.updateRemainingAmount(this.id, {
remaining_amount: this.application?.remaining_amount
})
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
this.application = data;
this.updating = false;
ElMessage.success(this.$t('application.message.updateSuccessfully'));
})
.catch(() => {
this.updating = false;
ElMessage.error(this.$t('application.message.updateFailed'));
});
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.el-card {
min-height: 500px;
padding-top: 50px;
}
.panel {
padding: 30px;
.credential {
.copy {
cursor: pointer;
}
}
}
.pagination {
float: right;
}
</style>
+2
View File
@@ -8,6 +8,7 @@ import {
faRotateRight as faSolidRotateRight,
faCheck as faSolidCheck,
faCube as faSolidCube,
faCubes as faSolidCubes,
faStore as faSolidStore,
faQuestion as faSolidQuestion,
faArrowsRotate as faSolidArrowsRotate,
@@ -20,6 +21,7 @@ library.add(faSolidCheck);
library.add(faRegularUser);
library.add(faRegularIdCard);
library.add(faSolidCube);
library.add(faSolidCubes);
library.add(faSolidStore);
library.add(faSolidQuestion);
library.add(faSolidUpRightFromSquare);
+6
View File
@@ -1,4 +1,5 @@
import {
ROUTE_CONSOLE_ADMIN_APPLICATION,
ROUTE_CONSOLE_APPLICATION_BUY,
ROUTE_CONSOLE_APPLICATION_LIST,
ROUTE_CONSOLE_ORDER_DETAIL,
@@ -39,6 +40,11 @@ export default {
path: 'applications/:id/buy',
name: ROUTE_CONSOLE_APPLICATION_BUY,
component: () => import('@/pages/console/application/Buy.vue')
},
{
path: 'admin/application',
name: ROUTE_CONSOLE_ADMIN_APPLICATION,
component: () => import('@/pages/console/admin/Application.vue')
}
]
};
+1
View File
@@ -8,6 +8,7 @@ export const ROUTE_CONSOLE_ORDER_LIST = 'console-order-list';
export const ROUTE_CONSOLE_ORDER_DETAIL = 'console-order-detail';
export const ROUTE_CONSOLE_APPLICATION_LIST = 'console-application-list';
export const ROUTE_CONSOLE_APPLICATION_BUY = 'console-application-buy';
export const ROUTE_CONSOLE_ADMIN_APPLICATION = 'console-application-admin-application';
export const ROUTE_DOCUMENT_LIST = 'document-list';
export const ROUTE_DOCUMENT_DETAIL = 'document-detail';