package com.mortals.xhx.common.pdu.gen.component;

import com.mortals.xhx.common.code.ComponentEnum;
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 TextAreaComponent extends Component {

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

    @Override
    public FieldsItem buildDefaultComponent(ComponentCons cons) {
        FieldsItem fieldsItem = new FieldsItem();
        Config config = new Config();
        config.setLabel("多行文本");
        config.setLabelWidth("");
        config.setShowLabel(true);
        config.setChangeTag(true);
        config.setTag("el-input");
        config.setTagIcon("textarea");
        config.setRequired(true);
        config.setLayout("colFormItem");
        config.setDocument("https://element.eleme.cn/#/zh-CN/component/input");
        config.setRegList(new ArrayList<>());
        config.setSpan(24);
        fieldsItem.setConfig(config);
        fieldsItem.setType("textarea");
        Autosize autosize = new Autosize();
        autosize.setMinRows(2);
        autosize.setMaxRows(4);
        fieldsItem.setAutosize(autosize);

        Style style = new Style();
        style.setWidth("100%");
        fieldsItem.setStyle(style);
        fieldsItem.setClearable(true);

        fieldsItem.setMaxlength(null);
        fieldsItem.setReadonly(false);
        fieldsItem.setDisabled(false);
        fieldsItem.setVModel("textarea");

        return fieldsItem;
    }

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