feat: license模块调整
This commit is contained in:
@@ -4,9 +4,14 @@ import type { LicenseApi } from '#/api/license/license';
|
||||
|
||||
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';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
let projectList = await getProjectList({});
|
||||
const customerList = await getCustomerList();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -21,34 +26,71 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户ID',
|
||||
label: $t('license.customer'),
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
component: 'Select',
|
||||
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',
|
||||
label: '项目ID',
|
||||
label: $t('license.project'),
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
component: 'Select',
|
||||
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',
|
||||
label: 'sn',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
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',
|
||||
label: '到期时间',
|
||||
label: $t('license.expirationTime'),
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
@@ -58,65 +100,51 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
{
|
||||
fieldName: 'neSwitch',
|
||||
label: '网元开关',
|
||||
label: $t('license.neSwitch'),
|
||||
component: 'CheckboxGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'string'),
|
||||
options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'number'),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'userNum',
|
||||
label: '用户数',
|
||||
label: $t('license.userNum'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入用户数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'baseStationNum',
|
||||
label: '基站数',
|
||||
label: $t('license.baseStationNum'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入基站数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'activationCode',
|
||||
label: '激活码',
|
||||
label: $t('license.activationCode'),
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入激活码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'licenseContent',
|
||||
label: 'License内容',
|
||||
label: $t('license.licenseContent'),
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入License内容',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'applicant',
|
||||
label: '申请人',
|
||||
label: $t('license.applicant'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择申请人',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'approver',
|
||||
label: '审批人',
|
||||
label: $t('license.approver'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择审批人',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
label: $t('license.status'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
|
||||
@@ -126,11 +154,8 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
label: $t('license.remark'),
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -140,20 +165,18 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户ID',
|
||||
label: $t('license.customer'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户ID',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'projectId',
|
||||
label: '项目ID',
|
||||
label: $t('license.project'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入项目ID',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -162,100 +185,91 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入sn',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'expirationTime',
|
||||
label: '到期时间',
|
||||
label: $t('license.expirationTime'),
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'neSwitch',
|
||||
label: '网元开关',
|
||||
},
|
||||
// {
|
||||
// fieldName: 'neSwitch',
|
||||
// label: $t('license.neSwitch'),
|
||||
// },
|
||||
{
|
||||
fieldName: 'userNum',
|
||||
label: '用户数',
|
||||
label: $t('license.userNum'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入用户数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'baseStationNum',
|
||||
label: '基站数',
|
||||
label: $t('license.baseStationNum'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入基站数',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'activationCode',
|
||||
label: '激活码',
|
||||
label: $t('license.activationCode'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入激活码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'licenseContent',
|
||||
label: 'License内容',
|
||||
label: $t('license.licenseContent'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入License内容',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'applicant',
|
||||
label: '申请人',
|
||||
label: $t('license.applicant'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择申请人',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'approver',
|
||||
label: '审批人',
|
||||
label: $t('license.approver'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择审批人',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
label: $t('license.status'),
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
label: $t('license.remark'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
label: $t('license.creationTime'),
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
@@ -271,13 +285,13 @@ export function useGridColumns(
|
||||
): VxeTableGridOptions<LicenseApi.License>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'customerId',
|
||||
title: '客户ID',
|
||||
field: 'customerName',
|
||||
title: $t('license.customer'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'projectId',
|
||||
title: '项目ID',
|
||||
field: 'projectName',
|
||||
title: $t('license.project'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
@@ -287,13 +301,13 @@ export function useGridColumns(
|
||||
},
|
||||
{
|
||||
field: 'expirationTime',
|
||||
title: '到期时间',
|
||||
title: $t('license.expirationTime'),
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'neSwitch',
|
||||
title: '网元开关',
|
||||
title: $t('license.neSwitch'),
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
@@ -302,37 +316,37 @@ export function useGridColumns(
|
||||
},
|
||||
{
|
||||
field: 'userNum',
|
||||
title: '用户数',
|
||||
title: $t('license.userNum'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'baseStationNum',
|
||||
title: '基站数',
|
||||
title: $t('license.baseStationNum'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'activationCode',
|
||||
title: '激活码',
|
||||
title: $t('license.activationCode'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'licenseContent',
|
||||
title: 'License内容',
|
||||
title: $t('license.licenseContent'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'applicant',
|
||||
title: '申请人',
|
||||
title: $t('license.applicant'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'approver',
|
||||
title: '审批人',
|
||||
title: $t('license.approver'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
title: $t('license.status'),
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
@@ -341,18 +355,18 @@ export function useGridColumns(
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
title: $t('license.remark'),
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
title: $t('license.creationTime'),
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'operation',
|
||||
title: '操作',
|
||||
title: $t('license.operation'),
|
||||
minWidth: 200,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
|
||||
@@ -117,7 +117,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
|
||||
<Grid table-title="License列表">
|
||||
<Grid :table-title="$t('license.list')">
|
||||
<template #toolbar-tools>
|
||||
<Button
|
||||
:icon="h(Plus)"
|
||||
|
||||
Reference in New Issue
Block a user