From 2f446fac554fd3c3b1a2ea4ad1c68f962b2c2a08 Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Wed, 10 Sep 2025 00:30:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20license=E5=88=B0=E6=9C=9F=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/report/expire/index.ts | 38 +++ apps/web-antd/src/views/report/expire/data.ts | 285 ++++++++++++++++++ .../src/views/report/expire/index.vue | 30 ++ .../views/report/expire/modules/expired.vue | 60 ++++ .../views/report/expire/modules/expiring.vue | 60 ++++ 5 files changed, 473 insertions(+) create mode 100644 apps/web-antd/src/api/report/expire/index.ts create mode 100644 apps/web-antd/src/views/report/expire/data.ts create mode 100644 apps/web-antd/src/views/report/expire/index.vue create mode 100644 apps/web-antd/src/views/report/expire/modules/expired.vue create mode 100644 apps/web-antd/src/views/report/expire/modules/expiring.vue diff --git a/apps/web-antd/src/api/report/expire/index.ts b/apps/web-antd/src/api/report/expire/index.ts new file mode 100644 index 0000000..c67b55d --- /dev/null +++ b/apps/web-antd/src/api/report/expire/index.ts @@ -0,0 +1,38 @@ +import type { Dayjs } from 'dayjs'; + +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace ExpireApi { + /** 客户进展信息 */ + export interface Expire { + id: number; // 主键 + customerId?: number; // 客户ID + projectId?: number; // 项目ID + serialNo?: string; // sn + expiryDate: Dayjs | string; // 到期时间 + neList: number[]; // 网元 + userNumber: number; // 用户数 + ranNumber: number; // 基站数 + activationCode: string; // 激活码 + fileUrl: string; // 激活码 + licenseContent: string; // License内容 + applicant: number; // 申请人 + applicationTime: Dayjs | string; // 申请时间 + approver: number; // 审批人 + status: number; // 状态 + remark: string; // 备注 + applyCount: number; // 申请次数 + customerName?: string; // 客户名称 + projectName?: string; // 项目名称 + } +} + +/** 查询License 到期分页 */ +export function getExpiryLicensePage(params: PageParam) { + return requestClient.get>( + '/license/report/license/expire', + { params }, + ); +} diff --git a/apps/web-antd/src/views/report/expire/data.ts b/apps/web-antd/src/views/report/expire/data.ts new file mode 100644 index 0000000..ad9a7c8 --- /dev/null +++ b/apps/web-antd/src/views/report/expire/data.ts @@ -0,0 +1,285 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { ProgressApi } from '#/api/report/progress'; + +import dayjs from 'dayjs'; +import relativeTime from 'dayjs/plugin/relativeTime'; + +import { getCustomerList } from '#/api/license/customer'; +import { getProjectList } from '#/api/license/project'; +import { $t } from '#/locales'; +import { DICT_TYPE, getRangePickerDefaultProps } from '#/utils'; + +dayjs.extend(relativeTime); + +// ==================== 未过期 ==================== + +/** 列表的搜索表单 */ +export function useExpiringGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'customerId', + label: $t('license.customer'), + component: 'ApiSelect', + componentProps: { + api: getCustomerList, + allowClear: true, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.name.toLowerCase().includes(input.toLowerCase()), + }, + }, + { + fieldName: 'projectId', + label: $t('license.project'), + component: 'ApiSelect', + componentProps: { + api: getProjectList, + allowClear: true, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.name.toLowerCase().includes(input.toLowerCase()), + }, + }, + { + fieldName: 'serialNo', + label: 'SN', + component: 'Input', + componentProps: { + allowClear: true, + }, + }, + { + fieldName: 'expiryDate', + label: '到期时间', + component: 'RangePicker', + defaultValue: [dayjs(), dayjs().add(7, 'days')], + componentProps: { + ...getRangePickerDefaultProps(), + format: 'YYYY-MM-DD', + showTime: false, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useExpiringGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'customerName', + title: '客户名称', + showOverflow: false, + minWidth: 60, + }, + { + field: 'projectName', + title: '项目名称', + showOverflow: false, + minWidth: 80, + }, + { + field: 'status', + title: $t('project.status'), + minWidth: 40, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.LIC_PROJECT_STATUS }, + }, + }, + { + field: 'serialNo', + title: 'SN', + showOverflow: false, + minWidth: 40, + }, + { + field: 'businessOwnerName', + title: '业务负责人', + minWidth: 40, + }, + { + field: 'technicalOwnerAName', + title: '技术负责人1', + minWidth: 40, + }, + { + field: 'technicalOwnerBName', + title: '技术负责人2', + visible: false, + minWidth: 40, + }, + { + field: 'startTime', + title: '项目开始时间', + minWidth: 80, + visible: false, + formatter: 'formatDateTime', + }, + { + field: 'expiryDate', + title: '到期时间', + minWidth: 80, + formatter: 'formatDateTime', + }, + { + field: 'expiryDateFormat', + title: '距离到期', + minWidth: 80, + formatter: ({ cellValue }) => { + if (!cellValue) return ''; + // const days = dayjs(cellValue).diff(dayjs(), 'day'); + // if (days > 0) { + // return `${days} 天`; + // } + // if (days === 0) { + // return '今天到期'; + // } + return dayjs(cellValue).fromNow(true); + }, + }, + { + field: 'applicationTime', + title: '申请时间', + minWidth: 80, + formatter: 'formatDateTime', + }, + ]; +} + +// ==================== 已过期 ==================== +export function useExpiredGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'customerId', + label: $t('license.customer'), + component: 'ApiSelect', + componentProps: { + api: getCustomerList, + allowClear: true, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.name.toLowerCase().includes(input.toLowerCase()), + }, + }, + { + fieldName: 'projectId', + label: $t('license.project'), + component: 'ApiSelect', + componentProps: { + api: getProjectList, + allowClear: true, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.name.toLowerCase().includes(input.toLowerCase()), + }, + }, + { + fieldName: 'serialNo', + label: 'SN', + component: 'Input', + componentProps: { + allowClear: true, + }, + }, + { + fieldName: 'expiryDate', + label: '到期时间', + component: 'RangePicker', + defaultValue: [dayjs().subtract(7, 'days'), dayjs()], + componentProps: { + ...getRangePickerDefaultProps(), + format: 'YYYY-MM-DD', + showTime: false, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useExpiredGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'customerName', + title: '客户名称', + showOverflow: false, + minWidth: 60, + }, + { + field: 'projectName', + title: '项目名称', + showOverflow: false, + minWidth: 80, + }, + { + field: 'status', + title: $t('project.status'), + minWidth: 40, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.LIC_PROJECT_STATUS }, + }, + }, + { + field: 'serialNo', + title: 'SN', + showOverflow: false, + minWidth: 40, + }, + { + field: 'businessOwnerName', + title: '业务负责人', + minWidth: 40, + }, + { + field: 'technicalOwnerAName', + title: '技术负责人1', + minWidth: 40, + }, + { + field: 'technicalOwnerBName', + title: '技术负责人2', + visible: false, + minWidth: 40, + }, + { + field: 'startTime', + title: '项目开始时间', + minWidth: 80, + visible: false, + formatter: 'formatDateTime', + }, + { + field: 'expiryDate', + title: '到期时间', + minWidth: 80, + formatter: 'formatDateTime', + }, + { + field: 'expiryDateFormat', + title: '已到期', + minWidth: 80, + formatter: ({ cellValue }) => { + if (!cellValue) return ''; + // const days = dayjs(cellValue).diff(dayjs(), 'day'); + // if (days > 0) { + // return `${days} 天`; + // } + // if (days === 0) { + // return '今天到期'; + // } + return dayjs(cellValue).fromNow(true); + }, + }, + { + field: 'applicationTime', + title: '申请时间', + minWidth: 80, + formatter: 'formatDateTime', + }, + ]; +} diff --git a/apps/web-antd/src/views/report/expire/index.vue b/apps/web-antd/src/views/report/expire/index.vue new file mode 100644 index 0000000..7ba60cd --- /dev/null +++ b/apps/web-antd/src/views/report/expire/index.vue @@ -0,0 +1,30 @@ + + + diff --git a/apps/web-antd/src/views/report/expire/modules/expired.vue b/apps/web-antd/src/views/report/expire/modules/expired.vue new file mode 100644 index 0000000..5c77f8b --- /dev/null +++ b/apps/web-antd/src/views/report/expire/modules/expired.vue @@ -0,0 +1,60 @@ + + + diff --git a/apps/web-antd/src/views/report/expire/modules/expiring.vue b/apps/web-antd/src/views/report/expire/modules/expiring.vue new file mode 100644 index 0000000..c849742 --- /dev/null +++ b/apps/web-antd/src/views/report/expire/modules/expiring.vue @@ -0,0 +1,60 @@ + + +