Parcourir la source

ration tuning

TonyKang il y a 8 ans
Parent
commit
85edd8058f
2 fichiers modifiés avec 45 ajouts et 17 suppressions
  1. 14 14
      web/rationLibEditor/dinge.html
  2. 31 3
      web/rationLibEditor/js/dinge.js

+ 14 - 14
web/rationLibEditor/dinge.html

@@ -49,7 +49,7 @@
                           <!--
                           <a href="#" class="btn btn-secondary btn-sm">创建默认章节树</a>
                           -->
-                          <a href="#" class="btn btn-secondary btn-sm">增加根节点</a>
+                          <a onclick="addRootNode()" class="btn btn-secondary btn-sm">增加根节点</a>
                       </div>
                     <div class="tab-content">
                       <ul id="treeDemo" class="ztree"></ul>
@@ -883,19 +883,19 @@
 /*var rationName = getQueryString("rationname");*/
 var treeObj;
 var zNodes =[
-    { id:1, pId:0,nId:2, name:"第一章 土石方工程",isParent:true,children:[]},
-    { id:2, pId:0,nId:3, name:"第二章 挡墙、护坡工程",isParent:true,children:[]},
-    { id:3, pId:0,nId:4, name:"第三章 基础工程",isParent:true,children:[]},
-    { id:4, pId:0,nId:5, name:"第四章 脚手架工程",isParent:true,children:[]},
-    { id:5, pId:0,nId:6, name:"第五章 砌筑工程",isParent:true,children:[]},
-    { id:6, pId:0,nId:7, name:"第六章 混凝土及钢筋混凝土工程",isParent:true,children:[]},
-    { id:7, pId:0,nId:8, name:"第七章 金属工程",isParent:true,children:[]},
-    { id:8, pId:0,nId:9, name:"第八章 门窗、木结构",isParent:true,children:[]},
-    { id:9, pId:0,nId:10, name:"第九章 楼地面工程",isParent:true,children:[]},
-    { id:10, pId:0,nId:11, name:"第十章 层面工程",isParent:true,children:[]},
-    { id:11, pId:0,nId:12, name:"第十一章 防腐隔热保温工程",isParent:true,children:[]},
-    { id:12, pId:0,nId:13, name:"第十二章 装饰工程",isParent:true,children:[]},
-    { id:13, pId:0,nId:-1, name:"第十三章 其他工程",isParent:true,children:[]},
+    { id:1, pId:-1,nId:2, name:"第一章 土石方工程",isParent:true,children:[]},
+    { id:2, pId:-1,nId:3, name:"第二章 挡墙、护坡工程",isParent:true,children:[]},
+    { id:3, pId:-1,nId:4, name:"第三章 基础工程",isParent:true,children:[]},
+    { id:4, pId:-1,nId:5, name:"第四章 脚手架工程",isParent:true,children:[]},
+    { id:5, pId:-1,nId:6, name:"第五章 砌筑工程",isParent:true,children:[]},
+    { id:6, pId:-1,nId:7, name:"第六章 混凝土及钢筋混凝土工程",isParent:true,children:[]},
+    { id:7, pId:-1,nId:8, name:"第七章 金属工程",isParent:true,children:[]},
+    { id:8, pId:-1,nId:9, name:"第八章 门窗、木结构",isParent:true,children:[]},
+    { id:9, pId:-1,nId:10, name:"第九章 楼地面工程",isParent:true,children:[]},
+    { id:10, pId:-1,nId:11, name:"第十章 层面工程",isParent:true,children:[]},
+    { id:11, pId:-1,nId:12, name:"第十一章 防腐隔热保温工程",isParent:true,children:[]},
+    { id:12, pId:-1,nId:13, name:"第十二章 装饰工程",isParent:true,children:[]},
+    { id:13, pId:-1,nId:-1, name:"第十三章 其他工程",isParent:true,children:[]},
 ];
 var setting = {
     view: {

+ 31 - 3
web/rationLibEditor/js/dinge.js

@@ -22,13 +22,41 @@ $(document).ready(function(){
 function initParam(){
     var rationLibName = getQueryString("repository");//获取定额库参数
     if(rationLibName) {
-        params.realLibName = LibName;
+        params.realLibName = rationLibName;
         getRationTree();
     } else{
         params = JSON.parse(getQueryString("params"));
         getRationTree();
     }
 }
+function addRootNode(){
+    //$.ajax({
+    //    type:"POST",
+    //    url:"api/getRationTree",
+    //    data:{"rationLibName": params.realLibName},
+    //    dataType:"json",
+    //    cache:false,
+    //    timeout:20000,
+    //    success:function(result,textStatus,status){
+    //        if(status.status == 200) createRationTree(result.data);//根据返回的全部定额章节对象,构架树。
+    //        else{
+    //            //treeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
+    //            //saveTempTree();
+    //        }
+    //    },
+    //    error:function(err){
+    //        alert(err.responseText.error)
+    //    }
+    //})
+
+    if (treeObj) {
+        var newNodes = [], isSilent = false;
+        newNodes.push({ id: 20, pId:-1, nId:-1, name:"新增节点",isParent:true, children:[]});
+        treeObj.addNodes(null, -1, newNodes, isSilent);
+    } else {
+        //treeObj = $.fn.zTree.init($("#treeDemo"), setting, treeArr);
+    }
+}
 //---------------------------------------------------初始化章节树界面
 function  getRationTree(){
     $.ajax({
@@ -41,8 +69,8 @@ function  getRationTree(){
         success:function(result,textStatus,status){
             if(status.status == 200) createRationTree(result.data);//根据返回的全部定额章节对象,构架树。
             else{
-                treeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
-                saveTempTree();
+                //treeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
+                //saveTempTree();
             }
         },
         error:function(err){