zoukankan      html  css  js  c++  java
  • 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;
        }
    
    }
    谢谢大家的阅读,阅读后记得关注一下呦!
  • 相关阅读:
    mysql 三星索引设置
    mysql 索引长度解释及不使用索引的一种特殊情况
    null作为方法的参数,并在方法里面赋值后的结果是什么?
    线程、调度线程池、异常
    系统服务化,需要考虑的问题
    05-Python之高级语法
    01-python基本语法元素
    04-Python之文件、异常和模块
    03-Python之类
    02-Python之函数
  • 原文地址:https://www.cnblogs.com/bhy-1116/p/8315287.html
Copyright © 2011-2022 走看看