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;

/**
 * 经营分析看板
 * @author  zhangh
 */
public class HomeBillForm extends AbstractFormPlugin {

    @Override
    public void afterCreateNewData(EventObject e) {
        Map<String, String> map  = new HashMap<>();
        map.put("yem_ca_tophometotal", "yem_grossflex");//首页顶部年度总量
        map.put("yem_ca_tophometfm","yem_flexpanelap");//首页顶部TFM
        map.put("yem_ca_tophomekfm","yem_flexpanelap1");//首页顶部KFM
        map.put("yem_ca_centerhometfm","yem_tfmpie");//首页中部TFM饼图
        map.put("yem_ca_centerhomekfm","yem_kfmpie");//首页中部KFM饼图
        map.put("yem_ca_centerhomebar","yem_bar");//首页柱状图
        map.put("yem_ca_lowhomeneed","yem_flexpanelap2");//首页底部需求表格
        map.put("yem_ca_lowhomepur","yem_flexpanelap21");//首页底部采购表格

        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);
        }
    }
}