package com.mortals.xhx.common.formdesign.component;
import com.google.common.collect.Lists;

import cn.hutool.core.util.IdUtil;
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 DesignInputComponent extends DesignComponent {

    public DesignInputComponent(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("input");
        columnsItem.setCompName(cons.getLabel());
        columnsItem.setCompIcon("input");
        columnsItem.setEle("el-input");
        columnsItem.setViewType("text");
        columnsItem.setConfig(true);
        columnsItem.setShowLabel(true);
        columnsItem.setLabel(cons.getLabel());
        columnsItem.setLabelWidth(120);
        columnsItem.setPlaceholder("请输入"+cons.getLabel());
        columnsItem.setRequired(false);
        columnsItem.setMaxLength(50);
        columnsItem.setGutter(15);
        columnsItem.setSpan(12);
        columnsItem.setWidth("100%");
        columnsItem.setClearable(true);
        columnsItem.setDisabled(false);
        columnsItem.setReadonly(false);
        columnsItem.setStatus("normal");
        columnsItem.setPrefixIcon("");
        columnsItem.setValue("");
        columnsItem.setRules(Lists.newArrayList());
        columnsItem.setRulesType("default");
        columnsItem.setAppend("");
        columnsItem.setPrepend("");
        columnsItem.setLayout("colItem");
        return columnsItem;
    }

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