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

import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.IListView;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.sdk.plugin.Plugin;
import nckd.jxccl.base.common.constant.FormConstant;
import nckd.jxccl.base.common.enums.psms.ScoreItemEnum;
import nckd.jxccl.hr.psms.common.ContributionConstant;

/**
* 年度贡献积分单据列表插件
* 实体标识：nckd_contribbill
* @author W.Y.C
* @date 2025/10/26 21:44
* @version 1.0
*/
public class ContribLillListPlugin extends AbstractListPlugin implements Plugin {

    @Override
    public void setFilter(SetFilterEvent e) {
        //获取单据标识，获取页面标识
        String billFormId = ((IListView) this.getView()).getBillFormId();
        ScoreItemEnum scoreItem = ScoreItemEnum.getByPageId(billFormId);
        if(scoreItem != null) {
            //根据不同页面过滤不同积分单据数据
            e.addCustomQFilter(new QFilter(String.join(".",ContributionConstant.NCKD_SCOREITEM, FormConstant.NUMBER_KEY), QCP.equals, scoreItem.getCode()));
        }
    }

    @Override
    public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
        super.closedCallBack(closedCallBackEvent);
    }
}