Browse Source

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 7 years ago
parent
commit
254561e917
79 changed files with 2101 additions and 767 deletions
  1. 9 2
      config/gulpConfig.js
  2. BIN
      lib/jquery-ui/images/ui-icons_444444_256x240.png
  3. BIN
      lib/jquery-ui/images/ui-icons_555555_256x240.png
  4. BIN
      lib/jquery-ui/images/ui-icons_777620_256x240.png
  5. BIN
      lib/jquery-ui/images/ui-icons_777777_256x240.png
  6. BIN
      lib/jquery-ui/images/ui-icons_cc0000_256x240.png
  7. BIN
      lib/jquery-ui/images/ui-icons_ffffff_256x240.png
  8. 62 0
      lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js
  9. 8 3
      modules/all_models/bills.js
  10. 2 0
      modules/all_models/project_glj.js
  11. 9 0
      modules/all_models/ration.js
  12. 1 0
      modules/all_models/ration_glj.js
  13. 10 1
      modules/all_schemas/bills_sub_schemas.js
  14. 1 1
      modules/complementary_glj_lib/controllers/gljController.js
  15. 5 0
      modules/complementary_ration_lib/models/sectionTreeModel.js
  16. 1 1
      modules/complementary_ration_lib/routes/routes.js
  17. 8 8
      modules/glj/models/glj_list_model.js
  18. 22 8
      modules/main/facade/project_facade.js
  19. 23 4
      modules/main/facade/ration_facade.js
  20. 1 0
      modules/main/models/project_consts.js
  21. 5 3
      modules/pm/models/project_model.js
  22. 7 2
      modules/pm/models/project_property_template.js
  23. 5 1
      modules/ration_glj/facade/glj_calculate_facade.js
  24. 43 0
      public/gljUtil.js
  25. 283 0
      public/web/gljUtil.js
  26. 49 0
      public/web/ration_glj_units.js
  27. 76 2
      public/web/sheet/sheet_common.js
  28. 1 0
      public/web/sheet/sheet_data_helper.js
  29. 13 9
      public/web/tree_sheet/tree_sheet_controller.js
  30. 5 4
      public/web/tree_sheet/tree_sheet_helper.js
  31. 3 2
      web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html
  32. 19 6
      web/building_saas/complementary_glj_lib/js/glj.js
  33. 1 0
      web/building_saas/complementary_glj_lib/js/gljClassTree.js
  34. 1 1
      web/building_saas/complementary_glj_lib/js/gljComponent.js
  35. 2 0
      web/building_saas/complementary_glj_lib/js/sheetOpr.js
  36. 4 4
      web/building_saas/complementary_ration_lib/html/anzhuang.html
  37. 69 11
      web/building_saas/complementary_ration_lib/html/dinge.html
  38. 4 4
      web/building_saas/complementary_ration_lib/html/fuzhu.html
  39. 4 4
      web/building_saas/complementary_ration_lib/html/gongliao.html
  40. 1 1
      web/building_saas/complementary_ration_lib/html/main.html
  41. 333 0
      web/building_saas/complementary_ration_lib/js/gljSelect.js
  42. 8 2
      web/building_saas/complementary_ration_lib/js/main.js
  43. 66 15
      web/building_saas/complementary_ration_lib/js/ration.js
  44. 2 2
      web/building_saas/complementary_ration_lib/js/ration_coe.js
  45. 81 52
      web/building_saas/complementary_ration_lib/js/ration_glj.js
  46. 2 63
      web/building_saas/complementary_ration_lib/js/repository_glj.js
  47. 9 0
      web/building_saas/complementary_ration_lib/js/section_tree.js
  48. 53 0
      web/building_saas/complementary_ration_lib/js/sheetsOpr.js
  49. 1 1
      web/building_saas/glj/html/project_glj.html
  50. 24 6
      web/building_saas/js/global.js
  51. 10 3
      web/building_saas/main/html/main.html
  52. 32 0
      web/building_saas/main/html/tender_price.html
  53. 25 23
      web/building_saas/main/js/controllers/block_controller.js
  54. 54 32
      web/building_saas/main/js/main.js
  55. 14 12
      web/building_saas/main/js/models/bills.js
  56. 44 14
      web/building_saas/main/js/models/calc_program.js
  57. 1 14
      web/building_saas/main/js/models/main_consts.js
  58. 29 168
      web/building_saas/main/js/models/project_glj.js
  59. 1 4
      web/building_saas/main/js/models/ration.js
  60. 36 30
      web/building_saas/main/js/models/ration_glj.js
  61. 21 8
      web/building_saas/main/js/views/character_content_view.js
  62. 22 30
      web/building_saas/main/js/views/glj_view.js
  63. 22 17
      web/building_saas/main/js/views/glj_view_contextMenu.js
  64. 41 69
      web/building_saas/main/js/views/project_glj_view.js
  65. 1 0
      web/building_saas/main/js/views/project_property_basicInfo.js
  66. 1 0
      web/building_saas/main/js/views/project_property_bills_quantity_decimal.js
  67. 2 1
      web/building_saas/main/js/views/project_property_indicativeInfo.js
  68. 1 0
      web/building_saas/main/js/views/project_property_labour_coe_view.js
  69. 1 0
      web/building_saas/main/js/views/project_property_projFeature.js
  70. 79 85
      web/building_saas/main/js/views/project_view.js
  71. 4 8
      web/building_saas/main/js/views/std_bills_lib.js
  72. 3 2
      web/building_saas/main/js/views/sub_view.js
  73. 272 0
      web/building_saas/main/js/views/tender_price_view.js
  74. 16 6
      web/building_saas/main/js/views/zmhs_view.js
  75. 1 1
      web/building_saas/pm/html/project-management-Recycle.html
  76. 2 2
      web/building_saas/pm/html/project-management.html
  77. 1 0
      web/building_saas/pm/js/pm_gc.js
  78. 27 14
      web/building_saas/pm/js/pm_newMain.js
  79. 2 1
      web/common/html/header.html

+ 9 - 2
config/gulpConfig.js

@@ -11,6 +11,7 @@ module.exports = {
         'lib/bootstrap/bootstrap.min.js',
         'web/building_saas/js/*.js',
         'public/web/scMathUtil.js',
+        'public/web/gljUtil.js',
         'public/web/PerfectLoad.js',
         'lib/lodash/lodash.js',
     ],
