package nckd.jxccl.swc.hcdm.formplugin.agencybill;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.IFormView;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;

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

/**
 * Tyx 单位代发单批量更新表单插件
 * 【nckd_agencybatchupdate】
 */
public class AgencyBatchUpdateFormPlugin extends AbstractFormPlugin implements Plugin {


    @Override
    public void registerListener(EventObject e) {
        super.registerListener(e);
    }

    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
        super.beforeDoOperation(args);
    }

    @Override
    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
        super.afterDoOperation(afterDoOperationEventArgs);
        String key = afterDoOperationEventArgs.getOperateKey();
        switch(key) {
            case "donothing_batchupdate":
                doUpdate();
                break;
        }
    }

    private void doUpdate() {
        DynamicObject dyn = this.getModel().getDataEntity();
        IFormView view = this.getView();
        Map map = new HashMap();
        map.put("month", dyn.getDate("nckd_month"));
        //map.put("calrule", dyn.getDynamicObject("nckd_calrule"));
        map.put("payRollScene", dyn.getDynamicObject("nckd_payrollscene"));
        view.returnDataToParent(map);
        view.close();
    }


}