瀏覽代碼

ration glj

TonyKang 8 年之前
父節點
當前提交
6b52a3e83a

+ 58 - 0
modules/rationRepository/models/gljRepository.js

@@ -0,0 +1,58 @@
+/**
+ * Created by Tony on 2017/5/4.
+ * 工料机的总库,根据不同定额库分类,参考原gljList表
+ */
+
+var mongoose = require("mongoose");
+var dbm = require("../../../config/db/db_manager");
+var db = dbm.getCfgConnection("rationRepository")
+var async = require("async");
+var Schema = mongoose.Schema;
+
+var gljTypeSchema = mongoose.Schema({
+    repositoryId: Number,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+    Name: String
+});
+
+var gljSchema = mongoose.Schema({
+    repositoryId: Number,
+    ID:Number,
+    //以下是基于已有access库
+    code: String,
+    name: String,
+    specs: String,
+    unit: String,
+    basePrice: Number,
+    gljType: Number
+});
+var gljTypeModel = db.model("gljType",gljTypeSchema, "gljType");
+var gljItemModel = db.model("gljRepository",gljSchema, "gljRepository");
+var counter = require('../../../public/counter/counter');
+
+var gljItemDAO = function(){};
+gljItemDAO.prototype.getGljTypes = function(repositoryId, callback){
+    gljTypeModel.find({"repositoryId": repositoryId},function(err,data){
+        if(err) callback(true, "获取工料机类型错误!", "")
+        else callback(false,"获取工料机类型", data);
+    })
+};
+
+gljItemDAO.prototype.getGljItemsByRep = function(repositoryId,callback){
+    gljItemModel.find({"repositoryId": repositoryId},function(err,data){
+        if(err) callback(true, "获取工料机错误!", "")
+        else callback(false,"获取工料机", data);
+    })
+};
+
+gljItemDAO.prototype.getGljItem = function(repositoryId, code, callback){
+    gljItemModel.find({"repositoryId": repositoryId, "code": code},function(err,data){
+        if(err) callback(true, "获取工料机错误!", "")
+        else callback(false,"获取工料机", data);
+    })
+};
+
+module.exports = new gljItemDAO();
+

+ 7 - 1
modules/rationRepository/models/rationItem.js

@@ -7,6 +7,11 @@ var db = dbm.getCfgConnection("rationRepository")
 var async = require("async");
 var async = require("async");
 var Schema = mongoose.Schema;
 var Schema = mongoose.Schema;
 
 
