Forráskód Böngészése

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

TonyKang 7 éve
szülő
commit
aeb467a378

+ 21 - 4
modules/bills_lib/models/bills_lib_interfaces.js

@@ -241,6 +241,7 @@ billsLibDao.prototype.createBills = function(cbillsData, callback){
     let nid = cbillsData.NextSiblingID;
     let billsLibId = cbillsData.billsLibId;
     let updatePreData = cbillsData.updatePreData;
+    let sectionInfo = cbillsData.sectionInfo;
     let lastOperator = cbillsData.lastOperator, lastOperateDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
     let newBills = {
         ID: newId,
@@ -253,6 +254,7 @@ billsLibDao.prototype.createBills = function(cbillsData, callback){
         ruleText: '',
         Expression: '',
         recharge:'',
+        sectionInfo: sectionInfo,
         deleted: false
     };
     async.parallel([
@@ -480,7 +482,7 @@ billsLibDao.prototype.upLevel = function(data, callback){
         },
         oprNode: function (data) {
             return function (cb){
-                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID, NextSiblingID: data.NextSiblingID}}, function(err){
+                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID, NextSiblingID: data.NextSiblingID, sectionInfo: data.sectionInfo}}, function(err){
                     if(err){
                         cb(err);
                     }
@@ -504,7 +506,7 @@ billsLibDao.prototype.upLevel = function(data, callback){
         },
         nextSiblingNode: function (data) {
             return function (cb) {
-                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID}}, function (err) {
+                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID, sectionInfo: data.sectionInfo}}, function (err) {
                     if(err){
                         cb(err);
                     }
@@ -536,7 +538,7 @@ billsLibDao.prototype.upLevel = function(data, callback){
         }
         else if(updateDatas[i].type === 'nextSiblingNode'){
             updateDatas[i].ID.forEach(function (id) {
-                let obj = {ID: id, ParentID: updateDatas[i].ParentID};
+                let obj = {ID: id, ParentID: updateDatas[i].ParentID, sectionInfo: updateDatas[i].sectionInfo};
                 functions.push(parallelFucs.nextSiblingNode(obj));
             });
         }
@@ -596,7 +598,7 @@ billsLibDao.prototype.downLevel = function (data, callback) {
         },
         oprNode: function (data) {
             return function (cb) {
-                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID, NextSiblingID: data.NextSiblingID}}, function (err) {
+                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {ParentID: data.ParentID, NextSiblingID: data.NextSiblingID, sectionInfo: data.sectionInfo}}, function (err) {
                     if(err){
                         cb(err);
                     }
@@ -617,6 +619,18 @@ billsLibDao.prototype.downLevel = function (data, callback) {
                     }
                 });
             };
+        },
+        oprChildren: function (data) {
+            return function (cb) {
+                Bills.update({billsLibId: billsLibId, ID: data.ID, deleted: false}, {$set: {sectionInfo: data.sectionInfo}}, function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                });
+            };
         }
     }
     for(let i=0; i<updateDatas.length; i++){
@@ -626,6 +640,9 @@ billsLibDao.prototype.downLevel = function (data, callback) {
         else if(updateDatas[i].type === 'oprNode'){
             functions.push(parallelFucs.oprNode(updateDatas[i]));
         }
+        else if(updateDatas[i].type === 'oprChildren'){
+            functions.push(parallelFucs.oprChildren(updateDatas[i]));
+        }
         else {
             functions.push(parallelFucs.preChildren(updateDatas[i]));
         }

+ 4 - 3
modules/bills_lib/models/bills_lib_schemas.js

@@ -37,9 +37,9 @@ let itemsSchema = mongoose.Schema({
     {versionKey: false});
 
 let billsSchema = mongoose.Schema({
-    ID: Number,
-    ParentID: Number,
-    NextSiblingID: Number,
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
     code: String,
     name: String,
     unit: String,
@@ -50,6 +50,7 @@ let billsSchema = mongoose.Schema({
     items: [],
     recharge:String,
     billsLibId: Number,
+    sectionInfo: {},
     deleted: Boolean
 },
     {versionKey: false}

+ 7 - 0
modules/ration_repository/controllers/repository_views_controller.js

@@ -31,6 +31,13 @@ class ViewsController extends BaseController{
                 userID: req.session.managerData.userID
             });
     }
+    redirectInstallation(req, res){
+        res.render('maintain/ration_repository/anzhuang.html',
+            {
+                userAccount: req.session.managerData.username,
+                userID: req.session.managerData.userID
+            });
+    }
 }
 
 export default ViewsController;

+ 33 - 1
modules/ration_repository/models/schemas.js

@@ -82,6 +82,36 @@ let rationAssItemSchema = new Schema({
     maxValue: String
 }, { _id: false });
 
+//安装增加费-费用规则
+let feeRuleSchema = new Schema({
+    ID: String,
+    sectionId: String, //分册章节id
+    code: String,
+    rule: String,
+    base: String,
+    feeRate: Number,
+    labour: Number,
+    material: Number,
+    machine: Number
+});
+
+//安装增加费-分册章节
+let installSectionSchema = new Schema({
+    ID: String,
+    feeItemId: String,
+    name: String,
+    feeRule: [feeRuleSchema]
+});
+
+//安装增加费-费用项
+let installFeeItemSchema = new Schema({
+    ID: String,
+    feeItem: String, //费用项
+    feeType: String, //费用类型
+    position: String, //记取位置
+    section: []
+});
+
 //定额
 var rationItemSchema = new Schema({
     ID:Number,
@@ -132,7 +162,9 @@ let coeListModel = db.model("std_ration_lib_coe_list",coeListSchema, "std_ration
 let rationRepository = db.model("std_ration_lib_map", RepositoryMapSchema, "std_ration_lib_map");
 let rationChapterTreeModel = db.model("std_ration_lib_ration_chapter_trees", rationChapterTreeSchema, "std_ration_lib_ration_chapter_trees");
 let rationItemModel = db.model("std_ration_lib_ration_items",rationItemSchema, "std_ration_lib_ration_items");
+let installSectionModel = db.model("std_ration_lib_installationSection", installSectionSchema, "std_ration_lib_installationSection")
+let installFeeItemModel = db.model("std_ration_lib_installation", installFeeItemSchema, "std_ration_lib_installation");
 //补充定额
 let compleRationModel = db.model('complementary_ration_items', compleRationSchema, 'complementary_ration_items');
 
-export{coeListModel, rationRepository, rationChapterTreeModel, rationItemModel, compleRationModel};
+export{coeListModel, rationRepository, rationChapterTreeModel, rationItemModel, installFeeItemModel, installSectionModel, compleRationModel};

+ 1 - 0
modules/ration_repository/routes/ration_rep_routes.js

@@ -26,6 +26,7 @@ module.exports =  function (app) {
     app.get('/rationRepository/ration',viewsController.auth, viewsController.init, viewsController.redirectRation);
     app.get('/rationRepository/lmm', viewsController.auth, viewsController.init, viewsController.redirectGlj);
     app.get('/rationRepository/coeList', viewsController.auth, viewsController.init, viewsController.redirectCoeList);
+    app.get('/rationRepository/installation', viewsController.auth, viewsController.init, viewsController.redirectInstallation);
 
     apiRouter.post("/getCompilationList", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getCompilationList);
 

+ 8 - 2
modules/std_glj_lib/controllers/gljController.js

@@ -23,8 +23,8 @@ class GljController extends BaseController{
         }
     }
     getGljTree(req,res){
-        let gljLibId = req.body.gljLibId;
-        gljDao.getGljTypes(gljLibId,function(err,data){
+        let data = JSON.parse(req.body.data);
+        gljDao.getGljTypes(data.gljLibId, function(err,data){
             callback(req,res,err, 'Get Tree', data)
         });
     }
@@ -72,6 +72,12 @@ class GljController extends BaseController{
             callback(req,res, err, results)
         });
     }
+    updateNodes(req, res){
+        let data = JSON.parse(req.body.data);
+        gljDao.updateNodes(data.updateData, data.lastOpr, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
     getGljItems(req, res) {
         let repId = req.body.repositoryId,
             gljType = req.body.type,

+ 18 - 8
modules/std_glj_lib/models/gljMapModel.js

@@ -3,6 +3,7 @@
  */
 import gljMapModel from "./schemas";
 import {gljModel, gljClassModel} from "./schemas";
+import {rationRepository} from "../../ration_repository/models/schemas";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
@@ -84,15 +85,24 @@ class GljMapDao extends OprDao{
             }
         })
     }
-    getAllGljLib(callback){
-        gljMapModel.find({deleted: false}, function (err, result) {
-            if(err){
-                callback(err, '没有定额库数据!', null);
-            }
-            else{
-                callback(null, '成功', result);
+    async getAllGljLib(callback){
+        try{
+            let gljLibs = await gljMapModel.find({deleted: false});
+            for(let gljLib of gljLibs){
+                let tempRationLibs = [];
+                for(let rationLib of gljLib.rationLibs){
+                    let rLib = await rationRepository.findOne({ID: rationLib.ID, deleted: false});
+                    if(rLib !== undefined && rLib !== null){
+                        tempRationLibs.push({ID: rationLib.ID, dispName: rLib.dispName});
+                    }
+                }
+                gljLib._doc.rationLibs = tempRationLibs;
             }
-        })
+            callback(null, '成功', gljLibs);
+        }
+        catch(err){
+            callback(err, '没有定额库数据!', null);
+        }
     }
     createGljLib(gljLibObj, callback){
         counter.counterDAO.getIDAfterCount(counter.moduleName.stdGljLib, 1, function (err, result) {

+ 84 - 8
modules/std_glj_lib/models/gljModel.js

@@ -9,13 +9,13 @@ import async from "async";
 
 class GljDao  extends OprDao{
     getGljTypes (gljLibId, callback){
-        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},function(err,data){
             if(data.length) {
-                callback(false,data);
+                callback(0, data);
             }
             else  if(err) callback("获取工料机类型错误!",false)
             else {
-                gljClassTemplateModel.find({'$or': [{isDeleted: null}, {isDeleted: false}]}, function (err, datas) {
+                gljClassTemplateModel.find({'$or': [{isDeleted: null}, {isDeleted: false}, {deleted: false}]}, function (err, datas) {
                     if(err){
                         callback("获取工料机类型错误!", false);
                     }
@@ -38,7 +38,7 @@ class GljDao  extends OprDao{
                             });
                         }, function (err) {
                             if(err) callback("新增工料机类型错误!", false);
-                            else callback(false, rst);
+                            else callback(0, rst);
                         });
                     }
                 });
@@ -67,8 +67,8 @@ class GljDao  extends OprDao{
         }
     }
 
-    getGljItemsByRep(repositoryId,callback = null){
-        let me = this;
+    async getGljItemsByRep(repositoryId,callback = null){
+   /*     let me = this;
         if (callback === null) {
             return gljModel.find({"repositoryId": repositoryId});
         } else {
@@ -79,7 +79,33 @@ class GljDao  extends OprDao{
                     callback(false,data);
                 }
             })
+        }*/
+
+        let me = this;
+        let rst = [];
+        //批量获取异步
+        let functions = [];
+        let count = await gljModel.find({repositoryId: repositoryId, $or: [{deleted: null}, {deleted: false}]}).count();
+        let findCount = Math.ceil(count/500);
+        for(let i = 0, len = findCount; i < len; i++){
+            functions.push((function(flag) {
+                return function (cb) {
+                    gljModel.find({repositoryId: repositoryId, deleted: null}, cb).skip(flag).sort({ID: 1}).limit(500);
+                }
+            })(i*500));
         }
+        async.parallel(functions,  function (err, results) {
+            if(err){
+                callback(err, null);
+            }
+            else{
+                for(let stdGljs of results){
+                    rst = rst.concat(stdGljs);
+                }
+                me.sortToNumber(rst);
+                callback(0, rst);
+            }
+        });
     }
 
     getGljItemByType (repositoryId, type, callback){
@@ -316,7 +342,57 @@ class GljDao  extends OprDao{
 
     }
 
-    updateNodes (repId, lastOpr, nodes, callback) {
+    updateNodes (updateData, lastOpr, callback) {
+        let functions = [];
+        for (let i = 0, len = updateData.length; i < len; i++) {
+            functions.push((function(doc) {
+                return function(cb) {
+                    if(doc.updateType === 'update'){
+                        gljClassModel.update({repositoryId: doc.updateData.repositoryId, ID: doc.updateData.ID}, doc.updateData, function (err) {
+                            if(err){
+                                cb(err);
+                            }
+                            else {
+                                cb(null);
+                            }
+                        });
+                    }
+                    else if(doc.updateType === 'new'){
+                        gljClassModel.create(doc.updateData, function (err) {
+                            if(err){
+                                cb(err);
+                            }
+                            else {
+                                cb(null);
+                            }
+                        });
+                    }
+                };
+            })(updateData[i]));
+        }
+        if(updateData.length > 0){
+            functions.push((function () {
+                return function (cb) {
+                    GljDao.updateOprArr({ID: updateData[0].updateData.rationRepId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null);
+                        }
+                    })
+                }
+            })());
+        }
+        async.parallel(functions, function(err, results) {
+            if(!err){
+                err = 0;
+            }
+            callback(err, results);
+        });
+    }
+
+  /*  updateNodes (repId, lastOpr, nodes, callback) {
         var functions = [];
         for (var i=0; i < nodes.length; i++) {
             functions.push((function(doc) {
@@ -340,7 +416,7 @@ class GljDao  extends OprDao{
         async.parallel(functions, function(err, results) {
             callback(err, results);
         });
-    }
+    }*/
     removeNodes (repId, lastOpr, nodeIds, preNodeId, preNodeNextId, callback){
         var functions = [];
         if (preNodeId != -1) {

+ 1 - 0
modules/std_glj_lib/routes/routes.js

@@ -29,6 +29,7 @@ module.exports = function (app) {
     router.post("/createNewGljTypeNode",gljController.auth, gljController.init, gljController.createNewGljTypeNode);
     router.post("/updateGljNodes",gljController.auth, gljController.init, gljController.updateGljNodes);
     router.post("/deleteGljNodes",gljController.auth, gljController.init, gljController.deleteGljNodes);
+    router.post("/updateNodes",gljController.auth, gljController.init, gljController.updateNodes);
     router.post("/getGljDistType",gljController.auth, gljController.init, gljController.getGljDistType);
     router.post("/getGljTree",gljController.auth, gljController.init, gljController.getGljTree);
     router.post("/getGljItems",gljController.auth, gljController.init, gljController.getGljItems);

+ 2 - 1
public/counter/counter.js

@@ -33,7 +33,8 @@ const COUNTER_MODULE_NAME = {
     billsLib: 'billsLib',
     billsLib_jobs: 'billsLib_jobs',
     billsLib_items: 'billsLib_items',
-    coeList: 'coeList'
+    coeList: 'coeList',
+    installation: 'installation'
 }
 /*const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
     REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'*/

+ 8 - 8
public/web/id_tree.js

@@ -422,7 +422,7 @@ var idTree = {
             }
         })();
         Tree.prototype.newNodeID = function () {
-            if (this.rangeNodeID() === -1) {
+            if (this.rangeNodeID() == -1) {
                 return this.maxNodeID() + 1;
             } else {
                 if (this.maxNodeID() < this.rangeNodeID()) {
@@ -460,7 +460,7 @@ var idTree = {
             // set parent by pid, set nextSibling by nid
             datas.forEach(function (data) {
                 node = that.nodes[prefix + data[that.setting.id]];
-                if (data[that.setting.pid] === that.setting.rootId) {
+                if (data[that.setting.pid] == that.setting.rootId) {
                     that.roots.push(node);
                 } else {
                     parent = that.nodes[prefix + data[that.setting.pid]];
@@ -500,8 +500,8 @@ var idTree = {
 
         Tree.prototype.insert = function (parentID, nextSiblingID) {
             var newID = this.newNodeID(), node = null, data = {};
-            var parent = parentID === -1 ? null : this.nodes[this.prefix + parentID];
-            var nextSibling = nextSiblingID === -1 ? null: this.nodes[this.prefix + nextSiblingID];
+            var parent = parentID == -1 ? null : this.nodes[this.prefix + parentID];
+            var nextSibling = nextSiblingID == -1 ? null: this.nodes[this.prefix + nextSiblingID];
             if (newID !== -1) {
                 data = {};
                 data[this.setting.id] = newID;
@@ -522,8 +522,8 @@ var idTree = {
         Tree.prototype.getInsertData = function (parentID, nextSiblingID) {
             var data = [];
             var newID = this.newNodeID();
-            var parent = parentID === -1 ? null : this.nodes[this.prefix + parentID];
-            var nextSibling = nextSiblingID === -1 ? null: this.nodes[this.prefix + nextSiblingID];
+            var parent = parentID == -1 ? null : this.nodes[this.prefix + parentID];
+            var nextSibling = nextSiblingID == -1 ? null: this.nodes[this.prefix + nextSiblingID];
             if (newID !== -1) {
                 data.push({type: 'new', data: this.getDataTemplate(newID, parent ? parent.getID() : this.setting.rootId, nextSibling ? nextSibling.getID() : this.setting.rootId)});
 
@@ -538,8 +538,8 @@ 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 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;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 0
public/web/uuid.js


+ 1 - 0
web/maintain/bills_lib/html/qingdan.html

@@ -238,6 +238,7 @@
     <!-- JS. -->
     <script 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>
+    <script src="/public/web/uuid.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>

+ 2 - 2
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -176,11 +176,11 @@ var billsAjax = {
             }
         });
     },
-    createBills: function(lastOperator, billsLibId, newId, pid, nid, updatePreData, callback){
+    createBills: function(lastOperator, billsLibId, newId, pid, nid, updatePreData, sectionInfo, callback){
         $.ajax({
             type: 'post',
             url: 'stdBillsEditor/createBills',
-            data: {data: JSON.stringify({lastOperator: lastOperator, billsLibId: billsLibId, newId: newId, ParentID: pid, NextSiblingID: nid, updatePreData: updatePreData})},
+            data: {data: JSON.stringify({lastOperator: lastOperator, billsLibId: billsLibId, newId: newId, ParentID: pid, NextSiblingID: nid, updatePreData: updatePreData, sectionInfo: sectionInfo})},
             dataType: 'json',
             success: function(result){
                 if(!result.error){

+ 83 - 7
web/maintain/bills_lib/scripts/db_controller.js

@@ -8,8 +8,11 @@ var dbController = {
         btn.attr('doing', 'true');
         if(controller.tree.items.length === 0){
             controller.tree.maxNodeID(0);
-            let newNodeId = controller.tree.newNodeID();
-            billsAjax.createBills(userAccount, billsLibId, newNodeId, -1 , -1, null, function(){
+           // let newNodeId = controller.tree.newNodeID();
+            let newNodeId = uuid.v1();
+            console.log(newNodeId);
+            let sectionInfo = {first: null, second: null, third: null};
+            billsAjax.createBills(userAccount, billsLibId, newNodeId, -1 , -1, null, sectionInfo, function(){
                 controller.insert();
                 controller.tree.selected.jobs = new Array();
                 controller.tree.selected.items = new Array();
@@ -23,9 +26,12 @@ var dbController = {
             let node = controller.tree.selected;
             if(node){
                 var updateId = node.getID(), createpid = node.getParentID(), createnid = node.getNextSiblingID();
-                let newNodeId = controller.tree.newNodeID();
+                //let newNodeId = controller.tree.newNodeID();
+                let newNodeId = uuid.v1();
+                console.log(newNodeId);
                 let updatePreData = {ID: updateId, NextSiblingID: newNodeId};
-                billsAjax.createBills(userAccount, billsLibId, newNodeId, createpid, createnid, updatePreData, function(){
+                let sectionInfo = tools.getSectionInfo(node);
+                billsAjax.createBills(userAccount, billsLibId, newNodeId, createpid, createnid, updatePreData, sectionInfo, function(){
                     controller.insert();
                     controller.tree.selected.jobs = new Array();
                     controller.tree.selected.items = new Array();
@@ -38,9 +44,12 @@ var dbController = {
             else {
                 let updateNode = controller.tree.roots[controller.tree.roots.length - 1];
                 let updateId = updateNode.getID();
-                let newNodeId = controller.tree.newNodeID();
+                //let newNodeId = controller.tree.newNodeID();
+                let newNodeId = uuid.v1();
+                console.log(newNodeId);
                 let updatePreData = {ID: updateId, NextSiblingID: newNodeId};
-                billsAjax.createBills(userAccount, billsLibId, newNodeId, -1, -1, updatePreData, function(){
+                let sectionInfo = tools.getSectionInfo(node);
+                billsAjax.createBills(userAccount, billsLibId, newNodeId, -1, -1, updatePreData, sectionInfo, function(){
                     controller.insert();
                     controller.tree.selected.jobs = new Array();
                     controller.tree.selected.items = new Array();
@@ -68,10 +77,12 @@ var dbController = {
         //node
         if(node){
             if(node.parent){
+                let oprSectionInfo = tools.getSectionInfo(node.parent);
                 let updateA = {
                     ID: node.getID(),
                     ParentID: node.parent.getParentID(),
                     NextSiblingID: node.parent.getNextSiblingID(),
+                    sectionInfo: oprSectionInfo,
                     type: 'oprNode'
                 };
                 updateData.push(updateA);
@@ -83,10 +94,21 @@ var dbController = {
                 }
                 updateData.push(updateB);
                 if(node.nextSibling){
+                    let nextSectionInfo = tools.getSectionInfo(node.parent);
+                    if(!tools.isDef(nextSectionInfo.first)){
+                        nextSectionInfo.first = node.getID();
+                    }
+                    else if(!tools.isDef(nextSectionInfo.second)){
+                        nextSectionInfo.second = node.getID();
+                    }
+                    else if(!tools.isDef(nextSectionInfo.third)){
+                        nextSectionInfo.third = node.getID();
+                    }
                     getNextSibling(node);
                     let updateC = {
                         ID: ids,
                         ParentID: node.getID(),
+                        sectionInfo: nextSectionInfo,
                         type: 'nextSiblingNode'
                     }
                     updateData.push(updateC);
@@ -117,6 +139,16 @@ var dbController = {
         var updateData = [];
         if(node){
             if(node.preSibling){
+                let oprSectionInfo = tools.getSectionInfo(node.preSibling);
+                if(!tools.isDef(oprSectionInfo.first)){
+                    oprSectionInfo.first = node.preSibling.getID();
+                }
+                else if(!tools.isDef(oprSectionInfo.second)){
+                    oprSectionInfo.second = node.preSibling.getID();
+                }
+                else if(!tools.isDef(oprSectionInfo.third)){
+                    oprSectionInfo.third = node.preSibling.getID();
+                }
                 var updateA = {
                     ID: node.preSibling.getID(),
                     NextSiblingID: node.getNextSiblingID(),
@@ -126,6 +158,7 @@ var dbController = {
                     ID: node.getID(),
                     ParentID: node.preSibling.getID(),
                     NextSiblingID: -1,
+                    sectionInfo: oprSectionInfo,
                     type: 'oprNode'
                 };
                 updateData.push(updateA);
@@ -138,6 +171,24 @@ var dbController = {
                     }
                     updateData.push(updateC);
                 }
+                //更新子节点sectionInfo
+                let childSectionInfo = {first: oprSectionInfo.first, second: oprSectionInfo.second, third: oprSectionInfo.third};
+                if(!tools.isDef(childSectionInfo.first)){
+                    childSectionInfo.first = node.getID();
+                }
+                else if(!tools.isDef(childSectionInfo.second)){
+                    childSectionInfo.second = node.getID();
+                }
+                else if(!tools.isDef(childSectionInfo.third)){
+                    childSectionInfo.third = node.getID();
+                }
+                for(let i = 0, len = node.children.length; i < len; i++){
+                    updateData.push({
+                        ID: node.children[i].getID(),
+                        sectionInfo: childSectionInfo,
+                        type: 'oprChildren'
+                    })
+                }
                 billsAjax.downLevel(userAccount, billsLibId, updateData, function(){
                     tools.btnAction(btn);
                     btn.attr('doing', 'false');
@@ -1382,8 +1433,33 @@ var tools = {
             }
         }
         return conformDatas;
-    }
+    },
+
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
 
+    getSectionInfo: function (node) {
+        let parentIDs = [];
+        let sectionInfo = {first: null, second: null, third: null};
+        getParent(node);
+        if(this.isDef(parentIDs[parentIDs.length - 1])){
+            sectionInfo.first = parentIDs[parentIDs.length - 1];
+        }
+        if(this.isDef(parentIDs[parentIDs.length - 2])){
+            sectionInfo.second = parentIDs[parentIDs.length - 2];
+        }
+        if(this.isDef(parentIDs[parentIDs.length - 3])){
+            sectionInfo.third = parentIDs[parentIDs.length - 3];
+        }
+        return sectionInfo;
+        function getParent(node){
+            if(node.parent){
+                parentIDs.push(node.parent.data.ID);
+                getParent(node.parent);
+            }
+        }
+    }
 };
 
 let pasteController = {

+ 1 - 1
web/maintain/ration_repository/dinge.html

@@ -37,7 +37,7 @@
                       <a class="nav-link px-3" id="fuzhu" href="#">附注条件</a>
                   </li>
                   <li class="nav-item">
-                      <a class="nav-link px-3" href="#">安装增加费</a>
+                      <a class="nav-link px-3" id="anzhuang" href="anzhuang.html">安装增加费</a>
                   </li>
               </ul>
         </nav>

+ 4 - 0
web/maintain/ration_repository/js/coe.js

@@ -16,6 +16,10 @@ var pageObj = {
             $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
         });
 
+        $("#anzhuang").click(function(){
+            $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+        });
+
         var libID = getQueryString("repository");
         var libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + libID);
         if (libName) {

+ 5 - 0
web/maintain/ration_repository/js/ration.js

@@ -9,6 +9,11 @@ $("#gongliao").click(function(){
 $("#fuzhu").click(function(){
     $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
 });
+
+$("#anzhuang").click(function(){
+    $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+});
+
 const digital = {
     gljPrc: -3,//计算定额基价时单个工料机价格取三位
     rationBasePrc: -2,

+ 6 - 2
web/maintain/ration_repository/js/repository_glj.js

@@ -10,6 +10,10 @@ $("#fuzhu").click(function(){
     $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
 });
 
+$("#anzhuang").click(function(){
+    $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+});
+
 var pageOprObj = {
     rationLibName : null,
     rationLibId: null,
@@ -119,7 +123,7 @@ repositoryGljObj = {
         $.ajax({
             type:"POST",
             url:"api/getGljTree",
-            data:{"gljLibID": gljLibID},
+            data:{data: JSON.stringify({"gljLibId": gljLibID})},
             dataType:"json",
             cache:false,
             timeout:20000,
@@ -147,7 +151,7 @@ repositoryGljObj = {
             data:{"repositoryId": gljLibID},
             dataType:"json",
             cache:false,
-            timeout:5000,
+            timeout:10000,
             success:function(result){
                 if(!result.error) {
                     me.gljList = result.data;

+ 17 - 104
web/maintain/std_glj_lib/html/gongliao.html

@@ -38,116 +38,24 @@
             <div class="container-fluid">
                 <div class="row">
                     <!--org 3:7:2-->
-                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow-y: auto">
-                        <ul id="repositoryTree" class="ztree"></ul>
+                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow: hidden">
+                      <div class="tab-bar">
+                          <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                      </div>
+                      <div class="tab-content" id="gljClassSpread" style="overflow: hidden">
+                      </div>
+                        <!--<ul id="repositoryTree" class="ztree"></ul>-->
                   </div>
                   <div class="main-content col-lg-6 p-0">
                     <div id="GLJListSheet" class="main-data">
-                      <!--<table class="table table-sm table-bordered m-0">
-                      <thead>
-                        <tr>
-                          <th></th>
-                          <th>编码</th>
-                          <th>名称</th>
-                          <th>规格型号</th>
-                          <th>计量单位</th>
-                          <th>单价</th>
-                          <th>类型</th>
-                        </tr>
-                      </thead>
-                      <tbody>
-                        <tr>
-                          <td>1</td>
-                          <td>00010201</td>
-                          <td>土石方综合工日</td>
-                          <td></td>
-                          <td>工日</td>
-                          <td>22.00</td>
-                          <td>人工</td>
-                        </tr>
-                        <tr>
-                          <td>2</td>
-                          <td>03010101</td>
-                          <td>钢材</td>
-                          <td></td>
-                          <td>t</td>
-                          <td>2600.00</td>
-                          <td>材料</td>
-                        </tr>
-                        <tr>
-                          <td>3</td>
-                          <td>36290101</td>
-                          <td>水</td>
-                          <td></td>
-                          <td>m3</td>
-                          <td>2600.00</td>
-                          <td>材料</td>
-                        </tr>
-                        <tr>
-                          <td>4</td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                        </tr>
-                        <tr>
-                          <td>5</td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                        </tr>
-                        <tr>
-                          <td>6</td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                          <td></td>
-                        </tr>
-                      </tbody>
-                    </table>-->
                     </div>
                   </div>
                     <div id="gljComponentSheet" class="main-side col-lg-3 p-0">
-                     <!-- <table class="table table-sm table-bordered m-0">
-                        <thead>
-                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
-                        </thead>
-                        <tbody>
-                          <tr><td>1</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
-                        </tbody>
-                      </table>
-                      <table class="table table-sm table-bordered m-0">
-                        <thead>
-                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
-                        </thead>
-                        <tbody>
-                          <tr><td>1</td><td>01010101</td><td>水泥32.5</td><td>kg</td><td>0.25</td><td>243.000</td></tr>
-                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
-                        </tbody>
-                      </table>
-                      <table class="table table-sm table-bordered m-0">
-                        <thead>
-                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
-                        </thead>
-                        <tbody>
-                          <tr><td>1</td><td>xxx</td><td>机上人工</td><td>工日</td><td>28.00</td><td>2.540</td></tr>
-                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
-                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
-                        </tbody>
-                      </table>-->
                     </div>
                 </div>
             </div>
@@ -248,7 +156,12 @@
     <script type="text/javascript" src="/public/web/scMathUtil.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+    <script type="text/javascript" src="/public/web/id_tree.js"></script>
+    <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
+    <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/glj.js"></script>
+    <script type="text/javascript" src="/web/maintain/std_glj_lib/js/gljClassTree.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/gljComponent.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/components.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>

+ 28 - 9
web/maintain/std_glj_lib/js/glj.js

@@ -21,9 +21,12 @@ let pageOprObj = {
             //repositoryGljObj.getRationGljIds(gljLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(gljLibId);
-                repositoryGljObj.getGljTree(gljLibId, function () {
+              /*  repositoryGljObj.getGljTree(gljLibId, function () {
                     repositoryGljObj.getGljItems(gljLibId);
-                });
+                });*/
+                repositoryGljObj.getGljItems(gljLibId, function () {
+                    gljClassTreeObj.getGljClassTree(gljLibId);
+                })
             });
         });
     }
@@ -154,7 +157,7 @@ let repositoryGljObj = {
             }
         })
     },
-    getGljItems: function(repId) {
+    getGljItems: function(repId, callback) {
         let me = this;
         $.ajax({
             type:"POST",
@@ -162,18 +165,15 @@ let repositoryGljObj = {
             data:{"repositoryId": repId},
             dataType:"json",
             cache:false,
-            timeout:5000,
+            timeout:20000,
             success:function(result){
                 if(!result.error) {
                     me.gljList = result.data;
                     me.workBook.getSheet(0).setRowCount(result.data.length);
                     me.sortGlj();
                     me.currentGlj = me.gljList.length > 0 ? me.gljList[0] : null;//初始
-                    let rootNode = me.treeObj.getNodes()[0];
-                    if(rootNode && rootNode.isParent && rootNode.isFirstNode){
-                        componentOprObj.rootNode = rootNode;
-                        me.treeObj.selectNode(rootNode);
-                        gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
+                    if(callback){
+                        callback();
                     }
                 }
             },
@@ -1099,6 +1099,25 @@ let repositoryGljObj = {
             }
         }
     },
+    updateParentNodeIds: function (nodes, caller) {
+        let private_build_parentNodeIds = function(pNodeId, nodesArr){
+            let rst = [];
+            for (let i = 0; i < nodesArr.length; i++) {
+                if (nodesArr[i].children.length > 0) {
+                    rst = rst.concat(private_build_parentNodeIds(nodesArr[i].data.ID, nodesArr[i].children));
+                } else {
+                    rst.push(nodesArr[i].data.ID);
+                }
+            }
+            if (pNodeId && rst.length > 0) {
+                caller.parentNodeIds["_pNodeId_" + pNodeId] = rst;
+            }
+            return rst;
+        };
+        if (caller.parentNodeIds) {
+            private_build_parentNodeIds(null, nodes);
+        }
+    },
     sortGlj: function() {
         let me = this;
         me.gljList.sort(function(a, b){

+ 501 - 0
web/maintain/std_glj_lib/js/gljClassTree.js

@@ -0,0 +1,501 @@
+/**
+ * Created by Zhong on 2018/1/16.
+ */
+let gljClassTreeObj = {
+    cache: null,//ref to tree.items
+    tree: null,
+    controller: null,
+    workBook: null,
+    sheet: null,
+    updateType: {new: 'new', update: 'update'},
+    insertBtn: $('#tree_Insert'),
+    removeBtn: $('#tree_remove'),
+    upLevelBtn: $('#tree_upLevel'),
+    downLevelBtn: $('#tree_downLevel'),
+    downMoveBtn: $('#tree_downMove'),
+    upMoveBtn: $('#tree_upMove'),
+    setting: {
+        sheet: {
+            cols:[
+                {
+                    head: {
+                        titleNames: ['名称'],
+                        spanCols: [1],
+                        spanRows: [2],
+                        vAlign: [1, 1],
+                        hAlign: [1, 1],
+                        font: 'Arial'
+                    },
+                    data: {
+                        field: 'Name',
+                        vAlign: 1,
+                        hAlign: 0,
+                        font: 'Arial'
+                    },
+                    width: 400
+                }
+            ],
+            headRows: 1,
+            headRowHeight: [30],
+            emptyRows: 0,
+            treeCol: 0
+        },
+        tree: {
+            id: 'ID',
+            pid: 'ParentID',
+            nid: 'NextSiblingID',
+            rootId: -1
+        },
+        options: {
+            tabStripVisible:  false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true
+        }
+    },
+
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
+    isFunc: function (v) {
+        return this.isDef(v) && typeof v === 'function';
+    },
+    //sheet things
+    setOptions: function (workbook, opts) {
+        for(let opt in opts){
+            workbook.options[opt] = opts[opt];
+        }
+    },
+
+    renderFunc: function (sheet, func) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        if(this.isFunc(func)){
+            func();
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+
+    buildSheet: function () {
+        if(!this.isDef(this.workBook)){
+            this.workBook = new GC.Spread.Sheets.Workbook($('#gljClassSpread')[0], {sheetCount: 1});
+            this.sheet = this.workBook.getActiveSheet();
+            this.setOptions(this.workBook, this.setting.options);
+            this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
+            this.bindEvents(this.sheet);
+        }
+    },
+
+    bindEvents: function (sheet) {
+        let me = gljClassTreeObj;
+        const Events = GC.Spread.Sheets.Events;
+        sheet.bind(Events.SelectionChanged, me.onSelectionChanged);
+        sheet.bind(Events.EditEnded, me.onEditEnded);
+        sheet.bind(Events.ClipboardPasted, me.onClipboardPasted);
+    },
+
+    onSelectionChanged: function (sender, info) {
+        let me = gljClassTreeObj;
+        if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
+            let row = info.newSelections[0].row;
+            let node = me.cache[row];
+            me.initSelection(node);
+        }
+        else {
+            me.refreshBtn(null);
+        }
+    },
+
+    onEditEnded: function (sender, args) {
+        let me = gljClassTreeObj;
+        let postData = [];
+        let v = me.isDef(args.editingText) ? args.editingText.toString().trim() : '';
+        let node = me.cache[args.row];
+        if(me.isDef(node) && node.data.Name !== v){
+            let updateObj = me.getUpdateObj(me.updateType.update, node.getID(), null, null, v, null);
+            postData.push(updateObj);
+            //ajax
+            //update
+            me.gljClassTreeAjax(postData, function (rstData) {
+                node.data.Name = v;
+            }, function () {
+                args.sheet.setValue(args.row, args.col, node.data.Name ? node.data.Name : '');
+            });
+        }
+    },
+
+    onClipboardPasted: function (sender, info) {
+        let me = gljClassTreeObj;
+        let items = sheetCommonObj.analyzePasteData({header: [{dataCode: 'Name'}]}, info);
+        let postData = [];
+        let frontData = [];
+        for(let i = 0, len = items.length; i < len; i++){
+            let row = info.cellRange.row + i;
+            let node = me.cache[row];
+            if(me.isDef(node) && me.isDef(items[i].Name) && node.data.Name !== items[i].Name){
+                let updateObj = me.getUpdateObj(me.updateType.update, node.getID(), null, null, items[i].Name, null);
+                postData.push(updateObj);
+                frontData.push({row: row, Name: items[i].Name});
+                node.data.Name = items[i].Name;
+            }
+        }
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                for(let i = 0, len = frontData.length; i < len; i++){
+                    let node = me.cache[frontData[i]['row']];
+                    if(me.isDef(node)){
+                        node.data.Name = frontData[i]['Name'];
+                    }
+                }
+            }, function () {
+                for(let i = 0, len = frontData.length; i < len; i++){
+                    let node = me.cache[frontData[i]['row']];
+                    me.sheet.setValue(frontData[i]['row'], 0, me.isDef(node) ? node.data.Name : '');
+                }
+            });
+        }
+    },
+
+    getGljClassTree: function (gljLibId, callback) {
+        let me = gljClassTreeObj;
+        let re = repositoryGljObj;
+        let url = 'api/getGljTree';
+        let postData = {gljLibId: gljLibId};
+        let sucFunc = function (rstData) {
+            zTreeHelper.createTree(rstData, componentSetting, "componentTree", componentOprObj);
+            let rootNode = componentOprObj.treeObj.getNodes()[0];
+            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                componentOprObj.rootNode = rootNode;
+            }
+            if (rstData && rstData.length > 0) {
+                me.gljCurTypeId = rstData[0].ID;
+            }
+            //init
+            me.buildSheet();
+            me.initTree(rstData);
+            me.cache = me.tree.items;
+            re.updateParentNodeIds(me.cache, re);
+            me.bindBtn();
+            me.initController(me.tree, me.sheet, me.setting.sheet);
+            me.controller.showTreeData();
+            me.sheet.setFormatter(-1, 0, '@');
+            me.initSelection(me.tree.selected);
+            if(callback){
+                callback();
+            }
+        };
+        let errFunc = function () {
+
+        };
+        CommonAjax.post(url, postData, sucFunc, errFunc);
+    },
+
+    initTree: function (datas) {
+        this.tree = idTree.createNew(this.setting.tree);
+        this.tree.loadDatas(datas);
+        this.tree.selected = this.tree.items.length > 0 ? this.tree.items[0] : null;
+    },
+
+    initController: function (tree, sheet, setting) {
+        this.controller = TREE_SHEET_CONTROLLER.createNew(tree, sheet, setting);
+    },
+
+    refreshBtn: function (selected) {
+        let me = this;
+        me.insertBtn.removeClass('disabled');
+        me.removeBtn.removeClass('disabled');
+        me.upLevelBtn.removeClass('disabled');
+        me.downLevelBtn.removeClass('disabled');
+        me.downMoveBtn.removeClass('disabled');
+        me.upMoveBtn.removeClass('disabled');
+        if(!me.isDef(selected)){
+            me.removeBtn.addClass('disabled');
+            me.upLevelBtn.addClass('disabled');
+            me.downLevelBtn.addClass('disabled');
+            me.downMoveBtn.addClass('disabled');
+            me.upMoveBtn.addClass('disabled');
+        }
+        else {
+            if(!me.isDef(selected.preSibling)){
+                me.downLevelBtn.addClass('disabled');
+                me.upMoveBtn.addClass('disabled');
+            }
+            if(!me.isDef(selected.nextSibling)){
+                me.downMoveBtn.addClass('disabled');
+            }
+            if(!me.isDef(selected.parent)){
+                me.upLevelBtn.addClass('disabled');
+            }
+        }
+    },
+
+    bindBtn: function () {
+        let me = this;
+        me.insertBtn.click(function () {
+            me.insert();
+        });
+        me.removeBtn.click(function () {
+            me.remove(me.tree.selected);
+        });
+        me.upLevelBtn.click(function () {
+            me.upLevel(me.tree.selected);
+        });
+        me.downLevelBtn.click(function () {
+            me.downLevel(me.tree.selected);
+        });
+        me.downMoveBtn.click(function () {
+            me.downMove(me.tree.selected);
+        });
+        me.upMoveBtn.click(function () {
+            me.upMove(me.tree.selected);
+        });
+    },
+
+    insert: function () {
+        let me = this;
+        let re = repositoryGljObj;
+        me.insertBtn.addClass('disabled');
+        let postData = [];
+        let newID = me.tree.newNodeID();
+        if(!me.isDef(newID)){
+            return;
+        }
+        let selected = me.tree.selected;
+        let insertObj = me.getUpdateObj(me.updateType.new, newID, -1, -1, '', null);
+        if(me.isDef(selected)) {
+            let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), newID, null, null, null);
+            postData.push(updateObj);
+            insertObj.updateData.ParentID = selected.getParentID();
+            if(me.isDef(selected.nextSibling)){
+                insertObj.updateData.NextSiblingID = selected.getNextSiblingID();
+            }
+        }
+        postData.push(insertObj);
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.insert();
+                me.refreshBtn(me.tree.selected);
+                //fresh tools
+                me.initTools(me.tree.selected);
+                re.updateParentNodeIds(me.cache, re);
+            });
+        }
+    },
+    remove: function (selected) {
+        let me = this;
+        let re = repositoryGljObj;
+        me.removeBtn.addClass('disabled');
+        let postData = [], IDs = [];
+        if(!selected){
+            return;
+        }
+        getDelIds(selected);
+        function getDelIds(node){
+            if(me.isDef(node)){
+                IDs.push(node.getID());
+                if(node.children.length > 0){
+                    for(let i = 0, len = node.children.length; i < len; i++){
+                        getDelIds(node.children[i]);
+                    }
+                }
+            }
+        }
+        if(me.isDef(selected.preSibling)){
+            let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
+            postData.push(updateObj);
+        }
+        if(IDs.length > 0){
+            for(let i = 0, len = IDs.length; i < len; i++){
+                let delObj = me.getUpdateObj(me.updateType.update, IDs[i], null, null, null, true);
+                postData.push(delObj);
+            }
+        }
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.delete();
+                me.refreshBtn(me.tree.selected);
+                me.initTools(me.tree.selected);
+                re.updateParentNodeIds(me.cache, re);
+            });
+        }
+    },
+    upLevel: function (selected) {
+        let me = this;
+        let re = repositoryGljObj;
+        me.upLevelBtn.addClass('disabled');
+        let postData = [];
+        if(!me.isDef(selected)){
+            return;
+        }
+        if(!me.isDef(selected.parent)){
+            return;
+        }
+        if(me.isDef(selected.preSibling)){
+            let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), -1, null, null, null);
+            postData.push(updateObj);
+        }
+        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.parent.getNextSiblingID(), selected.parent.getParentID(), null, null);
+        postData.push(updateObj);
+        let updateParent = me.getUpdateObj(me.updateType.update, selected.getParentID(), selected.getID(), null, null, null);
+        postData.push(updateParent);
+        let nextIDs = [];
+        getNext(selected);
+        function getNext(node){
+            if(me.isDef(node.nextSibling)){
+                nextIDs.push(node.getNextSiblingID());
+                getNext(node.nextSibling);
+            }
+        }
+        for(let i = 0, len = nextIDs.length; i < len; i++){
+            postData.push(me.getUpdateObj(me.updateType.update, nextIDs[i], null, selected.getID(), null, null));
+        }
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.upLevel();
+                me.refreshBtn(me.tree.selected);
+                re.updateParentNodeIds(me.cache, re);
+            });
+        }
+
+    },
+    downLevel: function (selected) {
+        let me = this;
+        let re = repositoryGljObj;
+        me.downLevelBtn.addClass('disabled');
+        let postData = [];
+        if(!me.isDef(selected)){
+            return;
+        }
+        if(!me.isDef(selected.preSibling)){
+            return;
+        }
+        let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
+        postData.push(updatePre);
+        if(selected.preSibling.children.length > 0){
+            let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.children[selected.preSibling.children.length - 1].getID(), selected.getID(), null, null, null);
+            postData.push(updateObj);
+        }
+        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), -1, selected.preSibling.getID(), null, null);
+        postData.push(updateObj);
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.downLevel();
+                me.refreshBtn(me.tree.selected);
+                re.updateParentNodeIds(me.cache, re);
+            });
+        }
+    },
+    upMove: function (selected) {
+        let me = this;
+        me.upMoveBtn.addClass('disabled');
+        let postData = [];
+        if(!me.isDef(selected)){
+            return;
+        }
+        if(!me.isDef(selected.preSibling)){
+            return;
+        }
+        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.preSibling.getID(), null, null, null);
+        postData.push(updateObj);
+        let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
+        postData.push(updatePre);
+        if(me.isDef(selected.preSibling.preSibling)){
+            let updatePrepre = me.getUpdateObj(me.updateType.update, selected.preSibling.preSibling.getID(), selected.getID(), null, null, null);
+            postData.push(updatePrepre);
+        }
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.upMove();
+                me.refreshBtn(me.tree.selected);
+            });
+        }
+    },
+    downMove: function (selected) {
+        let me = this;
+        me.downMoveBtn.addClass('disabled');
+        let postData = [];
+        if(!me.isDef(selected)){
+            return;
+        }
+        if(!me.isDef(selected.nextSibling)){
+            return;
+        }
+        if(me.isDef(selected.preSibling)){
+            let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
+            postData.push(updatePre);
+        }
+        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.nextSibling.getNextSiblingID(), null, null, null);
+        postData.push(updateObj);
+        let updateNext = me.getUpdateObj(me.updateType.update, selected.getNextSiblingID(), selected.getID(), null, null, null);
+        postData.push(updateNext);
+        if(postData.length > 0){
+            //ajax
+            me.gljClassTreeAjax(postData, function (rstData) {
+                me.controller.downMove();
+                me.refreshBtn(me.tree.selected);
+            });
+        }
+    },
+    getUpdateObj: function (updateType, id, nid, pid, name, deleted) {
+        let updateObj = Object.create(null);
+        updateObj.updateType = '';
+        updateObj.updateData = Object.create(null);
+        updateObj.updateData.repositoryId = pageOprObj.gljLibId;
+        if(this.isDef(updateType)){
+            updateObj.updateType = updateType;
+        }
+        if(this.isDef(id)){
+            updateObj.updateData.ID = id;
+        }
+        if(this.isDef(nid)){
+            updateObj.updateData.NextSiblingID = nid;
+        }
+        if(this.isDef(pid)){
+            updateObj.updateData.ParentID = pid;
+        }
+        if(this.isDef(name)){
+            updateObj.updateData.Name = name;
+        }
+        if(this.isDef(deleted)){
+            updateObj.updateData.deleted = true;
+        }
+        return updateObj;
+    },
+    gljClassTreeAjax: function (postData, scFunc, errFunc) {
+        CommonAjax.post('api/updateNodes', {updateData: postData, lastOpr: userAccount}, scFunc, errFunc);
+    },
+    //模仿默认点击
+    initSelection: function (node) {
+        let me = this,
+            re = repositoryGljObj,
+            that = gljComponentOprObj;
+        if(!re.isDef(node)){
+            return;
+        }
+        me.refreshBtn(node);
+
+        let gljTypeId = node.data.ID;
+        re.gljCurTypeId = node.data.ID;
+        re.addGljObj = null;
+        sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, 10);
+        if (re.parentNodeIds["_pNodeId_" + gljTypeId]) {
+            re.currentOprParent = 1;
+            re.currentCache = re.getParentCache(re.parentNodeIds["_pNodeId_" + gljTypeId]);
+            re.workBook.getSheet(0).setRowCount(re.currentCache.length);
+        } else {
+            re.currentOprParent = 0;
+            re.currentCache = re.getCache();
+        }
+        re.showGljItems(re.currentCache, gljTypeId);
+        me.workBook.focus(true);
+    }
+}

+ 10 - 4
web/maintain/std_glj_lib/js/gljComponent.js

@@ -371,11 +371,13 @@ let gljComponentOprObj = {
         let gljCache = that.gljList;
         if(info.cellRange.col === 0){
             for(let i = 0; i < items.length; i++){
+                let existCode = false;
                 for(let j = 0; j < gljCache.length; j++){
                     if(items[i].code === gljCache[j].code){
+                        existCode = true;
                         if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
                             || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )
-                            || (that.currentGlj.gljType === 4 && gljCache[i].gljType === 4 && that.currentGlj.ID !== gljCache[i].ID)){
+                            || (that.currentGlj.gljType === 4 && gljCache[j].gljType === 4 && that.currentGlj.ID !== gljCache[i].ID)){
                             //是否与原有组成物不同
                             let isExist = false;
                             for(let k = 0; k < component.length; k++){
@@ -417,10 +419,14 @@ let gljComponentOprObj = {
                         }
 
                     }
-                    else{
+                  /*  else{
                         me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
                             typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
-                    }
+                    }*/
+                }
+                if(!existCode){
+                    me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
+                        typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
                 }
             }
             if(isChange){
@@ -501,7 +507,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, gljBasePrc = 0;
         for(let i = 0; i < component.length; i++){
             let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
-            gljBasePrc += scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2);
+            gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2) + gljBasePrc, -2);
         }
         return gljBasePrc;
     }

+ 13 - 12
web/maintain/std_glj_lib/js/global.js

@@ -11,15 +11,16 @@ function autoFlashHeight(){
     $(".form-list").height($(window).height()-headerHeight-50 );
     $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
     $(".main-data").height($(window).height()-headerHeight);
+    $(".main-side .tab-content").height($(window).height()-headerHeight-38);
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/
 $(function(){
-/*侧滑*/
-$(".open-sidebar").click(function(){
-    $(".slide-sidebar").animate({width:"800"}).addClass("open");
-});
-$("body").click(function(event){
+    /*侧滑*/
+    $(".open-sidebar").click(function(){
+        $(".slide-sidebar").animate({width:"800"}).addClass("open");
+    });
+    $("body").click(function(event){
         var e = event || window.event; //浏览器兼容性
         if(!$(event.target).is('a')) {
             var elem = event.target || e.srcElement;
@@ -33,10 +34,10 @@ $("body").click(function(event){
         }
 
     });
-/*侧滑*/
-/*工具提示*/
-$('*[data-toggle=tooltip]').mouseover(function() {
- $(this).tooltip('show');
-  });
-/*工具提示*/
-});
+    /*侧滑*/
+    /*工具提示*/
+    $('*[data-toggle=tooltip]').mouseover(function() {
+        $(this).tooltip('show');
+    });
+    /*工具提示*/
+});

+ 10 - 0
web/users/js/main_tree_col.js

@@ -75,6 +75,16 @@ let MainTreeCol = {
         },
         forContain:function (node) {
             return MainTreeCol.readOnly.non_ration(node)&&!MainTreeCol.readOnly.glj(node);
+        },
+        forCode:function (node) {
+            return MainTreeCol.readOnly.glj(node)|| (node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type===rationType.gljRation);
+        },
+        forUnit:function (node) {
+            if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
+                return true;
+            }else {
+                return treeNodeTools.isRation(node);
+            }
         }
     },
     cellType: {