Skip to content

Commit a0d01d9

Browse files
authored
feat: support adding license modification feature (#7838)
1 parent 364edbe commit a0d01d9

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

frontend/src/api/modules/setting.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import { ResPage, SearchWithPage, DescriptionUpdate, ReqPage } from '../interfac
55
import { Setting } from '../interface/setting';
66

77
// license
8-
export const uploadFileData = (params: FormData) => {
9-
return http.upload('/core/licenses/upload', params);
8+
export const uploadLicense = (oldLicense: string, params: FormData) => {
9+
if (oldLicense === '') {
10+
return http.upload('/core/licenses/upload', params);
11+
}
12+
return http.upload('/core/licenses/update', params);
1013
};
11-
export const SearchLicense = (params: ReqPage) => {
14+
export const searchLicense = (params: ReqPage) => {
1215
return http.post<ResPage<Setting.License>>('/core/licenses/search', params);
1316
};
14-
export const DeleteLicense = (id: number, force: boolean) => {
17+
export const deleteLicense = (id: number, force: boolean) => {
1518
return http.post('/core/licenses/del', { id: id, force: force });
1619
};
1720
export const getLicenseStatus = () => {

frontend/src/components/group/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<DrawerPro v-model="open" :header="$t('commons.table.group')" size="large" :back="handleClose">
2+
<DrawerPro v-model="open" :header="$t('commons.table.group')" @close="handleClose" size="large" :back="handleClose">
33
<template #content>
44
<ComplexTable :data="data" @search="search()">
55
<template #toolbar>

frontend/src/components/license-import/index.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import i18n from '@/lang';
4545
import { ref } from 'vue';
4646
import { MsgSuccess } from '@/utils/message';
47-
import { uploadFileData } from '@/api/modules/setting';
47+
import { uploadLicense } from '@/api/modules/setting';
4848
import { GlobalStore } from '@/store';
4949
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
5050
import { useTheme } from '@/global/use-theme';
@@ -57,6 +57,18 @@ const open = ref(false);
5757
const uploadRef = ref<UploadInstance>();
5858
const uploaderFiles = ref<UploadFiles>([]);
5959
60+
const oldLicense = ref();
61+
interface DialogProps {
62+
oldLicense: string;
63+
}
64+
65+
const acceptParams = (params: DialogProps) => {
66+
oldLicense.value = params?.oldLicense || '';
67+
uploaderFiles.value = [];
68+
uploadRef.value?.clearFiles();
69+
open.value = true;
70+
};
71+
6072
const handleClose = () => {
6173
open.value = false;
6274
uploadRef.value!.clearFiles();
@@ -88,8 +100,9 @@ const submit = async () => {
88100
const file = uploaderFiles.value[0];
89101
const formData = new FormData();
90102
formData.append('file', file.raw);
103+
formData.append('title', oldLicense.value);
91104
loading.value = true;
92-
await uploadFileData(formData)
105+
await uploadLicense(oldLicense.value, formData)
93106
.then(async () => {
94107
globalStore.isProductPro = true;
95108
const xpackRes = await getXpackSetting();
@@ -113,12 +126,6 @@ const submit = async () => {
113126
});
114127
};
115128
116-
const acceptParams = () => {
117-
uploaderFiles.value = [];
118-
uploadRef.value?.clearFiles();
119-
open.value = true;
120-
};
121-
122129
defineExpose({
123130
acceptParams,
124131
});

frontend/src/views/setting/license/bind/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const onBind = async (formEl: FormInstance | undefined) => {
6464
loading.value = false;
6565
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
6666
globalStore.isProductPro = false;
67-
globalStore.themeConfig.isGold = false;
6867
window.location.reload();
6968
})
7069
.catch(() => {

frontend/src/views/setting/license/delete/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { FormInstance } from 'element-plus';
2828
import { ref } from 'vue';
2929
import i18n from '@/lang';
3030
import { MsgSuccess } from '@/utils/message';
31-
import { DeleteLicense } from '@/api/modules/setting';
31+
import { deleteLicense } from '@/api/modules/setting';
3232
3333
let form = reactive({
3434
id: 0,
@@ -56,7 +56,7 @@ const acceptParams = async (prop: DialogProps) => {
5656
5757
const submit = async () => {
5858
loading.value = true;
59-
DeleteLicense(form.id, form.forceDelete)
59+
deleteLicense(form.id, form.forceDelete)
6060
.then(() => {
6161
loading.value = false;
6262
emit('search');

frontend/src/views/setting/license/index.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
<script setup lang="ts">
8787
import { ref, reactive, onMounted } from 'vue';
88-
import { SearchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
88+
import { searchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
8989
import LicenseImport from '@/components/license-import/index.vue';
9090
import LicenseDelete from '@/views/setting/license/delete/index.vue';
9191
import LicenseBind from '@/views/setting/license/bind/index.vue';
@@ -165,7 +165,7 @@ const search = async () => {
165165
page: paginationConfig.currentPage,
166166
pageSize: paginationConfig.pageSize,
167167
};
168-
await SearchLicense(params)
168+
await searchLicense(params)
169169
.then((res) => {
170170
loading.value = false;
171171
data.value = res.data.items || [];
@@ -176,6 +176,7 @@ const search = async () => {
176176
? i18n.global.t('license.indefinitePeriod')
177177
: timestampToDate(Number(item.productPro));
178178
}
179+
paginationConfig.total = res.data.total;
179180
})
180181
.catch(() => {
181182
loading.value = false;
@@ -233,6 +234,15 @@ const buttons = [
233234
onUnbind(row);
234235
},
235236
},
237+
{
238+
label: i18n.global.t('commons.button.edit'),
239+
disabled: (row: any) => {
240+
return row.status === 'Free';
241+
},
242+
click: (row: any) => {
243+
licenseRef.value.acceptParams({ oldLicense: row.licenseName });
244+
},
245+
},
236246
{
237247
label: i18n.global.t('commons.button.sync'),
238248
disabled: (row: any) => {

0 commit comments

Comments
 (0)