提交 | 用户 | age
|
4ff1c4
|
1 |
import type { ValidationRule } from 'ant-design-vue/lib/form/Form'; |
84c9d7
|
2 |
import type { ComponentType } from './types/index'; |
dc09de
|
3 |
import { useI18n } from '/@/hooks/web/useI18n'; |
V |
4 |
|
962f90
|
5 |
const { t } = useI18n(); |
84c9d7
|
6 |
|
2f6253
|
7 |
/** |
陈 |
8 |
* @description: 生成placeholder |
|
9 |
*/ |
|
10 |
export function createPlaceholderMessage(component: ComponentType) { |
|
11 |
if (component.includes('Input') || component.includes('Complete')) { |
962f90
|
12 |
return t('component.form.input'); |
2f6253
|
13 |
} |
0b6110
|
14 |
if (component.includes('Picker')) { |
962f90
|
15 |
return t('component.form.choose'); |
2f6253
|
16 |
} |
陈 |
17 |
if ( |
|
18 |
component.includes('Select') || |
|
19 |
component.includes('Cascader') || |
|
20 |
component.includes('Checkbox') || |
|
21 |
component.includes('Radio') || |
|
22 |
component.includes('Switch') |
|
23 |
) { |
|
24 |
// return `请选择${label}`; |
962f90
|
25 |
return t('component.form.choose'); |
2f6253
|
26 |
} |
陈 |
27 |
return ''; |
|
28 |
} |
84c9d7
|
29 |
|
2f6253
|
30 |
function genType() { |
陈 |
31 |
return ['DatePicker', 'MonthPicker', 'RangePicker', 'WeekPicker', 'TimePicker']; |
|
32 |
} |
84c9d7
|
33 |
|
4ff1c4
|
34 |
export function setComponentRuleType(rule: ValidationRule, component: ComponentType) { |
V |
35 |
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component)) { |
|
36 |
rule.type = 'object'; |
|
37 |
} else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component)) { |
|
38 |
rule.type = 'array'; |
|
39 |
} else if (['InputNumber'].includes(component)) { |
|
40 |
rule.type = 'number'; |
|
41 |
} |
|
42 |
} |
|
43 |
|
2f6253
|
44 |
/** |
陈 |
45 |
* 时间字段 |
|
46 |
*/ |
|
47 |
export const dateItemType = genType(); |