package yem.wmc.ydn.formplugin.dynamic;

import kd.bos.bill.OperationStatus;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.ShowType;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;

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

/**
 * 动态表单插件
 */
public class OperatorHeadDynamic extends AbstractFormPlugin implements Plugin {

    @Override
    public void afterCreateNewData(EventObject e) {
        Map<String, String> map  = new HashMap<>();
        map.put("yem_ca_operatertop", "yem_grossflex");//首页顶部人员已完成总量
        map.put("yem_ca_unoperatortop","yem_flexpanelap");//首页顶部人员未完成总量
        map.put("yem_personneltotalamt","yem_tfmpie");//首页中部折线
        map.put("yem_personneldetails","yem_kfmpie");//首页中部单据体
        showForm(map);
    }

    public void showForm(Map<String, String> map) {
        for (String key : map.keySet()) {
            IFormView view = this.getView();
            FormShowParameter showParameter = new FormShowParameter();
            showParameter.setStatus(OperationStatus.EDIT);
            showParameter.getOpenStyle().setShowType(ShowType.InContainer);
            showParameter.getOpenStyle().setTargetKey(map.get(key));
            showParameter.setSendToClient(true);
            showParameter.setFormId(key);
            view.showForm(showParameter);
        }
    }
}