wujingjing
2024-04-22 f106e4dffb8279cb90726e83e7edd631f4c77699
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { FormItemRule } from 'element-plus';
import { Arrayable, buildProps } from 'element-plus/es/utils';
import { PropType } from 'vue';
 
export type FormItemConfig = {
    /** @description 表单标签名 */
    label: string;
    /** @description 表单内提示词 */
    placeholder?: string;
    /** @description 该表单项需要校验时起作用 */
    prop: string;
    /** @description 表单标签长度 */
    labelWidth?: string;
    /** @description 表单长度 */
    width?: string;
    /** @description 是否可手动清空值 */
    clearable?: boolean;
    /** @description 表单类型 */
    type?: 'string' | 'number' | 'date' | 'selectable' | 'selectOption' | 'tree-select';
};
 
export const YWFormProps = buildProps({
    /** @description 表单值 */
    model: {
        type: Object as PropType<Record<string, any>>,
        default: {},
    },
    /** @description 表单项配置 */
    formItems: {
        type: Array<FormItemConfig>,
        default: [],
    },
    /** @description 表单校验规则 */
    rules: {
        type: Object as PropType<Partial<Record<string, Arrayable<FormItemRule>>>>,
        default: {},
    },
    /** @description 控制所有表单项标签长度 */
    labelWidth: {
        type: String,
    },
    /** @description 是否行内显示(一行显示)表单项 */
    inline: {
        type: Boolean,
        default: false,
    },
} as const);