Selaa lähdekoodia

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

Chenshilong 8 vuotta sitten
vanhempi
commit
a1cd076d40
54 muutettua tiedostoa jossa 1305 lisäystä ja 446 poistoa
  1. 47 0
      modules/main/controllers/GLJ_controller.js
  2. 4 15
      modules/main/controllers/bills_controller.js
  3. 22 0
      modules/main/controllers/project_controller.js
  4. 6 17
      modules/main/controllers/rations_controller.js
  5. 85 0
      modules/main/models/GLJ.js
  6. 32 14
      modules/main/models/bills.js
  7. 1 1
      modules/main/models/billsSubSchemas.js
  8. 0 24
      modules/main/models/gljs.js
  9. 56 0
      modules/main/models/project.js
  10. 12 0
      modules/main/models/projectConsts.js
  11. 1 1
      modules/main/models/projectGLJ.js
  12. 15 15
      modules/main/models/rations.js
  13. 12 0
      modules/main/routes/GLJ_route.js
  14. 2 3
      modules/main/routes/bills_route.js
  15. 10 0
      modules/main/routes/project_route.js
  16. 12 0
      modules/main/routes/ration_route.js
  17. 0 13
      modules/main/routes/rations_route.js
  18. 20 0
      modules/pm/controllers/copy_proj_controller.js
  19. 21 0
      modules/pm/controllers/new_proj_controller.js
  20. 20 4
      modules/pm/controllers/pm_controller.js
  21. 74 28
      modules/pm/models/project.js
  22. 2 0
      modules/pm/routes/pm_route.js
  23. 54 0
      modules/rationRepository/controllers/rationChapterTreeController.js
  24. 31 6
      modules/rationRepository/controllers/rationRepositoryController.js
  25. 79 0
      modules/rationRepository/models/rationChapterTree.js
  26. 29 18
      modules/rationRepository/models/rationRepository.js
  27. 7 0
      modules/rationRepository/routes/rationRepRoutes.js
  28. 13 7
      modules/templates/models/bills_template.js
  29. 4 1
      public/counter/counter.js
  30. 49 15
      public/web/idTree.js
  31. 14 9
      public/web/scMathUtil.js
  32. 5 1
      public/web/tree_sheet_helper.js
  33. 6 2
      server.js
  34. 6 23
      test/tmp_data/bills_grid_setting.js
  35. 46 0
      test/tmp_data/test_project_1.js
  36. 37 0
      test/unit/public/testBatchInsertDocs.js
  37. 1 1
      test/unit/public/testScMath.js
  38. 30 26
      web/main/html/main.html
  39. 39 11
      web/main/js/models/bills.js
  40. 49 0
      web/main/js/models/glj.js
  41. 0 27
      web/main/js/models/gljs.js
  42. 9 0
      web/main/js/models/mainConsts.js
  43. 116 10
      web/main/js/models/project.js
  44. 62 0
      web/main/js/models/ration.js
  45. 0 39
      web/main/js/models/rations.js
  46. 1 0
      web/pm/html/project-management.html
  47. 0 2
      web/pm/js/pm_ajax.js
  48. 65 51
      web/pm/js/pm_main.js
  49. 20 14
      web/rationLibEditor/dinge.html
  50. 37 24
      web/rationLibEditor/js/dinge.js
  51. 8 4
      web/scripts/tree_table.js
  52. 1 0
      web/templates/html/bills.html
  53. 9 17
      web/templates/js/bills.js
  54. 24 3
      web/templates/js/tp_bills_setting.js

+ 47 - 0
modules/main/controllers/GLJ_controller.js

@@ -0,0 +1,47 @@
+/**
+ * Created by jimiz on 2017/4/17.
+ */
+/**
+ * Created by jimiz on 2017/4/7.
+ */
+var GLJData = require('../models/GLJ');
+
+//统一回调函数
+var callback = function(req, res, err, message, data){
+    res.json({error: err, message: message, data: data});
+};
+
+module.exports = {
+    getData: function(req, res){
+        var data = JSON.parse(req.body.data);
+        billsData.getData(data.projectId, function(err, message, billsList){
+            if (err === 0) {
+                callback(req, res, err, message, billsList);
+            } else {
+                callback(req, res, err, message, null);
+            }
+        });
+    },
+
+    getItemTemplate: function(req, res){
+        //var data = JSON.parse(req.body.data);
+        billsData.getItemTemplate(function(err, message, billsItem){
+            if (billsItem) {
+                callback(req, res, err, message, billsItem);
+            } else {
+                callback(req, res, err, message, null);
+            }
+        });
+    },
+
+    allocIDs: function(req, res){
+        billsData.allocIDs(function(err, message, data){
+            if (err) {
+                callback(req, res, err, message, data);
+            } else {
+                callback(req, res, err, message, null);
+            }
+        });
+    }
+
+};

+ 4 - 15
modules/main/controllers/bills_controller.js