+var rationGljItemSchema = mongoose.Schema({
+    gljId: Number,
+    consumeAmt: Number,
+    proportion: Number //配合比,暂时无需使用,默认0
+});
 var rationItemSchema = mongoose.Schema({
 var rationItemSchema = mongoose.Schema({
     ID:Number,
     ID:Number,
     //以下是基于已有access库
     //以下是基于已有access库
@@ -16,7 +21,8 @@ var rationItemSchema = mongoose.Schema({
     basePrice: Number,
     basePrice: Number,
     sectionId: Number,
     sectionId: Number,
     caption: String,
     caption: String,
-    feeType: Number
+    feeType: Number,
+    rationGljList: [rationGljItemSchema]
 });
 });
 var rationItemModel = db.model("rationItems",rationItemSchema, "rationItems")
 var rationItemModel = db.model("rationItems",rationItemSchema, "rationItems")
 var counter = require('../../../public/counter/counter');
 var counter = require('../../../public/counter/counter');

+ 4 - 425
web/rationLibEditor/dinge.html

@@ -882,10 +882,9 @@
     <script type="text/javascript" src="/web/rationLibEditor/js/ration.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/ration.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/rationGLJ.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/rationGLJ.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
-    <SCRIPT type="text/javascript">
-/*var rationName = getQueryString("rationname");*/
-var treeObj;
-var setting = {
+    <script type="text/javascript">
+
+        var setting = {
     view: {
     view: {
         //	showIcon: showIconForTree,//已存在*/
         //	showIcon: showIconForTree,//已存在*/
         addHoverDom: zTreeOprObj.addHoverDom,
         addHoverDom: zTreeOprObj.addHoverDom,
@@ -923,427 +922,7 @@ var setting = {
         onRename: zTreeOprObj.onRename
         onRename: zTreeOprObj.onRename
     }
     }
 };
 };
-var log, className = "dark";
-var properties = {
-}
-//点击树获取定额
-function SectionClick(event,treeId,treeNode){
-    var sectionID = treeNode.id;
-    properties.selectedSection =sectionID
-    getRationItems(sectionID);
-}
-
-function selectAll() {
-    var zTree = $.fn.zTree.getZTreeObj("rationChapterTree");
-    zTree.setting.edit.editNameSelectAll =  $("#selectAll").attr("checked");
-}
-
-
-//新增定额事件
-$("#mkadd").click(function(){
-    var section = treeObj.getSelectedNodes();
-    if(!section.length){
-        alert("请选择需要添加定额的章节!")
-        return;
-    }
-})
-$("#mkaddglj").click(function() {
-    var s = $("#gljparam").val()
-    if (!s) {
-        alert("请选择需要添加工料机的定额!")
-        return;
-    }
-})
-$("#rationAdd").click(function(){
-    var section = treeObj.getSelectedNodes();
-    var rationItem = {};
-    var code,name,danwei,jijia,xsname,qfzy;
-    code = $("#code").val();name = $("#name").val();danwei=$("#danwei").val();jijia = $("#jijia").val();xsname = $("#xsname").val();qfzy=$("#qfzy").val();
-    rationItem.RationCode = code;
-    rationItem.RationName = name;
-    rationItem.Unit = danwei;
-    rationItem.BasePrice = Number(jijia);
-    rationItem.SectionID = section[0].id;
-    rationItem.ContentID = 0;
-    rationItem.Caption = xsname;
-    rationItem.FeeType = Number(qfzy)
-    saveRationItem(rationItem);
-/*    bindRationDelete()
-    bindRationClick();*/
-})
-//保存定额条目Ajax函数
-function saveRationItem(obj){
-    var rationItem = JSON.stringify(obj)
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/rationLibEditor/saveRationItem",
-        data:{"rationName":rationName,"rationItem":rationItem},
-        dataType:"json",
-        cache:false,
-        timeout:1000,
-        success:function(result){
-            getRationItems(properties.selectedSection);
-        },
-        error: function(jqXHR, textStatus, errorThrown){
-          var err = JSON.parse(jqXHR.responseText);
-            alert(err.error);
-        }
-    })
-}
-//获取定额条目Ajax函数
-function getRationItems(sectionID){
-    $("#rationTbody").html("")
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/ration/getRationsBySectionID",
-        data:{"rationName": rationName,"sectionID": sectionID},
-        dataType:"json",
-        cache:false,
-        timeout:1000,
-        success:function(result){
-            if(result){
-                showRationItems(result.data);
-            }
-
-        },
-        error:function(){
-        }
-    })
-}
-//显示定额条目
-function showRationItems(data){
-    //var RationJSONStr = JSON.stringify(data);
-    var spread = $("#rationItemsSheet").data("workbook");
-    spread.fromJSON(data);
-
-}
-//绑定点击定额号
-function bindRationClick(){
-    var tr = $("#rationTbody tr");
-    var td = $("td:eq(1)",tr);
-    td.each(function() {
-        var a;
-        a = $('a', $(this));
-        var str = a.text();
-        a.click(function(){
-            $("#gljparam").val(str);
-            properties.selectedRation = str;
-            getRationGLJItems(str)
-        })
-        })
-}
-//获取定额工料机
-function getRationGLJItems(str){
-    var GLJTags = [];
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/ration/getRationGLJItems",
-        async: false,
-        data:{"rationName": rationName,"rationCode":str},
-        dataType:"json",
-        cache:false,
-        timeout:1000,
-        success:function(result,status){
-            if(result){
-                var rationGLJs = result.data;
-                for(var i=0;i<rationGLJs.length;i++){
-                    var TagItem = {};
-                    TagItem.dexh = rationGLJs[i].Amount;
-                    var gljCode = rationGLJs[i].GLJCode;
-                    $.ajax({
-                        type:"POST",
-                        url:"http://localhost:6060/ration/getGLJItem",
-                        async: false,
-                        data:{"rationName": rationName,"GLJCode":gljCode},
-                        dataType:"json",
-                        cache:false,
-                        timeout:1000,
-                        success:function(result1){
-                            TagItem.GLJ = result1.data[0];
-                            GLJTags[i] = TagItem;
-                        },
-                        error:function(){
-
-                        }
-                    })
-                }
-            }
-
-        },
-        error:function(){
-        }
-    })
-    showRationGLJ(GLJTags)
-
-}
-//为每条定额工料机绑定删除事件
-function bindRationGLJDelete(){
-    $("#rationGLJTbody tr").each(function() {
-        var td7, a1,td1,a2;
-        td7 = $("td:eq(7)", $(this));
-        td1 = $("td:eq(1)", $(this));
-        var str = td1.text();
-        a2 = $("a:eq(1)",td7);
-        a2.click(function(){
-            $("#delType").val("rationGLJ");
-            $("#delParam").val(str);
-        })
-    })
-}
-//为每条定额绑定编辑事件
-function bindRationEdit(){
-    $("#rationTbody tr").each(function() {
-        var td7,td1,a2;
-        td7 = $("td:eq(7)", $(this));
-        td1 = $("td:eq(1)", $(this));
-        var str = td1.text();
-        a2 = $("a:eq(0)",td7);
-        a2.click(function(){
-            properties.Edit = "ration";
-            properties.EditParam =str;
-            $.ajax({
-                type:"POST",
-                url:"http://localhost:6060/ration/getRationByCode",
-                data:{"rationName": rationName,"RationCode":str},
-                dataType:"json",
-                cache:false,
-                timeout:5000,
-                success:function(result){
-                    var ration = result.data[0];
-                    $("#ERcode").val(ration.RationCode).attr("disabled",true);
-                    $("#ERname").val(ration.RationName);
-                    $("#ERdanwei").find("option:selected").text(ration.Unit);
-                    $("#ERjijia").val(ration.BasePrice).attr("disabled",true);
-                    $("#ERxsmc").val(ration.Caption);
-                    $("#ERqfzy").val(ration.FeeType);
-                },
-                error:function(err){
-                }
-            })
-
-        })
-    })
-}
-//绑定定额消耗编辑事件
-function bindRGLJAmountEdit(){
-    $("#rationGLJTbody tr").each(function() {
-        var td5, td1, a2,amount;
-        var value = $("#gljparam").val();
-        td5 = $("td:eq(5)", $(this));
-        td1 = $("td:eq(1)", $(this));
-        var str = td1.text();
-        a2 = $("input", td5);
-
-        a2.blur(function () {
-            if(isNaN(a2.val()))
-            alert("请输入数值!");
-            else
-            $.ajax({
-                type:"POST",
-                url:"http://localhost:6060/ration/editRGLJAmount",
-                dataType:"json",
-                data:{"rationName":rationName,"GLJCode":str,"RationCode":value,"Amount":Number(a2.val())},
-
-                cache:false,
-                timeout:50000,
-                success:function(result){
-                  //  getRationItems(properties.selectedSection);
-                    getRationGLJItems(value);
-                },
-                error:function(iqXHR,textStatus,errorThrown){
-                    alert("error "+textStatus+" "+errorThrown);
-                }
-            })
-        })
-    })
-
-}
-$("#Rbianji").click(function(){//设置定额号不可编辑
-
-    var ERcode,ERname,ERdanwei,ERjijia,ERxsmc,ERqfzy,ration={};
-    ERcode=$("#ERcode").val();
-    ERname=$("#ERname").val();
-    ERdanwei=$("#ERdanwei").val();
-    ERjijia=$("#ERjijia").val();
-    ERxsmc = $("#ERxsmc").val();
-    ERqfzy=$("#ERqfzy").val();
-    ration.RationCode = ERcode;
-    ration.RationName = ERname;
-    ration.Unit = ERdanwei;
-    ration.BasePrice = Number(ERjijia);
-    ration.SectionID = properties.selectedSection;
-    ration.ContentID = 0;
-    ration.Caption = ERxsmc;
-    ration.FeeType =Number(ERqfzy);
-    var rationItem = JSON.stringify(ration);
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/ration/editRationItem",
-        dataType:"json",
-        data:{"rationName":rationName,"RationCode":properties.EditParam,"newRation":rationItem},
-        cache:false,
-        timeout:50000,
-        success:function(result){
-            getRationItems(properties.selectedSection);
-        },
-        error:function(iqXHR,textStatus,errorThrown){
-            alert("error "+textStatus+" "+errorThrown);
-        }
-    })
-})
-//为每条定额绑定删除事件
-function bindRationDelete(){
-    $("#rationTbody tr").each(function() {
-        var td7, a1,td1,a2;
-        td7 = $("td:eq(7)", $(this));
-        td1 = $("td:eq(1)", $(this));
-        var str = td1.text();
-        a2 = $("a:eq(1)",td7);
-        a2.click(function(){
-            $("#delType").val("ration");
-            $("#delParam").val(str);
-        })
-    })
-}
-//删除定额或定额工料机
-$("#shanchu").click(function(){
-    var type = $("#delType").val();
-    var value = $("#delParam").val();
-    switch(type){
-        case "ration":
-        {$.ajax({
-                type:"POST",
-                url:"http://localhost:6060/ration/deleteRation",
-                data:{"rationName": rationName,"type":type,"value":value},
-                async:false,
-                dataType:"json",
-                cache:false,
-                timeout:1000,
-                success:function(result){
-                    getRationItems(properties.selectedSection);
-                    getRationGLJItems(value)
-                },
-                error:function(){
-                    alert("nima")
-                }
-            })
-            break;}
-        case "rationGLJ":
-        { $.ajax({
-                type:"POST",
-                url:"http://localhost:6060/ration/deleteRationGLJ",
-                data:{"rationName": rationName,"type":type,"value":value},
-                async:false,
-                dataType:"json",
-                cache:false,
-                timeout:1000,
-                success:function(result){
-                   var s =  $("#gljparam").val();
-                    getRationGLJItems(s)
-                },
-                error:function(){
-                    alert("nima")
-                }
-            })
-            break;}
-    }
-
-})
-//显示定额工料机条目
-function showRationGLJ(obj){
-    $("#bglj tbody tr").html("");
-    var Baseprice = 0;
-    for(var i=0;i<obj.length;i++){
-        var code,name,danwei,jijia,dexh,leixing;
-        code = obj[i].GLJ.GLJCode;
-        name = obj[i].GLJ.GLJName;
-        danwei = obj[i].GLJ.Unit;
-        jijia = obj[i].GLJ.BasePrice;
-        dexh = obj[i].dexh;
-        Baseprice = Baseprice + Number(jijia)*Number(dexh);
-        leixing =obj[i].GLJ.Type;
-        var $tr = $('<tr><td></td><td></td><td></td><td></td><td></td><td><input></td><td></td><td> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td> </tr>')
-        //<a href="javacript:void(0);" data-toggle="modal" data-target="#editBglj" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
-        var td0,td1,td2,td3,td4,td5,td6,a;
-        td0 = $("td:eq(0)",$tr), td1 = $("td:eq(1)",$tr);td2 = $("td:eq(2)",$tr);td3 = $("td:eq(3)",$tr);td4 = $("td:eq(4)",$tr);td5 = $("td:eq(5)",$tr);a=$("input",td5);td6 = $("td:eq(6)",$tr);
-        td0.text(i); td1.text(code);td2.text(name);td3.text(danwei);td4.text(jijia);a.val(dexh);td6.text(leixing)
-        $tr.appendTo("#bglj tbody");
-    }
-    var s = $("#gljparam").val()
-    $("#rationTbody tr").each(function(){
-        var td = $("td:eq(1)",$(this))
-        var s1 = td.text();
-
-        if ( s  == s1){
-            td.next().next().next().text(Baseprice.toFixed(2));
-            $.ajax({
-                type:"POST",
-                url:"http://localhost:6060/ration/setRationBasePrice",
-                data:{"rationName": rationName,"rationCode":s,"BasePrice":Baseprice.toFixed(2)},
-                dataType:"json",
-                cache:false,
-                timeout:1000,
-                success:function(result){
-
-                },
-                error:function(err){
-
-                }
-            })
-        }
-
-    })
-    bindRGLJAmountEdit();
-    bindRationGLJDelete();
-}
-//添加定额工料机ajax函数
-$("#bt-glj").click(function(){
-    var rationGLJ = {};
-    rationGLJ.RationCode = $("#gljparam").val();
-    rationGLJ.GLJCode = $("#bt-inputCode").val();
-    rationGLJ.Amount =Number($("#gljxh").val());
-    rationGLJ.Type = Number($("#gljlx").val()) ;
-    var rationglj = JSON.stringify(rationGLJ);
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/ration/saveRationGLJ",
-        data:{"rationName": rationName,"rationGLJ":rationglj},
-        dataType:"json",
-        cache:false,
-        timeout:1000,
-        success:function(result){
-           getRationGLJItems($("#gljparam").val())
-        },
-        error:function(err){
-            var error = JSON.parse(err.responseText);
-            alert(error.error);
-        }
-    })
-})
-//输入工料机编号自动获取工料机信息
-$("#bt-inputCode").blur(function(){
-    var gljCode = $("#bt-inputCode").val();
-    $.ajax({
-        type:"POST",
-        url:"http://localhost:6060/ration/getGLJByCode",
-        data:{"rationName": rationName,"gljCode":gljCode},
-        dataType:"json",
-        cache:false,
-        timeout:5000,
-        success:function(result){
-          var glj = result.data[0];
-            $("#gljName").val(glj.GLJName).attr("disabled",true);
-            $("#gljdw").find("option:selected").text(glj.Unit).attr("disabled","disabled");
-            $("#gljdj").val(glj.BasePrice).attr("disabled",true);
-            $("#gljlx").val(glj.Type).attr("disabled","disabled");
-        },
-        error:function(err){
-            var error = JSON.parse(err.responseText);
-            alert(error.error);
-        }
-    })
-})
-  	</SCRIPT>
+  	</script>
 </body>
 </body>
 <script type="text/javascript">
 <script type="text/javascript">
     autoFlashHeight();
     autoFlashHeight();

