package com.kingdee.eas.hr.project.handler;

import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemCollection;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.web.dynamic.model.ListUIViewInfo;
import com.kingdee.shr.base.syssetting.web.dynamic.model.TreeNavigationInfo;
import com.kingdee.shr.base.syssetting.web.dynamic.model.UIViewInfo;
import com.kingdee.shr.base.syssetting.web.handler.ListHandler;
import org.springframework.ui.ModelMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** 项目成员管理列表
 * @BelongsProject: dataImpExp820
 * @BelongsPackage: com.kingdee.eas.hr.project.handler
 * @Author: lhbj
 * @CreateTime: 2024-11-27  18:21
 * @Description: TODO
 * @Version: 1.0
 */
public class MemberManagementListHandler extends ListHandler {

    @Override
    public String getTreeDataAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
        return super.getTreeDataAction(request, response, modelMap);
    }
    @Override
    protected UIViewInfo getUIViewInfo(HttpServletRequest request) throws SHRWebException {
        ListUIViewInfo uiViewInfo = (ListUIViewInfo) super.getUIViewInfo(request);
        TreeNavigationInfo treeNavigation = uiViewInfo.getTreeNavigation();
        treeNavigation.setBuilder("com.kingdee.eas.hr.project.builder.ProjectMTreeBuilder");
        return uiViewInfo;
    }
    protected FilterInfo getTreeDomainFilter(HttpServletRequest request) throws SHRWebException {
        FilterInfo ifo = null;
        FilterInfo filterInfo = super.getTreeDomainFilter(request);
        if(null!=filterInfo) {
            FilterItemCollection fcs = filterInfo.getFilterItems();
            ifo = new FilterInfo();
            if ((!fcs.isEmpty() && fcs.size() > 0)) {
                FilterItemInfo filterItemInfo = fcs.get(0);
                String str = filterItemInfo.toString();
                ifo.getFilterItems().add(new FilterItemInfo(str.replaceAll("longNumber","id")));
            }
        }
        return ifo;
    }

    @Override
    protected FilterInfo getDefaultFilter(HttpServletRequest request, HttpServletResponse response) throws SHRWebException {
        String userAdminOrgRangeSql = this.assembleTreeDataUserAdminOrgRangeSQL(request);
        FilterInfo ifo = new FilterInfo();
        ifo.getFilterItems().add(new FilterItemInfo("projectManagement.adminOrg.id in("+userAdminOrgRangeSql+")"));
        ifo.getFilterItems().add(new FilterItemInfo("projectManagement.projectState in('1','2')"));
        return ifo;
    }
}
