package com.mortals.xhx.common.formdesign.component;

import cn.hutool.core.util.IdUtil;
import com.google.common.collect.Lists;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.formdesign.ColumnsItem;
import com.mortals.xhx.common.formdesign.DesignComponent;
import com.mortals.xhx.common.formdesign.ListItem;
import com.mortals.xhx.common.pdu.gen.*;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;

import java.util.ArrayList;

/**
 * 文本域组件
 *
 * @author: zxfei
 * @date: 2021/10/26 10:35
 * @description:
 **/
public class DesignTextAreaComponent extends DesignComponent {

    public DesignTextAreaComponent(String type) {
        super(type);
    }

    @Override
    public ListItem buildDefaultComponent(ComponentCons cons) {
        ListItem columnsItem = new ListItem();
        columnsItem.setId(cons.getVal());
        columnsItem.set_id(cons.getVal());
        columnsItem.setCompType("textarea");
        columnsItem.setEle("el-input");
        columnsItem.setCompName("多行文本");
        columnsItem.setCompIcon("textarea");
        columnsItem.setViewType("text");
        columnsItem.setType("textarea");
        columnsItem.setConfig(true);
        columnsItem.setShowLabel(true);
        columnsItem.setLabel(cons.getLabel());
        columnsItem.setLabelWidth(120);
        columnsItem.setPlaceholder("请输入" + cons.getLabel());
        columnsItem.setRequired(false);
        columnsItem.setMaxLength(200);
        columnsItem.setShowWordLimit(true);
        columnsItem.setGutter(15);
        columnsItem.setSpan(24);
        columnsItem.setClearable(true);
        columnsItem.setDisabled(false);
        columnsItem.setReadonly(false);
        columnsItem.setRows(4);
        columnsItem.setStatus("normal");
         //设置默认值
        columnsItem.setRules(Lists.newArrayList());
        columnsItem.setRuleError("该字段不能为空");
        columnsItem.setRulesType("default");
        columnsItem.setLayout("colItem");
        return columnsItem;
    }

    @Override
    public String getType() {
        return ComponentEnum.TEXTAREA.getValue();
    }
}