@@ -69,7 +70,7 @@ module.exports = {
         'public/web/number_util.js',
         'public/web/sheet/sheet_common.js',
        // 'lib/ztree/*.js',
-        'lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1',
+        'lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2',
        // 'lib/spreadjs/views/gc.spread.views.dataview.10.0.0.min.js',
        // "lib/spreadjs/views/common/gc.spread.common.10.0.0.min.js",
       //  'lib/spreadjs/views/plugins/gc.spread.views.gridlayout.10.0.0.min.js',
@@ -130,6 +131,7 @@ module.exports = {
         'web/building_saas/main/js/views/character_content_view.js',
         'web/building_saas/main/js/views/glj_view.js',
         'web/building_saas/main/js/views/zmhs_view.js',
+        'web/building_saas/main/js/views/tender_price_view.js',
         'web/building_saas/main/js/views/sub_view.js',
         'web/building_saas/main/js/views/fee_rate_view.js',
         'web/building_saas/main/js/views/sub_fee_rate_views.js',
@@ -151,6 +153,7 @@ module.exports = {
         'public/web/id_tree.js',
         'public/web/tree_sheet/tree_sheet_controller.js',
         'public/web/tree_sheet/tree_sheet_helper.js',
+        'public/web/ration_glj_units.js',
         'web/building_saas/complementary_glj_lib/js/glj.js',
         'web/building_saas/complementary_glj_lib/js/gljClassTree.js',
         'web/building_saas/complementary_glj_lib/js/gljComponent.js',
@@ -162,15 +165,18 @@ module.exports = {
     ],
     compleRation_ration_css: [
         'lib/jquery-contextmenu/jquery.contextMenu.css',
+        'lib/ztree/css/zTreeStyle.css',
         'lib/spreadjs/sheets/css/gc.spread.sheets.sc.css'
     ],
     compleRation_ration_jspaths:[
+        'lib/ztree/jquery.ztree.core.js',
         'web/building_saas/complementary_ration_lib/js/global.js',
         'public/web/id_tree.js',
         'public/web/tree_sheet/tree_sheet_controller.js',
         'public/web/tree_sheet/tree_sheet_helper.js',
         'public/web/treeDataHelper.js',
         'public/web/sheet/sheet_common.js',
+        'public/web/sheet/sheet_data_helper.js',
         'web/building_saas/complementary_ration_lib/js/sheetsOpr.js',
         'public/web/QueryParam.js',
         'public/web/storageUtil.js',
@@ -181,8 +187,9 @@ module.exports = {
         'public/web/scMathUtil.js',
         'public/web/common_ajax.js',
         'public/web/ztree_common.js',
-        'web/building_saas/complementary_ration_lib/js/rationUnits.js',
+        'public/web/ration_glj_units.js',
         'web/building_saas/complementary_ration_lib/js/ration.js',
+        'web/building_saas/complementary_ration_lib/js/gljSelect.js',
         'web/building_saas/complementary_ration_lib/js/ration_glj.js',
         'web/building_saas/complementary_ration_lib/js/ration_coe.js',
         'web/building_saas/complementary_ration_lib/js/ration_assist.js',

BIN
lib/jquery-ui/images/ui-icons_444444_256x240.png


BIN
lib/jquery-ui/images/ui-icons_555555_256x240.png


BIN
lib/jquery-ui/images/ui-icons_777620_256x240.png


BIN
lib/jquery-ui/images/ui-icons_777777_256x240.png


BIN
lib/jquery-ui/images/ui-icons_cc0000_256x240.png


BIN
lib/jquery-ui/images/ui-icons_ffffff_256x240.png


File diff suppressed because it is too large
+ 62 - 0
lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js


+ 8 - 3
modules/all_models/bills.js

@@ -42,9 +42,8 @@ let billsSchema = new Schema({
     isTender_Labour: Boolean,
     isTender_Material: Boolean,
     isTender_Machine: Boolean,
-    tenderTargetPrice: String, // Decimal
-    tenderTargetUnitPrice: String, // Decimal
-    tenderTargetUnitPrice: String, // Decimal
+    targetUnitFee:String,//目标单价
+    targetTotalFee:String,//目标合价
     //工作内容//zhong 2017-8-31
     jobContentText: String, //清单工作内容列显示文本, 减少第一次拉数据时的循环次数
     jobContent: [subSchema.jobContentSchema],
@@ -55,6 +54,12 @@ let billsSchema = new Schema({
     fees: [subSchema.feesSchema],
     // 标记字段
     flags: [subSchema.flagsSchema],
+    //消耗量调整系数字段
+    quantityCoe:subSchema.quantityCoeSchema,
+    //子目工程量调整系数
+    rationQuantityCoe:String,
+    // 不调价
+    is_adjust_price: {type: Number,default: 0},
     installationKey:String,//用来记录安装增加费的关联字段
     deleteInfo: deleteSchema,
     isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估

+ 2 - 0
modules/all_models/project_glj.js

@@ -83,6 +83,8 @@ let modelSchema = {
     unit_price: Schema.Types.Mixed,
     // 显示关联的消耗量
     quantity: String,
+    // 不调价
+    tenderPrice: String,//调整后价格
     // 显示组成物的消耗量
     consumption: String,
     // 显示关联配合比的id

+ 9 - 0
modules/all_models/ration.js

@@ -36,6 +36,15 @@ let rationSchema = new Schema({
     marketUnitFee: String,
     marketTotalFee: String,
     fees: [subSchema.feesSchema],
+    //消耗量调整系数字段
+    quantityCoe:subSchema.quantityCoeSchema,
+    //子目工程量调整系数
+    rationQuantityCoe:String,
+    tenderQuantity:String,//调整后工程量
+    // 不调价
+    is_adjust_price: {type: Number,default: 0},
+    targetUnitFee:String,//目标单价
+    targetTotalFee:String,//目标合价
     deleteInfo: deleteSchema,
     type: Number,                               // 1 定额、2 量价、3 工料机定额
     subType: Number,                            // 子类型:1人工、201材料、301机械、4主材、5设备

+ 1 - 0
modules/all_models/ration_glj.js

@@ -29,6 +29,7 @@ var ration_glj = new Schema({
     quantity:String,
     customQuantity:String,
     rationItemQuantity:String,
+    tenderQuantity:String,//调整后消耗量
     createType: {type: String,default:'normal'},//normal、add、replace  正常、添加工料机、替换工料机
     from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
 },{versionKey:false});

+ 10 - 1
modules/all_schemas/bills_sub_schemas.js

@@ -44,5 +44,14 @@ let itemCharacterSchema = new Schema({
     eigenvalue: [eigenvalueSchema],//特征值
     isChecked: Boolean //是否勾选(输出)
 }, {_id: false});
+//消耗量调整系数字段
+let quantityCoeSchema = new Schema({
+    labour: String, //人工
+    material: String, //材料
+    machine:String,//机械
+    main: String, //主材
+    equipment:String//设备
+}, {_id: false});
+
 
-module.exports = {feesSchema: feesSchema, flagsSchema: flagsSchema, jobContentSchema: jobContentSchema, itemCharacterSchema: itemCharacterSchema};
+module.exports = {feesSchema: feesSchema, flagsSchema: flagsSchema, jobContentSchema: jobContentSchema, itemCharacterSchema: itemCharacterSchema,quantityCoeSchema:quantityCoeSchema};

+ 1 - 1
modules/complementary_glj_lib/controllers/gljController.js

@@ -83,7 +83,7 @@ class GljController extends BaseController{
         let stdGljLibId = data.stdGljLibId,
             userId = data.userId,
             compilationId = data.compilationId
-            gljDao.getGljItems(stdGljLibId, userId, compilationId, function(err, data){
+            gljDao.getGljItems(stdGljLibId, req.session.sessionUser.id, req.session.sessionCompilation._id, function(err, data){
                 callback(req,res,err,'Get Items',data)
             });
     }

+ 5 - 0
modules/complementary_ration_lib/models/sectionTreeModel.js

@@ -4,6 +4,7 @@
 
 const mongoose = require('mongoose');
 const compleRationSectionTreeModel = mongoose.model('complementary_ration_section_tree');
+const compleRationModel = mongoose.model('complementary_ration_items');
 let counter = require('../../../public/counter/counter');
 let stdSectionTreeModel = require ('../../ration_repository/models/ration_section_tree').Model;
 
@@ -75,6 +76,10 @@ class SectionTreeDao {
                 }
                 else if(updateObj.updateType === 'update'){
                     await compleRationSectionTreeModel.update({userId: userID, rationRepId: updateObj.updateData.rationRepId, ID: updateObj.updateData.ID}, updateObj.updateData);
+                    if(updateObj.updateData.deleteInfo){
+                        await compleRationModel.update({userId: userID, sectionId: updateObj.updateData.ID},
+                            {$set: {deleteInfo: {deleted: true, deleteBy: userID, deleteDateTime: Date.now()}}}, {multi: true});
+                    }
                 }
             }
             callback(0, 'success');

+ 1 - 1
modules/complementary_ration_lib/routes/routes.js

@@ -35,7 +35,7 @@ module.exports = function (app) {
 
     router.post('/getGljDistType', gljController.init, gljController.getGljDistType);
     router.post('/getGljTree', gljController.init, gljController.getGljTree);
-    router.post('/getGljItems', compleRationController.init, compleRationController.getGljItems);
+    router.post('/getGljItems', gljController.init, gljController.getGljItems);
     router.post('/getGljItemsOccupied', compleRationController.init, compleRationController.getGljItemsOccupied);
     router.post('/getRationsCodes', compleRationController.init, compleRationController.getRationsCodes);
     router.post('/getGljItemsByIds', compleRationController.init, compleRationController.getGljItemsByIds);

+ 8 - 8
modules/glj/models/glj_list_model.js

@@ -114,10 +114,13 @@ class GLJListModel extends BaseModel {
             for(let tmp of gljData) {
                 // 有组成物的类型才查找
                 let key = keyMap[tmp.id];
-                if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
-                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
+                if(this.ownCompositionTypes.indexOf(tmp.type)!=-1){
                     connect_keys.push(key);
                 }
+                /*if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
+                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
+                    connect_keys.push(key);
+                }*/
             }
             // 查找组成物的消耗量
             let totalComposition = {};
@@ -267,8 +270,7 @@ class GLJListModel extends BaseModel {
             let CompositionGLJ=[];
             let unitPriceModel = new UnitPriceModel();
             // 判断类型,如果是混凝土、砂浆、配合比或者主材则查找对应的组成物(前提是没有对应的项目工料机数据)
-            if (data.type === GLJTypeConst.CONCRETE || data.type === GLJTypeConst.MORTAR ||
-                data.type === GLJTypeConst.MIX_RATIO || data.type === GLJTypeConst.GENERAL_MACHINE||data.type === GLJTypeConst.MAIN_MATERIAL) {
+            if(this.ownCompositionTypes.indexOf(data.type)!=-1) {
                 //如果是新增
                 if(isAddProjectGLJ ){
                     await this.compositionInit(data, unitPriceFileId);
@@ -380,8 +382,7 @@ class GLJListModel extends BaseModel {
         //新增项目工料机
         let gljData = await this.add(glj);
         //查看是否是有配合比的工料机类型
-        if (glj.type === GLJTypeConst.CONCRETE || glj.type === GLJTypeConst.MORTAR ||
-            glj.type === GLJTypeConst.MIX_RATIO || glj.type === GLJTypeConst.GENERAL_MACHINE){
+        if(this.ownCompositionTypes.indexOf(glj.type)!=-1){
             // 配合比数据插入
             let key_array = [];
             if(ration_glj.subType){//定额类型的工料机和定额工料机的key有点不同subType
@@ -651,8 +652,7 @@ class GLJListModel extends BaseModel {
             // 查找对应的项目工料机数据
             let projectGLJData = await this.getDataById(projectGLJId,unitPriceFileId);
 
-            let allowType = [GLJTypeConst.MIX_RATIO, GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR,
-                GLJTypeConst.GENERAL_MACHINE,GLJTypeConst.MAIN_MATERIAL];
+            let allowType = this.ownCompositionTypes;
 
             if (projectGLJData.unit_price === null || allowType.indexOf(projectGLJData.unit_price.type) < 0) {
                 throw '找不到相关项目工料机';

+ 22 - 8
modules/main/facade/project_facade.js

@@ -10,8 +10,10 @@ let bill_model = require('../models/bills');
 let consts = require('../models/project_consts');
 let projectConsts = consts.projectConst;
 let ration_glj_model = mongoose.model('ration_glj');
+let project_glj_model = mongoose.model('glj_list');
 let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
 const uuidV1 = require('uuid/v1');
+const gljUtil = require('../../../public/gljUtil');
 
 module.exports = {
     markUpdateProject:markUpdateProject,
@@ -123,6 +125,9 @@ async function updateNodes(datas){
     let nodeGroups = _.groupBy(datas,'type');
     let rationTasks = [];
     let billTasks = [];
+    let rationGLJTasks = [];
+    let projectGLJTasks = [];
+    let projectTasks = [];
     let asyncTasks = [];
     for(let type in nodeGroups){
         for(let node of nodeGroups[type]){
@@ -130,25 +135,34 @@ async function updateNodes(datas){
                 billTasks.push(getTask(node));
             }else if(type == projectConsts.RATION){
                 rationTasks.push(getTask(node));
+            }else if(type == projectConsts.RATION_GLJ){
+                rationGLJTasks.push(getTask(node));
+            }else if(type == projectConsts.PROJECTGLJ){
+                projectGLJTasks.push(getTask(node,'id'));
+            }else if(type == projectConsts.PROJECT){
+                projectTasks.push(getTask(node));
             }
+
         }
     }
     rationTasks.length>0?asyncTasks.push(ration_model.model.bulkWrite(rationTasks)):'';
     billTasks.length>0?asyncTasks.push(bill_model.model.bulkWrite(billTasks)):"";
+    rationGLJTasks.length>0?asyncTasks.push(ration_glj_model.bulkWrite(rationGLJTasks)):"";
+    projectGLJTasks.length>0?asyncTasks.push(project_glj_model.bulkWrite(projectGLJTasks)):"";
+    projectTasks.length>0?asyncTasks.push(projectsModel.bulkWrite(projectTasks)):"";
     return  asyncTasks.length>0?await Promise.all(asyncTasks):"";
 
-    function getTask(node) {
+    function getTask(node,idFiled = 'ID') {
+
         let task={
             updateOne:{
-                filter:{
-                    //projectID: node.data.projectID, 现在复制项目也重新生成一个新的ID了,所以ID是唯一的
-                    ID: node.data.ID
-                    //deleteInfo: null
-                },
-                update :node.data
+                filter:{},
+                update :_.cloneDeep(node.data)
             }
         };
-       return task;
+        task.updateOne.filter[idFiled] = node.data[idFiled];//现在复制项目也重新生成一个新的ID了,所以ID是唯一的
+        delete task.updateOne.update[idFiled];//防止误操作
+        return task;
     }
 }
 

+ 23 - 4
modules/main/facade/ration_facade.js

@@ -15,6 +15,7 @@ let installationFeeModel = mongoose.model("installation_fee");
 let rationInstallationModel = mongoose.model('ration_installation');
 const uuidV1 = require('uuid/v1');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
+let complementary_glj_model =  mongoose.model('complementary_glj_lib');
 let coeMolde = mongoose.model('std_ration_lib_coe_list');
 let _= require('lodash');
 const projectDao = require('../../pm/models/project_model').project;
@@ -241,11 +242,22 @@ async function addRationGLJ(std,newRation) {
     let sum=0;
     let first = +new Date();
     if(std.hasOwnProperty('rationGljList') && std.rationGljList.length > 0){
-       let stdGLJID = _.map(std.rationGljList,'gljId');
-       let stdGLJList = await std_glj_lib_gljList_model.find({'ID':{'$in':stdGLJID}});//速度优化-------先一次性取出所有的工料机列表
+        let stdGLJID =[];//标准工料机ID数组
+        let cptGLJID=[];//补充工料机ID数组
+            //let stdGLJID = _.map(std.rationGljList,'gljId');
+        for(let tem_g  of std.rationGljList){
+             if(tem_g.type == 'complementary'){
+                cptGLJID.push(tem_g.gljId);
+             }else {
+                stdGLJID.push(tem_g.gljId);
+             }
+        }
+       let stdGLJList = stdGLJID.length > 0 ? await std_glj_lib_gljList_model.find({'ID':{'$in':stdGLJID}}):[];//速度优化-------先一次性取出所有的工料机列表
        let stdGLJMap = _.indexBy(stdGLJList, 'ID');
+       let cptGLJList =  cptGLJID.length > 0 ? await complementary_glj_model.find({'userId':std.userId,'ID':{'$in':cptGLJID}}):[];
+       let cptGLJMap = _.indexBy(cptGLJList, 'ID');
         let stdGLJMapTime = +new Date();
-        console.log("找到标准工料机映射表时间-------------------------------"+(stdGLJMapTime - first));
+        console.log("找到工料机映射表时间-------------------------------"+(stdGLJMapTime - first));
         for(let sub of std.rationGljList){
             let newGLJ = {};
             newGLJ.ID = uuidV1();
@@ -256,7 +268,14 @@ async function addRationGLJ(std,newRation) {
             newGLJ.rationItemQuantity = sub.consumeAmt;
             newGLJ.quantity = sub.consumeAmt;
             newGLJ.glj_repository_id = std.rationRepId;
-            let std_glj = stdGLJMap[sub.gljId];
+            let std_glj = null;
+           if(sub.type == 'complementary'){//有可能来自标准工料机库或补充工料机库
+                std_glj = cptGLJMap[sub.gljId];
+                newGLJ.from = 'cpt';
+            }else {
+               std_glj = stdGLJMap[sub.gljId];
+               newGLJ.from = 'std';
+           }
             let std_gljTime = +new Date();
             if(std_glj){
                 newGLJ.name = std_glj.name;

+ 1 - 0
modules/main/models/project_consts.js

@@ -2,6 +2,7 @@
  * Created by jimiz on 2017/4/18.
  */
 let projectConst = {
+    PROJECT: 'project',
     BILLS: 'bills',
     RATION: 'ration',
     GLJ: 'GLJ',

+ 5 - 3
modules/pm/models/project_model.js

@@ -11,7 +11,8 @@ import {
     basicInformation,
     projectFeature,
     displaySetting,
-    calcOptions
+    calcOptions,
+    tenderSetting
 } from './project_property_template';
 import fixedFlag from '../../common/const/bills_fixed';
 let FeeRateFiles = mongoose.model('fee_rate_file');
@@ -145,14 +146,15 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     data.updateData.property.billsCalcMode = 0;
                     data.updateData.property.zanguCalcMode = 0;
                     //计算选项
-                    data.updateData.property.calcOptions = calcOptions
+                    data.updateData.property.calcOptions = calcOptions;
                     //安装增加费
                     if(parseInt(data.updateData.property.engineering)==4){
                         await installationFacade.copyInstallationFeeFromLib(data.updateData.ID,data.updateData.property.engineering_id);
                     }
                     //锁定清单
                     data.updateData.property.lockBills = false;
-
+                    //工料机单价调整系数
+                    data.updateData.property.tenderSetting = tenderSetting;
                 }
                 newProject = new Projects(data.updateData);
                 // 查找同级是否存在同名数据

+ 7 - 2
modules/pm/models/project_property_template.js

@@ -17,7 +17,12 @@ const displaySetting = {
     billsAutoHeight:true,
     rationAutoHeight:false,
     disPlayMainMaterial:true
-}
+};
+
+const tenderSetting = {
+    gljPriceTenderCoe:1, //工料机单价调整系数
+    calcPriceOption:'coeBase'//根据调整系数计算报价
+};
 
 const calcOptions={
     calc_main:false,
@@ -132,4 +137,4 @@ const projectFeature = [
     {dispName: '门窗材料及装饰', key: 'doorsWindowsMaterial', value: ''}
 ];
 
-export {defaultDecimal, billsQuantityDecimal, basicInformation, projectFeature,displaySetting,calcOptions};
+export {defaultDecimal, billsQuantityDecimal, basicInformation, projectFeature,displaySetting,calcOptions,tenderSetting};

+ 5 - 1
modules/ration_glj/facade/glj_calculate_facade.js

@@ -157,7 +157,11 @@ function generateAdjustState(glj,coeList,adjustState,index,quantity) {
     if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
         adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
     }else if(glj._doc.createType=='add'){
-        let displayQuantity = glj._doc.hasOwnProperty('customQuantity')?parseFloat(glj.customQuantity):parseFloat(quantity);
+        let displayQuantity = quantity;
+        if(glj._doc.hasOwnProperty('customQuantity')&&(glj.customQuantity != null||glj.customQuantity != '')){
+            displayQuantity = glj.customQuantity;
+        }
+        displayQuantity = displayQuantity&&displayQuantity!=""?parseFloat(displayQuantity):0;
         adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity});
     }
     // to do

+ 43 - 0
public/gljUtil.js

@@ -0,0 +1,43 @@
+/**
+ * Created by zhang on 2018/6/7.
+ */
+import fs from 'fs';
+let _= require('lodash');
+const scMathUtil = require('./scMathUtil').getUtil();
+
+let gljNodeUtil = null;
+let data = fs.readFileSync(__dirname + '/web/gljUtil.js', 'utf8', 'r');
+eval(data + ' ; gljNodeUtil = gljUtil; ');
+
+module.exports = {
+    calcProjectGLJQuantity :calcProjectGLJQuantity,
+    getGLJPrice:getGLJPrice,
+    calcPriceDiff:calcPriceDiff,
+    getMarketPrice:getMarketPrice,
+    getBasePrice:getBasePrice,
+    getAdjustPrice:getAdjustPrice
+};
+
+function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
+    gljNodeUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil);
+}
+
+function getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
+    return gljNodeUtil.getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+}
+
+function getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
+    return gljNodeUtil.getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+}
+
+function getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
+    return gljNodeUtil.getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+}
+
+function getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false,_,scMathUtil) {
+    return gljNodeUtil.getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+}
+
+function calcPriceDiff(glj,calcOptions) {
+    gljNodeUtil.calcPriceDiff(glj,calcOptions);
+}

+ 283 - 0
public/web/gljUtil.js

@@ -0,0 +1,283 @@
+/**
+ * Created by zhang on 2018/6/7.
+ */
+
+
+
+
+let gljUtil = {
+    calcProjectGLJQuantity:function (projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil) {
+        let project_gljs = projectGLJDatas.gljList;
+        let mixRatioMap = projectGLJDatas.mixRatioMap;
+        let rations = rationDatas;
+        let rationMap = _.indexBy(rations,'ID');
+        let quantityMap={};
+        let rationGljGroup = _.groupBy(rationGLJDatas,'projectGLJID');
+        let [billIDs,tech_billIDS] = this.getSubdivisionAndTechBillsLeavesID(billsDatas);//分别取分部分项和技术措施项目的所有叶子清单ID
+        for(let pglj of project_gljs ){
+            let pg_index = this.getIndex(pglj,gljKeyArray);
+            pglj.subdivisionQuantity = 0;
+            pglj.techQuantity = 0;
+            pglj.quantity = 0;
+            let gljGroup = rationGljGroup[pglj.id]?rationGljGroup[pglj.id]:[];//定额工料机没有,有可能是定额类型的工料机
+            let result = this.getQuantityPerGLJ(gljGroup,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil);
+            pglj.subdivisionQuantity = result.subdivisionQuantity;
+            pglj.techQuantity = result.techQuantity;
+            pglj.quantity = result.quantity;
+            quantityMap[pg_index] = pglj;
+        }
+        //计算做为组成物的消耗量
+        for(let pkey in mixRatioMap){
+            let mixRatioList = mixRatioMap[pkey];
+            for(let m of mixRatioList){
+                let m_index = gljOprObj.getIndex(m,gljKeyArray);
+                let m_glj = quantityMap[m_index];
+                let p_glj = quantityMap[pkey];
+                if(m_glj&&p_glj){
+                    let quantity = scMathUtil.roundForObj(p_glj.quantity*parseFloat(m.consumption),q_decimal);
+                    let techQuantity = scMathUtil.roundForObj(p_glj.techQuantity*parseFloat(m.consumption),q_decimal);
+                    let subdivisionQuantity = scMathUtil.roundForObj(p_glj.subdivisionQuantity*parseFloat(m.consumption),q_decimal);
+                    m_glj.quantity =  scMathUtil.roundForObj(m_glj.quantity+quantity,q_decimal);
+                    m_glj.techQuantity =  scMathUtil.roundForObj(m_glj.techQuantity+techQuantity,q_decimal);
+                    m_glj.subdivisionQuantity =  scMathUtil.roundForObj(m_glj.subdivisionQuantity+subdivisionQuantity,q_decimal);
+                }
+            }
+        }
+    },
+    getQuantityPerGLJ : function (ration_glj_list,rations,rationMap,pglj,billIDs,tech_billIDS,q_decimal,_,scMathUtil) {
+        let result={};
+        let quantity_sum=0;//工料机汇总消耗量
+        let sum = 0;//分部分项总消耗量
+        let tech_sum = 0;//技术措施总消耗量
+        for(let rg of ration_glj_list){
+            let tem_ration = rationMap[rg.rationID];
+            let r_quantity = tem_ration?scMathUtil.roundForObj(tem_ration.quantity,q_decimal):0;
+            let glj_quantity = scMathUtil.roundForObj(rg.quantity, q_decimal);
+            if(!r_quantity){
+                continue;
+            }
+            let total = scMathUtil.roundForObj(glj_quantity*r_quantity, q_decimal);
+            quantity_sum = scMathUtil.roundForObj(quantity_sum+total,q_decimal);
+            if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
+                sum = scMathUtil.roundForObj(sum+total,q_decimal);
+            }
+            if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
+                tech_sum = scMathUtil.roundForObj(tech_sum+total,q_decimal);
+            }
+        }
+        for(let ra of rations){//计算定额类型工料机的消耗量
+            if(ra.type == rationType.gljRation&&ra.projectGLJID===pglj.id){
+                let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
+                r_quantity = r_quantity?r_quantity:0;
+                quantity_sum = scMathUtil.roundForObj(quantity_sum+r_quantity,q_decimal);
+                if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
+                    sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
+                }
+                if(_.includes(tech_billIDS,ra.billsItemID)){//计算技术措施项目消耗量
+                    tech_sum = scMathUtil.roundForObj(tech_sum+r_quantity,q_decimal);
+                }
+            }
+
+        }
+        result.subdivisionQuantity = sum;
+        result.techQuantity = tech_sum;
+        result.quantity = quantity_sum;
+        return result;
+    },
+    getSubdivisionAndTechBillsLeavesID:function (billsDatas) {//分别取分部分项和技术措施项目的所有叶子清单ID
+        if(projectObj){//存在,说明在前端调用
+            return [projectObj.project.Bills.getSubdivisionProjectLeavesID(),projectObj.project.Bills.getTechLeavesID()];
+        }
+        let parentMap ={};
+        let subdivisionBillID  = null,techBillID = null,sIDs = [],tIDS = [];
+        for(let b of billsDatas){
+            if(parentMap[b.ParentID]){
+                parentMap[b.ParentID].push(b);
+            }else {
+                parentMap[b.ParentID]= [b];
+            }
+            if(this.isFlag(b)&&b.flagsIndex.fixed.flag==this.fixedFlag.SUB_ENGINERRING) {
+                subdivisionBillID = b.ID;
+            }
+            if(this.isFlag(b)&&b.flagsIndex.fixed.flag==this.fixedFlag.CONSTRUCTION_TECH){
+                techBillID = b.ID;
+            }
+        }
+
+        getLeaveIDs(subdivisionBillID,parentMap,sIDs);
+        getLeaveIDs(techBillID,parentMap,tIDS);
+        return [sIDs,tIDS];
+
+        function getLeaveIDs(ID,parentM,leaveIDs) {
+            if(parentM[ID] && parentM[ID].length > 0){
+                let children  =  parentM[ID];
+                for(let c of children){
+                    if(parentM[c.ID]){
+                        getLeaveIDs(c.ID,parentM,leaveIDs);
+                    }else {
+                        leaveIDs.push(c.ID);
+                    }
+                }
+            }
+        }
+    },
+    getGLJPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false,_,scMathUtil) {
+        let result = {};
+        result.marketPrice = this.getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+        if(this.calcPriceDiff(glj,calcOptions)==true){//计取价差
+            result.basePrice = this.getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+            result.adjustPrice = this.getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+        }else {//不计价差
+            result.basePrice = result.marketPrice;
+            result.adjustPrice = result.marketPrice;
+        }
+        return result;
+    },
+    getMarketPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil) {
+        let price_decimal = decimalObj.glj.unitPrice;
+        let quantity_decimal = decimalObj.glj.quantity;
+        let process_decimal = decimalObj.process;
+        if (this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
+            let p =0;
+            for(let ratio of glj.ratio_data){
+                let tem =  _.find(projectGLJDatas.gljList,{
+                    'code': ratio.code,
+                    'name': ratio.name,
+                    'specs':ratio.specs,
+                    'type': ratio.type,
+                    'unit': ratio.unit
+                });
+                if(tem){
+                    let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
+                    p+=scMathUtil.roundForObj(priceData.marketPrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
+                }
+            }
+            return scMathUtil.roundForObj(p,price_decimal);
+        }else {
+            let tem_decimal = isRadio==true?process_decimal:price_decimal;
+            return scMathUtil.roundForObj(glj.unit_price.market_price,tem_decimal);
+        }
+    },
+    getBasePrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil) {
+        let price_decimal = decimalObj.glj.unitPrice;
+        let quantity_decimal = decimalObj.glj.quantity;
+        let process_decimal = decimalObj.process;
+        if (this.notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
+            let p =0;
+            for(let ratio of glj.ratio_data){
+                let tem =  _.find( projectGLJDatas.gljList,{
+                    'code': ratio.code,
+                    'name': ratio.name,
+                    'specs':ratio.specs,
+                    'type': ratio.type,
+                    'unit': ratio.unit
+                });
+                if(tem){
+                    let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
+                    p+=scMathUtil.roundForObj(priceData.basePrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
+                }
+            }
+            return scMathUtil.roundForObj(p,price_decimal);
+        }else {
+            let tem_decimal = isRadio==true?process_decimal:price_decimal;
+            return scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal);
+        }
+    },
+    getAdjustPrice:function (glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false,_,scMathUtil) {
+        let decimal = decimalObj.glj.unitPrice;
+        let quantity_decimal =  decimalObj.glj.quantity;
+        let process_decimal = decimalObj.process;
+        let  tem_decimal = isRadio==true?process_decimal:decimal;
+        if (glj.unit_price.type == this.gljType.LABOUR || glj.unit_price.type == this.gljType.MACHINE_LABOUR) {//人工、机上人工,调整价根据定额价*调整系数计算得出。
+            let labour = _.find(labourCoeDatas.coes,{'ID':glj.adjCoe});
+            let coe = labour && labour.coe ? labour.coe : 1;
+            return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal)), -tem_decimal);
+        } else if (notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
+            let p =0;
+            for(let ratio of glj.ratio_data){
+                let tem =  _.find( projectGLJDatas.gljList,{
+                    'code': ratio.code,
+                    'name': ratio.name,
+                    'specs':ratio.specs,
+                    'type': ratio.type,
+                    'unit': ratio.unit
+                })
+                if(tem){
+                    let priceData=this.getGLJPrice(tem,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,true,_,scMathUtil);
+                    p+=scMathUtil.roundForObj(priceData.adjustPrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
+                }
+            }
+            return scMathUtil.roundForObj(p,decimal);
+        } else {//对于其他普通材料等,无调整系数,调整价=定额价。
+            return glj.unit_price.base_price
+        }
+    },
+    calcPriceDiff:function (glj,calcOptions) {
+        if(glj.is_evaluate==1){//先按是否暂估判断
+            return calcOptions.calc_est;
+        }
+        if(glj.type==gljType.MAIN_MATERIAL||glj.type==gljType.EQUIPMENT){//再判断是否是主材和设备
+            return calcOptions.calc_main;
+        }
+        if(glj.unit_price.is_add==1){//再判断是否新增
+            return calcOptions.calc_add;
+        }
+        return true;
+    },
+    isFlag : function (v) {
+        return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed) && this.isDef(v.flagsIndex.fixed.flag);
+    }
+    ,
+    isDef:function (v) {
+        return v !== undefined && v !== null;
+    },
+    getIndex(obj, pops){
+        let t_index = '';
+        let k_arr = [];
+        for (let p of pops) {
+            let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
+            k_arr.push(tmpK);
+        }
+        t_index = k_arr.join("|-|");
+        return t_index;
+    },
+    fixedFlag : {
+        // 分部分项工程
+        SUB_ENGINERRING: 1,
+        // 措施项目
+        MEASURE: 2,
+        // 施工技术措施项目
+        CONSTRUCTION_TECH: 3
+    },
+    gljType : {
+        // 人工
+        LABOUR: 1,
+        // ==============材料类型=================
+        // 普通材料
+        GENERAL_MATERIAL: 201,
+        // 混凝土
+        CONCRETE: 202,
+        // 砂浆
+        MORTAR: 203,
+        // 配合比
+        MIX_RATIO: 204,
+        // 商品混凝土
+        COMMERCIAL_CONCRETE: 205,
+        // 商品砂浆
+        COMMERCIAL_MORTAR: 206,
+        // ==============材料类型=================
+        // ==============机械类型=================
+        // 机械台班
+        GENERAL_MACHINE: 301,
+        // 机械组成物
+        MACHINE_COMPOSITION: 302,
+        // 机上人工
+        MACHINE_LABOUR: 303,
+        // ==============机械类型=================
+        // 主材
+        MAIN_MATERIAL: 4,
+        // 设备
+        EQUIPMENT: 5
+    },
+     notEditType : [202, 203,204, 301, 4],
+}

+ 49 - 0
public/web/ration_glj_units.js

@@ -0,0 +1,49 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/6/4
+ * @version
+ */
+//定额与工料机公用单位
+const rationAndGljUnits =[
+    'm',
+    'm2',
+    'm3',
+    '台班',
+    '工日',
+    't',
+    'kg',
+    '座',
+    '组',
+    '宗',
+    '元',
+    '套',
+    '台',
+    '千米',
+    '千克',
+    '辆',
+    '块',
+    '公斤',
+    '付',
+    '部',
+    '10t',
+    '10m',
+    '10 m2',
+    '10 m3',
+    '100m',
+    '100 m2',
+    '100 m3',
+    '1000m',
+    '1000 m2',
+    '1000 m3',
+    '10000块',
+    '立方米',
+    '平方米',
+    '株',
+    '棵',
+    '项',
+    '樘'
+];

+ 76 - 2
public/web/sheet/sheet_common.js

@@ -12,7 +12,8 @@ var sheetCommonObj = {
         spreadBook.options.showVerticalScrollbar = true;
         spreadBook.options.allowCopyPasteExcelStyle = false;
         spreadBook.options.allowUserDragDrop = true;
-        spreadBook.options. allowUserEditFormula = false;
+        spreadBook.options.allowContextMenu = false;
+        spreadBook.options.allowUserEditFormula = false;
         return spreadBook;
     },
 
@@ -34,7 +35,7 @@ var sheetCommonObj = {
 
         sheet.options.colHeaderAutoTextIndex = 1;
         sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
-
+        sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
         sheet.options.protectionOptions = {
             allowResizeColumns: true
         };
@@ -63,6 +64,7 @@ var sheetCommonObj = {
         for (var i = 0; i < setting.header.length; i++) {
             sheet.setValue(0, i, setting.header[i].headerName, ch);
             sheet.setColumnWidth(i, setting.header[i].headerWidth?setting.header[i].headerWidth:100);
+            sheet.setColumnVisible(i,setting.header[i].visible === false ? false:true);
         }
     },
     cleanSheet: function(sheet, setting, rowCount) {
@@ -459,5 +461,77 @@ var sheetCommonObj = {
             pasteText.push(rowText.join('\t'));
         }
         return pasteText.join('\n');
+    },
+    transferToTreeSetting:function(setting,treeSetting,treeCol){
+        for(let h of setting.header){
+            treeSetting.cols.push(getSettingCol(h))
+        }
+        for(let l of setting.view.lockColumns){
+            treeSetting.cols[l].readOnly = true;
+        }
+        return treeSetting;
+        function getSettingCol(header) {
+            let aMap ={left:0,center:1,right:2};
+            let hAlign = header.hAlign?aMap[header.hAlign]:0;
+            let col = {
+                "width":header.headerWidth?header.headerWidth:100,
+                "head":{
+                    "titleNames":Array.isArray(header.headerName)?header.headerName:[header.headerName],
+                    "spanCols":header.spanCols?header.spanCols:[1],
+                    "spanRows":header.spanRows?header.spanRows:[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data": {
+                    "field": header.dataCode,
+                    "vAlign": 1,
+                    "hAlign": hAlign,
+                    "font": "Arial"
+                }
+            };
+            if(header.showHint == true){
+                col.showHint = true;
+            }
+
+            if(header.cellType){
+                col.data.cellType = getCellType(header);
+            }
+            if(header.decimalField){//设置formatter
+                let decimal = getDecimal(header.decimalField);
+                col.formatter = getFormatter(decimal);
+            }
+            if(header.getText && treeCol){
+                col.data.getText = treeCol.getEvent(header.getText);
+            }
+
+
+
+            /*col.readOnly = function (node) {
+                if(node.data.ParentID == -1 || node.data.id == 'GJ'){//三材类别项不能编辑)
+                    return true;
+                }
+                return false;
+            };*/
+            return col;
+        }
+        function getCellType(header) {
+            return function () {
+                if(header.cellType === "checkBox"){
+                    return new GC.Spread.Sheets.CellTypes.CheckBox();
+                }
+                if(header.cellType === "comboBox"){
+                    let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
+                    if(header.options){
+                        dynamicCombo.itemHeight(header.options.length).items(header.options);
+                        if(header.editorValueType==true){
+                            dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
+                        }
+                    }
+                    return dynamicCombo
+                }
+            }
+        }
     }
+
 }

+ 1 - 0
public/web/sheet/sheet_data_helper.js

@@ -52,6 +52,7 @@ var SheetDataHelper = {
         spread.options.scrollbarMaxAlign = true;
         spread.options.cutCopyIndicatorVisible = false;
         spread.options.allowCopyPasteExcelStyle = false;
+        spread.options.allowContextMenu = false;
         spread.options.allowUserDragDrop = false;
         spread.options.allowUndo = false;//that.mainSpread.commandManager().setShortcutKey(undefined, GC.Spread.Commands.Key.z, true, false, false, false); 屏蔽undo
         spread.options. allowUserEditFormula = false;

+ 13 - 9
public/web/tree_sheet/tree_sheet_controller.js

@@ -53,7 +53,7 @@ var TREE_SHEET_CONTROLLER = {
                 if (this.tree.delete(this.tree.selected)) {
                     TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
                         that.sheet.deleteRows(sels[0].row, that.tree.selected.posterityCount() + 1);
-                        that.setTreeSelected(that.tree.items[sels[0].row]);
+                        that.setTreeSelected(that.tree.items[sels[0].row] ? that.tree.items[sels[0].row] : that.tree.items[that.tree.items.length - 1]);
                     });
                     if(typeof cbTools !== 'undefined'){
                         cbTools.refreshFormulaNodes();
@@ -141,8 +141,10 @@ var TREE_SHEET_CONTROLLER = {
         controller.prototype.upMove = function () {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
-                if (this.tree.selected.upMove()) {
-                    TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo(),true);
+                    if (that.tree.selected.upMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.nextSibling], true);
                         TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
                         TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo());
@@ -150,15 +152,17 @@ var TREE_SHEET_CONTROLLER = {
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
                         }
-                    });
-                }
+                    }
+                });
             }
         };
         controller.prototype.downMove = function () {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
-                if (this.tree.selected.downMove()) {
-                    TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo(),true);
+                    if (that.tree.selected.downMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.preSibling], true);
                         TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
                         TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo());
@@ -166,8 +170,8 @@ var TREE_SHEET_CONTROLLER = {
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
                         }
-                    });
-                }
+                    }
+                });
             }
         };
 

+ 5 - 4
public/web/tree_sheet/tree_sheet_helper.js

@@ -83,6 +83,7 @@ var TREE_SHEET_HELPER = {
 
         sheet.options.protectionOptions = option;
         sheet.options.isProtected = true;
+        sheet.options.allowCellOverflow = false;
     },
     massOperationSheet: function (sheet, Operation) {
         sheet.suspendPaint();
@@ -183,11 +184,11 @@ var TREE_SHEET_HELPER = {
             }
         });
     },
