This commit is contained in:
dap
2024-09-22 15:48:13 +08:00
73 changed files with 2047 additions and 177 deletions

View File

@@ -34,8 +34,7 @@ import {
} from 'ant-design-vue';
import { isArray } from 'lodash-es';
// 业务表单组件适配
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
export type FormComponentType =
| 'AutoComplete'
| 'Checkbox'
@@ -92,7 +91,10 @@ setupVbenForm<FormComponentType>({
Upload,
},
config: {
// ant design vue组件库默认都是 v-model:value
baseModelPropName: 'value',
// 一些组件是 v-model:checked 或者 v-model:fileList
modelPropNameMap: {
Checkbox: 'checked',
Radio: 'checked',
@@ -101,12 +103,14 @@ setupVbenForm<FormComponentType>({
},
},
defineRules: {
// 输入项目必填国际化适配
required: (value, _params, ctx) => {
if ((!value && value !== 0) || value.length === 0) {
if (value === undefined || value === null || value.length === 0) {
return $t('formRules.required', [ctx.label]);
}
return true;
},
// 选择项目必填国际化适配
selectRequired: (value, _params, ctx) => {
if (
[false, null, undefined].includes(value) ||