隐藏单据中上所有工具栏原创
金蝶云社区-低级杂工
低级杂工
18人赞赏了该文章 428次浏览 未经作者许可,禁止转载编辑于2023年08月17日 10:30:38

/**

 * 背景:当别的页面跳转其他单据并且需要隐藏当局上所有的工具栏

*         BillShowParameter parameter = new BillShowParameter();

*         parameter.setFormId("xxxx");

*         parameter.getOpenStyle().setShowType(ShowType.Modal);

*         parameter.addCustPlugin("xx.xx.xx.xx.xx.VisibleToolBarFormPlugin");

*         parameter.setPkId(xxxxxxxxx);

*         parameter.setStatus(OperationStatus.VIEW);

*         this.getView().showForm(parameter);

 */

public class VisibleToolBarFormPlugin extends AbstractFormPlugin {

    private OperationStatus billStatus = null;

    @Override

    public void initialize() {

        super.initialize();

        if (this.billStatus == null){

            FormView view = (FormView) this.getView();

            this.billStatus = view.getStatus();

        }

    }

    @Override

    public void afterBindData(EventObject e) {

        super.afterBindData(e);

        List<Control> controls = Collections.singletonList(this.getView().getRootControl());

        loopAndHideToolBar(controls);

    }


    private void loopAndHideToolBar(List<Control> list){

        if (CollectionUtils.isNotEmpty(list)){


            for (Control control : list) {

                String key = control.getKey();

                if ("pagepanel".equals(key)){

                    this.getView().setVisible(false,"pagepanel");

                }else if (control instanceof Toolbar){

                    if (OperationStatus.VIEW.equals(this.billStatus)){

                        this.getView().setVisible(false,key);

                    }

                }else if (control instanceof Container){

                    this.loopAndHideToolBar(((Container) control).getItems());

                }

            }

        }

    }

}

代码.docx(63.71KB)

赞 18