• UEP-树和表


    Model Select:表格要展示的数据
    Tree DataSource:树的数据源
    数据源是自定义java类
    实现接口:ITreeRetriever创建根节点、判断子节点、创建子节点

    --数据源

    package com.haiyisoft.bill.page.tree;
    
    import java.math.BigDecimal;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import com.haiyisoft.entity.UepContract;
    import com.haiyisoft.entity.UepCustomer;
    import com.haiyisoft.ep.common.jpa.util.JPAUtil;
    import com.haiyisoft.ep.common.model.QueryParam;
    import com.haiyisoft.ep.common.model.QueryParamList;
    import com.haiyisoft.ep.framework.model.ITreeRetriever;
    import com.haiyisoft.ep.framework.model.TreeBean;
    
    public class TreeSourceDP implements ITreeRetriever {
    
        @Override
        public TreeBean createTree(String arg0) {
            TreeBean root = new TreeBean();
            if(arg0 != null && "".equals(arg0)){
                root.setCode("0");
            }else{
                root.setCode(arg0);
            }
            root.setLabel("客户合同树根");
            root.setType("ROOT");
            
            return root;
        }
    
        @Override
        public boolean hasChild(TreeBean arg0) {
            return this.retrieveNode(arg0).size()>0;
        }
    
        @Override
        public List<TreeBean> retrieveNode(TreeBean arg0) {
            List<TreeBean> list = new ArrayList<TreeBean>();
            if("ROOT".equals(arg0.getType())){
                List<UepCustomer> dataList = JPAUtil.loadAll(UepCustomer.class);
                for(UepCustomer entity : dataList){
                    TreeBean node = new TreeBean();
                    node.setCode(entity.getId().toString());
                    node.setLabel(entity.getCustomerName());
                    node.setType("CUSTOMER");
                    //向前台传递参数或属性
                    Map<String,String> extProp = new HashMap<String,String>();
                    extProp.put("config", node.getCode()+"_"+node.getLabel());
                    node.setExtProp(extProp);
                    
                    list.add(node);
                }
            }else if("CUSTOMER".equals(arg0.getType())){
                QueryParamList params = new QueryParamList();
                params.addParam("customerId",new BigDecimal(arg0.getCode()));
                List<UepContract> dataList = JPAUtil.load(UepContract.class,params);
                for(UepContract entity : dataList){
                    TreeBean node = new TreeBean();
                    node.setCode(entity.getId().toString());
                    
                    node.setLabel(entity.getContractName());
                    node.setType("CONTRACT");
                    list.add(node);
                }
            }
            
            return list;
        }
    
    }
    谢谢大家的阅读,阅读后记得关注一下呦!
  • 相关阅读:
    10月27日PHP加载类、设计模式(单例模式和工厂模式)、面向对象的六大原则
    数据解析2:JSON解析(2)
    数据解析2:JSON解析(1)
    数据解析1:XML解析(3)
    数据解析1:XML解析(2)
    数据解析1:XML解析(1)
    设计模式4:装饰模式(1)
    设计模式3:模板模式(1)
    设计模式2:工程模式(1)
    设计模式1:单例模式(1)
  • 原文地址:https://www.cnblogs.com/bhy-1116/p/8315287.html
Copyright © 2020-2023  润新知