-    refreshChildrenVisiable:function(sheet,tree,node,row){
+    refreshChildrenVisiable:function(sheet,tree,node,row,visiable){
         let iCount = node.posterityCount(), i, child;
         for (i = 0; i < iCount; i++) {
-            child = tree.items[row + i + 1];
-            sheet.setRowVisible(row + i + 1, child.visible, GC.Spread.Sheets.SheetArea.viewport);
+            child = tree.items[row + i +1];
+            sheet.setRowVisible(row + i + 1, visiable?visiable:child.visible, GC.Spread.Sheets.SheetArea.viewport);
         }
        sheet.invalidateLayout();
     },
@@ -373,7 +374,7 @@ var TREE_SHEET_HELPER = {
                 return;
             }
             if(dataField === 'name' || dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'){
-                if(hitinfo.sheet.getParent() === projectObj.mainSpread && textLength <= cellWidth)
+                if((hitinfo.sheet.getParent() === projectObj.mainSpread||hitinfo.sheet.getParent() === tender_obj.tenderSpread) && textLength <= cellWidth)
                  return;
             }
             if(dataField=="quantity"){

File diff suppressed because it is too large
+ 3 - 2
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html


+ 19 - 6
web/building_saas/complementary_glj_lib/js/glj.js

@@ -18,10 +18,7 @@ let pageOprObj = {
         //repositoryGljObj.getRationGljIds(gljLibId);
         repositoryGljObj.getGljDistType(function () {
             repositoryGljObj.currentRepositoryId = me.stdGljLibId;
-           /* repositoryGljObj.getGljTree(stdGljLibId, function () {
-                repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId);
-            });*/
-            repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId, function () {
+            repositoryGljObj.getGljItems(me.stdGljLibId, function () {
                 gljClassTreeObj.getGljClassTree(stdGljLibId);
             });
         });
@@ -60,6 +57,21 @@ let repositoryGljObj = {
             ]
         }
     },
+    setUnitCombo: function (sheet, headers) {
+        let me = this;
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        let combo = sheetCommonObj.getDynamicCombo();
+        combo.items(rationAndGljUnits).itemHeight(10).editable(true);
+        for(let i = 0; i < headers.length; i++){
+            if(headers[i].dataCode === 'unit'){
+                sheet.getRange(-1, i, -1, 1).cellType(combo);
+                break;
+            }
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
     getComboData: function (gljDistType) {
         let me = this;
         let distType;
@@ -119,9 +131,9 @@ let repositoryGljObj = {
             }
         });
     },
-    getGljItems: function(stdGljLibId, userId, compilationId, callback) {
+    getGljItems: function(stdGljLibId, callback) {
         let me = this;
-        CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId, userId: userId, compilationId: compilationId}, function (rstData) {
+        CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId}, function (rstData) {
             me.stdGljList = rstData.stdGljs;
             me.complementaryGljList = rstData.complementaryGljs;
             me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
@@ -162,6 +174,7 @@ let repositoryGljObj = {
         let me = repositoryGljObj;
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         me.repositoryGljDelOpr();
+        me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
         me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);

+ 1 - 0
web/building_saas/complementary_glj_lib/js/gljClassTree.js

@@ -41,6 +41,7 @@ let gljClassTreeObj = {
         },
         options: {
             tabStripVisible:  false,
+            allowContextMenu: false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,
             allowUserDragDrop : false,

+ 1 - 1
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -89,7 +89,7 @@ let gljComponentOprObj = {
                                     componentTypeTreeOprObj.onClick(null, 'componentTree', co.rootNode);
                                 }
                                 //弹出窗口
-                                $('#componentBtn').click();
+                                $('#component').modal('show');
                             }},
                             "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
                                 //删除

+ 2 - 0
web/building_saas/complementary_glj_lib/js/sheetOpr.js

@@ -8,6 +8,7 @@ let sheetOpr = {
         spreadBook.options.allowCopyPasteExcelStyle = false;
         spreadBook.options.tabStripVisible = false;
         spreadBook.options.scrollbarMaxAlign = true;
+        spreadBook.options.allowContextMenu = false;
         //spreadBook.options.showHorizontalScrollbar = false;
         spreadBook.options.allowUserDragDrop = false;
         return spreadBook;
@@ -42,6 +43,7 @@ let sheetOpr = {
         spreadBook.options.allowCopyPasteExcelStyle = false;
         spreadBook.options.allowExtendPasteRange = true;
         spreadBook.options.allowUserDragDrop = false;
+        spreadBook.options.allowContextMenu = false;
         var spreadNS = GC.Spread.Sheets;
         var sheet = spreadBook.getSheet(0);
         sheet.suspendPaint();

File diff suppressed because it is too large
+ 4 - 4
web/building_saas/complementary_ration_lib/html/anzhuang.html


File diff suppressed because it is too large
+ 69 - 11
web/building_saas/complementary_ration_lib/html/dinge.html


File diff suppressed because it is too large
+ 4 - 4
web/building_saas/complementary_ration_lib/html/fuzhu.html


File diff suppressed because it is too large
+ 4 - 4
web/building_saas/complementary_ration_lib/html/gongliao.html


+ 1 - 1
web/building_saas/complementary_ration_lib/html/main.html

@@ -5,7 +5,7 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <title>定额库编辑器</title>
+    <title>定额库编辑器-Smartcost</title>
     <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
    <!-- <link rel="stylesheet" href="css/bootstrap/themes.css">-->
     <link rel="stylesheet" href="/web/building_saas/css/main.css">

+ 333 - 0
web/building_saas/complementary_ration_lib/js/gljSelect.js

@@ -0,0 +1,333 @@
+/**
+ * Created by Zhong on 2017/8/25.
+ */
+
+let gljSelOprObj = {
+    parentNodeIds: {},
+    treeObj:null,
+    rootNode: null,//分类树根节点
+    radiosSelected: null,//allGljs, stdGljs, complementaryGljs
+    workBook: null,
+    selectedList: [],//选中的工料机
+    setting: {
+        header: [
+            {headerName:"选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center"},
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
+            {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
+        ]
+    },
+    setProp: function (prop, value, gljList) {
+        for(let i = 0, len = gljList.length; i < len; i++){
+            gljList[i][prop] = value;
+        }
+    },
+    sortGlj: function(gljList) {
+        gljList.sort(function(a, b){
+            let rst = 0;
+            if (a.code > b.code) rst = 1
+            else if (a.code < b.code) rst = -1;
+            return rst;
+        });
+    },
+    switchToGljId: function (gljList) {
+        for(let glj of gljList){
+            glj.gljId = glj.ID;
+            delete glj.ID;
+        }
+    },
+    getSelGljItems: function(stdGljLibId, callback) {
+        let me = this;
+        CommonAjax.post('/complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId}, function (rstData) {
+            me.stdGljList = rstData.stdGljs;
+            me.complementaryGljList = rstData.complementaryGljs;
+            me.switchToGljId(me.stdGljList);
+            me.switchToGljId(me.complementaryGljList);
+            me.setProp('type', 'std', me.stdGljList);
+            me.setProp('type', 'complementary', me.complementaryGljList);
+            me.sortGlj(me.stdGljList);
+            me.sortGlj(me.complementaryGljList);
+            if(callback){
+                callback();
+            }
+        });
+    },
+    getGljClassTree: function (gljLibId, callback) {
+        let me = this;
+        let url = '/complementartGlj/api/getGljTree';
+        let postData = {gljLibId: gljLibId};
+        let sucFunc = function (rstData) {
+            zTreeHelper.createTree(rstData, gljSelTreeOprObj.setting, "selGljTree", gljSelOprObj);
+            let rootNode = gljSelOprObj.treeObj.getNodes()[0];
+            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                gljSelOprObj.rootNode = rootNode;
+            }
+            gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
+            if(callback){
+                callback();
+            }
+        };
+        let errFunc = function () {
+
+        };
+        CommonAjax.post(url, postData, sucFunc, errFunc);
+    },
+    buildSheet: function (container) {
+        let me = gljSelOprObj;
+        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
+        me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
+        me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
+        me.bindBtnOpr($('#gljSelY'));
+        me.radiosChange();
+    },
+    onClipboardPasting: function (sender, args) {
+        args.cancel = true;
+    },
+    onCellEditStart: function (sender, args) {
+        args.cancel = true;
+    },
+    onButtonClicked: function (sender, args) {
+        let me = gljSelOprObj;
+        let val = args.sheet.getValue(args.row, args.col);
+        let thisGlj = me.currentCache[args.row];
+        thisGlj.isChecked = val;
+        if(args.sheet.isEditing()){
+            args.sheet.endEdit(true);
+        }
+        else{
+            //设置选中
+            if(val === true){
+                let isExist = false;
+                for(let i = 0, len = me.selectedList.length; i < len; i++){
+                    if(me.selectedList[i].gljId === thisGlj.gljId){
+                        isExist = true;
+                        break;
+                    }
+                }
+                if(!isExist){
+                    thisGlj.consumeAmt = 0;
+                    me.selectedList.push(thisGlj);
+                }
+            }
+            else if(val === false){
+                for(let i = 0, len = me.selectedList.length; i < len; i++){
+                    if(me.selectedList[i].gljId === thisGlj.gljId){
+                        me.selectedList.splice(i, 1);
+                        break;
+                    }
+                }
+            }
+        }
+    },
+    setShowGljList: function (gljList, clearChecked) {
+        //初始为所有工料机
+        let  me = this;
+        let curRationGlj = rationGLJOprObj.cache['_GLJ_' + rationGLJOprObj.currentRationItem.ID];
+        for(let i = 0; i < gljList.length; i++){
+            //去除与已添加的组成物重复的条目
+            let isExist = false;
+            for(let j = 0; j < curRationGlj.length; j++){
+                if(curRationGlj[j].gljId === gljList[i].gljId){
+                    isExist = true;
+                    break;
+                }
+            }
+            if(!isExist){
+                if(clearChecked){
+                    gljList[i].isChecked = false;
+                }
+            }
+            else {
+                gljList[i].isChecked = true;
+            }
+            me.showGljList.push(gljList[i]);
+        }
+    },
+    //初始默认radio
+    initRadio: function () {
+        let me = gljSelOprObj;
+        $('#gljSearchKeyword').val('');//恢复搜索文本
+        me.selectedList = [].concat(rationGLJOprObj.cache['_GLJ_' + rationGLJOprObj.currentRationItem.ID]);
+        //默认radio所有工料机
+        if(typeof $("input[name='glj']:checked")[0] !== 'undefined'){
+            $("input[name='glj']:checked")[0].checked = false;
+        }
+        $("input[value = 'allGljs']")[0].checked = true;
+        me.radiosSelected = 'allGljs';
+        //初始为所有工料机
+        me.showGljList = [];
+        if(me.radiosSelected === 'allGljs'){
+            me.setShowGljList(me.stdGljList, true);
+            me.setShowGljList(me.complementaryGljList, true);
+            me.sortGlj(me.showGljList);
+        }
+    },
+    filterDatasAndShow: function () {
+        let me = gljSelOprObj;
+        let val = $("input[name='glj']:checked").val();
+        me.radiosSelected = val;
+        //选择改变,数据重新筛选显示
+        me.showGljList = [];
+        if(me.radiosSelected === 'allGljs'){
+            me.setShowGljList(me.stdGljList);
+            me.setShowGljList(me.complementaryGljList);
+        }
+        else if(me.radiosSelected === 'stdGljs'){
+            me.setShowGljList(me.stdGljList);
+        }
+        else if(me.radiosSelected === 'complementaryGljs'){
+            me.setShowGljList(me.complementaryGljList);
+        }
+        //搜索匹配
+        let searchStr = $('#gljSearchKeyword').val();
+        if(searchStr && searchStr.trim() != ''){
+            let reg = new RegExp(searchStr);
+            me.showGljList = _.filter(me.showGljList, function (data) {
+                return reg.test(data.code) || reg.test(data.name);
+            });
+        }
+        me.sortGlj(me.showGljList);
+        //重新显示
+        me.showGljItems(me.showGljList, me.gljCurTypeId);
+        //切换radio后更新cache
+        if (me.currentOprParent = 1) {
+            if(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
+                me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
+            }
+            else{
+                me.currentCache = [];
+            }
+        } else {
+            me.currentCache = me.getCache();
+        }
+    },
+    //监听radios选择事件
+    radiosChange: function () {
+        let me = gljSelOprObj;
+        $('.glj-radio').change(function () {
+            me.filterDatasAndShow();
+        });
+    },
+
+    getParentCache: function (nodes) {
+        let me = gljSelOprObj, rst = [];
+        for(let i = 0; i < me.showGljList.length; i++){
+            if(nodes.indexOf(me.showGljList[i].gljClass) !== -1){
+                rst.push(me.showGljList[i]);
+            }
+        }
+        rst.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code)rst = -1;
+            return rst;
+        });
+        return rst;
+    },
+    getCache: function() {
+        let me = gljSelOprObj, rst = [];
+        for (let i = 0; i < me.showGljList.length; i++) {
+            if (me.showGljList[i].gljClass == me.gljCurTypeId) {
+                rst.push(me.showGljList[i]);
+            }
+        }
+        return rst;
+    },
+    showGljItems: function(data, type) {
+        let me = gljSelOprObj;
+        if (me.workBook) {
+            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) {
+                    cacheSection.push(data[i]);
+                }
+            }
+            sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+            sheetsOprObj.showDataForGljSel(me.workBook.getSheet(0), me.setting, cacheSection, rationGLJOprObj.distTypeTree);
+            me.workBook.getSheet(0).setRowCount(cacheSection.length);
+            cacheSection = null;
+        }
+    },
+    //组成物窗口按钮操作
+    bindBtnOpr: function (conf) {//确定、取消、关闭按钮
+        let me = gljSelOprObj, that = rationGLJOprObj;
+        conf.click(function () {
+            that.cache['_GLJ_' + that.currentRationItem.ID] = me.selectedList;
+            that.updateRationItem(function () {
+                that.sheet.getParent().focus();
+                sheetCommonObj.cleanData(that.sheet, that.setting, -1);
+                that.showGljItems(that.currentRationItem.ID);
+                $('#selGlj').modal('hide');
+            });
+        });
+    }
+};
+
+let gljSelTreeOprObj = {
+     setting: {
+        view: {
+            expandSpeed: "",
+            selectedMulti: false
+        },
+        edit: {
+            enable: false,
+            editNameSelectAll: true,
+            showRemoveBtn: true,
+            showRenameBtn: true,
+            removeTitle: "删除节点",
+            renameTitle: "更改名称"
+        },
+        data: {
+            keep: {
+                parent:true,
+                leaf:true
+            },
+            key: {
+                children: "items",
+                name: "Name"
+            },
+            simpleData: {
+                enable: false,
+                idKey: "ID",
+                pIdKey: "ParentID",
+                rootPId: -1
+            }
+        },
+        callback:{
+            onClick: function(event,treeId,treeNode) {
+                let me = gljSelOprObj, gljTypeId = treeNode.ID;
+                if(me.gljCurTypeId !== treeNode.ID){
+                    me.gljCurTypeId = treeNode.ID;
+                    if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
+                        me.currentOprParent = 1;
+                        me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
+                    } else {
+                        me.currentCache = me.getCache();
+                    }
+                }
+                me.showGljItems(me.showGljList, gljTypeId);
+            }
+        }
+    }
+};
+
+$(document).ready(function () {
+    $('#gljSearchKeyword').change(function () {
+        gljSelOprObj.filterDatasAndShow();
+    });
+    $('#gljSearchKeyword').bind('keypress', function (e) {
+        if(e.keyCode === 13){
+            $(this).blur();
+            return false;
+        }
+    });
+});

+ 8 - 2
web/building_saas/complementary_ration_lib/js/main.js

@@ -12,10 +12,16 @@ let compleRationMain = {
                     let libName = rstData[i].dispName;
                     $("#comple_ration_table").append(
                         "<tr id='tempId'>" +
-                        "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td></tr>"
+                        "<td><a href='javascript:void(0);'>"+libName+"</a></td></tr>"
                     );
                     var newHref = "/complementaryRation/ration?repository="+id;
-                    $("#tempId td:first a").attr("href", newHref);
+                    $("#tempId td:first a").click(function () {
+                        let newHref = "/complementaryRation/ration?repository="+id;
+                        let newTab = window.open('about:blank');
+                        CommonAjax.get(newHref, [], function () {
+                            newTab.location.href = newHref;
+                        });
+                    });
                     $("#tempId").attr("id", id);
                 }
             }

+ 66 - 15
web/building_saas/complementary_ration_lib/js/ration.js

