feat: 恢复license可选

This commit is contained in:
caiyuchao
2025-08-27 16:16:06 +08:00
parent 95b5e07a78
commit 19c0278ad3
4 changed files with 20 additions and 25 deletions

View File

@@ -35,7 +35,7 @@ async function initSetupVbenForm() {
}, },
// 选择项目必填国际化适配 // 选择项目必填国际化适配
selectRequired: (value, _params, ctx) => { selectRequired: (value, _params, ctx) => {
if (value === undefined || value === null) { if (value === undefined || value === null || value.length === 0) {
return $t('ui.formRules.selectRequired', [ctx.label]); return $t('ui.formRules.selectRequired', [ctx.label]);
} }
return true; return true;

View File

@@ -90,7 +90,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'type', fieldName: 'type',
label: $t('customer.customerType'), label: $t('customer.customerType'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_CUSTOMER_TYPE, 'number'), options: getDictOptions(DICT_TYPE.LIC_CUSTOMER_TYPE, 'number'),
@@ -109,7 +109,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'areaIds', fieldName: 'areaIds',
label: $t('customer.area'), label: $t('customer.area'),
rules: 'required', rules: 'selectRequired',
component: 'ApiCascader', component: 'ApiCascader',
componentProps: { componentProps: {
api: getAreaTree, api: getAreaTree,

View File

@@ -12,10 +12,7 @@ import { formatDate, formatDateTime } from '@vben/utils';
import dayjs, { Dayjs } from 'dayjs'; import dayjs, { Dayjs } from 'dayjs';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
import { import { getCustomerList } from '#/api/license/customer';
getCustomerList,
getLicenseCustomerList,
} from '#/api/license/customer';
import { isLicenseSnUnique } from '#/api/license/license'; import { isLicenseSnUnique } from '#/api/license/license';
import { getLicenseProjectList, getProjectList } from '#/api/license/project'; import { getLicenseProjectList, getProjectList } from '#/api/license/project';
import { getLicenseAdminList, getSimpleUserList } from '#/api/system/user'; import { getLicenseAdminList, getSimpleUserList } from '#/api/system/user';
@@ -41,15 +38,13 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'customerId', fieldName: 'customerId',
label: $t('license.customer'), label: $t('license.customer'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
dependencies: { dependencies: {
triggerFields: ['id'], triggerFields: ['id'],
disabled: (values) => !!values.id, disabled: (values) => !!values.id,
componentProps: async (values) => { componentProps: async () => {
customerList.value = await (values.id customerList.value = await getCustomerList();
? getCustomerList()
: getLicenseCustomerList());
return { return {
options: customerList, options: customerList,
@@ -68,7 +63,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'projectId', fieldName: 'projectId',
label: $t('license.project'), label: $t('license.project'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: projectList, options: projectList,
@@ -93,7 +88,7 @@ export function useFormSchema(): VbenFormSchema[] {
return project.id === values.projectId; return project.id === values.projectId;
}); });
if (!hasProject) { if (!hasProject) {
values.projectId = ''; values.projectId = undefined;
} }
} }
@@ -143,7 +138,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'expiryDate', fieldName: 'expiryDate',
label: $t('license.expiryDate'), label: $t('license.expiryDate'),
rules: 'required', rules: 'selectRequired',
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
// showTime: true, // showTime: true,
@@ -168,7 +163,7 @@ export function useFormSchema(): VbenFormSchema[] {
fieldName: 'approver', fieldName: 'approver',
label: $t('license.approver'), label: $t('license.approver'),
component: 'ApiSelect', component: 'ApiSelect',
rules: 'required', rules: 'selectRequired',
help: $t('license.licenseAdminHelp'), help: $t('license.licenseAdminHelp'),
componentProps: { componentProps: {
allowClear: true, allowClear: true,

View File

@@ -89,7 +89,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'customerId', fieldName: 'customerId',
label: $t('project.belongCustomer'), label: $t('project.belongCustomer'),
rules: 'required', rules: 'selectRequired',
component: 'ApiSelect', component: 'ApiSelect',
componentProps: { componentProps: {
api: async () => { api: async () => {
@@ -118,7 +118,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'businessStatus', fieldName: 'businessStatus',
label: $t('project.businessStatus'), label: $t('project.businessStatus'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_BUSINESS_STATUS, 'number'), options: getDictOptions(DICT_TYPE.LIC_BUSINESS_STATUS, 'number'),
@@ -127,7 +127,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'status', fieldName: 'status',
label: $t('project.status'), label: $t('project.status'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_PROJECT_STATUS, 'number'), options: getDictOptions(DICT_TYPE.LIC_PROJECT_STATUS, 'number'),
@@ -136,7 +136,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'businessOwner', fieldName: 'businessOwner',
label: $t('project.businessOwner'), label: $t('project.businessOwner'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: userList, options: userList,
@@ -157,7 +157,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'technicalOwnerA', fieldName: 'technicalOwnerA',
label: $t('project.technicalOwnerA'), label: $t('project.technicalOwnerA'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: userList, options: userList,
@@ -201,7 +201,7 @@ export function useFormSchema(): VbenFormSchema[] {
fieldName: 'startTime', fieldName: 'startTime',
label: $t('project.startTime'), label: $t('project.startTime'),
component: 'DatePicker', component: 'DatePicker',
rules: 'required', rules: 'selectRequired',
componentProps: { componentProps: {
format: 'YYYY-MM-DD', format: 'YYYY-MM-DD',
valueFormat: 'x', valueFormat: 'x',
@@ -219,7 +219,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'envInfo', fieldName: 'envInfo',
label: $t('project.envInfo'), label: $t('project.envInfo'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_ENV_INFO, 'number'), options: getDictOptions(DICT_TYPE.LIC_ENV_INFO, 'number'),
@@ -228,7 +228,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'operatingSystem', fieldName: 'operatingSystem',
label: $t('project.operatingSystem'), label: $t('project.operatingSystem'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_OPERATING_SYSTEM, 'number'), options: getDictOptions(DICT_TYPE.LIC_OPERATING_SYSTEM, 'number'),
@@ -237,7 +237,7 @@ export function useFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'softwareVersion', fieldName: 'softwareVersion',
label: $t('project.softwareVersion'), label: $t('project.softwareVersion'),
rules: 'required', rules: 'selectRequired',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.LIC_SOFTWARE_VERSION, 'number'), options: getDictOptions(DICT_TYPE.LIC_SOFTWARE_VERSION, 'number'),