123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="renderer" content="webkit|ie-comp|ie-stand">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
- <meta http-equiv="Cache-Control" content="no-siteapp" />
- <!--[if lt IE 9]>
- <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
- <![endif]-->
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
- <link rel="stylesheet" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
- <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/layer/3.0.3/layer.js"></script>
- <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
- <!--[if IE 6]>
- <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
- <script>DD_belatedPNG.fix('*');</script>
- <![endif]-->
- <script type="text/javascript">
- $(function() {
- $(window).resize(function(){
- $("#tree").setGridWidth($(window).width()-40);
- });
- $("#tree").jqGrid({
- caption:'字典管理',
- url : '${ctx}/myconsole/pdic/getByTree',
- editurl:"${ctx}/myconsole/pdic/saveOrUpdate",
- mtype : "POST",
- "hoverrows":false,
- "viewrecords":false,
- "gridview":true,
- "height":"auto",
- //"loadonce":true,
- "rowNum":100,
- "scrollrows":true,
- // enable tree grid
- "treeGrid":false,
- // which column is expandable
- "ExpandColumn":"tname",
- // datatype
- "treedatatype":"json",
- // the model used
- "treeGridModel":"adjacency",
- // configuration of the data comming from server
-
- "sortorder":"asc",
- autowidth : true,
- "datatype":"json",
- "pager":"#pager",
- colModel : [ {
- label : '字典名称',
- name : 'tname',
- edittype:"text",
- editable: true,
- formoptions:{
- elmsuffix:'*'
- },
- editrules:{required:true},
- width : 100
- }, {
- label : '字典键值',
- name : 'tid',
- editable: true,
- edittype: "text",
- width : 50
- }, {
- label : '字典编号',
- name : 'keyid',
- key : true,
- hidden : false,
- editable: false,
- width : 100
- }, {
- label : '字典排序',
- name : 'sortid',
- editable: true,
- edittype: "text",
- formoptions:{
- elmsuffix:'必须是数字'
- },
- width : 50
- },{
- "name":"upperid",
- "hidden":true
- },{
- "name":"tlevel",
- "hidden":true
- } ],
- });
- jQuery('#tree').jqGrid('navGrid','#pager',
- // the buttons to appear on the toolbar of the grid
- {
- edit : true,
- add : true,
- del : true,
- search : false,
- refresh : true,
- view : false,
- position : "left",
- cloneToTop : true,
- afterComplete:function(){
- // zTree = $.fn.zTree.init($("#ztree"), setting);
- }
- },
- // options for the Edit Dialog
- {
- recreateForm : true,
- checkOnUpdate : true,
- checkOnSubmit : true,
- closeAfterEdit : true,
- serializeEditData: function(postdata) {
- $.each(postdata,function (index, value) {
- if(index == "id"){
- index = "keyid";
- postdata[index] = value;
- }
- })
- return postdata;
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- },
- afterComplete:function(){
- zTree = $.fn.zTree.init($("#ztree"), setting);
- }
- },
- // options for the Add Dialog
- {
- closeAfterAdd : true,
- recreateForm : true,
- beforeSubmit: function(postdata, formid){
- var selRowId = $("#tree").jqGrid ('getGridParam', 'selrow');
- //myconsole.log(selRowId);
- //myconsole.log($("#tree").jqGrid('getGridParam', 'upperid'));
- if(selRowId != null){
- postdata.upperid=selRowId;
- }else{
- postdata.upperid = $("#tree").jqGrid('getGridParam', 'upperid');
- }
- return[true,''];
- },
- afterComplete : function (response, postdata, formid) {
- //取消选择
- $("#tree").jqGrid("resetSelection");
- zTree = $.fn.zTree.init($("#ztree"), setting);
- //关闭对话框
- $(".ui-icon-closethick").trigger('click');
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- // options for the Delete Dailog
- {
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- },
- afterComplete:function(){
- zTree = $.fn.zTree.init($("#ztree"), setting);
- }
- });
- jQuery('#tree').jqGrid('bindKeys');
- })
- var zTree;
- var setting = {
- async:{
- enable:true,
- type:"post",
- url:"${ctx}/myconsole/pdic/getzTree",
- dataFilter:dataFilter
- } ,
- check: {
- enable: false,
- chkStyle: "radio",
- radioType: "all"
- },
- view:{
- dblClickExpand: false,
- },
- data: {
- simpleData: {
- enable: true,
- idKey: "keyid",
- pIdKey: "upperid",
-
- // rootPId: 0
- },
- key:{
- name:"tname"
- }
- },
- callback: {
- beforeExpand: beforeExpand,
- onExpand: onExpand,
- onClick: onClick,
- onAsyncSuccess: onAsyncSuccess,
-
- }
- };
-
- function dataFilter (treeId,parentNode,childNodes){
- var getZ = $.fn.zTree.getZTreeObj("ztree");
- var nodes = {keyid:'0',tname:'首页',upperid:'-1',tlevel:'0',isleaf:'no',open:true};
- childNodes.push(nodes);
- for (var i=0, l=childNodes.length; i<l; i++) {
- childNodes[i].tname = childNodes[i].tname.replace(/\.n/g, '.');
- }
- return childNodes;
- }
- //异步请求成功后执行的方法,为了展开首页,或者树形结构刷新后,展开之前树形结构
- function onAsyncSuccess(){
- if(aNode != null){
- zTree.expandNode(aNode,true,false,false);
- //zTree.expandNode(aNode,true,false,false);
- }else{
- var fiNode = zTree.getNodeByParam("keyid","0");
- zTree.expandNode(fiNode,true,false,false);
- }
- // aNode = null;
- }
-
- var curExpandNode = null;//当前展开树形节点
- //树形结构展开之前执行方法,与singlePath方法实现控制同一级别下只展开一个树形节点
- function beforeExpand(treeId, treeNode) {
- var pNode = curExpandNode ? curExpandNode.getParentNode():null;
- var treeNodeP = treeNode.parentTId ? treeNode.getParentNode():null;
- var zTree = $.fn.zTree.getZTreeObj("ztree");
- for(var i=0, l=!treeNodeP ? 0:treeNodeP.children.length; i<l; i++ ) {
- if (treeNode !== treeNodeP.children[i]) {
- zTree.expandNode(treeNodeP.children[i], false);
- }
- }
- while (pNode) {
- if (pNode === treeNode) {
- break;
- }
- pNode = pNode.getParentNode();
- }
- if (!pNode) {
- singlePath(treeNode);
- }
-
- }
- function singlePath(newNode) {
- if (newNode === curExpandNode) return;
-
- var zTree = $.fn.zTree.getZTreeObj("ztree"),
- rootNodes, tmpRoot, tmpTId, i, j, n;
-
- if (!curExpandNode) {
- tmpRoot = newNode;
- while (tmpRoot) {
- tmpTId = tmpRoot.tId;
- tmpRoot = tmpRoot.getParentNode();
- }
- rootNodes = zTree.getNodes();
- for (i=0, j=rootNodes.length; i<j; i++) {
- n = rootNodes[i];
- if (n.tId != tmpTId) {
- zTree.expandNode(n, false);
- }
- }
- } else if (curExpandNode && curExpandNode.open) {
- if (newNode.parentTId === curExpandNode.parentTId) {
- zTree.expandNode(curExpandNode, false);
- } else {
- var newParents = [];
- while (newNode) {
- newNode = newNode.getParentNode();
- if (newNode === curExpandNode) {
- newParents = null;
- break;
- } else if (newNode) {
- newParents.push(newNode);
- }
- }
- if (newParents!=null) {
- var oldNode = curExpandNode;
- var oldParents = [];
- while (oldNode) {
- oldNode = oldNode.getParentNode();
- if (oldNode) {
- oldParents.push(oldNode);
- }
- }
- if (newParents.length>0) {
- zTree.expandNode(oldParents[Math.abs(oldParents.length-newParents.length)-1], false);
- } else {
- zTree.expandNode(oldParents[oldParents.length-1], false);
- }
- }
- }
- }
- curExpandNode = newNode;
- }
- //树形结构展开时执行方法
- function onExpand(event, treeId, treeNode) {
- curExpandNode = treeNode;
- }
- var zNodes;
- var aNode; //选中树形节点
- //ztree点击直接展开,并根据选中的树形节点重新加载jqgrid
- function onClick(e,treeId,treeNode){
- aNode = treeNode;
- if(treeNode.tname != "首页"){
- zTree.expandNode(treeNode,null,null,null,true);
- }else{
- $.fn.zTree.getZTreeObj("ztree").expandAll(false);
- zTree.expandNode(treeNode,null,null,null,true);
- }
- jQuery("#tree").jqGrid('setGridParam', { url: "${ctx}/myconsole/pdic/getByTree?nodeid="+treeNode.keyid,'upperid':treeNode.keyid }).trigger('reloadGrid');
- }
- $(function(){
- //zTree初始化方法
- zTree = $.fn.zTree.init($("#ztree"), setting);
- })
- </script>
- <title>我的桌面</title>
- <style type="text/css">
- .ztree li span.button.switch.level0 {visibility:hidden; width:1px;}
- .ztree li ul.level0 {padding:0; background:none;}
- </style>
- </head>
- <body>
- <div>
- <div id = "ztree" class="ztree" style="margin-top:15px;margin-left:5px;width:15%;float:left;"></div>
- <div style="margin-top:0px;width:83%;float:right;">
- <div class="page-container">
- <table id="tree"></table>
- <div id="pager"></div>
- </div>
- <footer class="footer mt-20">
- <div class="container">
- <p></p>
- </div>
- </footer>
- </div>
- </div>
- </body>
- </html>
|