@@ -54,6 +54,7 @@ let rationOprObj = {
         let me = rationOprObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.getRationsCodes(rationRepId);
+        me.onContextmenuOpr();
         me.rationDelOpr();
         me.setCombo(me.workBook.getSheet(0), 'dynamic');
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -70,7 +71,7 @@ let rationOprObj = {
         sheet.suspendEvent();
         if(combo){
             combo = sheetCommonObj.getDynamicCombo();
-            combo.items(rationUnits).itemHeight(10).editable(true);
+            combo.items(rationAndGljUnits).itemHeight(10).editable(true);
         }
         sheet.getRange(-1, me.setting.view.comboBox[0].col, -1, 1).cellType(combo);
         sheet.resumePaint();
@@ -163,6 +164,52 @@ let rationOprObj = {
         }
         return cacheSection;
     },
+    onContextmenuOpr: function () {//右键菜单
+        let me = this;
+        $.contextMenu({
+            selector: '#rationItemsSheet',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
+                let sheet = me.workBook.getSheet(0);
+                let  delDis = false;
+                let cacheSection = me.getCache();
+                let ration = cacheSection[target.row];
+                if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
+                    if(typeof target.row !== 'undefined'){
+                        //控制按钮是否可用
+                        sheet.setActiveCell(target.row, target.col);
+                        if(!cacheSection ||target.row >= cacheSection.length){//右键定位在有数据的行,删除键才显示可用
+                            delDis = true;
+                        }
+                        else{//有数据
+                            if(typeof target.col === 'undefined'){//定位不在表格内
+                                delDis = true;
+                            }
+                            else {
+                                delDis = ration.type === 'std' ? true : false;
+                            }
+                        }
+                    }
+                    else{
+                        delDis = true;
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
+                                me.mixDel = 1;
+                                me.mixUpdateRequest([], [], [ration.ID]);
+                            }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    },
     rationDelOpr: function () {
         let me = rationOprObj;
         me.workBook.commandManager().register('rationDelete', function () {
@@ -176,7 +223,7 @@ let rationOprObj = {
                             for(let i = 0; i < sels[sel].rowCount; i++){
                                 if(sels[sel].row + i < cacheSection.length && cacheSection[sels[sel].row + i].type !== me.type.std){
                                     removeArr.push(cacheSection[sels[sel].row + i].ID);
-                                    me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
+                                    me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code.toString()), 1);
                                 }
                             }
                         }
@@ -280,6 +327,10 @@ let rationOprObj = {
         }
     },
     onCellEditEnd: function(sender, args) {
+        let edV = args.sheet.getValue(args.row, args.col);
+        if(edV){
+            args.sheet.setValue(args.row, args.col, edV.toString().trim());
+        }
         let me = rationOprObj, rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
             updateArr = [], addArr = [];
         let dataCode = me.setting.header[args.col].dataCode;
@@ -293,9 +344,9 @@ let rationOprObj = {
                 if(me.currentEditingRation[dataCode] !== rObj[dataCode]){
                     me.addRationItem = rObj;
                     if(dataCode === 'code'){
-                        if(me.rationsCodes.indexOf(rObj.code) === -1){
-                            me.rationsCodes.splice(me.rationsCodes.indexOf(rObj.code), 1);
-                            me.rationsCodes.push(rObj.code);
+                        if(me.rationsCodes.indexOf(rObj.code.toString()) === -1){
+                            me.rationsCodes.splice(me.rationsCodes.indexOf(rObj.code.toString()), 1);
+                            me.rationsCodes.push(rObj.code.toString());
                             updateArr.push(rObj);
                         }
                         else{
@@ -324,7 +375,7 @@ let rationOprObj = {
                 //addArr.push(rObj);
                 me.addRationItem = rObj;
                 if(rObj.code && rObj.code.toString().trim().length > 0){
-                    if(me.rationsCodes.indexOf(rObj.code) === -1){
+                    if(me.rationsCodes.indexOf(rObj.code.toString()) === -1){
                         //jobContent
                         if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                             rObj.jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
@@ -334,7 +385,7 @@ let rationOprObj = {
                         }
                         me.setInitPrc(rObj);
                         addArr.push(rObj);
-                        me.rationsCodes.push(rObj.code);
+                        me.rationsCodes.push(rObj.code.toString());
                         me.addRationItem = null;
                     }
                     else{
@@ -386,11 +437,11 @@ let rationOprObj = {
         for (let i = 0; i < items.length; i++) {
             let rowIdx = info.cellRange.row + i;
             if (cacheSection) {
-                if(!me.isValidUnit(items[i], rationUnits)){//无效单位
+               /* if(!me.isValidUnit(items[i], rationUnits)){//无效单位
                     items[i].unit = rowIdx < cacheSection.length  && typeof cacheSection[rowIdx].unit !== 'undefined' ? cacheSection[rowIdx].unit : '';
-                }
+                }*/
                 if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
-                    if(me.rationsCodes.indexOf(items[i].code) === -1){
+                    if(me.rationsCodes.indexOf(items[i].code.toString()) === -1){
                         //jobConten
                         if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                             items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
@@ -400,7 +451,7 @@ let rationOprObj = {
                         }
                         me.setInitPrc(items[i]);
                         addArr.push(items[i]);
-                        me.rationsCodes.push(items[i].code);
+                        me.rationsCodes.push(items[i].code.toString());
                     }
                     else{
                         me.workBook.getSheet(0).setValue(rowIdx, 0, '');
@@ -417,7 +468,7 @@ let rationOprObj = {
                         me.workBook.getSheet(0).setValue(rowIdx, 8, '');
                     }
                     if(info.cellRange.col === 0){
-                        if(me.rationsCodes.indexOf(items[i].code) === -1){
+                        if(me.rationsCodes.indexOf(items[i].code.toString()) === -1){
                             items[i].ID = cacheSection[rowIdx].ID;
                             updateArr.push(items[i]);
                         }
@@ -432,13 +483,13 @@ let rationOprObj = {
                 }
 
             } else {
-                if(!me.isValidUnit(items[i], rationUnits)){//无效单位
+                /*if(!me.isValidUnit(items[i], rationUnits)){//无效单位
                     items[i].unit = '';
-                }
+                }*/
                 //add
                 if(info.cellRange.col === 0){
                     //是否含有已存在的编号
-                        if(me.rationsCodes.indexOf(items[i].code) === -1){
+                        if(me.rationsCodes.indexOf(items[i].code.toString()) === -1){
                             //jobConten
                             if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                                 items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';

+ 2 - 2
web/building_saas/complementary_ration_lib/js/ration_coe.js

@@ -10,7 +10,7 @@ var rationCoeOprObj = {
     cache: {},
     setting: {
         header:[
-            {headerName:"编号",headerWidth:120,dataCode:"serialNo", dataType: "Number", hAlign: 'left'},
+            {headerName:"编号",headerWidth:120,dataCode:"serialNo", dataType: "Number", hAlign: 'center'},
             {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String", hAlign: 'left'},
             {headerName:"内容",headerWidth:300,dataCode:"content", dataType: "String", hAlign: 'left'}
         ],
@@ -289,7 +289,7 @@ var rationCoeOprObj = {
             var curCache = me.cache["_Coe_" + me.curRation.ID];
             if (curCache) {
                 for (let obj of curCache) {
-                    rst.push(obj.ID);
+                    rst.push({ID: obj.ID, no: obj.no});
                 };
                 me.curRation.rationCoeList = rst;
                 updateArr.push(me.curRation);

+ 81 - 52
web/building_saas/complementary_ration_lib/js/ration_glj.js

@@ -15,7 +15,7 @@ var rationGLJOprObj = {
             {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
             {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String"},
             {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"基价单价",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00",  precision: 2},
+            {headerName:"定额价",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00",  precision: 2},
             {headerName:"定额消耗",headerWidth:160, dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", precision: 3},
             {headerName:"类型",headerWidth:160,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"}
         ],
@@ -79,13 +79,84 @@ var rationGLJOprObj = {
         var me = this;
         me.sheet = sheet;
         me.getGljDistType(function () {
-           // me.onContextmenuOpr();
-            sheetCommonObj.initSheet(me.sheet, me.setting, 30);
-            me.bindRationGljDelOpr();
-            me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-            me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-            me.sheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
-            me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+            gljSelOprObj.getGljClassTree(pageOprObj.gljLibId, function () {
+                gljSelOprObj.getSelGljItems(pageOprObj.gljLibId, function () {
+                    sheetCommonObj.initSheet(me.sheet, me.setting, 30);
+                    me.onContextmenuOpr();
+                    me.bindRationGljDelOpr();
+                    me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+                    me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+                    me.sheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
+                    me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+                });
+            });
+        });
+    },
+    onContextmenuOpr: function () {//右键菜单
+        let me = this;
+        $.contextMenu({
+            selector: '#rdSpread',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.sheet.getParent());
+                let sheet = me.sheet;
+                let addDis = false, delDis = false;
+                let rationGlj = [];
+                if(me.sheet.getParent().getActiveSheet() === me.sheet && target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
+                    if(typeof target.row !== 'undefined'){
+                        //控制按钮是否可用
+                        sheet.setActiveCell(target.row, target.col);
+                        //当前定额为补充定额时按钮有效
+                        if(me.currentRationItem && me.currentRationItem.type === 'complementary'){
+                            rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
+                            if(!rationGlj ||target.row >= rationGlj.length){//右键定位在有数据的行,删除键才显示可用
+                                delDis = true;
+                            }
+                            else{//有数据
+                                if(typeof target.col === 'undefined'){//定位不在表格内
+                                    delDis = true;
+                                }
+                            }
+                        }
+                        else{
+                            addDis = true;
+                            delDis = true;
+                        }
+                    }
+                    else{
+                        addDis = true;
+                        delDis = true;
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            "add": {name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
+                                //默认radio所有工料机
+                                gljSelOprObj.initRadio();
+                                gljSelOprObj.gljCurTypeId = null;
+                                //默认点击树根节点
+                                if(gljSelOprObj.rootNode){
+                                    gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
+                                    gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
+                                }
+                                //弹出窗口
+                                $('#selGlj').modal('show');
+                            }},
+                            "delete": {name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
+                                rationGlj.splice(target.row, 1);
+                                me.updateRationItem(function(){
+                                    me.sheet.getParent().focus();
+                                });
+                                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
+                                me.showGljItems(me.currentRationItem.ID);
+                            }},
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
         });
     },
     bindRationGljDelOpr: function () {
@@ -256,7 +327,7 @@ var rationGLJOprObj = {
                         }
                     }
                     if (isExist) {
-                        alert("该工料机已存在!");
+                        alert("人材机已存在!");
                         args.sheet.setValue(args.row, args.col, typeof cacheArr[args.row] !== 'undefined' ? cacheArr[args.row].code + '' : '');
                     }
                     else {
@@ -287,47 +358,6 @@ var rationGLJOprObj = {
             args.sheet.setValue(args.row, args.col, '');
         }
     },
-    onContextmenuOpr: function () {
-        let me = rationGLJOprObj;
-        $.contextMenu({
-            selector: '#rdSpread',
-            build: function ($triggerElement, e) {
-                //控制允许右键菜单在哪个位置出现
-                let sheet = me.sheet;
-                let offset = $triggerElement.offset(),
-                    x = e.pageX - offset.left,
-                    y = e.pageY - offset.top;
-                let target = sheet.hitTest(x, y);
-                if(sheet.parent.getActiveSheetIndex() === 0 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
-                    let delDis = true, cacheSection;
-                    sheet.setActiveCell(target.row, target.col);
-                    if(me.currentRationItem){
-                        let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID];
-                        if(target.row < cacheSection.length){
-                            delDis = false;
-                        }
-                    }
-                    return {
-                        callback: function(key, options) {
-                        },
-                        items: {
-                            "delete": {name: "删除", icon: 'fa-remove', disabled: delDis, callback: function (key, opt) {
-                                cacheSection.splice(target.row, 1);
-                                me.updateRationItem(function () {
-                                    me.sheet.getParent().focus(true);
-                                });
-                                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-                                me.showGljItems(me.currentRationItem.ID);
-                            }}
-                        }
-                    };
-                }
-                else{
-                    return false;
-                }
-            }
-        });
-    },
     getRecoveryArr: function (tempDelArr, newArr) {//获得更新的code不存在,恢复删除的被更新数据
         let rst = [];
         for(let i = 0, len = tempDelArr.length; i < len; i++){
@@ -402,7 +432,7 @@ var rationGLJOprObj = {
                     return rst;
                 });
                 $('#alertModalBtn').click();
-                $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
+                $('#alertText').text("人材机"+ codes + "不存在,请查找你所需要的人材机,或新增人材机");
                 $('#alertModalCls').click(function () {
                     me.showGljItems(me.currentRationItem.ID);
                 });
@@ -484,7 +514,6 @@ var rationGLJOprObj = {
 
     buildRationItemGlj: function(){
         var me = this, rst = [];
-        console.log(me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]);
         if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
             var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
             for (var i = 0; i < cacheArr.length; i++) {

+ 2 - 63
web/building_saas/complementary_ration_lib/js/repository_glj.js

@@ -111,20 +111,6 @@ repositoryGljObj = {
                 callback();
             }
         });
-   /*     $.ajax({
-            type: 'post',
-            url: "api/getGljDistType",
-            dataType: 'json',
-            success: function (result) {
-                if(!result.error && callback){
-                    me.distTypeTree = me.getComboData(result.data);
-                    /!*let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
-                    combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);*!/
-                    me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).value(me.distTypeTree.comboDatas[0].text);
-                    callback();
-                }
-            }
-        })*/
     },
     getGljTree: function(gljLibId, callback) {
         var me = this;
@@ -137,34 +123,11 @@ repositoryGljObj = {
             }
             callback();
         });
-/*
-        $.ajax({
-            type:"POST",
-            url:"api/getGljTree",
-            data:{"gljLibID": gljLibID},
-            dataType:"json",
-            cache:false,
-            timeout:20000,
-            success:function(result,textStatus,status){
-                if(status.status == 200) {
-                    zTreeHelper.createTree(result.data, gljSetting, "repositoryTree", me);
-                    if (result.data && result.data.length > 0) {
-                        me.gljCurTypeId = result.data[0].ID;
-                    } else {
-                        gljTypeTreeOprObj.addRootNode();
-                    }
-                    callback();
-                }
-            },
-            error:function(err){
-                alert(err.responseJSON.error);
-            }
-        })*/
     },
     getGljItems: function(gljLibId) {
         var me = this;
-        CommonAjax.post('api/getGljItems', {gljLibId: gljLibId}, function (rstData) {
-            me.gljList = rstData;
+        CommonAjax.post('api/getGljItems', {stdGljLibId: gljLibId}, function (rstData) {
+            me.gljList = rstData.stdGljs.concat(rstData.complementaryGljs);
             me.workBook.getSheet(0).setRowCount(rstData.length);
             me.sortGlj();
             let rootNode = me.treeObj.getNodes()[0];
@@ -174,30 +137,6 @@ repositoryGljObj = {
             }
         });
 
-       /* $.ajax({
-            type:"POST",
-            url:"api/getGljItems",
-            data:{"repositoryId": gljLibID},
-            dataType:"json",
-            cache:false,
-            timeout:5000,
-            success:function(result){
-                if(!result.error) {
-                    me.gljList = result.data;
-                    me.workBook.getSheet(0).setRowCount(result.data.length);
-                    me.sortGlj();
-                    let rootNode = me.treeObj.getNodes()[0];
-                    if(rootNode && rootNode.isParent && rootNode.isFirstNode){
-                        me.treeObj.selectNode(rootNode);
-                        gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
-                    }
-                    //me.showGljItems(result.data, me.gljCurTypeId);
-                }
-            },
-            error:function(err){
-                alert(err.responseJSON.error);
-            }
-        })*/
     },
     showGljItems: function(data, type) {
         var me = repositoryGljObj;

+ 9 - 0
web/building_saas/complementary_ration_lib/js/section_tree.js

@@ -104,6 +104,7 @@ let sectionTreeObj = {
             rootId: -1
         },
         options: {
+            allowContextMenu: false,
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,
@@ -353,6 +354,7 @@ let sectionTreeObj = {
                     me.refreshBtn(me.tree.selected);
                     //fresh tools
                     me.initTools(me.tree.selected);
+                    me.initSelection(me.tree.selected);
                 });
             }
         });
@@ -400,6 +402,7 @@ let sectionTreeObj = {
                 me.controller.delete();
                 me.refreshBtn(me.tree.selected);
                 me.initTools(me.tree.selected);
+                me.initSelection(me.tree.selected);
             });
         }
     },
@@ -439,8 +442,14 @@ let sectionTreeObj = {
     initSelection: function (node) {
         let me = this;
         if(!me.isDef(node)){
+            sheetCommonObj.cleanSheet(rationOprObj.workBook.getActiveSheet(), rationOprObj.setting, -1);
+            sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
+            sheetCommonObj.cleanSheet(rationCoeOprObj.sheet, rationCoeOprObj.setting, -1);
+            sheetCommonObj.cleanSheet(rationAssistOprObj.sheet, rationAssistOprObj.setting, -1);
+            sheetCommonObj.cleanSheet(rationInstObj.sheet, rationInstObj.setting, -1);
             return;
         }
+        me.workBook.getActiveSheet().setActiveCell(node.serialNo(), 0);
         me.initTools(node);
         me.refreshBtn(node);
         if(!me.isDef(node.children) || node.children.length === 0){

+ 53 - 0
web/building_saas/complementary_ration_lib/js/sheetsOpr.js

@@ -80,6 +80,59 @@ let sheetsOprObj = {
         sheet.resumePaint();
         //me.shieldAllCells(sheet);
     },
+    showDataForGljSel: function(sheet, setting, data, distTypeTree) {
+        var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+        if(typeof setting.owner !== 'undefined' && setting.owner === 'gljComponent'){
+            sheet.setRowCount(data.length + 5);
+        }
+        else{
+            sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
+        }
+        for (var col = 0; col < setting.header.length; col++) {
+            var hAlign = "left", vAlign = "center";
+            if (setting.header[col].hAlign) {
+                hAlign = setting.header[col].hAlign;
+            } else if (setting.header[col].dataType !== "String"){
+                hAlign = "right";
+            }
+            vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
+            me.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
+            if (setting.header[col].formatter) {
+                sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
+            }
+            for (var row = 0; row < data.length; row++) {
+                if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
+                    let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
+                    sheet.setValue(row, col, distTypeVal, ch);
+                }
+                else {
+                    sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
+                    sheet.setTag(row, 0, data[row].ID, ch);
+                }
+                //复选框
+                if(setting.header[col].dataCode === 'isComplementary'){
+                    sheet.setCellType(row, col, checkBoxType);
+                    sheet.getCell(row, col).value(1);
+                }
+                //新增组成物表,选择复选框
+                if(setting.header[col].dataCode === 'select'){
+                    sheet.setCellType(row, col, checkBoxType)
+                    if(data[row].isChecked === true){
+                        sheet.getCell(row, col).value(1);
+                    }
+                }
+            }
+            for(let i = data.length; i < sheet.getRowCount(); i++){
+                sheet.setCellType(i, 6, null);
+            }
+        }
+        sheet.resumeEvent();
+        sheet.resumePaint();
+        //me.shieldAllCells(sheet);
+    },
     combineRowData: function(sheet, setting, row, repositoryGljObj) {
         let me = this;
         var rst = {};

+ 1 - 1
web/building_saas/glj/html/project_glj.html

@@ -21,7 +21,7 @@
                 <li class="mb-2 li_sub"><a href="javascript:void(0)" id="MAIN_MATERIAL">主材</a></li>
                 <li class="mb-2 li_sub"><a href="javascript:void(0)" id="EQUIPMENT">设备</a></li>
                 <li class="mb-2"><a href="javascript:void(0)" id="FBFX">分部分项人材机</a></li>
-                <li class="mb-2"><a href="javascript:void(0)" id="TECH">措施项人材机</a></li>
+                <li class="mb-2"><a href="javascript:void(0)" id="TECH">措施项人材机</a></li>
                 <li class="mb-2"><a href="javascript:void(0)" id="JGCL">甲供材料</a></li>
                 <li class="mb-2"><a href="javascript:void(0)" id="ZGCL">暂估材料</a></li>
                 <li class="mb-2"><a href="javascript:void(0)" id="SCHZ">三材汇总</a></li>

+ 24 - 6
web/building_saas/js/global.js

@@ -3,9 +3,8 @@ function autoFlashHeight(){
     let headerHeight = $(".header").height();
     let toolsbarHeight = $(".toolsbar").height();
     let ftoolsbarHeight = $(".toolsbar-f").height();
-   // var feeRateToolsbarHeight = $(".toolsbar_feeRate").height();
-    let mainBottomContentHeight = $("#main .bottom-content").height();
-    let gljBottomContentHeight = $("#project-glj-main .bottom-content").height();
+    let btntoolsbarHeight = $(".btn-toolbar").height();
+    // var feeRateToolsbarHeight = $(".toolsbar_feeRate").height();
     let toolsBarHeightQ = $(".tools-bar-height-q").height();
     let toolsBarHeightD = $(".tools-bar-height-d").height();
     //$(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-302);
@@ -15,11 +14,12 @@ function autoFlashHeight(){
     $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
     $('#glj_tree_div .modal-content').width($(window).width() < 1020 + 20 ? $(window).width() - 20 : 1020);
     //$("#main .main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
-    $("#billsSpread").height($(window).height()-headerHeight-toolsbarHeight-mainBottomContentHeight-1);
-    $("#project_glj_sheet").height($(window).height()-headerHeight-toolsbarHeight-gljBottomContentHeight-50);
+    typeof(loadMainSize)== 'function' ?loadMainSize():'';//zhang 2018-06-04  统一加载高度方法
+    typeof(loadProjectGljSize)== 'function'?loadProjectGljSize():'';
     $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
     $(".main-data-full-fl").height($(window).height()-headerHeight-toolsbarHeight-37);
     $(".main-data-full-feeRate").height($(window).height()-headerHeight-78);
+    $(".main-data-full-tender").height($(window).height()-headerHeight-btntoolsbarHeight-10);
     $(".main-data-not").height($(window).height()-headerHeight-1);
     $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
     $(".side-content").height($(window).height()-headerHeight );
@@ -29,6 +29,9 @@ function autoFlashHeight(){
     $(".form-list").height($(window).height()-headerHeight-50 );
 
 };
+
+
+
 /*全局自适应高度结束*/
 $(function () {
     $(window).resize(autoFlashHeight);
@@ -106,4 +109,19 @@ function getFormatter(decimal) {
         pre += "0"
     }
     return pre;
-}
+}
+
+function getFeeIndex(fees) {
+    let feesIndex = {};
+    if (fees) {
+        for(let fee of fees){
+            fee.unitFee = parseFloat(fee.unitFee);
+            fee.totalFee = parseFloat(fee.totalFee);
+            fee.tenderUnitFee = parseFloat(fee.tenderUnitFee);
+            fee.tenderTotalFee = parseFloat(fee.tenderTotalFee);
+            feesIndex[fee.fieldName] = fee;
+        }
+    }
+    return feesIndex;
+}
+

File diff suppressed because it is too large
+ 10 - 3
web/building_saas/main/html/main.html


+ 32 - 0
web/building_saas/main/html/tender_price.html

@@ -0,0 +1,32 @@
+<div class="toolsbar px-1">
+    <div class="btn-toolbar py-1">
+
+        <select class="form-control mr-2" style="width: auto; font-size: .875rem" id="calcPriceOption">
+            <option value="coeBase">根据调整系数计算报价</option>
+            <option value="priceBase" >根据报价计算调整系数</option>
+        </select>
+
+        <div class="input-group input-group-sm mr-2" style="width:240px">
+            <div class="input-group-prepend">
+                <span class="input-group-text" id="inputGroup-sizing-sm">工料机单价调整系数</span>
+            </div>
+            <input id = 'gljPriceTenderCoe' type="number" step="0.1" class="form-control" placeholder="请输入系数" value="1">
+        </div>
+        <div class="btn-group mr-2">
+            <button type="button" class="btn btn-outline-primary btn-sm" id = "tenderGLJQuantity">调整人材机消耗</button>
+            <button type="button" class="btn btn-outline-primary btn-sm" id = "tenderRationQuantity">调整子目工程量</button>
+           <!-- <button type="button" class="btn btn-outline-primary btn-sm">反调单价</button>-->
+            <button type="button" class="btn btn-outline-primary btn-sm" id = "tenderPrice">调价计算</button>
+        </div>
+        <button type="button" class="btn btn-outline-danger btn-sm" id = "cleanTender">清空调价</button>
+    </div>
+</div>
+<div class="container-fluid">
+    <div class="row">
+        <div class="col-lg-12 p-0">
+            <div class="main-data-full-tender" id="tenderSpread">
+            </div>
+        </div>
+    </div>
+</div>
+

+ 25 - 23
web/building_saas/main/js/controllers/block_controller.js

@@ -24,7 +24,13 @@ let BlockController = {
         if(blockData.firstNodeType != blockType.RATION && blockData.isFBFX !=  Bills.isFBFX(selected)){//除了复制定额外,焦点行和复制的块不是来自同一个地方(分部分项工其它)
             return true;
         }
-        if(selected.sourceType == Bills.getSourceType() && selected.data.type == billType.FX && blockData.firstNodeType == blockType.FB){//焦点行是分项,复制块的第一层是分部,则无效。
+        if(this.blockIsFXorBX(blockData.firstNodeType) && this.isFB(selected)){//复制块的第一层是分项或补项,焦点行是分部,且分部有子项并且子项不是分项或补项,则无效。
+            if(selected.children.length && !this.isFXorBX(selected.children[0])){
+                return true;
+            }
+        }
+
+        if(this.isFXorBX(selected) && blockData.firstNodeType == blockType.FB){//焦点行是分项或补项,复制块的第一层是分部,则无效。
             return true;
         }
         if(blockData.firstNodeType == blockType.RATION && selected.sourceType == Bills.getSourceType()){ //复制的是定额/量价/工料机、焦点行是分部/清单父项则无效
@@ -142,7 +148,7 @@ let BlockController = {
             if(selected.sourceType == ModuleNames.ration && selected.data.type != rationType.install ){//焦点行是定额/量价/工料机,则粘贴为后项
                 return "next";
             }
-            if(isFXorBX(selected)||(selected.sourceType === Bills.getSourceType()&& selected.source.children.length == 0)){//焦点行是分项/叶子清单,且无基数计算,则粘贴到分项/叶子清单下
+            if(this.isFXorBX(selected)||(selected.sourceType === Bills.getSourceType()&& selected.source.children.length == 0)){//焦点行是分项/叶子清单,且无基数计算,则粘贴到分项/叶子清单下
                 if(!this.haveCalcBase(selected)){//无基数计算
                     return "sub";
                 }
@@ -154,8 +160,8 @@ let BlockController = {
         setRadioProp('pre_node',{checked:false,disabled:false});
         if(Bills.isFBFX(selected)){//  (2.1)、焦点行属于“分部分项工程”:
             //复制块的第一层、焦点行的类型都是“分部”
-            if(blockData.firstNodeType == blockType.FB && isFB(selected)){
-                if(selected.children.length > 0 && isFXorBX(selected.children[0])){//焦点行分部下有分项补项,弹出“粘贴位置选择”,默认为当前行的后项,可选前项,子项灰显。
+            if(blockData.firstNodeType == blockType.FB && this.isFB(selected)){
+                if(selected.children.length > 0 && this.isFXorBX(selected.children[0])){//焦点行分部下有分项补项,弹出“粘贴位置选择”,默认为当前行的后项,可选前项,子项灰显。
                     setRadioProp('sub_node',{checked:false,disabled:true});
                 }else {
                     //默认为当前行的后项,可选前项、子项。
@@ -163,13 +169,13 @@ let BlockController = {
                 }
             }
             //复制块的第一层、焦点行的类型都是“分项”或补项
-            if(blockIsFXorBX(blockData.firstNodeType) && isFXorBX(selected)){
+            if(this.blockIsFXorBX(blockData.firstNodeType) && this.isFXorBX(selected)){
                 //默认为当前行的后项,可选前项,子项灰显不可选。
                 setRadioProp('sub_node',{checked:false,disabled:true});
             }
             //复制块的第一层是分项,焦点行是分部,且分部下无子项或者子项是分项
-            if(blockIsFXorBX(blockData.firstNodeType)&& isFB(selected)){
-                if(selected.children.length == 0 || isFXorBX(selected.children[0])){
+            if(this.blockIsFXorBX(blockData.firstNodeType)&& this.isFB(selected)){
+                if(selected.children.length == 0 || this.isFXorBX(selected.children[0])){
                     return 'sub';//不弹出选择窗口,直接粘贴为子项。
                 }
             }
@@ -193,21 +199,6 @@ let BlockController = {
            $("#"+id).prop("checked",options.checked);
            $("#"+id).prop("disabled",options.disabled);
        }
-
-       function isFB(selected) {
-           return selected.sourceType == Bills.getSourceType() && selected.data.type == billType.FB;
-       }
-
-       function isFXorBX(selected) {//是分项或者补项
-            if(selected.sourceType == Bills.getSourceType()){
-                return   selected.data.type == billType.FX || selected.data.type == billType.BX;
-            }
-            return false;
-       }
-       function blockIsFXorBX(type) {
-           return type == blockType.FX||type == blockType.BX;
-       }
-
     },
     /**
      * @param blockData
@@ -601,7 +592,18 @@ let BlockController = {
         }
         return matchs;
     },
-
+    isFB :function (selected) {
+        return selected.sourceType == projectObj.project.Bills.getSourceType() && selected.data.type == billType.FB;
+    },
+    isFXorBX:function (selected) {//是分项或者补项
+        if(selected.sourceType == projectObj.project.Bills.getSourceType()){
+            return   selected.data.type == billType.FX || selected.data.type == billType.BX;
+        }
+        return false;
+    },
+    blockIsFXorBX: function (type) {
+        return type == blockType.FX||type == blockType.BX;
+    },
     removeBlock:function () {
         removeLocalCache('project_block');
     }

+ 54 - 32
web/building_saas/main/js/main.js

@@ -3,20 +3,7 @@
  */
 
 $(function () {
-    // 读取本地存储的高度(必须放在载入spread之前)
-    let mainResizeEles = {};
-    mainResizeEles.id = '#main';
-    mainResizeEles.resize = $('#main').find('.resize');
-    mainResizeEles.nearElement = $('#main').find('.top-content');
-    mainResizeEles.nearSpread = mainResizeEles.nearElement.children(".main-data-top");
-    mainResizeEles.farElement = $('#main').find('.bottom-content');
-    mainResizeEles.farSpread = mainResizeEles.farElement.children().find(".main-data-bottom");
-    mainResizeEles.nav = mainResizeEles.farElement.children('ul.nav');
-    loadSize(mainResizeEles, 'height', function() {
-        refreshSubSpread();
-        zmhs_obj.refresh();
-    });
-
+    loadMainSize();
     $("#header-menu").removeAttr('style');
     projectInfoObj.showProjectInfo();
     projectObj.checkMainSpread();
@@ -41,7 +28,7 @@ $(function () {
         sessionStorage.setItem('mainTab', '#tab_report');
     });
 
-    slideResize(mainResizeEles, {min: 170, max: 700}, 'height', function() {
+    slideResize(getMainResizeEles(), {min: 170, max: 700}, 'height', function() {
         projectObj.mainSpread.refresh();
         refreshSubSpread();
         zmhs_obj.refresh();
@@ -57,6 +44,28 @@ $(function () {
     });*/
 });
 
+function getMainResizeEles() {
+    // 读取本地存储的高度(必须放在载入spread之前)
+    let mainResizeEles = {};
+    mainResizeEles.id = '#main';
+    mainResizeEles.resize = $('#main').find('.resize');
+    mainResizeEles.nearElement = $('#main').find('.top-content');
+    mainResizeEles.nearSpread = mainResizeEles.nearElement.children(".main-data-top");
+    mainResizeEles.farElement = $('#main').find('.bottom-content');
+    mainResizeEles.farSpread = mainResizeEles.farElement.children().find(".main-data-bottom");
+    mainResizeEles.nav = mainResizeEles.farElement.children('ul.nav');
+    return mainResizeEles;
+}
+
+function loadMainSize() {//加载造价书页面各高度
+    // 读取本地存储的高度(必须放在载入spread之前)
+    let mainResizeEles = getMainResizeEles() ;
+    loadSize(mainResizeEles, 'height', function() {
+        refreshSubSpread();
+        zmhs_obj.refresh();
+    });
+}
+
 /**
  * 拖动更改div大小
  *
@@ -163,13 +172,7 @@ function loadSize(eles, type, callback) {
        /* eles.nearSpread[type](o_nearSize);
         eles.farSpread[type](o_farSize);*/
     }else {
-        nearSize = parseFloat(nearSize);
-        farSize = parseFloat(farSize);
-        if(type !== 'width') {
-            const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
-            eles.nearSpread[type](nearSize);
-            eles.farSpread[type](farSize - navSize);
-        }
+        setSizeWithPercent(tag,eles,nearSize,farSize,type)//zhang 2018-06-04 改成按百分比设置
     }
     if(type === 'width'){//使用百分比
         let rePercent = getResizeWidthPercent(nearSize ? nearSize : o_nearSize, farSize ? farSize : o_farSize);
@@ -186,17 +189,36 @@ function getResizeWidthPercent(nearSize, farSize){
     return {nearPercent, farPercent};
 }
 
+
+function setSizeWithPercent(tag,eles,nearSize,farSize,type) {
+    nearSize = parseFloat(nearSize);
+    farSize = parseFloat(farSize);
+    if(type !== 'width') {
+        let headerHeight = $(".header").height();
+        let toolsbarHeight = $(".toolsbar").height();
+        let exand = tag == "#main" ? 1:50;
+        let totalHeight = $(window).height() - headerHeight - toolsbarHeight-exand;
+        const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
+        totalHeight = totalHeight - navSize;
+        nearSize = (nearSize/(nearSize + farSize))* totalHeight;
+        eles.nearSpread[type](nearSize);
+        eles.farSpread[type](totalHeight - nearSize);
+    }
+}
+
 function setDefaultSize(tag,eles,type) {
-    let o_nearSize = eles.nearSpread[type]();
-    let o_farSize = eles.farSpread[type]();
-    if(tag == "#main"){
-        eles.nearSpread[type](o_nearSize);  //工料机汇总和main页面处理方式不同
-        eles.farSpread[type](o_farSize);
-    }else if(tag == "#project-glj-main"){
-        o_nearSize = parseFloat(o_nearSize);
-        o_farSize = parseFloat(o_farSize);
-        eles.nearSpread[type](o_nearSize - o_farSize + 30);
-        eles.farSpread[type](o_farSize);
+    let o_nearSize = 5;
+    let o_farSize = 2;
+    if(type == 'height'){
+        let headerHeight = $(".header").height();
+        let toolsbarHeight = $(".toolsbar").height();
+        let exand = tag == "#main" ? 1:50;
+        let totalHeight = $(window).height() - headerHeight - toolsbarHeight-exand;
+        const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
+        totalHeight = totalHeight - navSize;
+        let nearSize = (o_nearSize/(o_nearSize + o_farSize))* totalHeight;
+        eles.nearSpread[type](nearSize);
+        eles.farSpread[type](totalHeight - nearSize);
     }
 }
 

+ 14 - 12
web/building_saas/main/js/models/bills.js

@@ -92,16 +92,7 @@ var Bills = {
                 if (data.quantity) {
                     data.quantity = parseFloat(data.quantity);
                 }
-                data.feesIndex = {};
-                if (data.fees) {
-                    data.fees.forEach(function (fee) {
-                        fee.unitFee = parseFloat(fee.unitFee);
-                        fee.totalFee = parseFloat(fee.totalFee);
-                        fee.tenderUnitFee = parseFloat(fee.tenderUnitFee);
-                        fee.tenderTotalFee = parseFloat(fee.tenderTotalFee);
-                        data.feesIndex[fee.fieldName] = fee;
-                    });
-                }
+                data.feesIndex = getFeeIndex(data.fees);
                 data.flagsIndex = {};
                 if (data.flags) {
                     data.flags.forEach(function (flag) {
@@ -321,9 +312,9 @@ var Bills = {
                             updateNode[n_key].data[u_key] =updateDoc[u_key];
                         }
                     }
-                    project.calcProgram.calcAndSave(newParent);
                     controller.singleDelete();//删除树节点
                     me.tree.singleDelete(node.source);
+                    project.calcProgram.calcAndSave(newParent);
                     $.bootstrapLoading.end();
                 }, function () {
                     $.bootstrapLoading.end();
@@ -515,6 +506,17 @@ var Bills = {
                 return false;
             }
         };
+        bills.prototype.isMeasure = function (node) {//判读是否属于措施项目部分
+            let rootNode = this.getRootNode(node);
+            if(isFlag(rootNode.data)&&rootNode.data.flagsIndex.fixed.flag==fixedFlag.MEASURE){
+                return true;
+            }else {
+                return false;
+            }
+        };
+        bills.prototype.hasFlags = function (node) {
+            return isFlag(node.data);
+        };
         bills.prototype.isBX = function (node) {//判读是否属于补项
             if(node && node.sourceType == ModuleNames.bills&&node.data.type==billType.BX){
                 return  true;
@@ -834,7 +836,7 @@ function isDef(v) {
 }
 
 function isFlag(v) {
-    return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
+    return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed) && this.isDef(v.flagsIndex.fixed.flag);
 }
 
 function getRootFixedNode(node) {

+ 44 - 14
web/building_saas/main/js/models/calc_program.js

@@ -212,6 +212,17 @@ let calcTools = {
             treeNode.changed = true;
         };
     },
+    setFieldValue: function (treeNode, fieldName, value){
+        if (fieldName.includes('feesIndex')){
+            let arr = fieldName.split('.');
+            this.initFeeField(treeNode, arr[1]);
+            treeNode.data.feesIndex[arr[1]][arr[2]] = value;
+        }
+        else{
+            treeNode.data[fieldName] = value;
+        };
+        treeNode.changed = true;
+    },
     initSummaryFee: function (treeNode){
         if (!treeNode.data.summaryFees){
             treeNode.data.summaryFees = {
@@ -408,8 +419,10 @@ let calcTools = {
             sumU = undefined;
         }
         else if (me.isLeafBill(treeNode)){
-            if (isGather)
-                sumT = eTFee()
+            if (isGather){
+                me.getGLJList(treeNode, false);
+                sumT = eTFee();
+            }
             else
                 sumT = eTFeeByChildren();
 
@@ -417,6 +430,8 @@ let calcTools = {
             sumU = (sumT / q).toDecimal(decimalObj.bills.totalPrice);
         }
         else if (me.isRationCategory(treeNode)){
+            me.getGLJList(treeNode, false);
+
             sumU = eUFee();
             if (isBase) return sumU;
 
@@ -600,7 +615,8 @@ let calcTools = {
             feeRateID: treeNode.data.feeRateID,
             contain: treeNode.data.contain,
             quantityEXP: treeNode.data.quantityEXP,
-            summaryFees: treeNode.data.summaryFees
+            summaryFees: treeNode.data.summaryFees,
+            name:treeNode.data.name
         };
 
         // 定额大类
@@ -1375,7 +1391,7 @@ class CalcProgram {
     };
 
     // 只计算treeNode自身。changedArr: 外部传来的一个数组,专门存储发生变动的节点。
-    innerCalc(treeNode, changedArr){
+    innerCalc(treeNode, changedArr, isTender = false){
         let me = this;
         // 仅用作树节点显示的工料机不能参与计算。
         if (treeNode.sourceType === ModuleNames.ration_glj) return;
@@ -1505,13 +1521,27 @@ class CalcProgram {
             if (treeNode.data.programID) {
                 treeNode.data.programID = null;
                 treeNode.changed = true;
-            }
+            };
 
-            if (treeNode.data.fees && treeNode.data.fees.length > 0){
-                treeNode.data.fees = null;
-                treeNode.data.feesIndex = null;
-                treeNode.changed = true;
+            // 第1、2部分以外的叶子清单在没有公式的情况下可以手工修改综合单价并参与计算。
+            if(!calcTools.isInheritFrom(treeNode, [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE])){
+                if (treeNode.data.feesIndex && treeNode.data.feesIndex.common){
+                    let ftObj = {};
+                    ftObj.fieldName = 'common';
+                    ftObj.unitFee = parseFloatPlus(treeNode.data.feesIndex.common.unitFee);
+                    let q = parseFloatPlus(treeNode.data.quantity);
+                    ftObj.totalFee = (ftObj.unitFee * q).toDecimal(decimalObj.bills.totalPrice);
+                    calcTools.checkFeeField(treeNode, ftObj);
+                }
             }
+            else{
+                if (treeNode.data.fees && treeNode.data.fees.length > 0){
+                    treeNode.data.fees = null;
+                    treeNode.data.feesIndex = null;
+                    treeNode.changed = true;
+                }
+            };
+
             treeNode.data.calcTemplate = {"calcItems": []};
         }
         // 叶子清单公式计算
@@ -1597,10 +1627,8 @@ class CalcProgram {
             };
         };
 
-        if (!calcTools.isTotalCostBill(treeNode)){   // 已在上面的分支中计算过
-            calcTools.getGLJList(treeNode, false);
+        if (!calcTools.isTotalCostBill(treeNode))  // 已在上面的分支中计算过
             calcTools.estimateFee(treeNode);
-        }
 
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);
     };
@@ -1643,8 +1671,10 @@ class CalcProgram {
                     calcNodes(node.children);
                 };
 
-                if ((calcType == calcAllType.catAll || calcType == node.sourceType) && node.calcType != treeNodeCalcType.ctCalcBaseValue) {
-                    me.innerCalc(node, changedNodes);
+                if (calcType == calcAllType.catAll || calcType == node.sourceType) {
+                    node.calcType = calcTools.getCalcType(node);
+                    if (node.calcType != treeNodeCalcType.ctCalcBaseValue)
+                        me.innerCalc(node, changedNodes);
                 };
             }
         };

+ 1 - 14
web/building_saas/main/js/models/main_consts.js

@@ -2,6 +2,7 @@
  * Created by jimiz on 2017/4/19.
  */
 const ModuleNames = {
+    project:'project',
     bills: 'bills',
     ration: 'ration',
     GLJ: 'GLJ',
@@ -366,20 +367,6 @@ const filterType = {
     ZYCL:'11'
 };
 const filterTypeArray = ['1','2','3','4','5'];
-/*
-<li><a href="javascript:void(0)">所有工料机</a></li>
-    <li class="mb-2 li_sub"><a href="javascript:void(0)" id="labor">人工</a></li>
-    <li class="mb-2 li_sub"><a href="javascript:void(0)">材料</a></li>
-    <li class="mb-2 li_sub"><a href="javascript:void(0)">机械</a></li>
-    <li class="mb-2 li_sub"><a href="javascript:void(0)">主材</a></li>
-    <li class="mb-2 li_sub"><a href="javascript:void(0)">设备</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">分部分项工料机</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">措施分项工料机</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">甲供材料</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">暂估材料</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">三材汇总</a></li>
-    <li class="mb-2"><a href="javascript:void(0)">主要材料</a></li>
-*/
 
 const installFeeType = ['子目费用','分项费用','措施费用'];
 const installSectionBase = ['分别按人材机乘系数','人工','材料','机械'];

+ 29 - 168
web/building_saas/main/js/models/project_glj.js

@@ -201,6 +201,7 @@ ProjectGLJ.prototype.updateGLJProperty = function (node, updateField, newval) {
     let rationTypeGLJ = node.data;
     let postData = {};
     if (rationTypeGLJ[updateField] == newval) {
+        projectObj.mainController.refreshTreeNode([node]);
         return;
     }
     let data = {
@@ -507,7 +508,7 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     let nodes = [];
     let rationMap = {};
     let idArray = _.map(gljs,'id');
-    let priceArray = _.map(gljs,'unit_price');
+    let gljMap = _.indexBy(gljs,'id');
     //先根据项目工料机ID,找到受影响定额的ID
     let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
     for (let rg of ration_glj_list) {
@@ -518,9 +519,9 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
     for (let item of projectObj.project.mainTree.items) {
         if (item.sourceType == ModuleNames.ration) {
             if (item.data.type == rationType.gljRation) {//取定额类型的工料机
-                let idx = _.indexOf(idArray,item.data.projectGLJID);
-                if (idx != -1) {
-                    item.data.marketUnitFee = priceArray[idx].market_price; //更新市场单价
+                let tem_g = gljMap[item.data.projectGLJID];
+                if(tem_g){
+                    item.data.marketUnitFee = this.getMarketPrice(tem_g);//这里要按计算的市场价为准,不能直接取
                     nodes.push(item);
                 }
             } else if (rationMap[item.data.ID] == true) {  //受影响的定额
@@ -593,92 +594,29 @@ ProjectGLJ.prototype.setAdjustPrice = function (glj) {
 }
 
 ProjectGLJ.prototype.getAdjustPrice = function (glj,isRadio) {
-    GLJTypeConst = this.datas.constData.GLJTypeConst !== undefined ? JSON.parse(this.datas.constData.GLJTypeConst) : GLJTypeConst;
-    let decimal = getDecimal("glj.unitPrice");
-    let quantity_decimal = getDecimal("glj.quantity");
-    let process_decimal = getDecimal("process");
-    let  tem_decimal = isRadio==true?process_decimal:decimal;
-    if (glj.unit_price.type == GLJTypeConst.LABOUR || glj.unit_price.type == GLJTypeConst.MACHINE_LABOUR) {//人工、机上人工,调整价根据定额价*调整系数计算得出。
-        let labour = projectObj.project.calcProgram.compiledLabourCoes[glj.adjCoe];
-        //let labour=1;
-        let coe = labour && labour.coe ? labour.coe : 1;
-        return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal)), -tem_decimal);
-    } else if (notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
-        let p =0;
-        for(let ratio of glj.ratio_data){
-           let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{
-               'code': ratio.code,
-               'name': ratio.name,
-               'specs':ratio.specs,
-               'type': ratio.type,
-               'unit': ratio.unit
-           })
-            if(tem){
-                let priceData={};
-                gljOprObj.setGLJPrice(priceData,tem,true);
-                p+=scMathUtil.roundForObj(priceData.adjustPrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
-            }
-        }
-        return scMathUtil.roundForObj(p,decimal);
-    } else {//对于其他普通材料等,无调整系数,调整价=定额价。
-        return glj.unit_price.base_price
-    }
+    let proGLJ =  projectObj.project.projectGLJ;
+    let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
+    let decimalObj = projectInfoObj.projectInfo.property.decimal;
+    let labourCoeDatas =  projectObj.project.labourCoe.datas;
+    return gljUtil.getAdjustPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
 };
 
 ProjectGLJ.prototype.getBasePrice = function(glj,isRadio){
-    let price_decimal = getDecimal("glj.unitPrice");
-    let quantity_decimal = getDecimal("glj.quantity");
-    let process_decimal = getDecimal("process");
-    if (notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
-        let p =0;
-        for(let ratio of glj.ratio_data){
-            let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{
-                'code': ratio.code,
-                'name': ratio.name,
-                'specs':ratio.specs,
-                'type': ratio.type,
-                'unit': ratio.unit
-            });
-            if(tem){
-                let priceData={};
-                gljOprObj.setGLJPrice(priceData,tem,true);
-                p+=scMathUtil.roundForObj(priceData.basePrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
-            }
-        }
-        return scMathUtil.roundForObj(p,price_decimal);
-    }else {
-        let tem_decimal = isRadio==true?process_decimal:price_decimal;
-        return scMathUtil.roundForObj(glj.unit_price.base_price,tem_decimal);
-    }
+    let proGLJ =  projectObj.project.projectGLJ;
+    let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
+    let decimalObj = projectInfoObj.projectInfo.property.decimal;
+    let labourCoeDatas =  projectObj.project.labourCoe.datas;
+    return gljUtil.getBasePrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
 };
 
 
 ProjectGLJ.prototype.getMarketPrice = function (glj,isRadio) {
-    let price_decimal = getDecimal("glj.unitPrice");
-    let quantity_decimal = getDecimal("glj.quantity");
-    let process_decimal = getDecimal("process");
-    if (notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班等有组成物的材料,价格需根据组成物计算得出。
-        let p =0;
-        for(let ratio of glj.ratio_data){
-            let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{
-                'code': ratio.code,
-                'name': ratio.name,
-                'specs':ratio.specs,
-                'type': ratio.type,
-                'unit': ratio.unit
-            });
-            if(tem){
-                let priceData={};
-                gljOprObj.setGLJPrice(priceData,tem,true);
-                p+=scMathUtil.roundForObj(priceData.marketPrice*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),process_decimal);
-            }
-        }
-        return scMathUtil.roundForObj(p,price_decimal);
-    }else {
-        let tem_decimal = isRadio==true?process_decimal:price_decimal;
-        return scMathUtil.roundForObj(glj.unit_price.market_price,tem_decimal);
-    }
-}
+    let proGLJ =  projectObj.project.projectGLJ;
+    let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
+    let decimalObj = projectInfoObj.projectInfo.property.decimal;
+    let labourCoeDatas =  projectObj.project.labourCoe.datas;
+    return gljUtil.getMarketPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+};
 
 ProjectGLJ.prototype.isEstimateType = function(type){
     let typeString = type + "";
@@ -695,42 +633,13 @@ ProjectGLJ.prototype.getShortNameByID = function (ID) {
 
 ProjectGLJ.prototype.calcQuantity  = function (init=false){
     let project_gljs = this.datas.gljList;
-    let mixRatioConnectData = this.datas.mixRatioConnectData;
-    let mixRatioMap = this.datas.mixRatioMap;
-    let rations = projectObj.project.Ration.datas;
-    let rationMap = _.indexBy(rations,'ID');
-    let quantityMap={},changeArray=[];
-    let rationGljGroup = _.groupBy(projectObj.project.ration_glj.datas,'projectGLJID')
-    let q_decimal = getDecimal("glj.quantity");
-    for(let pglj of project_gljs ){
-        let pg_index = gljOprObj.getIndex(pglj,gljKeyArray);
-        pglj.subdivisionQuantity = 0;
-        pglj.techQuantity = 0;
-        pglj.quantity = 0;
-        let gljGroup = rationGljGroup[pglj.id]?rationGljGroup[pglj.id]:[];//定额工料机没有,有可能是定额类型的工料机
-        let result = this.getQuantityPerGLJ(gljGroup,rations,rationMap,pglj,quantityMap);
-        pglj.subdivisionQuantity = result.subdivisionQuantity;
-        pglj.techQuantity = result.techQuantity;
-        pglj.quantity = result.quantity;
-        quantityMap[pg_index] = pglj;
-    }
-    //计算做为组成物的消耗量
-    for(let pkey in mixRatioMap){
-        let mixRatioList = mixRatioMap[pkey];
-        for(let m of mixRatioList){
-            let m_index = gljOprObj.getIndex(m,gljKeyArray);
-            let m_glj = quantityMap[m_index];
-            let p_glj = quantityMap[pkey];
-            if(m_glj&&p_glj){
-                let quantity = scMathUtil.roundForObj(p_glj.quantity*parseFloat(m.consumption),q_decimal);
-                let techQuantity = scMathUtil.roundForObj(p_glj.techQuantity*parseFloat(m.consumption),q_decimal);
-                let subdivisionQuantity = scMathUtil.roundForObj(p_glj.subdivisionQuantity*parseFloat(m.consumption),q_decimal);
-                m_glj.quantity =  scMathUtil.roundForObj(m_glj.quantity+quantity,q_decimal);
-                m_glj.techQuantity =  scMathUtil.roundForObj(m_glj.techQuantity+techQuantity,q_decimal);
-                m_glj.subdivisionQuantity =  scMathUtil.roundForObj(m_glj.subdivisionQuantity+subdivisionQuantity,q_decimal);
-            }
-        }
-    }
+    let changeArray=[];
+    let rationGLJDatas = projectObj.project.ration_glj.datas;
+    let rationDatas = projectObj.project.Ration.datas;
+    let billsDatas = projectObj.project.Bills.datas;
+
+    gljUtil.calcProjectGLJQuantity(this.datas,rationGLJDatas,rationDatas,billsDatas,getDecimal("glj.quantity"),_,scMathUtil);
+
     if(init == true || this.quantityChangeMap == null){//如果是初始化,建立一个映射表
         this.quantityChangeMap = {};
         for(let pglj of project_gljs){
@@ -750,52 +659,4 @@ ProjectGLJ.prototype.calcQuantity  = function (init=false){
         }
     }
     changeArray.length > 0 && projectGljObject.calcPartASupplyFeeByProjectGLJs ?projectGljObject.calcPartASupplyFeeByProjectGLJs(changeArray):'';
-
-
-
-};
-
-ProjectGLJ.prototype.getQuantityPerGLJ = function (ration_glj_list,rations,rationMap,pglj) {
-    let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
-    let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单IDs
-    let mixRatioMap = this.datas.mixRatioMap;
-    let q_decimal = getDecimal("glj.quantity");
-    let result={};
-    let quantity_sum=0;//工料机汇总消耗量
-    let sum = 0;//分部分项总消耗量
-    let tech_sum = 0;//技术措施总消耗量
-    for(let rg of ration_glj_list){
-            let tem_ration = rationMap[rg.rationID];
-            let r_quantity = tem_ration?scMathUtil.roundForObj(tem_ration.quantity,q_decimal):0;
-            let glj_quantity = scMathUtil.roundForObj(rg.quantity, q_decimal);
-            if(!r_quantity){
-                continue;
-            }
-            let total = scMathUtil.roundForObj(glj_quantity*r_quantity, q_decimal);
-            quantity_sum = scMathUtil.roundForObj(quantity_sum+total,q_decimal);
-            if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
-                sum = scMathUtil.roundForObj(sum+total,q_decimal);
-            }
-            if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
-                tech_sum = scMathUtil.roundForObj(tech_sum+total,q_decimal);
-            }
-    }
-    for(let ra of rations){//计算定额类型工料机的消耗量
-        if(ra.type == rationType.gljRation&&ra.projectGLJID===pglj.id){
-            let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
-            r_quantity = r_quantity?r_quantity:0;
-            quantity_sum = scMathUtil.roundForObj(quantity_sum+r_quantity,q_decimal);
-            if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
-                sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
-            }
-            if(_.includes(tech_billIDS,ra.billsItemID)){//计算技术措施项目消耗量
-                tech_sum = scMathUtil.roundForObj(tech_sum+r_quantity,q_decimal);
-            }
-        }
-
-    }
-    result.subdivisionQuantity = sum;
-    result.techQuantity = tech_sum;
-    result.quantity = quantity_sum;
-    return result;
-} 
+};

+ 1 - 4
web/building_saas/main/js/models/ration.js

@@ -53,10 +53,7 @@ var Ration = {
             this.datas = datas;
             // generate Fees & Flags Index,For View & Calculate
             this.datas.forEach(function (data) {
-                data.feesIndex = {};
-                data.fees.forEach(function (fee) {
-                    data.feesIndex[fee.fieldName] = fee;
-                });
+                data.feesIndex = getFeeIndex(data.fees);
                 data.flagsIndex = {};
                 data.flags.forEach(function (flag) {
                     data.flagsIndex[flag.fieldName] = flag;

+ 36 - 30
web/building_saas/main/js/models/ration_glj.js

@@ -45,11 +45,16 @@ var ration_glj = {
                 let glj = JSON.parse(JSON.stringify(ration));
                 glj.type = glj.subType;
                 glj.quantity = 1;
+                glj.totalQuantity = parseFloatPlus(ration.quantity);
                 return [glj];
             }
             else{
                 let result = this.datas.filter(function (data) {
-                    return data.rationID === ration.ID;
+                    if(data.rationID === ration.ID){
+                        gljOprObj.getTotalQuantity(data, ration);
+                        return true;
+                    }
+                    return false;
                 })
                 result = gljOprObj.combineWithProjectGlj(result);
                 return result;
@@ -77,7 +82,10 @@ var ration_glj = {
             }
             for (let ration of rations) {
                 if (ration.type == rationType.volumePrice || ration.type == rationType.gljRation){
-                    result.push(ration);
+                    let glj = JSON.parse(JSON.stringify(ration));
+                    glj.type = glj.subType;
+                    glj.totalQuantity = parseFloatPlus(ration.quantity);
+                    result.push(glj);
                 }
                 else{
                     let rationGljs = this.getGljArrByRation(ration);
@@ -428,12 +436,11 @@ var ration_glj = {
                         }
                     }
                 }
-                me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
-
                 if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了
                     gljOprObj.showRationGLJSheetData();
                 }
                 projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
+                    me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
                     me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
                     if (initShow == true) {
                         gljOprObj.refreshView();
@@ -751,36 +758,35 @@ var ration_glj = {
             return ration;
         };
         ration_glj.prototype.updateFromMainSpread = function (value, node, fieldName) {
-            if (node.data[fieldName] === value) {
-                return;
-            }
-            if (fieldName == "marketUnitFee") {
-                var decimal = getDecimal("glj.unitPrice");
-                var newval = number_util.checkNumberValue(value, decimal);
-                if (newval) {
-                    fieldName = "marketPrice";
-                    projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval);
-                    return;
+            if (node.data[fieldName] !== value) {
+                if (fieldName == "marketUnitFee") {
+                    var decimal = getDecimal("glj.unitPrice");
+                    var newval = number_util.checkNumberValue(value, decimal);
+                    if (newval) {
+                        fieldName = "marketPrice";
+                        projectObj.project.projectGLJ.updatePriceFromRG(node.data, fieldName, newval);
+                        return;
 
-                }
-            } else {
-                if(fieldName == "contain"){
-                    if(value==null){
-                        value="";
-                    }else {
-                        var decimal = getDecimal("glj.quantity");
-                        value = number_util.checkNumberValue(value, decimal);
-                        fieldName="customQuantity";//填入自定义消耗
                     }
-                }
+                } else {
+                    if(fieldName == "contain"){
+                        if(value==null){
+                            value="";
+                        }else {
+                            var decimal = getDecimal("glj.quantity");
+                            value = number_util.checkNumberValue(value, decimal);
+                            fieldName="customQuantity";//填入自定义消耗
+                        }
+                    }
 
-                if (value !== undefined && value !== null) {
-                    if (fieldName == "subType") {
-                        node.data.subType = value;
-                        fieldName = "type";//转换成更新工料机类型
+                    if (value !== undefined && value !== null) {
+                        if (fieldName == "subType") {
+                            node.data.subType = value;
+                            fieldName = "type";//转换成更新工料机类型
+                        }
+                        this.updateRationGLJByEdit(node.data, fieldName, value, node);
+                        return;
                     }
-                    this.updateRationGLJByEdit(node.data, fieldName, value, node);
-                    return;
                 }
             }
             // node.data.subType = value;

+ 21 - 8
web/building_saas/main/js/views/character_content_view.js

@@ -731,8 +731,12 @@ let characterOprObj = {
         }
     },
     initSelection: function (row) {
+        console.log('enter');
         let me = characterOprObj;
         let disObj = {itemAdd: false, itemInsert: true, itemDel: true, itemUp: true, itemDown: true};
+        if(projectObj.project.mainTree.selected.sourceType !== projectObj.project.Bills.getSourceType()){
+            disObj.itemAdd = true;
+        }
         //清单锁定,不可用
         if(projectInfoObj.projectInfo.property.lockBills){
             disObj.itemAdd = true;
@@ -894,14 +898,20 @@ let pageCCOprObj = {
     },
     //设置特征及内容currentCache
     setCacheAndShow: function (node) {
-        let theCont = contentOprObj, theCha = characterOprObj;
-        node.data.jobContent = node && typeof node.data.jobContent !== 'undefined' ? node.data.jobContent : [];
-        node.data.itemCharacter = node && typeof node.data.itemCharacter !== 'undefined' ? node.data.itemCharacter : [];
-        theCont.currentCache =  node.data.jobContent;
-        theCha.currentCache = node.data.itemCharacter;
-        this.currentFindSet = node && typeof node.data.ID !== 'undefined' && typeof node.data.projectID ? {ID: node.data.ID, projectID: node.data.projectID} : null;
-        this.showData(theCont.workBook.getSheet(0), theCont.setting, theCont.currentCache);
-        this.showData(theCha.workBook.getSheet(0), theCha.setting, theCha.currentCache);
+        if(node && node.sourceType === projectObj.project.Bills.getSourceType()){
+            let theCont = contentOprObj, theCha = characterOprObj;
+            node.data.jobContent = node && typeof node.data.jobContent !== 'undefined' ? node.data.jobContent : [];
+            node.data.itemCharacter = node && typeof node.data.itemCharacter !== 'undefined' ? node.data.itemCharacter : [];
+            theCont.currentCache =  node.data.jobContent;
+            theCha.currentCache = node.data.itemCharacter;
+            this.currentFindSet = node && typeof node.data.ID !== 'undefined' && typeof node.data.projectID ? {ID: node.data.ID, projectID: node.data.projectID} : null;
+            this.showData(theCont.workBook.getSheet(0), theCont.setting, theCont.currentCache);
+            this.showData(theCha.workBook.getSheet(0), theCha.setting, theCha.currentCache);
+        }
+        else{
+            this.clearData();
+
+        }
     },
     //contentSpread、itemSpread展示数据用
     showData: function(sheet, setting, data) {
@@ -950,9 +960,12 @@ let pageCCOprObj = {
     clearData: function () {
         let theCon = contentOprObj, theCha = characterOprObj;
         theCon.workBook.getSheet(0).setRowCount(0);
+        theCon.refreshTools({jobAdd: true, jobInsert: true, jobDel: true, jobUp: true, jobDown: true});
         theCha.workBook.getSheet(0).setRowCount(0);
+        theCha.refreshTools({itemAdd: true, itemInsert: true, itemDel: true, itemUp: true, itemDown: true});
         sheetCommonObj.cleanSheet(theCon.workBook.getSheet(0), theCon.setting, -1);
         sheetCommonObj.cleanSheet(theCha.workBook.getSheet(0), theCha.setting, -1);
+
         projectObj.mainSpread.focus(true);
     },
     //锁定/解锁清单后添加规则的改变

+ 22 - 30
web/building_saas/main/js/views/glj_view.js

@@ -744,15 +744,14 @@ var gljOprObj = {
     },
     setGLJPrice:function (data,glj,isRadio = false) {//isRadio 标记是否算组成物的价格
         let proGLJ =  projectObj.project.projectGLJ;
+        let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
+        let decimalObj = projectInfoObj.projectInfo.property.decimal;
+        let labourCoeDatas =  projectObj.project.labourCoe.datas;
         glj = glj?glj:_.find(proGLJ.datas.gljList, {'id': data.projectGLJID});
-        data.marketPrice = proGLJ.getMarketPrice(glj,isRadio);
-        if(this.calcPriceDiff(glj)==true) {//计取价差
-            data.basePrice = proGLJ.getBasePrice(glj,isRadio);
-            data.adjustPrice = proGLJ.getAdjustPrice(glj,isRadio);
-        }else {//不计价差
-            data.basePrice = proGLJ.getMarketPrice(glj,isRadio);
-            data.adjustPrice = proGLJ.getMarketPrice(glj,isRadio);
-        }
+        let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+        data.marketPrice = result.marketPrice;
+        data.basePrice =  result.basePrice;
+        data.adjustPrice = result.adjustPrice;
         return data;
 
     },
@@ -767,16 +766,7 @@ var gljOprObj = {
     },
     calcPriceDiff:function (glj) {
         let calcOptions=projectInfoObj.projectInfo.property.calcOptions;
-        if(glj.is_evaluate==1){//先按是否暂估判断
-            return calcOptions.calc_est;
-        }
-        if(glj.type==gljType.MAIN_MATERIAL||glj.type==gljType.EQUIPMENT){//再判断是否是主材和设备
-            return calcOptions.calc_main;
-        }
-        if(glj.unit_price.is_add==1){//再判断是否新增
-            return calcOptions.calc_add;
-        }
-        return true;
+        return gljUtil.calcPriceDiff(glj,calcOptions);
     },
     getIndex(obj, pops){
         let t_index = '';
@@ -1062,19 +1052,21 @@ var gljOprObj = {
         $("#glj_tree_div").modal('hide');
         $.bootstrapLoading.start();
         project.ration_glj.insertGLJAsRation(me.GLJSelection, selected, function (parentNodeID,nextNodeID,data) {
+            let newNode=null;
+            for (let r_glj of data) {
+                r_glj.quantity = r_glj.quantity + "";
+                project.Ration.datas.push(r_glj);
+            }//要先更新树节点工程量,加载项目工料机并计算消耗量才有值
             project.projectGLJ.loadData(function () {
-                  let newNode=null;
-                 for (let r_glj of data) {
-                     r_glj = me.setGLJPrice(r_glj);//设置工料机价格
-                     r_glj.marketUnitFee = r_glj.marketPrice;
-                     r_glj.quantity = r_glj.quantity + "";
-                     project.Ration.datas.push(r_glj);
-                     newNode = project.mainTree.insert(parentNodeID, nextNodeID, r_glj.ID);
-                     newNode.source = r_glj;
-                     newNode.sourceType = project.Ration.getSourceType();
-                     newNode.data = r_glj;
-                     ProjectController.syncDisplayNewNode(projectObj.mainController, newNode);
-                 }
+                for(let r_glj of data){
+                    r_glj = me.setGLJPrice(r_glj);//设置工料机价格
+                    r_glj.marketUnitFee = r_glj.marketPrice;
+                    newNode = project.mainTree.insert(parentNodeID, nextNodeID, r_glj.ID);
+                    newNode.source = r_glj;
+                    newNode.sourceType = project.Ration.getSourceType();
+                    newNode.data = r_glj;
+                    ProjectController.syncDisplayNewNode(projectObj.mainController, newNode);
+                }
                 project.calcProgram.calcLeafAndSave(newNode.parent);//计算父级清单的所有子节点
                 projectObj.mainController.refreshTreeNode([newNode]);
                 if(me.hasComposition(newNode.data,true)){

+ 22 - 17
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -16,15 +16,18 @@ var gljContextMenu = {
                     icon: 'fa-remove',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if( sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
-                        }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return false;
+                        }else {
                             return true;
                         }
-                        return false;
+
                     },
                     callback: function () {
                         var sheetData = gljOprObj.sheetData;
@@ -67,15 +70,16 @@ var gljContextMenu = {
                     icon: 'fa-sign-in',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if(sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
+                            return false;
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         getGLJData('replace');
@@ -88,17 +92,17 @@ var gljContextMenu = {
                     name: '批量替换人材机',
                     icon: 'fa-sign-in',
                     disabled: function () {
-                        var sheetData = gljOprObj.sheetData;
-                        var disable = true;
+                        let sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             if(sheetData[gljContextMenu.selectedRow].isMixRatio==true){
                                 return true;
                             }
+                            return false;
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         getGLJData('m_replace');
@@ -112,17 +116,18 @@ var gljContextMenu = {
                     icon: 'fa-sign-in',
                     disabled: function () {
                         var sheetData = gljOprObj.sheetData;
+                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
+                            return true;
+                        }
                         if(subSpread.getActiveSheetIndex()==0&&sheetData!=null&&sheetData.length>0&&gljContextMenu.selectedRow<sheetData.length){
                             var recode = sheetData[gljContextMenu.selectedRow];
                             if(!(recode.isMixRatio!=true&&recode.isAdd==true)){
                                 return true
                             }
+                            return false;
                           //  disable= recode.isMixRatio!=true&&recode.isAdd==true?false:true
                         }
-                        if(gljOprObj.isInstallationNode(projectObj.project.mainTree.selected)){
-                            return true;
-                        }
-                        return false;
+                        return true;
                     },
                     callback: function () {
                         var sheetData = gljOprObj.sheetData;

+ 41 - 69
web/building_saas/main/js/views/project_glj_view.js

@@ -14,7 +14,7 @@ projectGljObject={
             {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
             {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
-            {headerName: "总消耗量", headerWidth: 100, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
+            {headerName: "总消耗量", headerWidth: 130, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
             {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.unitPrice',validator:"number"},
             {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
             {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"},
@@ -120,65 +120,7 @@ projectGljObject={
         this.materialTreeSheet.name('materialTreeSheet');
     },
     createMaterialTreeSheetSetting:function () {
-        for(let h of this.materialSetting.header){
-            this.materialTreeSetting.cols.push(getSettingCol(h))
-        }
-        for(let l of this.materialSetting.view.lockColumns){
-            this.materialTreeSetting.cols[l].readOnly = true;
-        }
-        return this.materialTreeSetting;
-        function getSettingCol(header) {
-            let aMap ={left:0,center:1,right:2};
-            let hAlign = header.hAlign?aMap[header.hAlign]:0;
-            let col = {
-                "width":header.headerWidth?header.headerWidth:100,
-                "head":{
-                    "titleNames":[header.headerName],
-                    "spanCols":[1],
-                    "spanRows":[1],
-                    "vAlign":[1],
-                    "hAlign":[1],
-                    "font":["Arial"]
-                },
-                "data": {
-                    "field": header.dataCode,
-                    "vAlign": 1,
-                    "hAlign": hAlign,
-                    "font": "Arial"
-                }
-            };
-            if(header.cellType){
-                col.data.cellType = getCellType(header);
-            }
-            if(header.decimalField){//设置formatter
-                let decimal = getDecimal(header.decimalField);
-                col.formatter = getFormatter(decimal);
-            }
-            col.readOnly = function (node) {
-                if(node.data.ParentID == -1 || node.data.id == 'GJ'){//三材类别项不能编辑)
-                    return true;
-                }
-                return false;
-            };
-            return col;
-        }
-        function getCellType(header) {
-            return function () {
-                if(header.cellType === "checkBox"){
-                    return new GC.Spread.Sheets.CellTypes.CheckBox();
-                }
-                if(header.cellType === "comboBox"){
-                    let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
-                    if(header.options){
-                        dynamicCombo.itemHeight(header.options.length).items(header.options);
-                        if(header.editorValueType==true){
-                            dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
-                        }
-                    }
-                    return dynamicCombo
-                }
-            }
-        }
+        return sheetCommonObj.transferToTreeSetting(this.materialSetting,this.materialTreeSetting);
     },
     unitPriceFileInit:function() {
         let me = this;
@@ -376,6 +318,18 @@ projectGljObject={
     },
     refreshDataSheet:function () {
         let me = projectGljObject;
+        let quantityCol = 5;
+        if(me.displayType == filterType.FBFX){//分部分项人材机,将“总消耗量”替换显示为“分部分项总消耗量”。
+            me.projectGljSetting.header[quantityCol].dataCode = 'subdivisionQuantity';
+            me.projectGljSheet.setValue(0, quantityCol, "分部分项总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }else if(me.displayType == filterType.TECH) {//措施项目人材机,将“总消耗量”替换显示为“措施项目总消耗量”。
+            me.projectGljSetting.header[quantityCol].dataCode = 'techQuantity';
+            me.projectGljSheet.setValue(0, quantityCol, "措施项目总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }else {
+            me.projectGljSetting.header[quantityCol].dataCode = 'quantity';
+            me.projectGljSheet.setValue(0, quantityCol, "总消耗量", GC.Spread.Sheets.SheetArea.colHeader);
+        }
+
         if(me.displayType == filterType.SCHZ){//三材汇总树节点
             me.showMaterialTreeData();
         }else {
@@ -526,7 +480,9 @@ projectGljObject={
             is_adjust_price:glj.is_adjust_price,
             ratio_data:glj.ratio_data,
             is_add:glj.unit_price.is_add,
-            bgColour:'white'
+            bgColour:'white',
+            techQuantity:glj.techQuantity,
+            subdivisionQuantity:glj.subdivisionQuantity
         };
         gljOprObj.setGLJPrice(data,glj);
         data.is_main_material = glj.is_main_material == 1?1:0;
@@ -605,6 +561,7 @@ projectGljObject={
            /* if(parentSheet.name() == 'projectGljSheet'){ 之前是单行刷新,父工料机与组成物对应的工料机分开刷,发现这样比整个刷新慢所以先整个刷新,当以后数据量大的时候再测试
                 me.refreshProjectGljRowByID(sid);
             }*/
+            projectObj.project.projectGLJ.calcQuantity();
             me.refreshParentData(prow,prowData.id,sid);
         });
     },
@@ -734,7 +691,7 @@ projectGljObject={
                 extend.supply_quantity = me.getSupplyQuantity(value, recode.quantity);
             }
             if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
-                value= value.toDecimal(getDecimal('glj.quantity'));
+                value=  scMathUtil.roundForObj(value,getDecimal('glj.quantity'));
             }
             if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'||dataCode === 'is_main_material'){
                 if(value == true){
@@ -750,6 +707,9 @@ projectGljObject={
                 value = scMathUtil.roundForObj(value,getDecimal("material"));
             }
             extend = Object.keys(extend).length > 0 ?  JSON.stringify(extend) : '';
+
+            if(recode[dataCode] == value) return;
+
             let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
             projectGLJ.pGljUpdate(updateData,callback);
         };
@@ -834,11 +794,11 @@ projectGljObject={
                       projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
                   });
               }
-        };
+        }
     }
 };
 
-$(function () {
+function getProjectResizeEles() {
     let pojGljResizeEles = {};
     pojGljResizeEles.id = '#project-glj-main';
     pojGljResizeEles.resize = $('#project-glj-main').find('.resize');
@@ -847,6 +807,22 @@ $(function () {
     pojGljResizeEles.farElement = $('#project-glj-main').find('.bottom-content');
     pojGljResizeEles.farSpread = pojGljResizeEles.farElement.children().find(".main-data-bottom");
     pojGljResizeEles.nav = pojGljResizeEles.farElement.children('ul.nav');
+    return pojGljResizeEles;
+}
+
+
+function loadProjectGljSize() {
+    let me = projectGljObject;
+    let pojGljResizeEles = getProjectResizeEles();
+    loadSize(pojGljResizeEles, 'height', function () {
+        me.projectGljSpread?me.projectGljSpread.refresh():'';
+        me.mixRatioSpread?me.mixRatioSpread.refresh():'';
+    });
+}
+
+
+$(function () {
+    let pojGljResizeEles =  getProjectResizeEles();
     slideResize(pojGljResizeEles, {min: 170, max: 700}, 'height', function () {
         projectGljObject.projectGljSpread.refresh();
         projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
@@ -862,11 +838,7 @@ $(function () {
         me.initMixRatio();
         //projectObj.project.projectGLJ.calcQuantity(); 在工程量有更新的地方调用
         me.refreshDataSheet();
-
-        loadSize(pojGljResizeEles, 'height', function () {
-            me.projectGljSpread.refresh();
-            me.mixRatioSpread?me.mixRatioSpread.refresh():'';
-        });
+        loadProjectGljSize();
     });
   /*  $('#ration_link').on('shown.bs.tab', function (e) {
         let me = projectGljObject;

+ 1 - 0
web/building_saas/main/js/views/project_property_basicInfo.js

@@ -11,6 +11,7 @@ let basicInfoView = {
             {name: '值', dataCode: 'value', width: 120, vAlign: 'center', hAlign: 'left'}
         ],
         options: {
+            allowContextMenu: false,
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,

+ 1 - 0
web/building_saas/main/js/views/project_property_bills_quantity_decimal.js

@@ -29,6 +29,7 @@ let billsDecimalView = {
             {name: '小数位数', dataCode: 'decimal', width: 80, vAlign: 'center', hAlign: 'center'}
         ],
         options: {
+            allowContextMenu: false,
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
             allowUserDragDrop : false,

+ 2 - 1
web/building_saas/main/js/views/project_property_indicativeInfo.js

@@ -13,6 +13,7 @@ let indicativeInfoObj = {
             {name: '单方造价', dataCode: 'perCentiare', width: 80, vAlign: 'center', hAlign: 'right'}
         ],
         options: {
+            allowContextMenu: false,
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,
@@ -64,7 +65,7 @@ let indicativeInfoObj = {
             sheet.setRowCount(datas.length);
             for(let col = 0, cLen = cols.length; col < cLen; col++){
                 //设置小数位数
-                if(cols[col]['dataCode'] === 'price'){
+                if(cols[col]['dataCode'] !== 'name'){
                     sheet.setFormatter(-1, col, MainTreeCol.getNumberFormatter(decimalObj.bills.totalPrice, true));
                 }
                 sheet.getRange(-1, col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);

+ 1 - 0
web/building_saas/main/js/views/project_property_labour_coe_view.js

@@ -36,6 +36,7 @@ let labourCoeView = {
         me.spread.options.tabStripVisible = false;
         me.spread.options.showVerticalScrollbar = true;
         me.spread.options.showHorizontalScrollbar = true;
+        me.spread.options.allowContextMenu = false;
         let sheetArea = GC.Spread.Sheets.SheetArea;
         let sheet = me.spread.getSheet(0);
         me.sheet = sheet;

+ 1 - 0
web/building_saas/main/js/views/project_property_projFeature.js

@@ -12,6 +12,7 @@ let projFeatureView = {
             {name: '值', dataCode: 'value', width: 120, vAlign: 'center', hAlign: 'center'}
         ],
         options: {
+            allowContextMenu: false,
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,

+ 79 - 85
web/building_saas/main/js/views/project_view.js

@@ -41,12 +41,7 @@ var projectObj = {
         //zhong 2017-9-1 特征及内容
         if(pageCCOprObj.active){
             pageCCOprObj.mainActiveCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];//mainSpread焦点单元格
-            if(node && node.sourceType === project.Bills.getSourceType()){
-                pageCCOprObj.setCacheAndShow(node);
-            }
-            else{
-                pageCCOprObj.clearData();
-            }
+            pageCCOprObj.setCacheAndShow(node);
         }
         // for test interface.  CSLAAAAA
         // projectObj.testDisplay('前四项累计值排除当前选中项' + projectObj.project.calcProgram.getBeforeTaxTotalFee([node]));
@@ -165,6 +160,8 @@ var projectObj = {
         setButtonValid(canDownLevel(selected), $('#downLevel'));
         setButtonValid(canUpMove(selected) , $('#upMove'));
         setButtonValid(canDownMove(selected), $('#downMove'));
+        setButtonValid(!projectObj.project.isBillsLocked(), $('#ZLFB_btn'));
+
     },
     checkCommonField: function (editingText, colSetting) {
         let value;
@@ -415,13 +412,13 @@ var projectObj = {
             else if(fieldName ==='contain'){//编辑含量
                 project.Ration.updateContain(value,node);
             }
-            else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'commonUnitFee' || fieldName === 'programID' ||
+            else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee' || fieldName === 'programID' ||
                 fieldName === 'subType' || fieldName === 'calcBase' || fieldName === 'isSubcontract'){
                 if (fieldName === 'quantity') {
                     project.quantity_detail.editMainTreeNodeQuantity(value,node,fieldName,editingText);
                     return;
                 }
-                else if (fieldName === 'marketUnitFee' || fieldName === 'commonUnitFee' ) {
+                else if (fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee') {
                     if (value) {value = parseFloat(value).toDecimal(decimalObj.decimal("unitPrice", node))};
                 }
                 else if (fieldName === 'calcBase') {
@@ -440,9 +437,8 @@ var projectObj = {
                 };
                 //计算基数赋值要经过解析和标准化,已在calculate里赋值
                 if(fieldName !== 'calcBase'){
-                    node.data[fieldName] = value;
-                    node.changed = true;
-                }
+                    calcTools.setFieldValue(node, fieldName, value);
+                };
 
                 project.calcProgram.calcAndSave(node);
                 gljOprObj.showRationGLJSheetData();
@@ -483,7 +479,6 @@ var projectObj = {
     },
     //repaint 动态下拉框
     mainSpreadEnterCell: function (sender, info) {
-        console.log('enterCell');
         let colSetting = projectObj.mainController.setting.cols[info.col];
         if(colSetting.data.field === 'unit' || (projectObj.lastCol&&projectObj.lastCol.data.field === 'unit')||colSetting.data.field ==='subType'
             || (projectObj.lastCol&&projectObj.lastCol.data.field === 'subType') || colSetting.data.field === 'programID' ||(projectObj.lastCol&&projectObj.lastCol.data.field === 'programID')){
@@ -651,7 +646,6 @@ var projectObj = {
                 });
                 let startShowTime = +new Date();
                 that.mainController = TREE_SHEET_CONTROLLER.createNew(that.project.mainTree, that.mainSpread.getActiveSheet(), that.project.projSetting.mainGridSetting);
-
                 that.mainController.showTreeData();
                 let endShowTime = +new Date();
                 console.log(`show data时间——${endShowTime - startShowTime}`);
@@ -830,11 +824,7 @@ var projectObj = {
                     visible: function(key, opt){
                         var selected = project.mainTree.selected;
                         if(selected){
-                            if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
-                                return false
-                            }else {
-                                return true
-                            }
+                          return canInsertRationNode(selected);
                         }
                        return false;
                     }
@@ -853,11 +843,7 @@ var projectObj = {
                     visible: function(key, opt){
                         var selected = project.mainTree.selected;
                         if(selected){
-                            if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
-                                return false
-                            }else {
-                                return true
-                            }
+                           return canInsertRationNode(selected);
                         }
                        return false;
                     }
@@ -884,28 +870,11 @@ var projectObj = {
                     visible: function(key, opt){
                         var selected = project.mainTree.selected;
                         if(selected){
-                            if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
-                                return false;
-                            }else {
-                                return true;
-                            }
+                          return canInsertRationNode(selected);
                         }
                         return false;
                     }
                 },
-                "ZLFB": {
-                    name: "整理分部",
-                    icon: 'fa-sign-in',
-                    disabled: function () {
-                       return projectObj.project.isBillsLocked();
-                    },
-                    callback: function (key, opt) {
-                        zlfb_object.getSectionInfo();
-                    },
-                    visible: function(key, opt){
-                        return true;
-                    }
-                },
                 "calc_installation_fee": {
                     name: "计取安装费用",
                     icon: 'fa-sign-in',
@@ -1155,54 +1124,47 @@ var projectObj = {
         if(!isDef(node)){
             return null;
         }
-        //选中行
-        if(node === this.project.mainTree.selected){
-            styleMap = mapping.SELECTED;
-        }
-        //非选中行
-        else {
-            //清单大类
-            if(node.sourceType === this.project.Bills.getSourceType()){
-                //大项费用
-                if(node.data.type === billType.DXFY){
-                    styleMap = mapping.DXFY;
-                }
-                //分部
-                if(node.data.type === billType.FB){
-                    styleMap = mapping.FB;
+        //清单大类
+        if(node.sourceType === this.project.Bills.getSourceType()){
+            //大项费用
+            if(node.data.type === billType.DXFY){
+                styleMap = mapping.DXFY;
+            }
+            //分部
+            if(node.data.type === billType.FB){
+                styleMap = mapping.FB;
+            }
+            //分项
+            else if(node.data.type === billType.FX){
+                styleMap = mapping.FX;
+            }
+            //补项
+            else if(node.data.type === billType.BX){
+                styleMap = mapping.BX;
+            }
+            //清单
+            else if(node.data.type === billType.BILL){
+                //非叶子节点的清单
+                if(node.source.children.length > 0){
+                    styleMap = mapping.UNLEAFBILL;
                 }
-                //分项
-                else if(node.data.type === billType.FX){
-                    styleMap = mapping.FX;
+                //未使用基数计算的叶子节点的清单
+                else if(node.source.children.length === 0 && (!isDef(node.data.calcBase) || node.data.calcBase === '')){
+                    styleMap = mapping.UNCBBILL;
                 }
-                //补项
-                else if(node.data.type === billType.BX){
-                    styleMap = mapping.BX;
+                //使用基数计算的叶子节点的清单
+                else if(node.source.children.length === 0 && isDef(node.data.calcBase && node.data.calcBaseValue !== '')){
+                    styleMap = mapping.CBBILL;
                 }
-                //清单
-                else if(node.data.type === billType.BILL){
-                    //非叶子节点的清单
-                    if(node.source.children.length > 0){
-                        styleMap = mapping.UNLEAFBILL;
-                    }
-                    //未使用基数计算的叶子节点的清单
-                    else if(node.source.children.length === 0 && (!isDef(node.data.calcBase) || node.data.calcBase === '')){
-                        styleMap = mapping.UNCBBILL;
-                    }
-                    //使用基数计算的叶子节点的清单
-                    else if(node.source.children.length === 0 && isDef(node.data.calcBase && node.data.calcBaseValue !== '')){
-                        styleMap = mapping.CBBILL;
-                    }
-                }
-            }
-            //定额下的主材、设备
-            else if(node.sourceType === this.project.ration_glj.getSourceType()){
-                styleMap = mapping.ZCSB;
-            }
-            else {
-                styleMap = mapping.DEFAULT;
             }
         }
+        //定额下的主材、设备
+        else if(node.sourceType === this.project.ration_glj.getSourceType()){
+            styleMap = mapping.ZCSB;
+        }
+        else {
+            styleMap = mapping.DEFAULT;
+        }
         let styleSetting = colorSetting[styleMap];
         let defaultSetting = colorSetting[mapping.DEFAULT];
         if(!isDef(styleSetting)){
@@ -1224,6 +1186,10 @@ var projectObj = {
                 }
             }*/
         }
+        //选中行-替换底色
+        if(node === this.project.mainTree.selected){
+             style.backColor = colorSetting[mapping.SELECTED]['backColor'];
+        }
         style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
@@ -1312,7 +1278,7 @@ $('#insert').click(function () {
 $('#delete').click(function () {
     let project = projectObj.project;
     let selected = project.mainTree.selected;
-    if(selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
+    if(isSingleSelect()&&selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
         project.Bills.deleteSelectedNode();
     }else {
         $("#delete_row").modal({show:true});//弹出删除提示框;
@@ -1379,6 +1345,19 @@ $("a[name='lockBills']").click(function () {
         pageCCOprObj.refreshRuleTools(lockBills);
     });
 });
+$('#ZLFB_btn').click(function () {
+    zlfb_object.getSectionInfo();
+});
+
+//工料机库
+$('#compleGljLib').click(function () {
+    let newTab = window.open('about:blank');
+    let newHref = '/complementaryGlj';
+    CommonAjax.get(newHref, [], function () {
+        newTab.location.href = newHref;
+    });
+});
+
 //显示至..
 let displayLevel = function(nodes, depth, type){
     let refreshNodes = [];
@@ -1756,6 +1735,9 @@ function ifCanDelete() {
                 if(projectObj.project.isBillsLocked()== true){
                     return false;
                 }
+                if(projectObj.project.Bills.hasFlags(node)){
+                    return false;
+                }
             }
             if(m_selection!=true&&node.sourceType === projectObj.project.ration_glj.getSourceType()){//多选的时候不做这一项判断
                 return false;
@@ -1782,6 +1764,18 @@ function ifCanDelete() {
     };
 }
 
+function canInsertRationNode(selected) {//判断是否能插入定额、量价、定额类型工料机, false 不能,true能
+    let project = projectObj.project;
+    if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
+        return false
+    }else if(!(project.Bills.isMeasure(selected)||project.Bills.isFBFX(selected))){
+        return false
+    }else {
+        return true
+    }
+}
+
+
 //选择要导入的excel文件
 $('#customFile').change(function () {
     let file = $(this)[0];

+ 4 - 8
web/building_saas/main/js/views/std_bills_lib.js

@@ -49,15 +49,12 @@ var billsLibObj = {
             sheet.resumePaint();
         }
     },
-    setTagForHint: function (datas) {
+    setTagForHint: function (nodes) {
         let sheet = this.stdBillsSpread.getActiveSheet();
         sheet.suspendPaint();
         sheet.suspendEvent();
-        for(let i = 0, len = sheet.getRowCount(); i < len; i++){
-            sheet.setTag(i, 2, '');
-        }
-        for(let i = 0, len = datas.length; i < len; i++){
-            sheet.setTag(i, 2, datas[i].ruleText ? datas[i].ruleText : '');
+        for(let node of nodes){
+            sheet.setTag(node.serialNo(), 2, node.data.ruleText ? node.data.ruleText : '');
         }
         sheet.resumePaint();
         sheet.resumeEvent();
@@ -185,9 +182,8 @@ var billsLibObj = {
                 that.stdBillsTree.setRootExpanded(that.stdBillsTree.roots, false);
             }
             stdBillsTreeController.showTreeData();
-            billsLibObj.setTagForHint(datas);
+            billsLibObj.setTagForHint(that.stdBillsTree.items);
             showBillsRela(that.stdBillsTree.firstNode());
-            console.log(that.stdBillsTree.items);
             stdBillsTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, showBillsRela);
             that.stdBillsSpread.unbind(GC.Spread.Sheets.Events.CellDoubleClick);
             that.stdBillsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args) {

+ 3 - 2
web/building_saas/main/js/views/sub_view.js

@@ -102,12 +102,13 @@ $("#linkTZJNR").click(function () {
         setRule(projectObj.project.property.addRule);
     }
     pageCCOprObj.mainActiveCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
-    if(selectedNode && selectedNode.sourceType === projectObj.project.Bills.getSourceType()){
+    pageCCOprObj.setCacheAndShow(selectedNode);
+   /* if(selectedNode && selectedNode.sourceType === projectObj.project.Bills.getSourceType()){
         pageCCOprObj.setCacheAndShow(selectedNode);
     }
     else{
         pageCCOprObj.clearData();
-    }
+    }*/
     gljOprObj.activeTab='#linkTZJNR';
 });
 

+ 272 - 0
web/building_saas/main/js/views/tender_price_view.js

@@ -0,0 +1,272 @@
+/**
+ * Created by zhang on 2018/6/1.
+ */
+
+let tender_obj={
+    tenderSpread:null,
+    tenderSheet:null,
+    tenderTree:null,
+    tenderController:null,
+    tenderSetting:{
+        header:[
+            {headerName: "项目编码", headerWidth: 170, dataCode: "code", dataType: "String",spanRows: [2],getText:'getText.code'},
+            {headerName: "类别", headerWidth: 50, dataCode: "subType", hAlign: "center", dataType: "String",spanRows: [2],getText:'getText.subType'},
+            {headerName: "项目名称", headerWidth: 200, dataCode: "name",showHint:true, hAlign: "left", dataType: "String",spanRows: [2]},
+            {headerName: "计量\n单位", headerWidth: 60, dataCode: "unit", hAlign: "center", dataType: "String",spanRows: [2]},
+            {headerName: "工程量", headerWidth: 120, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number",spanRows: [2]},
+            {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", hAlign: "center", cellType : "checkBox",dataType: "Number",spanRows: [2]},
+            {headerName: ["初始报价","综合单价"], headerWidth: 80, dataCode: "feesIndex.common.unitFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [2,1]},
+            {headerName: ["","综合合价"], headerWidth: 80, dataCode: "feesIndex.common.totalFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["目标造价","综合单价"], headerWidth: 80, dataCode: "targetUnitFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [2,1]},
+            {headerName: ["","综合合价"], headerWidth: 80, dataCode: "targetTotalFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["调整后报价","综合单价"], headerWidth: 80, dataCode: "feesIndex.common.tenderUnitFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [2,1]},
+            {headerName: ["","综合合价"], headerWidth: 80, dataCode: "feesIndex.common.tenderTotalFee", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["消耗量调整系数","人工"], headerWidth: 80, dataCode: "quantityCoe.labour", hAlign: "right", dataType: "Number",validator:"number",spanCols : [5,1]},
+            {headerName: ["","材料"], headerWidth: 80, dataCode: "quantityCoe.material", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["","机械"], headerWidth: 80, dataCode: "quantityCoe.machine", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["","主材"], headerWidth: 80, dataCode: "quantityCoe.main", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: ["","设备"], headerWidth: 80, dataCode: "quantityCoe.equipment", hAlign: "right", dataType: "Number",validator:"number",spanCols : [0,1]},
+            {headerName: "子目工程量\n调整系数", headerWidth: 100, dataCode: "rationQuantityCoe", hAlign: "center", dataType: "Number",spanRows: [2],validator:"number"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3,4,6,7,10,11]
+        }
+    },
+    tenderTreeSetting:{
+        "emptyRows" : 3,
+        "headRows" :2,
+        "treeCol" : 0,
+        "headRowHeight" : [21],
+        "cols" : []
+    },
+    initTenderSpread:function () {
+        if(!this.tenderSpread){
+            this.tenderSpread = SheetDataHelper.createNewSpread($("#tenderSpread")[0]);
+        }
+        this.tenderSheet = this.tenderSpread.getSheet(0);
+        this.tenderTree = cacheTree.createNew(this);
+        this.tenderTreeSetting = this.createTenderTreeSetting();
+        TREE_SHEET_HELPER.initSetting($('#tenderSpread')[0], this.tenderTreeSetting );
+        this.tenderTreeSetting.setAutoFitRow = MainTreeCol.getEvent("setAutoFitRow");
+        this.tenderController = TREE_SHEET_CONTROLLER.createNew(this.tenderTree, this.tenderSheet, this.tenderTreeSetting);
+        this.tenderSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSheetValueChange);
+        this.tenderSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onEditStarting);
+
+       // this.tenderController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, this.onSelectionChange);
+    },
+    createTenderTreeSetting:function () {
+       return sheetCommonObj.transferToTreeSetting(this.tenderSetting,this.tenderTreeSetting,MainTreeCol);
+    },
+    showTenderData:function () {
+        let me = this;
+        let mainTree = projectObj.project.mainTree;
+        this.tenderTree.nodes={},this.tenderTree.selected = null,this.tenderTree.roots = [],this.tenderTree.items=[];
+        for(r of mainTree.roots){
+            createTenderNode(r,null,null);
+        }
+        me.tenderTree.sortTreeItems();
+        this.tenderSheet.setRowCount(0);
+        me.tenderController.showTreeData();
+
+        function createTenderNode(mainNode,parent,next) {
+            if(mainNode.sourceType != ModuleNames.ration_glj){//主材、设备的工料机不用显示
+                let newNode = me.tenderTree.addNode(parent, next, mainNode.data.ID);
+                newNode.data = mainNode.data;
+                newNode.source =  mainNode.source;
+                newNode.sourceType = mainNode.sourceType;
+                newNode.mainNode = mainNode;
+                if(mainNode.children.length > 0){
+                    for(let c of mainNode.children){
+                        createTenderNode(c,newNode,null);
+                    }
+                }
+                return newNode;
+            }
+        }
+    },
+    onSheetValueChange : function (sender,args) {
+        let me = tender_obj, row = args.row, col = args.col;
+        let node = me.tenderTree.items[row];
+        let dataCode = me.tenderSetting.header[col].dataCode;
+        let value = args.newValue;
+        let updateData = {type:node.sourceType,data:{'ID' : node.data.ID}};
+        let datas = [],nodes = [];
+
+        if (value&&!projectGljObject.checkData(col,me.tenderSetting,value)) {
+            setTimeout(function () {//为了不与click事件冲突
+                alert('输入的数据类型不对,请重新输入!');
+            },200);
+            updateData = null;
+        }
+        if(dataCode == 'is_adjust_price'){//不调价,修改父项后,子项也跟着更新
+            if(value == true){
+                value = 1;
+            }else if(value == false){
+                value = 0;
+            }
+            me.updateChildrenValue(node,dataCode,value,datas,nodes);
+        }
+        if(updateData&&dataCode.indexOf("Coe") != -1 ){//如果是调整系统项,级联更新子项
+            value = scMathUtil.roundForObj(value,getDecimal('process'));
+            me.updateChildrenValue(node,dataCode,value,datas,nodes);
+        }
+
+
+        //在目标造价综合单价中输入数值,按项目属性中的清单单价精度取舍,并清空当前行的目标造价综合合价
+        if(dataCode == 'targetUnitFee'){
+            value = scMathUtil.roundForObj(value,getDecimal('unitPrice',node));
+            updateData?updateData.data["targetTotalFee"] = null:'';
+        }
+        if(dataCode == 'targetTotalFee'){
+            value = scMathUtil.roundForObj(value,getDecimal('totalPrice',node));
+            updateData?updateData.data["targetUnitFee"] = null:'';
+        }
+        if(updateData){
+            updateData.data[dataCode] = value;
+            datas.push(updateData);
+        }
+        nodes.push(node);
+        me.updateTenderData(datas,function () {
+            me.tenderController.refreshTreeNode(nodes, false);
+        });
+
+    },
+    updateChildrenValue:function (node,dataCode,value,datas,nodes) {
+         if(node.children.length > 0){
+            for(let c of node.children){
+                let updateData = {type:c.sourceType,data:{'ID' : c.data.ID}};
+                updateData.data[dataCode] = value;
+                datas.push(updateData);
+                nodes.push(c);
+                this.updateChildrenValue(c,dataCode,value,datas,nodes);
+            }
+         }
+
+    },
+
+    updateTenderData:function (datas,callback) {
+        let me = tender_obj;
+        if(datas.length <= 0){
+            callback?callback():'';
+            return;
+        }
+        $.bootstrapLoading.start();
+        projectObj.project.updateNodes(datas,function () {
+            for(let d of datas){
+                let temObj = null;
+                if(d.type == ModuleNames.bills || d.type == ModuleNames.ration){
+                    let temNode = me.tenderTree.findNode(d.data.ID);
+                    temObj = temNode?temNode.data:null;
+                }else if(d.type == ModuleNames.project){
+                    temObj = projectInfoObj.projectInfo;
+                }
+                if(temObj){
+                    for(let key in d.data){
+                        if(key == 'ID' || key == 'id'){
+                            continue;
+                        }
+                        _.set(temObj,key,d.data[key]);
+                    }
+                }
+            }
+            callback?callback():'';
+            $.bootstrapLoading.end();
+        })
+    },
+
+
+    onEditStarting:function (sender,args) {
+        let me = tender_obj, row = args.row, col = args.col;
+        if(me.editChecking(row,col) == false){
+            args.cancel = true;
+        }
+
+    },
+    editChecking:function (row,col) {//return false表示不能编辑
+        let me = tender_obj;
+        let dataCode = me.tenderSetting.header[col].dataCode;
+        let lockColumns = me.tenderSetting.view.lockColumns;
+
+        if(lockColumns.indexOf(col)!= -1){
+            return false;
+        }
+        if(dataCode == 'is_adjust_price'){
+            return false;
+        }
+        if(row >=  me.tenderTree.items.length){
+            return false;
+        }
+        if(dataCode == 'targetUnitFee' || dataCode == 'targetTotalFee'){
+            if($('#calcPriceOption').val() == 'coeBase'){//下拉按钮显示为“根据调整系数计算报价”时,目标造价(综合单价、综合合价) ,灰显,只读。
+                return false;
+            }else if(me.tenderTree.items[row].data.is_adjust_price === 1){//下拉按钮显示为“根据报价计算调整系数”时,打勾了不调价,目标造价(综合单价、综合合价)只读。
+                return false;
+            }
+        }
+        if(dataCode.indexOf('Coe') != -1){//如果是调整系数列
+            if($('#calcPriceOption').val() =='priceBase'){//下拉按钮显示为“根据报价计算调整系数”时,只读。
+                return false;
+            }else if(me.tenderTree.items[row].data.is_adjust_price === 1){//打勾了不调价,只读。
+                return false;
+            }
+        }
+        return true;
+    },
+    initPageContent : function () {
+        let tenderSetting = projectObj.project.property.tenderSetting;
+        let calcPriceOption = tenderSetting && tenderSetting.calcPriceOption? tenderSetting.calcPriceOption :"coeBase";
+        let gljPriceTenderCoe = tenderSetting && tenderSetting.gljPriceTenderCoe?tenderSetting.gljPriceTenderCoe:1;
+        $('#calcPriceOption').val(calcPriceOption);
+        $('#gljPriceTenderCoe').val(gljPriceTenderCoe);
+        if(calcPriceOption == 'coeBase'){
+            $('#tenderPrice').removeAttr("disabled");
+            $('#tenderGLJQuantity').attr("disabled",true);
+            $('#tenderRationQuantity').attr("disabled",true);
+        }else {
+            $('#tenderPrice').attr("disabled",true);
+            $('#tenderGLJQuantity').removeAttr("disabled");
+            $('#tenderRationQuantity').removeAttr("disabled");
+        }
+        //gljPriceTenderCoe
+    }
+};
+
+$(function () {
+    $('#tab_tender_price').on('shown.bs.tab', function (e) {
+        sessionStorage.setItem('mainTab', '#tab_tender_price');
+        $(e.relatedTarget.hash).removeClass('active');
+        if(!tender_obj.tenderSpread){
+            tender_obj.initTenderSpread();
+        }
+        autoFlashHeight();
+        tender_obj.tenderSpread.refresh();
+        tender_obj.showTenderData();
+        tender_obj.initPageContent();
+    });
+
+    $('#tenderGLJQuantity').bind('click',function () {
+        console.log($('#gljPriceTenderCoe').val()) ;
+    });
+
+    $('#calcPriceOption').change(function(){
+        let me = tender_obj;
+        let newVal = $(this).val();
+        let updateData = {type:ModuleNames.project,data:{'ID' : projectObj.project.ID(),'property.tenderSetting.calcPriceOption':newVal}};
+        me.updateTenderData([updateData],function () {
+            me.initPageContent();
+        });
+    });
+
+    $('#gljPriceTenderCoe').change(function(){
+        let me = tender_obj;
+        let process = getDecimal('process');
+        var newVal = $(this).val();
+        process = scMathUtil.roundForObj(newVal,process);
+        let updateData = {type:ModuleNames.project,data:{'ID' : projectObj.project.ID(),'property.tenderSetting.gljPriceTenderCoe':process}};
+        me.updateTenderData([updateData],function () {
+            me.initPageContent();
+        });
+    })
+
+
+});

+ 16 - 6
web/building_saas/main/js/views/zmhs_view.js

@@ -13,7 +13,7 @@ let zmhs_obj = {
             {headerName: "内容", headerWidth: 350, dataCode: "content", dataType: "String", hAlign: "left"}
         ],
         view: {
-            lockColumns: [0, 1, 2]
+            lockColumns: [0,1,2]
         }
     },
     assSpread:null,
@@ -38,7 +38,7 @@ let zmhs_obj = {
         this.coeSheet.bind(GC.Spread.Sheets.Events.CellClick, this.onCoeCellClick);
         this.coeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onButtonClick);
         this.coeSheet.bind(GC.Spread.Sheets.Events.EditStarting, function (e,args) {
-            args.cancel = true;
+            //args.cancel = true;
         });
         this.assSheet = this.assSpread.getSheet(0);
         sheetCommonObj.initSheet(this.assSheet, this.assSetting, 30);
@@ -257,15 +257,17 @@ let zmhs_obj = {
         projectObj.project.ration_coe.adjustCoeClick(recode, newval);
     },
     addCusButton: function (row, col, text) {
+        zmhs_obj.coeSheet.suspendPaint();
         var cus_button = new GC.Spread.Sheets.CellTypes.Button();
         zmhs_obj.coeSheet.setCellType(row, col, cus_button, GC.Spread.Sheets.SheetArea.viewport);
         cus_button.marginLeft(0);
         cus_button.marginTop(0);
-        cus_button.marginRight(0);
-        cus_button.marginBottom(0);
+        cus_button.marginRight(-2);
+        cus_button.marginBottom(-2);
         cus_button.text(text);
         cus_button.buttonBackColor('white');
-        zmhs_obj.coeSheet.repaint();
+        zmhs_obj.coeSheet.resumePaint();
+        //zmhs_obj.coeSheet.repaint();
     },
     addDropDownList: function () {
         var sheet = this.coeSheet;
@@ -297,10 +299,18 @@ let zmhs_obj = {
     getOneRow: function (text, name, id) {
         var rowstr = "<tr style='height:10px'><td style='width: 50px'>" + text
             + ":</td><td style='width: 70px' align='right'><input type='text'value='1' name=" + name
-            + " style='width:30px;border:0;height:14px' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)'></td></tr>";
+            + " style='width:30px;border:0;height:14px' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)'onfocus = 'zmhs_obj.coeStartEdit()' autocomplete='off'></td></tr>";
         return rowstr;
 
     },
+    coeStartEdit(){
+        if(zmhs_obj.coeSheet.isEditing()){
+            return;
+        }else {
+            zmhs_obj.coeSheet.startEdit();
+        }
+
+    },
     onAssEditEnded:function (e,args) {
         var me = zmhs_obj;
         if (args.row >= me.assSheetData.length) {

+ 1 - 1
web/building_saas/pm/html/project-management-Recycle.html

@@ -64,7 +64,7 @@
                 <p>勾选需要恢复的文件,点“确定”按钮,确认从回收站中恢复。</p>
                 <table class="table table-hover table-sm mb-5">
                     <thead><tr style="display: block;"><th width="266px">名称</th><th width="136px">删除时间</th><th width="64px">勾选</th></tr></thead>
-                    <tbody style="display:block; height: 300px; overflow: auto">
+                    <tbody style="display:block; height: 300px; overflow: auto;">
                     <tr><td>XX单价文件</td><td>2017-11-01<br>12:11:43</td><td><input type="checkbox"></td></tr>
                     </tbody>
                 </table>

File diff suppressed because it is too large
+ 2 - 2
web/building_saas/pm/html/project-management.html


+ 1 - 0
web/building_saas/pm/js/pm_gc.js

@@ -34,6 +34,7 @@ const gcTreeObj = {
         },
         options: {
             tabStripVisible:  false,
+            allowContextMenu: false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,
             allowUserDragDrop : false,

+ 27 - 14
web/building_saas/pm/js/pm_newMain.js

@@ -52,6 +52,7 @@ const projTreeObj = {
         },
         options: {
             tabStripVisible:  false,
+            allowContextMenu: false,
             allowCopyPasteExcelStyle : false,
             allowExtendPasteRange: false,
             allowUserDragDrop : true,
@@ -555,10 +556,9 @@ const projTreeObj = {
             }
             if(hitinfo.sheet.name() != "copyToSheet"){//如果是复制到sheet,不用执行
                 //建设项目,侧滑汇总
-                if(node.data.projType === projectType.project && withingClickArea()){
+                if(node.data.projType === projectType.project && withingClickArea() && !$('.slide-sidebar').hasClass('open')){
                     setDataToSideBar();
                     $(".slide-sidebar").animate({width:"440"}).addClass("open");
-                    $('body').unbind('click');
                     setTimeout(function () {
                         $("body").bind('click', function (event) {
                             var e = event || window.event; //浏览器兼容性
@@ -568,23 +568,33 @@ const projTreeObj = {
                                     if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
                                         return false;
                                     }
+                                    if($(elem).attr('id') && $(elem).attr('id') === 'del-wj'){
+                                        return false;
+                                    }
                                     elem = elem.parentNode;
                                 }
                                 $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
+                                $('body').unbind('click');
                             }
                         });
                     }, 500);
                 }
                 //单项文件,进入造价书界面
                 else if(node.data.projType === projectType.tender && withingClickArea()){
-                    let newTab = window.open('about:blank');
-                    BeforeOpenProject(node.data.ID, {'fullFolder': GetFullFolder(node.parent)}, function () {
-                        let mainUrl = `/main?project=${node.data.ID}`;
-                        CommonAjax.get(mainUrl, [], function () {
-                            newTab.location.href = mainUrl;
+                    let timeoutTime = 200;
+                    if($('.slide-sidebar').hasClass('open')){
+                        timeoutTime = 500;
+                    }
+                    setTimeout(function () {
+                        let newTab = window.open('about:blank');
+                        BeforeOpenProject(node.data.ID, {'fullFolder': GetFullFolder(node.parent)}, function () {
+                            let mainUrl = `/main?project=${node.data.ID}`;
+                            CommonAjax.get(mainUrl, [], function () {
+                                newTab.location.href = mainUrl;
+                            });
                         });
-                    });
-                    return;
+                        return;
+                    }, timeoutTime);
                 }
                 if (!node || node.children.length === 0) { return; }
             }
@@ -861,6 +871,7 @@ $(document).ready(function() {
             a_updateFiles([updateObj], function () {
                 fileDelObj = null;
                 $('#fileDelCancel').click();
+                setDataToSideBar();
                 //refresh front?
             });
         }
@@ -2470,8 +2481,8 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
             let newName = $(jqS + ' input').val().trim();
             if(newName !== orgName){
                 if(hasThisFileName(fileObjs, newName)){
-                    alert('本建设项目已存在该文件名,请重新输入!');
-                    $(jqS + ' input').val(orgName);
+                    $(jqS).find('span:eq(2)').show();
+                    //$(jqS + ' input').val(orgName);
                     return;
                 }
                 if(newName.trim().length === 0){
@@ -2510,6 +2521,7 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
         $(jqS + ' .btn-secondary').on('click', function () {
             $(jqS + ' div:eq(0)').show();
             $(jqS + ' div:eq(1)').hide();
+            $(jqS).find('span:eq(2)').hide();
         });
     });
     //悬浮框显示使用该文件的单位工程
@@ -2552,7 +2564,9 @@ function set_file_table(target, poj_tenders, fileList, type){
             + '<span class="input-group-btn">'
             + '<button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-remove"></i></button>'
             + '</span>'
-            + '</div></td>';
+            + '</div>'
+            + '<span class="form-text text-danger" style="display: none">本建设项目已存在该文件名,请重新输入!' +
+            '</span></td>';
         let fileTypeStr = type === fileType.unitPriceFile ? '单价文件' : '费率文件';
         let fileHtml = '<tr><td>' + fileCounter + '</td><td id="file_' + fileId + '"><div>' + fileList[i].name + hoverHtml + renHtml + usedHtml + '</tr>';
         fileCounter++;
@@ -2568,8 +2582,7 @@ function getFileObj(jqS, type){
     let trs = $('tr', jqS);
     for(let i = 0, len = trs.length; i < len; i++){
         let td = $('td:eq(1)', trs[i])[0];
-        let dispName = td.childNodes[0].childNodes[0].textContent;
-        let name = dispName.slice(0, dispName.length - 4);
+        let name = td.childNodes[0].childNodes[0].textContent;
         let attrId = $(td).attr('id');
         let id = attrId.slice(5, attrId.length);
         if(type === fileType.unitPriceFile){

+ 2 - 1
web/common/html/header.html

@@ -13,7 +13,7 @@
                 <!--<a class="dropdown-item" href="/complementaryRation/main">定额库编辑器</a>-->
                 <a class="dropdown-item" href="javascript:void(0);" aria-expanded="false" data-toggle="modal" data-target="#opts-set"><i class="fa fa-sliders"></i> 选项</a>
                 <a class="dropdown-item" href="javascript:void(0);" data-toggle="modal" data-target="#comple-ration">定额库编辑器</a>
-                <a class="dropdown-item" href="/complementaryGlj">人材机库编辑器</a>
+                <a id="compleGljLib" class="dropdown-item" href="javascript:void(0);">人材机库编辑器</a>
             </div>
         </li>
         <li class="nav-item dropdown">
@@ -92,6 +92,7 @@
 <script type="text/javascript" src="/web/building_saas/js/moment.min.js"></script>
 <script type="text/javascript" src="/web/building_saas/js/message.js"></script>
 <script type="text/javascript" src="/public/web/scMathUtil.js"></script>
+<script type="text/javascript" src="/public/web/gljUtil.js"></script>
 <script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
 <script type="text/javascript" src="/lib/lodash/lodash.js"></script>
 <!-- endinject -->