金蝶EAS,通用过滤中F7字段添加过滤

时间:2022-10-12 11:29:21

package com.kingdee.eas.custom.ems.util;

import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.ui.face.IUIObject;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.fm.common.client.FMDefaultQueryProcessor;

/**
* 损益期间F7工具类
* 用于实现在通用过滤中,期间按照财务组织进行过滤
* 引用该工具类时,需要在序时簿功能类中重写initCommonQueryDialog()
* @author 郭旭
*
*/
public class PeriodF7Util extends FMDefaultQueryProcessor {

protected IUIObject owner;

public PeriodF7Util() {

}

public PeriodF7Util(IUIObject owner) {
this.owner = owner;
}

/**
* 通用过滤时,如果选取了损益期间
* 将损益期间按照组织进行过滤
*/
public void process() throws Exception {

super.process();
Object editor = getEditor();
if (!(editor instanceof KDBizPromptBox)) return;
KDBizPromptBox f7 = (KDBizPromptBox) editor;
String query = f7.getQueryInfo();
if (query == null || query.trim().length() == 0) {
return;
}

if ("com\\kingdee\\eas\\custom\\ems\\app\\PeriodQuery".equalsIgnoreCase(query)) {

CompanyOrgUnitInfo company = SysContext.getSysContext().getCurrentFIUnit();
String companyId = company.getId().toString(); //当前财务组织ID
EntityViewInfo view = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("company.id", companyId));
view.setFilter(filter);
f7.setEntityViewInfo(view);

}

}

}

-------------序时簿界面功能类ListUI中重写以下方法--------------

/**
* 重写通用过滤
* 实现损益期间F7实现按组织过滤
*/
@Override
protected CommonQueryDialog initCommonQueryDialog() {

CommonQueryDialog dialog = super.initCommonQueryDialog();
dialog.setProcessor(new PeriodF7Util(this));

return dialog;

}