package nckd.jxccl.hr.psms.plugin.form.other;

import kd.bos.form.FormShowParameter;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;
import nckd.jxccl.base.common.utils.ConvertUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.EventObject;
import java.util.List;

/**
* 高级人才-解聘
* 实体标识：nckd_dismissappoint
* @author W.Y.C
* @date 2025/12/25 20:54
* @version 1.0
*/
public class DismissAppointFormPlugin extends AbstractFormPlugin implements Plugin {

    @Override
    public void afterBindData(EventObject e) {
        // 获取当前页面的FormShowParameter对象
        FormShowParameter showParameter = this.getView().getFormShowParameter();
        //获取列表选择的数据
        List<Long> selectRowId = ConvertUtil.toList(showParameter.getCustomParam("ids"));
        String idsStr = StringUtils.join(selectRowId, ",");
        this.getModel().setValue("nckd_ids", idsStr);
        this.getView().updateView("nckd_ids");
    }


    @Override
    public void afterDoOperation(AfterDoOperationEventArgs e) {
        if(e.getOperationResult() != null && e.getOperationResult().isSuccess()){
            String operateKey = e.getOperateKey();
            if("dismissappointaffirm".equalsIgnoreCase(operateKey)){
                this.getView().returnDataToParent(Boolean.TRUE);
                this.getView().close();
            }
        }
    }
}