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

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.Component;
import com.mortals.xhx.common.pdu.gen.Config;
import com.mortals.xhx.common.pdu.gen.FieldsItem;
import com.mortals.xhx.common.pdu.gen.Style;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;

import java.util.ArrayList;

/**
 * 时间组件
 *
 * @author: zxfei
 * @date: 2021/10/26 10:35
 * @description:
 **/
public class DesignDateComponent extends DesignComponent {

    public DesignDateComponent(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("date");
        columnsItem.setEle("el-date-picker");
        columnsItem.setCompName(cons.getLabel());
        columnsItem.setCompIcon("date");
        columnsItem.setViewType("text");
        columnsItem.setConfig(true);
        columnsItem.setShowLabel(true);
        columnsItem.setLabel(cons.getLabel());
        columnsItem.setLabelWidth(120);
        columnsItem.setType("date");
        columnsItem.setPlaceholder("请选择" + cons.getLabel());
        columnsItem.setRequired(false);
        columnsItem.setMaxLength(50);
        columnsItem.setGutter(15);
        columnsItem.setSpan(12);

        columnsItem.setFormat("yyyy 年 MM 月 dd 日");
        columnsItem.setValueFormat("yyyy 年 MM 月 dd 日");
        columnsItem.setLayout("colItem");
        return columnsItem;

    }

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