package nckd.jimin.jyyy.fi.plugin.form;

import kd.bos.form.events.FilterContainerInitArgs;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.fi.cas.consts.BillTypeConstants;

import java.util.List;

/**
 * 付款处理(nckd_cas_paybill_ext)，处理列表默认过滤
 * @author wanghaiwu_kd
 * @date 2025/06/18
 */
public class PaymentBillFilterListPlugin extends AbstractListPlugin {
    public void setFilter(SetFilterEvent e) {
        super.setFilter(e);

        List<QFilter> filters = e.getQFilters();
        if (!filters.isEmpty()) {
            for (int index = filters.size() - 1; index >= 0; --index) {
                if (((QFilter) filters.get(index)).getProperty().equals("iswaitsche")) {
                    QFilter qFilter = (QFilter) filters.get(index);

                    List<QFilter.QFilterNest> nests = qFilter.getNests(true);
                    for(int i = 0; i < nests.size(); i++){
                        QFilter.QFilterNest nest = nests.get(i);
                        QFilter cur = nest.getFilter();
                        if(cur.getProperty().equals("billtype")){
                            //调拨处理列表显示 跨主体调拨 数据
                            cur = cur.or(new QFilter("billtype", QCP.equals, BillTypeConstants.PAYBILL_SPAN));
                        }
                    }
                }
            }
        }
    }

    @Override
    public void filterContainerInit(FilterContainerInitArgs args) {
        super.filterContainerInit(args);
    }
}