+ 17 - 17
web/rationLibEditor/js/chapterTree.js

@@ -21,6 +21,7 @@ var pageOprObj = {
     }
     }
 }
 }
 var zTreeOprObj = {
 var zTreeOprObj = {
+    treeObj: null,
     getRationTree: function(){
     getRationTree: function(){
         var me = this;
         var me = this;
         $.ajax({
         $.ajax({
@@ -41,19 +42,19 @@ var zTreeOprObj = {
         })
         })
     },
     },
     createRationTree: function(sourceData){
     createRationTree: function(sourceData){
-        var treeArr = tree_Data_Helper.buildTreeNodeDirectly(sourceData);
+        var me = zTreeOprObj, treeArr = tree_Data_Helper.buildTreeNodeDirectly(sourceData);
         for (var i = 0; i < treeArr.length; i++) {
         for (var i = 0; i < treeArr.length; i++) {
             if (treeArr[i].ParentID = -1) {
             if (treeArr[i].ParentID = -1) {
                 //
                 //
             }
             }
         }
         }
-        treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, treeArr);
-        treeObj.expandAll(true);
+        me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, treeArr);
+        me.treeObj.expandAll(true);
     },
     },
     addRootNode: function() {
     addRootNode: function() {
-        var me = this, rawNode = {ParentID: -1, NextSiblingID: -1, name: "新增节点"}, lastNodeId = -1;
-        if (treeObj) {
-            var rootNodes = treeObj.getNodes();
+        var me = zTreeOprObj, rawNode = {ParentID: -1, NextSiblingID: -1, name: "新增节点"}, lastNodeId = -1;
+        if (me.treeObj) {
+            var rootNodes = me.treeObj.getNodes();
             if (rootNodes.length > 0) {
             if (rootNodes.length > 0) {
                 lastNodeId = rootNodes[rootNodes.length - 1].ID;
                 lastNodeId = rootNodes[rootNodes.length - 1].ID;
             }
             }
@@ -62,10 +63,10 @@ var zTreeOprObj = {
             if (!(err)) {
             if (!(err)) {
                 var newNodes = [], isSilent = false;
                 var newNodes = [], isSilent = false;
                 newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:false, items:[]});
                 newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:false, items:[]});
-                if (treeObj) {
-                    treeObj.addNodes(null, -1, newNodes, isSilent);
+                if (me.treeObj) {
+                    me.treeObj.addNodes(null, -1, newNodes, isSilent);
                 } else {
                 } else {
-                    treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
+                    me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
                 }
                 }
             }
             }
         });
         });
