mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-13 12:00:08 +08:00
feat: support adding license modification feature (#7838)
This commit is contained in:
parent
364edbe2ca
commit
a0d01d9a55
@ -5,13 +5,16 @@ import { ResPage, SearchWithPage, DescriptionUpdate, ReqPage } from '../interfac
|
|||||||
import { Setting } from '../interface/setting';
|
import { Setting } from '../interface/setting';
|
||||||
|
|
||||||
// license
|
// license
|
||||||
export const uploadFileData = (params: FormData) => {
|
export const uploadLicense = (oldLicense: string, params: FormData) => {
|
||||||
return http.upload('/core/licenses/upload', params);
|
if (oldLicense === '') {
|
||||||
|
return http.upload('/core/licenses/upload', params);
|
||||||
|
}
|
||||||
|
return http.upload('/core/licenses/update', params);
|
||||||
};
|
};
|
||||||
export const SearchLicense = (params: ReqPage) => {
|
export const searchLicense = (params: ReqPage) => {
|
||||||
return http.post<ResPage<Setting.License>>('/core/licenses/search', params);
|
return http.post<ResPage<Setting.License>>('/core/licenses/search', params);
|
||||||
};
|
};
|
||||||
export const DeleteLicense = (id: number, force: boolean) => {
|
export const deleteLicense = (id: number, force: boolean) => {
|
||||||
return http.post('/core/licenses/del', { id: id, force: force });
|
return http.post('/core/licenses/del', { id: id, force: force });
|
||||||
};
|
};
|
||||||
export const getLicenseStatus = () => {
|
export const getLicenseStatus = () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<DrawerPro v-model="open" :header="$t('commons.table.group')" size="large" :back="handleClose">
|
<DrawerPro v-model="open" :header="$t('commons.table.group')" @close="handleClose" size="large" :back="handleClose">
|
||||||
<template #content>
|
<template #content>
|
||||||
<ComplexTable :data="data" @search="search()">
|
<ComplexTable :data="data" @search="search()">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { uploadFileData } from '@/api/modules/setting';
|
import { uploadLicense } from '@/api/modules/setting';
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
|
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
|
||||||
import { useTheme } from '@/global/use-theme';
|
import { useTheme } from '@/global/use-theme';
|
||||||
@ -57,6 +57,18 @@ const open = ref(false);
|
|||||||
const uploadRef = ref<UploadInstance>();
|
const uploadRef = ref<UploadInstance>();
|
||||||
const uploaderFiles = ref<UploadFiles>([]);
|
const uploaderFiles = ref<UploadFiles>([]);
|
||||||
|
|
||||||
|
const oldLicense = ref();
|
||||||
|
interface DialogProps {
|
||||||
|
oldLicense: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const acceptParams = (params: DialogProps) => {
|
||||||
|
oldLicense.value = params?.oldLicense || '';
|
||||||
|
uploaderFiles.value = [];
|
||||||
|
uploadRef.value?.clearFiles();
|
||||||
|
open.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
uploadRef.value!.clearFiles();
|
uploadRef.value!.clearFiles();
|
||||||
@ -88,8 +100,9 @@ const submit = async () => {
|
|||||||
const file = uploaderFiles.value[0];
|
const file = uploaderFiles.value[0];
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file.raw);
|
formData.append('file', file.raw);
|
||||||
|
formData.append('title', oldLicense.value);
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await uploadFileData(formData)
|
await uploadLicense(oldLicense.value, formData)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
globalStore.isProductPro = true;
|
globalStore.isProductPro = true;
|
||||||
const xpackRes = await getXpackSetting();
|
const xpackRes = await getXpackSetting();
|
||||||
@ -113,12 +126,6 @@ const submit = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const acceptParams = () => {
|
|
||||||
uploaderFiles.value = [];
|
|
||||||
uploadRef.value?.clearFiles();
|
|
||||||
open.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
});
|
});
|
||||||
|
@ -64,7 +64,6 @@ const onBind = async (formEl: FormInstance | undefined) => {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
globalStore.isProductPro = false;
|
globalStore.isProductPro = false;
|
||||||
globalStore.themeConfig.isGold = false;
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
@ -28,7 +28,7 @@ import { FormInstance } from 'element-plus';
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
import { DeleteLicense } from '@/api/modules/setting';
|
import { deleteLicense } from '@/api/modules/setting';
|
||||||
|
|
||||||
let form = reactive({
|
let form = reactive({
|
||||||
id: 0,
|
id: 0,
|
||||||
@ -56,7 +56,7 @@ const acceptParams = async (prop: DialogProps) => {
|
|||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
DeleteLicense(form.id, form.forceDelete)
|
deleteLicense(form.id, form.forceDelete)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
emit('search');
|
emit('search');
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { SearchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
|
import { searchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
|
||||||
import LicenseImport from '@/components/license-import/index.vue';
|
import LicenseImport from '@/components/license-import/index.vue';
|
||||||
import LicenseDelete from '@/views/setting/license/delete/index.vue';
|
import LicenseDelete from '@/views/setting/license/delete/index.vue';
|
||||||
import LicenseBind from '@/views/setting/license/bind/index.vue';
|
import LicenseBind from '@/views/setting/license/bind/index.vue';
|
||||||
@ -165,7 +165,7 @@ const search = async () => {
|
|||||||
page: paginationConfig.currentPage,
|
page: paginationConfig.currentPage,
|
||||||
pageSize: paginationConfig.pageSize,
|
pageSize: paginationConfig.pageSize,
|
||||||
};
|
};
|
||||||
await SearchLicense(params)
|
await searchLicense(params)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
data.value = res.data.items || [];
|
data.value = res.data.items || [];
|
||||||
@ -176,6 +176,7 @@ const search = async () => {
|
|||||||
? i18n.global.t('license.indefinitePeriod')
|
? i18n.global.t('license.indefinitePeriod')
|
||||||
: timestampToDate(Number(item.productPro));
|
: timestampToDate(Number(item.productPro));
|
||||||
}
|
}
|
||||||
|
paginationConfig.total = res.data.total;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -233,6 +234,15 @@ const buttons = [
|
|||||||
onUnbind(row);
|
onUnbind(row);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: i18n.global.t('commons.button.edit'),
|
||||||
|
disabled: (row: any) => {
|
||||||
|
return row.status === 'Free';
|
||||||
|
},
|
||||||
|
click: (row: any) => {
|
||||||
|
licenseRef.value.acceptParams({ oldLicense: row.licenseName });
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: i18n.global.t('commons.button.sync'),
|
label: i18n.global.t('commons.button.sync'),
|
||||||
disabled: (row: any) => {
|
disabled: (row: any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user