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

import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.pdu.gen.*;

import java.util.ArrayList;

/**
 * 按钮组件
 *
 * @author: zxfei
 * @date: 2021/10/26 10:35
 * @description:
 **/
public class ButtonComponent extends Component {

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

    @Override
    public FieldsItem buildDefaultComponent(ComponentCons cons) {
        //创建按钮事件
        FieldsItem fieldsItem = new FieldsItem();
        Config config = new Config();
        config.setLabel("按钮");
        config.setTag("el-button");
        config.setTagIcon("button");
        config.setLabelWidth("");
        config.setShowLabel(true);
        config.setChangeTag(true);
        config.setTag("el-button");
        config.setRequired(false);
        config.setLayout("colFormItem");
        config.setDocument("https://element.eleme.cn/#/zh-CN/component/button");
        config.setSpan(12);
        fieldsItem.setConfig(config);

        Slot slot = new Slot();
        slot.setJsonMemberDefault("主要按钮");
        fieldsItem.setSlot(slot);

        fieldsItem.setSize("small");
        fieldsItem.setType("primary");

        fieldsItem.setIcon("el-icon-search");
        fieldsItem.setRound(false);
        fieldsItem.setPlain(false);
        fieldsItem.setCircle(false);
        fieldsItem.setDisabled(false);
        fieldsItem.setVModel("button");

        On on = new On();
        on.setClick("clickButton"+cons.getVal());

        fieldsItem.setOn(on);
        return fieldsItem;
    }

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