码迷,mamicode.com
首页 > 其他好文 > 详细

UEP-树和表

时间:2018-01-20 14:04:41      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:body   name   tco   sel   als   frame   ever   com   load   

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;
    }

}

 

UEP-树和表

标签:body   name   tco   sel   als   frame   ever   com   load   

原文地址:https://www.cnblogs.com/bhy-1116/p/8315287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!