diff --git a/apps/web-antd/src/views/license/customer/data.ts b/apps/web-antd/src/views/license/customer/data.ts index 783ed17..ef1ffb3 100644 --- a/apps/web-antd/src/views/license/customer/data.ts +++ b/apps/web-antd/src/views/license/customer/data.ts @@ -57,7 +57,9 @@ export function useFormSchema(): VbenFormSchema[] { label: $t('customer.customerSn'), component: 'InputNumber', rules: z - .number() + .number({ + message: $t('ui.formRules.required', [$t('customer.customerSn')]), + }) .min( 2000, $t('ui.formRules.range', [$t('customer.customerSn'), 2000, 9999]), @@ -77,7 +79,7 @@ export function useFormSchema(): VbenFormSchema[] { ]), }), ) - .nullable() + // .nullable() .refine( (value: null | number) => { return value; diff --git a/apps/web-antd/src/views/license/license/components/detail.vue b/apps/web-antd/src/views/license/license/components/detail.vue index 3ff45f9..cebe56e 100644 --- a/apps/web-antd/src/views/license/license/components/detail.vue +++ b/apps/web-antd/src/views/license/license/components/detail.vue @@ -83,7 +83,7 @@ const columns = [ }, type: 'primary', }, - $t('license.download'), + () => $t('license.download'), ); const file = h( @@ -130,7 +130,7 @@ const columns = [ }, type: 'primary', }, - $t('license.download'), + () => $t('license.download'), ); file1 = h( diff --git a/apps/web-antd/src/views/license/license/data.ts b/apps/web-antd/src/views/license/license/data.ts index 08d978f..97eeef5 100644 --- a/apps/web-antd/src/views/license/license/data.ts +++ b/apps/web-antd/src/views/license/license/data.ts @@ -8,7 +8,9 @@ import type { DescriptionItemSchema } from '#/components/description'; import { h, ref } from 'vue'; import { useAccess } from '@vben/access'; -import { formatDateTime } from '@vben/utils'; +import { formatDate, formatDateTime } from '@vben/utils'; + +import dayjs, { Dayjs } from 'dayjs'; import { z } from '#/adapter/form'; import { getCustomerList } from '#/api/license/customer'; @@ -121,9 +123,22 @@ export function useFormSchema(): VbenFormSchema[] { rules: 'required', component: 'DatePicker', componentProps: { - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', + // showTime: true, + format: 'YYYY-MM-DD', valueFormat: 'x', + disabledDate: (current: Dayjs) => { + // Can not select days before today and today + return current && current < dayjs().startOf('day'); + }, + presets: [ + { label: '七天', value: dayjs().add(+7, 'd') }, + { label: '一个月', value: dayjs().add(+1, 'month') }, + { label: '三个月', value: dayjs().add(+3, 'month') }, + { label: '半年', value: dayjs().add(+6, 'month') }, + { label: '一年', value: dayjs().add(+1, 'year') }, + { label: '三年', value: dayjs().add(+3, 'year') }, + { label: '永久', value: dayjs('2099-12-31') }, + ], }, }, // { @@ -165,8 +180,13 @@ export function useFormSchema(): VbenFormSchema[] { label: $t('license.userNumber'), component: 'InputNumber', componentProps: { - min: 0, + min: 10, }, + rules: z + .number() + .multipleOf(10, '用户数必须是10的倍数') + .nullable() + .optional(), }, { fieldName: 'ranNumber', @@ -305,6 +325,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'RangePicker', componentProps: { ...getRangePickerDefaultProps(), + showTime: false, allowClear: true, }, }, @@ -406,7 +427,7 @@ export function useGridColumns( field: 'expiryDate', title: $t('license.expiryDate'), minWidth: 120, - formatter: 'formatDateTime', + formatter: 'formatDate', }, // { // field: 'neList', @@ -565,7 +586,7 @@ export function useDetailSchema(): DescriptionItemSchema[] { field: 'expiryDate', label: $t('license.expiryDate'), content: (data) => { - return formatDateTime(data?.expiryDate) as string; + return formatDate(data?.expiryDate) as string; }, }, // { diff --git a/apps/web-antd/src/views/license/project/data.ts b/apps/web-antd/src/views/license/project/data.ts index 3d4364d..258a963 100644 --- a/apps/web-antd/src/views/license/project/data.ts +++ b/apps/web-antd/src/views/license/project/data.ts @@ -57,7 +57,7 @@ export function useFormSchema(): VbenFormSchema[] { label: $t('project.code'), component: 'InputNumber', rules: z - .number() + .number({ message: $t('ui.formRules.required', [$t('project.code')]) }) .min(2000, $t('ui.formRules.range', [$t('project.code'), 2000, 9999])) .max(9999, $t('ui.formRules.range', [$t('project.code'), 2000, 9999])) .refine( @@ -71,7 +71,6 @@ export function useFormSchema(): VbenFormSchema[] { ]), }), ) - .nullable() .refine( (value: null | number) => { return value; diff --git a/apps/web-antd/src/views/license/project/modules/form.vue b/apps/web-antd/src/views/license/project/modules/form.vue index e81adb3..371bf9c 100644 --- a/apps/web-antd/src/views/license/project/modules/form.vue +++ b/apps/web-antd/src/views/license/project/modules/form.vue @@ -77,6 +77,8 @@ const [Modal, modalApi] = useVbenModal({ modalApi.unlock(); } } + data.startTime = data.startTime ? data.startTime.toString() : ''; + data.endTime = data.endTime ? data.endTime.toString() : ''; // 设置到 values formData.value = data; await formApi.setValues(formData.value);