zoukankan      html  css  js  c++  java
  • 树形菜单数据源

    jsp  对应action:compwzproperty

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/framework/include/pageset.jspa"%>
    <%
    String treeNode = request.getParameter("treeNode") == null ? "0"
    : request.getParameter("treeNode");
    long treeCode =Long.parseLong(treeNode);
    %>

    <html>
    <head>
    <script>
    var treeNode ='0' ;
    var pathRoot = "${property.qiniuPicPrePath}";

    </script>
    <script type="text/javascript" src="compwzproperty.js?_v=12"></script>
    </head>
    <body>
    <hy:view>
    <s:form action="compwzproperty">
    <hy:filllayout cols="20%,*">
    <hy:fillarea>
    <hy:treeview id="tree"
    value="com.haiyisoft.hyps.wz.compwzprop.CompanyWzPropertyTree" dynamic="true"
    expandlevel="2" rootvisible="true" onclick="treeDoubleClick()" rootcode ="0" />
    </hy:fillarea>
    <hy:fillarea>
    <hy:tabpanel id="mainpanel" showtabbar="false" height='100%'>
    <hy:tab id="tabList" title="列表">
    <span style="margin:5px 5px 5px 5px;color:red;">根据登陆账号的companyId维护分类</span>
    <hy:filllayout rows="46,*">
    <hy:fillarea>

    <table >
    <tr>
    <td width="10"></td>
    <td width="60"><hy:button name="查询" onclick="retrieve()"/></td>
    <td width="60"><hy:button name="添加" onclick="addGnNode()"/></td>
    <td width="60"><hy:button name="删除" onclick="del()"/></td>
    <td width="60"><hy:button name="保存" onclick="save()"/></td>

    <td></td>
    </tr>
    </table>


    </hy:fillarea>
    <hy:fillarea>
    <hy:ajaxgrid id="ajaxgrid" name="dataWrap" height="100%" width="100%" ondblclick="showWzCode()"
    queryfunc="retrieve()">
    <hy:gridlineno title="序号" width="30" />
    <hy:gridcheckbox name="checked" width="50" title="全选" />
    <hy:gridlink editortitle="查看商家商品" width="120" onclick="showWzCode()"></hy:gridlink>
    <hy:gridfield name="propertyId" title="内码" readonly="true" width="80" align="right"/>
    <hy:gridfield name="propertyName" title="类别名称" required="true" width="120" align="left"/>
    <hy:gridfield name="orderNum" title="排序" width="100" align="right"/>
    <hy:griddate name="createDate" title="创建时间" editor="datetime"readonly="true" width="150" align="center"/>
    <hy:griddrop name="createOper" dropname="UEP.ACCOUNT_NAME" title="创建人" readonly="true" width="120" align="left"/>
    <hy:griddate name="modifyDate" title="修改时间" editor="datetime"readonly="true" width="150" align="center"/>
    <hy:griddrop name="modifyOper" dropname="UEP.ACCOUNT_NAME" title="修改人" readonly="true" width="120"align="left"/>
    <hy:gridinputbutton title="图片上传" name="icon" width="220" onclick="addFile()"
    labelprovider="com.haiyisoft.hyps.common.labelprovider.GetPic_labelprovider" align="left"/>
    <hy:gridlink editortitle="查看图片" onclick="showPic()" width="60"
    titlestyle="background:url(../images/button/change.gif) no-repeat;background-position: center;" align="left"/>
    </hy:ajaxgrid>
    </hy:fillarea>
    </hy:filllayout>
    </hy:tab>
    <hy:tab id="wzList" title="商家商品">
    <hy:layoutTable >
    <hy:layoutArea>
    <hy:layoutTable>
    <hy:layoutRegion height="50" cssClass="commonbgcolor">
    <hy:region title="查询条件" collapseoninit="false" collapsible="false">
    <table>
    <tr>
    <td width="80" align="right">商品ID</td>
    <td width="240" align="left"><input id="indexCode" name="dataWrap.query.wzIncode"
    upload="true" style="100%"/></td>

    <td width="80" align="right">物资名称</td>
    <td width="240" align="left"><input id="wzName" name="dataWrap.query.wzName_LIKE"
    upload="true" style="100%"/></td>

    </tr>

    </table>
    </hy:region>
    </hy:layoutRegion>
    <%--功能按钮 --%>
    <hy:layoutArea height="40" cssClass="commonbgcolor">
    <table>
    <tr>
    <td width="10">
    <td width="60"><hy:button name="返回" onclick="ret()"/></td>
    <td width="60"><hy:button name="查询" onclick="retrieveWz()"/></td>
    <td width="60"><hy:button name="添加" onclick="addCompPropWz()" /></td>
    <td width="90"><hy:button name="删除" onclick="deleteCompPropWz()" /></td>
    </tr>
    </table>
    </hy:layoutArea>
    <hy:layoutArea>
    <hy:ajaxgrid id="wzajaxgrid" name="wzWrap" height="100%"
    width="100%" showpager="true" readonly="true" queryfunc="retrieveWz()" clientsortable="false">
    <hy:gridlineno title="序号" width="30" />
    <hy:gridcheckbox name="checked" width="50" title="全选" />
    <%-- <hy:gridlink editortitle="详细" width="40" onclick="showDetail()"/>
    --%>
    <hy:gridfield name="wzIncode" title="商品ID" width="80" sortable="true" align="right"/>
    <hy:gridfield name="wzName" title="物资名称" width="150" sortable="true" align="left"/>
    <hy:gridfield name="modelDesc" title="物质规格" width="150" align="left"/>
    <hy:griddrop name="wzType" title="物资类别层级" width="200" sortable="true" droptype="label" dropname="WZ.CODE_LINK_DES" align="left"/>
    <hy:gridfield name="salePrice" title="商品价格" align="right" width="80" sortable="true" />
    <hy:gridfield name="goodsNum" title="上架数量" align="right" width="100" sortable="true"/>
    <hy:griddate name="beginDate" title="上架开始时间" editor="datetime" width="150" sortable="true" align="center"/>
    <hy:griddate name="endDate" title="上架结束时间" editor="datetime" width="150"sortable="true" align="center"/>
    <hy:griddrop name="passMark" title="审核状态" width="60" sortable="true" dropname="WZ.PASS_MARK" align="center"/>
    <hy:griddrop name="reviewer" title="审核人" dropname="UEP.ACCOUNT_NAME" width="100" sortable="true" align="left"/>
    <hy:griddate name="reviewTime" title="审核时间" editor="datetime" width="150"sortable="true"align="center" />
    </hy:ajaxgrid>
    </hy:layoutArea>
    </hy:layoutTable>
    </hy:layoutArea>
    </hy:layoutTable>

    </hy:tab>
    </hy:tabpanel>
    </hy:fillarea>
    </hy:filllayout>
    </s:form>
    </hy:view>
    </body>
    </html>

    2初始化树

    public class CompanyWzPropertyTree implements ITreeRetriever {
    @Override
    public TreeBean createTree(String rootCode) {
    //初始化树的根节点
    TreeBean treeRoot = new TreeBean();
    treeRoot.setCode("0");
    treeRoot.setLabel("顶级分类");
    treeRoot.setCloseIcon("images/wz/aider.png");
    treeRoot.setOpenIcon("images/framework/exec_.png");
    return treeRoot;
    }

    @Override
    public boolean hasChild(TreeBean treeBean) {//是否有子节点
    AdminView adv = (AdminView) ContextUtil.getUserView();
    try {
    String treeCode = treeBean.getCode();
    if (treeCode == null) {
    treeCode = "0";
    }
    Long code = Long.valueOf(treeCode);
    QueryParamList params = new QueryParamList();
    params.addParam("upId", code);
    params.addParam("statusFlag",0);
    params.addParam("companyId", adv.getCompanyId());
    List<CompanyWzCodePropertys> list = JPAUtil.load(CompanyWzCodePropertys.class, params);
    if (list.size() > 0) {
    return true;
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    return false;
    }

    @Override
    public List<TreeBean> retrieveNode(TreeBean rootBean) {//检索树的子节点
    List<TreeBean> list = new ArrayList<TreeBean>();
    AdminView adv = (AdminView) ContextUtil.getUserView();
    try {
    String treeCode = rootBean.getCode();
    if (treeCode == null) {
    return null;
    }
    Long code = Long.valueOf(treeCode);

    QueryParamList params = new QueryParamList();
    params.addParam("upId", code);
    params.addParam("statusFlag", 0);
    params.addParam("companyId", adv.getCompanyId());
    List<CompanyWzCodePropertys> List = JPAUtil.load(CompanyWzCodePropertys.class,params);
    for (int i = 0; i < List.size(); i++) {
    CompanyWzCodePropertys wz = List.get(i);

    TreeBean treeBean = new TreeBean();
    treeBean.setCode(String.valueOf(wz.getPropertyId()));
    treeBean.setLabel(wz.getPropertyName());
    list.add(treeBean);

    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    return list;
    }

    }

    3onlick事件

    //当前商家分类
    var wzCodeProperty ;
    function ajax_init(response){
    ajaxgrid.setData(response.getAjaxDataWrap("dataWrap"));
    }
    function treeDoubleClick(node){
    mainpanel.showTabPage("tabList");
    treeNode = node.code;
    $.request({
    action : "retrieve",
    params : {
    treeNode : treeNode
    },
    success : ajax_init
    });
    }

  • 相关阅读:
    HDU4611+数学
    HDU4612+Tarjan缩点+BFS求树的直径
    HDU4602+推导公式
    HDU4607+BFS
    HDU1353+贪心
    HDU4545+LCS
    HDU4548+素数
    HDU4539+状态压缩DP
    HDU2110+母函数
    HDU1569+最大点权集
  • 原文地址:https://www.cnblogs.com/zhangzhiqin/p/8251747.html
Copyright © 2011-2022 走看看