From 19c0278ad3658c9c78e1d60926e9173acb6bcd4d Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Wed, 27 Aug 2025 16:16:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=81=A2=E5=A4=8Dlicense=E5=8F=AF?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/adapter/form.ts | 2 +- .../src/views/license/customer/data.ts | 4 ++-- .../src/views/license/license/data.ts | 21 +++++++------------ .../src/views/license/project/data.ts | 18 ++++++++-------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/apps/web-antd/src/adapter/form.ts b/apps/web-antd/src/adapter/form.ts index 93428ba..157b890 100644 --- a/apps/web-antd/src/adapter/form.ts +++ b/apps/web-antd/src/adapter/form.ts @@ -35,7 +35,7 @@ async function initSetupVbenForm() { }, // 选择项目必填国际化适配 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 true; diff --git a/apps/web-antd/src/views/license/customer/data.ts b/apps/web-antd/src/views/license/customer/data.ts index e91daad..b583095 100644 --- a/apps/web-antd/src/views/license/customer/data.ts +++ b/apps/web-antd/src/views/license/customer/data.ts @@ -90,7 +90,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'type', label: $t('customer.customerType'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_CUSTOMER_TYPE, 'number'), @@ -109,7 +109,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'areaIds', label: $t('customer.area'), - rules: 'required', + rules: 'selectRequired', component: 'ApiCascader', componentProps: { api: getAreaTree, diff --git a/apps/web-antd/src/views/license/license/data.ts b/apps/web-antd/src/views/license/license/data.ts index ff5fd79..7ec9854 100644 --- a/apps/web-antd/src/views/license/license/data.ts +++ b/apps/web-antd/src/views/license/license/data.ts @@ -12,10 +12,7 @@ import { formatDate, formatDateTime } from '@vben/utils'; import dayjs, { Dayjs } from 'dayjs'; import { z } from '#/adapter/form'; -import { - getCustomerList, - getLicenseCustomerList, -} from '#/api/license/customer'; +import { getCustomerList } from '#/api/license/customer'; import { isLicenseSnUnique } from '#/api/license/license'; import { getLicenseProjectList, getProjectList } from '#/api/license/project'; import { getLicenseAdminList, getSimpleUserList } from '#/api/system/user'; @@ -41,15 +38,13 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'customerId', label: $t('license.customer'), - rules: 'required', + rules: 'selectRequired', component: 'Select', dependencies: { triggerFields: ['id'], disabled: (values) => !!values.id, - componentProps: async (values) => { - customerList.value = await (values.id - ? getCustomerList() - : getLicenseCustomerList()); + componentProps: async () => { + customerList.value = await getCustomerList(); return { options: customerList, @@ -68,7 +63,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'projectId', label: $t('license.project'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: projectList, @@ -93,7 +88,7 @@ export function useFormSchema(): VbenFormSchema[] { return project.id === values.projectId; }); if (!hasProject) { - values.projectId = ''; + values.projectId = undefined; } } @@ -143,7 +138,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'expiryDate', label: $t('license.expiryDate'), - rules: 'required', + rules: 'selectRequired', component: 'DatePicker', componentProps: { // showTime: true, @@ -168,7 +163,7 @@ export function useFormSchema(): VbenFormSchema[] { fieldName: 'approver', label: $t('license.approver'), component: 'ApiSelect', - rules: 'required', + rules: 'selectRequired', help: $t('license.licenseAdminHelp'), componentProps: { allowClear: true, diff --git a/apps/web-antd/src/views/license/project/data.ts b/apps/web-antd/src/views/license/project/data.ts index bc4a205..1b5751b 100644 --- a/apps/web-antd/src/views/license/project/data.ts +++ b/apps/web-antd/src/views/license/project/data.ts @@ -89,7 +89,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'customerId', label: $t('project.belongCustomer'), - rules: 'required', + rules: 'selectRequired', component: 'ApiSelect', componentProps: { api: async () => { @@ -118,7 +118,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'businessStatus', label: $t('project.businessStatus'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_BUSINESS_STATUS, 'number'), @@ -127,7 +127,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'status', label: $t('project.status'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_PROJECT_STATUS, 'number'), @@ -136,7 +136,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'businessOwner', label: $t('project.businessOwner'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: userList, @@ -157,7 +157,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'technicalOwnerA', label: $t('project.technicalOwnerA'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: userList, @@ -201,7 +201,7 @@ export function useFormSchema(): VbenFormSchema[] { fieldName: 'startTime', label: $t('project.startTime'), component: 'DatePicker', - rules: 'required', + rules: 'selectRequired', componentProps: { format: 'YYYY-MM-DD', valueFormat: 'x', @@ -219,7 +219,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'envInfo', label: $t('project.envInfo'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_ENV_INFO, 'number'), @@ -228,7 +228,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'operatingSystem', label: $t('project.operatingSystem'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_OPERATING_SYSTEM, 'number'), @@ -237,7 +237,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'softwareVersion', label: $t('project.softwareVersion'), - rules: 'required', + rules: 'selectRequired', component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_SOFTWARE_VERSION, 'number'),