package com.yem.wm.cm.tracktaskconsole.list;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.ListShowParameter;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;

/**
 * 跟单任务控制台列表插件
 */
public class TrackTaskConsoleList extends AbstractListPlugin implements Plugin {

    @Override
    public void setFilter(SetFilterEvent e) {
        super.setFilter(e);
        ListShowParameter parameter = (ListShowParameter) this.getView().getFormShowParameter();
        if(null != parameter) {
            String formId = parameter.getBillFormId();
            if(null != formId && !"".equals(formId)) {
                //单据类型过滤
                QFilter qFilter1 = new QFilter("number", QCP.equals, formId);
                DynamicObject[] bos_billtype_s = BusinessDataServiceHelper.load("bos_billtype",
                        "id,name,number", new QFilter[] { qFilter1 }, null);
                if(null != bos_billtype_s && bos_billtype_s.length>0) {
                    QFilter filter = new QFilter("yem_billtype.id", QCP.equals, bos_billtype_s[0].getPkValue());
                    e.getQFilters().add(filter);
                }
            }
        }
    }
}