@@ -9,9 +9,9 @@ var callback = function(req, res, err, message, data){
 };
 
 module.exports = {
-    getBills: function(req, res){
+    getData: function(req, res){
         var data = JSON.parse(req.body.data);
-        billsData.getBills(data.projectId, function(err, message, billsList){
+        billsData.getData(data.projectId, function(err, message, billsList){
             if (err === 0) {
                 callback(req, res, err, message, billsList);
             } else {
@@ -20,20 +20,9 @@ module.exports = {
         });
     },
 
-    updateBills: function(req, res){
-        var data = JSON.parse(req.body.data);
-        billsData.updateBills(data, function(err, message, errList){
-            if (err) {
-                callback(req, res, err, message, errList);
-            } else {
-                callback(req, res, err, message, null);
-            }
-        });
-    },
-
-    getBillsItemTemplate: function(req, res){
+    getItemTemplate: function(req, res){
         //var data = JSON.parse(req.body.data);
-        billsData.getBillsItemTemplate(function(err, message, billsItem){
+        billsData.getItemTemplate(function(err, message, billsItem){
             if (billsItem) {
                 callback(req, res, err, message, billsItem);
             } else {

+ 22 - 0
modules/main/controllers/project_controller.js

@@ -0,0 +1,22 @@
+/**
+ * Created by jimiz on 2017/4/16.
+ */
+var Project = require('../models/project');
+
+//统一回调函数
+var callback = function(req, res, err, message, data){
+    res.json({error: err, message: message, data: data});
+};
+
+module.exports = {
+    save: function (req, res) {
+        var data = JSON.parse(req.body.data);
+        Project.save(data, function (err, message, result) {
+            if (err) {
+                callback(req, res, err, message, result);
+            } else {
+                callback(req, res, err, message, null);
+            }
+        });
+    }
+};

+ 6 - 17
modules/main/controllers/rations_controller.js

@@ -1,7 +1,7 @@
 /**
  * Created by jimiz on 2017/4/9.
  */
-var rationsData = require('../models/rations');
+var rationData = require('../models/ration');
 
 //统一回调函数
 var callback = function(req, res, err, message, data){
@@ -9,9 +9,9 @@ var callback = function(req, res, err, message, data){
 };
 
 module.exports = {
-    getRations: function(req, res){
+    getData: function(req, res){
         var data = JSON.parse(req.body.data);
-        rationsData.getRations(data.projectId, function(err, message, rationList){
+        rationData.getData(data.projectId, function(err, message, rationList){
             if (err === 0) {
                 callback(req, res, err, message, rationList);
             } else {
@@ -20,20 +20,9 @@ module.exports = {
         });
     },
 
-    updateRations: function(req, res){
-        var data = JSON.parse(req.body.data);
-        rationsData.updateRations(data, function(err, message, errList){
-            if (err) {
-                callback(req, res, err, message, errList);
-            } else {
-                callback(req, res, err, message, null);
-            }
-        });
-    },
-
-    getRationItemTemplate: function(req, res){
+    getItemTemplate: function(req, res){
         //var data = JSON.parse(req.body.data);
-        rationsData.getRationItemTemplate(function(err, message, rationItem){
+        rationData.getItemTemplate(function(err, message, rationItem){
             if (billsItem) {
                 callback(req, res, err, message, rationItem);
             } else {
@@ -43,7 +32,7 @@ module.exports = {
     },
 
     allocIDs: function(req, res){
-        rationsData.allocIDs(function(err, message, data){
+        rationData.allocIDs(function(err, message, data){
             if (err) {
                 callback(req, res, err, message, data);
             } else {

+ 85 - 0
modules/main/models/GLJ.js

@@ -0,0 +1,85 @@
+/**
+ * Created by jimiz on 2017/4/1.
+ */
+var mongoose = require("mongoose");
+var db = require("../db/project_db");
+var Schema = mongoose.Schema;
+
+var GLJSchema = new Schema({
+    ID: Number,
+    projectID: Number,
+    orgRQuantity: String, //Decimal
+    rQuantity: String, //Decimal
+    customQuantity: String, //Decimal
+    quantity: String, //Decimal
+    rationItemQuantity: String, //Decimal
+    rationPrice: String, //Decimal
+    adjustPrice: String, //Decimal
+    price: String, //Decimal
+    tenderQuantity: String, //Decimal
+    tenderPrice: String, //Decimal
+    type: Number
+    // to do
+
+});
+
+var GLJ = db.model("GLJList", GLJSchema);
+
+var GLJDAO = function(){};
+
+GLJDAO.prototype.getData = function(projectId, callback){
+    GLJ.find({projectId: projectId}, function(err, datas){
+        if (!err) {
+            callback(0, '', datas);
+        } else {
+            callback(1, '', null);
+        };
+    });
+};
+
+GLJDAO.prototype.save = function(datas, callback){
+    var data, errList = [], updateLength = 0;
+    var updateFunc = function (err, errData) {
+        if (err){
+            errList.push(errData);
+        };
+    };
+    if (datas){
+        for (var i = 0; i < datas.length; i++){
+            data = datas[i];
+            if (data.updateType === 'update') {
+                delete data.updateType;
+                data.save(updateFunc);
+            } else if (data.updateType === 'create') {
+                delete data.updateType;
+                data.save(updateFunc);
+            } else if (data.updateType === 'delete') {
+                delete data.updateType;
+                data.remove(updateFunc);
+            };
+        };
+        if (errList.length > 0){
+            callback(1, errList);
+        } else {
+            callback(0, null);
+        };
+    };
+};
+
+GLJDAO.prototype.getItemTemplate = function(callback){
+    var data = new bills;
+    /* to do: 需要根据标准配置库填充fees和flags字段,是否需要更多的参数? */
+    callback(0, '', data);
+};
+
+const
+    IDStep = 50, IDModule = 'bills';
+
+GLJDAO.prototype.allocIDs = function(IDStep, callback){
+    counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, IDStep, function(err, highID){
+        var lowID = highID - IDStep + 1;
+        callback(0, '', {lowID: lowID, highID: highID});
+    });
+};
+
+module.exports = new GLJDAO();

+ 32 - 14
modules/main/models/bills.js

@@ -44,8 +44,8 @@ var bills = db.model("bills", billsSchema);
 
 var billsDAO = function(){};
 
-billsDAO.prototype.getBills = function(projectId, callback){
-    Projects.find({projectId: projectId}, function(err, datas){
+billsDAO.prototype.getData = function(projectID, callback){
+    bills.find({projectID: projectID}, function(err, datas){
         if (!err) {
             callback(0, '', datas);
         } else {
@@ -54,7 +54,28 @@ billsDAO.prototype.getBills = function(projectId, callback){
     });
 };
 
-billsDAO.prototype.updateBills = function(datas, callback){
+// get All Project Bills, include deleted
+billsDAO.prototype.getProjectBills = function (projectId, callback) {
+    if (callback) {
+        bills.find({projectID: projectId}, '-_id').exec()
+            .then(function (result, err) {
+                if (err) {
+                    callback(1, '找不到模板', null);
+                } else {
+                    callback(0, '', template);
+                }
+            });
+        return null;
+    } else {
+        return bills.find({projectID: projectId}, '-_id').exec();
+    }
+}
+
+billsDAO.prototype.AddBillsFromTemplate = function (datas, callback) {
+    bills.collection.insert(datas, callback);
+};
+
+billsDAO.prototype.save = function(datas, callback){
     var data, errList = [], updateLength = 0;
     var updateFunc = function (err, errData) {
         if (err){
@@ -76,27 +97,24 @@ billsDAO.prototype.updateBills = function(datas, callback){
             };
         };
         if (errList.length > 0){
-            callback(1, 'update error.', errList);
+            callback(1, errList);
         } else {
-            callback(0, '', null);
+            callback(0, null);
         };
     };
 };
 
-billsDAO.prototype.getBillsItemTemplate = function(callback){
+billsDAO.prototype.getItemTemplate = function(callback){
     var data = new bills;
     /* to do: 需要根据标准配置库填充fees和flags字段,是否需要更多的参数? */
     callback(0, '', data);
 };
 
-const
-    IDStep = 50, IDModule = 'bills';
-
-billsDAO.prototype.allocIDs = function(callback){
-    var lowID, highID;
-    counter.getIDAfterCount(IDModule, IDStep, function(highID, err){});
-    lowID = highID - IDStep + 1;
-    callback(0, '', {lowID: lowID, highID: highID});
+billsDAO.prototype.allocIDs = function(IDStep, callback){
+    counter.counterDAO.getIDAfterCount(counter.moduleName.bills, IDStep, function(err, highID){
+        var lowID = highID - IDStep + 1;
+        callback(0, '', {lowID: lowID, highID: highID});
+    });
 };
 
 module.exports = new billsDAO();

+ 1 - 1
modules/main/models/billsSubSchemas.js

@@ -16,7 +16,7 @@ var feesSchema = new Schema({
 // 标记字段
 var flagsSchema = new Schema({
     fieldName: String,
-    flag: Boolean
+    flag: Number
 });
 
 module.exports = {feesSchema: feesSchema, flagsSchema: flagsSchema};

+ 0 - 24
modules/main/models/gljs.js

@@ -1,24 +0,0 @@
-/**
- * Created by jimiz on 2017/4/1.
- */
-var mongoose = require("mongoose");
-var db = require("../db/project_db");
-var Schema = mongoose.Schema;
-
-var gljSchema = new Schema({
-    ID: Number,
-    projectID: Number,
-    orgRQuantity: String, //Decimal
-    rQuantity: String, //Decimal
-    customQuantity: String, //Decimal
-    quantity: String, //Decimal
-    rationItemQuantity: String, //Decimal
-    rationPrice: String, //Decimal
-    adjustPrice: String, //Decimal
-    price: String, //Decimal
-    tenderQuantity: String, //Decimal
-    tenderPrice: String, //Decimal
-    type: Number
-    // to do
-
-});

+ 56 - 0
modules/main/models/project.js

@@ -0,0 +1,56 @@
+/**
+ * Created by jimiz on 2017/4/16.
+ */
+var billsData = require('./bills');
+var rationData = require('./ration');
+var GLJData = require('./GLJ');
+var consts = require('./projectConsts');
+
+var moduleMap = {};
+
+moduleMap[consts.BILLS] = billsData;
+moduleMap[consts.RATION] = rationData;
+moduleMap[consts.GLJ] = GLJData;
+
+var Project = function (){};
+
+Project.prototype.datas = [];
+
+Project.prototype.prepare = function(data, callback){
+    data.updateData.forEach(function(item){
+        this.datas.push(item);
+        /*
+        to do
+        moduleMap[item.moduleName].prepare(item.data, jobCallback);
+        */
+    });
+};
+
+Project.prototype.save = function(data, callback){
+    var job, savePoint;
+    var errDatas = [];
+    this.prepare(data, function(job, savePoint){});
+
+    var saveCallback = function(err, moduleName, data){
+        if (err != 0){
+            var errData = {moduleName: moduleName, err: err, data: data};
+            errDatas.push(errData);
+        }
+    };
+
+    this.datas.forEach(function(item){
+        moduleMap[item.moduleName].save(item.data, saveCallback);
+    });
+
+    this.datas = [];
+
+    if (errDatas.length > 0){
+        callback(1, 'error', errDatas)
+    }
+    else{
+        callback(0, '', null)
+    }
+
+};
+
+module.exports = new Project();

+ 12 - 0
modules/main/models/projectConsts.js

@@ -0,0 +1,12 @@
+/**
+ * Created by jimiz on 2017/4/18.
+ */
+var projectConst = {
+    BILLS: 'bills',
+    RATION: 'ration',
+    GLJ: 'GLJ',
+    PROJECTGLJ: 'projectGLJ'
+
+};
+
+module.exports = projectConst;

+ 1 - 1
modules/main/models/projectGLJ.js

@@ -7,7 +7,7 @@ var Schema = mongoose.Schema;
 
 var projectGLJSchema = new Schema({
     ID: Number,
-    projectId: Number,
+    projectID: Number,
     code: Number,
     name: String,
     specs: String,

+ 15 - 15
modules/main/models/rations.js

@@ -6,9 +6,9 @@ var db = require("../db/project_db");
 var subSchema = require("./billsSubSchemas");
 var Schema = mongoose.Schema;
 
-var rationsSchema = new Schema({
+var rationSchema = new Schema({
     ID: Number,
-    ProjectID: Number,
+    projectID: Number,
     billsItemID: Number,
     serialNo: Number,
     libID: Number,
@@ -27,12 +27,12 @@ var rationsSchema = new Schema({
     flags: [subSchema.flagsSchema]
 });
 
-var rations = db.model("rations", rationsSchema);
+var ration = db.model("rations", rationSchema);
 
-var rationsDAO = function(){};
+var rationDAO = function(){};
 
-rationsDAO.prototype.getRations = function(projectId, callback){
-    Projects.find({projectID: projectId}, function(err, datas){
+rationDAO.prototype.getData = function(projectId, callback){
+    rations.find({projectID: projectId}, function(err, datas){
         if (!err) {
             callback(0, '', datas);
         } else {
@@ -41,7 +41,7 @@ rationsDAO.prototype.getRations = function(projectId, callback){
     });
 };
 
-rationsDAO.prototype.updateRations = function(projectId, datas, callback){
+rationDAO.prototype.save = function(projectId, datas, callback){
     var data, errList = [], updateLength = 0;
     var updateFunc = function (err, errData) {
         if (err){
@@ -70,8 +70,8 @@ rationsDAO.prototype.updateRations = function(projectId, datas, callback){
     };
 };
 
-rationsDAO.prototype.getRationItemTemplate = function(callback){
-    var data = new rations;
+rationDAO.prototype.getItemTemplate = function(callback){
+    var data = new ration;
     /* to do: 需要根据标准配置库填充fees和flags字段,是否需要更多的参数? */
     callback(0, '', data);
 };
@@ -79,11 +79,11 @@ rationsDAO.prototype.getRationItemTemplate = function(callback){
 const
     IDStep = 50, IDModule = 'rations';
 
-rationsDAO.prototype.allocIDs = function(callback){
-    var lowID, highID;
-    counter.getIDAfterCount(IDModule, IDStep, function(highID, err){});
-    lowID = highID - IDStep + 1;
-    callback(0, '', {lowID: lowID, highID: highID});
+rationDAO.prototype.allocIDs = function(IDStep, callback){
+    counter.counterDAO.getIDAfterCount(counter.moduleName.ration, IDStep, function(err, highID){
+        var lowID = highID - IDStep + 1;
+        callback(0, '', {lowID: lowID, highID: highID});
+    });
 };
 
-module.exports = new rationsDAO();
+module.exports = new rationDAO();

+ 12 - 0
modules/main/routes/GLJ_route.js

@@ -0,0 +1,12 @@
+/**
+ * Created by jimiz on 2017/4/17.
+ */
+var express = require('express');
+var GLJRouter = express.Router();
+var GLJController = require('../controllers/GLJ_controller');
+
+GLJRouter.post('/getData', GLJController.getData);
+GLJRouter.post('/getItemTemplate', GLJController.getItemTemplate);
+GLJRouter.post('/allocIDs', GLJController.allocIDs);
+
+module.exports = GLJRouter;

+ 2 - 3
modules/main/routes/bills_route.js

@@ -5,9 +5,8 @@ var express = require('express');
 var billsRouter = express.Router();
 var billsController = require('../controllers/bills_controller');
 
-billsRouter.post('/getBills', billsController.getBills);
-billsRouter.post('/updateBills', billsController.updateBills);
-billsRouter.post('/getBillsItemTemplate', billsController.getBillsItemTemplate);
+billsRouter.post('/getData', billsController.getData);
+billsRouter.post('/getItemTemplate', billsController.getItemTemplate);
 billsRouter.post('/allocIDs', billsController.allocIDs);
 
 module.exports = billsRouter;

+ 10 - 0
modules/main/routes/project_route.js

@@ -0,0 +1,10 @@
+/**
+ * Created by jimiz on 2017/4/16.
+ */
+var express = require('express');
+var projectRouter = express.Router();
+var projectController = require('../controllers/project_controller');
+
+projectRouter.post('/save', projectController.save);
+
+module.exports = projectRouter;

+ 12 - 0
modules/main/routes/ration_route.js

@@ -0,0 +1,12 @@
+/**
+ * Created by jimiz on 2017/4/7.
+ */
+var express = require('express');
+var rationRouter = express.Router();
+var rationController = require('../controllers/ration_controller');
+
+rationRouter.post('/getData', rationController.getData);
+rationRouter.post('/getItemTemplate', rationController.getItemTemplate);
+rationRouter.post('/allocIDs', rationController.allocIDs);
+
+module.exports = rationRouter;

+ 0 - 13
modules/main/routes/rations_route.js

@@ -1,13 +0,0 @@
-/**
- * Created by jimiz on 2017/4/7.
- */
-var express = require('express');
-var rationsRouter = express.Router();
-var rationsController = require('../controllers/rations_controller');
-
-rationsRouter.post('/getRations', rationsController.getRations);
-rationsRouter.post('/updateRations', rationsController.updateRations);
-rationsRouter.post('/getRationsItemTemplate', rationsController.getRationItemTemplate);
-rationsRouter.post('/allocIDs', rationsController.allocIDs);
-
-module.exports = rationsRouter;

+ 20 - 0
modules/pm/controllers/copy_proj_controller.js

@@ -0,0 +1,20 @@
+/**
+ * Created by Mai on 2017/4/24.
+ */
+
+var billsData = require('../../main/models/bills');
+
+module.exports = {
+    copyProjectData: function (srcProjID, newProjID, callback) {
+        billsData.getProjectBills(srcProjID).then(function (results) {
+            var datas = [];
+            results.forEach(function (result) {
+                result._doc.projectID = newProjID;
+                datas.push(result._doc);
+            });
+            return billsData.AddBillsFromTemplate(datas, callback);
+        }).then(function (err) {
+            callback(err);
+        });
+    }
+};

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

@@ -0,0 +1,21 @@
+/**
+ * Created by Mai on 2017/4/24.
+ */
+
+var billsData = require('../../main/models/bills');
+var BillsTemplateData = require('../../templates/models/bills_template');
+
+module.exports = {
+    copyTemplateData: function (tempType, newProjID, callback) {
+        BillsTemplateData.getTemplate(tempType).then(function (templates) {
+            var datas = [];
+            templates.forEach(function (template) {
+                template._doc.projectID = newProjID;
+                datas.push(template._doc);
+            })
+            return billsData.AddBillsFromTemplate(datas, callback);
+        }).catch(function (err) {
+            callback(err);
+        });
+    }
+};

+ 20 - 4
modules/pm/controllers/pm_controller.js

@@ -27,13 +27,23 @@ module.exports = {
             } else {
                 callback(req, res, err, message, null);
             }
-        })
+        });
+    },
+    copyProjects: function (req, res) {
+        var data = JSON.parse(req.body.data);
+        ProjectsData.copyUserProjects(data.user_id, data.updateData, function (err, message, data) {
+            if (err === 0) {
+                callback(req, res, err, message, data);
+            } else {
+                callback(req, res, err, message, null);
+            }
+        });
     },
     rename: function (req, res) {
         var data = JSON.parse(req.body.data);
         ProjectsData.rename(data.user_id, data.id, data.newName, function (err, message) {
             callback(req, res, err, message, null);
-        })
+        });
     },
     getProject: function(req, res){
         var data = JSON.parse(req.body.data);
@@ -43,12 +53,18 @@ module.exports = {
             } else {
                 callback(req, res, err, message, null);
             }
-        })
+        });
     },
     beforeOpenProject: function (req, res) {
         var data = JSON.parse(req.body.data);
         ProjectsData.beforeOpenProject(data.user_id, data.proj_id, data.updateData, function (err, message, data) {
             callback(req, res, err, message, data);
-        })
+        });
+    },
+    getNewProjectID: function (req, res) {
+        var data = JSON.parse(req.body.data);
+        ProjectsData.getNewProjectID(data.count, function (err, message, data) {
+            callback(req, res, err, message, data);
+        });
     }
 }

+ 74 - 28
modules/pm/models/project.js

@@ -1,13 +1,17 @@
 /**
  * Created by Mai on 2017/1/18.
  */
+var counter = require("../../../public/counter/counter.js");
+
+var newProjController = require('../controllers/new_proj_controller');
+var copyProjController = require('../controllers/copy_proj_controller');
 
-//*/
 var mongoose = require("mongoose");
 
 var dbm = require("../../../config/db/db_manager");
 var db = dbm.getCfgConnection("usersManages");
 var Schema = mongoose.Schema;
+var deleteSchema = require('../../../public/models/deleteSchema');
 var ProjectSchema = new Schema({
     "ID": Number,
     "ParentID": Number,
@@ -17,36 +21,15 @@ var ProjectSchema = new Schema({
     "projType": String,
     "recentDateTime": Date,
     "createDateTime": Date,
-    "deleted": Boolean,
-    'deleteDateTime': Date,
+    "deleteInfo": deleteSchema,
     'fullFolder': Array
 });
 var Projects = db.model("projects", ProjectSchema);
 
-/*/
-var db = require('../db/pm_db');
-var Schema = db.mongoose.Schema;
- var ProjectSchema = new Schema({
- "name": String,
- "projType": String,
- "lastDateTime": String,
- "createDateTime": String,
- "id": Number,
- "parentId": Number,
- "nextId": Number,
- "userId": Number,
- "deleted": Boolean,
- 'deleteDateTime': String,
- 'deleteFullFolder': Array
- });
-
- var Projects = db.mongoose.model("projects", ProjectSchema);
-//*/
-
 var ProjectsDAO = function(){};
 
 ProjectsDAO.prototype.getUserProjects = function(userId, callback){
-    Projects.find({userID: userId, deleted: { $in: [false, null]}}, '-_id', function(err, templates){
+    Projects.find({'$or': [{'userID': userId, 'deleteInfo': null}, {'userID': userId, 'deleteInfo.deleted': {'$in': [null, false]}}]}, '-_id', function(err, templates){
         if (err) {
             callback(1, 'Error', null);
         } else {
@@ -66,7 +49,7 @@ ProjectsDAO.prototype.getUserProject = function (userId, ProjId, callback) {
 }
 
 ProjectsDAO.prototype.updateUserProjects = function(userId, datas, callback){
-    var data, project, updateLength = 0, hasError = false;
+    var data, project, updateLength = 0, hasError = false, deleteInfo = null, tempType = 1, i, newProject;
     var updateAll = function (err) {
             if (!err){
                 updateLength += 1;
@@ -79,7 +62,7 @@ ProjectsDAO.prototype.updateUserProjects = function(userId, datas, callback){
             }
         };
     if (datas){
-        for (var i = 0; i < datas.length && !hasError; i++){
+        for (i = 0; i < datas.length && !hasError; i++){
             data = datas[i];
             if (data.updateType === 'update') {
                 Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll)
@@ -89,10 +72,62 @@ ProjectsDAO.prototype.updateUserProjects = function(userId, datas, callback){
                     data.updateData['createDateTime'] = new Date();
                 }
                 newProject = new Projects(data.updateData);
-                newProject.save(updateAll);
+                newProject.save(function (err, result) {
+                    if (!err && result._doc.projType === 'Tender') {
+                        newProjController.copyTemplateData(tempType, newProject.ID, updateAll);
+                    } else {
+                        updateAll(err);
+                    }
+                });
             } else if (data.updateType === 'delete') {
-                data.updateData['deleteDateTime'] = new Date();
+                deleteInfo = {};
+                deleteInfo['deleted'] = true;
+                deleteInfo['deleteDateTime'] = new Date();
+                deleteInfo['deleteBy'] = userId;
+                data.updateData['deleteInfo'] = deleteInfo;
                 Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll);
+            } else {
+                hasError = true;
+                callback(1, '提交数据错误.', null);
+            }
+        }
+    }
+};
+ProjectsDAO.prototype.copyUserProjects = function (userId, datas, callback) {
+    var data, project, updateLength = 0, hasError = false, deleteInfo = null, tempType = 1, i;
+    var updateAll = function (err) {
+        if (!err){
+            updateLength += 1;
+            if (updateLength === datas.length) {
+                callback(0, '', datas);
+            }
+        } else {
+            hasError = true;
+            callback(1, '提交数据出错.', null);
+        }
+    };
+    if (datas) {
+        for (i = 0; i < datas.length && !hasError; i++) {
+            data = datas[i];
+            if (data.updateType === 'update') {
+                Projects.update({userID: userId, ID: data.updateData.ID}, data.updateData, updateAll)
+            } else if (data.updateType === 'copy') {
+                data.updateData['userID'] = userId;
+                if (data.updateData.projType === 'Tender') {
+                    data.updateData['createDateTime'] = new Date();
+                };
+                newProject = new Projects(data.updateData);
+                newProject['srcProjectId'] = data.srcProjectId;
+                newProject.save(function (err, result) {
+                    if (!err && result._doc.projType === 'Tender') {
+                        copyProjController.copyProjectData(this.newProject.srcProjectId, result._doc.ID, updateAll);
+                    } else {
+                        updateAll(err);
+                    }
+                });
+            } else {
+                haseError = true;
+                callback(1, '提交数据错误', null);
             }
         }
     }
@@ -119,4 +154,15 @@ ProjectsDAO.prototype.beforeOpenProject = function (userId, projectId, updateDat
     });
 };
 
+ProjectsDAO.prototype.getNewProjectID = function (count, callback) {
+    counter.counterDAO.getIDAfterCount(counter.moduleName.project, count, function (err, result) {
+        var highID = result.value.sequence_value;
+        if (!err) {
+            callback(0, '', {lowID: highID - count + 1, highID: highID});
+        } else {
+            callback(1, '获取主键失败', null);
+        }
+    });
+}
+
 module.exports = new ProjectsDAO();

+ 2 - 0
modules/pm/routes/pm_route.js

@@ -8,8 +8,10 @@ var pmController = require('./../controllers/pm_controller');
 
 pmRouter.post('/getProjects', pmController.getProjects);
 pmRouter.post('/updateProjects', pmController.updateProjects);
+pmRouter.post('/copyProjects', pmController.copyProjects);
 pmRouter.post('/renameProject', pmController.rename);
 pmRouter.post('/beforeOpenProject', pmController.beforeOpenProject);
 pmRouter.post('/getProject', pmController.getProject);
+pmRouter.post('/getNewProjectID', pmController.getNewProjectID);
 
 module.exports = pmRouter;

+ 54 - 0
modules/rationRepository/controllers/rationChapterTreeController.js

@@ -0,0 +1,54 @@
+/**
+ * Created by Tony on 2017/4/21.
+ */
+
+var rationChapterTreeData = require('../models/rationChapterTree');
+var callback = function(req,res,err,data){
+    if(data){
+        res.status(200)
+        res.json({success:true,data:data});
+    }
+    else
+    if(err){
+        res.status(500)
+        res.json({success:false,error:err});
+    }
+    else{
+        res.status(204);
+        res.json({success:true,data:null});
+    }
+}
+module.exports ={
+    getRationChapterTree:
+        function(req,res){
+            var libName = req.body.rationLibName;
+            rationChapterTreeData.getRationChapterTrees(libName,function(err,data){
+                callback(req,res,err,data)
+            })
+        },
+    tempRationChapterTreeInsert:
+        function(req,res){
+            var DBName = req.body.rationName;
+            var rationTempTree = JSON.parse(req.body.rationTempTree);
+            rationChapterTreeData.tempRationChapterTreeInsert(DBName,rationTempTree,function(err,data){
+                callback(req,res,err,data)
+            })
+        },
+    sectionUpsert:
+        function(req,res){
+            var LibName = req.body.rationLibName;
+            var section = JSON.parse(req.body.rationSection);
+            rationChapterTreeData.sectionUpsert(LibName,section,function(err,data){
+                callback(req,res,err,data)
+            })
+        },
+    deleteSection:
+        function(req,res){
+            var LibName = req.body.rationLibName;
+            var sectionID = req.body.sectionID;
+            rationChapterTreeData.deleteSection(LibName,sectionID,function(err,data){
+                callback(req,res,err,data)
+            })
+        }
+
+}

+ 31 - 6
modules/rationRepository/controllers/rationRepositoryController.js

@@ -1,16 +1,21 @@
 /**
  * Created by Tony on 2017/4/20.
  */
-var rationRepository = require("../models/rationRepository");
+var rationRepository = require("../models/repositoryMap");
 
-var callback = function(req, res, err, data){
+var callback = function(req,res,err,data){
+    if(data){
+        res.status(200)
+        res.json({success:true,data:data});
+    }
+    else
     if(err){
-        //res.send({success: false, error: err});
-        res.json({success: false, error: err});
+        res.status(500)
+        res.json({success:false,error:err});
     }
     else{
-        //res.send({success: true, data: data});
-        res.json({success:true, data: data});
+        res.status(204);
+        res.json({success:true});
     }
 };
 
@@ -34,6 +39,26 @@ module.exports = {
             }
         });
     },
+    getRealLibName:function(req,res){
+        var libName = req.body.rationName;
+        rationRepository.getRealLibName(libName,function(err,data){
+            if (data) {
+                callback(req, res, err, data);
+            } else {
+                callback(req, res, err, null);
+            }
+        })
+    },
+    deleteRationLib:function(req,res){
+        var rationName = req.body.rationName;
+        rationRepository.deleteRationLib(rationName,function(err,data){
+            if (data) {
+                callback(req, res, err, data);
+            } else {
+                callback(req, res, err,  null);
+            }
+        })
+    },
     updateRationRepositoryName: function(req, res) {
         var orgName = req.body.rationName;
         var newName = req.body.newName;

+ 79 - 0
modules/rationRepository/models/rationChapterTree.js

@@ -0,0 +1,79 @@
+/**
+ * Created by Tony on 2017/4/21.
+ */
+
+var mongoose = require("mongoose");
+var dbm = require("../../../config/db/db_manager");
+var chapterTreeDb = dbm.getCfgConnection("rationRepository")
+var async = require("async");
+var Schema = mongoose.Schema;
+
+var rationChapterTreeSchema = mongoose.Schema({//章节树  //生成唯一id改为sectionID  改成string
+    rationRepId: Number,
+    ID:Number,
+    ParentID:Number,
+    NextSiblingID:Number,
+    dispName: String
+});
+var rationChapterTreeModel = chapterTreeDb.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
+var repositoryMap = require('./repositoryMap');
+var counter = require('../../../public/counter/counter');
+
+var rationChapterTreeDAO = function(){};
+
+rationChapterTreeDAO.prototype.getRationChapterTrees = function(repositoryName,callback){
+    repositoryMap.getRealLibName(repositoryName, function(err, rst){
+        rationChapterTreeModel.find({"rationRepId": rst[0].ID},function(err,data){
+            if(data.length) callback(false,data);
+            else  if(err) callback("获取定额树错误!",false)
+            else callback(false,false);
+        })
+    })
+}
+
+rationChapterTreeDAO.prototype.createNewNode = function(repositoryName,nodeData,callback){
+    repositoryMap.getRealLibName(repositoryName, function(err, rst){
+        //
+    })
+},
+
+rationChapterTreeDAO.prototype.tempRationChapterTreeInsert = function(repositoryName,rationTempTree,callback){
+    var db = dbm.getCfgConnection(repositoryName)
+    var rationChapterTreeModel = db.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
+    rationChapterTreeModel.collection.insert(rationTempTree,function(err,data){
+        if(err) callback("插入定额模板错误",false)
+        else callback(false,"ok")
+    })
+}
+
+rationChapterTreeDAO.prototype.sectionUpsert = function(repositoryName,section,callback){
+    var db = dbm.getCfgConnection(repositoryName);
+    var rationChapterTreeModel = db.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees");
+    rationChapterTreeModel.find({"sectionId": section.sectionId},function(err,data){
+        if(data.length){
+            rationChapterTreeModel.update({'sectionId':section.sectionId},section,function(err,data){
+                if(err){
+                    callback(" ",false);
+                }else
+                    callback(false,"ok");
+            });
+        }else{
+            var N = new rationChapterTreeModel(section).save(function(err){
+                if(err){
+                    callback(" ",false);
+                }else
+                    callback(false,"success!");
+            })
+        }
+    })
+}
+//待  ration模块完成
+rationChapterTreeDAO.prototype.deleteSection= function(repositoryName,sectionId,callback){
+    var db = dbm.getCfgConnection(repositoryName);
+    var rationChapterTreeModel = db.model("rationItems",rationChapterTreeSchema);
+    rationChapterTreeModel.find({"sectionId": sectionId},[],function(err,data){
+
+    })
+}
+
+module.exports = new rationChapterTreeDAO()

+ 29 - 18
modules/rationRepository/models/rationRepository.js

@@ -1,22 +1,23 @@
 /**
- * Created by Tony on 2017/4/19.
- * 定额库分类,如重庆、广东等各个省的建筑定额,未来考虑与公路合并
+ * Created by Tony on 2017/4/24.
+ * 重新构造,不适宜生成多个定额库db,还是得统一在一个表
  */
 var mongoose = require('mongoose');
 var dbm = require("../../../config/db/db_manager");
-var stringUtil = require('../../../public/stringUtil');
-var rationLibdb = dbm.getCfgConnection("rationLibMap");
+//var stringUtil = require('../../../public/stringUtil');
+var rationLibdb = dbm.getCfgConnection("rationRepository");
 var Schema = mongoose.Schema;
-var RationLibSchema = new Schema({
+var RepositoryMapSchema = new Schema({
+    "ID": Number,
     "dispName" : String,
-    "dbName": String,
     "appType" : String, //如:"建筑" / "公路"
     "localeType": String, //如 各个省份 / 部颁
     "descr" : String,
     "deleted": Boolean
 });
+var counter = require('../../../public/counter/counter');
 
-var rationRepository = rationLibdb.model("rationRepository", RationLibSchema, "rationRepository");
+var rationRepository = rationLibdb.model("repositoryMap", RepositoryMapSchema, "repositoryMap");
 
 function createNewLibModel(rationLibObj){
     var rst = {};
@@ -24,7 +25,6 @@ function createNewLibModel(rationLibObj){
     rst.appType = rationLibObj.appType?rationLibObj.appType:'construct';
     rst.localeType = rationLibObj.localeType?rationLibObj.localeType:'';
     rst.descr = rationLibObj.descr;
-    rst.dbName = 'r_r_' + stringUtil.getPinYinFullChars(rationLibObj.dispName);
     rst.deleted = false;
     return rst;
 }
@@ -42,16 +42,15 @@ rationRepositoryDao.prototype.getRealLibName = function(dispName,callback){
 };
 
 rationRepositoryDao.prototype.addRationRepository = function( rationLibObj,callback){
-    rationRepository.find({"dispName": rationLibObj.dispName},function(err,data){
-        if(data.length == 0)
-            new rationRepository(createNewLibModel(rationLibObj)).save(function(err) {
-                if (err) callback("Error", null)
-                else
-                    callback(false, "ok");
-            })
-        else
-            callback("定额库重名!",null)
-    })
+    counter.counterDAO.getIDAfterCount(counter.moduleName.rationMap, 1, function(err, result){
+        var rMap = createNewLibModel(rationLibObj);
+        rMap.ID = result.value.sequence_value;
+        new rationRepository(rMap).save(function(err) {
+            if (err) callback("Error", null)
+            else
+                callback(false, "ok");
+        });
+    });
 };
 
 rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
@@ -76,4 +75,16 @@ rationRepositoryDao.prototype.updateName = function(orgName,newName,callback){
     });
 }
 
+rationRepositoryDao.prototype.deleteRationLib = function(rationName,callback){
+    rationRepository.find({"dispName":rationName, "deleted": false}, function(err, data){
+        if (data.length == 1) {
+            rationRepository.update({dispName:rationName},{$set:{deleted: true}},function(err){
+                if(err) callback("err",false);
+                else callback(false,"ok")
+            })
+        } else
+            callback("删除失败!",false);
+    });
+}
+
 module.exports = new rationRepositoryDao();

+ 7 - 0
modules/rationRepository/routes/rationRepRoutes.js

@@ -6,9 +6,16 @@ var apiRouter =express.Router();
 var _rootDir = __dirname;
 
 var rationRepositoryController = require("../controllers/rationRepositoryController");
+var rationChapterTreeController = require("../controllers/rationChapterTreeController");
 
 apiRouter.post("/getRationDisplayNames",rationRepositoryController.getDisPlayRationLibs);
 apiRouter.post("/editRationLibs",rationRepositoryController.updateRationRepositoryName);
 apiRouter.post("/addRationRepository",rationRepositoryController.addRationRepository);
+apiRouter.post("/deleteRationLibs",rationRepositoryController.deleteRationLib);
+apiRouter.post("/getRealLibName",rationRepositoryController.getRealLibName);
+
+apiRouter.post("/getRationTree",rationChapterTreeController.getRationChapterTree);
+apiRouter.post("/addSection",rationChapterTreeController.sectionUpsert);
+apiRouter.post("/deleteSection",rationChapterTreeController.deleteSection);
 
 module.exports = apiRouter;

+ 13 - 7
modules/templates/models/bills_template.js

@@ -24,13 +24,19 @@ var BillsTemplates = templatesDB.model('temp_bills', BillsTemplateSchema);
 var BillsTemplateDAO = function(){};
 
 BillsTemplateDAO.prototype.getTemplate = function (type, callback) {
-    BillsTemplates.find({'$or': [{tempType: type, deleteInfo: null}, {tempType: type, 'deleteInfo.deleted': {$in: [null, false]}}]}, '-_id', function(err, template){
-        if (err) {
-            callback(1, '找不到模板', null);
-        } else {
-            callback(0, '', template);
-        }
-    });
+    if (callback) {
+        BillsTemplates.find({'$or': [{tempType: type, deleteInfo: null}, {tempType: type, 'deleteInfo.deleted': {$in: [null, false]}}]}, '-_id').exec()
+            .then(function (result, err) {
+                if (err) {
+                    callback(1, '找不到模板', null);
+                } else {
+                    callback(0, '', template);
+                }
+            });
+        return null;
+    } else {
+        return BillsTemplates.find({'$or': [{tempType: type, deleteInfo: null}, {tempType: type, 'deleteInfo.deleted': {$in: [null, false]}}]}, '-_id').exec();
+    }
 };
 BillsTemplateDAO.prototype.updateTemplate = function (userID, tempType, datas, callback) {
     var data, project, updateLength = 0, hasError = false, deleteInfo = null;

+ 4 - 1
public/counter/counter.js

@@ -20,7 +20,10 @@ const COUNTER_MODULE_NAME = {
     project: 'projects',
     user: 'users',
     bills: 'bills',
-    ration: 'rations',
+    ration: 'ration',
+    GLJ: 'glj',
+    rationMap: 'rationMaps',
+    rationTree: 'rationChapterTrees',
     report: 'rptTemplates',
     fee: 'fees',
     template_bills: 'temp_bills'

+ 49 - 15
public/web/idTree.js

@@ -7,7 +7,8 @@ var idTree = {
             id: 'id',
             pid: 'pid',
             nid: 'nid',
-            rootId: -1
+            rootId: -1,
+            autoUpdate: false
         };
 
         var _eventType = {
@@ -65,13 +66,14 @@ var idTree = {
                     nodes[i].nextSibling = (i === nodes.length - 1) ? null : nodes[i + 1];
                 }
             },
-            // 在nodes中,从iIndex(包括)开始全部移除
+            // 在nodes中,从iIndex(包括)开始全部移除
             removeNodes: function (tree, parent, iIndex, count) {
                 var children = parent ? parent.children : tree.roots;
                 var pre = (iIndex < 0 || iIndex >= children.length) ? null : children[iIndex].preSibling;
                 var next = (pre && iIndex + count - 1 < children.length) ? children[iIndex + count] : null;
                 if (pre) {
-                    pre.nextSibling = next;
+                    pre.setNextSibling(next);
+                    //pre.nextSibling = next;
                 }
                 if (next) {
                     next.preSibling = pre;
@@ -82,7 +84,7 @@ var idTree = {
                     children.splice(iIndex, children.length - iIndex);
                 }
             },
-            // 在nodes中增加addNodes, 位置从index开始
+            // 在parent.children/tree.roots中增加nodes, 位置从index开始
             addNodes: function (tree, parent, nodes, iIndex) {
                 var children = parent ? parent.children : tree.roots;
                 var pre, next, i;
@@ -95,20 +97,20 @@ var idTree = {
                     next = null;
                 }
                 if (pre) {
-                    pre.nextSibling = nodes[0];
+                    pre.setNextSibling(nodes[0]);
                 }
                 nodes[0].preSibling = pre;
                 if (next) {
                     next.preSibling = nodes[nodes.length - 1];
                 }
-                nodes[nodes.length - 1].nextSibling = next;
+                nodes[nodes.length - 1].setNextSibling(next);
                 for (i = 0; i < nodes.length; i++) {
                     if (arguments.length === 4) {
                         children.splice(iIndex + i, 0, nodes[i]);
                     } else if (arguments.length === 3) {
                         children.push(nodes[i]);
                     }
-                    nodes[i].parent = parent ? parent : null;
+                    nodes[i].setParent(parent ? parent : null);
                 }
             },
             sortTreeItems: function (tree) {
@@ -135,7 +137,7 @@ var idTree = {
         };
 
         var Node = function (tree, data) {
-            // 以下的属性,本单元外均不可直接修改
+            // 以下的属性,本单元外均不可直接修改
             this.tree = tree;
             this.data = data;
             this.children = [];
@@ -160,6 +162,19 @@ var idTree = {
             return this.nextSibling ? this.nextSibling.getID() : -1;
         };
 
+        Node.prototype.setParent = function (parent) {
+            this.parent = parent;
+            if (this.tree.setting.autoUpdate) {
+                this.data[this.tree.setting.pid] = this.getParentID();
+            }
+        };
+        Node.prototype.setNextSibling = function (nextSibling) {
+            this.nextSibling = nextSibling;
+            if (this.tree.setting.autoUpdate) {
+                this.data[this.tree.setting.nid] = this.getNextSiblingID();
+            }
+        }
+
         Node.prototype.firstChild = function () {
             return this.children.length === 0 ? null : this.children[0];
         };
@@ -320,12 +335,12 @@ var idTree = {
             var iIndex = this.siblingIndex(), belongArray = this.parent ? this.parent.children : this.tree.roots, orgPre = this.preSibling;
             if (this.canUpMove()) {
                 if (orgPre.preSibling) {
-                    orgPre.preSibling.nextSibling = this;
+                    orgPre.preSibling.setNextSibling(this);
                 }
-                orgPre.nextSibling = this.nextSibling;
+                orgPre.seNextSibling(this.nextSibling);
                 this.preSibling = orgPre.preSibling;
                 orgPre.preSibling = this;
-                this.nextSibling = orgPre;
+                this.setNextSibling(orgPre);
                 belongArray.splice(iIndex, 1);
                 belongArray.splice(iIndex - 1, 0, this);
                 tools.sortTreeItems(this.tree);
@@ -353,11 +368,11 @@ var idTree = {
             var iIndex = this.siblingIndex(), belongArray = this.parent ? this.parent.children : this.tree.roots, orgNext = this.nextSibling;
             if (this.canDownMove()) {
                 if (this.preSibling) {
-                    this.preSibling.nextSibling = orgNext;
+                    this.preSibling.setNextSibling(orgNext);
                 }
                 orgNext.preSibling = this.preSibling;
-                this.nextSibling = orgNext.nextSibling;
-                orgNext.nextSibling = this;
+                this.setNextSibling(orgNext.nextSibling);
+                orgNext.setNextSibling(this);
                 this.preSibling = orgNext;
                 belongArray.splice(iIndex, 1);
                 belongArray.splice(iIndex + 1, 0, this);
@@ -512,6 +527,25 @@ var idTree = {
             }
             return data;
         };
+        Tree.prototype.insertByData = function (data, parentID, nextSiblingID) {
+            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]];
+            if (node) {
+                return node;
+            } else {
+                node = new Node(this, data);
+                if (nextSibling) {
+                    tools.addNodes(this, parent, [node], nextSibling.siblingIndex());
+                } else {
+                    tools.addNodes(this, parent, [node]);
+                }
+                this.nodes[this.prefix +  data[this.setting.id]] = node;
+                tools.sortTreeItems(this);
+                this.maxNodeID( data[this.setting.id]);
+                return node;
+            }
+        };
 
         Tree.prototype.delete = function (node) {
             var success = false, that = this;
@@ -525,7 +559,7 @@ var idTree = {
                 deleteIdIndex([node]);
                 //delete this.nodes[this.prefix + node.getID()];
                 if (node.preSibling) {
-                    node.preSibling.nextSibling = node.nextSibling;
+                    node.preSibling.setNextSibling(node.nextSibling);
                 }
                 if (node.nextSibling) {
                     node.nextSibling.preSibling = node.preSibling;

+ 14 - 9
public/web/scMathUtil.js

@@ -5,18 +5,17 @@
 var scMathUtil = {
     innerRoundTo: function(num, digit){
         var lFactor = Math.pow(10, digit);
-        var fOffSet;
-        if (num > 0){
-            fOffSet = 0.5;
+        var fOffSet = 0.5;
+        var sign = '';
+        if (num < 0){
+            sign = '-';
+            num = Math.abs(num);
         }
-        else{
-            fOffSet = -0.5;
-        };
         var result = Math.floor((num / lFactor) + fOffSet).toString();
         var iLength = result.length;
         var r1 = result.substring(0, iLength + digit);
         var r2 = result.substring(iLength + digit, iLength);
-        return Number(r1 + '.' + r2);
+        return Number(sign + r1 + '.' + r2);
     },
     floatToBin: function(num) {
         return num.toString(2);
@@ -24,6 +23,12 @@ var scMathUtil = {
     binToFloat: function(bin) {
         var result = 0;
         var iLength = bin.length;
+        var sign = '';
+        if (iLength > 0 && bin[0]==='-'){
+            sign = '-';
+            bin = bin.substring(1, iLength);
+        }
+        iLength = bin.length;
         var iDot = bin.indexOf('.');
         if (iDot >= 0) {
             for (var i = 0; i < iLength; i++) {
@@ -42,7 +47,7 @@ var scMathUtil = {
         else {
             result = parseInt(bin, 2);
         };
-        return result;
+        return sign + result;
     },
     incMantissa: function(bin){
         var result = bin;
@@ -66,4 +71,4 @@ var scMathUtil = {
         var me = this;
         return me.innerRoundTo(me.binToFloat(me.incMantissa(me.floatToBin(num))), digit);
     }
-}
+};

+ 5 - 1
public/web/tree_sheet_helper.js

@@ -94,7 +94,11 @@ var TREE_SHEET_HELPER = {
                     }
                     return data;
                 };
-                cell.value(getFieldText2());
+                if (colSetting.data.getText) {
+                    cell.value(colSetting.data.getText(node));
+                } else {
+                    cell.value(getFieldText2());
+                }
             });
             if (recursive) {
                 TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, node.children, recursive);

+ 6 - 2
server.js

@@ -81,10 +81,14 @@ app.get('/main',  function(req, res) {
     }
 });
 
+var project_Router = require('./modules/main/routes/project_route');
 var bills_Router = require('./modules/main/routes/bills_route');
-var rations_Router = require('./modules/main/routes/rations_route');
+var ration_Router = require('./modules/main/routes/ration_route');
+var GLJ_Router = require('./modules/main/routes/GLJ_route');
+app.use('/project', project_Router);
 app.use('/bills', bills_Router);
-app.use('/rations', rations_Router);
+app.use('/ration', ration_Router);
+app.use('/glj', GLJ_Router);
 
 var rpt_Router = require("./modules/reports/routes/report_router");
 app.get('/report',  function(req, res) {

+ 6 - 23
test/tmp_data/bills_grid_setting.js

@@ -5,7 +5,7 @@ var BillsGridSetting = {
     cols: [
         {
             head: {
-                titleNames: ['编号'],
+                titleNames: ['项目编码'],
                 spanCols: [1],
                 spanRows: [2],
                 vAlign: [1, 1],
@@ -13,33 +13,16 @@ var BillsGridSetting = {
                 font: '9px Arial'
             },
             data: {
-                field: 'Code',
+                field: 'code',
                 vAlign: 1,
                 hAlign: 0,
                 font: '9px Arial'
             },
-            width: 150
-        },
-        {
-            head: {
-                titleNames: ['清单编号'],
-                spanCols: [1],
-                spanRows: [2],
-                vAlign: [1, 1],
-                hAlign: [1, 1],
-                font: '9px Arial'
-            },
-            data: {
-                field: 'B_Code',
-                vAlign: 1,
-                hAlign: 0,
-                font: '9px Arial'
-            },
-            width: 100
+            width: 200
         },
         {
             head: {
-                titleNames: ['名称'],
+                titleNames: ['项目名称'],
                 spanCols: [1],
                 spanRows: [2],
                 vAlign: [1, 1],
@@ -47,7 +30,7 @@ var BillsGridSetting = {
                 font: '9px Arial'
             },
             data: {
-                field: 'Name',
+                field: 'name',
                 vAlign: 1,
                 hAlign: 0,
                 font: '9px Arial'
@@ -64,7 +47,7 @@ var BillsGridSetting = {
                 font: '9px Arial'
             },
             data: {
-                field: 'Units',
+                field: 'unit',
                 vAlign: 1,
                 hAlign: 1,
                 font: '9px Arial'

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 46 - 0
test/tmp_data/test_project_1.js


+ 37 - 0
test/unit/public/testBatchInsertDocs.js

@@ -0,0 +1,37 @@
+/**
+ * Created by Tony on 2017/4/24.
+ */
+
+var test = require('tape');
+var mongoose = require('mongoose');
+var dbm = require("../../../config/db/db_manager");
+var testdb = dbm.getLocalConnection("Demo");
+var Schema = mongoose.Schema;
+//testBatchInsert
+var BatchInsertSchema = new Schema({
+    "ID": Number,
+    "dispName" : String
+});
+
+var testModel = testdb.model("testBatchInsert", BatchInsertSchema, "testBatchInsert");
+
+test('test batch insert docs', function(t){
+    var arr = [];
+    arr.push(new testModel({ID: 1, dispName: "name1"}));
+    arr.push(new testModel({ID: 2, dispName: "name2"}));
+    arr.push(new testModel({ID: 3, dispName: "name3"}));
+    testModel.collection.insert(arr, null, function(err, docs){
+        if (err) {
+            t.pass('pass with error');
+        } else {
+            t.pass('pass with: ' + docs.insertedCount + ' records were inserted!');
+        }
+        t.end();
+    })
+});
+
+test('finish', function (t) {
+    mongoose.disconnect();
+    t.pass('closing db connection');
+    t.end();
+});

+ 1 - 1
test/unit/public/testScMath.js

@@ -5,6 +5,6 @@ var test = require('tape');
 var scMathUtil = require('../../../public/scMathUtil').getUtil();
 
 test('test smartcost math util for rounding', function(t){
-    t.equal(scMathUtil.roundTo(3.12345, -2), 3.12);
+    t.equal(scMathUtil.roundTo(-3.12345, -2), -3.12);
     t.end();
 })

+ 30 - 26
web/main/html/main.html

@@ -517,10 +517,11 @@
     <script type="text/javascript" src="lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
     <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
     <!-- Model -->
+    <script type="text/javascript" src="web/main/js/models/mainConsts.js"></script>
     <script type="text/javascript" src="web/main/js/models/project.js"></script>
     <script type="text/javascript" src="web/main/js/models/bills.js"></script>
-    <script type="text/javascript" src="web/main/js/models/rations.js"></script>
-    <script type="text/javascript" src="web/main/js/models/gljs.js"></script>
+    <script type="text/javascript" src="web/main/js/models/ration.js"></script>
+    <script type="text/javascript" src="web/main/js/models/glj.js"></script>
 
     <script type="text/javascript" src="public/web/idTree.js"></script>
     <script type="text/javascript" src="web/main/js/models/cache_tree.js"></script>
@@ -529,11 +530,11 @@
     <script type="text/javascript" src="public/web/tree_sheet_helper.js"></script>
     <!-- Test Data -->
     <script type="text/javascript" src="test/tmp_data/bills_grid_setting.js"></script>
-    <script type="text/javascript" src="test/tmp_data/data_15690.js"></script>
-    <script type="text/javascript" src="test/tmp_data/drawing_data_10268.js"></script>
     <!-- view -->
     <script type="text/javascript" src="web/main/js/main_ajax.js"></script>
     <script type="text/javascript" src="web/main/js/main.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+    <script type="text/javascript" src="/public/web/urlUtil.js"></script>
     <SCRIPT type="text/javascript">
   		<!--
   		var setting = {
@@ -615,7 +616,7 @@
         billsSpread.options.scrollbarMaxAlign = true;
 
         // For Test
-        datas.forEach(function (data) {
+        /*datas.forEach(function (data) {
             data.fees = [];
             data.fees.push({fieldName: 'labour', unitFee: '1', totalFee: '2', tenderUnitFee: '3', tenderTotalFee: '4'});
             data.flags = [];
@@ -626,30 +627,33 @@
             data.fees.push({fieldName: 'machine', unitFee: '5', totalFee: '6', tenderUnitFee: '7', tenderTotalFee: '8'});
             data.flags = [];
             data.flags.push({fieldName: 'isPartGather', flag: false});
-        });
+        });*/
 
         project = PROJECT.createNew();
-        project.Bills.loadDatas(datas);
-        project.Rations.loadDatas(drawing_data);
-        project.loadMainTree();
-        //project.mainTree.loadDatas(project.Bills.tree, project.Rations.datas);
+        CommonAjax.post('/bills/getData', {projectId: scUrlUtil.GetQueryString('project')}, function (bills) {
+            project.Bills.loadDatas(bills);
+            project.Ration.loadDatas([]);
+            //project.Rations.loadDatas(drawing_data);
+            project.loadMainTree();
 
-        controller = TREE_SHEET_CONTROLLER.createNew(project.mainTree, billsSpread.getActiveSheet(), BillsGridSetting);
-        //controller = TREE_SHEET_CONTROLLER.createNew(project.Bills.tree, billsSpread.getActiveSheet(), BillsGridSetting);
-        controller.showTreeData();
-        controller.bind('refreshBaseActn', function (tree) {
-            var showButton = function (show, btn) {
-                if (show) {
-                    btn.show();
-                } else {
-                    btn.hide();
-                }
-            };
-            showButton(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
-            showButton(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
-            showButton(tree.selected && tree.selected.canUpMove(), $('#upMove'));
-            showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
-            showButton(tree.selected ? true : false, $('#delete'));
+            controller = TREE_SHEET_CONTROLLER.createNew(project.mainTree, billsSpread.getActiveSheet(), BillsGridSetting);
+            //controller = TREE_SHEET_CONTROLLER.createNew(project.Bills.tree, billsSpread.getActiveSheet(), BillsGridSetting);
+
+            controller.showTreeData();
+            controller.bind('refreshBaseActn', function (tree) {
+                var showButton = function (show, btn) {
+                    if (show) {
+                        btn.show();
+                    } else {
+                        btn.hide();
+                    }
+                };
+                showButton(tree.selected && tree.selected.canUpLevel(), $('#upLevel'));
+                showButton(tree.selected && tree.selected.canDownLevel(), $('#downLevel'));
+                showButton(tree.selected && tree.selected.canUpMove(), $('#upMove'));
+                showButton(tree.selected && tree.selected.canDownMove(), $('#downMove'));
+                showButton(tree.selected ? true : false, $('#delete'));
+            });
         });
 
         $('#insert').click(function () {

+ 39 - 11
web/main/js/models/bills.js

@@ -11,39 +11,67 @@ var Bills = {
             rootId: -1
         };
 
-        // 用户定义private方法
+        // 鐢ㄦ埛瀹氫箟private鏂规硶
         var tools = {};
 
-        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
         var bills = function (proj) {
             this.project = proj;
             this.datas = null;
             this.tree = idTree.createNew(billsTreeSetting);
 
-            var sourceType = 'bills';
+            var sourceType = ModuleNames.bills;
             this.getSourceType = function () {
                 return sourceType;
             }
+            proj.registerModule(ModuleNames.bills, this);
         };
 
-        // prototype用于定义public方法
+        // 从后台获取数据
+        bills.prototype.pullData = function (){
+            this.project.pullData(
+                '/bills/getData',
+                {projectID: this.project.ID},
+                function(result){
+                    if (result.error ===0){
+                        this.loadDatas(result.data);
+                    }
+                    else {
+                        // to do: ?错误处理需要细化
+                        alert(result.message);
+                    }
+                },
+                function (){/* to do: 错误处理需要细化*/}
+            )
+        };
+
+        // prototype鐢ㄤ簬瀹氫箟public鏂规硶
         bills.prototype.loadDatas = function (datas) {
             this.datas = datas;
-            // generate Fees & Flags Index,For View & Calculate
+            // generate Fees & Flags Index, For View & Calculate
             this.datas.forEach(function (data) {
                 data.FeesIndex = {};
-                data.fees.forEach(function (fee) {
-                    data.FeesIndex[fee.fieldName] = fee;
-                });
+                if (data.fees) {
+                    data.fees.forEach(function (fee) {
+                        data.FeesIndex[fee.fieldName] = fee;
+                    });
+                }
                 data.FlagsIndex = {};
-                data.flags.forEach(function (flag) {
-                    data.FlagsIndex[flag.fieldName] = flag;
-                });
+                if (data.flags) {
+                    data.flags.forEach(function (flag) {
+                        data.FlagsIndex[flag.fieldName] = flag;
+                    });
+                }
             });
             // datas load to Tree
             this.tree.loadDatas(this.datas);
         };
 
+        // 鎻愪氦鏁版嵁鍚庣殑閿欒�澶勭悊鏂规硶
+        bills.prototype.doAfterUpdate = function(err, data){
+            // to do
+        };
+
         return new bills(project);
     }
 };

+ 49 - 0
web/main/js/models/glj.js

@@ -0,0 +1,49 @@
+/**
+ * Created by Mai on 2017/4/1.
+ */
+var GLJ = {
+    createNew: function (project) {
+        // 用户定义private方法
+        var tools = {};
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        var glj = function (proj) {
+            this.project = proj;
+            this.datas = null;
+
+            var sourceType = ModuleNames.GLJ;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.GLJ, this);
+        };
+
+        // 从后台获取数据
+        glj.prototype.pullData = function (){
+            this.project.pullData(
+                '/glj/getData',
+                {projectID: this.project.ID},
+                function(result){
+                    if (result.error ===0){
+                        this.loadDatas(result.data);
+                    }
+                    else {
+                        // to do: 错误处理需要细化
+                        alert(result.message);
+                    }
+                },
+                function (){/* to do: 错误处理需要细化*/}
+            )
+        };
+        // prototype用于定义public方法
+        glj.prototype.loadDatas = function (datas) {
+            this.datas = datas;
+        };
+
+        // 提交数据后的错误处理方法
+        glj.prototype.doAfterUpdate = function(err, data){
+            // to do
+        };
+        return new glj(project);
+    }
+};

+ 0 - 27
web/main/js/models/gljs.js

@@ -1,27 +0,0 @@
-/**
- * Created by Mai on 2017/4/1.
- */
-var GLJs = {
-    createNew: function (project) {
-        // 用户定义private方法
-        var tools = {};
-
-        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
-        var gljs = function (proj) {
-            this.project = proj;
-            this.datas = null;
-
-            var sourceType = 'glj';
-            this.getSourceType = function () {
-                return sourceType;
-            }
-        };
-
-        // prototype用于定义public方法
-        gljs.prototype.loadDatas = function (datas) {
-            this.datas = datas;
-        };
-
-        return new gljs(project);
-    }
-};

+ 9 - 0
web/main/js/models/mainConsts.js

@@ -0,0 +1,9 @@
+/**
+ * Created by jimiz on 2017/4/19.
+ */
+const ModuleNames = {
+    bills: 'bills',
+    ration: 'ration',
+    GLJ: 'GLJ',
+    projectGLJ: 'projectGLJ'
+};

+ 116 - 10
web/main/js/models/project.js

@@ -2,27 +2,47 @@
  * Created by Mai on 2017/4/1.
  */
 var PROJECT = {
-    createNew: function () {
-        // 定义private方法
-        var tools = {};
+    createNew: function (projectID, userID) {
+        // 瀹氫箟private鏂规硶
+        var tools = {
+            _ID: projectID,
+            _userID: userID,
+            updateLock: 0,
+            updateData: [],
+            operation: '',
+            modules: {},
 
-        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+            doAfterUpdate: function(result){
+                result.forEach(function(item){
+                    if (item.moduleName in this.modules){
+                        this.modules[item.moduleName].doAfterUpdate(item.err, item.data);
+                    }
+                });
+            }
+        };
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
         var project = function () {
             this.mainTree = cacheTree.createNew(this);
 
             this.Bills = Bills.createNew(this);
-            this.Rations = Rations.createNew(this);
-            this.GLJs = GLJs.createNew(this);
+            this.Ration = Ration.createNew(this);
+            this.GLJ = GLJ.createNew(this);
 
 
             this.masterField = {ration: 'BillsID'};
         };
 
-        // prototype用于定义public方法
+        // prototype鐢ㄤ簬瀹氫箟public鏂规硶
         project.prototype.modify = function (modifyDatas, callback) {
             // To Do
         };
 
+        // prototype鐢ㄤ簬瀹氫箟public鏂规硶
+        project.prototype.ID = function () {
+            return tools._ID;
+        };
+
         project.prototype.loadMainTree = function () {
             var that = this;
             var loadRationNode = function (rations, cacheNode) {
@@ -31,7 +51,7 @@ var PROJECT = {
                     if (ration[that.masterField.ration] && ration[that.masterField.ration] === cacheNode.source.getID()) {
                         newNode = that.mainTree.addNode(cacheNode);
                         newNode.source = ration;
-                        newNode.sourceType = that.Rations.getSourceType();
+                        newNode.sourceType = that.Ration.getSourceType();
                         newNode.data = ration;
                     }
                 });
@@ -45,7 +65,7 @@ var PROJECT = {
                     newNode.data = nodes[i].data;
 
                     if (nodes[i].children.length === 0) {
-                        loadRationNode(that.Rations.datas, newNode);
+                        loadRationNode(that.Ration.datas, newNode);
                     } else {
                         loadIdTreeNode(nodes[i].children, newNode);
                     }
@@ -53,7 +73,93 @@ var PROJECT = {
             };
             loadIdTreeNode(this.Bills.tree.roots, null);
             this.mainTree.sortTreeItems();
-        }
+        };
+
+        // 鎻愪緵缁欏悇妯″潡璋冪敤鐨勭粺涓€浠庡悗鍙拌幏鍙栨暟鎹�殑鏂规硶
+        project.prototype.pullData = function (url, data, successCallback, errorCallback) {
+            $.ajax({
+                type:"POST",
+                url: url,
+                data: {'data': JSON.stringify(data)},
+                dataType: 'json',
+                cache: false,
+                timeout: 50000,
+                success: function(result){
+                    successCallback(result);
+                },
+                error: function(jqXHR, textStatus, errorThrown){
+                    alert('error ' + textStatus + " " + errorThrown);
+                    errorCallback();
+                }
+            });
+        };
+
+        // 鎵€鏈夋ā鍧楀湪姝や粠鍚庡彴鑾峰彇鏁版嵁
+        project.prototype.loadDatas = function (){
+            this.Bills.pullData();
+            this.Ration.pullData();
+            this.GLJ.pullData();
+
+        };
+
+        project.prototype.beginUpdate = function(operation){
+            if (tools.updateLock === 0){
+                tools.operation = operation
+            }
+            tools.updateLock += 1;
+        };
+
+        project.prototype.endUpdate = function(){
+            if (tools.updateLock === 0){
+                throw "project can not endUpdate before beginUpdate";
+            }
+            tools.updateLock -= 1;
+            if (tools.updateLock === 0) {
+                $.ajax({
+                    type: "POST",
+                    url: '/project/save',
+                    data: {'data': JSON.stringify({
+                        "project_id": tools._ID,
+                        "user_id": tools._userID,
+                        "date": new Date,
+                        "operation": tools.operation,
+                        "update_data": tools.updateData
+                    })},
+                    dataType: 'json',
+                    cache: false,
+                    timeout: 50000,
+                    success: function (result) {
+                        if (result.error === 0) {
+                            tools.doAfterUpdate(result.data);
+                        } else {
+                            alert('error: ' + result.message);
+                        }
+                    },
+                    error: function(jqXHR, textStatus, errorThrown){
+                        alert('error ' + textStatus + " " + errorThrown);
+                    }
+                });
+                tools.updateData = [];
+                tools.operation = "";
+            }
+        };
+
+        project.prototype.push = function(moduleName, data){
+            if (tools.updateLock === 0){
+                throw "project can not push data before beginUpdate";
+            };
+            var moduleData = {
+                moduleName: moduleName,
+                data: data
+            };
+            tools.updateData.push(moduleData);
+        };
+
+        project.prototype.registerModule = function(moduleName, obj){
+            if (!tools.modules.hasOwnProperty(moduleName)){
+                tools.modules[moduleName] = obj;
+            }
+        };
 
         return new project();
     }

+ 62 - 0
web/main/js/models/ration.js

@@ -0,0 +1,62 @@
+/**
+ * Created by Mai on 2017/4/1.
+ */
+
+var Ration = {
+    createNew: function (project) {
+        // 用户定义private方法
+        var tools = {};
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        var ration = function (proj) {
+            this.project = proj;
+            this.datas = null;
+
+            var sourceType = ModuleNames.ration;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.ration, this);
+        };
+
+        // 从后台获取数据
+        ration.prototype.pullData = function (){
+            this.project.pullData(
+                '/ration/getData',
+                {projectID: this.project.ID},
+                function(result){
+                    if (result.error ===0){
+                        this.loadDatas(result.data);
+                    }
+                    else {
+                        // to do: 错误处理需要细化
+                        alert(result.message);
+                    }
+                },
+                function (){/* to do: 错误处理需要细化*/}
+            )
+        };
+        // prototype用于定义public方法
+        ration.prototype.loadDatas = function (datas) {
+            this.datas = datas;
+            // generate Fees & Flags Index,For View & Calculate
+            this.datas.forEach(function (data) {
+                data.FeesIndex = {};
+                data.fees.forEach(function (fee) {
+                    data.FeesIndex[fee.fieldName] = fee;
+                });
+                data.FlagsIndex = {};
+                data.flags.forEach(function (flag) {
+                    data.FlagsIndex[flag.fieldName] = flag;
+                });
+            });
+        };
+
+        // 提交数据后的错误处理方法
+        ration.prototype.doAfterUpdate = function(err, data){
+            // to do
+        };
+
+        return new ration(project);
+    }
+};

+ 0 - 39
web/main/js/models/rations.js

@@ -1,39 +0,0 @@
-/**
- * Created by Mai on 2017/4/1.
- */
-
-var Rations = {
-    createNew: function (project) {
-        // 用户定义private方法
-        var tools = {};
-
-        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
-        var rations = function (proj) {
-            this.project = proj;
-            this.datas = null;
-
-            var sourceType = 'ration';
-            this.getSourceType = function () {
-                return sourceType;
-            }
-        };
-
-        // prototype用于定义public方法
-        rations.prototype.loadDatas = function (datas) {
-            this.datas = datas;
-            // generate Fees & Flags Index,For View & Calculate
-            this.datas.forEach(function (data) {
-                data.FeesIndex = {};
-                data.fees.forEach(function (fee) {
-                    data.FeesIndex[fee.fieldName] = fee;
-                });
-                data.FlagsIndex = {};
-                data.flags.forEach(function (flag) {
-                    data.FlagsIndex[flag.fieldName] = flag;
-                });
-            });
-        };
-
-        return new rations(project);
-    }
-};

+ 1 - 0
web/pm/html/project-management.html

@@ -457,6 +457,7 @@
     <script src="lib/global.js"></script>
     <script src="public/dateUtil.js"></script>
     <script src="web/scripts/tree_table.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script src="web/pm/js/pm_ajax.js"></script>
     <script src="web/pm/js/pm_main.js" charset="UTF-8"></script>
     <!-- zTree -->

+ 0 - 2
web/pm/js/pm_ajax.js

@@ -44,7 +44,6 @@ var UpdateProjectData = function (updateData, callback) {
         }
     });
 };
-
 // 重命名项目
 var RenameProject = function(projId, newName, callback) {
     $.ajax({
@@ -66,7 +65,6 @@ var RenameProject = function(projId, newName, callback) {
         }
     });
 };
-
 // 打开项目前,提交数据
 var BeforeOpenProject = function (projId, updateData, callback) {
     $.ajax({

+ 65 - 51
web/pm/js/pm_main.js

@@ -130,13 +130,13 @@ var GetPreNodeUpdateData = function (pre, nid) {
     var data = {};
     data['updateType'] = 'update';
     data['updateData'] = {};
-    data.updateData[setting.tree.id] = pre.id();
-    data.updateData[setting.tree.nid] = nid;
+    data.updateData[Tree.setting.tree.id] = pre.id();
+    data.updateData[Tree.setting.tree.id] = nid;
     return data;
 }
 // 获取新建项目数据
-var GetAddProjUpdateData = function (parent, next, name) {
-    var datas = [], updateData, pre, newId = Tree.maxNodeId() + 1;
+var GetAddProjUpdateData = function (parent, next, name, newId) {
+    var datas = [], updateData, pre;
     updateData = {};
     updateData['updateType'] = 'new';
     updateData['updateData'] = {};
@@ -148,8 +148,8 @@ var GetAddProjUpdateData = function (parent, next, name) {
     datas.push(updateData);
     return datas;
 };
-var GetAddFolderProjUpdateData = function (parent, next, folderName1, folderName2, name) {
-    var datas = [], updateData, folderData1, folderData2, pre, newId = Tree.maxNodeId() + 1;
+var GetAddFolderProjUpdateData = function (parent, next, folderName1, folderName2, name, newId) {
+    var datas = [], updateData, folderData1, folderData2, pre;
     var addUpdateData = function (parentId, nextId, name, projType) {
         var data = {};
         data['updateType'] = 'new';
@@ -169,8 +169,8 @@ var GetAddFolderProjUpdateData = function (parent, next, folderName1, folderName
     return datas;
 };
 // 获取新建文件夹数据
-var GetAddForlderUpdateData = function (parent, next, folderName) {
-    var datas = [], updateData, pre, newId = Tree.maxNodeId() + 1;
+var GetAddForlderUpdateData = function (parent, next, folderName, newId) {
+    var datas = [], updateData, pre;
     updateData = {};
     updateData['updateType'] = 'new';
     updateData['updateData'] = {};
@@ -217,9 +217,8 @@ var GetDeleteUpdateData = function (node) {
             data['updateType'] = 'delete';
             data['updateData'] = {};
             data['updateData'][Tree.setting.tree.id] = node.id();
-            data['updateData']['deleted'] = true;
             if (node.data.projType === 'Tender') {
-                data['updateData']['FullFolder'] = GetfullFolder(node.parent);
+                data['updateData']['FullFolder'] = GetFullFolder(node.parent);
             }
             return data;
         },
@@ -258,12 +257,13 @@ var GetMoveUpdateData = function (node, parent, next) {
     return datas;
 };
 
-var GetCopyUpdateData = function (node, parent, next){
+var GetCopyUpdateData = function (node, parent, next, newId){
     var datas = [], updateData, pre;
     updateData = {};
-    updateData['updateType'] = 'new';
+    updateData['updateType'] = 'copy';
+    updateData['srcProjectId'] = node.id();
     updateData['updateData'] = {};
-    updateData['updateData'][Tree.setting.tree.id] = node.tree.maxNodeId() + 1;
+    updateData['updateData'][Tree.setting.tree.id] = newId + 1;
     updateData['updateData'][Tree.setting.tree.pid] = parent ? parent.id() : -1;
     updateData['updateData'][Tree.setting.tree.nid] = next ? next.id() : -1;
     updateData['updateData']['name'] = node.data.name;
@@ -358,7 +358,7 @@ $('#addFolderBtn').click(function () {
 $('#addFolderOk').click(function () {
     var form = $('#addFolder');
     var name = $('#folder-name-input').val();
-    var updateData, parent, next;
+    var parent, next;
     if (name) {
         if (Tree.selected()) {
             if (Tree.selected().children.length === 0 || Tree.selected().firstChild().data.projType === 'Folder') {
@@ -373,21 +373,24 @@ $('#addFolderOk').click(function () {
             next = Tree.firstNode();
         }
 
-        updateData = GetAddForlderUpdateData(parent, next, name);
-        UpdateProjectData(updateData, function(datas){
-            datas.forEach(function (data) {
-                if (data.updateType === 'new') {
-                    Tree.addNodeData(data.updateData, parent, next);
-                }
+        CommonAjax.post('/getNewProjectID', {count: 1}, function (IDs) {
+            var updateData = GetAddForlderUpdateData(parent, next, name, IDs.lowID);
+            Tree.maxNodeId(IDs.lowID - 1);
+            UpdateProjectData(updateData, function(datas){
+                datas.forEach(function (data) {
+                    if (data.updateType === 'new') {
+                        Tree.addNodeData(data.updateData, parent, next);
+                    }
+                });
+                form.modal('hide');
             });
-            form.modal('hide');
         });
     }
 });
 
 // 新建工程
 var AddProj = function () {
-    var name = $('#tenderName').val(), updateData, parent, next;
+    var name = $('#tenderName').val();
     if (name !== '') {
         // if (Tree.selected()){
         //     if (Tree.selected().data.projType === 'Tender') {
@@ -405,34 +408,40 @@ var AddProj = function () {
         //     parent = Tree._root();
         //     next = Tree.firstNode();
         // }
-        updateData = GetAddProjUpdateData(Tree._root, Tree.firstNode(), name);
-        UpdateProjectData(updateData, function (datas) {
-            datas.forEach(function (data) {
-                var parent, next;
-                if (data.updateType === 'new') {
-                    parent = data.updateData.parentId === -1 ?  Tree._root : Tree.findNode(data.updateData.parentId);
-                    next = data.updateData.nextId === -1 ? null : Tree.findNode(data.updateData.nextId);
-                    Tree.addNodeData(data.updateData, parent, next);
-                }
+        CommonAjax.post('/getNewProjectID', {count: 1}, function (IDs) {
+            var updateData = GetAddProjUpdateData(Tree._root, Tree.firstNode(), name, IDs.lowID);
+            Tree.maxNodeId(IDs.lowID - 1);
+            UpdateProjectData(updateData, function (datas) {
+                datas.forEach(function (data) {
+                    var parent, next;
+                    if (data.updateType === 'new') {
+                        parent = data.updateData.parentId === -1 ?  Tree._root : Tree.findNode(data.updateData.parentId);
+                        next = data.updateData.nextId === -1 ? null : Tree.findNode(data.updateData.nextId);
+                        Tree.addNodeData(data.updateData, parent, next);
+                    }
+                });
+                $('#addProj').modal('hide');
             });
-            $('#addProj').modal('hide');
         });
     }
 }
 var AddFolderProj = function () {
-    var nameB = $('#buildName').val(), nameX = $('#xiangName').val(), name = $('#tenderName').val(), updateData;
+    var nameB = $('#buildName').val(), nameX = $('#xiangName').val(), name = $('#tenderName').val();
     if (nameB !== '' && nameX !== '' && name !== '') {
-        updateData = GetAddFolderProjUpdateData(Tree._root, Tree.firstNode(), nameB, nameX, name);
-        UpdateProjectData(updateData, function (datas) {
-            datas.forEach(function (data) {
-                var parent, next;
-                if (data.updateType === 'new') {
-                    parent = data.updateData[Tree.setting.tree.pid] === -1 ?  Tree._root : Tree.findNode(data.updateData[Tree.setting.tree.pid]);
-                    next = data.updateData[Tree.setting.tree.nid] === -1 ? null : Tree.findNode(data.updateData[Tree.setting.tree.nid]);
-                    Tree.addNodeData(data.updateData, parent, next);
-                }
+        CommonAjax.post('/getNewProjectID', {count: 3}, function (IDs) {
+            var updateData = GetAddFolderProjUpdateData(Tree._root, Tree.firstNode(), nameB, nameX, name, IDs.lowID);
+            Tree.maxNodeId(IDs.lowID - 1);
+            UpdateProjectData(updateData, function (datas) {
+                datas.forEach(function (data) {
+                    var parent, next;
+                    if (data.updateType === 'new') {
+                        parent = data.updateData[Tree.setting.tree.pid] === -1 ?  Tree._root : Tree.findNode(data.updateData[Tree.setting.tree.pid]);
+                        next = data.updateData[Tree.setting.tree.nid] === -1 ? null : Tree.findNode(data.updateData[Tree.setting.tree.nid]);
+                        Tree.addNodeData(data.updateData, parent, next);
+                    }
+                });
+                $('#addProj').modal('hide');
             });
-            $('#addProj').modal('hide');
         });
     }
 }
@@ -573,7 +582,7 @@ $('#copyto').on('show.bs.modal', function () {
     copytoZTree = ConvertTreeToZtree(Tree, $('#treeDemo2'));
 });
 $('#copytoOk').click(function() {
-    var updateData, form = $('#copyto'),
+    var form = $('#copyto'),
         target = GetTargetTreeNode($.fn.zTree.getZTreeObj('treeDemo2')),
         parent, next, cur = Tree.selected();
     if (target && (target.data.projType === 'Tender' || target.children.length === 0 || target.firstChild().data.projType === 'Tender')) {
@@ -586,13 +595,18 @@ $('#copytoOk').click(function() {
         }
 
         if (parent !== cur.parent || (next !== cur && next !== cur.nextSibling)){
-            updateData = GetCopyUpdateData(Tree.selected(), parent, next);
-            UpdateProjectData(updateData, function (data) {
-                form.modal('hide');
-                data.forEach(function (nodeData) {
-                    if (nodeData.updateType === 'new') {
-                        Tree.addNodeData(nodeData.updateData, parent, next);
-                    }
+            CommonAjax.post('/getNewProjectID', {count: 1}, function (IDs) {
+                var updateData = GetCopyUpdateData(cur, parent, next, IDs.lowID);
+                Tree.maxNodeId(IDs.lowID - 1);
+                CommonAjax.post('/copyProjects', {user_id: userID, updateData: updateData}, function (data) {
+                    form.modal('hide');
+                    data.forEach(function (nodeData) {
+                        if (nodeData.updateType === 'copy') {
+                            Tree.addNodeData(nodeData.updateData, parent, next);
+                        }
+                    });
+                }, function () {
+                    form.modal('hide');
                 });
             });
         } else {

+ 20 - 14
web/rationLibEditor/dinge.html

@@ -45,6 +45,12 @@
             <div class="container-fluid">
                 <div class="row">
                   <div class="main-side col-lg-3 p-0">
+                      <div class="tab-bar">
+                          <!--
+                          <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>
                     </div>
@@ -862,7 +868,7 @@
         </div>
     </div>
     <!-- JS. -->
-    <script src = "/lib/spreadjs/gc.spread.sheets.all.10.0.1.min.js"></script>
+    <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/tether/tether.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
@@ -877,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: {

+ 37 - 24
web/rationLibEditor/js/dinge.js

@@ -21,34 +21,47 @@ $(document).ready(function(){
 });
 function initParam(){
     var rationLibName = getQueryString("repository");//获取定额库参数
-    if(rationLibName)
-        getRealLib(rationLibName);
-    else{
+    if(rationLibName) {
+        params.realLibName = rationLibName;
+        getRationTree();
+    } else{
         params = JSON.parse(getQueryString("params"));
         getRationTree();
     }
 }
-function getRealLib(LibName){
-    $.ajax({
-        type:"POST",
-        url:"rationRepository/api/getRealLibName",
-        data:{"rationName":LibName},
-        async:false,
-        dataType:"json",
-        cache:false,
-        timeout:1000,
-        success:function(result){
-            params.realLibName = result.data[0].dbName
-            getRationTree();
-        },
-        error:function(){}
-    })
+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)
+    //    }
+    //})
+
+    var newNodes = [], isSilent = false;
+    newNodes.push({ id: 20, pId:-1, nId:-1, name:"新增节点",isParent:true, children:[]});
+    if (treeObj) {
+        treeObj.addNodes(null, -1, newNodes, isSilent);
+    } else {
+        treeObj = $.fn.zTree.init($("#treeDemo"), setting, newNodes);
+    }
 }
 //---------------------------------------------------初始化章节树界面
 function  getRationTree(){
     $.ajax({
         type:"POST",
-        url:"rationRepository/api/getRationTree",
+        url:"api/getRationTree",
         data:{"rationLibName": params.realLibName},
         dataType:"json",
         cache:false,
@@ -56,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){
@@ -151,7 +164,7 @@ function saveTempTree(){
     var rationTempTree = JSON.stringify(N)
     $.ajax({
         type:"POST",
-        url:"rationRepository/api/saveTempRationTree",
+        url:"api/saveTempRationTree",
         data:{"rationName":rationLibName,"rationTempTree":rationTempTree},
         dataType:"json",
         cache:false,
@@ -199,7 +212,7 @@ function saveNewSection(n){
     var section = JSON.stringify(sec);
     $.ajax({
         type:"POST",
-        url:"rationRepository/api/addSection",
+        url:"api/addSection",
         data:{"rationLibName":params.realLibName,"rationSection":section},
         dataType:"json",
         cache:false,
@@ -225,7 +238,7 @@ function onRemove(e, treeId, treeNode) {
     }
     $.ajax({
         type:"POST",
-        url:"rationRepository/api/deleteSection",
+        url:"api/deleteSection",
         data:{"rationLibName":params.realLibName,"sectionID": treeNode.id},
         dataType:"json",
         cache:false,

+ 8 - 4
web/scripts/tree_table.js

@@ -161,8 +161,12 @@
  					return _maxNodeId;
  				}
  			};
-			this.maxNodeId = function (){
-				return _maxNodeId;
+			this.maxNodeId = function (id){
+				if (arguments.length > 0) {
+					_maxNodeId = Math.max(id, _maxNodeId);
+				} else {
+					return _maxNodeId;
+				}
 			}
  		};
 
@@ -234,7 +238,7 @@
  					node = new Node(that, data);
  				}
  				node.data = data;
-				that.newNodeId(node.id());
+				that.maxNodeId(node.id());
 
 				if (!parent){
 					if (data[setting.tree.pid] === setting.tree.nullId) {
@@ -301,7 +305,7 @@
 			var pNode = parent ? parent : this._root;
 			if (!nextSibling || (nextSibling.parent === pNode && pNode.childIndex(nextSibling) > -1)) {
 				node = new Node(this, data);
-                this.newNodeId(data[this.setting.tree.id]);
+                this.maxNodeId(data[this.setting.tree.id]);
 				node.row = _view._makeRowDom(this.treeBodyObj, node);
 				this.move(node, pNode, nextSibling);
 			}

+ 1 - 0
web/templates/html/bills.html

@@ -100,6 +100,7 @@
 <script type="text/javascript" src="/web/templates/js/bills.js"></script>
 <script type="text/javascript" src="/web/templates/js/tp_bills_setting.js"></script>
 <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+<script>
     autoFlashHeight();
 </script>
 </html>

+ 9 - 17
web/templates/js/bills.js

@@ -26,16 +26,14 @@ $(document).ready(function () {
     }
     var RefreshBillsData = function (datas) {
         datas.forEach(function (data) {
-            bills.forEach(function (billsData) {
-                if (data.data.ID === billsData.ID) {
-                    $.extend(true, billsData, data.data);
-                }
-            })
-        })
-    }
+            var node = tree.findNode(data.data.ID);
+            if (node) {
+                $.extend(true, node.data, data.data);
+            }
+        });
+    };
 
-    var bills;
-    var tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
+    var tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
     var billsSpread = new GC.Spread.Sheets.Workbook($('#billsSpread')[0], { sheetCount: 1 });
     var controller = TREE_SHEET_CONTROLLER.createNew(tree, billsSpread.getActiveSheet(), TEMPLATE_BILLS_SETTING);
 
@@ -88,7 +86,7 @@ $(document).ready(function () {
     });
 
     CommonAjax.post('/template/bills/getBillsTemplate', {tempType: tempType}, function (data) {
-        bills = data;
+        var bills = data;
         tree.loadDatas(bills);
         controller.showTreeData();
         RefreshBaseActn(tree);
@@ -108,9 +106,8 @@ $(document).ready(function () {
                 updateData = FormatUpdateData(controller.tree.getInsertData());
             }
             if (updateData.updateData.length > 0) {
-                PostData('/template/bills/updateBillsTemplate', updateData, function (data) {
+                CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                     controller.insert();
-                    RefreshBillsData(data);
                     controller.showTreeData();
                 });
             } else {
@@ -124,7 +121,6 @@ $(document).ready(function () {
             updateData = FormatUpdateData(controller.tree.getDeleteData(selected));
             CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                 controller.delete();
-                RefreshBillsData(data);
                 controller.showTreeData();
             });
         }
@@ -135,7 +131,6 @@ $(document).ready(function () {
             updateData = FormatUpdateData(selected.getUpLevelData());
             CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                 controller.upLevel();
-                RefreshBillsData(data);
                 controller.showTreeData();
             });
         }
@@ -146,7 +141,6 @@ $(document).ready(function () {
             updateData = FormatUpdateData(selected.getDownLevelData());
             CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                 controller.downLevel();
-                RefreshBillsData(data);
                 controller.showTreeData();
             });
         }
@@ -157,7 +151,6 @@ $(document).ready(function () {
             updateData = FormatUpdateData(selected.getUpMoveData());
             CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                 controller.upMove();
-                RefreshBillsData(data);
                 controller.showTreeData();
             });
         }
@@ -168,7 +161,6 @@ $(document).ready(function () {
             updateData = FormatUpdateData(selected.getDownMoveData());
             CommonAjax.post('/template/bills/updateBillsTemplate', updateData, function (data) {
                 controller.downMove();
-                RefreshBillsData(data);
                 controller.showTreeData();
             });
         }

+ 24 - 3
web/templates/js/tp_bills_setting.js

@@ -120,7 +120,14 @@ var TEMPLATE_BILLS_SETTING = {
             "field":"ID",
             "vAlign":0,
             "hAlign":1,
-            "font":"14.6667px Calibri"
+            "font":"14.6667px Calibri"/*,
+            "getText": function (node) {
+                if (node) {
+                    return node.getID();
+                } else {
+                    return '';
+                }
+            }*/
         }
     }, {
         "width":50,
@@ -149,7 +156,14 @@ var TEMPLATE_BILLS_SETTING = {
             "field":"ParentID",
             "vAlign":0,
             "hAlign":1,
-            "font":"14.6667px Calibri"
+            "font":"14.6667px Calibri"/*,
+            "getText": function (node) {
+                if (node) {
+                    return node.getParentID();
+                } else {
+                    return '';
+                }
+            }*/
         }
     }, {
         "width":50,
@@ -178,7 +192,14 @@ var TEMPLATE_BILLS_SETTING = {
             "field":"NextSiblingID",
             "vAlign":0,
             "hAlign":1,
-            "font":"14.6667px Calibri"
+            "font":"14.6667px Calibri"/*,
+            "getText": function (node) {
+                if (node) {
+                    return node.getNextSiblingID();
+                } else {
+                    return '';
+                }
+            }*/
         }
     }]
 };