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_quitapplybb_ext
 * @author: jtd
 * @date: 2025/11/18 15:40
 */
public class QuitApplyListPlugin extends AbstractListPlugin {

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

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

        // 离职申请列表和离职办理列表过滤掉退休数据
        if (QuitApplyConstant.HTM_QUITAPPLYBASEBILL_ENTITY.equals(billFormId) || QuitApplyConstant.HTM_QUITHANDLE_ENTITY.equals(billFormId)) {
            e.addCustomQFilter(new QFilter(String.format("%s.number", QuitApplyConstant.AFFACTION_KEY), QCP.not_equals, QuitApplyConstant.RETIRE_AFFACTION_NUMBER));
        }

        // 退休申请列表和退休办理列表过滤掉离职数据
        if (QuitApplyConstant.NCKD_RETIREAPPLYBASEBILL_ENTITYID.equals(billFormId) || QuitApplyConstant.NCKD_RETIREHANDLER_ENTITY.equals(billFormId)) {
            e.addCustomQFilter(new QFilter(String.format("%s.number", QuitApplyConstant.AFFACTION_KEY), QCP.equals, QuitApplyConstant.RETIRE_AFFACTION_NUMBER));
        }
    }

}
