package nckd.jxccl.hr.tsc.plugin.form;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;

/**
 * 我要应聘-最新职位表单插件 【tsirm_advertopen】
 * @author Tyx
 * 时间 2026/1/14 14:30
 */
public class OpenAdvertEditEx extends AbstractFormPlugin implements Plugin {

    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
        super.beforeDoOperation(args);
        FormOperate formOperate = (FormOperate)args.getSource();
        String operateKey = formOperate.getOperateKey();
        if("donothing_apply".equals(operateKey)) {
            openApplicationBillForm(args);
        }
    }

    /**
     * 打开应聘申请单表单界面
     * @param args
     */
    private void openApplicationBillForm (BeforeDoOperationEventArgs args) {
        IDataModel model = this.getModel();
        DynamicObject dyn = model.getDataEntity();
        FormShowParameter formShowParameter = new FormShowParameter();
        formShowParameter.setFormId("nckd_applicationbill");
        formShowParameter.setCustomParam("positionId", dyn.getLong("position.id"));
        formShowParameter.setCustomParam("advertId", dyn.getLong("id"));
        formShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
        formShowParameter.setCloseCallBack(new CloseCallBack(this, "application"));
        this.getView().showForm(formShowParameter);
    }

}