feat: license历史

This commit is contained in:
caiyuchao
2025-08-04 15:38:04 +08:00
parent 1fa117b8f2
commit 964a281175
6 changed files with 92 additions and 8 deletions

View File

@@ -47,6 +47,13 @@ export function getLicense(id: number) {
return requestClient.get<LicenseApi.License>(`/license/license/get?id=${id}`); return requestClient.get<LicenseApi.License>(`/license/license/get?id=${id}`);
} }
/** 查询License历史 */
export function getLicenseHistory(id: number) {
return requestClient.get<LicenseApi.License[]>(
`/license/license/history?id=${id}`,
);
}
/** 新增License */ /** 新增License */
export function createLicense(data: LicenseApi.License) { export function createLicense(data: LicenseApi.License) {
return requestClient.post('/license/license/create', data); return requestClient.post('/license/license/create', data);

View File

@@ -33,5 +33,6 @@
"detail": "detail", "detail": "detail",
"downloadAll": "Download All", "downloadAll": "Download All",
"reapply": "Reapply", "reapply": "Reapply",
"reapplyAction": "Reapply For {0}" "reapplyAction": "Reapply For {0}",
"history": "History"
} }

View File

@@ -33,5 +33,6 @@
"detail": "详情", "detail": "详情",
"downloadAll": "全部下载", "downloadAll": "全部下载",
"reapply": "重新申请", "reapply": "重新申请",
"reapplyAction": "重新申请{0}" "reapplyAction": "重新申请{0}",
"history": "历史"
} }

View File

@@ -385,6 +385,10 @@ export function useGridColumns(
code: 'detail', code: 'detail',
text: $t('license.detail'), text: $t('license.detail'),
}, },
{
code: 'history',
text: $t('license.history'),
},
{ {
code: 'reapply', code: 'reapply',
text: $t('license.reapply'), text: $t('license.reapply'),
@@ -441,7 +445,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'expiryDate', field: 'expiryDate',
label: $t('license.expiryDate'), label: $t('license.expiryDate'),
content: (data) => { content: (data) => {
if (data.oldLicense) { if (data.oldLicense && data.oldLicense.expiryDate !== data.expiryDate) {
const after = h( const after = h(
'span', 'span',
{ {
@@ -449,7 +453,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
color: 'red', color: 'red',
}, },
}, },
`${formatDate(data?.expiryDate)}`, `${formatDate(data.expiryDate)}`,
); );
return h('div', {}, [ return h('div', {}, [
formatDate(data.oldLicense.expiryDate) as string, formatDate(data.oldLicense.expiryDate) as string,
@@ -463,7 +467,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'userNumber', field: 'userNumber',
label: $t('license.userNumber'), label: $t('license.userNumber'),
content: (data) => { content: (data) => {
if (data.oldLicense) { if (data.oldLicense && data.oldLicense.userNumber !== data.userNumber) {
const after = h( const after = h(
'span', 'span',
{ {
@@ -471,7 +475,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
color: 'red', color: 'red',
}, },
}, },
`${data.userNumber}`, `${data.userNumber ?? ''}`,
); );
return h('div', {}, [data.oldLicense.userNumber, after]); return h('div', {}, [data.oldLicense.userNumber, after]);
} }
@@ -482,7 +486,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'ranNumber', field: 'ranNumber',
label: $t('license.ranNumber'), label: $t('license.ranNumber'),
content: (data) => { content: (data) => {
if (data.oldLicense) { if (data.oldLicense && data.oldLicense.ranNumber !== data.ranNumber) {
const after = h( const after = h(
'span', 'span',
{ {
@@ -490,7 +494,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
color: 'red', color: 'red',
}, },
}, },
`${data.ranNumber}`, `${data.ranNumber ?? ''}`,
); );
return h('div', {}, [data.oldLicense.ranNumber, after]); return h('div', {}, [data.oldLicense.ranNumber, after]);
} }

View File

@@ -23,6 +23,7 @@ import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import Detail from './modules/detail.vue'; import Detail from './modules/detail.vue';
import Form from './modules/form.vue'; import Form from './modules/form.vue';
import History from './modules/history.vue';
const router = useRouter(); const router = useRouter();
@@ -31,6 +32,11 @@ const [FormModal, formModalApi] = useVbenModal({
destroyOnClose: true, destroyOnClose: true,
}); });
const [HistoryModal, historyModalApi] = useVbenModal({
connectedComponent: History,
destroyOnClose: true,
});
const [DetailModal, detailModalApi] = useVbenModal({ const [DetailModal, detailModalApi] = useVbenModal({
connectedComponent: Detail, connectedComponent: Detail,
destroyOnClose: true, destroyOnClose: true,
@@ -56,6 +62,11 @@ function onDetail(row: LicenseApi.License) {
detailModalApi.setData(row).open(); detailModalApi.setData(row).open();
} }
/** 历史License */
function onHistory(row: LicenseApi.License) {
historyModalApi.setData(row).open();
}
/** 下载License */ /** 下载License */
async function onDownload(row: LicenseApi.License) { async function onDownload(row: LicenseApi.License) {
const fileName = `${row.fileUrl?.slice( const fileName = `${row.fileUrl?.slice(
@@ -119,6 +130,10 @@ function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
onGenerate(row); onGenerate(row);
break; break;
} }
case 'history': {
onHistory(row);
break;
}
case 'reapply': { case 'reapply': {
onReapply(row); onReapply(row);
break; break;
@@ -169,6 +184,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<Page auto-content-height> <Page auto-content-height>
<FormModal @success="onRefresh" /> <FormModal @success="onRefresh" />
<DetailModal @success="onRefresh" /> <DetailModal @success="onRefresh" />
<HistoryModal @success="onRefresh" />
<Grid :table-title="$t('license.list')"> <Grid :table-title="$t('license.list')">
<template #toolbar-tools> <template #toolbar-tools>
<TableAction <TableAction

View File

@@ -0,0 +1,55 @@
<script lang="ts" setup>
import type { LicenseApi } from '#/api/license/license';
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { formatDateTime } from '@vben/utils';
import { getLicenseHistory } from '#/api/license/license';
import Detail from '../components/detail.vue';
const formDataList = ref<LicenseApi.License[]>();
const activeKey = ref(0);
const [Modal, modalApi] = useVbenModal({
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formDataList.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<LicenseApi.License>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formDataList.value = await getLicenseHistory(data.id);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal
title="License历史"
class="w-2/3"
:show-cancel-button="false"
:show-confirm-button="false"
>
<a-tabs v-model:active-key="activeKey" tab-scroll>
<a-tab-pane
v-for="(item, index) in formDataList"
:key="index"
:tab="formatDateTime(item.applicationTime as string)"
>
<Detail :form-data="item" />
</a-tab-pane>
</a-tabs>
</Modal>
</template>