package yem.wmc.imc.formplugin.dynamic;

import kd.bos.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin;
import java.util.Date;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 金亮
 * @date 2024/1/4 17:19
 * @relevantfile *绑定发票归集动态表单（yem_imc_invocollec）
 * @description *请描述开发的详细功能*
 * @versions 1.0
 */
public class InvoiceCollecDynamic extends AbstractFormPlugin {
    @Override
    public void registerListener(EventObject e) {
        super.registerListener(e);
        this.addClickListeners("yem_cancelbutton", "yem_submitbutton");
    }

    @Override
    public void click(EventObject e) {
        super.click(e);
        Control source = (Control) e.getSource();
        String key = source.getKey();
        if ("yem_cancelbutton".equals(key)) { //取消按钮
            this.getView().returnDataToParent(null);
            this.getView().close();//关闭视图
        } else if("yem_submitbutton".equals(key)) { //确定按钮
            btnOk();
        }
    }

    public void btnOk() {
        Date startDate = (Date) this.getModel().getValue("yem_startdate"); //开始时间
        Date endDate = (Date) this.getModel().getValue("yem_enddate"); //结束时间
        Integer currentPage = (Integer) this.getModel().getValue("yem_currentpage"); //当前页
        Integer pageSize = (Integer) this.getModel().getValue("yem_pagesize"); //页面查询条数
        Map<String, Object> map = new HashMap<>();
        map.put("yem_startdate", startDate);
        map.put("yem_enddate", endDate);
        map.put("yem_currentpage", currentPage);
        map.put("yem_pagesize", pageSize);
        this.getView().returnDataToParent(map);
        this.getView().close();
    }
}
