feat: 重新申请license

This commit is contained in:
caiyuchao
2025-08-04 10:22:21 +08:00
parent 2c0601a46b
commit 1fa117b8f2
3 changed files with 104 additions and 79 deletions

View File

@@ -64,7 +64,7 @@ const columns = [
title: '激活码', title: '激活码',
dataIndex: 'activationCodeMap', dataIndex: 'activationCodeMap',
key: 'activationCodeMap', key: 'activationCodeMap',
customRender: (data) => { customRender: (data: any) => {
if (data.value.new) { if (data.value.new) {
const after = h( const after = h(
'span', 'span',
@@ -82,117 +82,137 @@ const columns = [
}, },
{ {
title: 'License文件', title: 'License文件',
dataIndex: 'fileUrlList', dataIndex: 'fileUrlListMap',
key: 'fileUrlList', key: 'fileUrlListMap',
customRender: (data: any) => { customRender: (data: any) => {
if (!data.value) { const getFile = (dataValue: any) => {
return; if (!dataValue) {
} return;
if (!data.value[0]) { }
return; if (!dataValue[0]) {
} return;
const fileName = `${data.value[0]?.slice( }
Math.max(0, data.value[0].lastIndexOf('/') + 1), const fileName = `${dataValue[0]?.slice(
data.value[0].lastIndexOf('_'), Math.max(0, dataValue[0].lastIndexOf('/') + 1),
)}.ini`; dataValue[0].lastIndexOf('_'),
// 创建下载链接
const link = h(
'span',
{
style: {
marginRight: '15px',
},
},
fileName,
);
// 创建下载按钮
const button = h(
Button,
{
onClick: async () => {
const res = await fetch(data.value[0]);
if (!res.ok) {
message.error($t('license.downloadFailed'));
return;
}
const blob = await res.blob();
downloadFileFromBlobPart({ fileName, source: blob });
},
type: 'primary',
},
() => $t('license.download'),
);
const file = h(
'div',
{
style: {
display: 'flex',
alignItems: 'center',
},
},
[link, button],
);
let file1;
if (data.value[1]) {
const fileName1 = `${data.value[1]?.slice(
Math.max(0, data.value[1].lastIndexOf('/') + 1),
data.value[1].lastIndexOf('_'),
)}.ini`; )}.ini`;
// 创建下载链接 // 创建下载链接
const link1 = h( const link = h(
'span', 'span',
{ {
style: { style: {
marginRight: '15px', marginRight: '15px',
}, },
}, },
fileName1, fileName,
); );
// 创建下载按钮 // 创建下载按钮
const button1 = h( const button = h(
Button, Button,
{ {
onClick: async () => { onClick: async () => {
const res = await fetch(data.value[1]); const res = await fetch(dataValue[0]);
if (!res.ok) { if (!res.ok) {
message.error($t('license.downloadFailed')); message.error($t('license.downloadFailed'));
return; return;
} }
const blob1 = await res.blob(); const blob = await res.blob();
downloadFileFromBlobPart({ fileName: fileName1, source: blob1 }); downloadFileFromBlobPart({ fileName, source: blob });
}, },
type: 'primary', type: 'primary',
}, },
() => $t('license.download'), () => $t('license.download'),
); );
file1 = h( const file = h(
'div', 'div',
{ {
style: { style: {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
margin: '8px 0 0 0',
}, },
}, },
[link1, button1], [link, button],
); );
}
let file1;
if (dataValue[1]) {
const fileName1 = `${dataValue[1]?.slice(
Math.max(0, dataValue[1].lastIndexOf('/') + 1),
dataValue[1].lastIndexOf('_'),
)}.ini`;
// 创建下载链接
const link1 = h(
'span',
{
style: {
marginRight: '15px',
},
},
fileName1,
);
// 创建下载按钮
const button1 = h(
Button,
{
onClick: async () => {
const res = await fetch(dataValue[1]);
if (!res.ok) {
message.error($t('license.downloadFailed'));
return;
}
const blob1 = await res.blob();
downloadFileFromBlobPart({
fileName: fileName1,
source: blob1,
});
},
type: 'primary',
},
() => $t('license.download'),
);
file1 = h(
'div',
{
style: {
display: 'flex',
alignItems: 'center',
margin: '8px 0 0 0',
},
},
[link1, button1],
);
}
return h(
'div',
{
style: {},
},
[file, file1],
);
};
// 包裹容器 // 包裹容器
return h( // return getFile(data.value);
'div',
{ if (data.value.new) {
style: {}, const after = h(
}, 'span',
[file, file1], {
); style: {
color: 'red',
},
},
[``, getFile(data.value.new)],
);
return h('div', {}, [getFile(data.value.old), after]);
}
return getFile(data.value.old);
}, },
}, },
]; ];

View File

@@ -388,7 +388,12 @@ export function useGridColumns(
{ {
code: 'reapply', code: 'reapply',
text: $t('license.reapply'), text: $t('license.reapply'),
show: hasAccessByCodes(['license:license:apply']), show: (values: LicenseApi.License) => {
return (
hasAccessByCodes(['license:license:apply']) &&
values.status === 3
);
},
}, },
{ {
code: 'generate', code: 'generate',
@@ -396,7 +401,7 @@ export function useGridColumns(
show: (values: LicenseApi.License) => { show: (values: LicenseApi.License) => {
return ( return (
hasAccessByCodes(['license:license:generate']) && hasAccessByCodes(['license:license:generate']) &&
values.status === 1 (values.status === 1 || values.status === 4)
); );
}, },
}, },

View File

@@ -136,7 +136,7 @@ getDetail(route.query.id);
<Button <Button
v-if=" v-if="
hasAccessByCodes(['license:license:generate']) && hasAccessByCodes(['license:license:generate']) &&
formData?.status === 1 (formData?.status === 1 || formData?.status === 4)
" "
type="primary" type="primary"
:loading="loading" :loading="loading"