package nckd.jxccl.hr.htm.plugin.form.quitapply;

import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.mvc.list.ListView;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import nckd.jxccl.hr.htm.common.quitapply.QuitApplyConstant;

/**
 * 离职协作基础页面列表插件
 * @entity: nckd_htm_coopbase_ext
 * @author: jtd
 * @date: 2025/11/18 21:44
 */
public class QuitCoopBaseListPlugin extends AbstractListPlugin {

    @Override
    public void setFilter(SetFilterEvent e) {
        super.setFilter(e);

        // 获取表单标识
        String billFormId = ((ListView) getView()).getBillFormId();

        // 离职协作处理页面列表和离职协作管理页面列表过滤掉退休数据
        if (QuitApplyConstant.HTM_COOPHANDLE_ENTITY.equals(billFormId) || QuitApplyConstant.HTM_COOPMANAGE_ENTITY.equals(billFormId)) {
            e.addCustomQFilter(new QFilter(String.format("%s.%s.number", QuitApplyConstant.QUITAPPLY_KEY, QuitApplyConstant.AFFACTION_KEY), QCP.not_equals, QuitApplyConstant.RETIRE_AFFACTION_NUMBER));
        }

        // 退休协作处理页面列表和退休协作管理页面列表过滤掉离职数据
        if (QuitApplyConstant.NCKD_RETIRE_COOPHANDLE_ENTITY.equals(billFormId) || QuitApplyConstant.NCKD_RETIRE_COOPMANAGE_ENTITY.equals(billFormId)) {
            e.addCustomQFilter(new QFilter(String.format("%s.%s.number", QuitApplyConstant.QUITAPPLY_KEY, QuitApplyConstant.AFFACTION_KEY), QCP.equals, QuitApplyConstant.RETIRE_AFFACTION_NUMBER));
        }
    }
}
