Browse Source

统一使用uuid

zhongzewei 7 năm trước cách đây
mục cha
commit
4d8a626c5e

+ 3 - 3
modules/main/models/bills.js

@@ -16,9 +16,9 @@ let projectModel = require('../../pm/models/project_schema');
 
 
 let billsSchema = new Schema({
-    ID: Number,
-    ParentID: Number,
-    NextSiblingID: Number,
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
     projectID: Number,
     serialNo: Number,
     chapterID: Number,

+ 2 - 2
modules/main/models/glj.js

@@ -16,8 +16,8 @@ var GLJSchema = new Schema({
     ID: Number,
     GLJID: Number,
     rGLJID: Number,
-    rationID: Number,
-    billsItemID: Number,
+    rationID: String,
+    billsItemID: String,
     projectID: Number,
     orgRQuantity: String, //Decimal
     rQuantity: String, //Decimal

+ 2 - 3
modules/main/models/ration.js

@@ -29,9 +29,9 @@ var rationAssItemSchema = mongoose.Schema({
 // 定额、量价、工料机定额 合并存储
 let rationSchema = new Schema({
     // 公用属性部分
-    ID: Number,
+    ID: String,
     projectID: Number,
-    billsItemID: Number,
+    billsItemID: String,
     serialNo: Number,
     code: String,
     name: String,
@@ -93,7 +93,6 @@ class rationModel extends baseModel {
     save (user_id, datas, callback) {
         let functions = [];
         let data;
-
         function saveOne(doc) {
             return function (cb) {
                 switch (doc.updateType) {

+ 10 - 0
modules/pm/controllers/new_proj_controller.js

@@ -6,6 +6,7 @@ let billsData = require('../../main/models/bills');
 let projCounter = require('../../main/models/proj_counter_model');
 let projSetting = require('../../main/models/proj_setting_model');
 let async = require('async');
+const uuidV1 = require('uuid/v1');
 
 import BillsTemplateModel from "../models/templates/bills_template_model";
 import EngineeringLibModel from "../../users/models/engineering_lib_model";
@@ -18,8 +19,17 @@ module.exports = {
                 let billsTemplateModel = new BillsTemplateModel();
                 let templateData = JSON.stringify(await billsTemplateModel.getTemplateDataForNewProj(property.valuation, property.engineering));
                 let billsDatas = JSON.parse(templateData);
+                let uuidMaping = Object.create(null);
+                uuidMaping['-1'] = -1;
+                //建立uuid-ID映射
+                for(let bill of billsDatas){
+                    uuidMaping[bill.ID] = uuidV1();
+                }
                 billsDatas.forEach(function (template) {
                     template.projectID = newProjID;
+                    template.ID = uuidMaping[template.ID] ? uuidMaping[template.ID] : -1;
+                    template.ParentID = uuidMaping[template.ParentID] ? uuidMaping[template.ParentID] : -1;
+                    template.NextSiblingID = uuidMaping[template.NextSiblingID] ? uuidMaping[template.NextSiblingID] : -1;
                 });
                 billsData.insertData(billsDatas, callback);
             },

+ 2 - 2
modules/ration_glj/models/quantity_detail.js

@@ -8,8 +8,8 @@ var mongoose = require('mongoose'),
 var quantity_detail = new Schema({
     ID:String,
     projectID: Number,
-    rationID:Number,
-    billID:Number,
+    rationID:String,
+    billID:String,
     name:String,
     regex:String,
     result:Number,

+ 1 - 1
modules/ration_glj/models/ration_coe.js

@@ -17,7 +17,7 @@ var coeListSchema = mongoose.Schema({
     ID: String,                         // 系数ID(流水号ID)
     name: String,                       // 名称
     content: String,                    // 说明
-    rationID:Number,
+    rationID:String,
     projectID:Number,
     coeID:Number,
     isAdjust:Number, //0不调整,1调整

+ 2 - 2
modules/ration_glj/models/ration_glj.js

@@ -9,7 +9,7 @@ var ration_glj = new Schema({
     GLJID:Number,
     repositoryId:Number,
     projectID: Number,
-    rationID:Number,
+    rationID:String,
     projectGLJID:Number,
     name:String,
     code:String,
@@ -22,7 +22,7 @@ var ration_glj = new Schema({
     specs:String,
     unit:String,
     shortName:String,
-    billsItemID: Number,
+    billsItemID: String,
     type:Number,
     // 调整系数ID
     adjCoe: Number,

+ 2 - 2
modules/ration_glj/models/ration_glj_temp.js

@@ -41,9 +41,9 @@ var rationAssItemSchema = mongoose.Schema({
 
 let rationSchema = new Schema({
     // 公用属性部分
-    ID: Number,
+    ID: String,
     projectID: Number,
-    billsItemID: Number,
+    billsItemID: String,
     serialNo: Number,
     code: String,
     name: String,

+ 7 - 5
public/web/id_tree.js

@@ -519,12 +519,12 @@ var idTree = {
             }
             return node;
         };
-        Tree.prototype.getInsertData = function (parentID, nextSiblingID) {
+        Tree.prototype.getInsertData = function (parentID, nextSiblingID, uid = null) {
             var data = [];
-            var newID = this.newNodeID();
+            var newID = uid ? uuid.v1() : this.newNodeID();
             var parent = parentID === -1 ? null : this.nodes[this.prefix + parentID];
             var nextSibling = nextSiblingID === -1 ? null: this.nodes[this.prefix + nextSiblingID];
-            if (newID !== -1) {
+            if (newID != -1) {
                 data.push({type: 'new', data: this.getDataTemplate(newID, parent ? parent.getID() : this.setting.rootId, nextSibling ? nextSibling.getID() : this.setting.rootId)});
 
                 if (nextSibling && nextSibling.preSibling) {
@@ -537,7 +537,7 @@ var idTree = {
             }
             return data;
         };
-        Tree.prototype.insertByData = function (data, parentID, nextSiblingID) {
+        Tree.prototype.insertByData = function (data, parentID, nextSiblingID, uid = null) {
             var parent = parentID === -1 ? null : this.nodes[this.prefix + parentID];
             var nextSibling = nextSiblingID === -1 ? null : this.nodes[this.prefix + nextSiblingID];
             var node = this.nodes[this.prefix + data[this.setting.id]];
@@ -552,7 +552,9 @@ var idTree = {
                 }
                 this.nodes[this.prefix +  data[this.setting.id]] = node;
                 tools.sortTreeItems(this);
-                this.maxNodeID( data[this.setting.id]);
+                if(!uid){
+                    this.maxNodeID( data[this.setting.id]);
+                }
                 return node;
             }
         };

+ 4 - 4
web/building_saas/main/js/controllers/project_controller.js

@@ -78,7 +78,7 @@ ProjectController = {
             } else {
                 newSource = project.Bills.insertBills(parentID, nextSiblingID);
             }
-            newNode = project.mainTree.insert(nodeParentID, nodeNextSiblingID);
+            newNode = project.mainTree.insert(nodeParentID, nodeNextSiblingID, newSource.data.ID);
         } else {
             alert('不可添加清单');
         }
@@ -137,7 +137,7 @@ ProjectController = {
         let m_parent = parent==null?-1:parent.getID();
 
         newSource = project.Bills.insertSpecialBill(b_parent, b_nexID,isUserAdd,type);
-        newNode = project.mainTree.insert(m_parent,m_nexID);
+        newNode = project.mainTree.insert(m_parent,m_nexID, newSource.data.ID);
         if (newNode) {
             newNode.source = newSource;
             newNode.sourceType = project.Bills.getSourceType();
@@ -167,7 +167,7 @@ ProjectController = {
                 } else {
                     newSource = project.Ration.insertRation(selected.source.getID(),null, rationType);
                 }
-                newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
+                newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID(), newSource.ID);
             }
         } else if (selected.sourceType === project.Ration.getSourceType()) {
             if (std) {
@@ -176,7 +176,7 @@ ProjectController = {
             } else {
                 newSource = project.Ration.insertRation(selected.source[project.masterField.ration], selected.source, rationType);
             }
-            newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
+            newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID(), newSource.ID);
         };
         if (newNode) {
             newNode.source = newSource;

+ 22 - 6
web/building_saas/main/js/models/bills.js

@@ -85,6 +85,7 @@ var Bills = {
 
         // prototype用于定义public方法
         bills.prototype.loadData = function (datas) {
+            parseIDs(datas);
             this.datas = datas;
             // generate Fees & Flags Index, For View & Calculate
             this.datas.forEach(function (data) {
@@ -151,7 +152,7 @@ var Bills = {
             return updateData;
         };
         bills.prototype.insertSpecialBill=function(parentId, nextSiblingId,isUserAdd,type){
-            var insertData = this.tree.getInsertData(parentId, nextSiblingId);
+            var insertData = this.tree.getInsertData(parentId, nextSiblingId, true);
             var that = this, newData = null;
             insertData.forEach(function (data) {
                 if (data.type === idTree.updateType.new) {
@@ -167,10 +168,10 @@ var Bills = {
             //project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
 
             this.datas.push(newData);
-            return this.tree.insertByData(newData,parentId, nextSiblingId);
+            return this.tree.insertByData(newData,parentId, nextSiblingId, true);
         };
         bills.prototype.insertBills = function (parentId, nextSiblingId) {
-            var insertData = this.tree.getInsertData(parentId, nextSiblingId);
+            var insertData = this.tree.getInsertData(parentId, nextSiblingId, true);
             var that = this, newData = null;
             insertData.forEach(function (data) {
                 if (data.type === idTree.updateType.new) {
@@ -183,10 +184,10 @@ var Bills = {
             //project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
 
             this.datas.push(newData);
-            return this.tree.insertByData(newData,parentId, nextSiblingId);
+            return this.tree.insertByData(newData,parentId, nextSiblingId, true);
         };
         bills.prototype.insertStdBills = function (parentId, nextSiblingId, stdBillsData) {
-            var insertData = this.tree.getInsertData(parentId, nextSiblingId);
+            var insertData = this.tree.getInsertData(parentId, nextSiblingId, true);
             var newData = null, that = this;
             insertData.forEach(function (data) {
                 if (data.type === idTree.updateType.new) {
@@ -212,7 +213,7 @@ var Bills = {
                 [ tools.coverseTreeUpdateData(insertData, this.project.ID()), this.getCounterData()]);
 
             this.datas.push(newData);
-            return this.tree.insertByData(newData, parentId, nextSiblingId);
+            return this.tree.insertByData(newData, parentId, nextSiblingId, true);
         };
         bills.prototype.deleteBills = function (node) {
             let deleteNode = function (node) {
@@ -445,3 +446,18 @@ function getRootFixedNode(node) {
         }
     }
 }
+
+//转换ID '-1' to -1
+function parseIDs(datas){
+    for(let data of datas){
+        if(isDef(data.ID) && data.ID === '-1'){
+            data.ID = -1;
+        }
+        if(isDef(data.ParentID) && data.ParentID === '-1'){
+            data.ParentID = -1;
+        }
+        if(isDef(data.NextSiblingID) && data.NextSiblingID === '-1'){
+            data.NextSiblingID = -1;
+        }
+    }
+}

+ 7 - 4
web/building_saas/main/js/models/cache_tree.js

@@ -312,8 +312,11 @@ var cacheTree = {
             }
         };
 
-        Tree.prototype.addNode = function (parent, nextSibling) {
-            var newNode = new Node(this, this.newNodeID());
+        Tree.prototype.addNode = function (parent, nextSibling, id) {
+            if(!isDef(id) || id == -1){
+                return null;
+            }
+            var newNode = new Node(this, id);
             this.nodes[this.prefix + newNode.getID()] = newNode;
             if (nextSibling) {
                 tools.addNodes(this, parent, [newNode], nextSibling.siblingIndex());
@@ -352,11 +355,11 @@ var cacheTree = {
             return iCount;
         };
 
-        Tree.prototype.insert = function (parentID, nextSiblingID) {
+        Tree.prototype.insert = function (parentID, nextSiblingID, id) {
             var parent = !parentID || parentID === -1 ? null : this.nodes[this.prefix + parentID];
             var nextSibling = !nextSiblingID || nextSiblingID === -1 ? null: this.nodes[this.prefix + nextSiblingID];
 
-            var newNode = this.addNode(parent, nextSibling);
+            var newNode = this.addNode(parent, nextSibling, id);
             this.sortTreeItems();
 
             return newNode;

+ 28 - 33
web/building_saas/main/js/models/calc_base.js

@@ -50,14 +50,8 @@ let cbTools = {
         return null;
     },
     //通过ID获取节点
-    getNodeByID: function (items, ID) {
-        ID = parseInt(ID);
-        for(let i = 0, len = items.length; i < len; i++){
-            if(items[i]['data']['ID'] === ID){
-                return items[i];
-            }
-        }
-        return null;
+    getNodeByID: function (ID) {
+        return this.isDef(calcBase.project.mainTree.nodes['id_' + ID]) ? calcBase.project.mainTree.nodes['id_' + ID] : null;
     },
     //获取该节点所有父节点
     getParents: function (node) {
@@ -88,21 +82,21 @@ let cbTools = {
             return rst;
         }
         //获取表达式中的基数和行引用
-        let figureF = cbParser.getFigureF(cbParser.getFigure(exp), cbParser.getXNum(cbParser.getFArr(exp)));
+        let figureF = cbParser.getFigureF(cbParser.getFigure(exp), cbParser.getUID(cbParser.getFIDArr(exp)));
         for(let i = 0, len = figureF.length; i < len; i++){
             let figure = figureF[i];
             if(figure.type === 'base' && cbTools.isDef(calcBase.baseFigures[figure.value])){
                 let bill = calcBase.baseFigures[figure.value]['fixedBill']['bill'];
                 if(this.isDef(bill) && ids.indexOf(bill.ID) === -1){
-                    let node = getNodeByID(bill.ID);
+                    let node = this.getNodeByID(bill.ID);
                     if(this.isDef(node)){
                         ids.push(node.data.ID);
                         rst.push(node);
                     }
                 }
             }
-            else if(figure.type === 'row'){
-                let node = this.getBillByRow(calcBase.project.mainTree.items, figure.value - 1);
+            else if(figure.type === 'id'){
+                let node = this.getNodeByID(figure.value);
                 if(this.isDef(node) && ids.indexOf(node.data.ID) === -1){
                     ids.push(node.data.ID);
                     rst.push(node);
@@ -110,15 +104,6 @@ let cbTools = {
             }
         }
         return rst;
-        function getNodeByID(ID){
-            let items = calcBase.project.mainTree.items;
-            for(let i = 0, len = items.length; i < len; i++){
-                if(items[i]['data']['ID'] === ID){
-                    return items[i];
-                }
-            }
-            return null;
-        }
     },
     //需要用到计算基数的时候,先找出所有的固定清单,避免每个基数都要去遍历寻找清单
     setFixedBills: function (project, billsObj, fixedFlag) {
@@ -243,7 +228,7 @@ let cbTools = {
                     block.push(calcBase.baseFigures[bases[i]['value']]['fixedBill']['bill']['ID']);
                 }
                 else if(bases[i]['type'] === 'id'){
-                    let node = cbTools.getNodeByID(calcBase.project.mainTree.items, bases[i]['value']);
+                    let node = cbTools.getNodeByID(bases[i]['value']);
                     if(cbTools.isDef(node)){
                         block.push(node.data.ID);
                     }
@@ -254,7 +239,7 @@ let cbTools = {
         function getBase(node){
             if(node && node.children.length === 0){
                 if(cbTools.isDef(node.data.calcBase) && node.data.calcBase !== ''){
-                    let figureF = cbParser.getFigureF(cbParser.getFigure(node.data.calcBase), cbParser.getXNum(cbParser.getFIDArr(node.data.calcBase)));
+                    let figureF = cbParser.getFigureF(cbParser.getFigure(node.data.calcBase), cbParser.getUID(cbParser.getFIDArr(node.data.calcBase)));
                     tempBases = tempBases.concat(figureF);
                 }
             }
@@ -265,10 +250,10 @@ let cbTools = {
             }
         }
         function getBill(ID){
-            for(let i = 0, len = calcBase.project.mainTree.items.length; i < len; i++){
-                if(calcBase.project.mainTree.items[i].data.ID === ID && calcBase.project.mainTree.items[i].sourceType === calcBase.project.Bills.getSourceType()){
-                    return calcBase.project.mainTree.items[i];
-                }
+            let nodes = calcBase.project.mainTree.nodes;
+            let node = nodes['id_' + ID];
+            if(cbTools.isDef(node) && node.sourceType === calcBase.project.Bills.getSourceType()){
+                return node;
             }
             return null;
         }
@@ -591,7 +576,7 @@ let cbAnalyzer = {
         }
         //用于判断的起始清单ID
         let sIDs = cbTools.getNodeIDs(Array.from(new Set([cbTools.getBaseBill(node)].concat(cbTools.getParents(node)))));
-        let figureF = cbParser.getFigureF(cbParser.getFigure(exp), cbParser.getXNum(cbParser.getFIDArr(exp)));
+        let figureF = cbParser.getFigureF(cbParser.getFigure(exp), cbParser.getUID(cbParser.getFIDArr(exp)));
         for(let i = 0, len = figureF.length; i < len; i++){
             let figure = figureF[i];
             let bill = null;
@@ -599,7 +584,7 @@ let cbAnalyzer = {
                 bill = baseFigures[figure.value]['fixedBill']['bill'];
             }
             else if(figure.type === 'id'){
-                let node = cbTools.getNodeByID(calcBase.project.mainTree.items, figure.value);
+                let node = cbTools.getNodeByID(figure.value);
                 bill = cbTools.isDef(node) ? node.data : null;
             }
             if(cbTools.isDef(bill) && checkStack(getRefStack([bill.ID]), sIDs)){
@@ -687,9 +672,19 @@ let cbParser = {
         let rArr = Array.from(new Set(tempArr));
         return rArr;
     },
+    //获取uuid
+    getUID: function (arr) {
+        let rRex = /[\d,a-z,A-Z,-]{36}/g;
+        let tempArr = [];
+        for(let i = 0, len = arr.length; i < len; i++){
+            tempArr = tempArr.concat(arr[i].match(rRex));
+        }
+        let rArr = Array.from(new Set(tempArr));
+        return rArr;
+    },
     //获取ID引用
     getFIDArr: function (exp) {
-        let fidRex = /@\d+/g;
+        let fidRex = /@[\d,a-z,A-Z,-]{36}/g;
         let fidArr = exp.match(fidRex);
         return cbTools.isDef(fidArr) ? fidArr : [];
     },
@@ -781,7 +776,7 @@ let cbParser = {
         //获得ID引用
         let fidArr = this.getFIDArr(exp);
         for(let i = 0, len = fidArr.length; i < len; i++){
-            let id = this.getXNum([fidArr[i]]);
+            let id = this.getUID([fidArr[i]]);
             if(id.length === 1){
                 let row = cbTools.getRowByID(calcBase.project.mainTree.items, id[0]);
                 if(cbTools.isUnDef(row)){
@@ -840,9 +835,9 @@ let cbCalctor = {
     },
     //ID引用
     ref: function (fExp) {
-        let ID = cbParser.getXNum([fExp]);
+        let ID = cbParser.getUID([fExp]);
         if(ID.length === 1){
-            let node = cbTools.getNodeByID(calcBase.project.mainTree.items, parseInt(ID[0]));
+            let node = cbTools.getNodeByID(ID[0]);
             return cbTools.isDef(node) &&
                     cbTools.isDef(node.data.feesIndex) &&
                     cbTools.isDef(node.data.feesIndex.common) &&

+ 6 - 4
web/building_saas/main/js/models/project.js

@@ -128,7 +128,7 @@ var PROJECT = {
                 var newNode, bj = that.ration_glj.getMainAndEquGLJ(cacheNode.source.ID), i;
                 for(i=0;i<bj.length;i++){
                     that.ration_glj.transferToNodeData(bj[i]);
-                    newNode = that.mainTree.addNode(cacheNode);
+                    newNode = that.mainTree.addNode(cacheNode, null, bj[i].ID);
                     newNode.source = bj[i];
                     newNode.sourceType = that.ration_glj.getSourceType();
                     newNode.data = bj[i];
@@ -138,7 +138,7 @@ var PROJECT = {
             var loadRationNode = function (rations, cacheNode) {
                 var newNode, br = that.Ration.getBillsSortRation(cacheNode.source.getID()), i;
                 for (i = 0; i < br.length; i++) {
-                    newNode = that.mainTree.addNode(cacheNode);
+                    newNode = that.mainTree.addNode(cacheNode, null, br[i].ID);
                     if(br[i].type==rationType.gljRation){
                         br[i]=  that.ration_glj.combineRationAndGLJ(br[i]);
                     }
@@ -164,7 +164,7 @@ var PROJECT = {
             var loadIdTreeNode = function (nodes, parent) {
                 var newNode, i;
                 for (i = 0; i < nodes.length; i++) {
-                    newNode = that.mainTree.addNode(parent);
+                    newNode = that.mainTree.addNode(parent, null, nodes[i].data.ID);
                     newNode.source = nodes[i];
                     newNode.sourceType = that.Bills.getSourceType();
                     newNode.data = nodes[i].data;
@@ -295,7 +295,9 @@ var PROJECT = {
             this.beginUpdate(operation);
             if (Object.prototype.toString.apply(moduleName) === "[object Array]" && Object.prototype.toString.apply(data) === "[object Array]") {
                 moduleName.forEach(function (name, index) {
-                    that.push(moduleName[index], data[index]);
+                    if(name != 'projCounter'){
+                        that.push(moduleName[index], data[index]);
+                    }
                 });
             } else {
                 this.push(moduleName, data);

+ 15 - 7
web/building_saas/main/js/models/ration.js

@@ -35,7 +35,8 @@ var Ration = {
 
             var maxRationID = 0;
             this.getNewRationID = function () {
-                return maxRationID += 1;
+                return uuid.v1();
+                //return maxRationID += 1;
             };
             this.maxRationID = function (maxID) {
                 if (arguments.length === 0) {
@@ -161,12 +162,12 @@ var Ration = {
             var updateData = [];
             if (preRation) {
                 var preIndex = br.indexOf(preRation), i;
-                updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.maxRationID() + 1, billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType)});
+                updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.getNewRationID(), billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType)});
                 for (i = preIndex + 1; i < br.length; i++) {
                     updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(br[i].ID, billsID, i < br.length - 1 ? br[i+1].serialNo : br[i].serialNo + 1, rationType)});
                 }
             } else {
-                updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.maxRationID() + 1, billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType)});
+                updateData.push({updateType: 'ut_create', updateData: this.getTempRationData(this.getNewRationID(), billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType)});
             }
             return updateData;
         };
@@ -181,19 +182,26 @@ var Ration = {
         };
         ration.prototype.insertRation = function (billsID, preRation, rationType) {
             var br = this.getBillsSortRation(billsID);
+            let insertData = this.getInsertRationData(billsID, preRation, rationType);
             this.project.pushNow('insertRation', [this.getSourceType(), this.project.projCounter()],
-                [this.getInsertRationData(billsID, preRation, rationType), this.getCounterData()]);
+                [insertData, this.getCounterData()]);
 
             var newRation = null;
+            let newID = -1;
+            for(let data of insertData){
+                if(data.updateType === 'ut_create'){
+                    newID = data.updateData.ID;
+                }
+            }
             if (preRation) {
                 var preIndex = br.indexOf(preRation), i;
-                newRation = this.getTempRationData(this.getNewRationID(), billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType);
+                newRation = this.getTempRationData(newID, billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1, rationType);
                 this.datas.push(newRation);
                 for (i = preIndex + 1; i < br.length; i++) {
                     br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
                 }
             } else {
-                newRation = this.getTempRationData(this.getNewRationID(), billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType);
+                newRation = this.getTempRationData(newID, billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1, rationType);
                 this.datas.push(newRation);
             }
             return newRation;
@@ -223,7 +231,7 @@ var Ration = {
             });
             this.project.pushNow('insertRation', [this.getSourceType(), this.project.projCounter()], [updateData, this.getCounterData()]);
 
-            newRation.ID = this.getNewRationID();
+            //newRation.ID = this.getNewRationID();
             if (preRation) {
                 var preIndex = br.indexOf(preRation), i;
                 this.datas.push(newRation);

+ 1 - 1
web/building_saas/main/js/models/ration_glj.js

@@ -508,7 +508,7 @@ var ration_glj = {
                     r_glj.marketUnitFee = r_glj.marketPrice;
                     r_glj.quantity = r_glj.quantity + "";
                     project.Ration.datas.push(r_glj);
-                    newNode = project.mainTree.insert(parentNodeID, nextNodeID);
+                    newNode = project.mainTree.insert(parentNodeID, nextNodeID, r_glj.ID);
                     newNode.source = r_glj;
                     newNode.sourceType = project.Ration.getSourceType();
                     newNode.data = r_glj;

+ 2 - 0
web/building_saas/main/js/views/project_view.js

@@ -260,6 +260,8 @@ var projectObj = {
         }
     },
     updateCellValue: function (node, value, colSetting) {
+        console.log(`node`);
+        console.log(node);
         let project = projectObj.project, fieldName = colSetting.data.field;
         if(node.sourceType==project.ration_glj.getSourceType()){
             project.ration_glj.updateFromMainSpread(value,node,fieldName);