easyUI

//获取所有树叶子节点 注册添加事件 if ($('#menu').tree('isLeaf', node.target)) 是否叶子节点

$(function(){
  $('#menu').tree({
    onClick: function(node){

      //判断是不是叶子节点 node.target,节点对象的target属性)
      if($('#menu').tree("isLeaf",node.target)){  
        //alert(node.text);
        var tabs = $("#tabs");

        //getTab方法为在面板选项中获取指定的选项卡,node.text为指定选项卡的名字
        var tab = tabs.tabs("getTab",node.text);  

        //if(tab)tab存在的情况,在js中,如果存在有值,则表示true,不存在或者为0,表示false
        if(tab){
          tabs.tabs("select",node.text);
        }else{
          tabs.tabs('add',{
          title:node.text,
          href: node.attributes.url,  //加载远程url数据到选项卡,这个url是加载的页面的地址
          closable:true,
          bodyCls:"content"  //添加css类文到面板中
          });
        }
      }
    }
  });
});

 
  •  tabs选项卡

function addTab(title, url){  
    if ($('#tt').tabs('exists', title)){ /* 判断以title未标题的选项是否存在 */ 
        $('#tt').tabs('select', title);  /* 选中当前选项卡进行展现 */
    } else { 
        /* iframe指定显示框 */
        var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="100%;height:100%;"></iframe>';  
        $('#tt').tabs('add',{  /* tabs添加选项卡 ,add新增属性*/
            title:title,  
            content:content, /* 文本信息 */ 
            closable:true /* 可关闭的 */ 
        });  
    }  
} 
  • 通过请求数据创建表格

<!--定义表格,并且通过url访问json数据, fitColumns:true表示自动适应,singleSelect:true 表示选中单个
pageSize:20页面默认显示的数量,toolbar:toolbar工具栏  -->
<table class="easyui-datagrid" id="itemList" title="商品列表"
       data-options="singleSelect:false,collapsible:true,pagination:true,url:'/item/query',method:'get',pageSize:20,toolbar:toolbar">
    <thead>
        <tr>
            <th data-options="field:'ck',checkbox:true"></th>
            <th data-options="field:'id',60">商品ID</th>
            <th data-options="field:'title',200">商品标题</th>
            <th data-options="field:'cid',100,align:'center',formatter:KindEditorUtil.findItemName">叶子类目</th>
            <th data-options="field:'sellPoint',100">卖点</th>
            <th data-options="field:'price',70,align:'right',formatter:KindEditorUtil.formatPrice">价格</th>
            <th data-options="field:'num',70,align:'right'">库存数量</th>
            <th data-options="field:'barcode',100">条形码</th>
            <th data-options="field:'status',60,align:'center',formatter:KindEditorUtil.formatItemStatus">状态</th>
            <th data-options="field:'created',130,align:'center',formatter:KindEditorUtil.formatDateTime">创建日期</th>
            <th data-options="field:'updated',130,align:'center',formatter:KindEditorUtil.formatDateTime">更新日期</th>
        </tr>
    </thead>
</table>
  • 将数字字符串转换成数字:

//转化价格单位,将元转化为分
$("#itemAddForm [name=price]").val(eval($("#itemAddForm [name=priceView]").val()) * 100);
itemAddEditor.sync();//将输入的内容同步到多行文本中
原文地址:https://www.cnblogs.com/gxlaqj/p/11540089.html