feat: license模块调整

This commit is contained in:
caiyuchao
2025-07-02 16:20:56 +08:00
parent 01bada138c
commit 7d46e24db7
6 changed files with 137 additions and 82 deletions

View File

@@ -26,7 +26,7 @@ export function getCustomerPage(params: PageParam) {
); );
} }
/** 查询客户分页 */ /** 查询客户列表 */
export function getCustomerList() { export function getCustomerList() {
return requestClient.get<CustomerApi.Customer[]>('/license/customer/list'); return requestClient.get<CustomerApi.Customer[]>('/license/customer/list');
} }

View File

@@ -8,7 +8,7 @@ export namespace ProjectApi {
/** 项目信息 */ /** 项目信息 */
export interface Project { export interface Project {
id: number; // 主键 id: number; // 主键
projectId?: number; // 项目ID customerId?: number; // 客户ID
name?: string; // 项目名称 name?: string; // 项目名称
code?: string; // 项目编号 code?: string; // 项目编号
contractCode?: string; // 合同编号 contractCode?: string; // 合同编号
@@ -35,6 +35,13 @@ export function getProjectPage(params: PageParam) {
); );
} }
/** 查询项目列表 */
export function getProjectList(params: any) {
return requestClient.get<ProjectApi.Project[]>('/license/project/list', {
params,
});
}
/** 查询项目详情 */ /** 查询项目详情 */
export function getProject(id: number) { export function getProject(id: number) {
return requestClient.get<ProjectApi.Project>(`/license/project/get?id=${id}`); return requestClient.get<ProjectApi.Project>(`/license/project/get?id=${id}`);

View File

@@ -0,0 +1,17 @@
{
"customer": "Customer",
"project": "Project",
"expirationTime": "Expiration Time",
"neSwitch": "NE Switch",
"userNum": "User Count",
"baseStationNum": "Base Station Count",
"activationCode": "Activation Code",
"licenseContent": "License Content",
"applicant": "Applicant",
"approver": "License Administrator",
"status": "Status",
"remark": "Remark",
"creationTime": "Creation Time",
"operation": "Operation",
"list": "License List"
}

View File

@@ -0,0 +1,17 @@
{
"customer": "客户",
"project": "项目",
"expirationTime": "有效期",
"neSwitch": "网元开关",
"userNum": "用户数",
"baseStationNum": "基站数",
"activationCode": "激活码",
"licenseContent": "License内容",
"applicant": "申请人",
"approver": "License管理员",
"status": "状态",
"remark": "备注",
"creationTime": "创建时间",
"operation": "操作",
"list": "License列表"
}

View File

@@ -4,9 +4,14 @@ import type { LicenseApi } from '#/api/license/license';
import { useAccess } from '@vben/access'; import { useAccess } from '@vben/access';
import { getCustomerList } from '#/api/license/customer';
import { getProjectList } from '#/api/license/project';
import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
const { hasAccessByCodes } = useAccess(); const { hasAccessByCodes } = useAccess();
let projectList = await getProjectList({});
const customerList = await getCustomerList();
/** 新增/修改的表单 */ /** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] { export function useFormSchema(): VbenFormSchema[] {
@@ -21,34 +26,71 @@ export function useFormSchema(): VbenFormSchema[] {
}, },
{ {
fieldName: 'customerId', fieldName: 'customerId',
label: '客户ID', label: $t('license.customer'),
rules: 'required', rules: 'required',
component: 'Input', component: 'Select',
componentProps: { componentProps: {
placeholder: '请输入客户ID', options: customerList,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.label.toLowerCase().includes(input.toLowerCase()),
}, },
}, },
{ {
fieldName: 'projectId', fieldName: 'projectId',
label: '项目ID', label: $t('license.project'),
rules: 'required', rules: 'required',
component: 'Input', component: 'Select',
componentProps: { componentProps: {
placeholder: '请输入项目ID', options: projectList,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.label.toLowerCase().includes(input.toLowerCase()),
},
dependencies: {
componentProps: async (values) => {
projectList = await getProjectList({
customerId: values.customerId,
});
const hasProject = projectList.find((project) => {
return project.id === values.projectId;
});
if (!hasProject) {
values.projectId = '';
}
return {
options: projectList,
};
},
triggerFields: ['customerId'],
}, },
}, },
{ {
fieldName: 'sn', fieldName: 'sn',
label: 'sn', label: 'sn',
rules: 'required',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入sn', disabled: true,
},
dependencies: {
trigger(values, form) {
const projectCode = projectList.find((project) => {
return project.id === values.projectId;
})?.code;
const customerCode = customerList.find((customer) => {
return customer.id === values.customerId;
})?.code;
form.setFieldValue('sn', `${customerCode || ''}${projectCode || ''}`);
},
// 只有指定的字段改变时,才会触发
triggerFields: ['customerId', 'projectId'],
}, },
}, },
{ {
fieldName: 'expirationTime', fieldName: 'expirationTime',
label: '到期时间', label: $t('license.expirationTime'),
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
showTime: true, showTime: true,
@@ -58,65 +100,51 @@ export function useFormSchema(): VbenFormSchema[] {
}, },
{ {
fieldName: 'neSwitch', fieldName: 'neSwitch',
label: '网元开关', label: $t('license.neSwitch'),
component: 'CheckboxGroup', component: 'CheckboxGroup',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'string'), options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'number'),
}, },
}, },
{ {
fieldName: 'userNum', fieldName: 'userNum',
label: '用户数', label: $t('license.userNum'),
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入用户数',
},
}, },
{ {
fieldName: 'baseStationNum', fieldName: 'baseStationNum',
label: '基站数', label: $t('license.baseStationNum'),
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入基站数',
},
}, },
{ {
fieldName: 'activationCode', fieldName: 'activationCode',
label: '激活码', label: $t('license.activationCode'),
component: 'Textarea', component: 'Textarea',
componentProps: {
placeholder: '请输入激活码',
},
}, },
{ {
fieldName: 'licenseContent', fieldName: 'licenseContent',
label: 'License内容', label: $t('license.licenseContent'),
component: 'Textarea', component: 'Textarea',
componentProps: {
placeholder: '请输入License内容',
},
}, },
{ {
fieldName: 'applicant', fieldName: 'applicant',
label: '申请人', label: $t('license.applicant'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: [], options: [],
placeholder: '请选择申请人',
}, },
}, },
{ {
fieldName: 'approver', fieldName: 'approver',
label: '审批人', label: $t('license.approver'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: [], options: [],
placeholder: '请选择审批人',
}, },
}, },
{ {
fieldName: 'status', fieldName: 'status',
label: '状态', label: $t('license.status'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'), options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
@@ -126,11 +154,8 @@ export function useFormSchema(): VbenFormSchema[] {
}, },
{ {
fieldName: 'remark', fieldName: 'remark',
label: '备注', label: $t('license.remark'),
component: 'Textarea', component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
},
}, },
]; ];
} }
@@ -140,20 +165,18 @@ export function useGridFormSchema(): VbenFormSchema[] {
return [ return [
{ {
fieldName: 'customerId', fieldName: 'customerId',
label: '客户ID', label: $t('license.customer'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入客户ID',
}, },
}, },
{ {
fieldName: 'projectId', fieldName: 'projectId',
label: '项目ID', label: $t('license.project'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入项目ID',
}, },
}, },
{ {
@@ -162,100 +185,91 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入sn',
}, },
}, },
{ {
fieldName: 'expirationTime', fieldName: 'expirationTime',
label: '到期时间', label: $t('license.expirationTime'),
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
allowClear: true, allowClear: true,
}, },
}, },
{ // {
fieldName: 'neSwitch', // fieldName: 'neSwitch',
label: '网元开关', // label: $t('license.neSwitch'),
}, // },
{ {
fieldName: 'userNum', fieldName: 'userNum',
label: '用户数', label: $t('license.userNum'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入用户数',
}, },
}, },
{ {
fieldName: 'baseStationNum', fieldName: 'baseStationNum',
label: '基站数', label: $t('license.baseStationNum'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入基站数',
}, },
}, },
{ {
fieldName: 'activationCode', fieldName: 'activationCode',
label: '激活码', label: $t('license.activationCode'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入激活码',
}, },
}, },
{ {
fieldName: 'licenseContent', fieldName: 'licenseContent',
label: 'License内容', label: $t('license.licenseContent'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入License内容',
}, },
}, },
{ {
fieldName: 'applicant', fieldName: 'applicant',
label: '申请人', label: $t('license.applicant'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
options: [], options: [],
placeholder: '请选择申请人',
}, },
}, },
{ {
fieldName: 'approver', fieldName: 'approver',
label: '审批人', label: $t('license.approver'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
options: [], options: [],
placeholder: '请选择审批人',
}, },
}, },
{ {
fieldName: 'status', fieldName: 'status',
label: '状态', label: $t('license.status'),
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'), options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
placeholder: '请选择状态',
}, },
}, },
{ {
fieldName: 'remark', fieldName: 'remark',
label: '备注', label: $t('license.remark'),
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请输入备注',
}, },
}, },
{ {
fieldName: 'createTime', fieldName: 'createTime',
label: '创建时间', label: $t('license.creationTime'),
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
@@ -271,13 +285,13 @@ export function useGridColumns(
): VxeTableGridOptions<LicenseApi.License>['columns'] { ): VxeTableGridOptions<LicenseApi.License>['columns'] {
return [ return [
{ {
field: 'customerId', field: 'customerName',
title: '客户ID', title: $t('license.customer'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'projectId', field: 'projectName',
title: '项目ID', title: $t('license.project'),
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -287,13 +301,13 @@ export function useGridColumns(
}, },
{ {
field: 'expirationTime', field: 'expirationTime',
title: '到期时间', title: $t('license.expirationTime'),
minWidth: 120, minWidth: 120,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'neSwitch', field: 'neSwitch',
title: '网元开关', title: $t('license.neSwitch'),
minWidth: 120, minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
@@ -302,37 +316,37 @@ export function useGridColumns(
}, },
{ {
field: 'userNum', field: 'userNum',
title: '用户数', title: $t('license.userNum'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'baseStationNum', field: 'baseStationNum',
title: '基站数', title: $t('license.baseStationNum'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'activationCode', field: 'activationCode',
title: '激活码', title: $t('license.activationCode'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'licenseContent', field: 'licenseContent',
title: 'License内容', title: $t('license.licenseContent'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'applicant', field: 'applicant',
title: '申请人', title: $t('license.applicant'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'approver', field: 'approver',
title: '审批人', title: $t('license.approver'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'status', field: 'status',
title: '状态', title: $t('license.status'),
minWidth: 120, minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
@@ -341,18 +355,18 @@ export function useGridColumns(
}, },
{ {
field: 'remark', field: 'remark',
title: '备注', title: $t('license.remark'),
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'createTime', field: 'createTime',
title: '创建时间', title: $t('license.creationTime'),
minWidth: 120, minWidth: 120,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
field: 'operation', field: 'operation',
title: '操作', title: $t('license.operation'),
minWidth: 200, minWidth: 200,
align: 'center', align: 'center',
fixed: 'right', fixed: 'right',

View File

@@ -117,7 +117,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<Page auto-content-height> <Page auto-content-height>
<FormModal @success="onRefresh" /> <FormModal @success="onRefresh" />
<Grid table-title="License列表"> <Grid :table-title="$t('license.list')">
<template #toolbar-tools> <template #toolbar-tools>
<Button <Button
:icon="h(Plus)" :icon="h(Plus)"