package com.yem.em.bc.list;

import java.util.EventObject;

import kd.bos.filter.FilterContainer;
import kd.bos.list.plugin.AbstractListPlugin;

/**
 * @author 夜子
 * @ClassName BtnTreeOrgCtrList
 * @description: 树状列表按钮显示（组织10000）
 * @date 2023年07月11日
 * @version: 1.0
 */
public class BtnTreeOrgCtrList  extends AbstractListPlugin {

    @Override
    public void registerListener(EventObject e) {
        super.registerListener(e);
        FilterContainer filterContainer = (FilterContainer) this.getControl("filtercontainerap");
        filterContainer.addAfterSearchClickListener((searchClickEvent) -> {
            this.refreshTreeRootNode();
        });
    }

    private void refreshTreeRootNode() {
        String orgId = this.getPageCache().get("createOrg");
        if (!orgId.equals("100000")) {
            this.getView().setVisible(Boolean.FALSE, "btnnew", "btnedit", "btndel", "searchap");
        } else {
            this.getView().setVisible(Boolean.TRUE, "btnnew", "btnedit", "btndel", "searchap");
        }
    }

    @Override
    public void afterBindData(EventObject e) {
        super.afterBindData(e);
        String orgId = this.getPageCache().get("createOrg");
        if (!orgId.equals("100000")) {
            this.getView().setVisible(Boolean.FALSE, "btnnew", "btnedit", "btndel", "searchap");
        } else {
            this.getView().setVisible(Boolean.TRUE, "btnnew", "btnedit", "btndel", "searchap");
        }
    }
}
