소스 검색

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

TonyKang 7 년 전
부모
커밋
1a3541c45d
44개의 변경된 파일1268개의 추가작업 그리고 642개의 파일을 삭제
  1. 23 0
      modules/bills_lib/controllers/stdBillsLib_permissionController.js
  2. 4 3
      modules/bills_lib/models/bills_lib_interfaces.js
  3. 26 4
      modules/bills_lib/models/bills_lib_schemas.js
  4. 1 0
      modules/bills_lib/routes/bills_lib_routes.js
  5. 1 1
      modules/common/base/base_controller.js
  6. 0 37
      modules/common/std/schemas/std_glj_lib_map.js
  7. 1 1
      modules/common/std/std_glj_lib_map_model.js
  8. 54 19
      modules/ration_repository/controllers/ration_repository_controller.js
  9. 3 3
      modules/ration_repository/controllers/repository_glj_controller.js
  10. 8 7
      modules/ration_repository/models/glj_repository.js
  11. 34 147
      modules/ration_repository/models/ration_item.js
  12. 94 61
      modules/ration_repository/models/repository_map.js
  13. 1 0
      modules/ration_repository/routes/ration_rep_routes.js
  14. 31 12
      modules/std_glj_lib/controllers/gljController.js
  15. 17 4
      modules/std_glj_lib/models/gljMapModel.js
  16. 51 18
      modules/std_glj_lib/models/gljModel.js
  17. 25 6
      modules/std_glj_lib/models/schemas.js
  18. 2 1
      modules/std_glj_lib/routes/routes.js
  19. 18 2
      modules/templates/controllers/bills_template_controller.js
  20. 26 19
      modules/templates/models/bills_template.js
  21. 25 0
      modules/templates/models/schemas/bills_template.js
  22. 5 6
      modules/templates/routes/bills_template_router.js
  23. 7 0
      modules/users/controllers/compilation_controller.js
  24. 16 1
      public/web/sheet/sheet_common.js
  25. 10 0
      public/web/tree_sheet/tree_sheet_helper.js
  26. 17 7
      web/maintain/bills_lib/html/main.html
  27. 7 0
      web/maintain/bills_lib/html/neirong.html
  28. 14 0
      web/maintain/bills_lib/html/qingdan.html
  29. 15 0
      web/maintain/bills_lib/html/tezheng.html
  30. 23 4
      web/maintain/bills_lib/scripts/bills_lib_ajax.js
  31. 8 8
      web/maintain/ration_repository/gongliao.html
  32. 273 11
      web/maintain/ration_repository/js/main.js
  33. 18 3
      web/maintain/ration_repository/js/ration.js
  34. 33 29
      web/maintain/ration_repository/js/ration_glj.js
  35. 18 16
      web/maintain/ration_repository/js/repository_glj.js
  36. 14 10
      web/maintain/ration_repository/main.html
  37. 219 165
      web/maintain/std_glj_lib/js/glj.js
  38. 52 20
      web/maintain/std_glj_lib/js/gljComponent.js
  39. 18 7
      web/maintain/std_glj_lib/js/main.js
  40. 28 4
      web/users/js/col_setting.js
  41. 5 2
      web/users/js/compilation.js
  42. 7 2
      web/users/views/compilation/add.html
  43. 10 2
      web/users/views/compilation/modal.html
  44. 6 0
      web/users/views/tool/index.html

+ 23 - 0
modules/bills_lib/controllers/stdBillsLib_permissionController.js

@@ -3,8 +3,31 @@
  */
 let billsController = require("./bills_lib_controllers");
 import baseController from "../../common/base/base_controller";
+import CompilationModel from "../../users/models/compilation_model";
 
