lige
2024-04-18 ed277ece348dae9bc6e36c0fc9f69ae8a3825912
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.ltkj.tduck.vo;
 
 
import cn.hutool.core.collection.CollUtil;
import com.ltkj.tduck.domain.UserFormItemEntity;
import com.ltkj.tduck.utils.FormDataUtils;
import com.ltkj.tduck.utils.HtmlUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
 
import static com.ltkj.tduck.constant.FormConstants.FIELD_SUFFIX_LABEL;
 
 
/**
 * 表单字段类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FormFieldVO {
 
    /**
     * 字段Id
     */
    protected String value;
    /**
     * 字段名称
     */
    protected String label;
    /**
     * 字段类型
     */
    protected String type;
 
    /**
     * 配置
     */
    protected Object scheme;
 
    public FormFieldVO(String value, String label) {
        this.value = value;
        // 清除html里面的标签
        this.label = HtmlUtils.cleanHtmlTag(label);
    }
 
    public FormFieldVO(String value, String label, String type) {
        this.value = value;
        this.label = HtmlUtils.cleanHtmlTag(label);
        this.type = type;
    }
 
    public FormFieldVO(UserFormItemEntity entity) {
        this.label = HtmlUtils.cleanHtmlTag(entity.getLabel());
        this.type = entity.getType().toString();
        this.value = entity.getFormItemId();
        //  选择型组件特殊处理
        if (CollUtil.contains(FormDataUtils.specialFields, entity.getType())) {
            this.value = entity.getFormItemId() + FIELD_SUFFIX_LABEL;
        }
        //获取配置项
        this.scheme = entity.getScheme();
    }
}