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 ImageComponent extends Component {

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

    @Override
    public FieldsItem buildDefaultComponent(ComponentCons cons) {
        //图片选择
        FieldsItem fieldsItem = new FieldsItem();
        Config config = new Config();
        config.setLabel("日期选择");
        config.setTag("el-upload");
        config.setTagIcon("upload");
        config.setButtonText("点击上传");
        config.setFileSize(2);
        config.setSizeUnit("MB");
        config.setLabelWidth("");
        config.setShowLabel(true);
        config.setChangeTag(true);
        config.setTag("el-upload");
        config.setRequired(false);
        config.setLayout("colFormItem");
        config.setDocument("https://element.eleme.cn/#/zh-CN/component/upload");
        config.setRegList(new ArrayList<>());
        config.setSpan(12);
        fieldsItem.setConfig(config);

        Slot slot = new Slot();
        slot.setListType(true);

        fieldsItem.setSlot(slot);
        fieldsItem.setAction("/m/file/commonupload?prePath=preview");
        fieldsItem.setAccept("image/*");
        fieldsItem.setName("file");
        fieldsItem.setAutoUpload(true);
        fieldsItem.setListType("picture-card");
        fieldsItem.setMultiple(false);
        fieldsItem.setClearable(true);

        fieldsItem.setReadonly(false);
        fieldsItem.setDisabled(false);
        fieldsItem.setVModel("imageupload");

        return fieldsItem;
    }

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