package com.yem.wm.es.storagetrans.dynamic;

import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.IFormView;
import kd.bos.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin;

import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;

public class BLDateBackFillEdit extends AbstractFormPlugin {

    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        IDataModel model = this.getModel();
        IFormView view = this.getView();
        IFormView parentView = view.getParentView();
        IDataModel parentModel = parentView.getModel();
        model.setValue("yem_tddate", parentModel.getValue("yem_tddate"));//提单日期
    }

    @Override
    public void registerListener(EventObject e) {
        this.addClickListeners("btnok");
    }

    @Override
    public void click(EventObject e) {
        super.click(e);
        Control control = (Control) e.getSource();
        String key = control.getKey();
        IDataModel model = this.getModel();
        IFormView view = this.getView();
        if ("btnok".equals(key)) {
            Map<String, Object> map = new HashMap<>();
            map.put("yem_tddate", model.getValue("yem_tddate"));
            this.getView().returnDataToParent(map);
        }
        view.close();
    }
}