+let callback = function(req, res, err, message, data){
+    res.json({error: err, message: message, data: data});
+}
 class billsLibPermContr extends baseController{
+    async getCompilationList(req, res){
+        try{
+            let compilationModel = new CompilationModel(), rst = [];
+            let compilationList = await compilationModel.getCompilationList();
+            if(compilationList.length <= 0){
+                throw '没有数据';
+            }
+            else{
+
+                compilationList.forEach(function (compilation) {
+                    rst.push({_id: compilation._id, name: compilation.name});
+                })
+                callback(req, res, false, '', rst);
+            }
+        }
+        catch(err) {
+            callback(req, res, err, '没有数据', null);
+        }
+    }
     getMaxNumber(req, res){
         billsController.getMaxNumber(req, res);
     }

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

@@ -66,10 +66,10 @@ billsLibDao.prototype.getStdBillsLib = function(callback){
 billsLibDao.prototype.createStdBillsLib = function(clibData, callback){
     counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1, function(err, result){
         let billsLibId = result.value.sequence_value;
-        let userId = clibData.userId;
         let userAccount = clibData.userAccount;
         let billsLibName = clibData.name;
-        let createDate = Date.now();
+        let compilationId = clibData.compilationId;
+        let compilationName = clibData.compilationName;
         let dateStr = moment().format('YYYY-MM-DD HH:mm:ss');
         let newStdBillsLib = {
             creator: userAccount,
@@ -77,7 +77,8 @@ billsLibDao.prototype.createStdBillsLib = function(clibData, callback){
             recentOpr: [{operator: userAccount, operateDate: dateStr}],
             billsLibId: billsLibId,
             billsLibName: billsLibName,
-            localeType: -1,
+            compilationId: compilationId,
+            compilationName: compilationName,
             deleted: false
         };
         StdBillsLib.create(newStdBillsLib, function(err){

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

@@ -1,19 +1,41 @@
 let mongoose = require('mongoose');
 
+let oprSchema = mongoose.Schema({
+    operateDate: String,
+    operator: String
+},
+    {_id: false},
+    {versionKey: false});
+
 let stdBillsLibSchema =mongoose.Schema({
         creator: String,
         createDate: String,
-        recentOpr: [],
+        recentOpr: [oprSchema],
        /* lastOperator: String,
         lastOperateDate: Date,*/
         billsLibId: Number,
         billsLibName: String,
-        localeType: Number,
+        compilationId: String,
+        compilationName: String,
         deleted: Boolean
     },
     {versionKey: false}
 );
 
+let jobsSchema = mongoose.Schema({
+    id: Number,
+    serialNo: Number
+},
+    {_id: false},
+    {versionKey: false});
+
+let itemsSchema = mongoose.Schema({
+    id: Number,
+    serialNo: Number
+},
+    {_id: false},
+    {versionKey: false});
+
 let billsSchema = mongoose.Schema({
     ID: Number,
     ParentID: Number,
@@ -23,8 +45,8 @@ let billsSchema = mongoose.Schema({
     unit: String,
     ruleText: String,
     Expression: String,
-    jobs: Array,
-    items: Array,
+    jobs: [],
+    items: [],
     recharge:String,
     billsLibId: Number,
     deleted: Boolean

+ 1 - 0
modules/bills_lib/routes/bills_lib_routes.js

@@ -21,6 +21,7 @@ module.exports =function (app) {
      app.get('/stdJobs', viewsContr.auth, viewsContr.init, viewsContr.redirectStdJobs);
      app.get('/stdItems', viewsContr.auth, viewsContr.init, viewsContr.redirectStdItems);
 
+     billsRouter.post('/getCompilationList', billsLibContr.auth, billsLibContr.init, billsLibContr.getCompilationList);
      billsRouter.post('/getMaxNumber', billsLibContr.auth, billsLibContr.init, billsLibContr.getMaxNumber);
      billsRouter.post('/getABillsLib', billsLibContr.auth, billsLibContr.init, billsLibContr.getABillsLib);
      billsRouter.post("/getStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.getStdBillsLib);

+ 1 - 1
modules/common/base/base_controller.js

@@ -67,7 +67,7 @@ class BaseController {
                 currentPermission = currentPermission.split(',');
                 let withoutPermission = ['login', 'dashboard'];
                 // 工具页面整合
-                let toolPermission = ['rationRepository', 'stdBillsmain'];
+                let toolPermission = ['rationRepository', 'stdBillsmain', 'stdGljRepository'];
                 let hasToolPermission = false;
                 if (controller === 'tool') {
                     for (let tmpPermission of toolPermission) {

+ 0 - 37
modules/common/std/schemas/std_glj_lib_map.js

@@ -1,37 +0,0 @@
-/**
- * 工料机库数据模型
- *
- * @author CaiAoLin
- * @date 2017/8/16
- * @version
- */
-/*
-import mongoose from "mongoose";
-
-let Schema = mongoose.Schema;
-let collectionName = 'std_glj_lib_map';
-let modelSchema = {
-    // 显示名称
-    dispName: String,
-    // 类型
-    appType: String,
-    // 是否被删除标记
-    deleted: Boolean,
-    // 自增ID
-    ID: Number,
-    // 创建时间
-    createDate: String,
-    // 创建者
-    creator: String,
-    // 最近一次操作
-    recentOpr: Schema.Types.Mixed,
-    // 编办id
-    compilationId: String,
-    // 编办名称
-    compilationName: String,
-    // 定额库
-    rationLibs: Schema.Types.Mixed
-};
-
-let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
-export {model as default, collectionName as collectionName};*/

+ 1 - 1
modules/common/std/std_glj_lib_map_model.js

@@ -6,7 +6,7 @@
  * @version
  */
 import BaseModel from "../../common/base/base_model";
-import STDGLJLibMapSchema from "./schemas/std_glj_lib_map";
+import STDGLJLibMapSchema from "../../std_glj_lib/models/schemas";
 
 class STDGLJLibMapModel extends BaseModel {
 

+ 54 - 19
modules/ration_repository/controllers/ration_repository_controller.js

@@ -4,6 +4,8 @@
 var rationRepository = require("../models/repository_map");
 import baseController from "../../common/base/base_controller";
 import CompilationModel from "../../users/models/compilation_model";
+import gljMapModel from "../../std_glj_lib/models/schemas";
+import async from "async";
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
@@ -20,8 +22,37 @@ class RationRepositoryController extends baseController{
 
                compilationList.forEach(function (compilation) {
                    rst.push({_id: compilation._id, name: compilation.name});
+               });
+               //获得相关编办下的工料机库
+               let parallelFucs = [];
+               for(let i = 0; i < rst.length; i++){
+                   parallelFucs.push((function (obj) {
+                       return function (cb) {
+                           gljMapModel.find({compilationId: obj._id, deleted: false}, function (err, result) {
+                               if(err){
+                                   cb(err);
+                               }
+                               else{
+                                   cb(null, result);
+                               }
+                           })
+                       }
+                   })(rst[i]));
+               }
+               async.parallel(parallelFucs, function (err, result) {
+                   if(err){
+                       callback(req, res, err, '没有数据', null);
+                   }
+                   else{
+                       let gljLibsRst = [];
+                       for(let i = 0; i < result.length; i++){
+                           for(let j = 0; j < result[i].length; j++){
+                               gljLibsRst.push(result[i][j]);
+                           }
+                       }
+                       callback(req, res, false, '', {compilation: rst, gljLibs: gljLibsRst});
+                   }
                })
-               callback(req, res, false, '', rst);
            }
        }
         catch(err) {
@@ -38,6 +69,16 @@ class RationRepositoryController extends baseController{
             }
         })
     }
+    getRationLib(req, res){
+        let libId = req.body.libId;
+        rationRepository.getRationLib(libId, function(err, data){
+            if (data) {
+                callback(req, res, err, "has data",data);
+            } else {
+                callback(req, res, err, "no data", null);
+            }
+        });
+    }
     getDisPlayRationLibs(req, res){
         rationRepository.getDisplayRationLibs(function(err, data){
             if (data) {
@@ -66,27 +107,21 @@ class RationRepositoryController extends baseController{
             }
         })
     }
+
     deleteRationLib(req,res){
-        var rationName = req.body.rationName, lastOperator = req.body.lastOperator;
-        rationRepository.deleteRationLib(rationName, lastOperator, function(err,data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        })
+        let oprtor = req.body.oprtor,
+            libId = req.body.libId;
+        rationRepository.deleteRationLib(oprtor, libId, function (err, message) {
+            callback(req, res, err, message, null);
+        });
     }
+
     updateRationRepositoryName(req, res) {
-        var orgName = req.body.rationName;
-        var newName = req.body.newName;
-        var lastOperator = req.body.lastOperator;
-        rationRepository.updateName(orgName, newName, lastOperator, function(err, data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        });
+        let oprtor = req.body.oprtor,
+            renameObj = JSON.parse(req.body.renameObj);
+        rationRepository.updateName(oprtor, renameObj, function (err, message) {
+            callback(req, res, err, message, null);
+        })
     }
 }
 

+ 3 - 3
modules/ration_repository/controllers/repository_glj_controller.js

@@ -20,8 +20,8 @@ class RepositoryGljController extends BaseController{
         }
     }
     getGljTree(req,res){
-        var rationLibId = req.body.rationLibId;
-        gljRepository.getGljTypes(rationLibId,function(err,data){
+        var gljLibID = req.body.gljLibID;
+        gljRepository.getGljTypes(gljLibID,function(err,data){
             callback(req,res,err, 'Get Tree', data)
         });
     }
@@ -52,7 +52,7 @@ class RepositoryGljController extends BaseController{
         });
     }
     getGljItems(req, res) {
-        var repId = req.body.repositoryId,
+        var repId = req.body.gljLibID,
             gljType = req.body.type,
             gljCode = req.body.code;
         if (gljCode) {

+ 8 - 7
modules/ration_repository/models/glj_repository.js

@@ -36,10 +36,11 @@ var gljItemModel = db.model("std_ration_lib_glj_list",gljSchema, "std_ration_lib
 var repositoryMap = require('./repository_map');
 var counter = require('../../../public/counter/counter');
 let moment = require('moment');
+import {gljModel, gljClassModel} from "../../std_glj_lib/models/schemas";
 
 var gljItemDAO = function(){};
-gljItemDAO.prototype.getGljTypes = function(rationLibId, callback){
-    gljTypeModel.find({"repositoryId": rationLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+gljItemDAO.prototype.getGljTypes = function(gljLibID, callback){
+    gljClassModel.find({"repositoryId": gljLibID, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
         if(data.length) callback(false,data);
         else  if(err) callback("获取工料机类型错误!",false)
         else callback(false,false);
@@ -47,35 +48,35 @@ gljItemDAO.prototype.getGljTypes = function(rationLibId, callback){
 };
 
 gljItemDAO.prototype.getGljItemsByRep = function(repositoryId,callback){
-    gljItemModel.find({"repositoryId": repositoryId},function(err,data){
+    gljModel.find({"repositoryId": repositoryId},function(err,data){
         if(err) callback(true, "")
         else callback(false,data);
     })
 };
 
 gljItemDAO.prototype.getGljItemByType = function(repositoryId, type, callback){
-    gljItemModel.find({"repositoryId": repositoryId, "gljType": type},function(err,data){
+    gljModel.find({"repositoryId": repositoryId, "gljType": type},function(err,data){
         if(err) callback(true, "")
         else callback(false, data);
     })
 };
 
 gljItemDAO.prototype.getGljItem = function(repositoryId, code, callback){
-    gljItemModel.find({"repositoryId": repositoryId, "code": code},function(err,data){
+    gljModel.find({"repositoryId": repositoryId, "code": code},function(err,data){
         if(err) callback(true, "")
         else callback(false, data);
     })
 };
 
 gljItemDAO.prototype.getGljItems = function(gljIds, callback){
-    gljItemModel.find({"ID": {"$in": gljIds}},function(err,data){
+    gljModel.find({"ID": {"$in": gljIds}},function(err,data){
         if(err) callback(true, "")
         else callback(false, data);
     })
 };
 
 gljItemDAO.prototype.getGljItemsByCode = function(repositoryId, codes, callback){
-    gljItemModel.find({"repositoryId": repositoryId,"code": {"$in": codes}},function(err,data){
+    gljModel.find({"repositoryId": repositoryId,"code": {"$in": codes}},function(err,data){
         if(err) callback(true, "")
         else callback(false, data);
     })

+ 34 - 147
modules/ration_repository/models/ration_item.js

@@ -212,24 +212,52 @@ function round(v,e){
     return Math.round(v*t)/t;
 }
 
-rationItemDAO.prototype.updateRationBasePrc = function (data, callback) {
-    let basePrcArr = data.basePrcArr,
+rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, callback) {
+   // let basePrcArr = data.basePrcArr;
        // adjGljId = data.gljId, adjBasePrice = data.basePrice, adjGljType = data.gljType,
-        repId = data.repId, lastOpr = data.lastOpr;
+      //  repId = data.repId, lastOpr = data.lastOpr;
     //
-    let updateArr;
+   // let updateArr;
     async.each(basePrcArr, function (basePrcObj, finalCb) {
         let adjGljId = basePrcObj.gljId, adjBasePrice = basePrcObj.basePrice, adjGljType = basePrcObj.gljType;
         async.waterfall([
             function (cb) {
-                rationItemModel.find({'rationGljList.gljId': adjGljId}, function (err, result) {
+                if(typeof basePrcObj.delete !== 'undefined' && basePrcObj.delete === 1){
+                    rationItemModel.find({'rationGljList.gljId': adjGljId},{ID: 1, rationGljList: 1}, function (err, result) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            //删除
+                            rationItemModel.update({'rationGljList.gljId': adjGljId}, {$pull: {rationGljList: {gljId: adjGljId}}}, {multi: true}, function (err) {
+                                if(err){
+                                    cb(err);
+                                }
+                                else{
+                                    cb(null, result);
+                                }
+                            });
+                        }
+                    });
+                }
+                else{
+                    rationItemModel.find({'rationGljList.gljId': adjGljId}, function (err, result) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null, result);
+                        }
+                    });
+                }
+               /* rationItemModel.find({'rationGljList.gljId': adjGljId}, function (err, result) {
                     if(err){
                         cb(err);
                     }
                     else{
                         cb(null, result);
                     }
-                });
+                });*/
             },
             function (result, cb) {
                 async.each(result, function (rationItem, ecb) {
@@ -332,16 +360,6 @@ rationItemDAO.prototype.updateRationBasePrc = function (data, callback) {
                     }
                 });
             },
-            function (cb) {
-                rationRepositoryDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                    if(err){
-                        cb(err);
-                    }
-                    else{
-                        cb(null);
-                    }
-                })
-            }
         ], function (err) {
             if(err){
                 finalCb(err);
@@ -358,137 +376,6 @@ rationItemDAO.prototype.updateRationBasePrc = function (data, callback) {
             callback(null, '');
         }
     });
-    //
-    /*async.waterfall([
-        function (cb) {
-            rationItemModel.find({'rationGljList.gljId': adjGljId}, function (err, result) {
-                if(err){
-                    cb(err);
-                }
-                else{
-                    cb(null, result);
-                }
-            });
-        },
-        function (result, cb) {
-            async.each(result, function (rationItem, ecb) {
-                let rationGljList = rationItem.rationGljList,
-                    gljIds = [];
-                rationGljList.forEach(function (rationGlj) {
-                    gljIds.push(rationGlj.gljId);
-                });
-                gljDao.getGljItems(gljIds, function(err, gljItems){
-                    if(err){
-                        ecb(err);
-                    }
-                    else{
-                        let gljArr = [];
-                        for(let i=0; i<gljItems.length; i++){
-                            let gljParentType = -1;
-                            if(gljItems[i].ID === adjGljId){
-                                gljItems[i].gljType = adjGljType;
-                            }
-                            if(gljItems[i].gljType <= 3){
-                                gljParentType = gljItems[i].gljType;
-                            }
-                            if(gljItems[i].gljType > 200 && gljItems[i].gljType < 300){
-                                gljParentType = 2;
-                            }
-                            if(gljItems[i].gljType > 300 && gljItems[i].gljType < 400){
-                                gljParentType = 3;
-                            }
-                            if(gljItems[i].ID === adjGljId){
-                                gljArr.push({gljId: gljItems[i].ID, basePrice: adjBasePrice, gljParentType: gljParentType});
-                            }
-                            else {
-                                gljArr.push({gljId: gljItems[i].ID, basePrice: gljItems[i].basePrice, gljParentType: gljParentType});
-                            }
-                        }
-                        gljArr.forEach(function (gljItem) {
-                            rationGljList.forEach(function (rationGlj) {
-                                if(gljItem.gljId === rationGlj.gljId){
-                                    gljItem.consumeAmt = rationGlj.consumeAmt;
-                                }
-                            })
-                        });
-                        //recalculate the price of ration
-                        let labourPrc = [], materialPrc = [], machinePrc = [], singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0};
-                        gljArr.forEach(function (gljItem) {
-                            if(gljItem.gljParentType !== -1){
-                                singlePrc = round(gljItem.basePrice * gljItem.consumeAmt, 3);
-                                if(gljItem.gljParentType === 1){
-                                    labourPrc.push(singlePrc);
-                                }
-                                else if(gljItem.gljParentType ===2){
-                                    materialPrc.push(singlePrc);
-                                }
-                                else{
-                                    machinePrc.push(singlePrc);
-                                }
-                            }
-                        });
-                        if(labourPrc.length > 0){
-                            let sumLaP = 0;
-                            for(let i=0; i<labourPrc.length; i++){
-                                sumLaP += labourPrc[i];
-                            }
-                            updatePrc.labourPrice = round(sumLaP, 2);
-                        }
-                        if(materialPrc.length > 0){
-                            let sumMtP = 0;
-                            for(let i= 0; i<materialPrc.length; i++){
-                                sumMtP += materialPrc[i];
-                            }
-                            updatePrc.materialPrice = round(sumMtP, 2);
-                        }
-                        if(machinePrc.length > 0){
-                            let sumMaP = 0;
-                            for(let i =0; i< machinePrc.length; i++){
-                                sumMaP += machinePrc[i];
-                            }
-                            updatePrc.machinePrice = round(sumMaP, 2);
-                        }
-                        updatePrc.basePrice = updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice;
-                        //updateDataBase
-                        rationItemModel.update({ID: rationItem.ID}, {$set: {labourPrice: updatePrc.labourPrice, materialPrice: updatePrc.materialPrice,
-                            machinePrice: updatePrc.machinePrice, basePrice: updatePrc.basePrice}},
-                            function (err, result) {
-                                if(err){
-                                    ecb(err);
-                                }
-                                else {
-                                    ecb(null);
-                                }
-                            });
-                    }
-                });
-            }, function(err){
-                if(err){
-                    cb(err);
-                }
-                else {
-                    cb(null);
-                }
-            });
-        },
-        function (cb) {
-            rationRepositoryDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                if(err){
-                    cb(err);
-                }
-                else{
-                    cb(null);
-                }
-            })
-        }
-    ], function (err) {
-        if(err){
-            callback(err, 'Error');
-        }
-        else{
-            callback(null, '');
-        }
-    });*/
 };
 
 rationItemDAO.prototype.getRationGljIds = function (data, callback) {

+ 94 - 61
modules/ration_repository/models/repository_map.js

@@ -6,19 +6,29 @@ var mongoose = require('mongoose');
 var dbm = require("../../../config/db/db_manager");
 let async = require("async");
 let moment = require('moment');
+import gljMapModel from "../../std_glj_lib/models/schemas";
 //var stringUtil = require('../../../public/stringUtil');
 var rationLibdb = dbm.getCfgConnection("scConstruct");
 var Schema = mongoose.Schema;
+
+let oprSchema = new Schema({
+        operateDate: String,
+        operator: String
+    },
+    {_id: false},
+    {versionKey: false});
+
 var RepositoryMapSchema = new Schema({
     "ID": Number,
     "dispName" : String,
     "appType" : String, //如:"建筑" / "公路"
-    "compilationId": Number, //编办
+    "compilationId": String, //编办
     "compilationName": String,
+    "gljLib": Number,
     "descr" : String,
     "creator": String,
     "createDate": String,
-    "recentOpr" :[],
+    "recentOpr" :[oprSchema],
     "deleted": Boolean
 },  {versionKey: false});
 var counter = require('../../../public/counter/counter');
@@ -29,17 +39,29 @@ function createNewLibModel(rationLibObj){
     var rst = {};
     rst.dispName = rationLibObj.dispName;
     rst.appType = rationLibObj.appType?rationLibObj.appType:'construct';
-    rst.localeType = rationLibObj.localeType?rationLibObj.localeType:'';
-    rst.descr = rationLibObj.descr;
+    rst.compilationId = rationLibObj.compilationId;
+    rst.compilationName = rationLibObj.compilationName;
+    rst.gljLib = rationLibObj.gljLib;
     rst.creator = rationLibObj.creator;
     rst.createDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
-    rst.recentOpr = [{operator: rationLibObj.lastOperator, operateDate: rst.createDate}],
+    rst.recentOpr = [{operator: rationLibObj.creator, operateDate: rst.createDate}],
     rst.deleted = false;
     return rst;
 }
 
 var rationRepositoryDao = function(){};
 
+rationRepositoryDao.prototype.updateGljLib = function (gljLibId, callback) {
+    rationRepository.update({gljLib: gljLibId}, {$set: {gljLib: -1}}, {multi: true}, function (err) {
+        if(err){
+            callback(err);
+        }
+        else{
+            callback(null);
+        }
+    })
+};
+
 rationRepositoryDao.prototype.updateOprArr= function(findSet, oprtor, oprDate, cb){
     rationRepository.find(findSet, function (err, result) {
         if(err){
@@ -133,13 +155,39 @@ rationRepositoryDao.prototype.addRationRepository = function( rationLibObj,callb
         var rMap = createNewLibModel(rationLibObj);
         rMap.ID = result.value.sequence_value;
         new rationRepository(rMap).save(function(err, result) {
-            if (err) callback("Error", null)
-            else
-                callback(false, result);
+            if (err) callback("Error", null);
+            else{
+                //向引用工料机库的添加标记
+                gljMapModel.update({ID: rMap.gljLib, deleted: false}, {$addToSet: {rationLibs: {ID: rMap.ID, dispName: rMap.dispName}}}, function (err, data) {
+                    if(err){
+                        rationRepository.remove({ID: rMap.ID}, function (err) {
+                            if(err){
+                                callback("创建失败且回滚失败!", null);
+                            }
+                            else{
+                                callback("创建失败,已回滚!", null);
+                            }
+                        });
+                    }
+                    else{
+                        callback(false, result);
+                    }
+                });
+            }
         });
     });
 };
 
+rationRepositoryDao.prototype.getRationLib = function(libId, callback) {
+    rationRepository.find({ID: libId, "deleted": false}, function(err, data){
+        if (err) {
+            callback( 'Error', null);
+        } else {
+            callback( false, data);
+        }
+    });
+};
+
 rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
     rationRepository.find({"deleted": false}, function(err, data){
         if (err) {
@@ -150,69 +198,54 @@ rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
     });
 };
 
-rationRepositoryDao.prototype.updateName = function(orgName,newName, lastOpr, callback){
-    rationRepository.find({"dispName":newName, "deleted": false}, function(err, data){
-        if (data.length == 0) {
-            async.waterfall([
-                function (cb) {
-                    rationRepository.update({dispName:orgName},{$set:{dispName:newName}},function(err){
-                        if(err) cb(err);
-                        else cb(null)
-                    });
-                },
-                function (cb) {
-                    new rationRepositoryDao().updateOprArr({dispName: newName}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                        if(err){
-                            cb(err)
-                        }
-                        else{
-                            cb(null);
-                        }
-                    });
-                }
-            ], function (err) {
+rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback){
+    rationRepository.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName}}, function (err) {
+        if(err){
+            callback(err, '重命名失败!');
+        }
+        else{
+            new rationRepositoryDao().updateOprArr({ID: renameObj.ID, deleted: false}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
                 if(err){
-                    callback('err', false);
+                    callback(err, '更新最近操作者失败!');
                 }
                 else{
-                    callback(false, 'ok');
+                    callback(null, '成功!');
                 }
             });
-        } else
-            callback("不可重名!",false);
+        }
     });
 }
 
-rationRepositoryDao.prototype.deleteRationLib = function(rationName, lastOpr,  callback){
-    rationRepository.find({"dispName":rationName, "deleted": false}, function(err, data){
-        if (data.length == 1) {
-            async.parallel([
-                function (cb) {
-                    rationRepository.update({dispName:rationName, deleted: false},{$set: {deleted: true}},function(err){
-                        if(err) cb(err);
-                        else cb(null);
-                    })
-                },
-                function (cb) {
-                    new rationRepositoryDao().updateOprArr({dispName: rationName}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                        if(err){
-                            cb(err);
-                        }
-                        else{
-                            cb(null);
-                        }
-                    });
-                }
-            ], function (err) {
-                if(err){
-                    callback("err", false)
-                }
+rationRepositoryDao.prototype.deleteRationLib = function(oprtor, libId, callback){
+    new rationRepositoryDao().updateOprArr({ID: libId, deleted: false}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+        if(err){
+            callback(err, '失败!')
+        }
+        else{
+            rationRepository.find({ID: libId, deleted: false}, function (err, result) {
+               if(err){
+                   callback(err, "没有数据!");
+               }
                 else{
-                    callback(false, "ok");
-                }
+                   rationRepository.update({ID: libId, deleted: false}, {$set: {deleted: true}}, function (err) {
+                       if(err){
+                           callback(err, '移除工料机库失败!');
+                       }
+                       else{
+                           //移除工料机库内被引用标记
+                           gljMapModel.update({ID: result[0].gljLib, deleted: false}, {$pull: {rationLibs: {ID: libId}}}, function (err) {
+                               if(err){
+                                   callback(err, '删除引用失败!');
+                               }
+                               else{
+                                   callback(null, '成功!');
+                               }
+                           });
+                       }
+                   });
+               }
             });
-        } else
-            callback("删除失败!",false);
+        }
     });
 }
 

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

@@ -38,6 +38,7 @@ module.exports =  function (app) {
 
     apiRouter.post("/getCompilationList", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getCompilationList);
 
+    apiRouter.post("/getRationLib",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getRationLib);
     apiRouter.post("/getRationDisplayNames",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getDisPlayRationLibs);
     apiRouter.post("/editRationLibs",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.updateRationRepositoryName);
     apiRouter.post("/addRationRepository",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.addRationRepository);

+ 31 - 12
modules/std_glj_lib/controllers/gljController.js

@@ -5,6 +5,7 @@
 import BaseController from "../../common/base/base_controller";
 import stdgljutil  from "../../../public/cache/std_glj_type_util";
 import GljDao from "../models/gljModel";
+import rationItemDao from "../../ration_repository/models/ration_item";
 
 let gljDao = new GljDao();
 let callback = function(req, res, err, message, data){
@@ -22,22 +23,40 @@ class GljController extends BaseController{
         }
     }
     getGljTree(req,res){
-        var gljLibId = req.body.gljLibId;
+        let gljLibId = req.body.gljLibId;
         gljDao.getGljTypes(gljLibId,function(err,data){
             callback(req,res,err, 'Get Tree', data)
         });
     }
+    updateRationBasePrc(req, res){
+        let basePrcArr = JSON.parse(req.body.basePrcArr);
+        rationItemDao.updateRationBasePrc(basePrcArr, function (err, message) {
+            if(err){
+                callback(req, res, err, message, null);
+            }
+            else{
+                callback(req, res, err, message, null);
+            }
+        });
+    }
+
+    getRationGljIds(req, res){
+        let rationLibs = req.body.rationLibs;
+        gljDao.getRationGljIds(rationLibs, function (err, msg, data) {
+            callback(req, res, err, msg, data);
+        })
+    }
     createNewGljTypeNode(req, res) {
-        var repId = req.body.repositoryId;
-        var lastNodeId = req.body.lastNodeId;
+        let repId = req.body.repositoryId;
+        let lastNodeId = req.body.lastNodeId;
         let lastOpr = req.body.lastOpr;
-        var nodeData = JSON.parse(req.body.rawNodeData);
+        let nodeData = JSON.parse(req.body.rawNodeData);
         gljDao.createNewNode(repId, lastOpr, lastNodeId, nodeData, function(err, msg, data){
             callback(req,res,err,msg, data)
         });
     }
     updateGljNodes(req, res) {
-        var nodes = JSON.parse(req.body.nodes);
+        let nodes = JSON.parse(req.body.nodes);
         let repId = req.body.repId,
             lastOpr = req.body.lastOpr;
         gljDao.updateNodes(repId, lastOpr, nodes, function(err,results){
@@ -45,16 +64,16 @@ class GljController extends BaseController{
         });
     }
     deleteGljNodes(req, res) {
-        var nodes = JSON.parse(req.body.nodes);
-        var preNodeId = req.body.preNodeId;
-        var preNodeNextId = req.body.preNodeNextId;
+        let nodes = JSON.parse(req.body.nodes);
+        let preNodeId = req.body.preNodeId;
+        let preNodeNextId = req.body.preNodeNextId;
         let repId = req.body.repId, lastOpr = req.body.lastOpr;
         gljDao.removeNodes(repId, lastOpr, nodes, preNodeId, preNodeNextId, function(err,results){
             callback(req,res, err, results)
         });
     }
     getGljItems(req, res) {
-        var repId = req.body.repositoryId,
+        let repId = req.body.repositoryId,
             gljType = req.body.type,
             gljCode = req.body.code;
         if (gljCode) {
@@ -72,13 +91,13 @@ class GljController extends BaseController{
         }
     }
     getGljItemsByIds(req, res) {
-        var gljIds = JSON.parse(req.body.gljIds);
+        let gljIds = JSON.parse(req.body.gljIds);
         gljDao.getGljItems(gljIds, function(err, data){
             callback(req,res,err,'Get Items',data)
         });
     }
     getGljItemsByCodes(req, res) {
-        var gljCodes = JSON.parse(req.body.gljCodes),
+        let gljCodes = JSON.parse(req.body.gljCodes),
             repId = req.body.repId;
         gljDao.getGljItemsByCode(repId, gljCodes, function(err, data){
             callback(req,res,err,'Get Items',data)
@@ -93,7 +112,7 @@ class GljController extends BaseController{
         })
     }
     mixUpdateGljItems(req, res){
-        var repId = req.body.repositoryId,
+        let repId = req.body.repositoryId,
             updateItems = JSON.parse(req.body.updateItems),
             addItems = JSON.parse(req.body.addItems),
             removeIds = JSON.parse(req.body.removeIds),

+ 17 - 4
modules/std_glj_lib/models/gljMapModel.js

@@ -1,10 +1,11 @@
 /**
  * Created by Zhong on 2017/8/11.
  */
-import {gljMapModel} from "./schemas";
+import gljMapModel from "./schemas";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
+let rationRepositoryDao =  require("../../ration_repository/models/repository_map");
 
 class OprDao {
     static updateOprArr(findSet, oprtor, date, cb){
@@ -134,12 +135,24 @@ class GljMapDao extends OprDao{
                 callback(err, '失败!')
             }
             else{
-                gljMapModel.update({ID: libId, deleted: false}, {$set: {deleted: true}}, function (err) {
+                gljMapModel.find({ID: libId, deleted: false}, function (err, result) {
                     if(err){
-                        callback(err, '移除工料机库失败!');
+                        callback(err, '数据不存在!');
                     }
                     else{
-                        callback(null, '成功!');
+                        if(result[0].rationLibs.length > 0){//已被引用
+                            callback(null, '此工料机库已被引用!');
+                        }
+                        else{
+                            gljMapModel.update({ID: libId, deleted: false}, {$set: {deleted: true}}, function (err) {
+                                if(err){
+                                    callback(err, '移除工料机库失败!');
+                                }
+                                else{
+                                   callback(null, '删除成功');
+                                }
+                            });
+                        }
                     }
                 });
             }

+ 51 - 18
modules/std_glj_lib/models/gljModel.js

@@ -116,34 +116,63 @@ class GljDao  extends OprDao{
                 callback(err, '更新组成物错误!', null);
             }
             else{
-                console.log(result);
                 callback(null, '成功!', result);
             }
         });
     }
 
     mixUpdateGljItems (repId, lastOpr, updateItems, addItems, rIds, callback) {
-        var me = this;
         if (updateItems.length == 0 && rIds.length == 0) {
-            me.addGljItems(repId, lastOpr, addItems, callback);
-        } else {
-            me.removeGljItems(repId, lastOpr, rIds, function(err, message, docs) {
-                me.updateGljItems(repId, lastOpr, updateItems, function(err, results){
-                    if (err) {
-                        callback(true, "Fail to update", false);
+            GljDao.addGljItems(repId, lastOpr, addItems, callback);
+        } else if (rIds.length > 0) {
+            GljDao.removeGljItems(repId, lastOpr, rIds, function(err, message, docs) {
+            });
+            gljModel.remove({ID: {$in: rIds}}, function (err) {
+                if(err){
+                    callback(err, '删除错误', null);
+                }
+                else{
+                    callback(null, '删除成功', null);
+                }
+            });
+        }
+        else if(updateItems.length > 0 || addItems.length > 0){
+            GljDao.updateGljItems(repId, lastOpr, updateItems, function(err, results){
+                if (err) {
+                    callback(true, "Fail to update", false);
+                } else {
+                    if (addItems && addItems.length > 0) {
+                        GljDao.addGljItems(repId, lastOpr, addItems, callback);
                     } else {
-                        if (addItems && addItems.length > 0) {
-                            me.addGljItems(repId, lastOpr, addItems, callback);
-                        } else {
-                            callback(false, "Save successfully", results);
-                        }
+                        callback(false, "Save successfully", results);
                     }
-                });
+                }
             });
         }
-    };
+    }
 
-    removeGljItems (repId, lastOpr, rIds, callback) {
+    /*mixUpdateGljItems (repId, lastOpr, updateItems, addItems, rIds, callback) {
+        if (updateItems.length == 0 && rIds.length == 0) {
+            GljDao.addGljItems(repId, lastOpr, addItems, callback);
+        } else if (rIds.length > 0) {
+            GljDao.removeGljItems(repId, lastOpr, rIds, function(err, message, docs) {
+            });
+        }else{
+            GljDao.updateGljItems(repId, lastOpr, updateItems, function(err, results){
+                if (err) {
+                    callback(true, "Fail to update", false);
+                } else {
+                    if (addItems && addItems.length > 0) {
+                        GljDao.addGljItems(repId, lastOpr, addItems, callback);
+                    } else {
+                        callback(false, "Save successfully", results);
+                    }
+                }
+            });
+        }
+    };*/
+
+    static removeGljItems (repId, lastOpr, rIds, callback) {
         if (rIds && rIds.length > 0) {
             gljModel.collection.remove({ID: {$in: rIds}}, null, function(err, docs){
                 if (err) {
@@ -164,7 +193,7 @@ class GljDao  extends OprDao{
         }
     }
 
-    addGljItems (repId, lastOpr, items, callback) {
+    static addGljItems (repId, lastOpr, items, callback) {
         if (items && items.length > 0) {
             counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, items.length, function(err, result){
                 var maxId = result.value.sequence_value;
@@ -195,7 +224,7 @@ class GljDao  extends OprDao{
         }
     }
 
-    updateGljItems(repId, lastOpr, items, callback) {
+    static updateGljItems(repId, lastOpr, items, callback) {
         var functions = [];
         for (var i=0; i < items.length; i++) {
             functions.push((function(doc) {
@@ -228,6 +257,10 @@ class GljDao  extends OprDao{
         });
     }
 
+    getRationGljIds(rationLibs, callback){
+
+    }
+
     updateNodes (repId, lastOpr, nodes, callback) {
         var functions = [];
         for (var i=0; i < nodes.length; i++) {

+ 25 - 6
modules/std_glj_lib/models/schemas.js

@@ -3,19 +3,37 @@
  */
 import mongoose from "mongoose";
 let Schema = mongoose.Schema;
+let gjlMapRationLibsSchema = new Schema(
+    {
+        ID: Number,
+        dispName: String
+    },
+    {_id: false},
+    {versionKey: false}
+);
+
+let oprSchema = new Schema({
+        operateDate: String,
+        operator: String
+    },
+    {_id: false},
+    {versionKey: false});
+
 let gljMapSchema = new Schema({
-    deleted: false,
+    deleted: Boolean,
     ID: Number,
     dispName: String,
     appType: String,
     creator: String,
     createDate: String,
-    recentOpr: [],
+    recentOpr: [oprSchema],
+    rationLibs: [gjlMapRationLibsSchema],
     compilationId: String,
     compilationName: String
 },
     {versionKey: false});
 
+
 let gjlComponentSchema = mongoose.Schema(
     {
         ID: Number,
@@ -25,8 +43,9 @@ let gjlComponentSchema = mongoose.Schema(
     {versionKey: false}
 );
 
+
 let gljSchema = new Schema({
-    deleted: false,
+    deleted: Boolean,
     repositoryId: Number,
     ID: Number,
     code: String,
@@ -45,7 +64,7 @@ let gljClassSchema = mongoose.Schema({
     ParentID: Number,
     NextSiblingID: Number,
     Name: String,
-    isDeleted: Boolean
+    deleted: Boolean
 }, {versionKey: false});
 
 let gljClassTemplate = mongoose.Schema({
@@ -53,7 +72,7 @@ let gljClassTemplate = mongoose.Schema({
     ParentID: Number,
     NextSiblingID: Number,
     Name: String,
-    isDeleted: Boolean
+    deleted: Boolean
 }, {versionKey: false});
 
 
@@ -62,4 +81,4 @@ let gljModel = mongoose.model('std_glj_lib_gljList', gljSchema, 'std_glj_lib_glj
 let gljClassModel = mongoose.model('std_glj_lib_gljClass', gljClassSchema, 'std_glj_lib_gljClass');
 let gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate', gljClassTemplate, 'std_glj_lib_gljClassTemplate');
 
-export {gljMapModel, gljModel, gljClassModel, gljClassTemplateModel};
+export {gljMapModel as default, gljModel, gljClassModel, gljClassTemplateModel};

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

@@ -24,7 +24,8 @@ module.exports = function (app) {
     router.post('/renameGljLib', gljMapController.auth, gljMapController.init, gljMapController.renameGljLib);
     router.post('/removeGljLib', gljMapController.auth, gljMapController.init, gljMapController.removeGljLib);
 
-
+    router.post("/updateRationBasePrc",gljController.auth, gljController.init, gljController.updateRationBasePrc);//更新定额单价
+    router.post("/getRationGljIds",gljController.auth, gljController.init, gljController.getRationGljIds);
     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);

+ 18 - 2
modules/templates/controllers/bills_template_controller.js

@@ -1,11 +1,25 @@
 /**
+ * 清单模板控制器
  * Created by Mai on 2017/4/17.
  */
-var BillsTemplateData = require('../models/bills_template');
+/*
+var BillsTemplateData = require('../models/bills_template_model');
 
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
+/!*
+class BillsTemplateController {
+    /!**
+     * 清单模板编辑页面
+     * @param req
+     * @param res
+     *!/
+    async index(req, res) {
+        let id = req.query.id;
+        let
+    }
+};*!/
 
 module.exports = {
     getBillsTemplate: function(req, res){
@@ -34,4 +48,6 @@ module.exports = {
             callback(req, res, err, message, data);
         });
     }
-}
+}
+
+export default BillsTemplateController;*/

+ 26 - 19
modules/templates/models/bills_template.js

@@ -2,25 +2,32 @@
  * Created by Mai on 2017/4/14.
  * 清单模板,新建项目使用
  */
-var counter = require("../../../public/counter/counter.js");
+import BaseModel from "../../common/base/base_model";
+import BillsTemplateSchema from "./schemas/bills_template";
 
-var mongoose = require('mongoose');
-var dbm = require("../../../config/db/db_manager");
-var templatesDB = dbm.getCfgConnection("templates");
-var Schema = mongoose.Schema;
-var deleteSchema = require('../../../public/models/delete_schema');
-var BillsTemplateSchema = new Schema({
-    ID: Number,
-    ParentID: Number,
-    NextSiblingID: Number,
-    code: String,
-    name: String,
-    unit: String,
-    deleteInfo: deleteSchema,
-    tempType: Number
-});
-var BillsTemplates = templatesDB.model('temp_bills', BillsTemplateSchema);
+class BillsTemplateModel extends BaseModel {
+    /**
+     * 构造函数
+     *
+     * @return {void}
+     */
+    constructor() {
+        let parent = super();
+        parent.model = BillsTemplateSchema;
+        parent.init();
+    }
+
+    async getTemplateData (valuationId) {
+        // 筛选字段
+        let field = {_id: 1, valuationId: 1, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1};
+        let data = await this.findDataByCondition({valuationId: valuationId}, field, false);
+
+        return data === null ? [] : data;
+    }
+};
 
+export default BillsTemplateModel;
+/*
 var BillsTemplateDAO = function(){};
 
 BillsTemplateDAO.prototype.getTemplate = function (type, callback) {
@@ -82,6 +89,6 @@ BillsTemplateDAO.prototype.getNewBillsTemplateID = function (count, callback) {
             callback(1, '获取主键失败', null);
         }
     });
-}
+};
 
-module.exports = new BillsTemplateDAO();
+module.exports = new BillsTemplateDAO();*/

+ 25 - 0
modules/templates/models/schemas/bills_template.js

@@ -0,0 +1,25 @@
+/**
+ * Created by Mai on 2017/8/17.
+ */
+import mongoose from "mongoose";
+let Schema = mongoose.Schema;
+
+let collectionName = 'temp_bills';
+
+let BillsTemplateSchema = {
+    // 树结构所需ID
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+    // 编号
+    code: String,
+    // 名称
+    name: String,
+    // 单位
+    unit: String,
+    // 所属计价ID
+    valuationId: String
+};
+
+let model = mongoose.model(collectionName, new Schema(BillsTemplateSchema, {versionKey: false, collection: collectionName}));
+export {model as default, collectionName as collectionName};

+ 5 - 6
modules/templates/routes/bills_template_router.js

@@ -3,12 +3,11 @@
  */
 
 var express = require('express');
-
-var billsTemplateController = require('./../controllers/bills_template_controller');
-
+/*
+var billsTemplateController = require('./../controllers/bills_template_controller');*/
 
 module.exports = function (app) {
-    app.get('/template/bills', function (req, res) {
+    app.get('/template/bills/:id', function (req, res) {
         let checkAdmin = function (userAccount) {
             return true;
         }
@@ -32,12 +31,12 @@ module.exports = function (app) {
         }
     });
 
-    var billsTemplateRouter = express.Router();
+/*    var billsTemplateRouter = express.Router();
 
     billsTemplateRouter.post('/getBillsTemplate', billsTemplateController.getBillsTemplate);
     billsTemplateRouter.post('/updateBillsTemplate', billsTemplateController.updateBillsTemplate);
     billsTemplateRouter.post('/getNewBillsTemplateID', billsTemplateController.getNewBillsTemplateID);
-    app.use('/template/bills/api', billsTemplateRouter);
+    app.use('/template/bills/api', billsTemplateRouter);*/
 }
 
 

+ 7 - 0
modules/users/controllers/compilation_controller.js

@@ -11,6 +11,7 @@ import STDRationLibMapModel from "../../common/std/std_ration_lib_map_model";
 import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
 import STDGLJLibMapModel from "../../common/std/std_glj_lib_map_model";
 import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
+import BillsTemplateModel from "../../templates/models/bills_template_model";
 
 class CompilationController extends BaseController {
 
@@ -116,6 +117,7 @@ class CompilationController extends BaseController {
         let valuationData = {};
         let valuationList = {};
         let gljList = [];
+        let billsTemplateData = [];
         try {
             let compilationModel = new CompilationModel();
             compilationList = await compilationModel.getCompilationList();
@@ -138,6 +140,10 @@ class CompilationController extends BaseController {
                 throw '不存在数据';
             }
 
+            // 获取清单模板数据
+            let billsTemplateModel = new BillsTemplateModel();
+            billsTemplateData = await billsTemplateModel.getTemplateData(valuationId);
+
         } catch (error) {
             console.log(error);
         }
@@ -148,6 +154,7 @@ class CompilationController extends BaseController {
             rationList: JSON.stringify(rationList),
             gljList: JSON.stringify(gljList),
             mainTreeCol: JSON.stringify(valuationData.main_tree_col),
+            billsTemplateData: JSON.stringify(billsTemplateData),
             engineeringList: EngineeringList,
             selectedCompilation: selectedCompilation,
             valuationData: valuationData,

+ 16 - 1
public/web/sheet/sheet_common.js

@@ -36,6 +36,7 @@ var sheetCommonObj = {
         spreadBook.options.showHorizontalScrollbar = false;
         spreadBook.options.scrollbarMaxAlign = true;
         spreadBook.options.allowCopyPasteExcelStyle = false;
+        spreadBook.options.allowExtendPasteRange = true;
         var spreadNS = GC.Spread.Sheets;
         var sheet = spreadBook.getSheet(0);
         sheet.suspendPaint();
@@ -98,7 +99,12 @@ var sheetCommonObj = {
             sheet.setRowCount(data.length + 5);
         }
         else{
-            sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 5);
+            sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
+        }
+        if(data.length === 0){
+            for(let i = 0; i < sheet.getRowCount(); i++){
+                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+            }
         }
         for (var col = 0; col < setting.header.length; col++) {
             var hAlign = "left", vAlign = "center";
@@ -118,6 +124,12 @@ var sheetCommonObj = {
             for (var row = 0; row < data.length; row++) {
                 //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
                 if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
+                    if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) !== -1){
+                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(true);
+                    }
+                    else if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) === -1){
+                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                    }
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
@@ -126,6 +138,9 @@ var sheetCommonObj = {
                     sheet.setTag(row, 0, data[row].ID, ch);
                 }
             }
+            for(let i = data.length; i < sheet.getRowCount(); i++){
+                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+            }
         }
         sheet.resumeEvent();
         sheet.resumePaint();

+ 10 - 0
public/web/tree_sheet/tree_sheet_helper.js

@@ -3,6 +3,16 @@
  */
 
 var TREE_SHEET_HELPER = {
+    createNewSpread: function (obj) {
+        var spread = new GC.Spread.Sheets.Workbook(obj, {sheetCount: 1});
+        spread.options.tabStripVisible = false;
+        spread.options.scrollbarMaxAlign = true;
+        spread.options.cutCopyIndicatorVisible = false;
+        spread.options.allowCopyPasteExcelStyle = false;
+        spread.options.allowUserDragDrop = false;
+        spread.getActiveSheet().setRowCount(3);
+        return spread;
+    },
     getSheetCellStyle: function (setting) {
         var style = new GC.Spread.Sheets.Style();
         style.locked = setting.readOnly ? true : false;

+ 17 - 7
web/maintain/bills_lib/html/main.html

@@ -61,11 +61,15 @@
                       <label>清单规则名称</label>
                       <input id="createText" class="form-control" placeholder="输入清单规则名称" type="text">
                     </div>
+                      <div class="form-group">
+                          <label>编办名称</label>
+                          <select id="compilationSels" class="form-control"></select>
+                      </div>
                   </form>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                    <a id="createA"  href="javascript:void(0);" class="btn btn-primary" data-dismiss="modal">新建</a>
+                    <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a id="createA"  href="javascript:void(0);" class="btn btn-primary">新建</a>
                 </div>
             </div>
         </div>
@@ -130,17 +134,23 @@
 </script>
 <script>
     let userAccount = '<%= userAccount %>';
+    mainAjax.getCompilationList();
     mainAjax.getStdBillsLib();
     $(document).ready(function(){
         //main 增删改
         $("#createA").click(function(){
             let billsLibName = $("#createText").val();
-            if(billsLibName){
-                mainAjax.createStdBillsLib(userAccount, billsLibName);
-                $("#createText").val("");
+            let compilationName = $('#compilationSels option:selected').text();
+            let compilationId = $('#compilationSels option:selected').val();
+            if(billsLibName.trim().length === 0){
+                alert("请输入清单规则名称!");
+            }
+            else if(compilationName.trim().length === 0){
+                alert("编办不可为空!");
             }
-            else{
-                alert("请输入清单规则名称!");
+            else {
+                mainAjax.createStdBillsLib(userAccount, billsLibName, compilationId, compilationName);
+                $("#createText").val("");
             }
         });
 

+ 7 - 0
web/maintain/bills_lib/html/neirong.html

@@ -262,6 +262,13 @@
 
         function pasteJobs(sheet, totalJobs){
             sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
+            sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+                //复制的列数超过正确的列数,不可复制
+                if(maxCol >= totalJobsSetting.cols.length){
+                    args.cancel = true;
+                }
+            });
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
                 const colIdx = 1;
                 let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;

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

@@ -634,6 +634,13 @@
 
     function bindPasteBills(controller, sheet, setting){
         sheetBillsDatas = tools.getsheetDatas(sheet, 'bills', controller);
+        sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+            let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+            //复制的列数超过正确的列数,不可复制
+            if(maxCol >= billsLibSetting.cols.length){
+                args.cancel = true;
+            }
+        });
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
             let datas = [], field;
             let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
@@ -676,6 +683,13 @@
     }
     function bindPasteRel(sheet, controller, totalJobs, setting){
         sheetDatas = tools.getsheetDatas(sheet, 'jobs');
+        sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+            let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+            //复制的列数超过正确的列数,不可复制
+            if(maxCol >= jobsSetting.cols.length){
+                args.cancel = true;
+            }
+        });
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
           //  sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.viewport);
            // sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.colHeader);

+ 15 - 0
web/maintain/bills_lib/html/tezheng.html

@@ -311,6 +311,13 @@
 
         function pasteItems(sheet, totalItems){
             totalItemsDatas = tools.getsheetDatas(sheet, 'total');
+            sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+                //复制的列数超过正确的列数,不可复制
+                if(maxCol >= totalItemsSetting.cols.length){
+                    args.cancel = true;
+                }
+            });
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
                 const colIdx = 1;
                 let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
@@ -371,6 +378,14 @@
         }
 
         function pasteValue(sheet, totalItems){
+            sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+                //复制的列数超过正确的列数,不可复制
+                if(maxCol >= eigenValueSetting.cols.length){
+                    args.cancel = true;
+                }
+            });
+
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
                 valueDatas = tools.getsheetDatas(sheet, 'total');
                 const colIdx = 1;

+ 23 - 4
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -2,6 +2,24 @@
  * Created by vian on 2017/3/27.
  */
 var mainAjax = {
+    //获取编办
+    getCompilationList: function () {
+        $.ajax({
+            type: 'post',
+            url: 'stdBillsEditor/getCompilationList',
+            dataType: 'json',
+            success: function (result) {
+                //addoptions
+                for(let i = 0; i < result.data.length; i++){
+                    let $option =  $("<option >"+ result.data[i].name +"</option>");
+                    $option.val( result.data[i]._id);
+                    $('#compilationSels').append($option);
+                }
+                $('#compilationSels').on("change", function () {
+                });
+            }
+        });
+    },
     getMaxNumber: function(billsLibId, field, callback){
         $.ajax({
             type: 'post',
@@ -60,11 +78,11 @@ var mainAjax = {
             }
         });
     },
-    createStdBillsLib: function(userAccount, billsLibName){
+    createStdBillsLib: function(userAccount, billsLibName, compilationId, compilationName){
         $.ajax({
             type: "POST",
             url: "/stdBillsEditor/createStdBillsLib",
-            data: {data: JSON.stringify({userAccount: userAccount, name: billsLibName}) },
+            data: {data: JSON.stringify({userAccount: userAccount, name: billsLibName, compilationId: compilationId, compilationName: compilationName}) },
             dataType: "json",
             success: function(result){
                 if(!result.error){
@@ -79,6 +97,7 @@ var mainAjax = {
                     var newHref = "stdBills?billsLibId="+id;
                     $("#tempId td:first a").attr("href", newHref);
                     $("#tempId").attr("id", id);
+                    $('#cancelBtn').click();
                 }
             }
         });
@@ -282,11 +301,11 @@ var billsAjax = {
             }
         })
     },
-    updateSerialNo: function (lastOperator, billsLibId, billsId, updateArr, field, callback) {
+    updateSerialNo: function (billsLibId, billsId, updateArr, field, callback) {
         $.ajax({
             type: 'post',
             url: 'stdBillsEditor/updateSerialNo',
-            data: {data: JSON.stringify({lastOperator: lastOperator, billsLibId: billsLibId, billsId: billsId, updateArr: updateArr, field: field})},
+            data: {data: JSON.stringify({lastOperator: userAccount, billsLibId: billsLibId, billsId: billsId, updateArr: updateArr, field: field})},
             dataType: 'json',
             success: function (result) {
                 if(!result.error && callback){

+ 8 - 8
web/maintain/ration_repository/gongliao.html

@@ -232,13 +232,13 @@
         let userAccount = '<%=userAccount %>';
         var gljSetting = {
             view: {
-                addHoverDom: gljTypeTreeOprObj.addHoverDom,
-                removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
+               // addHoverDom: gljTypeTreeOprObj.addHoverDom,
+               // removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
                 expandSpeed: "",
                 selectedMulti: false
             },
             edit: {
-                enable: true,
+                enable: false,
                 editNameSelectAll: true,
                 showRemoveBtn: true,
                 showRenameBtn: true,
@@ -255,17 +255,17 @@
                     name: "Name"
                 },
                 simpleData: {
-                    enable: true,
+                    enable: false,
                     idKey: "ID",
                     pIdKey: "ParentID",
                     rootPId: -1
                 }
             },
             callback:{
-                beforeRename: gljTypeTreeOprObj.beforeRename,
-                onRename: gljTypeTreeOprObj.onRename,
-                beforeRemove: gljTypeTreeOprObj.onBeforeRemove,
-                onRemove: gljTypeTreeOprObj.onRemove,
+               // beforeRename: gljTypeTreeOprObj.beforeRename,
+                //onRename: gljTypeTreeOprObj.onRename,
+               // beforeRemove: gljTypeTreeOprObj.onBeforeRemove,
+                //onRemove: gljTypeTreeOprObj.onRemove,
                 onClick: gljTypeTreeOprObj.onClick
             }
         };

+ 273 - 11
web/maintain/ration_repository/js/main.js

@@ -1,9 +1,10 @@
 /**
  * Created by Syusuke on 2017/3/17.
  */
-$(function(){
+/*$(function(){
+    let libNames = [];
     getCompilationList();
-    getRationLibs();
+    getRationLibs(libNames);
 })
 
 function addEvent_Addressdirect(){
@@ -69,22 +70,52 @@ function getCompilationList(){
         url: 'api/getCompilationList',
         dataType: 'json',
         success: function (result) {
+            console.log(result);
             //addoptions
-            for(let i = 0; i < result.data.length; i++){
-               let $option =  $("<option >"+ result.data[i].name +"</option>");
-                $option.val( result.data[i]._id);
+            for(let i = 0; i < result.data.compilation.length; i++){
+               let $option =  $("<option >"+ result.data.compilation[i].name +"</option>");
+                $option.val( result.data.compilation[i]._id);
                 $('#compilationSels').append($option);
             }
-            $('#compilationSels').on("change", function () {
+            //初始工料机库选项
+            if(result.data.compilation.length > 0 && result.data.gljLibs.length > 0){
+                let compilationId = result.data.compilation[0]._id;
+                //console.log(compilationId);
+                let gljLibOps = getGljLibOps(compilationId, result.data.gljLibs);
+                console.log(gljLibOps);
+                for(let i = 0; i < gljLibOps.length; i++){
+                    let $option =  $("<option >"+ gljLibOps[i].dispName +"</option>");
+                    $option.val(gljLibOps[i].ID);
+                    $('#gljLibSels').append($option);
+                }
 
-               console.log(this.selectedOptions);
-               console.log(this.selectedOptions[0].text);
-               console.log(this.selectedOptions[0].value);
+            }
+            $('#compilationSels').on("change", function () {
+                //刷新工料机库选项
+                $('#gljLibSels').children().remove();
+                let newGljLibOps = getGljLibOps(this.selectedOptions[0].value, result.data.gljLibs);
+                for(let i = 0; i < newGljLibOps.length; i++){
+                    let $option =  $("<option >"+ newGljLibOps[i].dispName +"</option>");
+                    $option.val(newGljLibOps[i].ID);
+                    $('#gljLibSels').append($option);
+                }
             });
         }
     });
 }
-function getRationLibs(){
+function getGljLibOps(compilationId, gljLibs){
+    let rst = [];
+    for(let i = 0; i < gljLibs.length; i++){
+        if(gljLibs[i]){
+            if(compilationId === gljLibs[i].compilationId){
+                rst.push(gljLibs[i]);
+            }
+        }
+    }
+    return rst;
+}
+
+function getRationLibs(libNames){
     $.ajax({
         type:"POST",
         url:"api/getRationDisplayNames",
@@ -96,7 +127,9 @@ function getRationLibs(){
             for(var i=0;i<result.data.length;i++){
                 addLibTag(result.data[i].dispName, result.data[i].ID, result.data[i].createDate);
                 storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data[i].ID, result.data[i].dispName);
+                libNames.push(result.data[i].dispName);
             }
+            console.log(libNames);
             addEvent_Addressdirect();
             addEvent_DeleteLib();
             addEvent_EditLib();
@@ -184,4 +217,233 @@ $("#edtOK").click(function(){
 
 });
 
-autoFlashHeight();
+autoFlashHeight();*/
+
+$(function () {
+    let dispNameArr;
+    getAllRationLib(function (dispNames) {
+        dispNameArr = dispNames;
+        //添加
+        $('#addBtn').click(function () {
+            let compilationName = $('#compilationSels option:selected').text();
+            let compilationId = $('#compilationSels option:selected').val();
+            let gljLibName = $('#gljLibSels option:selected').text();
+            let gljLibId = $('#gljLibSels option:selected').val();
+            let libName = $('#libNameTxt').val();
+            if(libName.trim().length === 0){
+                alert('名称不可为空!');
+                $('#libNameTxt').val('')
+            }
+            else if(dispNames.indexOf(libName) !== -1){
+                alert('此定额库已存在!');
+                $('#libNameTxt').val('')
+            }
+            else if(compilationName.trim().length === 0){
+                alert('编办不可为空!');
+            }
+            else if(gljLibName.trim().length === 0){
+                alert("请选择工料机库!");
+            }
+            else{
+                let newRationLib = {};
+                newRationLib.dispName = libName;
+                newRationLib.compilationId = compilationId;
+                newRationLib.compilationName = compilationName;
+                newRationLib.gljLib = gljLibId;
+                newRationLib.creator = userAccount;
+                newRationLib.appType = "建筑";
+                $('#libNameTxt').val('');
+                createRationLib(newRationLib, dispNameArr);
+            }
+        });
+        //重命名
+        $("#showArea").on("click", "[data-target = '#edit']", function(){
+            let renameId = $(this).parent().parent().attr("id");
+            $("#renameA").attr("renameId", renameId);
+        });
+        $("#renameA").click(function(){
+            let newName = $("#renameText").val();
+            let libId = $(this).attr("renameId");
+            let jqSel = "#" + libId + " td:first" + " a";
+            let orgName = $(jqSel).text();
+            if(newName.trim().length === 0){
+                alert("名称不可为空!");
+                $("#renameText").val('');
+            }
+            else if(dispNameArr.indexOf(newName) !== -1){
+                alert("该工料机库已存在!");
+                $("#renameText").val('');
+            }
+            else{
+                renameRationLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
+            }
+        });
+        //删除
+        $("#showArea").on("click", "[data-target = '#del']", function(){
+            let deleteId = $(this).parent().parent().attr("id");
+            $("#deleteA").attr("deleteId", deleteId);
+        });
+        $("#deleteA").click(function(){
+            let deleteId = $(this).attr("deleteId");
+            let jqSel = "#" + deleteId + " td:first" + " a";
+            let libName = $(jqSel).text();
+            removeRationLib({libId: deleteId, libName: libName}, dispNameArr);
+        });
+
+
+    });
+    getCompilationList();
+});
+
+function getAllRationLib(callback){
+    $.ajax({
+        type: 'post',
+        url: 'api/getRationDisplayNames',
+        dataType: 'json',
+        success: function (result) {
+            let dispNames = [];
+            if(result.data.length > 0){
+                for(let i = 0; i < result.data.length; i++){
+                    storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data[i].ID, result.data[i].dispName);
+                    if(result.data[i].gljLib){
+                        storageUtil.setSessionCache("gljLib","repositoryID_" + result.data[i].ID, result.data[i].gljLib);
+                    }
+                    let id = result.data[i].ID;
+                    let libName = result.data[i].dispName;
+                    let createDate = result.data[i].createDate.split(' ')[0];
+                    dispNames.push(result.data[i].dispName);
+                    $("#showArea").append(
+                        "<tr id='tempId'>" +
+                        "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
+                        "<td>"+createDate+" </td>" +
+                        "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
+                        "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
+                        "<i class='fa fa-remove'></i></a></td></tr>");
+                    var newHref = "/rationRepository/ration?repository="+id;
+                    $("#tempId td:first a").attr("href", newHref);
+                    $("#tempId").attr("id", id);
+                }
+            }
+            callback(dispNames);
+        }
+    });
+}
+function getCompilationList(){
+    $.ajax({
+        type: 'post',
+        url: 'api/getCompilationList',
+        dataType: 'json',
+        success: function (result) {
+            console.log(result);
+            //addoptions
+            for(let i = 0; i < result.data.compilation.length; i++){
+                let $option =  $("<option >"+ result.data.compilation[i].name +"</option>");
+                $option.val( result.data.compilation[i]._id);
+                $('#compilationSels').append($option);
+            }
+            //初始工料机库选项
+            if(result.data.compilation.length > 0 && result.data.gljLibs.length > 0){
+                let compilationId = result.data.compilation[0]._id;
+                //console.log(compilationId);
+                let gljLibOps = getGljLibOps(compilationId, result.data.gljLibs);
+                console.log(gljLibOps);
+                for(let i = 0; i < gljLibOps.length; i++){
+                    let $option =  $("<option >"+ gljLibOps[i].dispName +"</option>");
+                    $option.val(gljLibOps[i].ID);
+                    $('#gljLibSels').append($option);
+                }
+
+            }
+            $('#compilationSels').on("change", function () {
+                //刷新工料机库选项
+                $('#gljLibSels').children().remove();
+                let newGljLibOps = getGljLibOps(this.selectedOptions[0].value, result.data.gljLibs);
+                for(let i = 0; i < newGljLibOps.length; i++){
+                    let $option =  $("<option >"+ newGljLibOps[i].dispName +"</option>");
+                    $option.val(newGljLibOps[i].ID);
+                    $('#gljLibSels').append($option);
+                }
+            });
+        }
+    });
+}
+function getGljLibOps(compilationId, gljLibs){
+    let rst = [];
+    for(let i = 0; i < gljLibs.length; i++){
+        if(gljLibs[i]){
+            if(compilationId === gljLibs[i].compilationId){
+                rst.push(gljLibs[i]);
+            }
+        }
+    }
+    return rst;
+}
+
+function createRationLib(rationObj, dispNamesArr){
+    $.ajax({
+        type: 'post',
+        url: 'api/addRationRepository',
+        data: {rationRepObj: JSON.stringify(rationObj)},
+        dataType: 'json',
+        success: function (result) {
+            if(result.data){
+                storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data.ID, result.data.dispName);
+                if(result.data.gljLib){
+                    storageUtil.setSessionCache("gljLib","repositoryID_" + result.data.ID, result.data.gljLib);
+                }
+                let id = result.data.ID;
+                let libName = result.data.dispName;
+                let createDate = result.data.createDate.split(' ')[0];
+                let compilationName = result.data.compilationName;
+                dispNamesArr.push(libName);
+                $("#showArea").append(
+                    "<tr id='tempId'>" +
+                    "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
+                    "<td>"+createDate+" </td>" +
+                    "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
+                    "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
+                    "<i class='fa fa-remove'></i></a></td></tr>");
+                var newHref = "/rationRepository/ration?repository="+id;
+                $("#tempId td:first a").attr("href", newHref);
+                $("#tempId").attr("id", id);
+            }
+            $('#cancelBtn').click();
+        }
+    })
+}
+function renameRationLib(renameObj, dispNames){
+    $.ajax({
+        type: 'post',
+        url: 'api/editRationLibs',
+        data: {oprtor: userAccount, renameObj: JSON.stringify(renameObj)},
+        dataType: 'json',
+        success: function (result) {
+            if(!result.error){
+                let jqSel = "#" + renameObj.ID + " td:first" + " a";
+                $(jqSel).text(renameObj.newName);
+                let index = dispNames.indexOf(renameObj.orgName);
+                dispNames.splice(index, 1);
+                dispNames.splice(index, 0, renameObj.newName);
+            }
+            $('#editCancelBtn').click();
+            $('#renameText').val('');
+        }
+    })
+}
+function removeRationLib(delObj, dispNames){
+    $.ajax({
+        type: 'post',
+        url: 'api/deleteRationLibs',
+        data: {oprtor: userAccount, libId: delObj.libId},
+        dataType: 'json',
+        success: function (result) {
+            if(!result.error){
+                var jqSel = "#"+ delObj.libId;
+                $(jqSel).remove();
+                let index = dispNames.indexOf(delObj.libName);
+                dispNames.splice(index, 1);
+                $('#delCancelBtn').click();
+            }
+        }
+    })
+}

+ 18 - 3
web/maintain/ration_repository/js/ration.js

@@ -20,14 +20,14 @@ var rationOprObj = {
     setting: {
         header:[
             {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
-            {headerName:"名称",headerWidth:300,dataCode:"name", dataType: "String"},
+            {headerName:"名称",headerWidth:280,dataCode:"name", dataType: "String"},
             {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
             {headerName:"人工费",headerWidth:120,dataCode:"labourPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
             {headerName:"材料费",headerWidth:120,dataCode:"materialPrice", dataType: "Number", formatter: "0.00",  hAlign: "right"},
             {headerName:"机械费",headerWidth:120,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
             {headerName:"基价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
-            {headerName:"显示名称(以%s表示参数)",headerWidth:350,dataCode:"caption", dataType: "String"},
-            {headerName:"取费专业",headerWidth:120,dataCode:"feeType", dataType: "Number", hAlign: "center"}
+            {headerName:"显示名称(以%s表示参数)",headerWidth:280,dataCode:"caption", dataType: "String"},
+            {headerName:"取费专业",headerWidth:100,dataCode:"feeType", dataType: "Number", hAlign: "center"}
         ],
         view:{
             comboBox:[
@@ -44,6 +44,12 @@ var rationOprObj = {
     buildSheet: function(container) {
         let rationRepId = getQueryString("repository");
         var me = rationOprObj;
+        let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+        console.log(gljLibID);
+        if(!gljLibID || typeof gljLibID === 'undefined' || gljLibID == -1){
+            alert("没有引用工料机库!");
+            window.location.href = "/rationRepository/main";
+        }
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.workBook.options.showHorizontalScrollbar = true;
         me.getRationsCodes(rationRepId);
@@ -440,6 +446,7 @@ var rationOprObj = {
                         else if (a.code < b.code) rst = -1;
                         return rst;
                     });
+                    me.mixUpdate = 1;
                     me.showRationItems(me.currentSectionId);
                     me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
                 }
@@ -451,6 +458,7 @@ var rationOprObj = {
     getRationItems: function(sectionID){
         if (sectionID != -1) {
             var me = rationOprObj;
+            me.mixUpdate = 0;
             me.currentSectionId = sectionID;
             if (me.currentRations["_SEC_ID_" + sectionID]) {
                 me.showRationItems(sectionID);
@@ -498,6 +506,13 @@ var rationOprObj = {
                 var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                 sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
+
+                if(me.mixUpdate === 1){
+                    rationGLJOprObj.getGljItems(cacheSection[cacheSection.length - 1], function () {
+                        me.workBook.focus(true);
+                    });
+                }
+
             } else {
                 //清除ration数据及工料机数据
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);

+ 33 - 29
web/maintain/ration_repository/js/ration_glj.js

@@ -174,38 +174,41 @@ var rationGLJOprObj = {
     onClipboardPasted: function(e, info) {
         var me = rationGLJOprObj, repId = storageUtil.getSessionCache("RationGrp","repositoryID");
         if (repId) {
-            if (info.cellRange.col == 0) {
-                var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
-                var codes = [];
-                for (var i = 0; i < tmpCodes.length; i++) {
-                    codes.push(tmpCodes[i].code);
-                }
-                me.addGljItems(codes, repId);
-            } else {
-                //修改用量
-                if(me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length){
-                    let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
-                    let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
+            let gljLibId = storageUtil.getSessionCache("gljLib", "repositoryID_" + repId);
+            if(gljLibId){
+                if (info.cellRange.col == 0) {
+                    var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
+                    var codes = [];
+                    for (var i = 0; i < tmpCodes.length; i++) {
+                        codes.push(tmpCodes[i].code);
+                    }
+                    me.addGljItems(codes, gljLibId, info.cellRange);
+                } else {
+                    //修改用量
+                    if(me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length){
+                        let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
+                        let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
                         me.cache["_GLJ_" + me.currentRationItem.ID].length - info.cellRange.row : info.cellRange.rowCount;
-                    for(let i = 0; i < maxCount; i++){
-                        me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = tempConsumes[i].consumeAmt;
+                        for(let i = 0; i < maxCount; i++){
+                            me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = tempConsumes[i].consumeAmt;
+                        }
+                        me.updateRationItem();
+                        if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
+                            me.sheet.suspendPaint();
+                            for(let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
+                                me.sheet.setValue(rowIdx, info.cellRange.col, '');
+                            }
+                            me.sheet.resumePaint();
+                        }
                     }
-                    me.updateRationItem();
-                    if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
+                    else if(info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
                         me.sheet.suspendPaint();
-                        for(let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
+                        for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
                             me.sheet.setValue(rowIdx, info.cellRange.col, '');
                         }
                         me.sheet.resumePaint();
                     }
                 }
-                else if(info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
-                    me.sheet.suspendPaint();
-                    for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
-                        me.sheet.setValue(rowIdx, info.cellRange.col, '');
-                    }
-                    me.sheet.resumePaint();
-                }
             }
         }
     },
@@ -252,11 +255,12 @@ var rationGLJOprObj = {
                 }
             } else*/
             if(args.editingText !== null && args.editingText.trim().length !== 0){
-                var repId = storageUtil.getSessionCache("RationGrp","repositoryID");
-                if (repId) {
+                let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
+                let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+                if (gljLibID) {
                     var codes = [];
                     codes.push(args.editingText.trim());
-                    me.addGljItems(codes, repId, args);
+                    me.addGljItems(codes, gljLibID, args);
                 }
             }
         }
@@ -329,12 +333,12 @@ var rationGLJOprObj = {
                         $('#alertModalCls').click(function () {
                             sheetCommonObj.lockCells(me.sheet, me.setting);
                             me.showGljItems(me.currentRationItem.ID);
-                            args.sheet.setValue(args.row, args.col, '');
+                            me.sheet.setValue(args.row, args.col, '');
                         });
                         $('#alertModalCof').click(function () {
                             sheetCommonObj.lockCells(me.sheet, me.setting);
                             me.showGljItems(me.currentRationItem.ID);
-                           args.sheet.setValue(args.row, args.col, '');
+                           me.sheet.setValue(args.row, args.col, '');
                         })
                     }
                 }

+ 18 - 16
web/maintain/ration_repository/js/repository_glj.js

@@ -26,9 +26,13 @@ var pageOprObj = {
             repositoryGljObj.getRationGljIds(rationLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(rationLibId);
-                repositoryGljObj.getGljTree(rationLibId, function () {
-                    repositoryGljObj.getGljItems(rationLibId);
-                });
+                //引用的工料机库
+                let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationLibId);
+                if(gljLibID && typeof gljLibID !== 'undefined'){
+                    repositoryGljObj.getGljTree(gljLibID, function () {
+                        repositoryGljObj.getGljItems(gljLibID);
+                    });
+                }
                 sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
             });
         }
@@ -116,12 +120,12 @@ var pageOprObj = {
             }
         })
     },
-    getGljTree: function(rationLibId, callback) {
+    getGljTree: function(gljLibID, callback) {
         var me = this;
         $.ajax({
             type:"POST",
             url:"api/getGljTree",
-            data:{"rationLibId": rationLibId},
+            data:{"gljLibID": gljLibID},
             dataType:"json",
             cache:false,
             timeout:20000,
@@ -141,12 +145,12 @@ var pageOprObj = {
             }
         })
     },
-    getGljItems: function(repId) {
+    getGljItems: function(gljLibID) {
         var me = this;
         $.ajax({
             type:"POST",
             url:"api/getGljItems",
-            data:{"repositoryId": repId},
+            data:{"gljLibID": gljLibID},
             dataType:"json",
             cache:false,
             timeout:5000,
@@ -190,13 +194,14 @@ var pageOprObj = {
     buildSheet: function(container) {
         var me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
-        me.repositoryGljDelOpr();
+        me.workBook.getSheet(0).options.isProtected = true;
+       /* me.repositoryGljDelOpr();
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);*/
     },
      onEnterCell: function (sender, args) {
          let me = repositoryGljObj;
@@ -924,23 +929,20 @@ var gljTypeTreeOprObj = {
         var me = repositoryGljObj,
             gljTypeId = treeNode.ID;
         me.gljCurTypeId = treeNode.ID;
-        //me.currentCache = me.getCache();
         if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
             me.currentOprParent = 1;
             me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
-            sheetCommonObj.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
+           // sheetCommonObj.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
             me.workBook.getSheet(0).setRowCount(me.currentCache.length);
-            //sheetCommonObj.shieldAllCells(me.workBook.getSheet(0), me.setting);
         } else {
             me.currentOprParent = 0;
             me.currentCache = me.getCache();
-            //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+            me.workBook.getSheet(0).setRowCount(me.currentCache.length);
             /*sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
-            sheetCommonObj.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);*/
-            sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
-            sheetCommonObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
+            sheetCommonObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);*/
         }
         me.showGljItems(me.gljList, gljTypeId);
+        me.workBook.getSheet(0).setRowCount(me.currentCache.length);
     },
     beforeRename: function(treeId, treeNode, newName, isCancel) {
         if (newName.length == 0) {

+ 14 - 10
web/maintain/ration_repository/main.html

@@ -36,7 +36,7 @@
                     <div class="warp-p2 mt-3">
                       <table class="table table-hover table-bordered">
                         <thead><tr><th>定额库名称</th><th width="160">添加时间</th><th width="90">操作</th></tr></thead>
-                        <tbody>
+                        <tbody id="showArea">
                         </tbody>
                       </table>
                     </div>
@@ -83,7 +83,7 @@
                     <form>
                         <div class="form-group">
                             <label>定额库名称</label>
-                            <input class="form-control" placeholder="输入定额库名称" type="text">
+                            <input id="libNameTxt" class="form-control" placeholder="输入定额库名称" type="text">
                         </div>
                         <div class="form-group">
                             <label>编办名称</label>
@@ -96,8 +96,8 @@
                     </form>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                    <a href="" class="btn btn-primary">新建</a>
+                    <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a id="addBtn" href="javascript: void(0);" class="btn btn-primary">新建</a>
                 </div>
             </div>
         </div>
@@ -116,13 +116,15 @@
                   <form>
                     <div class="form-group">
                       <label>定额库名称</label>
-                      <input class="form-control" id = "inputRation" placeholder="输入编码" type="text" value="">
+                      <input class="form-control" id="renameText" placeholder="输入定额库名称" type="text" value="">
                     </div>
                   </form>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" id="edtCancel" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                    <button type="button"  id="edtOK" class="btn btn-secondary" data-dismiss="modal">确定</button>
+                    <!--<button type="button" id="edtCancel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <button type="button"  id="edtOK" class="btn btn-secondary" data-dismiss="modal">确定</button>-->
+                    <button id="editCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript: void(0);"  id="renameA" class="btn btn-primary">确定</a>
 
                 </div>
             </div>
@@ -130,7 +132,7 @@
     </div>
     <!--弹出删除-->
     <div class="modal fade" id="del" data-backdrop="static" style="display: none;" aria-hidden="true">
-        <input type="hidden" id="did" value="123">
+        <!--<input type="hidden" id="did" value="123">-->
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -143,8 +145,10 @@
                     <h5 class="text-danger">删除后无法恢复,确认是否删除?</h5>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                    <a href="" id="deleteLib" class="btn btn-danger">删除</a>
+                    <!--<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="" id="deleteLib" class="btn btn-danger">删除</a>-->
+                    <button id="delCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a id="deleteA" href="javascript: void(0);" class="btn btn-danger">删除</a>
                 </div>
             </div>
         </div>

+ 219 - 165
web/maintain/std_glj_lib/js/glj.js

@@ -1,15 +1,16 @@
 /**
  * Created by Zhong on 2017/8/14.
  */
-var pageOprObj = {
+let pageOprObj = {
     gljLibName : null,
     gljLibId: null,
     initPage : function(container, containerComponent) {
-        var me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
+        let me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
         me.gljLibId = gljLibId;
-            repositoryGljObj.getGljLib(gljLibId);
+        repositoryGljObj.getGljLib(gljLibId, function () {
             repositoryGljObj.buildSheet(container);
             gljComponentOprObj.buildSheet(containerComponent);
+            //获得定额库中引用此工料机库中的,所有被定额所套的工料机的ID
             //repositoryGljObj.getRationGljIds(gljLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(gljLibId);
@@ -18,10 +19,10 @@ var pageOprObj = {
                 });
                 sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
             });
-       // }
+        });
     }
 }
-repositoryGljObj = {
+let repositoryGljObj = {
     treeObj : null,
     workBook: null,
     gljCurTypeId: -1,
@@ -29,7 +30,7 @@ repositoryGljObj = {
     currentCache: null,
     parentNodeIds: {},
     gljList: [],
-    allowComponent: [202, 203, 204, 3],
+    allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
     distTypeTree: null,//add
     setting: {
 
@@ -80,7 +81,7 @@ repositoryGljObj = {
                 && distTypeObj.data.fullName !== '机上人工'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }*/
-            if(distTypeObj.data.fullName !== '材料'){
+            if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
         });
@@ -104,8 +105,8 @@ repositoryGljObj = {
             }
         })
     },
-    getGljLib: function (libId) {
-        let me = this;
+    getGljLib: function (libId, callback) {
+        let me = repositoryGljObj;
         $.ajax({
             type: 'post',
             url: 'api/getGljLib',
@@ -113,16 +114,20 @@ repositoryGljObj = {
             dataType: 'json',
             success: function (result) {
                 if(!result.error){
-                    $(".navbar-text").append(
-                        "<a href='/stdGljRepository/main'>工料机库</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].dispName
-                    );
-                    pageOprObj.gljLibName = result.data[0].dispName;
+                    if(result.data.length > 0){
+                        me.rationLibs = result.data[0].rationLibs;
+                        $(".navbar-text").append(
+                            "<a href='/stdGljRepository/main'>工料机库</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].dispName
+                        );
+                        pageOprObj.gljLibName = result.data[0].dispName;
+                    }
+                    callback();
                 }
             }
         })
     },
     getGljTree: function(gljLibId, callback) {
-        var me = this;
+        let me = this;
         $.ajax({
             type:"POST",
             url:"api/getGljTree",
@@ -148,7 +153,7 @@ repositoryGljObj = {
         })
     },
     getGljItems: function(repId) {
-        var me = this;
+        let me = this;
         $.ajax({
             type:"POST",
             url:"api/getGljItems",
@@ -174,11 +179,11 @@ repositoryGljObj = {
         })
     },
     showGljItems: function(data, type) {
-        var me = repositoryGljObj;
+        let me = repositoryGljObj;
         if (me.workBook) {
-            var cacheSection = [];
-            var pArr = me.parentNodeIds["_pNodeId_" + type];
-            for (var i = 0; i < data.length; i++) {
+            let cacheSection = [];
+            let pArr = me.parentNodeIds["_pNodeId_" + type];
+            for (let i = 0; i < data.length; i++) {
                 if (pArr && pArr.indexOf(data[i].gljClass) >= 0) {
                     cacheSection.push(data[i]);
                 } else if (type == data[i].gljClass) {
@@ -192,7 +197,7 @@ repositoryGljObj = {
         }
     },
     buildSheet: function(container) {
-        var me = repositoryGljObj;
+        let me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
         me.repositoryGljDelOpr();
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -228,10 +233,11 @@ repositoryGljObj = {
     },
     reshowGljBasePrc: function (glj) {
         let me = repositoryGljObj;
+
         for(let i = 0; i < me.gljList.length; i++){
             if(glj.ID === me.gljList[i].ID){
                 me.gljList[i].basePrice = glj.basePrice;
-                me.workBook.getSheet(0).setValue(i - 1, 4, glj.basePrice);
+                me.workBook.getSheet(0).setValue(me.activeRow, 4, glj.basePrice);
                 break;
             }
         }
@@ -241,18 +247,18 @@ repositoryGljObj = {
         //混凝土202、砂浆203、配合比204、机械3
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
+            me.activeRow = row;
             sheetCommonObj.lockCells(that.workBook.getSheet(0), that.setting);
             that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
             that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
             //that.workBook.getSheet(0).options.isProtected = true;
             sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
             me.workBook.focus(true);
-            me.currentGlj = null;
             me.currentComponent = [];
             if(row < me.currentCache.length){
+                //标记当前工料机
+                me.currentGlj = me.currentCache[row];
                 if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
-                    //标记当前工料机
-                    me.currentGlj = me.currentCache[row];
                     that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                     that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                     //that.workBook.getSheet(0).options.isProtected = false;
@@ -266,6 +272,9 @@ repositoryGljObj = {
                     }
                 }
             }
+            else{
+                me.currentGlj = null;
+            }
         }
     },
     onEnterCell: function (sender, args) {
@@ -343,13 +352,13 @@ repositoryGljObj = {
         }
     },
     onCellEditStart: function(sender, args) {
-        var me = repositoryGljObj;
-        var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
+        let me = repositoryGljObj;
+        let rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
         me.currentEditingGlj = rObj;
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
-        var cacheSection = me.gljList;
+        let cacheSection = me.gljList;
         if (cacheSection) {
-            for (var j = 0; j < cacheSection.length; j++) {
+            for (let j = 0; j < cacheSection.length; j++) {
                 if (cacheSection[j][me.setting.header[0].dataCode] && cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
                     rObj["ID"] = cacheSection[j]["ID"];
                     rObj.gljClass = cacheSection[j].gljClass;
@@ -359,7 +368,7 @@ repositoryGljObj = {
         }
     },
     onCellEditEnd: function(sender, args) {
-        var me = repositoryGljObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
+        let me = repositoryGljObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
             updateArr = [], addArr = [], updateBasePrcArr = [];
         me.editingRowIdx = args.row;
         rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
@@ -370,15 +379,22 @@ repositoryGljObj = {
                 if(me.currentEditingGlj[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
                     me.addGljObj = rObj;
                     if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode]){
-                        if(me.currentGlj){
-                            rObj.component = me.currentGlj.component;
+                        if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型,组成物清空
+                            if(me.currentGlj){
+                                me.currentGlj.component = [];
+                            }
+                            if(me.allowComponent.indexOf(rObj.gljType) !== -1){
+                                rObj.basePrice = 0;
+                            }
                         }
+                        rObj.component = me.currentGlj.component;
                         updateArr.push(rObj);
                         break;
                     }
                 }
             }
-           /* if(me.currentEditingGlj.basePrice !== rObj.basePrice){
+            //--------------------------------------
+            if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
                 let gljType = -1;
                 let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
@@ -391,15 +407,21 @@ repositoryGljObj = {
                 let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: rObj.basePrice};
                 if(gljBasePrcObj.gljType !== -1){
                     updateBasePrcArr.push(gljBasePrcObj);
-                    me.updateRationBasePrcRq(updateBasePrcArr);
+                    if(me.rationLibs.length > 0){//重算定额单价
+                        me.updateRationBasePrcRq(updateBasePrcArr);
+                    }
                 }
-            }*/
+            }
             //update basePrice of ration when editting gljType of glj
-           /* if(me.currentEditingGlj.gljType !== rObj.gljType){
+            if(me.currentEditingGlj.gljType !== rObj.gljType){
+
                 let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
                 updateBasePrcArr.push(gljTypeObj);
-                me.updateRationBasePrcRq(updateBasePrcArr);
-            }*/
+                if(me.rationLibs.length > 0){
+                    me.updateRationBasePrcRq(updateBasePrcArr);
+                }
+            }
+            //-----------------------------------------------------------
         } else {
             me.addGljObj = rObj;
             let isCanSav = true;
@@ -409,10 +431,14 @@ repositoryGljObj = {
             if(isCanSav){
                 me.addGljObj = null;
                 rObj.component = [];
+                //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
+                if(me.allowComponent.indexOf(rObj.gljType) !== -1){
+                    rObj.basePrice = 0;
+                }
                 addArr.push(rObj);
             }
         }
-        if(me.gljCurTypeId !== 1){
+        if(me.gljCurTypeId !== 732){
             rObj.gljClass = me.gljCurTypeId;
         }
         if(updateArr.length >0 || addArr.length >0){
@@ -430,14 +456,17 @@ repositoryGljObj = {
                 refGljCodes = [], //已被引用的工料机
                 updateBasePrcArr = [],//删除基价单位后重新计算
                 sels = sheet.getSelections(),
+                canUpdate = false,
                 cacheSection = me.currentCache;
             if(sels.length > 0 && cacheSection.length > 0){
                 for(let i = 0; i < sels.length; i++){
                     if(sels[i].colCount === me.setting.header.length){
                         for(let j = 0; j < sels[i].rowCount; j++){
                             if(sels[i].row + j < cacheSection.length){
-                                //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
                                 removeArr.push(cacheSection[sels[i].row + j].ID);
+                                //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
+                                //删除后重新计算引用了此工料机的定额单价
+                                updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
                             }
                         }
                     }
@@ -449,14 +478,21 @@ repositoryGljObj = {
                                     let updateObj = cacheSection[sels[i].row + j];
                                     for(let col = sels[i].col; col <= maxCol; col++){
                                         if(me.setting.header[col].dataCode === 'basePrice'){
-                                            updateObj[me.setting.header[col].dataCode] = 0;
-                                         //   updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
+                                            //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
+                                            if(me.allowComponent.indexOf(updateObj.gljType) === -1){
+                                                canUpdate = true;
+                                                updateObj[me.setting.header[col].dataCode] = 0;
+                                                updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
+                                            }
                                         }
                                         else{
+                                            canUpdate = true;
                                             updateObj[me.setting.header[col].dataCode] = '';
                                         }
                                     }
-                                    updateArr.push(updateObj);
+                                    if(canUpdate){
+                                        updateArr.push(updateObj);
+                                    }
                                 }
                             }
                         }
@@ -522,10 +558,16 @@ repositoryGljObj = {
                     });
                 }*/
                 if(removeArr.length > 0 || updateArr.length > 0){
-                    me.mixUpdateRequest(updateArr, [], removeArr);
-                   /* if(updateBasePrcArr.length > 0){
-                        me.updateRationBasePrcRq(updateBasePrcArr);
-                    }*/
+                    //删除警告
+                    $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
+                    $('#gljAlertBtn').click();
+                    //确认
+                    $('#aleConfBtn').click(function () {
+                        me.mixUpdateRequest(updateArr, [], removeArr);
+                        if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
+                            me.updateRationBasePrcRq(updateBasePrcArr);
+                        }
+                    });
                 }
             }
 
@@ -538,7 +580,7 @@ repositoryGljObj = {
         let rst = {}, backUpObj = {},
             me = repositoryGljObj,
             tempObj = me.currentCache[rowIdx],
-            //reCalBasePrc = false,
+            reCalBasePrc = false,
             isValid = true;
         //备份原始数据
         for(let atr in tempObj){
@@ -575,7 +617,7 @@ repositoryGljObj = {
             for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
                 if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
                     isExsit = true;
-                   // reCalBasePrc = true;
+                    reCalBasePrc = true;
                     tempObj.gljType = me.distTypeTree.comboDatas[i].value;
                     tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
 
@@ -587,15 +629,15 @@ repositoryGljObj = {
         pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
             me.currentCache[rowIdx].basePrice;
         if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
-          //  reCalBasePrc = true;
+            reCalBasePrc = true;
             tempObj.basePrice = pasteObj.basePrice;
         }
         if(isValid){
             rst.updateGlj = tempObj;
-            /*if(reCalBasePrc){
+            if(reCalBasePrc){
                 //重新计算定额基价对象
                 rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
-            }*/
+            }
         }
         else {
             for(let attr in backUpObj){
@@ -637,120 +679,133 @@ repositoryGljObj = {
         return true;
     },
     onClipboardPasting: function(sender, args) {
-        var me = repositoryGljObj;
+        let me = repositoryGljObj;
         /*if (args.cellRange.colCount != me.setting.header.length || me.gljCurTypeId < 0 || me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
          args.cancel = true;
          }*/
         if (me.gljCurTypeId < 0 ) {
             args.cancel = true;
         }
+        let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+        //复制的列数超过正确的列数,不可复制
+        if(maxCol >= me.setting.header.length){
+            args.cancel = true;
+        }
     },
     onClipboardPasted: function(e, info) {
-        var me = repositoryGljObj;
-        var updateArr = [], addArr = [];
-        var items = sheetCommonObj.analyzePasteData(me.setting, info);
-        let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
-            maxRow = me.currentCache.length - 1, updateItems = [], addItems = [],
-            updateBasePrcArr = [] ,
-            updateCount, resumeArr = [];
-        if(endRow <= maxRow){
-            //updateItems = items;
-            for(let i = 0; i < items.length; i++){
-                let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
-                    updateArr.push(updateObj.updateGlj);
-                   /* if(typeof updateObj.updateBasePrc !== 'undefined'){
-                        updateBasePrcArr.push(updateObj.updateBasePrc);
-                    }*/
-                }
-                else{
-                    resumeArr.push(info.cellRange.row + i);
-                }
-            }
-        }
-        else if(beginRow <= maxRow && endRow > maxRow){
-            updateCount = maxRow - beginRow + 1;
-            for(let i = 0; i < updateCount; i++){
-                let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
-                    updateArr.push(updateObj.updateGlj);
-                   /* if(typeof updateObj.updateBasePrc !== 'undefined'){
-                        updateBasePrcArr.push(updateObj.updateBasePrc);
-                    }*/
-                }
-                else{
-                    resumeArr.push(info.cellRange.row + i);
-                }
-            }
-            if(info.cellRange.colCount === me.setting.header.length){
-                for(let i = updateCount ; i < items.length; i++){
-                    if(me.isValidObj(items[i])){
-                        addItems.push(items[i]);
-                        addArr.push(items[i]);
+        let me = repositoryGljObj;
+            let updateArr = [], addArr = [];
+            let items = sheetCommonObj.analyzePasteData(me.setting, info);
+            let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
+                maxRow = me.currentCache.length - 1,
+                updateBasePrcArr = [] ,
+                updateCount, resumeArr = [];
+            if(endRow <= maxRow){
+                //updateItems = items;
+                for(let i = 0; i < items.length; i++){
+                    let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
+                    if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
+                        updateArr.push(updateObj.updateGlj);
+                        if(typeof updateObj.updateBasePrc !== 'undefined'){
+                            updateBasePrcArr.push(updateObj.updateBasePrc);
+                        }
                     }
                     else{
                         resumeArr.push(info.cellRange.row + i);
                     }
                 }
             }
-            else{
-                for(let i = updateCount ; i < items.length; i++){
-                    resumeArr.push(info.cellRange.row + i);
-                }
-            }
-        }
-        else{
-            if(info.cellRange.colCount === me.setting.header.length){
-                for(let i = 0; i < items.length; i++){
-                    if(me.isValidObj(items[i])){
-                        addArr.push(items[i]);
+            else if(beginRow <= maxRow && endRow > maxRow){
+                updateCount = maxRow - beginRow + 1;
+                for(let i = 0; i < updateCount; i++){
+                    let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
+                    if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
+                        updateArr.push(updateObj.updateGlj);
+                        if(typeof updateObj.updateBasePrc !== 'undefined'){
+                            updateBasePrcArr.push(updateObj.updateBasePrc);
+                        }
                     }
                     else{
                         resumeArr.push(info.cellRange.row + i);
                     }
                 }
-            }
-            else{
-                for(let i = 0; i < items.length; i++){
-                    resumeArr.push(info.cellRange.row + i);
+                if(info.cellRange.colCount === me.setting.header.length){
+                    for(let i = updateCount ; i < items.length; i++){
+                        if(me.isValidObj(items[i])){
+                            items[i].component = [];
+                            //类型为混凝土、砂浆、配合比、机械时,基价只能组成物计算
+                            if(me.allowComponent.indexOf(items[i].gljType) !== -1){
+                                items[i].basePrice = 0;
+                            }
+                            addArr.push(items[i]);
+                        }
+                        else{
+                            resumeArr.push(info.cellRange.row + i);
+                        }
+                    }
+                }
+                else{
+                    for(let i = updateCount ; i < items.length; i++){
+                        resumeArr.push(info.cellRange.row + i);
+                    }
                 }
             }
-        }
-        //repaint
-        if(resumeArr.length > 0){
-            info.sheet.suspendPaint();
-            for(let i = 0; i < resumeArr.length ; i++){
-                if(resumeArr[i] < me.currentCache.length){
-                    for(let col = 0; col < me.setting.header.length; col++){
-                        if(me.setting.header[col].dataCode === 'gljType'){
-                            let gljType = me.currentCache[resumeArr[i]][me.setting.header[col].dataCode];
-                            info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
+            else{
+                if(info.cellRange.colCount === me.setting.header.length){
+                    for(let i = 0; i < items.length; i++){
+                        if(me.isValidObj(items[i])){
+                            items[i].component = [];
+                            if(me.allowComponent.indexOf(items[i].gljType) !== -1){
+                                items[i].basePrice = 0;
+                            }
+                            addArr.push(items[i]);
                         }
                         else{
-                            info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][me.setting.header[col].dataCode]);
+                            resumeArr.push(info.cellRange.row + i);
                         }
                     }
                 }
                 else{
-                    for(let col = 0; col < me.setting.header.length; col++){
-                        info.sheet.setValue(resumeArr[i], col, '');
+                    for(let i = 0; i < items.length; i++){
+                        resumeArr.push(info.cellRange.row + i);
                     }
                 }
             }
-            info.sheet.resumePaint();
-        }
-        if (updateArr.length > 0 || addArr.length > 0) {
-            me.mixUpdateRequest(updateArr, addArr, []);
-        }
-       /* if(updateBasePrcArr.length > 0){
-            me.updateRationBasePrcRq(updateBasePrcArr);
-        }*/
+            //repaint
+            if(resumeArr.length > 0){
+                info.sheet.suspendPaint();
+                for(let i = 0; i < resumeArr.length ; i++){
+                    if(resumeArr[i] < me.currentCache.length){
+                        for(let col = 0; col < me.setting.header.length; col++){
+                            if(me.setting.header[col].dataCode === 'gljType'){
+                                let gljType = me.currentCache[resumeArr[i]][me.setting.header[col].dataCode];
+                                info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
+                            }
+                            else{
+                                info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][me.setting.header[col].dataCode]);
+                            }
+                        }
+                    }
+                    else{
+                        for(let col = 0; col < me.setting.header.length; col++){
+                            info.sheet.setValue(resumeArr[i], col, '');
+                        }
+                    }
+                }
+                info.sheet.resumePaint();
+            }
+            if (updateArr.length > 0 || addArr.length > 0) {
+                me.mixUpdateRequest(updateArr, addArr, []);
+            }
+            if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
+                me.updateRationBasePrcRq(updateBasePrcArr);
+            }
     },
-   /* updateRationBasePrcRq: function (basePrcArr) {
+    updateRationBasePrcRq: function (basePrcArr) {
         $.ajax({
             type: 'post',
             url: 'api/updateRationBasePrc',
-            data:{data: JSON.stringify({repId: pageOprObj.rationLibId, lastOpr: userAccount, basePrcArr: basePrcArr})},
+            data:{basePrcArr: JSON.stringify(basePrcArr)},
             dataType: 'json',
             success: function (result) {
                 if(result.error){
@@ -758,7 +813,7 @@ repositoryGljObj = {
                 }
             }
         });
-    },*/
+    },
   /*  getRationGljIds: function (repId) {
         let me = repositoryGljObj;
         $.ajax({
@@ -774,7 +829,7 @@ repositoryGljObj = {
         });
     },*/
     mixUpdateRequest: function(updateArr, addArr, removeIds) {
-        var me = repositoryGljObj;
+        let me = repositoryGljObj;
         $.ajax({
             type:"POST",
             url:"api/mixUpdateGljItems",
@@ -822,8 +877,8 @@ repositoryGljObj = {
         return rst;
     },
     getCache: function() {
-        var me = this, rst = [];
-        for (var i = 0; i < me.gljList.length; i++) {
+        let me = this, rst = [];
+        for (let i = 0; i < me.gljList.length; i++) {
             if (me.gljList[i].gljClass == me.gljCurTypeId) {
                 rst.push(me.gljList[i]);
             }
@@ -831,29 +886,29 @@ repositoryGljObj = {
         return rst;
     },
     updateCache: function(addArr, updateArr, removeIds, result) {
-        var me = this, cacheSection = me.gljList;
+        let me = this, cacheSection = me.gljList;
         if (addArr.length > 0) {
             me.gljList = me.gljList.concat(addArr);
             cacheSection = me.gljList;
         }
-        for (var i = removeIds.length - 1; i >= 0; i--) {
-            for (var j = cacheSection.length - 1; j >= 0 ; j--) {
+        for (let i = removeIds.length - 1; i >= 0; i--) {
+            for (let j = cacheSection.length - 1; j >= 0 ; j--) {
                 if (cacheSection[j]["ID"] == removeIds[i]) {
                     cacheSection.splice(j,1);
                 }
             }
         }
-        if (result && result.data.ops && result.data.ops.length > 0) {
-            for (var i = 0; i < result.data.ops.length; i++) {
-                for (var j = 0; j < cacheSection.length; j++) {
+        if (result && result.data && result.data.ops && result.data.ops.length > 0) {
+            for (let i = 0; i < result.data.ops.length; i++) {
+                for (let j = 0; j < cacheSection.length; j++) {
                     if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
                         cacheSection[j]["ID"] = result.data.ops[i]["ID"];
                     }
                 }
             }
         }
-        for (var i = 0; i < updateArr.length; i++) {
-            for (var j = 0; j < cacheSection.length; j++) {
+        for (let i = 0; i < updateArr.length; i++) {
+            for (let j = 0; j < cacheSection.length; j++) {
                 if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
                     if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
                         cacheSection[j] = updateArr[i];
@@ -867,9 +922,9 @@ repositoryGljObj = {
         }
     },
     sortGlj: function() {
-        var me = this;
+        let me = this;
         me.gljList.sort(function(a, b){
-            var rst = 0;
+            let rst = 0;
             if (a.code > b.code) rst = 1
             else if (a.code < b.code) rst = -1;
             return rst;
@@ -877,9 +932,9 @@ repositoryGljObj = {
     }
 }
 
-var gljTypeTreeOprObj = {
+let gljTypeTreeOprObj = {
     onClick: function(event,treeId,treeNode) {
-        var me = repositoryGljObj,
+        let me = repositoryGljObj,
             that = gljComponentOprObj,
             gljTypeId = treeNode.ID;
         me.gljCurTypeId = treeNode.ID;
@@ -912,7 +967,7 @@ var gljTypeTreeOprObj = {
         return true;
     },
     onRename : function(e, treeId, treeNode, isCancel) {
-        var nodes = [];
+        let nodes = [];
         nodes.push(treeNode);
         gljTypeTreeOprObj.updateNodes(nodes);
     },
@@ -925,20 +980,20 @@ var gljTypeTreeOprObj = {
         if (!confirm("您确定要删除此节点及所有子节点的数据?删除后不可恢复!")) {
             return false;
         }
-        var nodeIds = [], preNode = treeNode.getPreNode(), preNodeId = -1;
+        let nodeIds = [], preNode = treeNode.getPreNode(), preNodeId = -1;
         if (preNode) {
             preNodeId = preNode.ID;
         }
         private_fetchAllSubItems = function(pItem){
             nodeIds.push(pItem.ID);
             if (pItem.items && pItem.items.length > 0) {
-                for (var i = 0; i < pItem.items.length; i++) {
+                for (let i = 0; i < pItem.items.length; i++) {
                     private_fetchAllSubItems(pItem.items[i]);
                 }
             }
         };
         nodeIds.push(treeNode.ID);
-        for (var i = 0; i < treeNode.items.length; i++) {
+        for (let i = 0; i < treeNode.items.length; i++) {
             private_fetchAllSubItems(treeNode.items[i]);
         }
         $.ajax({
@@ -949,7 +1004,7 @@ var gljTypeTreeOprObj = {
             cache:false,
             timeout:5000,
             success:function(result,textStatus,status){
-                var pNode = treeNode.getParentNode();
+                let pNode = treeNode.getParentNode();
                 if (pNode && pNode.items && pNode.items.length == 1) {
                     pNode.isParent = false;
                 }
@@ -960,7 +1015,7 @@ var gljTypeTreeOprObj = {
         return true;
     },
     onRemove: function(e, treeId, treeNode){
-        var me = repositoryGljObj, pNode = me.treeObj.getNodeByTId(treeNode.parentTId);
+        let me = repositoryGljObj, pNode = me.treeObj.getNodeByTId(treeNode.parentTId);
         if (pNode && pNode.items && pNode.items.length == 0) {
             pNode.isParent = false;
             me.treeObj.refresh();
@@ -968,9 +1023,9 @@ var gljTypeTreeOprObj = {
     },
     updateNodes: function(nodes){
         if (nodes && nodes.length > 0) {
-            var reqData = []
-            for (var i = 0; i < nodes.length; i++) {
-                var node = {};
+            let reqData = []
+            for (let i = 0; i < nodes.length; i++) {
+                let node = {};
                 node.repositoryId = nodes[i].repositoryId;
                 node.ID = nodes[i].ID;
                 node.ParentID = nodes[i].ParentID;
@@ -994,13 +1049,13 @@ var gljTypeTreeOprObj = {
         }
     },
     addRootNode: function() {
-        var me = repositoryGljObj, rawNode = {ParentID: -1, NextSiblingID: -1, Name: "所有"}, lastNodeId = -1;
+        let me = repositoryGljObj, rawNode = {ParentID: -1, NextSiblingID: -1, Name: "所有"}, lastNodeId = -1;
         if (me.treeObj) {
-            var rootNodes = me.treeObj.getNodes();
+            let rootNodes = me.treeObj.getNodes();
             if (rootNodes.length == 0) {
                 gljTypeTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
                     if (!(err)) {
-                        var newNodes = [], isSilent = false;
+                        let newNodes = [], isSilent = false;
                         newNodes.push({ repositoryId: rst.data.repositoryId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, Name:"所有",isParent:false, items:[]});
                         me.treeObj.addNodes(null, -1, newNodes, isSilent);
                     }
@@ -1030,21 +1085,20 @@ var gljTypeTreeOprObj = {
         }
         hoverOpr();
         function hoverOpr(){
-            //console.log(treeNode);
-            var me = repositoryGljObj, sObj = $("#" + treeNode.tId + "_span");
+            let me = repositoryGljObj, sObj = $("#" + treeNode.tId + "_span");
             if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
-            var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
+            let addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
             sObj.after(addStr);
-            var btn = $("#addBtn_"+treeNode.tId);
+            let btn = $("#addBtn_"+treeNode.tId);
             if (btn) btn.bind("click", function(){
                 treeNode.doing = true;
-                var rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, Name: "新增子节点"}, lastNodeId = -1;
+                let rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, Name: "新增子节点"}, lastNodeId = -1;
                 if (treeNode.items.length > 0) {
                     lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
                 }
                 gljTypeTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
                     if (!(err)) {
-                        var newNodes = [], isSilent = false;
+                        let newNodes = [], isSilent = false;
                         if(treeNode.items.length > 0){
                             treeNode.items[treeNode.items.length - 1].NextSiblingID = rst.data.ID;
                         }

+ 52 - 20
web/maintain/std_glj_lib/js/gljComponent.js

@@ -18,7 +18,7 @@ let gljComponentOprObj = {
         }
     },
     buildSheet: function(container) {
-        var me = gljComponentOprObj;
+        let me = gljComponentOprObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
@@ -55,7 +55,7 @@ let gljComponentOprObj = {
         return component;
     },
     gljComponentDelOpr: function () {
-        let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false;
+        let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
         me.workBook.commandManager().register('gljComponentDel', function () {
             let sels = me.workBook.getSheet(0).getSelections();
             if(sels.length > 0 && that.currentComponent.length > 0){
@@ -119,11 +119,16 @@ let gljComponentOprObj = {
                     }
                     //重新计算工料机
                     let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
+                    if(gljBasePrc !== that.currentGlj.basePrice){
+                        that.currentGlj.basePrice = gljBasePrc;
+                        that.reshowGljBasePrc(that.currentGlj);
+                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                    }
                     updateArr.push(that.currentGlj);
-                    console.log(updateArr);
                     me.updateComponent(updateArr);
+                    if(updateBasePrc.length > 0){
+                        that.updateRationBasePrcRq(updateBasePrc);
+                    }
                 }
             }
         });
@@ -136,7 +141,7 @@ let gljComponentOprObj = {
         me.currentEditingComponent = rObj;
     },
     onCellEditEnd: function (sender, args) {
-        let me = gljComponentOprObj, that = repositoryGljObj;
+        let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
         let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
         if(args.editingText !== me.currentEditingComponent.code){
             if(args.col === 0 && args.editingText && args.editingText.trim().length > 0){
@@ -145,7 +150,7 @@ let gljComponentOprObj = {
                     if(gljList[i].code === args.editingText){//有效的组成物
                         hasCode = true;
                         if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
-                            || (that.currentGlj.gljType === 3 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
+                            || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
                             //是否与原有组成物不同
                             let isExist = false;
                             for(let j = 0; j < component.length; j++){
@@ -187,7 +192,12 @@ let gljComponentOprObj = {
 
                         }
                         else{
-                            alert("无效!");
+                            if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
+                                alert("该组成物只能是普通材料!");
+                            }
+                            else if(that.currentGlj.gljType === 3){
+                                alert("该组成物只能是机械组成物或机上人工!")
+                            }
                             args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
                                 me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
                             //无效
@@ -195,7 +205,7 @@ let gljComponentOprObj = {
                     }
                 }
                 if(!hasCode){
-                    alert("不存在,请添加!");
+                    alert("不存在此工料机,请添加!");
                     args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
                         me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
                     //不存在
@@ -213,8 +223,12 @@ let gljComponentOprObj = {
                     that.currentComponent[args.row].consumeAmt = consumeAmt;
                     //计算工料机单价
                     let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
+                    if(gljBasePrc !== that.currentGlj.basePrice){
+                        that.currentGlj.basePrice = gljBasePrc;
+                        that.reshowGljBasePrc(that.currentGlj);
+                        //工料机单价改变,重算引用了该工料机的定额单价
+                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                    }
                     updateArr.push(that.currentGlj);
                 }
                 else{
@@ -230,15 +244,22 @@ let gljComponentOprObj = {
         }
         if(updateArr.length > 0){
             me.updateComponent(updateArr);
-            //保存
+            if(updateBasePrc.length > 0){
+                that.updateRationBasePrcRq(updateBasePrc)
+            }
         }
     },
     onClipboardPasting: function (sender, info) {
-
+        let me = gljComponentOprObj;
+        let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
+        //复制的列数超过正确的列数,不可复制
+        if(maxCol >= me.setting.header.length){
+            args.cancel = true;
+        }
     },
     onClipboardPasted: function (sender, info) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
-            component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false;
+            component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
         let gljCache = that.gljList;
         if(info.cellRange.col === 0){
@@ -246,7 +267,7 @@ let gljComponentOprObj = {
                 for(let j = 0; j < gljCache.length; j++){
                     if(items[i].code === gljCache[j].code){
                         if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
-                            || (that.currentGlj.gljType === 3 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
+                            || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
                             //是否与原有组成物不同
                             let isExist = false;
                             for(let k = 0; k < component.length; k++){
@@ -295,6 +316,13 @@ let gljComponentOprObj = {
                 }
             }
             if(isChange){
+                //计算工料机单价
+                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
+                if(gljBasePrc !== that.currentGlj.basePrice){
+                    that.currentGlj.basePrice = gljBasePrc;
+                    that.reshowGljBasePrc(that.currentGlj);
+                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                }
                 updateArr.push(that.currentGlj);
             }
         }
@@ -325,13 +353,19 @@ let gljComponentOprObj = {
             if(isChange){
                 //计算工料机单价
                 let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                that.currentGlj.basePrice = gljBasePrc;
-                that.reshowGljBasePrc(that.currentGlj);
+                if(gljBasePrc !== that.currentGlj.basePrice){
+                    that.currentGlj.basePrice = gljBasePrc;
+                    that.reshowGljBasePrc(that.currentGlj);
+                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                }
                 updateArr.push(that.currentGlj);
             }
         }
         if(updateArr.length > 0){
             me.updateComponent(updateArr);
+            if(updateBasePrc.length > 0){
+                that.updateRationBasePrcRq(updateBasePrc);
+            }
         }
     },
     updateComponent: function (updateArr) {
@@ -342,11 +376,9 @@ let gljComponentOprObj = {
             data: {libId: pageOprObj.gljLibId, updateArr: updateArr, oprtor: userAccount},
             dataType: 'json',
             success: function (result) {
-                console.log(result);
                 if(result.data.length > 0){
                     if(result.data[0]){
                         that.currentComponent =  that.getCurrentComponent(result.data[0].component);
-                        console.log(that.currentComponent);
                         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                         sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
                     }
@@ -355,7 +387,7 @@ let gljComponentOprObj = {
         })
     },
     round: function (v, e) {
-        var t=1;
+        let t=1;
         for(;e>0;t*=10,e--);
         for(;e<0;t/=10,e++);
         return Math.round(v*t)/t;

+ 18 - 7
web/maintain/std_glj_lib/js/main.js

@@ -86,12 +86,17 @@ function getAllGljLib(callback){
                     let libName = result.data[i].dispName;
                     let createDate = result.data[i].createDate.split(' ')[0];
                     let compilationName = result.data[i].compilationName;
+                    let rationLibs = result.data[i].rationLibs;
+                    let rationLibsName = '';
+                    for(let j = 0; j < rationLibs.length; j++){
+                        rationLibsName += rationLibs[j].dispName + "</br>";
+                    }
                     dispNames.push(result.data[i].dispName);
                     $("#showArea").append(
                         "<tr id='tempId'>" +
                         "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
                         "<td>"+compilationName+" </td>" +
-                        "<td>"+'xx定额库(xx)'+" </td>" +
+                        "<td>"+rationLibsName+" </td>" +
                         "<td>"+createDate+" </td>" +
                         "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
                         "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
@@ -140,7 +145,7 @@ function createGljLib(gljLibObj, dispNamesArr){
                     "<tr id='tempId'>" +
                     "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
                     "<td>"+compilationName+" </td>" +
-                    "<td>"+'xx定额库(xx)'+" </td>" +
+                    "<td>"+''+" </td>" +
                     "<td>"+createDate+" </td>" +
                     "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
                     "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
@@ -180,11 +185,17 @@ function removeGljLib(delObj, dispNames){
         dataType: 'json',
         success: function (result) {
             if(!result.error){
-                var jqSel = "#"+ delObj.libId;
-                $(jqSel).remove();
-                let index = dispNames.indexOf(delObj.libName);
-                dispNames.splice(index, 1);
-                $('#delCancelBtn').click();
+                if(result.message === '此工料机库已被引用!'){
+                    $('#delCancelBtn').click();
+                    alert("此工料机库已被引用,不可删除!");
+                }
+                else if(result.message === '删除成功'){
+                    var jqSel = "#"+ delObj.libId;
+                    $(jqSel).remove();
+                    let index = dispNames.indexOf(delObj.libName);
+                    dispNames.splice(index, 1);
+                    $('#delCancelBtn').click();
+                }
             }
         }
     })

+ 28 - 4
web/users/js/col_setting.js

@@ -88,6 +88,19 @@ let ColSettingObj = {
         this.initSheet(colEditSpread.getActiveSheet(), setting);
         this.setColCount(this.colSetting.cols.length);
         this.setHeaderRowCount(this.colSetting.headRows);
+        // headerHeight
+        for (let iRow in this.colSetting.headRowHeight) {
+            colEditSpread.getActiveSheet().setRowHeight(iRow, this.colSetting.headRowHeight[iRow], GC.Spread.Sheets.SheetArea.viewport);
+        }
+
+        if (setting.treeCol >= 0) {
+            $('#is-tree')[0].checked = true;
+            $('#tree-col-div').removeClass('hidden');
+            $('#tree-col').val(setting.treeCol);
+        } else {
+            $('#is-tree')[0].checked = false;
+            $('#tree-col-div').addClass('hidden');
+        }
 
         if (setting.cols) {
             let sheet = colEditSpread.getActiveSheet(), iRow;
@@ -119,7 +132,7 @@ let ColSettingObj = {
                 cell.cellType(this.cellType.readOnly).value(col.readOnly).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
             }
         }
-        let cell = info.sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport);
+        let cell = colEditSpread.getActiveSheet().getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport);
         if (cell) {
             $('#font').val(cell.font());
         }
@@ -174,8 +187,8 @@ let ColSettingObj = {
         let setting = {}, sheet = colEditSpread.getActiveSheet();
         setting.emptyRows = parseInt($('#empty-rows').val());
         setting.headRows = parseInt($('#header-row-count').val());
-        if ($('#is-tree').checked) {
-            setting.treeCol = parseInt($('#treeCol').val());
+        if ($('#is-tree')[0].checked) {
+            setting.treeCol = parseInt($('#tree-col').val());
         }
         setting.headRowHeight = [];
         for (let iRow = 0; iRow < setting.headRows; iRow++) {
@@ -245,6 +258,13 @@ $('#header-row-count').change(function () {
     ColSettingObj.setHeaderRowCount(parseInt($(this).val()));
     ColSettingObj.colSetting.headRows = parseInt($(this).val());
 });
+$('#is-tree').click(function () {
+    if (this.checked) {
+        $('#tree-col-div').removeClass('hidden');
+    } else {
+        $('#tree-col-div').addClass('hidden');
+    }
+});
 $('#merge').click(function () {
     let sheet = colEditSpread.getActiveSheet();
     let sel = sheet.getSelections();
@@ -279,7 +299,11 @@ $('#save-col-setting').click(function () {
     mainTreeCol = JSON.stringify(ColSettingObj.colSetting);
     $('input:hidden[name="main_tree_col"]').val(mainTreeCol);
     $('#set-column').modal('hide');
-    SheetDataHelper.loadSheetHeader(ColSettingObj.colSetting, colSpread.getActiveSheet());
+
+    let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
+    billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
+    TREE_SHEET_HELPER.loadSheetHeader(ColSettingObj.colSetting, colSpread.getActiveSheet());
+    TREE_SHEET_HELPER.showTreeData(ColSettingObj.colSetting, colSpread.getActiveSheet(), billsTemplateTree);
 });
 
 $('#h-left').click(function () {

+ 5 - 2
web/users/js/compilation.js

@@ -250,8 +250,11 @@ function initCompilation() {
         return false;
     }
     // 初始化 造价书列设置
-    colSpread = SheetDataHelper.createNewSpread($('#main-tree-col')[0]);
-    SheetDataHelper.loadSheetHeader(JSON.parse(mainTreeCol), colSpread.getActiveSheet());
+    colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
+    let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
+    billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
+    TREE_SHEET_HELPER.loadSheetHeader(JSON.parse(mainTreeCol), colSpread.getActiveSheet());
+    TREE_SHEET_HELPER.showTreeData(JSON.parse(mainTreeCol), colSpread.getActiveSheet(), billsTemplateTree);
 
     // 标准清单
     let html = '';

+ 7 - 2
web/users/views/compilation/add.html

@@ -102,7 +102,10 @@
                         </div>
                     </div>
                     <div class="col-md-8">
-                        <legend>造价书列设置<a href="javascript:void(0)" data-toggle="modal" data-target="#set-column" class="btn btn-primary btn-sm pull-right">设置</a></legend>
+                        <legend>清单模板 / 造价书列
+                            <a href="javascript:void(0)" data-toggle="modal" data-target="#set-column" class="btn btn-primary btn-sm pull-right">列设置</a>
+                            <a href="/template/bills/<%= valuationId %>" data-toggle="modal" data-target="" class="btn btn-primary btn-sm pull-right" style="margin-right:5px">模板设置</a>
+                        </legend>
                         <input type="hidden" name="main_tree_col" value="<%= mainTreeCol %>">
                         <div id="main-tree-col">
                         </div>
@@ -119,9 +122,11 @@
     let rationList = '<%- rationList %>';
     let gljList = '<%- gljList %>';
     let mainTreeCol = '<%- mainTreeCol %>';
+    let billsTemplateData = '<%- billsTemplateData %>';
     let colSpread = null;
     let colEditSpread = null;
 </script>
-<script type="text/javascript" src="/public/web/sheet/sheet_data_helper.js"></script>
+<script type="text/javascript" src="/public/web/id_tree.js"></script>
+<script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
 <script type="text/javascript" src="/web/users/js/compilation.js"></script>
 <%include ../compilation/modal.html %>

+ 10 - 2
web/users/views/compilation/modal.html

@@ -100,13 +100,21 @@
                             <input type="number" class="form-control input-sm" value="1" id="header-row-count">
                         </div>
                     </div>
-                    <div class="col-md-3">
+                </div>
+                <div class="row">
+                    <div class="col-md-2">
                         <div class="checkbox">
                             <label>
-                                <input type="checkbox" id="is-tree"> 是否包含树结构
+                                <input type="checkbox" id="is-tree" value> 是否包含树结构
                             </label>
                         </div>
                     </div>
+                    <div class="col-md-3" id="tree-col-div">
+                        <div class="input-group">
+                            <span class="input-group-addon" id="basic-addon1">树结构绘制列</span>
+                            <input type="number" class="form-control input-sm" value="1" id="tree-col">
+                        </div>
+                    </div>
                 </div>
                 <div class="">
                     <div class="btn-toolbar" role="toolbar">

+ 6 - 0
web/users/views/tool/index.html

@@ -24,6 +24,12 @@
                         <a href="/rpt_tpl" class="btn btn-primary pull-right">进入</a></h2>
                 </div>
             </div>
+            <div class="col-xs-6 mb-30 ">
+                <div class="c-body">
+                    <h2>工料机库
+                        <a href="/stdGljRepository/main" class="btn btn-primary pull-right">进入</a></h2>
+                </div>
+            </div>
         </div>
     </div>
 </div>