@@ -87,7 +88,6 @@ var zTreeOprObj = {
         })
         })
     },
     },
     beforeRename: function(treeId, treeNode, newName, isCancel) {
     beforeRename: function(treeId, treeNode, newName, isCancel) {
-        className = (className === "dark" ? "":"dark");
         if (newName.length == 0) {
         if (newName.length == 0) {
             return false;
             return false;
         }
         }
@@ -134,11 +134,11 @@ var zTreeOprObj = {
         return true;
         return true;
     },
     },
     onRemove: function(e, treeId, treeNode){
     onRemove: function(e, treeId, treeNode){
-        var pNode = treeObj.getNodeByTId(treeNode.parentTId);
+        var me = zTreeOprObj, pNode = me.treeObj.getNodeByTId(treeNode.parentTId);
         if (pNode && pNode.items && pNode.items.length == 0) {
         if (pNode && pNode.items && pNode.items.length == 0) {
             pNode.isParent = false;
             pNode.isParent = false;
-            treeObj.refresh();
-            //treeObj.updateNode(pNode, false); //这方法有后遗症,多次操作后会造成节点新增子节点时,父节点icon显示不正确
+            me.treeObj.refresh();
+            //me.treeObj.updateNode(pNode, false); //这方法有后遗症,多次操作后会造成节点新增子节点时,父节点icon显示不正确
         }
         }
     },
     },
     beforeDrag: function(treeId, treeNodes) {
     beforeDrag: function(treeId, treeNodes) {
@@ -174,7 +174,7 @@ var zTreeOprObj = {
         }
         }
     },
     },
     addHoverDom: function(treeId, treeNode) {
     addHoverDom: function(treeId, treeNode) {
-        var sObj = $("#" + treeNode.tId + "_span");
+        var me = zTreeOprObj, sObj = $("#" + treeNode.tId + "_span");
         //if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0||(treeNode.level==2)) return;
         //if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0||(treeNode.level==2)) return;
         if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
         if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
         var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='add node' onfocus='this.blur();'></span>";
         var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='add node' onfocus='this.blur();'></span>";
@@ -190,10 +190,10 @@ var zTreeOprObj = {
                     var newNodes = [], isSilent = false;
                     var newNodes = [], isSilent = false;
                     newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, name:"新增子节点",isParent:false, items:[]});
                     newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, name:"新增子节点",isParent:false, items:[]});
                     treeNode.isParent = true;
                     treeNode.isParent = true;
-                    if (treeObj) {
-                        treeObj.addNodes(treeNode, -1, newNodes, isSilent);
+                    if (me.treeObj) {
+                        me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
                     } else {
                     } else {
-                        treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
+                        me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
                     }
                     }
                 }
                 }
             });
             });