Prechádzať zdrojové kódy

Merge branch '1.0.0_online' of http://192.168.1.12:3000/SmartCost/ConstructionCost into 1.0.0_online

TonyKang 6 rokov pred
rodič
commit
7301da3588
97 zmenil súbory, kde vykonal 3243 pridanie a 1278 odobranie
  1. 2 1
      config/gulpConfig.js
  2. 35 0
      modules/all_models/block_lib_model.js
  3. 1 1
      modules/all_models/compleGlj_glj.js
  4. 23 0
      modules/all_models/compleGlj_section.js
  5. 30 0
      modules/all_models/compleGlj_sectionTemplate.js
  6. 2 4
      modules/all_models/compleRation_ration.js
  7. 3 0
      modules/all_models/ration_coe.js
  8. 2 0
      modules/all_models/stdRation_coe.js
  9. 2 4
      modules/all_models/stdRation_ration.js
  10. 11 0
      modules/complementary_glj_lib/controllers/gljController.js
  11. 9 1
      modules/complementary_glj_lib/models/gljModel.js
  12. 1 0
      modules/complementary_glj_lib/routes/routes.js
  13. 4 4
      modules/complementary_ration_lib/models/sectionTreeModel.js
  14. 11 2
      modules/main/controllers/bills_controller.js
  15. 23 0
      modules/main/controllers/block_lib_controller.js
  16. 26 13
      modules/main/controllers/ration_controller.js
  17. 11 2
      modules/main/facade/bill_facade.js
  18. 69 0
      modules/main/facade/block_lib_facade.js
  19. 11 2
      modules/main/facade/project_facade.js
  20. 57 18
      modules/main/facade/ration_facade.js
  21. 4 3
      modules/main/models/bills.js
  22. 2 2
      modules/main/models/project.js
  23. 19 0
      modules/main/routes/block_lib_route.js
  24. 2 0
      modules/main/routes/ration_route.js
  25. 15 12
      modules/pm/controllers/pm_controller.js
  26. 59 5
      modules/pm/facade/pm_facade.js
  27. 13 11
      modules/pm/models/project_model.js
  28. 3 0
      modules/pm/routes/pm_route.js
  29. 19 0
      modules/ration_glj/controllers/ration_glj_controller.js
  30. 44 17
      modules/ration_glj/facade/glj_calculate_facade.js
  31. 18 1
      modules/ration_glj/facade/ration_ass_facade.js
  32. 79 32
      modules/ration_glj/facade/ration_glj_facade.js
  33. 1 0
      modules/ration_glj/routes/ration_glj_route.js
  34. 0 2
      modules/users/controllers/user_controller.js
  35. 1 0
      modules/users/models/user_model.js
  36. 2 1
      public/counter/counter.js
  37. 6 0
      public/scHintBox.html
  38. 21 1
      public/web/headerOpr.js
  39. 1 1
      public/web/sheet/sheet_common.js
  40. 81 22
      public/web/slideResize.js
  41. 9 3
      public/web/tree_sheet/tree_sheet_helper.js
  42. 2 2
      web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html
  43. 34 10
      web/building_saas/complementary_glj_lib/js/components.js
  44. 48 35
      web/building_saas/complementary_glj_lib/js/glj.js
  45. 11 6
      web/building_saas/complementary_glj_lib/js/gljClassTree.js
  46. 13 6
      web/building_saas/complementary_glj_lib/js/gljComponent.js
  47. 4 2
      web/building_saas/complementary_glj_lib/js/sheetOpr.js
  48. 55 17
      web/building_saas/complementary_ration_lib/html/dinge.html
  49. 2 2
      web/building_saas/complementary_ration_lib/html/gongliao.html
  50. 154 20
      web/building_saas/complementary_ration_lib/js/coe.js
  51. 32 11
      web/building_saas/complementary_ration_lib/js/gljSelect.js
  52. 3 1
      web/building_saas/complementary_ration_lib/js/global.js
  53. 68 16
      web/building_saas/complementary_ration_lib/js/ration.js
  54. 1 5
      web/building_saas/complementary_ration_lib/js/ration_glj.js
  55. 15 24
      web/building_saas/complementary_ration_lib/js/section_tree.js
  56. 22 2
      web/building_saas/css/custom.css
  57. 62 8
      web/building_saas/css/main.css
  58. 4 4
      web/building_saas/glj/html/project_glj.html
  59. 1 0
      web/building_saas/js/global.js
  60. 367 251
      web/building_saas/main/html/main.html
  61. 9 2
      web/building_saas/main/js/controllers/block_controller.js
  62. 57 20
      web/building_saas/main/js/controllers/material_controller.js
  63. 30 0
      web/building_saas/main/js/controllers/project_controller.js
  64. 20 145
      web/building_saas/main/js/main.js
  65. 32 4
      web/building_saas/main/js/models/bills.js
  66. 43 6
      web/building_saas/main/js/models/calc_program.js
  67. 1 2
      web/building_saas/main/js/models/project.js
  68. 2 2
      web/building_saas/main/js/models/quantity_detail.js
  69. 2 1
      web/building_saas/main/js/models/ration.js
  70. 8 2
      web/building_saas/main/js/models/ration_ass.js
  71. 98 10
      web/building_saas/main/js/models/ration_coe.js
  72. 93 45
      web/building_saas/main/js/models/ration_glj.js
  73. 20 18
      web/building_saas/main/js/views/billsElf.js
  74. 197 114
      web/building_saas/main/js/views/block_lib.js
  75. 4 4
      web/building_saas/main/js/views/character_content_view.js
  76. 3 5
      web/building_saas/main/js/views/fee_rate_view.js
  77. 40 7
      web/building_saas/main/js/views/glj_view.js
  78. 4 1
      web/building_saas/main/js/views/glj_view_contextMenu.js
  79. 27 9
      web/building_saas/main/js/views/locate_view.js
  80. 1 0
      web/building_saas/main/js/views/main_tree_col.js
  81. 84 32
      web/building_saas/main/js/views/mbzm_view.js
  82. 17 9
      web/building_saas/main/js/views/project_glj_view.js
  83. 4 1
      web/building_saas/main/js/views/project_info.js
  84. 4 1
      web/building_saas/main/js/views/project_property_basicInfo.js
  85. 222 44
      web/building_saas/main/js/views/project_view.js
  86. 3 0
      web/building_saas/main/js/views/quantity_edit_view.js
  87. 149 82
      web/building_saas/main/js/views/side_tools.js
  88. 4 5
      web/building_saas/main/js/views/std_billsGuidance_lib.js
  89. 58 11
      web/building_saas/main/js/views/std_ration_lib.js
  90. 136 45
      web/building_saas/main/js/views/sub_view.js
  91. 153 40
      web/building_saas/main/js/views/zmhs_view.js
  92. 17 1
      web/building_saas/pm/html/project-management.html
  93. 63 14
      web/building_saas/pm/js/pm_newMain.js
  94. 2 2
      web/building_saas/report/html/rpt_main.html
  95. 3 3
      web/users/html/login-infoinput.html
  96. 1 2
      web/users/html/login.html
  97. 2 2
      web/users/html/user-info.html

+ 2 - 1
config/gulpConfig.js

@@ -29,7 +29,7 @@ module.exports = {
     ],
     login_jspaths:[
         'public/web/url_util.js',
-        'web/users/js/login.js'
+        'web/users/js/login.js',
     ],
     pm_css:[
         'lib/ztree/css/zTreeStyle.css',
@@ -82,6 +82,7 @@ module.exports = {
         'public/web/url_util.js',
         'public/web/number_util.js',
         'public/web/sheet/sheet_common.js',
+        'public/web/slideResize.js',
        // 'lib/ztree/*.js',
         'lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2',
        // 'lib/spreadjs/views/gc.spread.views.dataview.10.0.0.min.js',

+ 35 - 0
modules/all_models/block_lib_model.js

@@ -0,0 +1,35 @@
+/**
+ * Created by CSL on 2018-12-17.
+ */
+let mongoose = require('mongoose');
+let Schema = mongoose.Schema;
+
+let dataSchema = new Schema({
+    ID: String,
+    NextSiblingID: String,
+    ParentID: String,
+    children: [],
+    code: String,
+    compilationID: String,
+    copyTime: Number,
+    firstNodeType: Number,
+    isFBFX: {type: Boolean, default: true},
+    itemCharacterText: String,
+    name: String,
+    nodeName: String,
+    type: Number,
+    unit: String,
+    unitFee: String,
+    _id: false
+},{versionKey:false});
+
+let blockLibsSchema = new Schema({
+    userID: String,
+    compilationID: String,
+    libID: Number,
+    libName: String,
+    datas: [dataSchema],
+    share: {}
+},{versionKey:false});
+
+mongoose.model('blockLibsModel', blockLibsSchema, 'block_libs');

+ 1 - 1
modules/all_models/compleGlj_glj.js

@@ -24,7 +24,7 @@ const comple_glj = new Schema({
     specs: String,
     unit: String,
     basePrice: String,
-    gljClass: Number,
+    gljClass: String,
     gljType: Number,
     model: Number,
     shortName: String,

+ 23 - 0
modules/all_models/compleGlj_section.js

@@ -0,0 +1,23 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/12/13
+ * @version
+ */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSection = new Schema({
+    userId: String,
+    compilationId: String,
+    Name: String,
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
+});
+
+mongoose.model('complementary_glj_section', compleGljSection, 'complementary_glj_section');

+ 30 - 0
modules/all_models/compleGlj_sectionTemplate.js

@@ -0,0 +1,30 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/12/13
+ * @version
+ */
+
+/*
+ * 我的补充人材机库章节树模板,一个费用定额有一个模板
+ * 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
+ * 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
+ *
+ * */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSectionTemp = new Schema({
+    compilationId: String,
+    Name: String,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+});
+
+mongoose.model('complementary_glj_section_templates', compleGljSectionTemp, 'complementary_glj_section_templates');
+

+ 2 - 4
modules/all_models/compleRation_ration.js

@@ -56,11 +56,9 @@ const compleRationSchema = new Schema({
     rationAssList: [compleRationAssItemSchema],
     rationInstList: [rationInstSchema],
     rationTemplateList : [new Schema({
+        rationID:Number,
         type: String,
-        code: String,
-        name: String,
-        billsLocation: String,
-        unit:String
+        billsLocation: String
     }, { _id: false })],
     deleteInfo: deleteSchema
 }, {versionKey: false});

+ 3 - 0
modules/all_models/ration_coe.js

@@ -20,6 +20,9 @@ var coeListSchema = mongoose.Schema({
     ID: String,                         // 系数ID(流水号ID)
     name: String,                       // 名称
     content: String,                    // 说明
+    original_code:String,               //原人材机编码
+    option_codes:String,                //可选人材机编码
+    select_code:String,
     rationID:String,
     projectID:Number,
     coeID:Number,

+ 2 - 0
modules/all_models/stdRation_coe.js

@@ -23,6 +23,8 @@ const coeListSchema = new Schema({
     serialNo: Number,                  //编号
     name: String,                       // 名称
     content: String,                    // 说明
+    original_code:String,               //原人材机编码
+    option_codes:String,                //可选人材机编码
     coes: [coeSchema]
 }, {versionKey: false});
 

+ 2 - 4
modules/all_models/stdRation_ration.js

@@ -48,11 +48,9 @@ const rationItemSchema = new Schema({
     rationAssList: [rationAssItemSchema],
     rationInstList: [rationInstSchema],
     rationTemplateList : [new Schema({
+        rationID:Number,
         type: String,
-        code: String,
-        name: String,
-        billsLocation: String,
-        unit:String
+        billsLocation: String
     }, { _id: false })]
 
 });

+ 11 - 0
modules/complementary_glj_lib/controllers/gljController.js

@@ -61,6 +61,17 @@ class GljController extends BaseController{
             callback(req,res,err, 'Get Tree', data)
         });
     }
+    //获取标准分类树和补充分类树
+    async getMixedTree(req, res){
+        try {
+            let data = JSON.parse(req.body.data);
+            let treeData = await gljDao.getMixedTree(data.gljLibId, req.session.sessionUser.id, req.session.sessionCompilation._id);
+            callback(req, res, 0, 'success', treeData);
+        } catch (err) {
+            console.log(err);
+            callback(req, res, 1, err, null);
+        }
+    }
 
     createNewGljTypeNode(req, res) {
         let repId = req.body.repositoryId;

+ 9 - 1
modules/complementary_glj_lib/models/gljModel.js

@@ -5,13 +5,14 @@ const mongoose = require('mongoose');
 const complementaryGljModel = mongoose.model('complementary_glj_lib');
 const stdGljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
+const compleClassModel = mongoose.model('complementary_glj_section');
 import counter from "../../../public/counter/counter";
 import async from "async";
 import STDGLJLibGLJListModel from "../../common/std/std_glj_lib_glj_list_model";
 
 class GljDao {
     getGljTypes (gljLibId, callback){
-        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+        gljClassModel.find({"repositoryId": gljLibId},function(err,data){
             if(data.length) {
                 callback(0,data);
             }
@@ -335,6 +336,13 @@ class GljDao {
 
         return result;
     }
+
+    async getMixedTree(gljLibId, userId, compilationId){
+        let rst = {std: [], comple: []};
+        rst.std = await gljClassModel.find({repositoryId: gljLibId});
+        rst.comple = await compleClassModel.find({userId: userId, compilationId: compilationId});
+        return rst;
+    }
 }
 
 export default GljDao;

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

@@ -26,6 +26,7 @@ module.exports = function (app) {
     router.post("/updateRationBasePrc",compleRationController.init, compleRationController.updateRationBasePrc);//更新定额单价
     //router.post("/getGljItemsByIds", gljController.init, gljController.getGljItemsByIds);
     //router.post("/getGljItemsByCodes", gljController.init, gljController.getGljItemsByCodes);
+    router.post('/getMixedTree', gljController.init, gljController.getMixedTree);
 
     app.use("/complementartGlj/api", router);
 

+ 4 - 4
modules/complementary_ration_lib/models/sectionTreeModel.js

@@ -122,10 +122,10 @@ class SectionTreeDao {
                     await compleRationSectionTreeModel.create(updateObj.updateData);
                 }
                 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});
+                    if(!updateObj.updateData.deleteInfo){
+                        await compleRationSectionTreeModel.update({userId: userID, ID: updateObj.updateData.ID}, updateObj.updateData);
+                    } else {
+                        await compleRationSectionTreeModel.remove({userId: userID, ID: updateObj.updateData.ID});
                     }
                 }
             }

+ 11 - 2
modules/main/controllers/bills_controller.js

@@ -457,9 +457,18 @@ function  generateUpdateTasks(data,projectID,user_id) {
             }
         };
         if(updateData[key]===true){
-            task.updateOne.update={
+            //原先是假删除,现在改成真删除
+            task = {
+                deleteOne:{
+                    filter:{
+                        ID:key,
+                        projectID:projectID
+                    }
+                }
+            }
+           /* task.updateOne.update={
                 deleteInfo:deleteInfo
-            };
+            };*/
         }else {
             task.updateOne.update=updateData[key];
         }

+ 23 - 0
modules/main/controllers/block_lib_controller.js

@@ -0,0 +1,23 @@
+/**
+ * Created by CSL on 2018-12-17.
+ */
+
+let mongoose = require('mongoose');
+let blFacade = require('../facade/block_lib_facade');
+
+module.exports = {
+    doController: async function (req, res) {
+        let result = {error: 0, message: '', data: null};
+        try {
+            let funcName = req.url.replace(/\//g, "");
+            let dataObj = JSON.parse(req.body.data);
+            result.data = await blFacade[funcName](dataObj);
+        } catch (err) {
+            console.log(err);
+            result.error = 1;
+            result.message = err.message;
+        }
+        res.json(result);
+    }
+};
+

+ 26 - 13
modules/main/controllers/ration_controller.js

@@ -1,9 +1,10 @@
 /**
  * Created by jimiz on 2017/4/9.
  */
-var rationData = require('../models/ration');
-var ration_glj_facade = require('../../ration_glj/facade/ration_glj_facade');
-var ration_facade = require('../facade/ration_facade');
+let rationData = require('../models/ration');
+let ration_glj_facade = require('../../ration_glj/facade/ration_glj_facade');
+let ration_ass_facade = require('../../ration_glj/facade/ration_ass_facade');
+let ration_facade = require('../facade/ration_facade');
 let bill_facade = require('../facade/bill_facade');
 let project_facade = require("../facade/project_facade");
 let logger = require("../../../logs/log_helper").logger;
@@ -54,22 +55,34 @@ let controller = {
     applyTemplate:async function(req){
         let data = req.body.data;
         data = JSON.parse(data);
-        let rationResult = [],billsResult = [],updateDatas =[];
-        //先生成新定额
-        if(data.rations.create.length > 0){
-            rationResult = await ration_facade.addMultiRation(data.rations.create,req.session.sessionCompilation);
-        }
-        //再生成清单
-        if(data.bills.create.length > 0){
-            billsResult =  await bill_facade.createNewBills(data.bills.create)
-        }
+        let updateDatas =[];
+        let applyTasks = [
+            ration_facade.addMultiRation(data.rations.create,req.session.sessionCompilation),//先生成新定额
+            bill_facade.createNewBills(data.bills.create),
+        ];
         //整理更新的数据,调用一个方法更新
         updateDatas.push(data.ration_template);
         if(data.rations.update.length > 0)  prepareUpdateNodes(data.rations.update,updateDatas,"ration");
         if(data.bills.update.length > 0)  prepareUpdateNodes(data.bills.update,updateDatas,"bills");
-        await project_facade.updateNodes(updateDatas);
+        applyTasks.push(project_facade.updateNodes(updateDatas));
+        let [rationResult,billsResult,updates] = await Promise.all(applyTasks);
         return {rationResult:rationResult,billsResult:billsResult,updateDatas:updateDatas};
+    },
+    //更新辅助定额
+    updateRationAss:async function(req){
+        let data = req.body.data;
+        data = JSON.parse(data);
+        return ration_ass_facade.updateRationAss(data);
+    },
+    //勾选定额调整系数
+    updateCoeAdjust:async function(req){
+        let data = req.body.data;
+        data = JSON.parse(data);
+        return await ration_facade.updateCoeAdjust(data,req.session.sessionCompilation);
+
     }
+
+
 };
 
 function prepareUpdateNodes(datas,nodes,type) {

+ 11 - 2
modules/main/facade/bill_facade.js

@@ -208,7 +208,16 @@ function generateBillTasks(data) {
     let deleteInfo={deleted: true, deleteDateTime: new Date(), deleteBy: user_id};
     if(data.delete && data.delete.length > 0){
         for(let d_ID of data.delete){
-            let task={
+            //原先是假删除,现在改成真删除
+            let task = {
+                deleteOne:{
+                    filter:{
+                        ID:d_ID,
+                        projectID:projectID
+                    }
+                }
+            };
+          /*  let task={
                 updateOne:{
                     filter:{
                         ID:d_ID,
@@ -218,7 +227,7 @@ function generateBillTasks(data) {
                         deleteInfo:deleteInfo
                     }
                 }
-            };
+            };*/
             tasks.push(task);
         }
     }

+ 69 - 0
modules/main/facade/block_lib_facade.js

@@ -0,0 +1,69 @@
+/**
+ * Created by CSL on 2018-12-17.
+ */
+
+let mongoose = require('mongoose');
+let blModel = mongoose.model('blockLibsModel');
+
+module.exports = {
+    getLibNames: getLibNames,
+    getLib: getLib,
+    getLibNamesAndFirstLib: getLibNamesAndFirstLib,
+    saveBlock: saveBlock
+};
+
+// userID、compilationID
+async function getLibNames(data) {
+    let libNames = await blModel.find({userID: data.userID, compilation: data.compilationID}, ["libID","libName","-_id"]);
+    return libNames;
+};
+
+// libID
+async function getLib(data) {
+    let lib = await blModel.findOne({libID: data.libID});
+    return lib;
+};
+
+// userID、compilationID
+async function getLibNamesAndFirstLib(data) {
+    let libNames = await getLibNames(data);
+    let firstLib = await getLib(libNames[0]);
+    return {libNames: libNames, firstLib: firstLib};
+};
+
+/*------------------------------------------------------------------------------
+data参数示例:
+        {
+            libID: 3,
+            nodeID: 5,
+            create: {node}
+            delete: true
+            update: {nodeName: 'xxx', children: [...]}
+        }
+说明:   libID、nodeID 必须。 create|update|delete三选一。
+        create属性值是完整的node节点数据。
+        delete属性值是true。
+        update属性值是要修改的属性键值对组成的对象。
+------------------------------------------------------------------------------*/
+async function saveBlock(data) {
+    if (data.create) {
+        await blModel.update({libID: data.libID}, {$addToSet: {datas: data.create}});
+    }
+    if (data.delete) {
+        await blModel.update({libID: data.libID}, {$pull: {datas: {ID: data.nodeID}}});
+    }
+    else if (data.update){
+        let doc = await blModel.findOne({libID: data.libID});
+        let datas = doc._doc.datas;
+        for (let i = 0; i < datas.length; i++) {
+            if (datas[i].ID == data.nodeID) {
+                for (let pn in data.update){
+                    datas[i][pn] = data.update[pn];
+                };
+                await doc.save();
+                break;
+            }
+        };
+    };
+    return 'saveBlock.OK';
+};

+ 11 - 2
modules/main/facade/project_facade.js

@@ -99,7 +99,16 @@ function generateTasks(data,userID) {
     let deleteInfo={deleted: true, deleteDateTime: new Date(), deleteBy: userID};
     if(data.delete && data.delete.length > 0){
         for(let bd of data.delete){
-            let task={
+            //原先是假删除,现在改成真删除
+            let task = {
+                deleteOne:{
+                    filter:{
+                        ID:bd.ID,
+                        projectID:bd.projectID
+                    }
+                }
+            };
+           /* let task={
                 updateOne:{
                     filter:{
                         ID:bd.ID,
@@ -109,7 +118,7 @@ function generateTasks(data,userID) {
                         deleteInfo:deleteInfo
                     }
                 }
-            };
+            };*/
             tasks.push(task);
         }
     }

+ 57 - 18
modules/main/facade/ration_facade.js

@@ -5,6 +5,7 @@ let mongoose = require('mongoose');
 import SearchDao from '../../complementary_ration_lib/models/searchModel';
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
+let glj_calculate_facade = require("../../ration_glj/facade/glj_calculate_facade");
 let quantity_detail = require("../facade/quantity_detail_facade");
 let ration_glj = mongoose.model('ration_glj');
 let ration_coe = mongoose.model('ration_coe');
@@ -22,6 +23,7 @@ let complementaryRationModel = mongoose.model('complementary_ration_items');
 
 let coeMolde = mongoose.model('std_ration_lib_coe_list');
 let compleCoeModel = mongoose.model('complementary_ration_coe_list');
+
 let _= require('lodash');
 const projectDao = require('../../pm/models/project_model').project;
 let projectModel = mongoose.model('projects');
@@ -34,7 +36,8 @@ module.exports = {
     getSameSectionRations:getSameSectionRations,
     getExtendData:getExtendData,
     getDefaultProgramID:getDefaultProgramID,
-    deleteSubListByQuery:deleteSubListByQuery
+    deleteSubListByQuery:deleteSubListByQuery,
+    updateCoeAdjust:updateCoeAdjust
 };
 async function addNewRation(data,compilation) {
     let query = data.itemQuery;
@@ -258,18 +261,21 @@ async function addRationTemplate(std,newRation) {
     let templateList = [];
     if(std.hasOwnProperty('rationTemplateList') && std.rationTemplateList.length > 0){
         for(let tem of std.rationTemplateList){
-            let template = {
-                billID:"",
-                fxID:"",
-                quantity:"0",
-                coe:"0"
-            };
-            template.code = tem.code;
-            template.name = tem.name;
-            template.type = tem.type;
-            template.unit = tem.unit;
-            template.billsLocation = tem.billsLocation;
-            templateList.push(template)
+            let re_ration = await rationItemModel.findOne({rationRepId:std.rationRepId,ID:tem.rationID});
+            if(re_ration){
+                let template = {
+                    billID:"",
+                    fxID:"",
+                    quantity:"0",
+                    coe:"0"
+                };
+                template.code = re_ration.code;
+                template.name = re_ration.name;
+                template.type = tem.type;
+                template.unit = re_ration.unit;
+                template.billsLocation = tem.billsLocation;
+                templateList.push(template)
+            }
         }
     }
     if(templateList.length > 0){
@@ -304,6 +310,8 @@ async function addRationCoe(std,newRation,compilation) {
                 newCoe.seq = seq;
                 newCoe.name = libCoe.name;
                 newCoe.content = libCoe.content;
+                newCoe.original_code = libCoe.original_code;
+                newCoe.option_codes = libCoe.option_codes;
                 newCoe.isAdjust=0;
                 newCoe.coes = libCoe.coes;
                 newCoe.rationID = newRation.ID;
@@ -418,9 +426,6 @@ async function addRationGLJ(std,newRation,compilation) {
                     std_glj.basePrice =  std_glj.priceProperty[ext.priceField];
                 }
             }
-            console.log("================================get std glj=============================================");
-            console.log(std_glj);
-            let std_gljTime = +new Date();
             if(std_glj){
                 newGLJ.name = std_glj.name;
                 newGLJ.code = std_glj.code;
@@ -442,8 +447,8 @@ async function addRationGLJ(std,newRation,compilation) {
                 newRationGLJList.push(newGLJ);
                 rationGLJShowList.push(info);
             }
-            let InfoFromProjectGLJ = +new Date();
-            console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
+            //let InfoFromProjectGLJ = +new Date();
+            //console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
         }
     }
     let before = +new Date();
@@ -471,6 +476,39 @@ async function deleteSubListByQuery(delete_query) {
     await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
 }
 
+async function updateCoeAdjust(data,compilation) {
+    let replace = [];
+    await ration_coe.update({ID:data.ID},data.doc);
+    //添加单个工料机的情况
+    if (data.add.length > 0)   await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
+    if(data.delete.length > 0) await ration_glj_facade.deleteGLJ(data.delete);
+
+    //替换工料机的情况
+    if (data.replace.length > 0){
+        for(let r of data.replace){
+            replace.push(await  ration_glj_facade.replaceGLJByData(r,compilation)) ;
+        }
+    }
+
+    let cal_result = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID},null,true);
+    let coe = {
+        query:{ID:data.ID,projectID:data.projectID},
+        doc:data.doc
+    };
+    let ration_glj ={
+        quantityRefresh:true,
+        glj_result:cal_result.glj_result
+    };
+    let ration = {
+        ID:cal_result.rationID,
+        adjustState:cal_result.adjustState,
+        name:cal_result.rationName
+    };
+    return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete,replace:replace}
+
+}
+
+
 
 async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
     // insertNewRation
@@ -562,6 +600,7 @@ function createRationAss(std) {
         for(let i=0;i<std.rationAssList.length;i++){
             let ass = std.rationAssList[i];
             ass._doc.actualValue = ass.stdValue;
+            if(_.isString(ass._doc.assistCode)) ass._doc.assistCode = ass._doc.assistCode.replace("\n","");
             rationAssList.push(ass);
         }
     }

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

@@ -71,7 +71,8 @@ class billsModel extends baseModel {
                         break;
                     case commonConsts.UT_DELETE:
                         doc.updateData.deleteInfo = {deleted: true, deleteDateTime: new Date(), deleteBy: user_id};
-                        bills.update({projectID: doc.updateData.projectID, ID: doc.updateData.ID}, doc.updateData, cb);
+                       //bills.update({projectID: doc.updateData.projectID, ID: doc.updateData.ID}, doc.updateData, cb);
+                        bills.deleteOne({projectID: doc.updateData.projectID, ID: doc.updateData.ID},cb);
                         break;
                 }
             }
@@ -181,13 +182,13 @@ class billsModel extends baseModel {
         let deleteInfo = {deleted: true, deleteDateTime: new Date(), deleteBy: userID};
         if(bill_ids.length > 0){
             //删除bills
-            await me.model.updateMany({ID: {$in: bill_ids}, deleteInfo: null}, {$set: {deleteInfo: deleteInfo}});
+            await me.model.deleteMany({ID: {$in: bill_ids}});
             //删除bill-quantity_detail
             await quantityDelModel.deleteMany({billID: {$in: bill_ids}});
         }
         if(ration_ids.length > 0){
             //删除rations
-            await rationModel.updateMany({ID: {$in: ration_ids}, deleteInfo: null}, {$set: {deleteInfo: deleteInfo}});
+            await rationModel.deleteMany({ID: {$in: ration_ids}});
             //删除ration-glj
             await rationGljModel.deleteMany({rationID: {$in: ration_ids}});
             //删除ration-coe

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

@@ -86,8 +86,8 @@ Project.prototype.save = function(datas, callback){
     asyncTool.parallel(functions, function(err, results) {
         if (!err){
             callback(null, '', results)
-        }
-        else{
+        } else{
+            console.log(err);
             callback(1, 'save project failed', null)
         }
     });

+ 19 - 0
modules/main/routes/block_lib_route.js

@@ -0,0 +1,19 @@
+/**
+ * Created by CSL on 2018-12-14.
+ */
+
+let express = require('express');
+let blController = require('../controllers/block_lib_controller');
+
+module.exports = function (app) {
+    let blRouter = express.Router();
+    let funcNames = ['getLibNames', 'getLib', 'getLibNamesAndFirstLib', 'saveBlock'];
+    for (let name of funcNames) {
+        blRouter.post(`/${name}`, blController.doController);
+    }
+    app.use('/blockLib', blRouter);
+}
+
+
+
+

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

@@ -16,5 +16,7 @@ module.exports = function (app) {
     rationRouter.post('/getSameSectionRations', rationController.action);
     rationRouter.post('/getDefaultProgramID', rationController.action);
     rationRouter.post('/applyTemplate', rationController.action);
+    rationRouter.post('/updateRationAss', rationController.action);
+    rationRouter.post('/updateCoeAdjust', rationController.action);
     app.use('/ration', rationRouter);
 };

+ 15 - 12
modules/pm/controllers/pm_controller.js

@@ -251,20 +251,12 @@ module.exports = {
         sessionCompilation = request.session.sessionCompilation;
         //更新用户的使用过的费用定额列表
         let userData = await userModel.findOne({_id: mongoose.Types.ObjectId(request.session.sessionUser.id)}, '-_id used_list');
+        //是否第一次进入该费用定额
+        let isFirst = false;
         if (userData) {
-            let usedCompilation = _.find(userData.used_list, function (o) {
+            isFirst = !_.find(userData.used_list, function (o) {
                 return o.compilationId === compilationData._id.toString();
-            });
-            //第一次使用该费用定额
-            if (!usedCompilation) {
-                await userModel.update({_id: mongoose.Types.ObjectId(request.session.sessionUser.id)}, {$push: {used_list: {compilationId: compilationData._id}}});
-                //拷贝补充定额模板数据
-                await sectionTreeDao.copyDataFromTemplate(request.session.sessionUser.id, compilationData._id);
-                //拷贝例题数据
-                if (sessionCompilation.example && sessionCompilation.example.length > 0) {
-                   await pm_facade.copyExample(request.session.sessionUser.id, sessionCompilation._id, sessionCompilation.example);
-                }
-            }
+            });;
         }
         // 清单计价
         let billValuation = sessionCompilation.bill_valuation !== undefined ?
@@ -281,6 +273,7 @@ module.exports = {
         let absoluteUrl = compilationData.overWriteUrl ? request.app.locals.rootDir + compilationData.overWriteUrl : request.app.locals.rootDir;
         let overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilationData.overWriteUrl : null;
         let renderData = {
+            isFirst: isFirst,
             userAccount: request.session.userAccount,
             userID: request.session.sessionUser.id,
             compilationData: JSON.stringify(sessionCompilation),
@@ -295,6 +288,16 @@ module.exports = {
 
         response.render('building_saas/pm/html/project-management.html', renderData);
     },
+    //第一次进入该费用定额时准备的初始数据
+    prepareInitialData: async function(request, response) {
+        try {
+            let sessionCompilation = request.session.sessionCompilation;
+            await pm_facade.prepareInitialData(request.session.sessionUser.id, sessionCompilation._id, sessionCompilation.example);
+            callback(request, response, 0, 'success', null);
+        } catch(err) {
+            callback(request, response, 1, err, null);
+        }
+    },
     // 获取单价文件列表
     getUnitFileList: async function(request, response) {
         let data = request.body.data;

+ 59 - 5
modules/pm/facade/pm_facade.js

@@ -23,10 +23,15 @@ let rationGLJModel = mongoose.model('ration_glj');
 let rationCoeModel = mongoose.model('ration_coe');
 let rationInstallationModel = mongoose.model('ration_installation');
 let quantityDetailModel = mongoose.model('quantity_detail');
+let userModel = mongoose.model('user');
+let compleGljSectionModel = mongoose.model('complementary_glj_section');
+let compleGljSectionTModel = mongoose.model('complementary_glj_section_templates');
 
 let featureLibModel =  mongoose.model("std_project_feature_lib");
 let scMathUtil = require('../../../public/scMathUtil').getUtil();
 let counter = require('../../../public/counter/counter');
+import SectionTreeDao from '../../complementary_ration_lib/models/sectionTreeModel';
+let sectionTreeDao = new SectionTreeDao();
 import CounterModel from "../../glj/models/counter_model";
 import moment from 'moment';
 import billsFlags from '../../common/const/bills_fixed';
@@ -52,6 +57,7 @@ module.exports={
     projectType: projectType,
     getPosterityProjects: getPosterityProjects,
     isShare: isShare,
+    prepareInitialData: prepareInitialData,
 };
 
 //拷贝例题项目
@@ -180,7 +186,6 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
     projectMap['copy'].document.userID = userID;
     projectMap['copy'].document.compilation = compilationID;
     projectMap['copy'].document.createDateTime = new Date();
-
     //清单、定额ID生成任务
     let IDtasks = [
         createIDsAndReturn(originalID,billsModel),
@@ -188,7 +193,6 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
         getProjectGLJIDAndReturn(originalID,newProjectID)
     ];
     let [billMap,rationMap,projectGLJMap] = await Promise.all(IDtasks);
-
     //所有复制任务异步处理,提升效率  复制清单,定额,4个文件,项目工料机, 定额工料机,人工系数,工程量明细,定额安装增加费,安装增加费
     let copyTasks = [
         createProject(projectMap),
@@ -235,8 +239,11 @@ async function getProjectGLJIDAndReturn(originalID,newProjectID) {
     let IDMap = {};
     let datas = [];
     let result = await gljListModel.find({project_id:originalID}, '-_id');
-    for(let d of result){
-        let newID = await getCounterID("glj_list");
+    let gljCount = await counter.counterDAO.getIDAfterCountSync(counter.moduleName.glj_list, result.length);
+    for(let i = 0; i < result.length; i++){
+        let d = result[i];
+        let newID = gljCount.sequence_value - (result.length - 1) + i;
+        //let newID = await getCounterID("glj_list");
         IDMap[d.id] = newID;
         d._doc.project_id = newProjectID;
         d._doc.id = newID;
@@ -877,4 +884,51 @@ async function isShare(userId, project){
         project = await projectModel.findOne({ID: project.ParentID}, '-_id shareInfo ID ParentID');
     }
     return false;
-}
+}
+
+//用户第一次进入费用定额的数据准备
+async function prepareInitialData(userId, compilation, example) {
+    let prepareTask = [
+        updateUsedList(userId, compilation),
+        copyCompleRationSection(userId, compilation),
+        copyCompleGljSection(userId, compilation)
+    ];
+    if (example && example.length > 0) {
+        prepareTask.push(copyExample(userId, compilation, example));
+    }
+    await Promise.all(prepareTask);
+}
+
+async function updateUsedList(userId, compilation) {
+    await userModel.update({_id: mongoose.Types.ObjectId(userId)}, {$push: {used_list: {compilationId: compilation}}});
+}
+
+//拷贝补充定额章节树
+async function copyCompleRationSection(userId, compilationId) {
+    await sectionTreeDao.copyDataFromTemplate(userId, compilationId);
+}
+//拷贝补充人材机分类树
+async function copyCompleGljSection(userId, compilationId) {
+    let templateData = await compleGljSectionTModel.find({compilationId: compilationId});
+    if (templateData.length > 0) {
+        let insertDatas = [],
+            uuidMapping = {};
+        //将ID替换成UUID
+        for (let temData of templateData) {
+            uuidMapping[temData.ID] = uuidV1();
+        }
+        for(let temData of templateData) {
+            let insertD = {
+                userId: userId,
+                compilationId: compilationId,
+                Name: temData.Name,
+                ID: uuidMapping[temData.ID],
+                ParentID: uuidMapping[temData.ParentID] || -1,
+                NextSiblingID: uuidMapping[temData.NextSiblingID] || -1,
+            };
+            insertDatas.push(insertD);
+        }
+        //插入数据
+        await compleGljSectionModel.insertMany(insertDatas);
+    }
+}

+ 13 - 11
modules/pm/models/project_model.js

@@ -697,18 +697,20 @@ ProjectsDAO.prototype.getProjectProperty = async function (projectId) {
 
 ProjectsDAO.prototype.getExtendData = function(property,compilation) {
     let ext = {};
-    let region = property.region;
-    let taxType = property.taxType;
-    if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
-        let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
-        if(priceProperty){
-            ext['priceField'] =  priceProperty.price.dataCode;
+    if(property){
+        let region = property.region;
+        let taxType = property.taxType;
+        if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
+            let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
+            if(priceProperty){
+                ext['priceField'] =  priceProperty.price.dataCode;
+            }
         }
-    }
-    if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
-        let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
-        if(consumeAmt){
-            ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
+        if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
+            let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
+            if(consumeAmt){
+                ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
+            }
         }
     }
     return _.isEmpty(ext)?null:ext;

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

@@ -24,6 +24,9 @@ module.exports = function (app) {
     /*
      req.body = {data: '{user_id}'}
      */
+
+    pmRouter.post('/prepareInitialData', pmController.prepareInitialData);
+
     pmRouter.post('/getProjects', pmController.getProjects);
     pmRouter.post('/getSummaryInfo', pmController.getSummaryInfo);
 

+ 19 - 0
modules/ration_glj/controllers/ration_glj_controller.js

@@ -10,6 +10,7 @@ module.exports={
     createRationGLJ:createRationGLJ,
     testGetQuantify:testGetQuantify,
     getGLJData:getGLJData,
+    getGLJDataByCodes:getGLJDataByCodes,
     addGLJ:addGLJ,
     replaceGLJ:replaceGLJ,
     mReplaceGLJ:mReplaceGLJ,
@@ -38,6 +39,24 @@ async function testGetQuantify() {
     }
 }
 
+async function getGLJDataByCodes(req,res){
+    let result={
+        error:0
+    }
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let datas= await ration_glj_facade.getGLJDataByCodes(data,req.session.sessionCompilation);
+        result.data=datas;
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+    res.json(result);
+}
+
+
 async function getGLJData(req, res) {
     let result={
         error:0

+ 44 - 17
modules/ration_glj/facade/glj_calculate_facade.js

@@ -66,7 +66,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
          }
          gljList = sortRationGLJ(gljList);
          for(let i =0;i<gljList.length;i++ ){
-             let r = await calculateQuantityPerGLJ(gljList[i],i,coeList,assList,adjustState,noNeedCal);
+             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
              result.glj_result.push(r);
          }
 
@@ -136,7 +136,7 @@ function sortRationGLJ(list) {
     return list;
 }
 
-async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
+async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,noNeedCal) {
     let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
     let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
     let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
@@ -154,7 +154,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
             if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""){
                 quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
                 quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
-                quantity = calculateQuantityByCoes(quantity,coeList,glj);
+                quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
             }else {
                 quantity = glj.customQuantity;
                 result.doc.customQuantity = glj.customQuantity;
@@ -162,11 +162,12 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
             let customerCoe = _.last(coeList);
             if(customerCoe&&customerCoe.isAdjust==1){
                 quantity = scMathUtil.roundToString(quantity,decimal);
-                quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj);
+                quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj,decimal);
             }
             result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
+            glj.quantity = quantity;//这里保存中间过程计算出来的消耗量,后面处理“+*”操作符时要用到
         }
-        generateAdjustState(glj,coeList,adjustState,index,result.doc.quantity);
+        generateAdjustState(glj,coeList,adjustState,gljList,result.doc.quantity);
         return result;
     }catch (err){
         throw err;
@@ -198,7 +199,7 @@ async function calculateAss(quantity,assList,glj) {
     return scMathUtil.roundTo(quantity,-6);
 }
 
-function generateAdjustState(glj,coeList,adjustState,index,quantity) {
+function generateAdjustState(glj,coeList,adjustState,gljList,quantity) {
    //替换工料机 and 添加工料机
     if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
         adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
@@ -208,18 +209,26 @@ function generateAdjustState(glj,coeList,adjustState,index,quantity) {
             displayQuantity = glj.customQuantity;
         }
         displayQuantity = displayQuantity&&displayQuantity!=""?parseFloat(displayQuantity):0;
-        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity});
+        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity,type:"添"+glj.code});
     }
     // to do
 
   //标准附注条件调整 + 自定义乘系数
-    if(0==index){
+    if(_.last(gljList).ID == glj.ID){//最后一个工料机的时候才生成,生成一次就可以了
         for(let i=0;i<coeList.length;i++){
             if(coeList[i].isAdjust==1){
                 if(i==coeList.length-1){
                     adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
                 }else {
-                    adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
+                    if(coeList[i].select_code && coeList[i].select_code!=""){
+                        _.remove(adjustState,{'content':coeList[i].original_code+'换'+coeList[i].select_code});//去掉替换工料机自动生成的调整状态
+                        adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].original_code+'换'+coeList[i].select_code});
+                    }
+                    for(let c of coeList[i].coes){
+                        if(c.coeType=='单个工料机') _.remove(adjustState,{'type':"添"+c.gljCode});//如果是单个工料机子目换算类型自动添加的,去掉前面手动生成的调整状态
+                        if(c.coeType=='替换人材机') _.remove(adjustState,{'content':c.gljCode+'换'+c.replaceCode});//如果是替换人材机子目换算类型自动添加的,去掉前面手动生成的调整状态
+                    }
+                    if(coeList[i].content) adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
                 }
             }
         }
@@ -290,26 +299,30 @@ function calculateTimes(ass){
     return scMathUtil.roundTo(times,-6);
 }
 
-function calculateQuantityByCoes(quantity,coeList,glj){
+function calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal){
     let coeQuantity = quantity;
     if(coeList.length>1){
         for(let i=0;i<coeList.length-1;i++){
-            coeQuantity = everyCoe(coeQuantity,coeList[i],glj);
+            coeQuantity = everyCoe(coeQuantity,coeList[i],glj,gljList,decimal);
         }
     }
     return scMathUtil.roundTo(coeQuantity,-6);
 }
 
-function everyCoe(quantity,coe,glj) {
+function everyCoe(quantity,coe,glj,gljList,decimal) {
     let coeQuantity = quantity;
     if(coe.isAdjust==1){
         for(let i=0;i<coe.coes.length;i++){
-            if(coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+            if(coe.coes[i].coeType=='单个工料机' &&coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
+            }else if(coe.coes[i].coeType== "替换人材机" && glj.rcode == coe.coes[i].gljCode && glj.code == coe.coes[i].replaceCode){
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
+            }else if(coe.coes[i].coeType== "所选人材机" && glj.rcode == coe.original_code && glj.code == coe.select_code ){
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             } else if(coe.coes[i].coeType=='定额'){
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             }else if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             }
         }
     }
@@ -331,7 +344,15 @@ function calculateQuantityByCustomerCoes(quantify,coe,glj) {
     return quantify
 }
 
-function getCalculateResult(quantify,c) {
+function getCoeSelectedGLJ(gljList,rcode,code) {
+    if(gljList&& code && code !=""){
+        let o_glj = _.find(gljList,{'rcode':rcode,'code':code});
+        return o_glj;
+    }
+    return null;
+}
+
+function getCalculateResult(quantify,c,coe,gljList,decimal) {
     let q = quantify;
     switch (c.operator){
         case '+' :
@@ -346,6 +367,12 @@ function getCalculateResult(quantify,c) {
         case '/' :
             q = q / c.amount;
             break;
+        case '+*' :
+            let o_glj = getCoeSelectedGLJ(gljList,coe.original_code,coe.select_code);
+            if(o_glj){
+              q = q +  c.amount * scMathUtil.roundForObj(o_glj.quantity,decimal);
+            }
+            break;
         case '=' :
              q = c.amount;
             break;

+ 18 - 1
modules/ration_glj/facade/ration_ass_facade.js

@@ -13,7 +13,8 @@ let glj_calculate_facade = require('./glj_calculate_facade');
 
 module.exports={
     save:save,
-    getData:getData
+    getData:getData,
+    updateRationAss
 }
 
 let operationMap={
@@ -26,6 +27,22 @@ function create_ration_ass(user_id,datas) {
 
 };
 
+async function updateRationAss(data){
+    let result =await doRationAssAdjust(data.query.ration,data.doc);
+    let ration_glj ={
+        quantityRefresh:true,
+        glj_result:result.cal_result.glj_result
+    }
+    let ration = {
+        ID:result.cal_result.rationID,
+        adjustState:result.cal_result.adjustState,
+        name:result.cal_result.rationName,
+        rationAssList:data.doc.rationAssList
+    };
+    return {ration_glj:ration_glj,ration:ration}
+}
+
+
 function update_ration_ass(user_id,datas) {
     return function (callback) {
         let editAss = datas.query.editAss;

+ 79 - 32
modules/ration_glj/facade/ration_glj_facade.js

@@ -27,6 +27,7 @@ const complementaryGljModel = mongoose.model('complementary_glj_lib');
 const stdGljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 const projectDao = require('../../pm/models/project_model').project;
+const compleClassModel = mongoose.model('complementary_glj_section');
 
 module.exports = {
     save: save,
@@ -35,8 +36,12 @@ module.exports = {
     getQuantityByProjectGLJ: getQuantityByProjectGLJ,
     getLibInfo: getLibInfo,
     getGLJData: getGLJData,
+    getGLJDataByCodes:getGLJDataByCodes,
     addGLJ: addGLJ,
+    deleteGLJ:deleteGLJ,
+    insertAddTypeGLJ:insertAddTypeGLJ,
     replaceGLJ: replaceGLJ,
+    replaceGLJByData:replaceGLJByData,
     mReplaceGLJ: mReplaceGLJ,
     updateRationGLJByEdit: updateRationGLJByEdit,
     getGLJClass: getGLJClass,
@@ -45,7 +50,8 @@ module.exports = {
     getInfoFromProjectGLJ:getInfoFromProjectGLJ,
     createNewRecord:createNewRecord,
     getGLJSearchInfo:getGLJSearchInfo,
-    updateRationGLJFromDoc:updateRationGLJFromDoc
+    updateRationGLJFromDoc:updateRationGLJFromDoc,
+    getGLJLibByEngineerID:getGLJLibByEngineerID
 }
 
 let operationMap = {
@@ -316,7 +322,8 @@ async function doCustomQuantityUpdate(datas) {
 
 function delete_ration_glj(user_id, datas) {
     return function (callback) {
-        callback(new Error("删除子数据失败!"),null)
+        deleteByID(datas, callback);
+        //callback(new Error("删除子数据失败!"),null)
         //这个方法已经不用,先注释,稳定后再删除
        /* if (datas.deleteType == "RATION") {
             deleteByRation(datas, callback);
@@ -382,6 +389,9 @@ function deleteByID(datas, callback) {
         }
     })
 }
+async function deleteGLJ(IDs) {
+    await ration_glj.deleteMany({'ID': {$in: IDs}});
+}
 
 async function deleteAndUpdateState(datas) {
     let result = {
@@ -505,12 +515,10 @@ function save(user_id, datas, callback) {
 }
 
 async function getLibInfo(req) {
-    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation,
-        engineeringLibModel = new EngineeringLibModel() ;
+    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation;
     engineerID = req.params.engineerID;
     if(engineerID){
-        let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
-        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+        gljLibId = await getGLJLibByEngineerID(engineerID);
     }else {
         throw new Error("工程专业ID为空!");
     }
@@ -523,21 +531,27 @@ async function getLibInfo(req) {
     return data;
 }
 
+async function getGLJLibByEngineerID  (engineerID) {
+    let engineeringLibModel = new EngineeringLibModel() ;
+    let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
+    let gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    return gljLibId
+}
+
+
 function getGLJData(info, callback) {
     let gljDao = new GljDao();
     let datas = {};
     let gljDistTypeCache = stdgljutil.getStdGljTypeCacheObj().toArray();
     datas.distTypeTree = gljDistTypeCache;
     async_n.parallel([
-        function (cb) {
-            gljDao.getGljTypes(info.gljLibId, function (err, data) {
-                if (err) {
-                    cb(err);
-                } else {
-                    datas.treeData = data;
-                    cb(null);
-                }
-            })
+        async function (cb) {
+            try {
+                datas.treeData = await gljDao.getMixedTree(info.gljLibId, info.userID, info.compilationId);
+                cb(null);
+            } catch (err) {
+                cb(err);
+            }
         },
         function (cb) {
             gljDao.getGljItems(info.gljLibId, info.userID, info.compilationId, function (err, data) {
@@ -602,8 +616,22 @@ async function prepareExtData(projectID,compilation) {
 
 
 async function addGLJ(rgList,compilation) {
-    let newRecodes = [];
     if (rgList.length <= 0) return {};
+    let newRecodes = await insertAddTypeGLJ(rgList,compilation);
+    let stateResult = await glj_calculate_facade.calculateQuantity({
+        projectID: rgList[0].projectID,
+        rationID: rgList[0].rationID
+    });
+    let result = {
+        newRecodes: newRecodes,
+        showData: rgList,
+        adjustState: stateResult.adjustState
+    };
+    return result;
+}
+
+async function insertAddTypeGLJ(rgList,compilation) {
+    let newRecodes = [];
     let [unitFileId,ext] = await  prepareExtData(rgList[0].projectID,compilation);
     for (let g of rgList) {
         let projectGljModel = new GLJListModel();
@@ -624,21 +652,11 @@ async function addGLJ(rgList,compilation) {
         newRecodes.push(createNewRecord(g));
     }
     await ration_glj.insertMany(newRecodes);
-
-    let stateResult = await glj_calculate_facade.calculateQuantity({
-        projectID: rgList[0].projectID,
-        rationID: rgList[0].rationID
-    });
-    let result = {
-        newRecodes: newRecodes,
-        showData: rgList,
-        adjustState: stateResult.adjustState
-    }
-    return result;
+    return newRecodes;
 }
 
-async function replaceGLJ(data,compilation) {
-    let rdata = {};
+
+async  function replaceGLJByData(data,compilation) {
     let projectGljModel = new GLJListModel();
     let [unitFileId,ext] = await  prepareExtData(data.projectID,compilation);
     let result = await projectGljModel.addList(getGLJSearchInfo(data),unitFileId,ext);
@@ -657,6 +675,13 @@ async function replaceGLJ(data,compilation) {
     if (result.hasOwnProperty('subList') && result.subList.length > 0) {
         data.subList = getMixRatioShowDatas(result.subList);
     }
+    return data;
+}
+
+
+async function replaceGLJ(data,compilation) {
+    let rdata = {};
+    data = await  replaceGLJByData(data,compilation);
     let stateResult = await glj_calculate_facade.calculateQuantity({
         projectID: data.projectID,
         rationID: data.rationID
@@ -778,9 +803,9 @@ async function getGLJClass(info, data) {
         return result
     }
     //查找工料机类型树
-    let items = await gljClassModel.find({
-        "repositoryId": info.gljLibId,
-        "$or": [{"isDeleted": null}, {"isDeleted": false}]
+    let items = await compleClassModel.find({
+        userId: info.userID,
+        compilationId: info.compilationId
     });
     result.items = items;
     return result;
@@ -834,6 +859,28 @@ async function changAdjustState(data, rationList) {
     return stateList;
 }
 
+async function getGLJDataByCodes(data,compilation) {
+  let  gljLibId = await getGLJLibByEngineerID(data.engineerID);
+  let gljDatas = [];
+  if(gljLibId){
+     let stdList =   await  std_glj_lib_gljList_model.find({'repositoryId':gljLibId,code:{'$in':data.codes}});
+     if(stdList.length > 0){
+         let property = await projectDao.getProjectProperty(data.projectID);
+         let ext = projectDao.getExtendData(property,compilation);//多单价处理
+         for(let s of stdList){
+             let tem = JSON.parse(JSON.stringify(s));
+             if(ext && ext.priceField && tem && tem.priceProperty){
+                 tem.basePrice =  tem.priceProperty[ext.priceField];
+             }
+             gljDatas.push(tem);
+
+         }
+     }
+  }
+    return gljDatas
+}
+
+
 async function testError() {
     throw  new Error('test Error');
 }

+ 1 - 0
modules/ration_glj/routes/ration_glj_route.js

@@ -9,6 +9,7 @@ module.exports = function (app) {
 
     var rgRouter = express.Router();
     rgRouter.get('/getGLJData/:engineerID', rgController.getGLJData);
+    rgRouter.post('/getGLJDataByCodes',rgController.getGLJDataByCodes);
     rgRouter.post('/addGLJ',rgController.addGLJ);
     rgRouter.post('/replaceGLJ',rgController.replaceGLJ);
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);

+ 0 - 2
modules/users/controllers/user_controller.js

@@ -57,8 +57,6 @@ class UserController extends BaseController {
                 real_name: request.body.real_name,
                 province: request.body.province,
                 company: request.body.company,
-                company_type: request.body.company_type,
-                company_scale: request.body.company_scale,
                 version: request.body.version
             };
             let sessionUser = request.session.sessionUser;

+ 1 - 0
modules/users/models/user_model.js

@@ -195,6 +195,7 @@ class UserModel extends BaseModel {
             email: userData.email,
             mobile: userData.mobile,
             create_time: new Date().getTime(),
+            latest_login: new Date().getTime(),
         };
         return this.db.create(insertData);
     }

+ 2 - 1
public/counter/counter.js

@@ -20,7 +20,8 @@ const COUNTER_MODULE_NAME = {
     template_bills: 'temp_bills',
     billsLib: 'billsLib',
     coeList: 'coeList',
-    complementaryCoeList: 'complementary_coe_list'
+    complementaryCoeList: 'complementary_coe_list',
+    glj_list: 'glj_list'
 }
 /*const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
     REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'*/

+ 6 - 0
public/scHintBox.html

@@ -77,6 +77,12 @@
         font: function(str){
             return `<span style='color:red;font-weight:bold;font-size:15px'> ${str} </span>`;
         },
+        fontRed: function(str){
+            return `<span style='color:red;'> ${str} </span>`;
+        },
+        fontBlue: function(str){
+            return `<span style='color:blue;'> ${str} </span>`;
+        },
         error: function (err) {   // 注意:该方法只能用在valueBox()的doOK回调函数中。
             $('#hintBox_error').text(err);
             $('#hintBox_error').show(200);

+ 21 - 1
public/web/headerOpr.js

@@ -58,9 +58,29 @@ const CommonHeader = (function () {
             getCategoryList(-1, '联系客服');
         });
     }
-    return {getCategoryList, addEventListener}
+    //取消浏览器自带右键
+    //@return {void}
+    function banNavigatorContextMenu() {
+        document.oncontextmenu = function(event) {
+            if (window.event) {
+                event = window.event;
+            }
+            try {
+                var the = event.srcElement;
+                if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
+                    return false;
+                }
+                return true;
+            } catch (e) {
+                return false;
+            }
+        }
+    }
+    return {getCategoryList, addEventListener, banNavigatorContextMenu};
 })();
 
+CommonHeader.banNavigatorContextMenu();
+
 $(document).ready(function(){
     CommonHeader.addEventListener();
 });

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

@@ -319,7 +319,7 @@ var sheetCommonObj = {
                 $editor.css("position", "fixed");
                 $editor.css("background", "white");
                 //$editor.css("width", cellRect.width); 2018-11-15 改成固定列宽
-                $editor.css("width", 140);
+                $editor.css("width", 160);
                 $editor.attr("gcUIElement", "gcEditingInput");
                 if(htmlGenerator) htmlGenerator(context,cellRect,$editor);
             }

+ 81 - 22
public/web/slideResize.js

@@ -9,11 +9,10 @@
  */
 
 /*
- * div之间的水平拖动,适应各种情况
- * module: 所属模块,防止不同页面相同id导致localstorage数据被覆盖
- * eleObj: resize, parent, left, right
- * limit: min, max
- * */
+* 拖动相关公共接口
+* 前台使用此接口时,注意在恢复系统默认设置时,
+* 清除相关缓存数据: project_view.js--->$('#property_default').click(callback)
+* */
 
 const SlideResize = (function() {
     //设置水平拖动条的宽度
@@ -28,14 +27,29 @@ const SlideResize = (function() {
         let resizeParentWidth = resize.parent().width();
         let resizeDecimalWidth = fixedWidth / resizeParentWidth,
             otherDecimalWidth = 1 - resizeDecimalWidth;
+        if(bros.length > 2){ //当同层有多个子元素时,other 的宽度要排除其余的宽度
+            for(let i = 2; i< bros.length;i++){
+                otherDecimalWidth = otherDecimalWidth - $(bros[i]).width()/resizeParentWidth
+            }
+        }
+
         let resizePercentWidth = resizeDecimalWidth * 100 + '%',
             otherPercentWidth = otherDecimalWidth * 100 + '%';
         resize.css('width', resizePercentWidth);
         other.css('width', otherPercentWidth);
+
+
     }
 
     let mouseMoveCount = 0;
-    function horizontalSlide(module, eleObj, limit, callback) {
+    /*
+     * div之间的水平拖动,适应各种情况
+     * @param {Object}eleObj: module所属模块,防止不同页面相同id导致localstorage数据被覆盖(放在对象里,因为可能有的地方要实时改这个module)
+     *         resize, parent, left, right
+     * @param {Object}limit: min, max
+     * @param {Function}callback 回调
+     * */
+    function horizontalSlide(eleObj, limit, callback) {
         const triggerCBSize = 5;
         let drag = false,
             startPoint = 0,
@@ -57,10 +71,10 @@ const SlideResize = (function() {
                 let moveSize = e.clientX - startPoint;
                 leftChange = leftWidth + moveSize;
                 leftChange = leftChange < limit.min ? limit.min : leftChange;
-                leftChange = leftChange > limitMax ? limitMax - 3 : leftChange;
+                leftChange = leftChange > limitMax ? limitMax - 5 : leftChange;
                 rightChange = rightWidth - moveSize;
                 rightChange = rightChange < limit.min ? limit.min : rightChange;
-                rightChange = rightChange > limitMax ? limitMax - 3 : rightChange;
+                rightChange = rightChange > limitMax ? limitMax - 5 : rightChange;
                 let leftPercentWidth = leftChange / eleObj.parent.width() * 100 + '%',
                     rightPercentWidth = rightChange / eleObj.parent.width() * 100 + '%';
                 eleObj.left.css('width', leftPercentWidth);
@@ -79,9 +93,9 @@ const SlideResize = (function() {
                 mouseMoveCount = 0;
                 //将宽度信息存储到localstorage
                 let leftWidthInfo = eleObj.left[0].style.width;
-                setLocalCache(`${module}${eleObj.left.attr('id')}Width`, leftWidthInfo);
+                setLocalCache(`${eleObj.module}${eleObj.left.attr('id')}Width`, leftWidthInfo);
                 let rightWidthInfo = eleObj.right[0].style.width;
-                setLocalCache(`${module}${eleObj.right.attr('id')}Width`, rightWidthInfo);
+                setLocalCache(`${eleObj.module}${eleObj.right.attr('id')}Width`, rightWidthInfo);
             }
         });
     }
@@ -104,11 +118,12 @@ const SlideResize = (function() {
 
     /*
      * div上下拖动
-     * module: 所属模块,防止不同页面相同id导致localstorage数据被覆盖
-     * eleObj: resize, top, topSpread, bottom, bottomSpread
-     * limit: min, max, notTopSpread(上部分非spread部分的高度) notBottomSpread(下部分非spread部分的高度)
+     * @param {Object} eleObj: module所属模块,防止不同页面相同id导致localstorage数据被覆盖(放在对象里,因为可能有的地方要实时改这个module)
+     *        resize, top, topSpread, bottom, bottomSpread
+     * @param {Object}limit: min, max, notTopSpread(上部分非spread部分的高度) notBottomSpread(下部分非spread部分的高度)
+     * @param {Function}callback 回调
      * */
-    function verticalSlide(module, eleObj, limit, callback) {
+    function verticalSlide(eleObj, limit, callback) {
         const triggerCBSize = 5;
         let drag = false,
             startPoint = 0,
@@ -130,10 +145,10 @@ const SlideResize = (function() {
                 let moveSize = e.clientY - startPoint;
                 topChange = topHeight + moveSize;
                 topChange = topChange < limit.min ? limit.min : topChange;
-                topChange = topChange > limitMax ? limitMax - 3 : topChange;
+                topChange = topChange > limitMax ? limitMax : topChange;
                 bottomChange = bottomHeight - moveSize;
                 bottomChange = bottomChange < limit.min ? limit.min : bottomChange;
-                bottomChange = bottomChange > limitMax ? limitMax - 3 : bottomChange;
+                bottomChange = bottomChange > limitMax ? limitMax : bottomChange;
 
                 //设置上部分div高度
                 eleObj.top.height(topChange);
@@ -156,18 +171,19 @@ const SlideResize = (function() {
                 mouseMoveCount = 0;
                 //将高度信息存储到localstorage
                 let topHeightInfo = eleObj.top.height();
-                setLocalCache(`${module}${eleObj.top.attr('id')}Height`, topHeightInfo);
+                setLocalCache(`${eleObj.module}${eleObj.top.attr('id')}Height`, topHeightInfo);
                 let bottomHeightInfo = eleObj.bottom.height();
-                setLocalCache(`${module}${eleObj.bottom.attr('id')}Height`, bottomHeightInfo);
+                setLocalCache(`${eleObj.module}${eleObj.bottom.attr('id')}Height`, bottomHeightInfo);
             }
         });
     }
 
     /*
      * 加载上下高度
-     * module: 所属模块,防止不同页面相同id导致localstorage数据被覆盖
-     * eleObj: top, topSpread, bottom, bottomSpread
-     * limit: totalHeight(实时的上下部分总高度) notTopSpread(上部分非spread部分的高度) notBottomSpread(下部分非spread部分的高度)
+     * @param {String}module 所属模块,防止不同页面相同id导致localstorage数据被覆盖
+     * @param {Object}eleObj: module所属模块,防止不同页面相同id导致localstorage数据被覆盖(放在对象里,因为可能有的地方要实时改这个module) top, topSpread, bottom, bottomSpread
+     * @param {Object}limit: totalHeight(实时的上下部分总高度) notTopSpread(上部分非spread部分的高度) notBottomSpread(下部分非spread部分的高度)
+     * @param {Function}callback 回调
      * */
 
     function loadVerticalHeight(module, eleObj, limit, callback) {
@@ -195,5 +211,48 @@ const SlideResize = (function() {
         }
     }
 
-    return {horizontalSlide, loadHorizonWidth, verticalSlide, loadVerticalHeight}
+    /*
+    * 包含多个上下结构的拖动(n>= 2,只包含上下结构的地方可以用loadVerticalHeight)
+    * 加载多个结构高度
+    * @param {String}module所属模块,防止不同页面相同id导致localstorage数据被覆盖
+    * @param {Array}eles 元素为结构对象 内部: {container: 外部div, spread: 该div的Spread, notSpread: 该div不含Spread的高度, defaultProportion: 默认高度比例0.6}
+    * @param {String}totalHeight 各个结构div总高度-可编译字符串
+    * @param {Function}callback 回调
+    * */
+    function loadMultiVerticalHeight(module, eles, totalHeight, callback) {
+        //当前窗口拖动区域总高度
+        totalHeight = eval(totalHeight);
+        let cacheHeight = 0,//缓存中设置了高度的div总高度
+            notCacheProportion = 0;//缓存中没设置高度的div占用的总高度比例(每个div都有默认的高度比例) (有了缓存高度的div就是被拖动过的,被拖动过的div,其默认高度比例就没用了)
+        //获取缓存的总高度、未被拖动过的所有div的默认比例之和notCacheProportion (1-notCacheProportion)就是缓存高度的占总的比例
+        for (let ele of eles) {
+            let eleHeight = getLocalCache(`${module}${ele.container.attr('id')}Height`);
+            if (eleHeight !== null) {
+                eleHeight = parseFloat(eleHeight);
+                cacheHeight += eleHeight;
+            } else {
+                notCacheProportion += ele.defaultProportion;
+            }
+        }
+        //缓存高度占总的比例
+        let cacheProportion = 1 - notCacheProportion;
+        for (let ele of eles) {
+            let eleHeight = getLocalCache(`${module}${ele.container.attr('id')}Height`),
+                curHeight = 0;
+            if (eleHeight !== null) {
+                eleHeight = parseFloat(eleHeight);
+                //ele在当前窗口大小中的高度
+                curHeight = eleHeight / cacheHeight * cacheProportion * totalHeight;
+            } else {
+                curHeight = ele.defaultProportion * totalHeight;
+            }
+            ele.container.height(curHeight);
+            ele.spread.height(curHeight - ele.notSpread);
+        }
+        if (callback) {
+            callback();
+        }
+    }
+
+    return {setResizeWidth, horizontalSlide, loadHorizonWidth, verticalSlide, loadVerticalHeight, loadMultiVerticalHeight}
 })();

+ 9 - 3
public/web/tree_sheet/tree_sheet_helper.js

@@ -529,7 +529,10 @@ var TREE_SHEET_HELPER = {
 
         if(isRationNode){
             TreeNodeCellType.prototype.createEditorElement = function (context) {
-                return document.createElement("div");
+                let div = document.createElement("div");
+                div.setAttribute("gcUIElement", "gcEditingInput");
+                $(div).attr("id", 'rationCheckBox');
+                return div;
             };
 
             TreeNodeCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
@@ -551,6 +554,10 @@ var TREE_SHEET_HELPER = {
                 return $editor;
             };
 
+            TreeNodeCellType.prototype.deactivateEditor = function (editorContext, context) {
+                    console.log("hehe")
+            };
+
             TreeNodeCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
                 let me = this;
                 $(editorContext).append(`<div><ul class="es-list" style="display: block;"></ul></div>`);//<li class="" data-value="" style=""> <br></li> //background-color:${cellStyle.backColor}
@@ -584,7 +591,7 @@ var TREE_SHEET_HELPER = {
                     });
                     if( $('#esInput').val()) setCursor( $("#esInput")[0], $('#esInput').val().length)
                 });
-
+                console.log("update")
             };
 
             TreeNodeCellType.prototype.processKeyDown = function (e, context){ //当用isReservedKey 不拦截编辑模式时的input框ctrl + c时,在非编辑模式的ctrl + c事件也需要自已处理,所以在这里再调用一下复制命令
@@ -599,7 +606,6 @@ var TREE_SHEET_HELPER = {
                  $('#esInput').val(value);
             };
             TreeNodeCellType.prototype.getEditorValue = function (editor, context) {
-                console.log($('#esInput').val());
                 return  $('#esInput').val()!==''? $('#esInput').val():null;
             };
 

+ 2 - 2
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html

@@ -67,7 +67,7 @@
                 </div>
                 <div class="modal-body" style="padding-left: 0; padding-right: 3px; margin-left: 0;">
                         <div style="width: 36%; float: left;">
-                            <input type="radio" class="glj-radio" name="glj" value="allGljs">所有&nbsp;&nbsp;
+                            <!--<input type="radio" class="glj-radio" name="glj" value="allGljs">所有&nbsp;-->&nbsp;
                             <input type="radio" class="glj-radio" name="glj" value="stdGljs">标准&nbsp;&nbsp;
                             <input type="radio" class="glj-radio" name="glj" value="complementaryGljs">补充&nbsp;&nbsp;
                             <div  class="modal-auto-height" id="componentTreeDiv" style="overflow: hidden">
@@ -98,8 +98,8 @@
                         </div>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
                     <a href="javascript:void(0);" id="componentsConf" class="btn btn-primary">确定</a>
+                    <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>
             </div>
         </div>

+ 34 - 10
web/building_saas/complementary_glj_lib/js/components.js

@@ -7,6 +7,7 @@
 let componentOprObj = {
     treeObj:null,
     rootNode: null,//分类树根节点
+    parentNodeIds: {},
     radiosSelected: null,//allGljs, stdGljs, complementaryGljs
     workBook: null,
     selectedList: [],//选中的组成物
@@ -98,6 +99,24 @@ let componentOprObj = {
                 }
             }
     },
+    //初始化分类树
+    //@param {String}type(标准或补充) {Array}treeData(树数据)
+    initClassTree: function (type, treeData) {
+        let me = this;
+        if (me.treeObj) {
+            me.treeObj.destroy();
+            me.parentNodeIds = {};
+        }
+        zTreeHelper.createTree(treeData, componentSetting, "componentTree", componentOprObj);
+        let rootNode = componentOprObj.treeObj.getNodes()[0];
+        if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+            componentOprObj.rootNode = rootNode;
+        }
+        if(me.rootNode){
+            me.treeObj.selectNode(me.rootNode);
+            componentTypeTreeOprObj.onClick(null, 'componentTree', me.rootNode);
+        }
+    },
     //初始默认radio
     initRadio: function () {
         let that = repositoryGljObj, me = componentOprObj;
@@ -108,13 +127,13 @@ let componentOprObj = {
         if(typeof $("input[name='glj']:checked")[0] !== 'undefined'){
             $("input[name='glj']:checked")[0].checked = false;
         }
-        $("input[value = 'allGljs']")[0].checked = true;
-        me.radiosSelected = 'allGljs';
+        $("input[value = 'stdGljs']")[0].checked = true;
+        me.radiosSelected = 'stdGljs';
         //初始为所有工料机,机械类型可添加机械组成物,混凝土,砂浆、配合比可添加普通材料
         me.showGljList = [];
-        if(me.radiosSelected === 'allGljs'){
+        if(me.radiosSelected === 'stdGljs'){
             me.setShowGljList(that.stdGljList, true);
-            me.setShowGljList(that.complementaryGljList, true);
+            //me.setShowGljList(that.complementaryGljList, true);
             that.sortGlj(me.showGljList);
         }
     },
@@ -147,8 +166,8 @@ let componentOprObj = {
         me.showGljItems(me.showGljList, me.gljCurTypeId);
         //切换radio后更新cache
         if (me.currentOprParent = 1) {
-            if(re.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
-                me.currentCache = me.getParentCache(re.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
+            if(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
+                me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
             }
             else{
                 me.currentCache = [];
@@ -159,8 +178,13 @@ let componentOprObj = {
     },
     //监听radios选择事件
     radiosChange: function () {
-        let me = componentOprObj, re = repositoryGljObj;
+        let me = componentOprObj, gc = gljClassTreeObj;
         $('.glj-radio').change(function () {
+            if($(this).val() === 'stdGljs') {
+                me.initClassTree('std', gc.treeData.std);
+            } else {
+                me.initClassTree('comple', gc.treeData.comple);
+            }
             me.filterDatasAndShow();
         });
     },
@@ -192,7 +216,7 @@ let componentOprObj = {
         let me = componentOprObj, re = repositoryGljObj;
         if (me.workBook) {
             let cacheSection = [];
-            let pArr = re.parentNodeIds["_pNodeId_" + type];
+            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]);
@@ -248,9 +272,9 @@ let componentTypeTreeOprObj = {
         let me = componentOprObj, re = repositoryGljObj, that = gljComponentOprObj, gljTypeId = treeNode.ID;
         if(me.gljCurTypeId !== treeNode.ID){
             me.gljCurTypeId = treeNode.ID;
-            if (re.parentNodeIds["_pNodeId_" + treeNode.ID]) {
+            if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
                 me.currentOprParent = 1;
-                me.currentCache = me.getParentCache(re.parentNodeIds["_pNodeId_" + treeNode.ID]);
+                me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
             } else {
                 me.currentCache = me.getCache();
             }

+ 48 - 35
web/building_saas/complementary_glj_lib/js/glj.js

@@ -4,40 +4,41 @@
 
 $(document).ready(function () {
     let moduleName = 'compleGLj';
-    function refreshALlWorkBook() {
-        if (gljClassTreeObj.workBook) {
-            gljClassTreeObj.workBook.refresh();
-        }
-        if (repositoryGljObj.workBook) {
-            repositoryGljObj.workBook.refresh();
-        }
-        if (gljComponentOprObj.workBook) {
-            gljComponentOprObj.workBook.refresh();
-        }
-    }
     SlideResize.loadHorizonWidth(moduleName, [$('#rightResize'), $('#leftResize')], [$('#leftContent'), $('#midContent'), $('#rightContent')], function () {
         refreshALlWorkBook();
     });
     //章节树与人材机表
     let leftElesObj = {};
+    leftElesObj.module = moduleName;
     leftElesObj.resize = $('#leftResize');
     leftElesObj.parent = $('#dataRow');
     leftElesObj.left = $('#leftContent');
     leftElesObj.right = $('#midContent');
-    SlideResize.horizontalSlide(moduleName, leftElesObj, {min: 200, max: `$('#dataRow').width() - $('#rightContent').width() - 200`}, function () {
+    SlideResize.horizontalSlide(leftElesObj, {min: 200, max: `$('#dataRow').width() - $('#rightContent').width() - 200`}, function () {
         refreshALlWorkBook();
     });
     //人材机表与人材机组成物表
     let rightElesObj = {};
+    rightElesObj.module = moduleName;
     rightElesObj.resize = $('#rightResize');
     rightElesObj.parent = $('#dataRow');
     rightElesObj.left = $('#midContent');
     rightElesObj.right = $('#rightContent');
-    SlideResize.horizontalSlide(moduleName, rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
+    SlideResize.horizontalSlide(rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
         refreshALlWorkBook();
     });
 });
-
+function refreshALlWorkBook() {
+    if (gljClassTreeObj.workBook) {
+        gljClassTreeObj.workBook.refresh();
+    }
+    if (repositoryGljObj.workBook) {
+        repositoryGljObj.workBook.refresh();
+    }
+    if (gljComponentOprObj.workBook) {
+        gljComponentOprObj.workBook.refresh();
+    }
+}
 let pageOprObj = {
     gljLibName : null,
     stdGljLibId: null,
@@ -113,7 +114,7 @@ let repositoryGljObj = {
         let me = this;
         let distType;
         let distTypeTree = {
-            prefix : 'gljType',
+            prefix: 'gljType',
             distTypes: {},
             comboDatas: [],
             distTypesArr: []
@@ -123,24 +124,20 @@ let repositoryGljObj = {
                 data: typeData,
                 children: [],
                 parent: null
-            };
-            if(allowGljType.includes(typeData.ID)){
-                distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
-                distTypeTree.distTypesArr.push(typeObj);
             }
+            distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
+            distTypeTree.distTypesArr.push(typeObj);
         });
         gljDistType.forEach(function (typeData) {
-            if(allowGljType.includes(typeData.ID)){
-                distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
-                let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
-                if(parent){
-                    distType.parent = parent;
-                    parent.children.push(distType);
-                }
+            distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
+            let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
+            if (parent) {
+                distType.parent = parent;
+                parent.children.push(distType);
             }
         });
         distTypeTree.distTypesArr.forEach(function (distTypeObj) {
-            if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
+            if (distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械') {
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
         });
@@ -173,6 +170,7 @@ let repositoryGljObj = {
         });
     },
     getGljItems: function(stdGljLibId, callback) {
+        console.log('enterGG');
         let me = this;
         CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId}, function (rstData) {
             me.stdGljList = rstData.stdGljs;
@@ -190,12 +188,6 @@ let repositoryGljObj = {
             if(callback){
                 callback();
             }
-         /*   let rootNode = me.treeObj.getNodes()[0];
-            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
-                componentOprObj.rootNode = rootNode;
-                me.treeObj.selectNode(rootNode);
-                gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
-            }*/
         });
     },
     showGljItems: function(data, type) {
@@ -395,7 +387,7 @@ let repositoryGljObj = {
         }
     },
     initSel: function (row) {
-        let me = repositoryGljObj, that = gljComponentOprObj;
+        let me = repositoryGljObj, that = gljComponentOprObj, componentCanEdit = false;
         sheetOpr.cleanData(that.workBook.getSheet(0), that.setting, -1);
         me.workBook.focus(true);
         me.currentComponent = [];
@@ -404,6 +396,7 @@ let repositoryGljObj = {
             //标记当前工料机
             me.currentGlj = me.currentCache[row];
             if(allowComponent.includes(me.currentCache[row].gljType)){
+                componentCanEdit = true;
                 //展示数据
                 if(me.currentGlj.component.length > 0){
                     me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
@@ -416,6 +409,26 @@ let repositoryGljObj = {
         else{
             me.currentGlj = null;
         }
+
+        //组成物表能编辑则显示,否则隐藏该工作表
+        let rightWidth = getLocalCache('compleGLjrightContentWidth') || '25%';
+        rightWidth = rightWidth.replace('%', '');
+        let curMidWidth = $('#midContent')[0].style.width.replace('%', ''),
+            curRightWidth = $('#rightContent')[0].style.width.replace('%', '');
+        if (componentCanEdit && curRightWidth === '0') {
+            curMidWidth = parseFloat(curMidWidth) - parseFloat(rightWidth);
+            $('#midContent').css('width', `${curMidWidth}%`);
+            $('#rightContent').css('width', `${rightWidth}%`);
+        } else if(!componentCanEdit && curRightWidth !== '0') {
+            curMidWidth = parseFloat(curMidWidth) + parseFloat(rightWidth);
+            $('#midContent').css('width', `${curMidWidth}%`);
+            $('#rightContent').css('width', `0%`);
+        }
+        //减少触发
+        if (me.preComponentCanEdit !== componentCanEdit) {
+            refreshALlWorkBook();
+        }
+        me.preComponentCanEdit = componentCanEdit;
     },
     onEnterCell: function (sender, args) {
         let me = repositoryGljObj;
@@ -1111,7 +1124,7 @@ let repositoryGljObj = {
         // }
     },
     updateRationBasePrcRq: function (basePrcArr) {
-        CommonAjax.post('complementartGlj/api/updateRationBasePrc', {basePrcArr: basePrcArr}, function (rstData) {
+        CommonAjax.post('/complementartGlj/api/updateRationBasePrc', {basePrcArr: basePrcArr}, function (rstData) {
         });
     },
   /*  getRationGljIds: function (repId) {

+ 11 - 6
web/building_saas/complementary_glj_lib/js/gljClassTree.js

@@ -2,6 +2,7 @@
  * Created by Zhong on 2018/1/16.
  */
 let gljClassTreeObj = {
+    treeData: null,
     cache: null,//ref to tree.items
     tree: null,
     controller: null,
@@ -110,22 +111,25 @@ let gljClassTreeObj = {
     },
 
     getGljClassTree: function (gljLibId, callback) {
+        console.log('enter1');
         let me = gljClassTreeObj;
         let re = repositoryGljObj;
-        let url = 'complementartGlj/api/getGljTree';
+        let url = '/complementartGlj/api/getMixedTree';
         let postData = {gljLibId: gljLibId};
         let sucFunc = function (rstData) {
-            zTreeHelper.createTree(rstData, componentSetting, "componentTree", componentOprObj);
+            me.treeData = rstData;
+            let compleTreeData = me.treeData.comple;
+            /*zTreeHelper.createTree(rstData.std, componentSetting, "componentTree", componentOprObj);
             let rootNode = componentOprObj.treeObj.getNodes()[0];
             if(rootNode && rootNode.isParent && rootNode.isFirstNode){
                 componentOprObj.rootNode = rootNode;
-            }
-            if (rstData && rstData.length > 0) {
-                me.gljCurTypeId = rstData[0].ID;
+            }*/
+            if (compleTreeData && compleTreeData.length > 0) {
+                me.gljCurTypeId = compleTreeData[0].ID;
             }
             //init
             me.buildSheet();
-            me.initTree(rstData);
+            me.initTree(compleTreeData);
             me.cache = me.tree.items;
             re.updateParentNodeIds(me.cache, re);
             me.initController(me.tree, me.sheet, me.setting.sheet);
@@ -177,6 +181,7 @@ let gljClassTreeObj = {
             re.currentCache = re.getCache();
         }
         re.showGljItems(re.complementaryGljList, gljTypeId);
+        re.initSel(re.workBook.getSheet(0).getActiveRowIndex());
         me.workBook.focus(true);
     }
 }

+ 13 - 6
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -18,9 +18,19 @@ let gljComponentOprObj = {
             lockedCols:[0, 1, 2, 3]
         }
     },
+    buildHeader: function (sheet, header) {
+        sheet.setRowCount(2, GC.Spread.Sheets.SheetArea.colHeader);
+        for (let i = 0; i < header.length; i++) {
+            sheet.setValue(1, i, header[i].headerName, GC.Spread.Sheets.SheetArea.colHeader);
+            sheet.setColumnWidth(i, header[i].headerWidth? header[i].headerWidth:100);
+        }
+        sheet.setValue(0, 0, '组成物信息', GC.Spread.Sheets.SheetArea.colHeader);
+        sheet.addSpan(0, 0, 1, header.length, GC.Spread.Sheets.SheetArea.colHeader);
+    },
     buildSheet: function(container) {
         let me = gljComponentOprObj;
-        me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
+        me.workBook = sheetOpr.buildSheet(container, me.setting, 30, false);
+        me.buildHeader(me.workBook.getSheet(0), me.setting.header);
         sheetCommonObj.spreadDefaultStyle(me.workBook);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
@@ -85,10 +95,7 @@ let gljComponentOprObj = {
                                 co.initRadio();
                                 co.gljCurTypeId = null;
                                 //默认点击树根节点
-                                if(co.rootNode){
-                                    co.treeObj.selectNode(co.rootNode);
-                                    componentTypeTreeOprObj.onClick(null, 'componentTree', co.rootNode);
-                                }
+                                co.initClassTree('std', gljClassTreeObj.treeData.std);
                                 //弹出窗口
                                 $('#component').modal('show');
                             }},
@@ -433,7 +440,7 @@ let gljComponentOprObj = {
                 if(row + i < that.currentComponent.length){
                     let currentObj = that.currentComponent[row + i];
                     if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
-                        let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), 3);
+                        let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
                         isChange = true;
                         currentObj.consumeAmt = roundCons;
                         for(let j = 0; j < component.length; j++){

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

@@ -34,7 +34,7 @@ let sheetOpr = {
         sheet.resumePaint();
     },
 
-    buildSheet: function(container, setting, rowCount) {
+    buildSheet: function(container, setting, rowCount, buildHeader = true) {
         var me = this;
         var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });
         spreadBook.options.tabStripVisible = false;
@@ -60,7 +60,9 @@ let sheetOpr = {
         };
         sheet.showRowOutline(false);
         //setup column header
-        me.buildHeader(sheet, setting);
+        if (buildHeader) {
+            me.buildHeader(sheet, setting);
+        }
         //setup cells
         if (rowCount > 0) sheet.setRowCount(rowCount);
         sheet.resumeEvent();

+ 55 - 17
web/building_saas/complementary_ration_lib/html/dinge.html

@@ -18,6 +18,19 @@
     <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico">
     <link rel="icon" type="image/gif" href="/web/building_saas/css/animated_favicon1.gif">
     <style type="text/css">
+        div.resize-y{
+            height: 10px;
+            background: #efefef;
+            width: 100%;
+            cursor: s-resize;
+        }
+        div.resize-x{
+            width: 1%;
+            height: 100%;
+            background: #efefef;
+            cursor: w-resize;
+            float: left;
+        }
         .ztree * {
             font-family: Calibri;
             font-size: 0.9rem;
@@ -75,18 +88,20 @@
     <div class="content" style="margin-left: 0px">
         <div class="container-fluid">
             <div class="row" id="dataRow">
-                <div class="main-side p-0" style="width: 25%; height: 100%; overflow: hidden" id="leftContentg">
-                    <div class="tab-bar">
-                        <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
-                        <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                        <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                        <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                        <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                        <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
-                    </div>
-                    <div class="tab-content" id="sectionSpread" style="overflow: hidden">
-                        <!--<ul id="rationChapterTree" class="ztree"></ul>-->
+                <div class="main-side p-0" id="leftContent" style="width: 25%; height: 100%; overflow: hidden">
+                    <div style="width: 99%; float: left">
+                        <div class="tab-bar">
+                            <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
+                            <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                            <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                            <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                            <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                            <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                        </div>
+                        <div class="tab-content" id="sectionSpread" style="overflow: hidden">
+                        </div>
                     </div>
+                    <div class="resize-x" id="slideResizeLeft"></div>
                 </div>
                 <div class="main-content p-0" id="mainContent" style="width: 75%">
                     <!-- 右标签 -->
@@ -112,8 +127,9 @@
                         <div class="tab-pane active" id="tde" role="tabpanel">
                             <!--定额top-->
                             <div id="rationItemsSheet" class="main-data-top"></div>
+                            <div class="resize-y" id="rationSubResize"></div>
                             <!--定额bottom-->
-                            <div class="bottom-content">
+                            <div class="bottom-content" id="subContent">
                                 <!-- 标签 -->
                                 <ul class="nav nav-tabs" role="tablist">
                                     <li class="nav-item">
@@ -186,10 +202,11 @@
                     </div>
                 </div>
                 <div class="main-side p-0 main-side-right" id="zmhsContent" style="width: 25%; display: none">
-                    <div class="resize" id="rightResize" style="width: 1%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
+                    <div class="resize-x" id="slideResizeRight"></div>
                     <div style="width: 99%; float: left">
                         <div class="main-data-top-fluid" id="mainSpread">
                         </div>
+                        <div class="resize-y" id="zmhsAdjResize"></div>
                         <div class="bottom-content" id="contentSpread">
                         </div>
                     </div>
@@ -501,12 +518,13 @@
             </div>
             <div class="modal-body" style="padding-left: 0; padding-right: 3px; margin-left: 0;">
                 <div style="width: 36%; float: left;">
+                    &nbsp;
+                    <input type="radio" class="glj-radio" name="glj" value="stdGljs">标准&nbsp;&nbsp;
+                    <input type="radio" class="glj-radio" name="glj" value="complementaryGljs">补充&nbsp;&nbsp;
                     <div  class="modal-auto-height" id="gljSelTreeDiv" style="overflow: hidden">
-                        <!--<div class="print-list">-->
                         <div style="width: 100%; height: 100%; overflow: auto">
                             <ul id="selGljTree" class="ztree"></ul>
                         </div>
-                        <!--</div>-->
                     </div>
                 </div>
                 <div style="width: 64%; padding-left: 3px; float: left;">
@@ -514,9 +532,9 @@
                         <div class="col-12" id="gljRadios">
                             <div class="row">
                                 <div class="col-7" style="margin-top: 5px;">
-                                    <input type="radio" class="glj-radio" name="glj" value="allGljs">所有&nbsp;&nbsp;
+                                  <!--  <input type="radio" class="glj-radio" name="glj" value="allGljs">所有&nbsp;&nbsp;
                                     <input type="radio" class="glj-radio" name="glj" value="stdGljs">标准&nbsp;&nbsp;
-                                    <input type="radio" class="glj-radio" name="glj" value="complementaryGljs">补充&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="complementaryGljs">补充&nbsp;&nbsp;-->
                                 </div>
                                 <div class="input-group col-5" style="margin-bottom: 5px;">
                                     <input type="text" class="form-control form-control-sm" placeholder="请输入筛选编码或名称" value="" id="gljSearchKeyword">
@@ -556,6 +574,26 @@
         </div>
     </div>
 </div>
+<div class="modal fade" id="delRationAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <input type="hidden"  value="123">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">警告</h5>
+                <button type="button"  class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <h5 class="text-danger">是否删除当前节点及其子项?</h5>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-danger" id="delRationConfirm">确认</button>
+                <button type="button" class="btn btn-secondary"  data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
 <!-- JS. -->
 <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
 <script>GC.Spread.Sheets.LicenseKey =  '<%- LicenseKey %>';</script>

+ 2 - 2
web/building_saas/complementary_ration_lib/html/gongliao.html

@@ -48,9 +48,9 @@
                 <!--  <li class="nav-item">
                       <a class="nav-link px-3" id="fuzhu" href="<%= redirectCoe %>">子目换算</a>
                   </li>-->
-                  <li class="nav-item">
+                  <!--<li class="nav-item">
                       <a class="nav-link px-3" id="anzhuang" href="<%= redirectInstallation %>">安装增加费</a>
-                  </li>
+                  </li>-->
               </ul>
         </nav>
     </div>

+ 154 - 20
web/building_saas/complementary_ration_lib/js/coe.js

@@ -3,35 +3,169 @@
  */
 //modiyied by zhong on 2017/9/21
 
-let moduleName = 'compleRation';
 $(document).ready(function () {
+    let moduleName = 'compleRation';
+    function refreshALlWorkBook() {
+        if (sectionTreeObj.workBook) {
+            sectionTreeObj.workBook.refresh();
+        }
+        if (rationOprObj.workBook) {
+            rationOprObj.workBook.refresh();
+        }
+        if (rationGLJOprObj.sheet && rationGLJOprObj.sheet.getParent()) {
+            rationGLJOprObj.sheet.getParent().refresh();
+        }
+        if (coeOprObj.workBook) {
+            coeOprObj.workBook.refresh();
+        }
+        if (gljAdjOprObj.workBook) {
+            gljAdjOprObj.workBook.refresh();
+        }
+    }
+    //定额章节树与定额表
+    let leftElesObj = {};
+    leftElesObj.module = moduleName;
+    leftElesObj.resize = $('#slideResizeLeft');
+    leftElesObj.parent = $('#dataRow');
+    leftElesObj.left = $('#leftContent');
+    leftElesObj.right = $('#mainContent');
+    let maxEval = `$('#zmhsContent').is(':visible') ? $('#dataRow').width() - $('#zmhsContent').width() - 300 : $('#dataRow').width()  - 300`;
+    SlideResize.horizontalSlide(leftElesObj, {min: 300, max: maxEval}, function () {
+        refreshALlWorkBook();
+    });
+    SlideResize.loadHorizonWidth(moduleName, [$('#slideResizeLeft')], [$('#leftContent'), $('#mainContent')], function () {
+        //refreshAfterZmhs(false);
+        let leftContentWidth = parseFloat($('#leftContent')[0].style.width.replace('%', '')),
+            mainContentWidth = parseFloat($('#mainContent')[0].style.width.replace('%', ''));
+        let surplus = 100 - leftContentWidth - mainContentWidth;
+        $('#leftContent').css('width', `${leftContentWidth + surplus / 2}%`);
+        $('#mainContent').css('width', `${mainContentWidth + surplus / 2}%`);
+
+        refreshALlWorkBook();
+    });
     //定额表与子目换算表
     let rightElesObj = {};
-    rightElesObj.resize = $('#rightResize');
+    rightElesObj.module = moduleName;
+    rightElesObj.resize = $('#slideResizeRight');
     rightElesObj.parent = $('#dataRow');
     rightElesObj.left = $('#mainContent');
     rightElesObj.right = $('#zmhsContent');
-    SlideResize.horizontalSlide(moduleName, rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
-        pageOprObj.refreshAllBooks();
+    let maxEvalRight = `$('#dataRow').width() - $('#leftContent').width() - 200`;
+    SlideResize.horizontalSlide(rightElesObj, {min: 200, max: maxEvalRight}, function () {
+        refreshALlWorkBook();
     });
-});
-
-$('#zmhs').click(function () {
-    if(!$(this).hasClass('active')){
-        $(this).addClass('active');
-        $('#mainContent').css('width', '50%');
-        $('#zmhsContent').show();
-        SlideResize.loadHorizonWidth(moduleName, [$('#mainContent'), $('#zmhsContent')], function () {
-            pageOprObj.refreshAllBooks();
-        });
-    } else {
-        $(this).removeClass('active');
-        $('#mainContent').css('width', '75%')
-        $('#zmhsContent').hide();
-        rationOprObj.workBook.refresh();
-        rationGLJOprObj.sheet.getParent().refresh();
+    //设置水平拖动条的宽度
+    //@param {Object dom}resize滚动条
+    function setResizeWidth (resize) {
+        const fixedWidth = 10;
+        //跟滚动条同层的其他节点
+        let bros = resize.parent().children();
+        //滚动条节点 及 同层非滚动条节点的索引
+        let index = bros.index(resize),
+            otherIndex = index ? 0 : 1;
+        const other = resize.parent().children(`:eq(${otherIndex})`);
+        let resizeParentWidth = resize.parent().width();
+        let resizeDecimalWidth = fixedWidth / resizeParentWidth,
+            otherDecimalWidth = 1 - resizeDecimalWidth;
+        let resizePercentWidth = resizeDecimalWidth * 100 + '%',
+            otherPercentWidth = otherDecimalWidth * 100 + '%';
+        resize.css('width', resizePercentWidth);
+        other.css('width', otherPercentWidth);
+    }
+    function refreshAfterZmhs(visible) {
+        const min = 20;
+        //宽度比例localstorage key
+        let leftContentKey = `${moduleName}${$('#leftContent').attr('id')}Width`,
+            mainContentKey = `${moduleName}${$('#mainContent').attr('id')}Width`,
+            zmhsContentKey = `${moduleName}${$('#zmhsContent').attr('id')}Width`;
+        let zmhsWidth = getLocalCache(zmhsContentKey) ? getLocalCache(zmhsContentKey) :$('#zmhsContent')[0].style.width,
+            mainContentWidth = $('#mainContent')[0].style.width,
+            leftContentWidth;
+        zmhsWidth = parseFloat(zmhsWidth.replace('%', ''));
+        mainContentWidth = parseFloat(mainContentWidth.replace('%', ''));
+        if (visible) {
+            mainContentWidth = mainContentWidth - zmhsWidth / 2 < min ? min : mainContentWidth - zmhsWidth / 2;
+            if (100 - mainContentWidth - zmhsWidth < min) {
+                leftContentWidth = min;
+                zmhsWidth = 100 - mainContentWidth - leftContentWidth;
+            } else {
+                leftContentWidth = 100 - mainContentWidth - zmhsWidth;
+            }
+        } else {
+            mainContentWidth += zmhsWidth / 2;
+            leftContentWidth = 100 - mainContentWidth;
+        }
+        $('#leftContent').css('width', `${leftContentWidth}%`);
+        setLocalCache(leftContentKey, `${leftContentWidth}%`);
+        $('#mainContent').css('width', `${mainContentWidth}%`);
+        setLocalCache(mainContentKey, `${mainContentWidth}%`);
+        $('#zmhsContent').css('width', `${zmhsWidth}%`);
+        setLocalCache(zmhsContentKey, `${zmhsWidth}%`);
+        let resizes = [$('#slideResizeLeft'), $('#slideResizeRight')];
+        for (let resize of resizes) {
+            setResizeWidth(resize);
+        }
     }
+    $('#zmhs').click(function () {
+        if(!$(this).hasClass('active')){
+            $(this).addClass('active');
+            refreshAfterZmhs(true);
+            $('#zmhsContent').show();
+            if(!coeOprObj.workBook){
+                pageObj.initPage();
+            }
+            refreshALlWorkBook();
+        } else {
+            $(this).removeClass('active');
+            refreshAfterZmhs(false);
+            $('#zmhsContent').hide();
+            refreshALlWorkBook();
+        }
+    });
+    //子目换算和调整表上下拖动
+    let zmhsAdjResize = getZmhsAdjResize();
+    SlideResize.verticalSlide(zmhsAdjResize.eleObj, zmhsAdjResize.limit, function () {
+        if (coeOprObj.workBook) {
+            coeOprObj.workBook.refresh();
+        }
+        if (gljAdjOprObj.workBook) {
+            gljAdjOprObj.workBook.refresh();
+        }
+    });
+    loadZmhsAdjSize(zmhsAdjResize);
 });
+function getZmhsAdjResize() {
+    let zmhsAdjResize = {};
+    zmhsAdjResize.eleObj = {
+        module: 'compleRation',
+        resize: $('#zmhsAdjResize'),
+        top: $('#mainSpread'),
+        topSpread: $('#mainSpread'),
+        bottom: $('#contentSpread'),
+        bottomSpread: $('#contentSpread')
+    };
+    zmhsAdjResize.limit = {
+        min: 150,
+        max: `$(window).height()-$('.header').height()-150-10`,
+        totalHeight: `$(window).height()-$('.header').height()-10`,
+        notTopSpread: 0,
+        notBottomSpread: 0,
+    };
+    return zmhsAdjResize;
+}
+function loadZmhsAdjSize(resizeObj) {
+    if (!resizeObj) {
+        resizeObj = getZmhsAdjResize();
+    }
+    SlideResize.loadVerticalHeight(resizeObj.eleObj.module, resizeObj.eleObj, resizeObj.limit, function () {
+        if (coeOprObj.workBook) {
+            coeOprObj.workBook.refresh();
+        }
+        if (gljAdjOprObj.workBook) {
+            gljAdjOprObj.workBook.refresh();
+        }
+    });
+}
 
 var pageObj = {
     initPage: function (){

+ 32 - 11
web/building_saas/complementary_ration_lib/js/gljSelect.js

@@ -62,16 +62,32 @@ let gljSelOprObj = {
             }
         });
     },
+    initClassTree: function (type, treeData) {
+        let me = this;
+        if (me.treeObj) {
+            me.treeObj.destroy();
+            me.parentNodeIds = {};
+        }
+        zTreeHelper.createTree(treeData, gljSelTreeOprObj.setting, "selGljTree", me);
+        let rootNode = me.treeObj.getNodes()[0];
+        if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+            me.rootNode = rootNode;
+        }
+        if(me.rootNode){
+            me.treeObj.selectNode(me.rootNode);
+            if ((me.stdGljList && me.stdGljList.length > 0) ||
+                (me.complementaryGljList && me.complementaryGljList.length > 0)) {
+                gljSelTreeOprObj.setting.callback.onClick(null, 'selGljTree', me.rootNode);
+            }
+        }
+    },
     getGljClassTree: function (gljLibId, callback) {
         let me = this;
-        let url = '/complementartGlj/api/getGljTree';
+        let url = '/complementartGlj/api/getMixedTree';
         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;
-            }
+            me.treeData = rstData;
+            me.initClassTree('std', me.treeData.std);
             gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
             if(callback){
                 callback();
@@ -166,13 +182,13 @@ let gljSelOprObj = {
         if(typeof $("input[name='glj']:checked")[0] !== 'undefined'){
             $("input[name='glj']:checked")[0].checked = false;
         }
-        $("input[value = 'allGljs']")[0].checked = true;
-        me.radiosSelected = 'allGljs';
-        //初始为所有工料机
+        $("input[value = 'stdGljs']")[0].checked = true;
+        me.radiosSelected = 'stdGljs';
+        //初始为标准工料机
         me.showGljList = [];
-        if(me.radiosSelected === 'allGljs'){
+        if(me.radiosSelected === 'stdGljs'){
             me.setShowGljList(me.stdGljList, true);
-            me.setShowGljList(me.complementaryGljList, true);
+            //me.setShowGljList(me.complementaryGljList, true);
             me.sortGlj(me.showGljList);
         }
     },
@@ -219,6 +235,11 @@ let gljSelOprObj = {
     radiosChange: function () {
         let me = gljSelOprObj;
         $('.glj-radio').change(function () {
+            if($(this).val() === 'stdGljs') {
+                me.initClassTree('std', me.treeData.std);
+            } else {
+                me.initClassTree('comple', me.treeData.comple);
+            }
             me.filterDatasAndShow();
         });
     },

+ 3 - 1
web/building_saas/complementary_ration_lib/js/global.js

@@ -12,7 +12,7 @@ function autoFlashHeight(){
     $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
     $(".main-data-top-fluid").height($(window).height()-headerHeight-bottomContentHeight-2);
     $(".main-data").height($(window).height()-headerHeight);
-    $(".main-side .tab-content").height($(window).height()-headerHeight-38);
+    $(".main-side .tab-content").height($(window).height()-headerHeight-29);
     $('#partialBody').height($(window).height()-headerHeight-toolsBar - 60);
     let partialWidth = $('#tablePartial').width();
     $('#tablePartial').find('th:eq(0)').width(partialWidth * 0.06);
@@ -25,6 +25,8 @@ function autoFlashHeight(){
     $('#explanationShow').height($(window).height()-headerHeight-toolsBar-100);
 //计算规则
     $('#ruleTextShow').height($(window).height()-headerHeight-toolsBar-100);
+    typeof loadRationSubSize !== 'undefined' ? loadRationSubSize() : '';
+    typeof loadZmhsAdjSize !== 'undefined' ? loadZmhsAdjSize() : '';
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/

+ 68 - 16
web/building_saas/complementary_ration_lib/js/ration.js

@@ -2,6 +2,59 @@
  * Created by Tony on 2017/4/28.
  */
 
+$(document).ready(function () {
+    //定额表与下方子表上下拖动
+    let rationSubResize = getRationSubResize();
+    SlideResize.verticalSlide(rationSubResize.eleObj, rationSubResize.limit, function () {
+        if (rationOprObj.workBook) {
+            rationOprObj.workBook.refresh();
+        }
+        if (rationGLJOprObj.sheet && rationGLJOprObj.sheet.getParent()) {
+            rationGLJOprObj.sheet.getParent().refresh();
+        }
+    });
+    SlideResize.loadVerticalHeight(rationSubResize.eleObj.module, rationSubResize.eleObj, rationSubResize.limit, function () {
+        if (rationOprObj.workBook) {
+            rationOprObj.workBook.refresh();
+        }
+        if (rationGLJOprObj.sheet && rationGLJOprObj.sheet.getParent()) {
+            rationGLJOprObj.sheet.getParent().refresh();
+        }
+    });
+});
+function getRationSubResize() {
+    let rationSubResize = {};
+    rationSubResize.eleObj = {
+        module: 'compleRation',
+        resize: $('#rationSubResize'),
+        top: $('#rationItemsSheet'),
+        topSpread: $('#rationItemsSheet'),
+        bottom: $('#subContent'),
+        bottomSpread: $('#rdSpread')
+    };
+    rationSubResize.limit = {
+        min: 150,
+        max: `$(window).height()-$('.header').height()-$('.tools-bar').height()-150-10`,
+        totalHeight: `$(window).height()-$('.header').height()-$('.tools-bar').height()-10`,
+        notTopSpread: 0,
+        notBottomSpread: $('#subContent ul').height(),
+    };
+    return rationSubResize;
+}
+function loadRationSubSize(resizeObj) {
+    if (!resizeObj) {
+        resizeObj = getRationSubResize();
+    }
+    SlideResize.loadVerticalHeight(resizeObj.eleObj.module, resizeObj.eleObj, resizeObj.limit, function () {
+        if (rationOprObj.workBook) {
+            rationOprObj.workBook.refresh();
+        }
+        if (rationGLJOprObj.sheet && rationGLJOprObj.sheet.getParent()) {
+            rationGLJOprObj.sheet.getParent().refresh();
+        }
+    });
+}
+
 const digital = {
     gljPrc: -3,//计算定额基价时单个工料机价格取三位
     rationBasePrc: -2,
@@ -214,15 +267,14 @@ let rationOprObj = {
                         callback: function(){},
                         items: {
                             "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
-
                                 let removeInfo = `确定要删除定额 “${ration.code}” 及其下的所有数据吗?`;
                                 $('#delRationAlert').find('.modal-body h5').text(removeInfo);
                                 $('#delRationAlert').modal('show');
+                                $('#delRationConfirm').unbind('click');
                                 $('#delRationConfirm').bind('click', function () {
                                     me.rationsCodes.splice(me.rationsCodes.indexOf(ration.code.toString()), 1);
                                     me.mixDel = 1;
                                     me.mixUpdateRequest([], [], [ration.ID]);
-                                    $('#delRationConfirm').unbind('click');
                                     $('#delRationAlert').modal('hide');
                                 });
                             }}
@@ -418,12 +470,12 @@ let rationOprObj = {
                 if(rObj.code && rObj.code.toString().trim().length > 0){
                     if(me.rationsCodes.indexOf(rObj.code.toString()) === -1){
                         //jobContent
-                        if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                       /* if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                             rObj.jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
                         }
                         if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
                             rObj.annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
-                        }
+                        }*/
                         me.setInitPrc(rObj);
                         if (rObj.code && rObj.code !== '') {
                             rObj.code = rObj.code.toUpperCase();
@@ -481,12 +533,12 @@ let rationOprObj = {
                 if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
                     if(me.rationsCodes.indexOf(items[i].code.toString()) === -1){
                         //jobConten
-                        if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                        /*if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                             items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
                         }
                         if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
                             items[i].annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
-                        }
+                        }*/
                         me.setInitPrc(items[i]);
                         addArr.push(items[i]);
                         me.rationsCodes.push(items[i].code.toString());
@@ -529,12 +581,12 @@ let rationOprObj = {
                     //是否含有已存在的编号
                     if(me.rationsCodes.indexOf(items[i].code.toString()) === -1){
                         //jobConten
-                        if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                       /* if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
                             items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
                         }
                         if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
                             items[i].annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
-                        }
+                        }*/
                         me.setInitPrc(items[i]);
                         addArr.push(items[i]);
                     }
@@ -594,7 +646,7 @@ let rationOprObj = {
             me.rationSelInit(curRow);
             //add
             //jobContent
-            if(jobContentOprObj ){
+            /*if(jobContentOprObj ){
                 jobContentOprObj.currentRationItems = cacheSection;
                 jobContentOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, jobContentOprObj.radios);
                 if(cacheSection.length === 0){
@@ -614,7 +666,7 @@ let rationOprObj = {
                 if(annotationOprObj.currentSituation === annotationOprObj.situations.PARTIAL){
                     annotationOprObj.buildTablePartial(annotationOprObj.fzTablePartial, annotationOprObj.getGroup(cacheSection));
                 }
-            }
+            }*/
             me.showRationItems(me.currentSectionId);
             me.mixUpdate = 0;
             me.mixDel = 0;
@@ -631,10 +683,10 @@ let rationOprObj = {
             me.currentSectionId = sectionID;
             if (me.currentRations["_SEC_ID_" + sectionID]) {
                 //jobContent--
-                jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
-                jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
+               /* jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
+                jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);*/
                 //annotation
-                annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
+                //annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                 me.showRationItems(sectionID);
                 sectionTreeObj.removeBtn.removeClass('disabled');
                 if(callback){
@@ -645,10 +697,10 @@ let rationOprObj = {
                     me.currentRations["_SEC_ID_" + sectionID] = rstData;
                     me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
                     //job--
-                    jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
-                    jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
+                    /*jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
+                    jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);*/
                     //annotation
-                    annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
+                    //annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                     me.showRationItems(sectionID);
                     sectionTreeObj.removeBtn.removeClass('disabled');
                     if(callback) {

+ 1 - 5
web/building_saas/complementary_ration_lib/js/ration_glj.js

@@ -136,11 +136,7 @@ var rationGLJOprObj = {
                                 //默认radio所有工料机
                                 gljSelOprObj.initRadio();
                                 gljSelOprObj.gljCurTypeId = null;
-                                //默认点击树根节点
-                                if(gljSelOprObj.rootNode){
-                                    gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
-                                    gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
-                                }
+                                gljSelOprObj.initClassTree('std', gljSelOprObj.treeData.std);
                                 //弹出窗口
                                 $('#selGlj').modal('show');
                             }},

+ 15 - 24
web/building_saas/complementary_ration_lib/js/section_tree.js

@@ -26,29 +26,20 @@ let pageOprObj = {
     gljLibId: gljLibId,
     initPage : function() {
         let me = this;
-       // me.getRationLibInfo(rationLibId, function (rstData) {
-            //if(rstData.length > 0){
-                //me.rationLibName = rstData[0].dispName;
-                //let $rationName = $(`<div id='rationname' class='navbar-text'><a id='rationLibBtn' href='javascript:void(0);'>定额库</a><i class='fa fa-angle-right fa-fw'></i>${me.rationLibName}</div>`);
-                //let $rationName = $(`<div id='rationname' class='navbar-text'>${me.rationLibName}</div>`);
-               // $('.header-logo').after($rationName);
-              //  me.gljLibId = rstData[0].gljLib;
-                sectionTreeObj.getSectionTree();
-                //job
-                jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
-                $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
-                $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
-                jobContentOprObj.bindAllEvents($('#txtareaAll'));
-                //fz
-                annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
-                $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
-                $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
-                annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
-           // }
-            gljSelOprObj.getGljClassTree(gljLibId, function () {
-                    gljSelOprObj.getSelGljItems(gljLibId);
-            });
-       // });
+        sectionTreeObj.getSectionTree();
+        //job
+        jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
+        $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
+        $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
+        jobContentOprObj.bindAllEvents($('#txtareaAll'));
+        //fz
+        annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
+        $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
+        $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
+        annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
+        gljSelOprObj.getGljClassTree(gljLibId, function () {
+            gljSelOprObj.getSelGljItems(gljLibId);
+        });
     },
     getRationLibInfo: function (rationLibId, callback) {
         CommonAjax.post('api/getRationLib', {rationRepId: rationLibId}, callback);
@@ -274,7 +265,7 @@ let sectionTreeObj = {
             me.setColor(me.cache);
             me.sheet.setFormatter(-1, 0, '@');
             me.initSelection(me.tree.selected);
-            explanatoryOprObj.bindEvents($('#explanationShow'), $('#ruleTextShow'));
+            //explanatoryOprObj.bindEvents($('#explanationShow'), $('#ruleTextShow'));
         };
         let errFunc = function () {
 

+ 22 - 2
web/building_saas/css/custom.css

@@ -11,10 +11,23 @@ label.title{
 
 div.resize{
     height: 10px;
-    background: #f7f7f9;
+    background: #efefef;
     width: 100%;
     cursor: s-resize;
 }
+div.resize-y{
+    height: 10px;
+    background: #efefef;
+    width: 100%;
+    cursor: s-resize;
+}
+div.resize-x{
+    width: 1%;
+    height: 100%;
+    background: #efefef;
+    cursor: w-resize;
+    float: left;
+}
 /*.zlfb-check{
     margin-left: 20px;
 }*/
@@ -261,7 +274,6 @@ legend.legend{
 .item_spread{
     width: 29.8%;
     float: left;
-    margin-top: -5px;
     background: #F1F1F1;
     word-wrap:break-word
 }
@@ -275,4 +287,12 @@ input.text-right{
 }
 .more{
     padding-left:.25rem!important
+}
+.bottom-tznrTools {
+    height: 30px;
+    line-height: 30px;
+    background:#efefef;
+    bottom:30px;
+    left:0px;
+    z-index: 999
 }

+ 62 - 8
web/building_saas/css/main.css

@@ -36,7 +36,7 @@ a{
     font-size: 1rem;
     height:38px;
     background:url(logo.png) no-repeat 0 0;
-    padding-left:40px;
+    padding-left:50px;
 }
 .header-logo div.v-title{
     font-size:11px;
@@ -169,6 +169,9 @@ a{
 .main-side.col-lg-0{
     width:0%;
 }
+.sidebar-middle{
+    height:80px;
+}
 .sidebar-bottom,.sidebar-bottom .col-lg-6,.sidebar-bottom .col-lg-12 {
     height:300px
 }
@@ -185,6 +188,14 @@ a{
     border-radius: 0;
     padding: 0.2em 0.5em
 }
+.bottom-tools {
+    height: 30px;
+    line-height: 30px;
+    background:#fff;
+    bottom:20px;
+    left:22px;
+    z-index: 999
+}
 .side-tabs .nav-tabs .nav-item {
     z-index: 999
 }
@@ -314,7 +325,7 @@ a{
 .bottom-content .tab-content .ovf-hidden{
     overflow: hidden;
 }
-.tn-nav{
+.tn-nav,.rn-nav{
     width:30px;
     height: 100%;
     border-left:1px solid #dee2e6 ;
@@ -326,6 +337,34 @@ a{
     background:#f7f7f9;
     cursor: pointer;
 }
+.rn-nav {
+    background: #f7f7f9
+}
+.rn-nav .nav{
+    padding: 0
+}
+.rn-nav .nav-tabs {
+    border:none;
+    margin-top:2px;
+}
+.rn-nav .nav-tabs .nav-link{
+    padding:0.8em 0.4em;
+    line-height: 16px
+}
+.rn-nav .nav-tabs .nav-link.active {
+    border:none;
+    background-color: #fff;
+    border-left:1px solid #fff;
+    margin-left:-1px;
+    border-top:1px solid #ccc;
+    border-bottom:1px solid #ccc;
+}
+.rn-nav .nav-tabs .nav-link span{
+    display:none;
+}
+.rn-nav .nav-tabs .nav-link.active span{
+    display: inline-block;
+}
 .form-signin {
     max-width: 500px;
     margin: 150px auto;
@@ -493,10 +532,25 @@ a{
 .navbar-crumb .f-nav li.focus .s-nav{
     display: block
 }
-.bottom-tools {
-    height: 30px;
-    line-height: 30px;
-    background:#F1F1F1;
-    bottom:30px;
-    left:2px;
+/*书签颜色*/
+.annotate-color-1{
+    background: #E2F2C5
+}
+.annotate-color-2{
+    background: #F9E2CF
+}
+.annotate-color-3{
+    background: #F2EFD9
+}
+.annotate-color-4{
+    background: #F5D1DA
+}
+.annotate-color-5{
+    background: #E3E3E3
+}
+.annotate-color-6{
+    background: #B6F3F2
 }
+.annotate-color-7{
+    background: #ECE0F5
+}

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

@@ -3,7 +3,7 @@
         display: none;
     }
 </style>
-<div class="toolsbar px-1">
+<div class="toolsbar px-1" id="projectGljToolsBar">
     <div class="form-inline py-1">
         <label class="mx-2">当前使用:<span id="current-name"></span>(<label class="a_color" id="pop-used-list" data-original-title="" title=""><span id="used-project-count">0</span>个单位工程使用</label>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-unitFile"><i class="fa fa-exchange"></i> 选择其他</a>
@@ -30,12 +30,12 @@
             </ul>
         </div>
         <div class="main-content col p-0 col-lg-11" id="project-glj-main">
-            <div class="top-content">
+            <div class="top-content" id="projectGljTop">
                 <div class="main-data-top" style="width: 100% " id="project_glj_sheet">
                 </div>
             </div>
-            <div class="resize"></div>
-            <div class="bottom-content">
+            <div class="resize-y" id="projectGljResize"></div>
+            <div class="bottom-content" id="projectGljBottom">
                 <ul class="nav nav-tabs" role="tablist">
                   <!--  <li class="nav-item">
                         <a class="nav-link active" data-toggle="tab" data-name="ration_sheet" id="ration_link" href="#glj_de_div" role="tab">相关定额</a>

+ 1 - 0
web/building_saas/js/global.js

@@ -33,6 +33,7 @@ function autoFlashHeight(){
     $(".form-list").height($(window).height()-headerHeight);
     $('#comments').find('textarea').height($('#comments').height() - 25);
     typeof(adaptiveTzjnrWidth)== 'function' ?adaptiveTzjnrWidth():''
+    //typeof zmhs_obj === 'object' ? zmhs_obj.loadSideResize() : '';
 };
 
 

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 367 - 251
web/building_saas/main/html/main.html


+ 9 - 2
web/building_saas/main/js/controllers/block_controller.js

@@ -242,8 +242,15 @@ let BlockController = {
         if(blockData.firstNodeType == blockType.RATION){ //复制的是定额,需根据新的父项信息和工程量明细计算工程量
             for(let d of blockData.datas){
                 d.billsItemID = parentID;
-                let billsQuantity = scMathUtil.roundForObj(parent.data.quantity,getDecimal("quantity",parent));
-                this.calcRationQuantityAndContain(billsQuantity,d,parent.data.unit);
+                if (blockData.zeroQuantity){   // 来自克隆块
+                    d.quantity = 0;
+                    d.quantityEXP = '';
+                    d.contain = '';
+                }else{
+                    let billsQuantity = scMathUtil.roundForObj(parent.data.quantity,getDecimal("quantity",parent));
+                    this.calcRationQuantityAndContain(billsQuantity,d,parent.data.unit);
+                }
+
                 //如果粘贴位置不属于分部分项工程,或者不是安装工程,则把安装增加费内容置空
                 if(!Bills.isFBFX(parent)|| !project.isInstall()){
                     d.ration_installations = [];

+ 57 - 20
web/building_saas/main/js/controllers/material_controller.js

@@ -2,6 +2,7 @@
  * Created by zhang on 2018/9/12.
  */
 let MaterialController = {
+    moduleName: 'subRcj', //模块名
     subSpreadDivWidth:"",
     showItemText:false,
     //规则相关映射
@@ -168,6 +169,7 @@ let MaterialController = {
             return;
         }
         $("#subSpread").addClass("ration_glj_spread");
+        $('#itemTextDiv').show();
         $("#replaceM").show();
         $("#rgResize").show();// 拖动调整大小功能添加
         // 2018-11-07 需求变更,这个项目特征替换表格暂时隐藏不删除,以后可能还要用,先把项目初始化这句注释掉
@@ -218,15 +220,47 @@ let MaterialController = {
         if(selected&&parent){
             text = parent.data.itemCharacterText?parent.data.itemCharacterText.replace(/\n/g,"<br>"):"";
         }
-        if(text == "") {//为空的时候不显示
+       /* if(text == "") {//为空的时候不显示
             $("#replaceM").hide();
             $("#subSpread").removeClass("ration_glj_spread");
             $('#subSpread').css('width','');
             return;
+        }*/
+        //$('#replaceM').css('margin-top',0);
+        //this.toggleItemInit();
+        $("#itemCharacterText").html("<br>"+text);
+    },
+    //初始化人材机和项目特征文本两个区域的宽度,改变窗口大小时调用此方法,实时刷新
+    initItemWidth: function () {
+        //总宽度
+        let totalWidth = $('#subItems').width();
+        //人材机和项目特征文本比例
+        const openWidth = 30;//打开项目特征工具条
+        let textVisible = $('#replaceText').is(':visible'),
+            //默认比例
+            textPercent = '15%',
+            rcjPercent = '85%';
+        //文本没显示,则打开工具条固定30px转换百分比
+        if (!textVisible) {
+            textPercent = openWidth / totalWidth;
+            rcjPercent = 1 - textPercent;
+            textPercent = textPercent * 100 + '%';
+            rcjPercent = rcjPercent * 100 + '%';
+        }
+        //设置特征及内容与排版规则的比例
+        if ($('#replaceM').is(':visible')) {//显示工具条
+            $('#subSpread').css('width', rcjPercent);
+            $('#itemTextDiv').css('width', textPercent);
+            //打开了项目特征,则继续加载人材机表和项目特征文本具体比例
+            if (this.showItemText === true) {
+                let rg_sideResizeEles = MaterialController.getSideResize();
+                SlideResize.loadHorizonWidth(rg_sideResizeEles.eleObj.module,
+                    [rg_sideResizeEles.eleObj.resize], [rg_sideResizeEles.eleObj.left, rg_sideResizeEles.eleObj.right]);
+            }
+        } else {//不显示工具条
+            $('#subSpread').css('width', '100%');
         }
-        $('#replaceM').css('margin-top',0);
-        this.toggleItemInit();
-        $("#replaceText").html(text);
+
     },
     toggleItemInit:function () {
         if(this.showItemText == true){
@@ -235,20 +269,14 @@ let MaterialController = {
             $("#replaceText").show();
             $("#closeItemText").show();
             $("#rgResize").show();
-            let swidth =  this.subSpreadDivWidth == ""? $("#bottom_div").width()*0.83:this.subSpreadDivWidth;
-            swidth = parseFloat(swidth);
-            $('#subSpread').css('width',swidth);
-            $('#replaceM').css('width',$("#bottom_div").width()-$("#rgResize").width()-swidth);
+            this.initItemWidth();
         }else {
             $("#replaceM").addClass("ovf-hidden");
             $("#openItemText").show();
             $("#replaceText").hide();
             $("#closeItemText").hide();
             $("#rgResize").hide();
-            $('#replaceM').css('width',30);
-            $('#subSpread').css('width',$("#bottom_div").width()-30);
-
-
+            this.initItemWidth();
         }
     },
     getItems:function(characterText){
@@ -287,21 +315,30 @@ let MaterialController = {
             }
             if(!_.isEmpty(doc)) this.postReplace([{glj:ration_glj,doc:doc}]);
         }
+    },
+    getSideResize: function () {
+        let rg_sideResizeEles = {};
+        rg_sideResizeEles.eleObj = {
+            module: this.moduleName,
+            resize: $('#rgResize'),
+            parent: $('#subItems'),
+            left: $('#subSpread'),
+            right: $('#itemTextDiv')
+        };
+        rg_sideResizeEles.limit = {
+            min: 100,
+            max: `$('#subItems').width()-100`
+        };
+        return rg_sideResizeEles;
     }
 };
 
-let rg_sideResizeEles = {};
-rg_sideResizeEles.id = 'tabRG';
-rg_sideResizeEles.resize = $('#rgResize');
-rg_sideResizeEles.nearElement = $('#subSpread');
-rg_sideResizeEles.farElement = $('#replaceM');
-rg_sideResizeEles.nav = null;
-slideResize(rg_sideResizeEles, {min: 100, max: $('#tabCon').width()-100}, 'width', function(){
+let rg_sideResizeEles = MaterialController.getSideResize();
+SlideResize.horizontalSlide(rg_sideResizeEles.eleObj, rg_sideResizeEles.limit, function(){
     MaterialController.subSpreadDivWidth = $('#subSpread').css('width');
     refreshSubSpread();
 });
 
-
 $(function (){
     $("#openItemText").click(function () {
         MaterialController.showItemText = true;

+ 30 - 0
web/building_saas/main/js/controllers/project_controller.js

@@ -233,6 +233,36 @@ ProjectController = {
         } else {
             alert('当前焦点行不是定额,无法替换。');
         }
+    },
+    addNewNodes:function (updateData){
+        let controller = projectObj.mainController;
+        let Bill = projectObj.project.Bills;
+        let newAddNode = [];
+        let newRationNodes = [];
+        for(let nb of updateData.bills.add){
+            let newSource = Bill.tree.insertByData(nb, nb.ParentID, -1, true);//按顺序插入的情况下,nextID为-1,树节点
+            let newNode = projectObj.project.mainTree.insert(nb.ParentID, -1, newSource.data.ID);
+            newNode.source = newSource;
+            newNode.sourceType = Bill.getSourceType();
+            newNode.data = newSource.data;
+            controller.sheet.addRows(newNode.serialNo(), 1);
+           // controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
+            newAddNode.push(newNode);
+            Bill.datas.push(nb);
+        }
+        for(let nr of updateData.ration.add){
+            let newNode = projectObj.project.mainTree.insert(nr.billsItemID, -1, nr.ID);
+            newNode.source = nr;
+            newNode.sourceType = projectObj.project.Ration.getSourceType();
+            newNode.data = nr;
+            controller.sheet.addRows(newNode.serialNo(), 1);
+           // controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
+            newAddNode.push(newNode);
+            newRationNodes.push(newNode);
+            projectObj.project.Ration.datas.push(nr);
+        }
+        TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
+        return newRationNodes;
     }
 /*    addVolumePrice: function (project, sheetController) {
         if (!project || !sheetController) { return null; }

+ 20 - 145
web/building_saas/main/js/main.js

@@ -1,7 +1,6 @@
 /**
  * Created by Mai on 2017/3/10.
  */
-
 $(function () {
     loadMainSize();
     $("#header-menu").removeAttr('style');
@@ -27,15 +26,14 @@ $(function () {
 
     $('#tab_report').on('shown.bs.tab', function(e){
         sessionStorage.setItem('mainTab', '#tab_report');
+        autoFlashHeight();
     });
-
-    slideResize(getMainResizeEles(), {min: 170, max: 700}, 'height', function() {
+    let mainResizeEles = getMainResizeEles();
+    SlideResize.verticalSlide(mainResizeEles.eleObj, mainResizeEles.limit, function(){
         projectObj.mainSpread.refresh();
         refreshSubSpread();
-        //zmhs_obj.refresh();
         $('#comments').find('textarea').height($('#comments').height() - 25);
     });
-
     const projectId = scUrlUtil.GetQueryString('project');
     // 绑定点击事件
     projectObj.mainSpread.bind(GC.Spread.Sheets.Events.CellClick, function(sender, info) {
@@ -52,156 +50,33 @@ $(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');
+    mainResizeEles.eleObj = {
+        module: 'mainVertical',
+        resize: $('#mainVerticalResize'),
+        top: $('#top_div'),
+        topSpread: $('#top_div').children('.main-data-top'),
+        bottom: $('#bottom_div'),
+        bottomSpread: $('#bottom_div').children().find('.main-data-bottom'),
+    };
+    mainResizeEles.limit = {
+        min: 150,
+        max: `$(window).height()-$('.header').height()-$('#headerToolsBar').height()-150-10`,
+        notTopSpread: 0,
+        notBottomSpread: $('#bottom_div ul').height(),
+        totalHeight: `$(window).height()-$('.header').height()-$('#headerToolsBar').height()-10`
+    };
     return mainResizeEles;
 }
 
 function loadMainSize() {//加载造价书页面各高度
     // 读取本地存储的高度(必须放在载入spread之前)
-    let mainResizeEles = getMainResizeEles() ;
-    loadSize(mainResizeEles, 'height', function() {
+    let mainResizeEles = getMainResizeEles();
+    SlideResize.loadVerticalHeight(mainResizeEles.eleObj.module, mainResizeEles.eleObj, mainResizeEles.limit, function () {
         refreshSubSpread();
         zmhs_obj.refresh();
     });
 }
 
-let mouseMoveCount = 0;
-
-/**
- * 拖动更改div大小
- *
- * @param {Object} eles - id:存储本地的标记 resize:拖动条 nearElement:左上外层div nearSpread:左上spread farElement:右下外层div evFixedSize:造价书左右拖动用
- * @param {Object} limit - min/max
- * @param {String} type - height/width
- * @param {function} callback - 成功后执行
- * @return {void}
- */
-function slideResize(eles, limit, type, callback) {
-    if(type !== 'height' && type !== 'width'){
-        return;
-    }
-    //nearElement:左上, farElement:右下
-    let startP = 0;
-    let drag = false;
-    const resizeElement = eles.resize;
-    const nElement = eles.nearElement;
-    const fElement = eles.farElement;
-    const navContentEle = eles.nav ? eles.nav : null;
-    let nEleSize = 0;
-    let fEleSize = 0;
-    let navSize = 0;
-    let nEleChangeSize = 0;
-    let fEleChangeSize = 0;
-
-    // 鼠标点下时
-    resizeElement.mousedown(function(e) {
-        mouseMoveCount = 0;
-        drag = true;
-        startP = type === 'height' ? e.clientY : e.clientX;
-        // 获取左(上)部分的宽度(高度)
-        nEleSize = nElement[type]();
-        // 获取右(下)部分的宽度(高度)
-        fEleSize = fElement[type]();
-        // nav宽(高度)部分
-        if(navContentEle){
-            navSize = navContentEle[type]() + 4;
-        }
-        resizeElement.tooltip('hide');
-    });
-
-    // 鼠标移动
-    $("body").mousemove(function(e) {
-        if (drag) {
-            let moveSize = type === 'height' ? e.clientY - startP : e.clientX - startP;
-            // 判断拖动范围不能超出
-            nEleChangeSize = nEleSize + moveSize;
-            nEleChangeSize = nEleChangeSize < limit.min ? limit.min : nEleChangeSize;
-            nEleChangeSize = nEleChangeSize > limit.max ? limit.max + 9 : nEleChangeSize;
-            fEleChangeSize = fEleSize - moveSize;
-            fEleChangeSize = fEleChangeSize < limit.min ? limit.min : fEleChangeSize;
-            fEleChangeSize = fEleChangeSize > limit.max ? limit.max + 9 : fEleChangeSize;
-            let rePercent = {};
-            if(type === 'width'){
-                 rePercent = getResizeWidthPercent(nEleChangeSize, fEleChangeSize);
-                if(limit.no_proportion === true){//如果只需要记算百分比,但不按页分比设置(还有其它兄弟div和情况)
-                    eles.nearElement.css(type, nEleChangeSize);
-                    eles.farElement.css(type, fEleChangeSize);
-                }else {
-                    eles.nearElement.css(type, rePercent.nearPercent);
-                    eles.farElement.css(type, rePercent.farPercent);
-                }
-
-            }
-            else{
-                eles.nearSpread[type](nEleChangeSize);
-                eles.farSpread[type](fEleChangeSize - navSize);
-                eles.farElement[type](fEleChangeSize);
-            }
-            //实时刷新页面
-            mouseMoveCount+=Math.abs(moveSize);//取移动的决对值
-            if(mouseMoveCount >=5){//当累计移动超过5个像素时,才刷新,减少刷新次数
-                if(callback) callback(rePercent);
-                mouseMoveCount = 0;
-            }
-        }
-    });
-
-    // 鼠标弹起
-    $("body").mouseup(function(e) {
-        if (drag) {
-            callback();
-            drag = false;
-            // 存入本地缓存
-            const id = eles.id;
-            nEleChangeSize = nEleChangeSize >= limit.max ? limit.max + 9  : nEleChangeSize;
-            fEleChangeSize = fEleChangeSize >= limit.max ? limit.max + 9  : fEleChangeSize;
-            setLocalCache(`near${type}:${id}`, nEleChangeSize);
-            setLocalCache(`far${type}:${id}`, fEleChangeSize);
-        }
-    });
-}
-
-/**
- * 读取设置的高度
- *
- * @param {String} tag - 顶层div的id
- * @param {function} callback - 回调函数
- * @return {void}
- */
-
-function loadSize(eles, type, callback) {
-    let tag = eles.id;
-    if (tag === '') {
-        return;
-    }
-    if(type !== 'height' && type !== 'width'){
-        return;
-    }
-    let o_nearSize = eles.nearSpread[type]();
-    let o_farSize = eles.farSpread[type]();
-    let nearSize = getLocalCache(`near${type}:${tag}`);
-    let farSize = getLocalCache(`far${type}:${tag}`);
-    if (nearSize === null || farSize === null) {
-        setDefaultSize(tag,eles,type);//zhang 2018-05-21
-       /* eles.nearSpread[type](o_nearSize);
-        eles.farSpread[type](o_farSize);*/
-    }else {
-        setSizeWithPercent(tag,eles,nearSize,farSize,type)//zhang 2018-06-04 改成按百分比设置
-    }
-    if(type === 'width'){//使用百分比
-        let rePercent = getResizeWidthPercent(nearSize ? nearSize : o_nearSize, farSize ? farSize : o_farSize);
-        eles.nearElement.css(type, rePercent.nearPercent);
-        eles.farElement.css(type, rePercent.farPercent);
-    }
-    callback();
-}
-
 function getResizeWidthPercent(nearSize, farSize){
     const resizeWidth = 6;
     nearSize = parseFloat(nearSize);

+ 32 - 4
web/building_saas/main/js/models/bills.js

@@ -682,7 +682,7 @@ var Bills = {
                 }
             }
         };
-        bills.prototype.deleteSelectedNodes=function() {//删除选中多行时的节点
+        bills.prototype.deleteSelectedNodes=function(isDeleteChild = false, parentNode = null) {//删除选中多行时的节点
             let controller = projectObj.mainController, project = projectObj.project;
             let selected = controller.tree.selected, parent = selected.parent;
             let me = this;
@@ -722,9 +722,9 @@ var Bills = {
             let updateRation = false;
             for(let m_node of mainNodes){
                 if(m_node.sourceType == project.Bills.getSourceType()){
-                    if(m_node.preSibling){
+                    if(m_node.preSibling && !gljUtil.isDef(mainTreeMap[m_node.preSibling.data.ID])){ //有前一节点,并且前一节点不在删除的列表中
                         billsUpdate[m_node.preSibling.data.ID] = {
-                            NextSiblingID:m_node.nextSibling?m_node.nextSibling.data.ID:-1
+                            NextSiblingID:getNotDeleteNextID(m_node.nextSibling,mainTreeMap)
                         };
                         updateBill=true;
                     }
@@ -738,6 +738,7 @@ var Bills = {
                 updateNodes.push(m_node);
                 controller.tree.getAllSubNode(m_node,updateNodes);
             }
+            let refNodes = mbzm_obj.deleteReferenceRation(mainNodes,updateNodes);//删除子目关联定额节点
             for(let u_node of updateNodes){
                 if(u_node.sourceType == project.Bills.getSourceType()){
                     billsUpdate[u_node.data.ID] = true;
@@ -777,7 +778,10 @@ var Bills = {
                         project.Ration.deleteSubListOfRation({ID:r_key});
                     }
                 }
-                controller.m_delete(mainNodes);//删除树节点
+                for(let r of refNodes){
+                    controller.m_delete([r],r.serialNo())//这里删除关联子目生成的定额因为是离散的树节点,所以要这样分开处理
+                }
+                controller.m_delete(mainNodes,mainNodes[0].serialNo());//删除树节点
                 me.tree.m_delete(idTreeNodes);
                 $.bootstrapLoading.end();
                 //重新计算
@@ -794,10 +798,34 @@ var Bills = {
                     if(addRuleSetting && addRuleSetting.addContent === '5'){
                         addRuleUseToBills(getAddRuleSetting(), projectObj.project.mainTree.items);
                     }
+                };
+
+                if (isDeleteChild){
+                    calcTools.forceSelect(parentNode);
                 }
             }, function () {
                 $.bootstrapLoading.end();
             });
+
+            function getNotDeleteNextID(nextNode,map) {
+                if(nextNode){
+                    if(gljUtil.isDef(map[nextNode.data.ID])){
+                        return getNotDeleteNextID(nextNode.nextSibling,map)
+                    } else {
+                        return nextNode.data.ID
+                    }
+                }else {
+                    return -1
+                }
+            }
+
+        };
+        bills.prototype.deleteChildren = function(node) {
+            if (!(node.children.length && node.children.length > 0)) return;
+            let me = this;
+            let firstChild = node.firstChild();
+            calcTools.forceSelect(firstChild, node.children.length);
+            me.deleteSelectedNodes(true, node);
         };
         bills.prototype.setNodeToMapAndArray=function (node,map,array) {
             let nodeID = node.getID();

+ 43 - 6
web/building_saas/main/js/models/calc_program.js

@@ -205,6 +205,30 @@ let calcTools = {
             treeNode.data.gljList = projectObj.project.ration_glj.getGatherGljArrByRations(rations, needOneBill, q);
         };
     },
+    getLeafBills: function (treeNode){
+        let leafBills = [];
+
+        function getBill(node){
+            if (!node) return;
+            if (calcTools.isLeafBill(node))
+                leafBills.push(node);
+
+            if (node.firstChild()) getBill(node.firstChild());
+            if (node.nextSibling) getBill(node.nextSibling);
+        };
+
+        let fc = treeNode.firstChild();
+        if (fc) getBill(fc);
+
+        return leafBills;
+    },
+    forceSelect: function (treeNode, rowsCount = 1, colsCount = 2){
+        projectObj.mainController.tree.selected = treeNode;
+        let idx = projectObj.project.mainTree.items.indexOf(treeNode);
+        let sheet = projectObj.mainSpread.getActiveSheet();
+        sheet.setSelection(idx, 0, rowsCount, colsCount);
+        sheet.showRow(idx, GC.Spread.Sheets.VerticalPosition.center);
+    },
 
     initFees: function (treeNode){
         if (!treeNode.data.fees) {
@@ -565,17 +589,25 @@ let calcTools = {
     marketPriceToBase: function (treeNode, baseName, isTender) {
         if (treeNode.data.type != rationType.volumePrice && treeNode.data.type != rationType.gljRation) return;
         let result = 0, me = this;
-        if (
-            (treeNode.data.subType === gljType.LABOUR && calcTools.inBase(baseName, 'RGF')) ||
+
+        let rcj = (treeNode.data.subType === gljType.LABOUR && calcTools.inBase(baseName, 'RGF')) ||
             (baseMaterialTypes.includes(treeNode.data.subType) && calcTools.inBase(baseName, 'CLF')) ||
-            (treeNode.data.subType === gljType.GENERAL_MACHINE && calcTools.inBase(baseName, 'JXF')) ||
+            (treeNode.data.subType === gljType.GENERAL_MACHINE && calcTools.inBase(baseName, 'JXF'));
+
+        if (typeof isJX2017 != 'undefined') {
+            rcj = rcj || (treeNode.data.subType === gljType.LABOUR && calcTools.inBase(baseName, 'SC_RGF')) ||
+                (baseMaterialTypes.includes(treeNode.data.subType) && calcTools.inBase(baseName, 'SC_CLF')) ||
+                (treeNode.data.subType === gljType.GENERAL_MACHINE && calcTools.inBase(baseName, 'SC_JXF'))
+        };
+
+        if (rcj ||
             (treeNode.data.subType === gljType.MAIN_MATERIAL && calcTools.inBase(baseName, 'ZCF')) ||
             (treeNode.data.subType === gljType.EQUIPMENT && calcTools.inBase(baseName, 'SBF'))) {
             if (treeNode.data.type == rationType.volumePrice)
                 result = treeNode.data.marketUnitFee ? parseFloat(treeNode.data.marketUnitFee).toDecimal(decimalObj.ration.unitPrice) : 0
             else if (treeNode.data.type == rationType.gljRation)
-                // result = treeNode.data.basePrice ? parseFloat(treeNode.data.basePrice).toDecimal(decimalObj.ration.unitPrice) : 0;
-                // 这里因为是算基数所以要取基价,但不能直接取basePrice,受限于项目属性的三个选项。
+            // result = treeNode.data.basePrice ? parseFloat(treeNode.data.basePrice).toDecimal(decimalObj.ration.unitPrice) : 0;
+            // 这里因为是算基数所以要取基价,但不能直接取basePrice,受限于项目属性的三个选项。
                 result = gljOprObj.getBasePrice(treeNode);
         }
         else if (treeNode.data.subType === gljType.GENERAL_MACHINE && calcTools.inBase(baseName, 'JSRGF')) {
@@ -927,11 +959,16 @@ let rationCalcBasesNameKinds = {
     QTCLF:      ['定额其他材料费'],
     JXF:        ['定额基价机械费', '定额机械费', '定额施工机具使用费'],
     JSRGF:      ['定额基价机上人工费'],
-    ZCF:        ['主材费'],
+    ZCF:        ['主材费', '市场价主材费'],
     SBF:        ['设备费'],
     RGGR:       ['人工工日'],
     ZGCLF:      ['暂估材料费'],
 
+    // 市场价人工费、市场价材料费、市场价机械费。江西用,跟重庆区分开,概念上不太统一,这里要注意区分。
+    SC_RGF:     ['人工费'],
+    SC_CLF:     ['材料费'],
+    SC_JXF:     ['机械费'],
+
     JC_RGF:     ['人工费价差'],
     JC_CLF:     ['材料费价差'],
     JC_JXF:     ['机械费价差'],

+ 1 - 2
web/building_saas/main/js/models/project.js

@@ -422,16 +422,15 @@ var PROJECT = {
                     temObj = _.find(this[d.type].datas,{"ID":d.data.ID});
                 }
                 if(temObj){
-                    console.log(temObj);
                     for(let key in d.data){
                         if(key == 'ID' || key == 'id'){
                             continue;
                         }
                         this.setValue(temObj,key,d.data[key])
                     }
-                    console.log(temObj);
                 }
             }
+            return refreshNode;
         };
         project.prototype.setValue=function (obj,key,value) {
             let keyArray = key.split('.');

+ 2 - 2
web/building_saas/main/js/models/quantity_detail.js

@@ -728,7 +728,7 @@ var quantity_detail = {
             node.data.quantityEXP = quantityEXP?quantityEXP:editingText;
             value = scMathUtil.roundForObj(value,getDecimal("quantity",node));
             let newQuantity =  value+"";
-            if(oldQuantityEXP == node.data.quantityEXP && node.data.quantity == newQuantity){ //相当于什么都没改,不用做提交操作
+            if(quantityEXP!="GCLMXHJ"&& oldQuantityEXP == node.data.quantityEXP && node.data.quantity == newQuantity){ //除了修改工程量明细表达式进来的操作,相当于什么都没改,不用做提交操作
                 projectObj.mainController.refreshTreeNode([node]);//这里要再刷新一下,因为工程量要把手工输入的值刷新为转换后的值再显示
                 return;
             }
@@ -801,7 +801,7 @@ var quantity_detail = {
             //value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
             value = project.quantity_detail.autoTransformQuantity(value,node);//先转换再4舍5入
             value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node));
-            if(oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //相当于什么都没改,不用做提交操作
+            if( quantityEXP!="GCLMXHJ" && oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //除了修改工程量明细表达式进来的操作,相当于什么都没改,不用做提交操作
                 projectObj.mainController.refreshTreeNode([node]);//这里要再刷新一下,因为工程量要把手工输入的值刷新为转换后的值再显示
                 return;
             }

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

@@ -423,6 +423,7 @@ var Ration = {
                    }
                 }
                 project.projectGLJ.loadData(function () {
+                    mbzm_obj.nodeChanged = true;//子目模板关联刷新
                     gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
                     project.calcProgram.calcNodesAndSave(refershNodes);
                     projectObj.mainController.refreshTreeNode(refershNodes, true);
@@ -439,7 +440,7 @@ var Ration = {
             let me = this;
             let project = projectObj.project, sheetController = projectObj.mainController;
             let engineering = projectInfoObj.projectInfo.property.engineering;
-            let selected = project.mainTree.selected, newSource = null, newNode = null,pre=null,br=null;
+            let selected = project.mainTree.selected, newSource = null, newNode = null,pre = null,br = null;
             let billItemID = null,serialNo=1,nextID=null;
             let needInstall = false;
             let newDatas = [];

+ 8 - 2
web/building_saas/main/js/models/ration_ass.js

@@ -99,6 +99,7 @@ var ration_ass = {
             return updateData;
         };
         ration_ass.prototype.updateActualValue=function(assList,index,newVal){
+            let me = this;
             var selected = projectObj.project.mainTree.selected;
             assList[index].actualValue=newVal;
             var rationname = selected.data.name;
@@ -116,8 +117,13 @@ var ration_ass = {
             };
 
             var updateData = this.getUpdateData('ut_update',query,doc);
-
-            project.pushNow('updateRationAss',[this.getSourceType()],updateData);
+            $.bootstrapLoading.start();
+            CommonAjax.post("/ration/updateRationAss",updateData[0],function (result) {
+                $.bootstrapLoading.end();
+                zmhs_obj.refreshAfterUpdate(result);
+                zmhs_obj.showAssData();
+            })
+           // project.pushNow('updateRationAss',[this.getSourceType()],updateData);
 
         };
         return new ration_ass(project);

+ 98 - 10
web/building_saas/main/js/models/ration_coe.js

@@ -127,18 +127,106 @@ var ration_coe = {
             updateData.push(newobj);
             return updateData;
         };
-        ration_coe.prototype.adjustCoeClick = function(recode,newval){
-            var query = {
-                'ID':recode.ID,
-                'projectID': recode.projectID,
-                'rationID':recode.rationID
+        ration_coe.prototype.adjustCoeClick = function(record,newval,ext){
+            let me=this,codesList = [],add=[],replace=[];
+            let doc = ext?ext:{};
+            doc['isAdjust'] = newval;
+            var updateData = {
+                'ID':record.ID,
+                'projectID': record.projectID,
+                'rationID':record.rationID,
+                'doc':doc,
+                add:[],
+                delete:[],
+                replace:[]
             };
-            var doc ={
-                isAdjust:newval,
-            };
-            var updateData = this.getUpdateData('ut_update',query,doc,'adjustUpdate');
-            project.pushNow('updateRationCOE',[this.getSourceType()],updateData);
+            let gljList = project.ration_glj.getGLJListByRationID(record.rationID);
+            if(gljUtil.isDef(record.option_codes)&&record.option_codes!=""){ //说明编辑的是下拉选择编号的类型
+                this.prepareDataForOptionType(record,newval,gljList,updateData,replace,codesList,ext);
+            }
+
+            for(let coe of record.coes){//做单个、替换等检查
+                if(coe.coeType == "单个工料机"){ //单个工料机的情况
+                    let glj = _.find(gljList,{"code":coe.gljCode});
+                    if(newval == 1){ //单个工料机,选中时,如果能找到则不管,如果没找到,则需自动插入
+                        if(glj) continue;
+                        add.push(coe.gljCode);
+                        codesList.push(coe.gljCode);
+                    }else {//取消勾选时,要删除添加的工料机记录
+                       if(glj && glj.createType == "add") updateData.delete.push(glj.ID);
+                    }
+                }
+                //替换工料机的情况
+                if(coe.coeType ==  "替换人材机"){
+                    let glj = _.find(gljList,{"rcode":coe.gljCode,'code':coe.replaceCode});//两个条件都满足,则表示已找到对应的记录
+                    if(newval == 1){
+                        if(glj) continue;
+                        let r_glj = _.find(gljList,function (g) {
+                            return (g.code == coe.gljCode && (g.createType===undefined || g.createType == 'normal')) || g.rcode == coe.gljCode //这两个满足一个说明要替换
+                        });
+                        if(r_glj){
+                            replace.push({code:coe.replaceCode,oldData:r_glj});
+                            codesList.push(coe.replaceCode);
+                        }
+                    }
+                    if(newval == 0 && glj){//取消勾选并找到的情况,要恢复成原来的
+                        replace.push({code:coe.gljCode,oldData:glj});
+                        codesList.push(coe.gljCode);
+                    }
+                }
+            }
+            project.ration_glj.getGLJDataByCodes(codesList,function (gljList) {//统一从后端按编号查找标准工料机信息
+                let gljMap = _.indexBy(gljList, 'code');
+                for(let a of add){
+                    if(gljMap[a]){
+                        let tem = project.ration_glj.getAddDataByStd(gljMap[a],record.rationID,project.mainTree.selected.data.billsItemID,record.projectID);
+                        updateData.add.push(tem);
+                    }
+                }
+                for(let r of replace){
+                    if(gljMap[r.code]){
+                        let r_tem = project.ration_glj.getReplaceDataByStd(r.oldData,gljMap[r.code]);
+                        updateData.replace.push(r_tem);
+                    }
+                }
+                $.bootstrapLoading.start();
+                CommonAjax.post("/ration/updateCoeAdjust",updateData,function (result) {
+                    $.bootstrapLoading.end();
+                    me.refreshAfterUpdate(result.coe);
+                    zmhs_obj.refreshAfterUpdate(result,true)
+                })
+            });
+
         };
+        ration_coe.prototype.prepareDataForOptionType = function (record,newval,gljList,updateData,replace,codesList,ext) {
+            let select_code = record.select_code;
+            if(ext && gljUtil.isDef(ext.select_code)&&ext.select_code!=""){//是下拉框选择了人材机编号进来的
+                select_code = ext.select_code;
+            }
+            if(gljUtil.isDef(select_code) && select_code!=""){//有选中编号的情况下,才会做这些操作
+                let glj = _.find(gljList,{"rcode":record.original_code,'code':select_code});//两个条件都满足,则表示已找到对应的记录
+                if(newval == 1){
+                    if(!glj){//在没找到的情况下,要替换
+                        let r_glj = _.find(gljList,function (g) {
+                            return (g.code == record.original_code && (g.createType===undefined || g.createType == 'normal')) || g.rcode == record.original_code //这两个满足一个说明要替换
+                        });
+                        if(r_glj){
+                            replace.push({code:select_code,oldData:r_glj});
+                            codesList.push(select_code);
+                        }
+                    }
+                }else {
+                    updateData.doc['select_code'] = ""; //取消勾选,选中值要恢复为空
+                    if(glj){//如果找到工料机,还需要恢复成原来的
+                        replace.push({code:record.original_code,oldData:glj});
+                        codesList.push(record.original_code);
+                    }
+                }
+            }
+        };
+
+
+
 
         ration_coe.prototype.updateCustomerCoe = function (data) {
             var updateData = this.getUpdateData('ut_update',data.query,data.doc,'updateCustomerCoe');

+ 93 - 45
web/building_saas/main/js/models/ration_glj.js

@@ -61,6 +61,11 @@ let ration_glj = {
             }
         };
 
+        ration_glj.prototype.getGLJListByRationID = function (rationID) {
+           return  _.filter(this.datas, {'rationID': rationID})
+        };
+
+
         ration_glj.prototype.getGatherGljArrByRations = function (rations, needOneBill, billQuantity) {
             let result = [];
             let clone = function (obj) {
@@ -182,6 +187,18 @@ let ration_glj = {
                 }
             }
         };
+        ration_glj.prototype.updateGLJNodeAfterReplace = function(data){
+            if (this.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
+                var node = this.findGLJNodeByID(data.ID);
+                if (node) {
+                    this.transferToNodeData(data);
+                    node.source = data;
+                    node.data = data;
+                }
+               return node;
+            }
+        };
+
         ration_glj.prototype.addToMainTree = function (datas) {
             datas = sortRationGLJ(datas);
             for (let data of datas) {
@@ -230,17 +247,25 @@ let ration_glj = {
 
         ration_glj.prototype.refreshAfterUpdate = function (data) {
             let me = this;
+            let rationID= me.updateCacheAfterAdjust(data);
+            gljOprObj.showRationGLJSheetData(true);
+            this.reCalcWhenGLJChange({rationID:rationID});
+        };
+
+        ration_glj.prototype.updateCacheAfterAdjust=function (data) {
+            let me = this;
             let rationID=null;
             if (data.quantityRefresh) {
                 data.glj_result.forEach(function (item) {
-                   rationID = me.refreshEachItme(item.doc, item.query);
+                    rationID = me.refreshEachItme(item.doc, item.query);
                 })
             } else {
                 rationID =  me.refreshEachItme(data.doc, data.query);
             }
-            gljOprObj.showRationGLJSheetData(true);
-            this.reCalcWhenGLJChange({rationID:rationID});
+            return rationID;
         };
+
+
         ration_glj.prototype.refreshEachItme = function (doc, query) {
             let glj = this.refreshByID(query.ID,doc);
             return glj.rationID;
@@ -603,10 +628,55 @@ let ration_glj = {
                 $.bootstrapLoading.end();
             });
 
+        };
+        ration_glj.prototype.getGLJDataByCodes = function (codes,callback) {
+            if(!gljUtil.isDef(codes)||codes.length ==0) {
+                if(callback) callback([]);
+                return
+            }
+            $.bootstrapLoading.start();
+            CommonAjax.post("/rationGlj/getGLJDataByCodes", { 'engineerID':projectInfoObj.projectInfo.property.engineering_id,projectID:projectObj.project.ID(),codes:codes}, function (result) {
+                $.bootstrapLoading.end();
+                callback(result)
+            });
+        };
 
+        ration_glj.prototype.getAddDataByStd = function (glj,rationID,billsItemID,projectID) {//生成添加类型的定额工料机数据
+            let ration_glj = {
+                projectID: projectID,
+                GLJID: glj.ID,
+                rationID: rationID,
+                billsItemID: billsItemID,
+                rationItemQuantity: 0,
+                quantity: 0,
+                name: glj.name,
+                code: glj.code,
+                original_code: glj.code,
+                unit: glj.unit,
+                specs: glj.specs,
+                basePrice: glj.basePrice,
+                marketPrice:glj.basePrice,
+                shortName: glj.shortName,
+                type: glj.gljType,
+                model:glj.model,
+                adjCoe: glj.adjCoe,
+                createType: 'add',
+                materialType:glj.materialType,
+                materialCoe:glj.materialCoe,
+                repositoryId: glj.repositoryId
+            };
+            if (glj.hasOwnProperty("compilationId")) {
+                ration_glj.from = "cpt";
+                if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
+                    ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
+                }
+            }
+            return ration_glj;
         };
+
+
         ration_glj.prototype.addGLJByLib = function (GLJSelection, ration, callback) {
-            let gljList = [];
+            let me=this,gljList = [];
             let allGLJ = gljOprObj.AllRecode;
             GLJSelection.sort();
             _.forEach(GLJSelection, function (g) {
@@ -614,36 +684,7 @@ let ration_glj = {
                     let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
                     return i_key == g;
                 });
-                let ration_glj = {
-                    projectID: ration.projectID,
-                    GLJID: glj.ID,
-                    rationID: ration.ID,
-                    billsItemID: ration.billsItemID,
-                    rationItemQuantity: 0,
-                    quantity: 0,
-                    name: glj.name,
-                    code: glj.code,
-                    original_code: glj.code,
-                    unit: glj.unit,
-                    specs: glj.specs,
-                    basePrice: glj.basePrice,
-                    marketPrice:glj.basePrice,
-                    shortName: glj.shortName,
-                    type: glj.gljType,
-                    model:glj.model,
-                    adjCoe: glj.adjCoe,
-                    createType: 'add',
-                    materialType:glj.materialType,
-                    materialCoe:glj.materialCoe,
-                    repositoryId: glj.repositoryId
-                }
-                if (glj.hasOwnProperty("compilationId")) {
-                    ration_glj.from = "cpt";
-                    if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
-                        ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
-                    }
-                }
-
+                let ration_glj = me.getAddDataByStd(glj,ration.ID,ration.billsItemID,ration.projectID);
                 gljList.push(ration_glj);
             });
             $.bootstrapLoading.start();
@@ -703,23 +744,16 @@ let ration_glj = {
             }, function () {
                 $.bootstrapLoading.end();
             });
-
-
         };
 
-        ration_glj.prototype.replaceGLJ = function (selectCode, oldData, callback) {
-            let allGLJ = gljOprObj.AllRecode;
-            let glj = _.find(allGLJ, function (item) {
-                let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
-                return i_key == selectCode;
-            });
-            if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
-                return callback(null);
-            }
+        ration_glj.prototype.getReplaceDataByStd = function (oldData,glj) {
             if (oldData.createType===undefined || oldData.createType == 'normal') {// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
                 oldData.createType = 'replace';
             }
+            if(oldData.createType == 'replace' && oldData.rcode == glj.code){//如果原数据已经是替换过的,这次替换又恢复成原数据,则把类型改回来
+                oldData.createType = 'normal'
+            }
             oldData.GLJID = glj.ID;
             oldData.name = glj.name;
             oldData.code = glj.code;
@@ -740,6 +774,20 @@ let ration_glj = {
             } else {
                 oldData.from = "std";
             }
+            return oldData;
+        };
+
+
+        ration_glj.prototype.replaceGLJ = function (selectCode, oldData, callback) {
+            let allGLJ = gljOprObj.AllRecode;
+            let glj = _.find(allGLJ, function (item) {
+                let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
+                return i_key == selectCode;
+            });
+            if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
+                return callback(null);
+            }
+            oldData = this.getReplaceDataByStd(oldData,glj);
             $.bootstrapLoading.start();
             CommonAjax.post("/rationGlj/replaceGLJ", oldData, callback, function () {
                 $.bootstrapLoading.end();

+ 20 - 18
web/building_saas/main/js/views/billsElf.js

@@ -168,7 +168,7 @@ const BillsElf = (function() {
             workBookWidth = ($(window).width() - $('.main').find('.main-nav').width() - $('.main-side').width()) * 5 / 6,
             headers = elfItem.headers;
         if(workBook){
-            workBookWidth -= 60;
+            workBookWidth -= 55;
             const sheet = workBook.getActiveSheet();
             sheet.suspendEvent();
             sheet.suspendPaint();
@@ -461,30 +461,32 @@ const BillsElf = (function() {
             }
             let height = cellRect.height;
             let options = getOptions(node.data, bills.selected.elf.datas);
-            top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height - 5;
+            top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height;
             let $editInput = $(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div>`),
-                $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
+                $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6+5 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
             for(let opt of options){
-                let $opt = $(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis"></div>`),
-                    $optInput = $(`<input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox" 
-                    ${node.data.optionChecked && _.find(node.data.optionChecked, {ID: opt.ID}) ? 'checked' : ''}>`);
+                let $opt = $(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="cursor: pointer; height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis"></div>`),
+                    $optInput = $(`<input rank="${opt.rank}" value="${opt.ID}" style="cursor: pointer; margin-left: 5px; vertical-align: middle" type="checkbox" 
+                    ${node.data.optionChecked && _.find(node.data.optionChecked, {ID: opt.ID}) ? 'checked' : ''} ${projectReadOnly ? 'disabled' : ''}>`);
                 $opt.text(`${opt.name ? opt.name : ''}`);
                 $opt.prepend($optInput);
                 $optDiv.append($opt);
                 //选项复选框点击监听
-                $opt.click(function () {
-                    //单选
-                    if(billsGuidanceSelMode === 0){
-                        let $allInput = $optDiv.find('input');
-                        for(let input of $allInput){
-                            $(input).prop('checked', false);
-                        }
-                        $($optInput).prop('checked', 'checked');
-                        elfItem.workBook.getSheet(0).endEdit();
-                    } else {//多选
+                if (!projectReadOnly) {
+                    $opt.click(function () {
+                        //单选
+                        if(billsGuidanceSelMode === 0){
+                            let $allInput = $optDiv.find('input');
+                            for(let input of $allInput){
+                                $(input).prop('checked', false);
+                            }
+                            $($optInput).prop('checked', 'checked');
+                            elfItem.workBook.getSheet(0).endEdit();
+                        } else {//多选
 
-                    }
-                });
+                        }
+                    });
+                }
             }
             $editor.append($editInput);
             $editor.append($optDiv);

+ 197 - 114
web/building_saas/main/js/views/block_lib.js

@@ -3,6 +3,8 @@
  * Created by CSL on 2018-09-19.
  */
 var blockLibObj = {
+    libs: [],
+    activeLib: null,
     mainSpread: null,
     mainSheet: null,
     mainTree: null,
@@ -27,7 +29,7 @@ var blockLibObj = {
                 "font":["Arial"]
             },
             "data":{
-                "field":"name",
+                "field":"nodeName",
                 "vAlign":1,
                 "hAlign":0,
                 "font":"Arial"
@@ -42,7 +44,7 @@ var blockLibObj = {
             {headerName: "项目编码", headerWidth: 90, dataCode: "code", dataType: "String", hAlign: "center"},
             {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
             {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
-            {headerName: "综合单价", headerWidth: 70, dataCode: "", dataType: "Number"},
+            {headerName: "综合单价", headerWidth: 70, dataCode: "unitFee", dataType: "Number"},
             {headerName: "项目特征", headerWidth: 160, dataCode: "itemCharacterText", dataType: "String"}
         ],
         view: {
@@ -57,30 +59,32 @@ var blockLibObj = {
             {headerName: "名称", headerWidth: 100, dataCode: "name", dataType: "String"},
             {headerName: "单位", headerWidth: 40, dataCode: "unit", dataType: "String", hAlign: "center"},
             {headerName: "含量", headerWidth: 40, dataCode: "contain", dataType: "Number"},
-            {headerName: "取费专业", headerWidth: 70, dataCode: "", dataType: "String", hAlign: "center"},
-            {headerName: "综合单价", headerWidth: 70, dataCode: "", dataType: "Number"},
+            {headerName: "取费专业", headerWidth: 70, dataCode: "programName", dataType: "String", hAlign: "center"},
+            {headerName: "综合单价", headerWidth: 70, dataCode: "unitFee", dataType: "Number"},
             {headerName: "子目换算状态", headerWidth: 90, dataCode: "adjustState", dataType: "String"}
         ],
         view: {
             lockColumns: [0, 1, 2, 3, 4, 5, 6]
         }
     },
+    cloneType: null,
 
-    buildSheet: function () {
+    buildSheet: async function () {
         $.bootstrapLoading.start();
         let me = this;
-        me.mainDatas = [
-            {ID: 1, ParentID: -1, NextSiblingID: 2, name: '分类1', type: 1},
-            {ID: 2, ParentID: -1, NextSiblingID: 3, name: '分类2', type: 1},
-            {ID: 3, ParentID: -1, NextSiblingID: 4, name: '分类3', type: 1},
+       /* me.mainDatas = [
+            {ID: 1, ParentID: -1, NextSiblingID: 2, nodeName: '分类1', type: 1},
+            {ID: 2, ParentID: -1, NextSiblingID: 3, nodeName: '分类2', type: 1},
+            {ID: 3, ParentID: -1, NextSiblingID: 4, nodeName: '分类3', type: 1},
             // {ID: 105, ParentID: 1, NextSiblingID: 106, name: '块1', type: 2},
             // {ID: 106, ParentID: 1, NextSiblingID: 107, name: '块2', type: 2},
-            {ID: 7, ParentID: -1, NextSiblingID: 8, name: '分类7', type: 1},
-            {ID: 9, ParentID: -1, NextSiblingID: -1, name: '分类9', type: 1}//,
-            // {ID: 201, ParentID: 52, NextSiblingID: -1, name: '块201', type: 2}
-        ];
+            {ID: 7, ParentID: -1, NextSiblingID: 8, nodeName: '分类7', type: 1},
+            {ID: 9, ParentID: -1, NextSiblingID: -1, nodeName: '分类9', type: 1}//,
+            // {ID: 201, ParentID: 52, NextSiblingID: -1, nodeName: '块201', type: 2}
+        ];*/
 
-        if (me.mainSpread) {
+       if (me.libs.length > 0) me.libs.splice(0, me.libs.length);
+       if (me.mainSpread) {
             me.mainSpread.destroy();
             me.mainSpread = null;
         };
@@ -93,6 +97,21 @@ var blockLibObj = {
             me.rationSpread = null;
         };
 
+        let namesAndLib = await ajaxPost('/blockLib/getLibNamesAndFirstLib', {userID: userID, compilationID: projectInfoObj.projectInfo.compilation});
+        me.mainDatas = namesAndLib.firstLib.datas;
+        me.libs.push(namesAndLib.firstLib);
+        me.activeLib = namesAndLib.firstLib;
+
+        function getLibNamesHtml(libsArr) {
+            let result = '';
+            for (let lib of libsArr) {
+                result += '<option value="' + lib.libID + '">' + lib.libName + '</option>';
+            };
+            return result;
+        };
+        let html = getLibNamesHtml(namesAndLib.libNames);
+        $("#select_block_lib_names").html(html);
+
         me.mainSpread = SheetDataHelper.createNewSpread($('#div_block_tree')[0]);
         // me.mainSpread = TREE_SHEET_HELPER.createNewSpread($('#div_block_tree')[0]);
         me.mainSheet = me.mainSpread.getSheet(0);
@@ -131,15 +150,14 @@ var blockLibObj = {
     },
     loadDetailDatas: function (node){
         let me = this;
+        if (!node) return;
         if (node.data.type == 2){
-            let bill = node.data.datas[0];
+            let bill = node.data;
             let rations = bill.children;
             sheetCommonObj.showData(me.billSheet, me.billSetting, [bill]);
-            me.changeBillText(bill);
             let rCount = (rations.length > 0) ? rations.length : 1;
             me.rationSheet.setRowCount(rCount, GC.Spread.Sheets.SheetArea.viewport);
             sheetCommonObj.showData(me.rationSheet, me.rationSetting, rations);
-            me.changeRationText(rations);
         }
         else{
             sheetCommonObj.cleanSheet(me.billSheet, me.billSetting, 1);
@@ -345,57 +363,99 @@ var blockLibObj = {
         };
         return new TreeCell();
     },
-    newNode: function (nodeType, nodeName, categoryID, source){     // 1 分类(只用前两个参数)  2 块文件
+    newNode: async function (nodeType, nodeName, categoryID, source){     // 1 分类(只用前两个参数)  2 块文件
         let tree = blockLibObj.mainTree;
-        let pID = -1, nID = -1;
-        let select = tree.selected;
-        if (nodeType == 1){
-            if (!select) {
-                nID = -1;
-            }
-            else if (select.data.type == 1){
-                nID = select.getNextSiblingID();
-            }
-            else if (select.data.type == 2){
-                nID = select.parent.getNextSiblingID();
+        let ID = uuid.v1();
+        let pID = (nodeType == 2) ? categoryID : -1;
+        let nID = -1;
+
+        // 先生成临时结点数据用于提交入库,成功后才生成树结点,并在UI上刷新显示。
+        let temp = {};
+        temp.data = {
+            ID: ID,
+            ParentID: pID,
+            NextSiblingID: nID,
+            libID: blockLibObj.activeLib.libID,
+            type: nodeType,
+            nodeName: nodeName
+        };
+        if (nodeType == 2)
+            blockLibObj.assignData(temp, source);
+
+        try {
+            let obj = {
+                libID: blockLibObj.activeLib.libID,
+                nodeID: temp.data.ID,
+                create: temp.data
             };
+            await ajaxPost('/blockLib/saveBlock', obj);
+            let newN = tree.insertByID(ID, pID, nID);
+            newN.data = temp.data;
+            tree.selected = newN;
+            let sheet = blockLibObj.mainSheet;
+            sheet.suspendPaint();
+            sheet.suspendEvent();
+            let idx = tree.items.indexOf(newN);
+            sheet.addRows(idx, 1);
+            sheet.getRange(idx, 0, 1, 1).locked(true);
+            sheet.setValue(idx, 0, newN.data.nodeName);
+            sheet.setSelection(idx, 0, 1, 1);
+            sheet.resumeEvent();
+            sheet.resumePaint();
         }
-        else if (nodeType == 2) {
-            pID = categoryID;
-            nID = -1;
-        }
-
-        let newNode = tree.insert(pID, nID);
-        newNode.data.type = nodeType;
-        newNode.data.name = nodeName;
-        if (nodeType == 2){
-            newNode.data.compilationID = source.compilationID;
-            newNode.data.copyTime = source.copyTime;
-            newNode.data.firstNodeType = source.firstNodeType;
-            newNode.data.isFBFX = source.isFBFX;
-            newNode.data.datas = source.datas;
-        }
-
-        tree.selected = newNode;
-
-        let sheet = blockLibObj.mainSheet;
-        sheet.suspendPaint();
-        sheet.suspendEvent();
-
-        let idx = tree.items.indexOf(newNode);
-        sheet.addRows(idx, 1);
-        sheet.getRange(idx, 0, 1, 1).locked(true);
-        sheet.setValue(idx, 0, newNode.data.name);
-        sheet.setSelection(idx, 0, 1, 1);
-
-        sheet.resumeEvent();
-        sheet.resumePaint();
+        catch (err) {
+            console.log(err.message);
+            return;
+        };
     },
-    reName: function (node, newName){
-        node.data.name = newName;
+    assignData: function (block, source){
+        block.data.compilationID = source.compilationID;
+        block.data.copyTime = source.copyTime;
+        block.data.firstNodeType = source.firstNodeType;
+        block.data.isFBFX = source.isFBFX;
+
+        let bill = source.datas[0];
+        block.data.code = bill.code;
+        block.data.name = bill.name;
+        block.data.unit = bill.unit;
+        block.data.itemCharacterText = bill.itemCharacterText;
+        block.data.unitFee = (bill.feesIndex && bill.feesIndex.common) ? bill.feesIndex.common.unitFee : 0;
+        block.data.children = bill.children;
+
+        for (let r of bill.children){
+            r.unitFee =  (r.feesIndex && r.feesIndex.common) ? r.feesIndex.common.unitFee : 0;
+            if (r.programID)
+                r.programName = projectObj.project.calcProgram.compiledTemplateMaps[r.programID];
+            // delete r.ID;         // 这个不能删!
+            delete r.billsItemID;
+            delete r.fees;
+            delete r.feesIndex;
+        };
+    },
+    reName: async function (node, newName){
+        if (newName == '') return;
+        let obj = {
+            libID: blockLibObj.activeLib.libID,
+            nodeID: node.data.ID,
+            update: {nodeName: newName}
+        };
+        await ajaxPost('/blockLib/saveBlock', obj);
+        node.data.nodeName = newName;
         let idx = blockLibObj.mainTree.items.indexOf(node);
         blockLibObj.mainSheet.setValue(idx, 0, newName);
     },
+    moveBlock: function (parentID) {
+        // this.mainTreeController.moveTo(parentID);
+    },
+    delete: async function () {
+        let obj = {
+            libID: blockLibObj.activeLib.libID,
+            nodeID: blockLibObj.mainTree.selected.data.ID,
+            delete: true
+        };
+        await ajaxPost('/blockLib/saveBlock', obj);
+        this.mainTreeController.delete();
+    },
     getCategories: function () {
         let nodes = [], node = blockLibObj.mainTree.items[0];
         nodes.push(node);
@@ -411,6 +471,18 @@ var blockLibObj = {
     curIsCategory: function () {
         return this.mainTree.selected.data.type == 1;
     },
+    getSameNameNode: function(name){
+        let rst = null;
+        let nodes = blockLibObj.mainTree.items;
+        for (let i = 0; i < nodes.length; i++) {
+            let node = nodes[i];
+            if (node.data.nodeName == name){
+                rst = node;
+                break;
+            }
+        }
+        return rst;
+    },
     refreshSpread: function (){
         if (this.mainSpread)
             this.mainSpread.refresh();
@@ -419,28 +491,6 @@ var blockLibObj = {
         if (this.rationSpread)
             this.rationSpread.refresh();
     },
-    changeRationText: function (rationDatas) {
-        let sheet = this.rationSheet;
-        sheet.suspendPaint();
-        sheet.suspendEvent();
-        for (let i = 0; i < rationDatas.length; i++) {
-            let pID = rationDatas[i].programID;
-            if (pID) sheet.setValue(i, 4, projectObj.project.calcProgram.compiledTemplateMaps[pID]);
-            if (rationDatas[i].feesIndex && rationDatas[i].feesIndex.common)
-                sheet.setValue(i, 5, rationDatas[i].feesIndex.common.unitFee);
-        }
-        sheet.resumeEvent();
-        sheet.resumePaint();
-    },
-    changeBillText: function (billData){
-        let sheet = this.billSheet;
-        sheet.suspendPaint();
-        sheet.suspendEvent();
-        if (billData.feesIndex && billData.feesIndex.common)
-            sheet.setValue(0, 3, billData.feesIndex.common.unitFee);
-        sheet.resumeEvent();
-        sheet.resumePaint();
-    },
     loadTreeContextMenu: function (){
         let me = this;
         $.contextMenu({
@@ -452,41 +502,47 @@ var blockLibObj = {
             items: {
                 "oneToOneClone": {
                     name: '一对一克隆',
-                    icon: "fa-battery-empty",
+                    icon: "fa-stop",
                     disabled: function () {
-
+                        let ok = me.curIsBlock() && calcTools.isLeafBill(projectObj.project.mainTree.selected);
+                        return !ok;
                     },
                     visible: function(key, opt){
-                        return me.curIsBlock();
+                        return true;
                     },
                     callback: function (key, opt) {
-                        me.oneToOneClone();
+                        blockLibObj.cloneType = 1;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "oneToMoreClone": {
                     name: '一对多克隆',
-                    icon: "fa-battery-half",
+                    icon: "fa-th-list",
                     disabled: function () {
-
+                        let ok = me.curIsBlock() && calcTools.isParentBill(projectObj.project.mainTree.selected);
+                        return !ok;
                     },
                     visible: function(key, opt){
-                        return me.curIsBlock();
+                        return true;
                     },
                     callback: function (key, opt) {
-
+                        blockLibObj.cloneType = 2;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "moreToMoreClone": {
                     name: '多对多克隆',
-                    icon: "fa-battery-full",
+                    icon: "fa-th",
                     disabled: function () {
-
+                        let ok = me.curIsCategory() && calcTools.isParentBill(projectObj.project.mainTree.selected);
+                        return !ok;
                     },
                     visible: function(key, opt){
-                        return me.curIsCategory();
+                        return true;
                     },
                     callback: function (key, opt) {
-
+                        blockLibObj.cloneType = 3;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "delete": {
@@ -499,17 +555,21 @@ var blockLibObj = {
                         return true;
                     },
                     callback: function (key, opt) {
-
+                        let name = hintBox.fontRed(me.mainTree.selected.data.nodeName);
+                        hintBox.infoBox('操作确认', `确定要删除"${name}"吗?`, 2, function () {
+                            me.delete();
+                        });
                     }
                 },
                 "moveBlock": {
                     name: '移动模板',
                     icon: "cut",
                     disabled: function () {
-
+                        return true;
                     },
                     visible: function(key, opt){
-                        return me.curIsBlock();
+                        // return me.curIsBlock();
+                        return false;
                     },
                     callback: function (key, opt) {
 
@@ -523,34 +583,57 @@ var blockLibObj = {
         me.mainTree.selected = me.mainTree.items[me.mainSheet.getActiveRowIndex()];
     },
     onCellDoubleClick: function (sender, args) {
-        blockLibObj.oneToOneClone();
-    },
-    oneToOneClone: function () {
-        let me = blockLibObj;
         let projectNode = projectObj.project.mainTree.selected;
         if (!calcTools.isLeafBill(projectNode)) return;
-
-        let block = me.mainTree.selected.data;
-        // 这里再次封装成伟城的块文件格式,可直接使用伟城的“粘贴块”接口。前提:当前块文件的全部数据已从后台取到前台。
+        blockLibObj.cloneType = 1;
+        $("#div_cloneOptions").modal({show: true});
+    },
+    oneToOneClone: function (projectNode, block, options) {
+        let canClone = true;
+        if (options.checkCode)
+            canClone = canClone && (projectNode.data.code.substr(0, 9) == block.data.code.substr(0, 9));
+        if (options.checkName)
+            canClone = canClone && (projectNode.data.name == block.data.name);
+        if (options.checkUnit)
+            canClone = canClone && (projectNode.data.unit == block.data.unit);
+        if (!canClone) return;
+        
+        if (options.overwriteRations)
+            projectObj.project.Bills.deleteChildren(projectNode);
+        /*  这里封装成伟城的块文件格式,可直接使用伟城的“粘贴块”接口。
+            但这里结构要作出调整:忽略叶子清单层,直接从定额开始(跟粘贴块有区别),始终强制在叶子清单下插入定额。
+            该操作前提:当前块文件的全部数据已从后台取到前台。  */
         let vBlock_WC = {
-            compilationID: block.compilationID,
-            copyTime: block.copyTime,
-            firstNodeType: 1,   // 强制改成1。这里跟粘贴块有区别,忽略叶子清单层,直接从定额开始,即始终强制在叶子清单下插入定额。
-            isFBFX: block.isFBFX,
-            datas: block.datas[0].children    // rations
+            compilationID: block.data.compilationID,
+            copyTime: block.data.copyTime,
+            firstNodeType: 1,           // 强制改成1 (因为是从清单下的定额开始。清单自身的还是保留,暂不使用使用)。
+            isFBFX: block.data.isFBFX,
+            zeroQuantity: options.zeroQuantity,
+            datas: block.data.children       // rations
         };
+        vBlock_WC = JSON.parse(JSON.stringify(vBlock_WC));
         BlockController.confirmPaste(vBlock_WC, projectNode, 'sub');
+    },
+    checkShow: async function () {   // 这里需要处理异步:模板库装载完再弹出位置选择窗。
+        if (!$("#kmbk").is(":visible")){  // 如果还没显示
+            if (!blockLibObj.mainSpread){
+                await blockLibObj.buildSheet();
+            };
+            $('#blockLibTab').click();  // 强制显示
+        };
+        $("#div_createBlocks").modal({show: true});
     }
 };
 
-$(document).ready(function(){
+$(document).ready(function(){    // 这里不需要处理异步:因为不需要弹出位置选择窗。
     $('#blockLibTab').on('click', function (){
-        if ($("#kmbk").is(":visible")){
+        if ($("#kmbk").is(":visible")){    // 显示状态下
             if (!blockLibObj.mainSpread){
                 blockLibObj.buildSheet();
             };
         }
     });
+
     $('#btn_block_newFolder').on('click', function (){
         $('#input_block_newFolder').val('');
     });
@@ -562,12 +645,12 @@ $(document).ready(function(){
 
     $('#btn_block_reName').on('click', function (){
         let select = blockLibObj.mainTree.selected;
-        $('#input_block_reName').val(select.data.name);
+        $('#input_block_reName').val(select.data.nodeName);
     });
 
     $('#btn_block_reName_OK').on('click', function (){
         let select = blockLibObj.mainTree.selected;
-        let oldName = select.data.name;
+        let oldName = select.data.nodeName;
         let newName = $('#input_block_reName').val();
         if (oldName != newName) blockLibObj.reName(select, newName);
     });

+ 4 - 4
web/building_saas/main/js/views/character_content_view.js

@@ -1475,10 +1475,10 @@ let pageCCOprObj = {
     },
     resizeWidth: function () {
         let workBookWidth = pageCCOprObj.getWorkBookWidth();
-        contentOprObj.setRateWith($('#jobDiv').width() - 40);
-        sheetCommonObj.setColumnWidthByRate($('#jobDiv').width() - 40, contentOprObj.workBook, contentOprObj.setting.header);
-        characterOprObj.setRateWith($('#itemDiv').width() - 40);
-        sheetCommonObj.setColumnWidthByRate($('#itemDiv').width() - 40, characterOprObj.workBook, characterOprObj.setting.header);
+        contentOprObj.setRateWith($('#jobDiv').width() - 45);
+        sheetCommonObj.setColumnWidthByRate($('#jobDiv').width() - 55, contentOprObj.workBook, contentOprObj.setting.header);
+        characterOprObj.setRateWith($('#itemDiv').width() - 45);
+        sheetCommonObj.setColumnWidthByRate($('#itemDiv').width() - 48, characterOprObj.workBook, characterOprObj.setting.header);
     }
 }
 

+ 3 - 5
web/building_saas/main/js/views/fee_rate_view.js

@@ -354,11 +354,9 @@ var feeRateObject={
             var init=false;
         }
         FeeRateEditCellType.prototype = new ns.CellTypes.Text();
-        FeeRateEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-           // if(value!=null){
-               // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
+        //2018-12-12 按新需求隐藏费率选择按钮
+      /*  FeeRateEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
              GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-           // }
             if(feeRateObject.editingCell && !projectReadOnly){
                 if(feeRateObject.editingCell.row==options.row&&feeRateObject.editingCell.col==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
@@ -437,7 +435,7 @@ var feeRateObject={
                 hitinfo.sheet.repaint();
                 feeRateObject.pmLeave = true;
             }
-        }
+        }*/
         return new FeeRateEditCellType();
     },
     showSelectModal:function (hitinfo) {

+ 40 - 7
web/building_saas/main/js/views/glj_view.js

@@ -69,6 +69,7 @@ var gljOprObj = {
                         me.gljCurTypeId = treeNode.ID;
                         me.filterLibGLJSheetData();
                         me.showLibGLJSheetData();
+                        gljOprObj.initSelection({row: me.gljLibSheet.getActiveRowIndex()});
                     }
                 } else {
                     if (treeNode.isParent) {
@@ -323,6 +324,7 @@ var gljOprObj = {
     initSelection: function (sel) {
         let me = gljOprObj;
         if(sel){
+            sel.row = !sel.row || sel.row == -1 ? 0 : sel.row;
             me.gljLibSheet.setStyle(sel.row, -1, me.getSelStyle(true));
         }
         if(me.preGljLibSelection && me.preGljLibSelection.row !== sel.row){
@@ -517,7 +519,8 @@ var gljOprObj = {
                 }else {
                     if($('#linkGLJ').hasClass('active')){
                         this.showRationGLJData(node);
-                        MaterialController.showReplaceDiv(node);
+                        subObj.showGljSubTabData();
+                       // MaterialController.showReplaceDiv(node);
                     }
                     if($('#linkAZZJF').hasClass('active')) installationFeeObj.showRationInstallationData(node);
                     if($('#linkMBZM').hasClass('active')) mbzm_obj.showMBZMData(node);
@@ -539,7 +542,7 @@ var gljOprObj = {
             MaterialController.hideReplaceDiv();
         }
         //子目换算
-        zmhs_obj.showZMHSData(node);
+        //zmhs_obj.showZMHSData(node);
         //   $('#dropdown').hide();
     },
     showMixRatio:function (node) {//显示组成物到定额工料机
@@ -1092,6 +1095,7 @@ var gljOprObj = {
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
         });
+        console.log(distTypeTree);
         return distTypeTree;
     },
     doInsertGLJ: function () {
@@ -1183,7 +1187,9 @@ var gljOprObj = {
                 glj_list[list_index] = data;
                 project.projectGLJ.loadData(function () {//加载完项目工料机再计算
                     gljOprObj.showRationGLJSheetData();
-                    if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
+                    let node = project.ration_glj.updateGLJNodeAfterReplace(data);
+                    if(node) nodes.push(node);
+                    /*if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
                         var node = project.ration_glj.findGLJNodeByID(data.ID);
                         if (node) {
                             project.ration_glj.transferToNodeData(data);
@@ -1191,7 +1197,7 @@ var gljOprObj = {
                             node.data = data;
                         }
                         node ? nodes.push(node) : "";
-                    }
+                    }*/
                     //project.ration_glj.addToMainTree(data);
                     selected.data.adjustState = result.adjustState;
                     selected.data.name = result.name;
@@ -1407,6 +1413,26 @@ var gljOprObj = {
         }else {
             gljOprObj.billsTab = gljOprObj.activeTab;
         }
+    },
+    //初始化分类树
+    //@param {String}type(标准或补充) {Array}treeData(树数据)
+    initClassTree: function (type, treeData, initSel = false) {
+        let me = this;
+        if (me.treeObj) {
+            me.treeObj.destroy();
+            me.parentNodeIds = {};
+        }
+        zTreeHelper.createTree(treeData, me.gljTreeSetting, "gljTree", me);
+        if (initSel) {
+            let rootNode = me.treeObj.getNodes()[0];
+            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                me.rootNode = rootNode;
+            }
+            if(me.rootNode){
+                me.treeObj.selectNode(me.rootNode);
+                me.gljTreeSetting.callback.onClick(null, 'gljTree', me.rootNode);
+            }
+        }
     }
 }
 
@@ -1474,9 +1500,15 @@ $(function () {
             gljOprObj.filterLibGLJSheetData();
             gljOprObj.showLibGLJSheetData();
         } else {
-            gljOprObj.gljLibSheetData = gljOprObj[val];
-            gljOprObj.filterLibGLJSheetData();
-            gljOprObj.showLibGLJSheetData();
+            if(val === 'stdGLJ') {
+                gljOprObj.initClassTree('std', gljOprObj.treeData.std, true);
+            } else {
+                gljOprObj.initClassTree('comple', gljOprObj.treeData.comple, true);
+            }
+            gljOprObj.initSelection({row: 0});
+            //gljOprObj.gljLibSheetData = gljOprObj[val];
+            /*gljOprObj.filterLibGLJSheetData();
+            gljOprObj.showLibGLJSheetData();*/
         }
     });
 /*    //工料机搜索
@@ -1494,6 +1526,7 @@ $(function () {
     $('#gljSearchKeyword').bind('keyup', function (e) {
         gljOprObj.filterLibGLJSheetData();
         gljOprObj.showLibGLJSheetData();
+        gljOprObj.initSelection({row: 0});
     });
 
     $('#glj_selected_conf').click(function () {

+ 4 - 1
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -378,7 +378,9 @@ function getGLJData(actionType) {
     $.bootstrapLoading.start();
     projectObj.project.ration_glj.getGLJData(function (result) {
         console.log(+new Date());
-        zTreeHelper.createTree(result.datas.treeData, gljOprObj.gljTreeSetting, "gljTree", gljOprObj);
+        gljOprObj.treeData =  result.datas.treeData;
+        //zTreeHelper.createTree(result.datas.treeData, gljOprObj.gljTreeSetting, "gljTree", gljOprObj);
+        gljOprObj.initClassTree('std', gljOprObj.treeData.std);
         gljOprObj.stdGLJ=result.datas.stdGLJ;
         gljOprObj.complementaryGLJs=result.datas.complementaryGLJs;
         for(let compleGlj of gljOprObj.complementaryGLJs){
@@ -386,6 +388,7 @@ function getGLJData(actionType) {
             compleGlj.isComplementary = true;
         }
         gljOprObj.AllRecode=gljOprObj.stdGLJ.concat(gljOprObj.complementaryGLJs);
+        //gljOprObj.AllRecode=gljOprObj.stdGLJ;
         gljOprObj.distTypeTree=gljOprObj.getComboData(result.datas.distTypeTree);
         $('#modalCon').width($(window).width()*0.5);
         $("input[name='glj']").get(0).checked=true;

+ 27 - 9
web/building_saas/main/js/views/locate_view.js

@@ -73,6 +73,14 @@ let locateObject={
             this.subSpread.refresh();
         }
     },
+    refreshWorkBook: function () {
+        if (this.mainSpread) {
+            this.mainSpread.refresh();
+        }
+        if (this.subSpread) {
+            this.subSpread.refresh();
+        }
+    },
     initSubSheet:function () {
         this.subSheet = this.subSpread .getSheet(0);
         sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
@@ -85,19 +93,29 @@ let locateObject={
         //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
         this.mainSpread.getActiveSheet().setRowCount(datas.length);
     },
+    refreshView: function (options, refreshWorkBook) {
+        let me = this;
+        let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
+        let subHeight = 0;
+        $('#locateTopDiv').height(mainHeight);
+        $('#locate_result').height(mainHeight);
+        $('#locateBottomDiv').height(subHeight);
+        $('#locate_sub').height(subHeight - 7);
+        if(options == "ration_glj"){
+            let locateLibResize = getLocateLibResize();
+            SlideResize.loadVerticalHeight(locateLibResize.eleObj.module, locateLibResize.eleObj, locateLibResize.limit, function () {
+                locateObject.refreshWorkBook();
+            });
+        }
+        if (refreshWorkBook) {
+            me.refreshWorkBook();
+        }
+    },
     init:function () {
         let me = this;
         let options = $("input[name='content_type']:checked").val();
         let callback = function () {
-            let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
-            let subHeight = 0;
-            if(options == "ration_glj"){
-                subHeight = mainHeight*0.4;
-                mainHeight = mainHeight*0.6;
-            }
-            console.log(mainHeight);
-            $('#locate_result').height(mainHeight);
-            $('#locate_sub').height(subHeight - 7);
+            me.refreshView(options, false);
             me.initMainSpread();
             me.initSubSpread();
             me.showMainData();

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

@@ -306,6 +306,7 @@ let MainTreeCol = {
             ) {
                 // var names = new GC.Spread.Sheets.CellTypes.ComboBox();
                 var names = sheetCommonObj.getDynamicCombo();
+                names._maxDropDownItems = 10;
                 names.items(projectObj.project.calcProgram.compiledTemplateNames);
                 return names;
             }

+ 84 - 32
web/building_saas/main/js/views/mbzm_view.js

@@ -15,8 +15,8 @@ let mbzm_obj={
         header: [
             {headerName: "编码", headerWidth: 130, dataCode: "code", dataType: "String", formatter: "@"},
             {headerName: "模板类别", headerWidth: 260, dataCode: "name", dataType: "String", hAlign: "left"},
-            {headerName: "系数", headerWidth: 65, dataCode: "coe", dataType: "Number",validator:"number"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center",getText:'forUnit'},
+            {headerName: "系数", headerWidth: 65, dataCode: "coe", dataType: "Number",validator:"number"},
             {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number",validator:"number"},
             {headerName: "关联类别", headerWidth: 100, dataCode: "type", dataType: "String"},
             {headerName: "清单位置", headerWidth: 200, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton',getText:'forPosition'},
@@ -57,6 +57,9 @@ let mbzm_obj={
         this.sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSheetValueChange);
         this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, installationFeeObj.onPositionButtonClick);//共用一个位置选择器
         this.sheet.name('ration_template');
+        if(projectReadOnly){
+            disableSpread(this.spread);
+        }
     },
     refresh:function () {
         let total = $('#mbzmSpread').parent().height();
@@ -78,7 +81,7 @@ let mbzm_obj={
                 if(template) {
                     $("#createLocation").val(template.createLocation);
                     let pcol = _.findIndex(this.setting.header,{dataCode:"position"});
-                    this.setting.header[pcol].visible = template.createLocation == 3?false:true;
+                    this.setting.header[pcol].visible = template.createLocation == this.locateMap.AFTERRATION?false:true;
                     datas = _.cloneDeep(template.templateList);
                 }
             }
@@ -117,7 +120,7 @@ let mbzm_obj={
     },
     updatePosition:function (recode) {
         let selection = this.sheet.getSelections()[0];
-        let selectedItem  =(this.datas[selection.row]);
+        let selectedItem =this.datas[selection.row];
         let updateField = $("#createLocation").val()==this.locateMap.INMEASURE?"billID":"fxID";
         if(selectedItem[updateField] == recode.ID) return;
         selectedItem[updateField] = recode.ID;
@@ -132,7 +135,7 @@ let mbzm_obj={
         if(this.datas.length <= 0) return;
         for(let d of this.datas){
             if(gljUtil.isDef(d.quantity)&& parseFloat(d.quantity)>0){
-                if(this.positionChecking(createLocation,d) == false){
+                if(this.positionChecking(createLocation,d) == false){//清单位置检查
                     alert(`请选择${d.code}生成的清单位置`);
                     return;
                 }
@@ -149,15 +152,37 @@ let mbzm_obj={
         console.log(data);
         $.bootstrapLoading.start();
         CommonAjax.post('/ration/applyTemplate',data,function (result) {
-            $.bootstrapLoading.end();
             let refreshNodes = projectObj.project.updateNodesCache(result.updateDatas);//更新要update的前端缓存,并返回要刷新的树节点
+            let nodeDatas = {ration:{add:[]}, bills:{add:[]}};
+            if(result.rationResult){
+                for(let rr of result.rationResult){
+                    nodeDatas.ration.add.push(rr.ration);//定额datas数据的push在addNodes里面做
+                    projectObj.project.Ration.addSubListOfRation(rr);//添加定额子项缓存
+                }
+            }
             //对于新插入的清单:
             if(result.billsResult.length > 0){
-
+                nodeDatas.bills.add = result.billsResult;
             }
-            //对于新插入的定额
-
+            let calRations = ProjectController.addNewNodes(nodeDatas);
+            if(refreshNodes.length > 0){
+                for(let r of refreshNodes){
+                    if(r.sourceType == ModuleNames.ration){
+                        calRations.push(r);
+                        if(r.data.quantityEXP =="MBGCL" ) projectObj.project.quantity_detail.cleanQuantityDetail(r,true);
+                    }
+                }
+                projectObj.mainController.refreshTreeNode(refreshNodes, false);
+            }
+            projectObj.project.projectGLJ.loadData(function () {
+                $.bootstrapLoading.end();
+                cbTools.refreshFormulaNodes();
+                //更新计算程序模板,并进行重新计算
+                projectObj.project.calcProgram.calcNodesAndSave(calRations,function () {
+                    installationFeeObj.calcInstallationFee();
+                });
 
+            });
             console.log(result);
         })
 
@@ -171,7 +196,7 @@ let mbzm_obj={
             }else if(_.isEmpty(data.billsLocation)){
                 validate = false
             }
-        }else {
+        }else if(type == mbzm_obj.locateMap.INFBFX){
             if(_.isEmpty(data.fxID)) {
                 validate = false;
             }else {
@@ -189,6 +214,7 @@ let mbzm_obj={
         let ration = this.getExistRation(data,referenceRationID,type);
         if(ration) {//如果存在,则比较清耗量、工程量表达式是否一致
             let tem =  this.getRationData(ration,data,quantity);//取更新信息
+
             if(tem){//如果不一致,则需要更新
                 rations.update.push(tem);
             }
@@ -204,30 +230,14 @@ let mbzm_obj={
         }else {
             this.createNewRationInFBFX(data,mainRation,quantity,rations,bills);
         }
-
-        /*[
-            {
-                type:'ration',
-                data:{
-                    projectID:1605,
-                    ID:"7b962fb0-1131-11e8-b3da-af725dadd7ae",
-                    name:'testRation'
-                }
-            },
-            {
-                type:'bills',
-                data:{
-                    projectID:1605,
-                    ID:"af9f0081-1127-11e8-99a8-2fc02230b6e7",
-                    name:'安全文明施工专项费用123'
-                }
-            }
-        ]*/
     },
     getRationData:function (ration,data,quantity) {
         let tem = {};
         if (ration.quantity + "" != quantity) tem.quantity = quantity;
-        if (gljUtil.isDef(data.coe) && data.coe != "0") tem.quantityEXP = "MBGCL";
+        if (gljUtil.isDef(data.coe) && data.coe != "0"&&ration.quantityEXP != "MBGCL") {
+            tem.isFromDetail = 0;
+            tem.quantityEXP = "MBGCL";
+        }
         if(!_.isEmpty(tem)) {
             tem.projectID = ration.projectID;
             tem.ID = ration.ID;
@@ -243,7 +253,7 @@ let mbzm_obj={
         if(rations.create.length > 0){
             serialNo = rations.create[rations.create.length -1].newData.serialNo + 1
         }
-        let n_ration = this.createNewRationData(data,newID,mainRation.data.referenceRationID,mainRation.data.billsItemID,serialNo,quantity,mainRation.data.libID);
+        let n_ration = this.createNewRationData(data,newID,mainRation.data.ID,mainRation.data.billsItemID,serialNo,quantity,mainRation.data.libID);
         rations.create.push(n_ration);
         //处理其它兄弟节点的序号
         let br = projectObj.project.Ration.getBillsSortRation();
@@ -279,7 +289,18 @@ let mbzm_obj={
                 }
             }
             if(billsID == ""){//也没有生成过的情况下,要自动生成清单
+                //2018-12-19  对于新生成的清单,根据新清单编码的前6位去查询有没有完全匹配的清单,有的话将这一节点做为新清单的父项清单
+                let subNodes=[];
+                //默认没有找到编码匹配的就挂在技术措施项目下
                 let parentNode = projectObj.project.Bills.getAutoParentNode("措施费用");
+                if(data.billsLocation.length >= 6){
+                    projectObj.mainController.tree.getAllSubNode(rootNode,subNodes);
+                    let tem_code = data.billsLocation.substr(0,6);
+                    let n_parentNode = _.find(subNodes,function (n) {
+                        return n.data.code == tem_code;
+                    });
+                    if(n_parentNode) parentNode = n_parentNode;
+                }
                 billsID = uuid.v1();
                 let newBill = {
                     ID:billsID,
@@ -287,6 +308,7 @@ let mbzm_obj={
                     ParentID:parentNode.data.ID,
                     NextSiblingID:-1,
                     code:projectObj.project.Bills.newFormatCode(data.billsLocation),
+                    type:billType.BILL,
                     billsLibId:projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id,//projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib
                     billsLocation : data.billsLocation//这个是用来在后端查找清单信息
                 };
@@ -385,7 +407,6 @@ let mbzm_obj={
         }
         return data.quantity
     },
-
     getExistRation:function (data,referenceRationID,type) {
         let temRation = null;
         //先检查要更新的定额是否已经存在
@@ -421,8 +442,35 @@ let mbzm_obj={
                 }
             }
         }
-
         return temRation;
+    },
+    hasReferenceRation:function (node) {
+        if(node.sourceType == ModuleNames.ration){
+            let  template = projectObj.project.ration_template.getTemplateByRationID(node.data.ID);
+            if(template){
+                let ration = _.find(projectObj.project.Ration.datas,{'referenceRationID':node.data.ID});
+                if(ration) return true;
+            }
+
+        }
+        return false;
+    },
+    deleteReferenceRation:function (mainNodes,updateNodes) {
+        let refNode = [];
+        for(let m of mainNodes){
+            if(this.hasReferenceRation(m)){
+                let  rations = _.filter(projectObj.project.Ration.datas,{'referenceRationID':m.data.ID});
+                for(let r of rations){
+                    let temNode =  projectObj.project.mainTree.getNodeByID(r.ID);
+                    if(temNode && updateNodes.indexOf(temNode) == -1){//能找到该节点,并且节点不在已经删除的列表中
+                        refNode.push(temNode);
+                        updateNodes.push(temNode);
+                        projectObj.mainController.tree.getAllSubNode(temNode,updateNodes)//添加显示到造价书页面的主材、设备节点
+                    }
+                }
+            }
+        }
+        return refNode;
     }
 };
 
@@ -435,6 +483,9 @@ $('#createLocation').change(function(){
 
 
 $('#next_mbzm').click(function () {
+    if (projectReadOnly) {
+        return;
+    }
     let mainSheet = projectObj.mainSpread.getActiveSheet();
     let selection = mainSheet.getSelections()[0];
     let node =  projectObj.project.mainTree.selected;
@@ -460,5 +511,6 @@ $('#next_mbzm').click(function () {
 });
 
 $('#apply_mbzm').click(function () {
+    if(projectReadOnly) return;
     mbzm_obj.applyTemplate();
 });

+ 17 - 9
web/building_saas/main/js/views/project_glj_view.js

@@ -1070,13 +1070,21 @@ projectGljObject={
 
 function getProjectResizeEles() {
     let pojGljResizeEles = {};
-    pojGljResizeEles.id = '#project-glj-main';
-    pojGljResizeEles.resize = $('#project-glj-main').find('.resize');
-    pojGljResizeEles.nearElement = $('#project-glj-main').find('.top-content');
-    pojGljResizeEles.nearSpread = pojGljResizeEles.nearElement.children(".main-data-top");
-    pojGljResizeEles.farElement = $('#project-glj-main').find('.bottom-content');
-    pojGljResizeEles.farSpread = pojGljResizeEles.farElement.children().find(".main-data-bottom");
-    pojGljResizeEles.nav = pojGljResizeEles.farElement.children('ul.nav');
+    pojGljResizeEles.eleObj = {
+        module: 'projectGlj',
+        resize: $('#projectGljResize'),
+        top: $('#projectGljTop'),
+        topSpread: $('#project_glj_sheet'),
+        bottom: $('#projectGljBottom'),
+        bottomSpread: $('#mix_ratio_sheet')
+    };
+    pojGljResizeEles.limit = {
+        min: 150,
+        max: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-150-10`,//10: resize.height()
+        notTopSpread: 0,
+        notBottomSpread: $('#projectGljBottom ul').height(),
+        totalHeight: `$(window).height()-$('.header').height()-$('#projectGljToolsBar').height()-10`
+    };
     return pojGljResizeEles;
 }
 
@@ -1084,7 +1092,7 @@ function getProjectResizeEles() {
 function loadProjectGljSize() {
     let me = projectGljObject;
     let pojGljResizeEles = getProjectResizeEles();
-    loadSize(pojGljResizeEles, 'height', function () {
+    SlideResize.loadVerticalHeight(pojGljResizeEles.eleObj.module, pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
         me.projectGljSpread?me.projectGljSpread.refresh():'';
         me.mixRatioSpread?me.mixRatioSpread.refresh():'';
     });
@@ -1116,7 +1124,7 @@ function getFileHierarchyInfo(treeData){
 
 $(function () {
     let pojGljResizeEles =  getProjectResizeEles();
-    slideResize(pojGljResizeEles, {min: 170, max: 700}, 'height', function () {
+    SlideResize.verticalSlide(pojGljResizeEles.eleObj, pojGljResizeEles.limit, function () {
         projectGljObject.projectGljSpread.refresh();
         projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
     });

+ 4 - 1
web/building_saas/main/js/views/project_info.js

@@ -18,7 +18,10 @@ var projectInfoObj = {
                 <span data-toggle="tooltip" data-placement="bottom" data-original-title="${engName}"><i class="fa fa-cube"></i>...</span>
                 <span class="text-muted px-1">\</span>
                  <span><i class="fa fa-sticky-note-o"></i></span>
-                <span class="text-truncate"  data-toggle="tooltip" data-placement="bottom" data-original-title="${proj.name}">&nbsp;${proj.name}</span>`;
+                <span class="text-truncate"  data-toggle="tooltip" data-placement="bottom" data-original-title="${proj.name}">&nbsp;${proj.name}</span>
+                ${projectReadOnly ? '' +
+                '<span data-toggle="tooltip" data-placement="bottom" data-original-title="当前的工程状态为“只读”,如果要进行编辑,请在项目管理-分享界面,使用“拷贝工程”功能。">(只读)</span>' 
+                : ''}`;
             fullPath.push(newHtml);
 
         }

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

@@ -488,7 +488,10 @@ $(document).ready(function () {
     $('#tab_poj-settings-basicInfo').on('shown.bs.tab', function () {
         basicInfoView.workBook.refresh();
     });
-
+    $('#openProjSet').click(function () {
+        $('[data-toggle="tooltip"]').tooltip('hide');
+        $('#poj-set').modal('show');
+    })
    /* $('#property_ok').bind('click', function () {
         if(basicInfoView.toUpdate(basicInfoView.orgDatas, basicInfoView.datas)){
             basicInfoView.a_updateInfo(basicInfoView.toSaveDatas(basicInfoView.datas));

+ 222 - 44
web/building_saas/main/js/views/project_view.js

@@ -806,12 +806,15 @@ var projectObj = {
         };
     },
     mainSpreadEditEnded: function (sender, info) {
-        console.log('enterEDEnd');
         let project = projectObj.project;
         let node = project.mainTree.items[info.row];
         project.withinBillsLocked(node);
         let colSetting = projectObj.mainController.setting.cols[info.col];
         let fieldName = projectObj.mainController.setting.cols[info.col].data.field;
+        //提前处理
+        if (fieldName === 'code' || fieldName === 'name' || fieldName === 'unit') {
+            info.editingText = info.editingText ? info.editingText.toString().replace(new RegExp(/[\r,\n]/g), '') : info.editingText;
+        }
         // 检查输入类型等
         let value = projectObj.checkSpreadEditingText(info.editingText, colSetting);
         projectObj.updateCellValue(node, value, colSetting,info.editingText);
@@ -901,6 +904,7 @@ var projectObj = {
                 // that.project.initCalcFields();
                 let str = JSON.stringify(that.project.projSetting.main_tree_col);
                 that.project.projSetting.mainGridSetting = JSON.parse(str);
+                console.log(that.project.projSetting.mainGridSetting);
                 that.project.projSetting.mainGridSetting.frozenCols = 4;
                 TREE_SHEET_HELPER.initSetting($('#billsSpread')[0], that.project.projSetting.mainGridSetting);
                 that.project.projSetting.mainGridSetting.setAutoFitRow = MainTreeCol.getEvent("setAutoFitRow");
@@ -973,11 +977,10 @@ var projectObj = {
                 that.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, that.onCellDoubleClick);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.ColumnWidthChanged, that.onColumnWidthChanged);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, that.onClipboardPasting);
-
                 //let loadOtherStartTime = +new Date();
-                if(!projectReadOnly){
+                //if(!projectReadOnly){
                     that.loadMainSpreadContextMenu();
-                }
+                //}
                 socketObject.connect();//连接socket服务器
                 let endTime = +new Date();
                 console.log(`其它时间——${endTime - endShowTime}`);
@@ -1157,6 +1160,7 @@ var projectObj = {
             selector: '#billsSpread',
             selectableSubMenu: true,
             build: function ($trigger, e) {
+                projectObj.cusRationCombCheck(spread.getActiveSheet());
                 var target = SheetDataHelper.safeRightClickSelection($trigger, e, spread);
                 controller.setTreeSelected(controller.tree.items[target.row]);
                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
@@ -1166,7 +1170,7 @@ var projectObj = {
                     name: "插入大项费用",
                     icon: 'fa-sign-in',
                     disabled: function () {
-                        return projectObj.project.isBillsLocked() && project.withinBillsLocked(project.mainTree.selected);
+                        return projectReadOnly || (projectObj.project.isBillsLocked() && project.withinBillsLocked(project.mainTree.selected));
                         //return project.mainTree.selected ? project.mainTree.selected.sourceType !== project.Bills.getSourceType() : false;
                     },
                     callback: function (key, opt) {
@@ -1180,6 +1184,9 @@ var projectObj = {
                     name: "插入分部",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let selected = project.mainTree.selected;
                         if(projectObj.project.isBillsLocked()== false&&selected&&selected.sourceType==project.Bills.getSourceType()){
                             if(selected.data.type==billType.FB){
@@ -1211,6 +1218,9 @@ var projectObj = {
                     name: "插入分项",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let selected = project.mainTree.selected;
                         if(projectObj.project.isBillsLocked()== false&& selected&&selected.sourceType==project.Bills.getSourceType()){
                             if(selected.data.type==billType.FX||selected.data.type==billType.BX){//焦点行是分项,有效显示
@@ -1249,6 +1259,9 @@ var projectObj = {
                     name: "插入清单",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let selected = project.mainTree.selected;
                         if(!(projectObj.project.isBillsLocked()== true && project.withinBillsLocked(selected)) && selected && selected.sourceType === project.Bills.getSourceType()){
                             return false
@@ -1278,6 +1291,9 @@ var projectObj = {
                     name: "插入定额",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         // var selected = project.mainTree.selected;
                         // return project.Ration.addRationChecking(selected);  // Vincent, 2018-01-02
                         // 工具栏要加按钮,且不能隐藏。菜单可以隐藏,两者又必须统一,所以启用新规则。怕以后又要改回来,所以保留。 CSL, 2018-01-02
@@ -1296,6 +1312,9 @@ var projectObj = {
                     name: "插入量价",//插入量价不需要自动定位到编号列
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         // var selected = project.mainTree.selected;
                         // return project.Ration.addRationChecking(selected);  // Vincent, 2018-01-02
                         return !project.Ration.canAdd(project.mainTree.selected);
@@ -1348,6 +1367,9 @@ var projectObj = {
                     name: "插入人材机",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         // var selected = project.mainTree.selected;
                         // return project.Ration.addRationChecking(selected);  // Vincent, 2018-01-02
                         return !project.Ration.canAdd(project.mainTree.selected);
@@ -1373,6 +1395,9 @@ var projectObj = {
                     name: "计取安装费用",
                     icon: 'fa-sign-in',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         return false;
                     },
                     callback: function (key, opt) {
@@ -1386,12 +1411,15 @@ var projectObj = {
                     name: '删除',
                     icon: 'fa-remove',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         return !ifCanDelete();
                     },
                     callback: function () {
                         var selected = project.mainTree.selected;
                         if(selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
-                            project.Bills.deleteSelectedNode();
+                            project.Bills.deleteSelectedNodes();//project.Bills.deleteSelectedNode();
                         }else {
                             $("#delete_row").modal({show:true});//弹出删除提示框;
                         }
@@ -1403,6 +1431,11 @@ var projectObj = {
                     callback: function () {
                         project.calcProgram.calcAllNodesAndSave();
                     },
+                    disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
+                    },
                     visible:function(key, opt){//2018-11-15 新需求隐藏右键“造价计算”。
                         return false;
                     }
@@ -1412,6 +1445,9 @@ var projectObj = {
                     name: '复制整块',
                     icon: 'fa-copy',
                     disabled: function () {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let selection = projectObj.mainSpread.getActiveSheet().getSelections()[0];
                         let firstNode = projectObj.project.mainTree.items[selection.row];//当多选的情况,用mainTree.selected判断不正确,要用第一个选中的节点
                         for(let i = 0;i< selection.rowCount;i++){ //多选的时候判断所有与第一个节点同级的节点
@@ -1439,6 +1475,9 @@ var projectObj = {
                     name: '粘贴整块',
                     icon: 'fa-paste',
                     disabled: function (){
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         return BlockController.pasteBtnDisable(project.mainTree.selected);
                     },
                     callback: function () {
@@ -1448,6 +1487,9 @@ var projectObj = {
                 "editEngineer": {
                     name: '编辑工程内容',
                     icon: 'fa-edit',
+                    disabled: function () {
+                        return projectReadOnly;
+                    },
                     visible: function(key, opt){
                          let  selected = project.mainTree.selected;
                          return selected.sourceType==ModuleNames.bills&&project.Bills.isEngineerEst(selected);//当焦点行是“专业工程暂估价”时,右键可见并有效。
@@ -1462,6 +1504,9 @@ var projectObj = {
                 "editService": {
                     name: '编辑服务内容',
                     icon: 'fa-edit',
+                    disabled: function () {
+                        return projectReadOnly;
+                    },
                     visible: function(key, opt){
                         let  selected = project.mainTree.selected;
                         return selected.sourceType==ModuleNames.bills&&project.Bills.isTotalService(selected);//当焦点行是“总承包服务费”时,右键可见并有效。
@@ -1476,6 +1521,9 @@ var projectObj = {
                 "editAccording": {
                     name: '编辑签证及索赔依据',
                     icon: 'fa-edit',
+                    disabled: function () {
+                        return projectReadOnly;
+                    },
                     visible: function(key, opt){
                         let  selected = project.mainTree.selected;
                         return selected.sourceType==ModuleNames.bills&&project.Bills.isClaimVisa(selected);//当焦点行是“签证及索赔计价”时,右键可见并有效。
@@ -1491,6 +1539,9 @@ var projectObj = {
                     name:'智能材料替换',
                     icon: 'fa-edit',
                     disabled:function (key,opt) {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let  selected = project.mainTree.selected;
                         return selected.sourceType==ModuleNames.bills ?!(project.Bills.isFXorBX(selected)||selected.source.children.length ==0):true//是分项、补项或叶子清单才有效;
                     },
@@ -1505,15 +1556,14 @@ var projectObj = {
                     name:'生成组价模板',
                     icon: 'fa-puzzle-piece',
                     disabled:function (key,opt) {
+                        if (projectReadOnly) {
+                            return true;
+                        }
                         let selected = project.mainTree.selected;
                         return selected.sourceType != ModuleNames.bills;
                     },
-                    callback:function(){
-                        if (!$("#kmbk").is(":visible")){
-                            $('#blockLibTab').click()
-                        };
-
-                        $("#zujiamb").modal({show: true});
+                    callback: function(){
+                        blockLibObj.checkShow();
                     },
                     visible: function(key, opt){
                         return G_SHOW_BLOCK_LIB;
@@ -1993,6 +2043,12 @@ var projectObj = {
             if(field != null) projectObj.mainController.sheet.setSelection(newNode.serialNo(), colSettingObj.getColByField(field), 1, 1);  //自动定位到编号单元格
             projectObj.mainSpread.focus();
         }
+    },
+    cusRationCombCheck:function (sheet) {//检查自定义定额编号下拉框,右键的时候不自动消失,现手动结束编辑,并删除元素
+        if(sheet.isEditing()){
+            sheet.endEdit()
+        }
+        if($("#rationCheckBox").is(':visible'))  $("#rationCheckBox").parent().parent().remove();
     }
 
 
@@ -2156,6 +2212,27 @@ let displayLevel = function(nodes, depth, type){
         TREE_SHEET_HELPER.refreshNodesVisible(refreshNodes, projectObj.mainSpread.getActiveSheet(), true)
     });
 };
+$('body').click(function () {
+    //点击完后隐藏子菜单
+   if ($('#subDisplay').is(':visible')) {
+       $('#subDisplay').removeClass('show');
+   }
+});
+let enterDisplayA = false;
+//鼠标移到显示至,自动弹出子菜单
+$('#displayA').mouseenter(function (e) {
+    enterDisplayA = true;
+    $('#subDisplay').addClass('show');
+});
+$('#displayA').mouseleave(function () {
+    enterDisplayA = false;
+});
+$('#moreMenu > a').mouseenter(function () {
+   if (!enterDisplayA) {
+       $('#subDisplay').removeClass('show');
+   }
+});
+
 $('#displayDXFY').click(function () {
    displayLevel(projectObj.project.mainTree.items, 0, 'DXFY')
 });
@@ -2239,27 +2316,59 @@ $('#recColSetting').click(function () {
         $('#recColSetting').removeClass('disabled');
     });
 });
-
 //恢复默认系统设置
 $('#property_default').click(function () {
     let project = projectObj.project,
         projectID = project.ID();
+    /*
+    * 清除窗口比例缓存
+    * */
     //清单精灵/指引窗口比例
-    removeLocalCache('farwidth:stdBillsGuidanceTab');
-    removeLocalCache('nearwidth:stdBillsGuidanceTab');
-    removeLocalCache('farheight:#zy');
-    removeLocalCache('nearheight:#zy');
+    removeLocalCache('stdBillsGuidanceTabmainWidth');
+    removeLocalCache('stdBillsGuidanceTabmainSideWidth');
     //定额库窗口比例
-    removeLocalCache('farwidth:stdRationTab');
-    removeLocalCache('nearwidth:stdRationTab');
-    removeLocalCache('farheight:#de');
-    removeLocalCache('nearheight:#de');
+    removeLocalCache('stdRationTabmainWidth');
+    removeLocalCache('stdRationTabmainSideWidth');
+    removeLocalCache('dedeTopDivHeight');
+    removeLocalCache('dedeBottomDivHeight');
+    //查找定位窗口比例
+    removeLocalCache('locateTabmainWidth');
+    removeLocalCache('locateTabmainSideWidth');
+    removeLocalCache('locatelocateTopDivHeight');
+    removeLocalCache('locatelocateBottomDivHeight');
+    //块模板库窗口比例
+    removeLocalCache('kmbkkmbkTopDivHeight');
+    removeLocalCache('kmbkkmbkMidDivHeight');
+    removeLocalCache('kmbkkmbkBottomDivHeight');
     //主界面窗口比例
-    removeLocalCache('farheight:#main');
-    removeLocalCache('nearheight:#main');
+    removeLocalCache('mainVerticaltop_divHeight');
+    removeLocalCache('mainVerticalbottom_divHeight');
+    //造价书下方-人材机和项目特征文本
+    removeLocalCache('subRcjsubSpreadWidth');
+    removeLocalCache('subRcjitemTextDivWidth');
+    //造价书下方-子目换算下调整状态和辅助值
+    removeLocalCache('subRcjitemTextDivWidth');
+    removeLocalCache('subRcjitemTextDivWidth');
+    //造价书下方-特征及内容窗口比例
+    removeLocalCache('subZmhscoeSpreadWidth');
+    removeLocalCache('subZmhsassDivWidth');
     //人材机汇总窗口比例
-    removeLocalCache('farheight:#project-glj-main');
-    removeLocalCache('nearheight:#project-glj-main');
+    removeLocalCache('projectGljprojectGljTopHeight');
+    removeLocalCache('projectGljprojectGljBottomHeight');
+    //补充人材机库
+    removeLocalCache('compleGLjleftContentWidth');
+    removeLocalCache('compleGLjmidContentWidth');
+    removeLocalCache('compleGLjrightContentWidth');
+    //补充定额库
+    removeLocalCache('compleRationleftContentWidth');
+    removeLocalCache('compleRationmainContentWidth');
+    removeLocalCache('compleRationzmhsContentWidth');
+    removeLocalCache('compleRationrationItemsSheetHeight');
+    removeLocalCache('compleRationsubContentHeight');
+    removeLocalCache('compleRationmainSpreadHeight');
+    removeLocalCache('compleRationcontentSpreadHeight');
+
+    //在后台恢复一些设置
     CommonAjax.post('/pm/api/defaultSettings', {user_id: userID, projectID: projectID}, function (rstData) {
         window.location.href = `/main?project=${projectID}`;
     });
@@ -2474,6 +2583,8 @@ $('#delete_row').on('show.bs.modal', function (e) {//这里用show,在shown之
             showN = true;
             cancelText = "取消";
         }
+    }else if(isSingleSelect()&&mbzm_obj.hasReferenceRation(selected)){//“有模板关联的定额”右键点击删除,弹窗提示“删除主子目时将删除对应的关联子目,是否继续?  是 否” (只有单选中一条定额并且是有模板关联的定额)
+        showinfo = "<label>删除主子目时将删除对应的关联子目,是否继续?</label>";
     }
     $('#delete_showinfo').html(showinfo);
     showN==true? $('#deleteN').show():$('#deleteN').hide();
@@ -2874,13 +2985,13 @@ $(function () {
 
     });
 
-    $("#zujiamb").on('show.bs.modal', function(){
+    $("#div_createBlocks").on('show.bs.modal', function(){
         function getBlockCategoriesHtml(Categories) {
             let result = '';
             if (Categories.length <= 0) return result;
 
             for (let c of Categories){
-                result += '<option value="'+ c.data.ID +'">'+ c.data.name +'</option>';
+                result += '<option value="'+ c.data.ID +'">'+ c.data.nodeName +'</option>';
             };
             return result;
         };
@@ -2888,22 +2999,43 @@ $(function () {
         let sHtml = getBlockCategoriesHtml(blockLibObj.getCategories());
         $("#select_block_category").html(sHtml);
         $("#select_block_category")[0].selectedIndex = 0;
+        $('#ckb_block_exist_cover').prop("checked", false);
     });
 
-    $("#btn_block_createBlocks").click(function () {
+    $("#div_cloneOptions").on('show.bs.modal', function(){
+        let s = '';
+        switch (blockLibObj.cloneType) {
+            case 1:
+                s = '一对一克隆';
+                break;
+            case 2:
+                s = '一对多克隆';
+                break;
+            case 3:
+                s = '多对多克隆';
+                break;
+        }
+        s = `<span style='color:red;'>${s}</span>`;
+        $('#clone_option_title').html(`快速组价 (${s})`);
+        $('#clone_option_code').prop("checked", true);
+        $('#clone_option_name').prop("checked", false);
+        $('#clone_option_unit').prop("checked", true);
+        $('#clone_option_quantity').prop("checked", true);
+        $('#clone_option_noCover').prop("checked", true);
+    });
+
+    $("#btn_block_createBlocks").click(async function () {
         if ($("#select_block_category")[0].options.length < 1) return;
         let cID = $("#select_block_category").val();
         let selected = projectObj.project.mainTree.selected;
-
-        function createBlocks(aNode, categoryID){
-            function createBlock(node) {
+        let cover = $('#ckb_block_exist_cover').prop("checked");
+        async function createBlocks(aNode, categoryID){
+            async function createBlock(node) {
                 if (node.data.name == undefined || node.data.name == '') return;  // 清单名称为空,不生成块模板文件
-                let name = node.data.code + ' ' + node.data.name + ' ' + node.data.unit;
-                name = name.replace(/^\s+|\s+$/g, "");    // 只去两头空格
-
+                if (node.children.length == 0) return;
                 // 封装成伟城的块文件格式,直接调用伟城接口(定额这里的业务太多太庞杂,不要再重做一遍,尽量共用,维护代价小)
                 // 块文件要构建自己的树结构,所以也有自己的一部分数据。两种结构揉合在一起,显得有点杂乱,但利大于弊。
-                let block_WC = {
+                let vBlock_WC = {
                     compilationID: projectInfoObj.projectInfo.compilation,
                     firstNodeType: node.data.type,
                     isFBFX: projectObj.project.Bills.isFBFX(node),
@@ -2911,11 +3043,20 @@ $(function () {
                     datas: []
                 };
                 let ration_glj_Map = _.groupBy(projectObj.project.ration_glj.datas, 'rationID');
-                block_WC.datas.push(BlockController.getNodeDatas(node, ration_glj_Map));
-                blockLibObj.newNode(2, name, categoryID, block_WC);
+                vBlock_WC.datas.push(BlockController.getNodeDatas(node, ration_glj_Map));
+                vBlock_WC = JSON.parse(JSON.stringify(vBlock_WC));
+                let fileName = node.data.code + ' ' + node.data.name + ' ' + node.data.unit;
+                fileName = fileName.replace(/^\s+|\s+$/g, "");    // 只去两头空格
+
+                let extN = blockLibObj.getSameNameNode(fileName);
+                if (extN){
+                    if (cover) blockLibObj.assignData(extN, vBlock_WC);
+                }
+                else
+                    await blockLibObj.newNode(2, fileName, categoryID, vBlock_WC);
             };
 
-            function createRecursion(node){
+            async function createRecursion(node){
                 if (!node) return;
 
                 if (calcTools.isLeafBill(node)) createBlock(node);
@@ -2925,14 +3066,48 @@ $(function () {
             };
 
             if (calcTools.isLeafBill(aNode))
-                createBlock(aNode)
+               await createBlock(aNode)
             else
-                createRecursion(aNode.firstChild());
+               await createRecursion(aNode.firstChild());
         };
 
-        createBlocks(selected, cID);
+        await createBlocks(selected, cID);
         blockLibObj.loadDetailDatas(blockLibObj.mainTree.selected);
-        $("#zujiamb").modal("hide");
+        $("#div_createBlocks").modal("hide");
+    });
+
+    $("#btn_block_clone_ok").click(function () {
+        let projectNode = projectObj.project.mainTree.selected;
+        let block = blockLibObj.mainTree.selected;
+        let options = {};
+        if ($('#clone_option_code').prop("checked")) options.checkCode = true;
+        if ($('#clone_option_name').prop("checked")) options.checkName = true;
+        if ($('#clone_option_unit').prop("checked")) options.checkUnit = true;
+        if ($('#clone_option_zeroQuantity').prop("checked")) options.zeroQuantity = true;
+        if ($('#clone_option_cover').prop("checked")) options.overwriteRations = true;
+
+        switch (blockLibObj.cloneType) {
+            case 1:
+                blockLibObj.oneToOneClone(projectNode, block, options);
+                break;
+            case 2:
+                let bills = calcTools.getLeafBills(projectNode);
+                for (let bill of bills){
+                    calcTools.forceSelect(bill);
+                    blockLibObj.oneToOneClone(bill, block, options);
+                };
+                break;
+            case 3:
+                let mtmBills = calcTools.getLeafBills(projectNode);
+                let mtmBlocks = blockLibObj.mainTree.selected.children;
+                for (let mtmBill of mtmBills){
+                    for (let mtmBlock of mtmBlocks){
+                        calcTools.forceSelect(mtmBill);
+                        blockLibObj.oneToOneClone(mtmBill, mtmBlock, options);
+                    };
+                };
+                break;
+        }
     });
 
 
@@ -2979,6 +3154,9 @@ function disableTools(){
     //清单精灵
     $('#elfInsertRation').addClass('disabled');
     $('#elfInsertSingle').addClass('disabled');
+    //模板子目:应用、下一条
+    $('#apply_mbzm').addClass('disabled');
+    $('#next_mbzm').addClass('disabled');
     //特征及内容
     $('#add-rule').find('select').prop('disabled', 'disabled');
     $('#use-to-current').addClass('disabled');
@@ -2993,9 +3171,9 @@ function disableTools(){
     $('#compleRationLib').addClass('disabled');
     $('#compleGljLib').addClass('disabled')
     //库
-    $('#stdBillsGuidanceTab').addClass('disabled');
+    //$('#stdBillsGuidanceTab').addClass('disabled');
     $('#stdBillsTab').addClass('disabled');
-    $('#stdRationTab').addClass('disabled');
+    //$('#stdRationTab').addClass('disabled');
     $('#blockLibTab').addClass('disabled');
     //人材机汇总,选择其他、另存使用
     $('a[data-target="#change-unitFile"]').remove();

+ 3 - 0
web/building_saas/main/js/views/quantity_edit_view.js

@@ -184,6 +184,9 @@ let quantityEditObj = {
             $("#quantityEditSpread").hide();
         }
         $("#quantityEXPValue").val(selected.data.quantityEXP);
+        selected.data.quantityEXP == "GCLMXHJ" || selected.data.quantityEXP =="MBGCL"?$("#quantityEXPValue").attr("disabled","disabled"):$("#quantityEXPValue").removeAttr("disabled");
+
+
     },
     checkingAndUpdate(quantityEXP,node){
         let me = this;

+ 149 - 82
web/building_saas/main/js/views/side_tools.js

@@ -7,127 +7,194 @@ $(window).resize(function() {
     billsGuidance.refreshWorkBook();
     rationLibObj.refreshSpread();
     BillsElf.setColumnWidthByRate();
+    loadSideToolsHeight();
+    //刷新主界面与各库中间的拖动条宽度:始终保持为一个宽度(在小窗口打开一个库,再放大窗口后,该拖动条宽度会变大)
+    SlideResize.setResizeWidth($('#sideResize'));
+    subObj.initGljSubTab();
+    refreshSubSpread();
+
 });
-//造价书与清单定额库左右拖动
+//造价书与库左右拖动
 let sideResizeEles = {};
-sideResizeEles.id = 'stdRationTab';
-sideResizeEles.resize = $('#sideResize');
-sideResizeEles.evFixedSize = `$(window).width()-$('.main-nav').width()-5`;
-sideResizeEles.nearElement = $('.main-content');
-sideResizeEles.nearSpread = $('.main-content');
-sideResizeEles.farElement = $('.main-side');
-sideResizeEles.farSpread = $('.main-side');
-sideResizeEles.nav = null;
-slideResize(sideResizeEles, {min: 250, max: $('#zaojiashu').width()-260}, 'width', function(){
-    adaptiveTzjnrWidth();
-    MaterialController.showReplaceDiv();
+sideResizeEles.eleObj = {
+    module: 'stdBillsGuidanceTab',
+    resize: $('#sideResize'),
+    parent: $('#mainRow'),
+    left: $('#main'),
+    right: $('#mainSide')
+};
+sideResizeEles.limit = {
+    min: 150,
+    max: `$('#mainRow').width()-150`
+};
+SlideResize.horizontalSlide(sideResizeEles.eleObj, sideResizeEles.limit, function(){
+   // MaterialController.showReplaceDiv();
+    subObj.initGljSubTab();
     pageCCOprObj.resizeWidth();
     BillsElf.setColumnWidthByRate();
     projectObj.refreshMainSpread();
     refreshSubSpread();
-    if(sideResizeEles.id === 'stdBillsGuidanceTab'){
+    if (sideResizeEles.eleObj.module === 'stdBillsGuidanceTab') {//清单精灵(规则)
         billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
         billsGuidance.refreshWorkBook();
-    }
-    else if(sideResizeEles.id === 'stdRationTab'){
+    } else if (sideResizeEles.eleObj.module === 'stdRationTab') {//定额库
         sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 40, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
         rationLibObj.refreshSpread();
-    }
-    else if(sideResizeEles.id === 'blockLibTab'){
+    } else if (sideResizeEles.eleObj.module === 'blockLibTab') {//块模板库
         blockLibObj.refreshSpread();
-    }
-    else{
-        billsLibObj.refreshBillsSpread();
-        billsLibObj.refreshBillsRelaSpread();
+    } else if (sideResizeEles.eleObj.module === 'locateTab'){//查找定位
+        locateObject.refreshWorkBook();
     }
 });
 
-/*//清单指引上下拖动
-let billsGuidanceLibResizeEles = {};
-billsGuidanceLibResizeEles.id = '#zy';
-billsGuidanceLibResizeEles.resize = $('#zyResize');
-billsGuidanceLibResizeEles.nearElement = $('#zy').find('.top-content');
-billsGuidanceLibResizeEles.nearSpread = $('#billsGuidance_bills');
-billsGuidanceLibResizeEles.farElement = $('#zy').find('.bottom-content');
-billsGuidanceLibResizeEles.farSpread = $('#billsGuidance_items');
-billsGuidanceLibResizeEles.nav = null;
-slideResize(billsGuidanceLibResizeEles, {min: 147, max: 680}, 'height', function() {
-    billsGuidance.refreshWorkBook();
-});*/
-
 //定额库上下拖动
 let rationLibResizeEles = {};
-rationLibResizeEles.id = '#de';
-rationLibResizeEles.resize = $('#deResize');
-rationLibResizeEles.nearElement = $('#de').find('.top-content');
-rationLibResizeEles.nearSpread = $('#stdRationChapter');
-rationLibResizeEles.farElement = $('#de').find('.bottom-content');
-rationLibResizeEles.farSpread = $('#stdSectionRations');
-rationLibResizeEles.nav = null;
-slideResize(rationLibResizeEles, {min: 147, max: 680}, 'height', function() {
+rationLibResizeEles.eleObj = {
+    module: 'de',
+    resize: $('#deResize'),
+    top: $('#deTopDiv'),
+    topSpread: $('#stdRationChapter'),
+    bottom: $('#deBottomDiv'),
+    bottomSpread: $('#stdSectionRations')
+};
+rationLibResizeEles.limit = {
+    min: 150,
+    max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#deToolsBar').height()-150-10`,//10: resize.height()
+    notTopSpread: 0,
+    notBottomSpread: 0,
+    totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#deToolsBar').height()-10`
+};
+SlideResize.verticalSlide(rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
     rationLibObj.refreshSpread();
 });
 
-//清单库上下拖动
-let billsLibResizeEles = {};
-billsLibResizeEles.id = '#qd';
-billsLibResizeEles.resize = $('#qdResize');
-billsLibResizeEles.nearElement = $('#qd').find('.top-content');
-billsLibResizeEles.nearSpread = $('#stdBillsSpread');
-billsLibResizeEles.farElement = $('#qd').find('.bottom-content');
-billsLibResizeEles.farSpread = billsLibResizeEles.farElement.find('.p-0');
-billsLibResizeEles.nav = null;
-slideResize(billsLibResizeEles, {min: 147, max: 680}, 'height', function() {
-    billsLibObj.refreshBillsSpread();
-    billsLibObj.refreshBillsRelaSpread();
+//查找定位上下拖动
+function getLocateLibResize(){
+    let resizeObj = {};
+    resizeObj.eleObj = {
+        module: 'locate',
+        resize: $('#locate_resize'),
+        top: $('#locateTopDiv'),
+        topSpread: $('#locate_result'),
+        bottom: $('#locateBottomDiv'),
+        bottomSpread: $('#locate_sub')
+    };
+    resizeObj.limit = {
+        min: 150,
+        max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-150-10`,//10: resize.height()
+        notTopSpread: 0,
+        notBottomSpread: 0,
+        totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#searchPanel').height()-10`
+    };
+    return resizeObj;
+}
+let locateLibResize = getLocateLibResize();
+SlideResize.verticalSlide(locateLibResize.eleObj, locateLibResize.limit, function () {
+    locateObject.refreshWorkBook();
 });
 
-// 块模板库上下拖动
-let blockLibResizeEles = {};
-blockLibResizeEles.id = '#kmbk';
-blockLibResizeEles.resize = $('#kmbkResize');
-blockLibResizeEles.nearElement = $('#kmbk').find('.top-content');
-blockLibResizeEles.nearSpread = $('#div_block_tree');
-blockLibResizeEles.farElement = $('#kmbk').find('.bottom-content');
-blockLibResizeEles.farSpread = $('#div_block_detail');
-blockLibResizeEles.nav = null;
-slideResize(blockLibResizeEles, {min: 147, max: 680}, 'height', function() {
+// 块模板库上下拖动(上中)
+let blockLibTopMid = {};
+blockLibTopMid.eleObj = {
+    module: 'kmbk',
+    resize: $('#kmbkResizeA'),
+    top: $('#kmbkTopDiv'),
+    topSpread: $('#div_block_tree'),
+    bottom: $('#kmbkMidDiv'),
+    bottomSpread: $('#div_block_bill')
+};
+blockLibTopMid.limit = {
+    min: 100,
+    max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-100-10*2`,
+    notTopSpread: 0,
+    notBottomSpread: 0,
+    totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkBottomDiv').height()-10*2` //10: resize.height()
+};
+SlideResize.verticalSlide(blockLibTopMid.eleObj, blockLibTopMid.limit, function () {
     blockLibObj.refreshSpread();
 });
 
+// 块模板库上下拖动(中下)
+let blockLibMidBottom = {};
+blockLibMidBottom.eleObj = {
+    module: 'kmbk',
+    resize: $('#kmbkResizeB'),
+    top: $('#kmbkMidDiv'),
+    topSpread: $('#div_block_bill'),
+    bottom: $('#kmbkBottomDiv'),
+    bottomSpread: $('#div_block_ration')
+};
+blockLibMidBottom.limit = {
+    min: 100,
+    max: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-100-10*2`,
+    notTopSpread: 0,
+    notBottomSpread: 0,
+    totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-$('#kmbkTopDiv').height()-10*2` //10: resize.height()
+};
+SlideResize.verticalSlide(blockLibMidBottom.eleObj, blockLibMidBottom.limit, function () {
+    blockLibObj.refreshSpread();
+});
+
+//加载块模板库多个结构的变量对象
+let blockLibMulti = {
+    module: 'kmbk',
+    eles: [
+        {container: $('#kmbkTopDiv'), spread: $('#div_block_tree'), notSpread: 0, defaultProportion: 0.6},
+        {container: $('#kmbkMidDiv'), spread: $('#div_block_bill'), notSpread: 0, defaultProportion: 0.15},
+        {container: $('#kmbkBottomDiv'), spread: $('#div_block_ration'), notSpread: 0, defaultProportion: 0.25},
+    ],
+    totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#kmbkToolsBar').height()-10*2`
+};
+
+//加载各库内部上下高度(有的库需要上下拖动)
+function loadSideToolsHeight() {
+    //定额库
+    if ($('#de').is(':visible')) {
+        SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
+            rationLibObj.refreshSpread();
+        });
+    } else if ($('#locate').is(':visible')) {
+        //查找定位
+        let options = $("input[name='content_type']:checked").val();
+        locateObject.refreshView(options, true);
+    } else if ($('#kmbk').is(':visible')) {
+        SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
+            blockLibObj.refreshSpread();
+        });
+    }
+}
 
 var sideToolsObj = {
     showSideTools: function (tabPanel, show, id) {
-        sideResizeEles.id = id;
+        sideResizeEles.eleObj.module = id;
         if (show) {
-            sideResizeEles.nearElement.css('width', '66.666667%');
-            sideResizeEles.farElement.css('width', '33.333333%');
+            //刚打开各库时的默认比例
+            sideResizeEles.eleObj.left.css('width', '66.666667%');
+            sideResizeEles.eleObj.right.css('width', '33.333333%');
+            SlideResize.setResizeWidth(sideResizeEles.eleObj.resize);
             $('.main-side .tab-pane').hide();
             id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
-            loadSize(sideResizeEles, 'width', function(){
-                if(id === 'stdRationTab'){//定额库
-                    loadSize(rationLibResizeEles, 'height', function(){
-                    });
-                }
-                else if(id === 'blockLibTab'){//块模板库
-                    loadSize(blockLibResizeEles, 'height', function(){
+            //加载打开的库与主界面的宽度比
+            SlideResize.loadHorizonWidth(id, [sideResizeEles.eleObj.resize], [sideResizeEles.eleObj.left, sideResizeEles.eleObj.right], function(){
+                if (id === 'stdRationTab') {//加载定额库内部上下高度
+                    SlideResize.loadVerticalHeight(rationLibResizeEles.eleObj.module, rationLibResizeEles.eleObj, rationLibResizeEles.limit, function () {
+                        rationLibObj.refreshSpread();
                     });
-                }else if(id == "locateTab"){
-
-                }
-                else{//清单库
-                    loadSize(billsLibResizeEles, 'height', function(){
+                } else if (id === 'blockLibTab') {//块模板库
+                    SlideResize.loadMultiVerticalHeight(blockLibMulti.module, blockLibMulti.eles, blockLibMulti.totalHeight, function () {
+                        blockLibObj.refreshSpread();
                     });
                 }
             });
         } else {
-            sideResizeEles.nearElement.css('width', '100%');
-            sideResizeEles.farElement.css('width', '0%');
+            sideResizeEles.eleObj.left.css('width', '100%');
+            sideResizeEles.eleObj.right.css('width', '0%');
             tabPanel.hide();
         }
         adaptiveTzjnrWidth();
         autoFlashHeight();
-        MaterialController.showReplaceDiv();
+        subObj.initGljSubTab();
+        //MaterialController.showReplaceDiv();
         pageCCOprObj.resizeWidth();
         billsGuidance.refreshWorkBook();
         billsLibObj.refreshBillsSpread();

+ 4 - 5
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -105,10 +105,7 @@ const billsGuidance = (function () {
                 if(!node){
                     return;
                 }
-                if(node.children.length === 0){
-                    billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, node);
-                }
-                else {
+                if(node.children.length > 0){
                     node.setExpanded(!node.expanded);
                     //设置展开收起状态
                     sessionStorage.setItem('stdBillsGuidanceExpState', bills.tree.getExpState(bills.tree.items));
@@ -121,6 +118,8 @@ const billsGuidance = (function () {
                         args.sheet.invalidateLayout();
                     });
                     args.sheet.repaint();
+                } else if(!projectReadOnly) {
+                    billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, node);
                 }
             }
         }
@@ -737,7 +736,7 @@ const billsGuidance = (function () {
     function bindBtn(){
         //打开清单指引库
         $('#stdBillsGuidanceTab').click(function () {
-            if(libSel.children().length === 0 && !projectReadOnly && !$(this).hasClass('disabled')){
+            if(libSel.children().length === 0 && !$(this).hasClass('disabled')){
                 initLibs(projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib);
             }
         });

+ 58 - 11
web/building_saas/main/js/views/std_ration_lib.js

@@ -27,8 +27,9 @@ var rationLibObj = {
         if (!this.sectionRationsSpread) {
             this.sectionRationsSpread = SheetDataHelper.createNewSpread($('#stdSectionRations')[0]);
             sheetCommonObj.spreadDefaultStyle(this.sectionRationsSpread);
-
-            this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRationSpreadCellDoubleClick);
+            if (!projectReadOnly) {
+                this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRationSpreadCellDoubleClick);
+            }
             this.refreshSettingForHint();
         }
     },
@@ -188,8 +189,48 @@ var rationLibObj = {
             SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
             rationLibObj.setTagForHint(rationSheet, datas);
         };
+        //定额名称的处理:
+        /*
+         * 1、从定额库提取的名称,是否含有空格:
+         * 1.1、无,则不处理。
+         * 1.2、有,则取第一个空格前的文本,与定额所属节点名称(去掉前面和后面的编号、括号、空格,保留中间的中文及符号)比较是否相同:
+         * 1.2.1、不同,则不处理。
+         * 1.2.2、相同,则将定额名称显示为去除第一个空格及空格之前的文本。
+         */
+        //@param {String}sectionName(章节名称) {Array}datas(定额数据)
+        function simplifyName(sectionName, datas){
+            if (!sectionName || !datas || datas.length === 0) {
+                return;
+            }
+            //提取需要匹配的章节名称
+            //去掉前缀
+            let toMatchArr = sectionName.split(' '),
+                toMatchStr = toMatchArr[toMatchArr.length - 1];
+            //去掉后缀
+            let sectionReg = /\(\w{9,}\)/g,
+                regMatch = toMatchStr.match(sectionReg);
+            if (regMatch) {
+                toMatchStr = toMatchStr.replace(regMatch[regMatch.length - 1], '');
+            }
+            //简化匹配到的定额名称
+            for (let data of datas) {
+                //第一个空格前的字符串去进行匹配,没有则不匹配
+                let nameArr = data.name.split(' ');
+                if (nameArr.length <= 1) {
+                    continue;
+                }
+                let matchName = nameArr[0];
+                if (matchName === toMatchStr) {
+                    nameArr.shift();
+                    data.name = nameArr.join(' ');
+                }
+            }
+        }
         if (sectionID) {
             CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID, type: me.curLibType}, function (datas) {
+                let chapterSheet = me.rationChapterSpread.getActiveSheet();
+                let sectionName = chapterSheet.getText(chapterSheet.getActiveRowIndex(), chapterSheet.getActiveColumnIndex());
+                simplifyName(sectionName, datas);
                 showDatas(datas, rationLibObj.sectionRationsSetting);
                 if(me.doAfterLoadGetRations){
                     me.doAfterLoadGetRations(datas);
@@ -240,6 +281,9 @@ var rationLibObj = {
                 "insertStdRation": {
                     name: "插入定额",
                     icon: 'fa-sign-in',
+                    disabled: function () {
+                        return projectReadOnly;
+                    },
                     callback: function (key, opt) {
                         let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
                         let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
@@ -252,6 +296,9 @@ var rationLibObj = {
                 "replaceStdRation": {
                     name: "替换定额",
                     icon: 'fa-sign-in',
+                    disabled: function () {
+                        return projectReadOnly
+                    },
                     callback: function (key, opt) {
                         let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
                         let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
@@ -493,14 +540,12 @@ if($('#stdRationChapter').height() === 0 || $('#stdSectionRations').height() ===
 }
 
 $('#stdRationTab').bind('click', function () {
-    if(!projectReadOnly){
-        var select = $('#stdRationLibSelect');
-        rationLibObj.checkSpread();
-        if (select[0].options.length === 0) {
-            rationLibObj.loadStdRationLibs();
-            rationLibObj.loadStdRationContextMenu();
-        };
-    }
+    var select = $('#stdRationLibSelect');
+    rationLibObj.checkSpread();
+    if (select[0].options.length === 0) {
+        rationLibObj.loadStdRationLibs();
+        rationLibObj.loadStdRationContextMenu();
+    };
 });
 $('#stdRationLibSelect').change(function () {
     var select = $(this);
@@ -654,7 +699,9 @@ function seachRation(){
             rationLibObj.resultSpread = resultSpread;
             bindContextmenuOpr(resultSpread.getActiveSheet());
             SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
-            resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+            if (!projectReadOnly) {
+                resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
+            }
             resultSpread.bind(GC.Spread.Sheets.Events.TopRowChanged, rationLibObj.onRationSpreadTopRowChanged);
         }else {
             rationLibObj.resultSpread.refresh();

+ 136 - 45
web/building_saas/main/js/views/sub_view.js

@@ -10,6 +10,7 @@
 let subSpread = null;
 let subObj = {
     TZJNRrePercent:null,
+    showGljSubTab:false,
     initSubSpread:function () {
         //清单精灵
         BillsElf.buildSheet();
@@ -89,6 +90,54 @@ let subObj = {
             $(gljOprObj.billsTab).click();
         }
         projectObj.mainSpread.focus();
+    },
+    //初始化人材机和项目特征文本两个区域的宽度,改变窗口大小时调用此方法,实时刷新
+    initItemWidth:function (){
+        //总宽度
+        let totalWidth = $('#subItems').width();
+        //人材机和项目特征文本比例
+        const openWidth = 30;//打开项目特征工具条
+        let textVisible = $('#replaceText').is(':visible'),
+            //默认比例
+            textPercent = '15%',
+            rcjPercent = '85%';
+        //文本没显示,则打开工具条固定30px转换百分比
+        if (!subObj.showGljSubTab) {
+            textPercent = openWidth / totalWidth;
+            rcjPercent = 1 - textPercent;
+            textPercent = textPercent * 100 + '%';
+            rcjPercent = rcjPercent * 100 + '%';
+        }
+        //设置特征及内容与排版规则的比例
+        $('#subSpread').css('width', rcjPercent);
+        $('#itemTextDiv').css('width', textPercent);
+        //打开了项目特征,则继续加载人材机表和项目特征文本具体比例
+        if (subObj.showGljSubTab === true) {
+            let rg_sideResizeEles = MaterialController.getSideResize();
+            SlideResize.loadHorizonWidth(rg_sideResizeEles.eleObj.module,
+                [rg_sideResizeEles.eleObj.resize], [rg_sideResizeEles.eleObj.left, rg_sideResizeEles.eleObj.right]);
+            $("#gljSubDiv").width( $('#itemTextDiv').width() - rg_sideResizeEles.eleObj.resize.width() - 30)
+        }
+    },
+    initGljSubTab:function() {
+        if(!($('#linkGLJ').hasClass('active'))){
+            return;
+        }
+        if(this.showGljSubTab == true){
+            $("#gljSubDiv").show();
+            $("#rgResize").show();
+        } else {
+            $("#gljSubDiv").hide();
+            $("#rgResize").hide();
+        }
+        $("#subSpread").addClass("ration_glj_spread");
+        this.initItemWidth();
+    },
+    showGljSubTabData:function () {
+        this.initGljSubTab();
+        if($('#rnc-zm').is(':visible')) zmhs_obj.showCoeData();
+        if($('#rnc-fz').is(':visible')) zmhs_obj.showAssData();
+        refreshSubSpread();
     }
 };
 
@@ -97,8 +146,11 @@ let subObj = {
 $("#linkGLJ").click(function(){
     $("#subItems").children().hide();//控制显示subSpread,隐藏特征及内容spread
     //show
-    MaterialController.showReplaceDiv();
+    //MaterialController.showReplaceDiv();
+    subObj.showGljSubTabData();
     $("#subSpread").show();
+    $("#itemTextDiv").show();
+    $("#gljItemTab").show();
     pageCCOprObj.active = false;
     subSpread.options.allowUserDragFill = false;
     refreshSubSpread();
@@ -153,9 +205,9 @@ $("#linkJSCX").click(function(){        // 计算程序
 $("#linkZMHS").click(function(){        // 子目换算
     $("#subItems").children().hide();
     $("#tabZMHS").show();
+    zmhs_obj.loadSideResize();
     pageCCOprObj.active = false;
     refreshSubSpread();
-
     gljOprObj.activeTab='#linkZMHS';
     gljOprObj.setNodeShowTab();
 });
@@ -168,39 +220,54 @@ $("#linkMBZM").click(function(){        // 模板子目
     gljOprObj.setNodeShowTab();
 });
 
+//特征及内容、工作内容与项目特征左右拖动
+let TZJNR_sideResizeEles = {};
+TZJNR_sideResizeEles.eleObj = {
+    module: 'tzjnr',
+    resize: $('#TZJNRResize'),
+    parent: $('#contentDiv'),
+    left: $('#jobDiv'),
+    right: $('#itemDiv')
+};
+TZJNR_sideResizeEles.limit = {
+    min: 100,
+    max: `$('#contentDiv').width()-100`
+};
+SlideResize.horizontalSlide(TZJNR_sideResizeEles.eleObj, TZJNR_sideResizeEles.limit, function () {
+    pageCCOprObj.resizeWidth();
+    refreshSubSpread();
+});
+
+//刷新特征内容与添加规则宽度
+function initTznrWidth(){
+    //特征及内容总宽度
+    let totalWidth = $('#tzjnrCon').width();
+    //特征及内容和排版规则比例
+    const typeSettingWidth = 30;//排版规则工具条
+    let addRuleVisible = $('#add-rule').is(':visible'),
+        addRulePercent = '33.3%',
+        contentPercent = '66.7%';
+    //排版规则没显示,则排版规则工具条固定30px转换百分比
+    if (!addRuleVisible) {
+        addRulePercent = typeSettingWidth / totalWidth;
+        contentPercent = 1 - addRulePercent;
+        addRulePercent = addRulePercent * 100 + '%';
+        contentPercent = contentPercent * 100 + '%';
+    }
+    //设置特征及内容与排版规则的比例
+    $('#contentDiv').css('width', contentPercent);
+    $('#ruleDiv').css('width', addRulePercent);
+}
 
 //特征及内容各模块宽度自适应
 function adaptiveTzjnrWidth() {
     if(gljOprObj.activeTab !== '#linkTZJNR'){
         return;
     }
-    let job_proportion = 0.33;
-    let item_proportion = 0.67;
-    if(subObj.TZJNRrePercent){
-        job_proportion = parseFloat(subObj.TZJNRrePercent.nearPercent)/100;
-        item_proportion = 1- job_proportion;
-    }
-
-    //排版规则工具条宽度
-    const typeSettingWidth = 30;
-    let tzjnrWidth = $('#tabCon').width();
-    //let tzjnrWidth = $(window).width() - $('.main-nav').width() - $('.main-side').width();
-    //2018-11-23 zhang 需求两个表格默认占比为25%:75%  还要可拖动
-    let extWidth = $('#add-rule').is(':visible')? tzjnrWidth / 3:typeSettingWidth;
-    let totalWidth = tzjnrWidth - extWidth - $('#TZJNRResize').width();
-    $('#jobDiv').css('width', totalWidth*job_proportion);
-    $('#itemDiv').css('width', totalWidth*item_proportion);
-    $('#add-rule').is(':visible')?$('#add-rule').css('width', extWidth): $('#openTypeSetting').css('width', extWidth);
-  /*  if($('#add-rule').is(':visible')){
-        let totalWidth = tzjnrWidth - tzjnrWidth / 3;
-        $('#jobDiv').css('width', totalWidth*0.25);
-        $('#itemDiv').css('width', totalWidth*0.75);
-        $('#add-rule').css('width', tzjnrWidth / 3);
-    } else{
-        $('#jobDiv').css('width', tzjnrWidth / 2);
-        $('#itemDiv').css('width', tzjnrWidth / 2 - typeSettingWidth);
-        $('#openTypeSetting').css('width', typeSettingWidth);
-    }*/
+    initTznrWidth();
+    //加载特征及内容里,工作内容和项目特征的比例
+    SlideResize.loadHorizonWidth(TZJNR_sideResizeEles.eleObj.module, [TZJNR_sideResizeEles.eleObj.resize],
+        [TZJNR_sideResizeEles.eleObj.left, TZJNR_sideResizeEles.eleObj.right]);
     pageCCOprObj.resizeWidth();
     refreshSubSpread();
 }
@@ -221,11 +288,9 @@ $("#linkTZJNR").click(function () {
     gljOprObj.activeTab='#linkTZJNR';
     $("#subItems").children().hide();
     $("#tzjnrCon").show();
-    adaptiveTzjnrWidth();
-    pageCCOprObj.resizeWidth();
     $("#add-rule p").not(":first").css('margin-bottom', 4);
     pageCCOprObj.active = true;
-    refreshSubSpread();
+    adaptiveTzjnrWidth();
     contentOprObj.workBook.getActiveSheet().showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
     characterOprObj.workBook.getActiveSheet().showColumn(0, GC.Spread.Sheets.HorizontalPosition.left);
     let selectedNode = projectObj.mainController.tree.selected;
@@ -566,7 +631,8 @@ function refreshSubSpread(){
         if(MaterialController.spread) MaterialController.spread.refresh();
     }
     BillsElf.refreshWorkBook();
-    if($('#linkZMHS').hasClass('active')) zmhs_obj.refresh();
+    //if($('#linkZMHS').hasClass('active')) zmhs_obj.refresh();
+    if($('#rnc-zm').is(':visible')|| $('#rnc-fz').is(':visible')) zmhs_obj.refresh();
     if($('#linkMBZM').hasClass('active')) mbzm_obj.refresh();
 }
 
@@ -650,16 +716,41 @@ $('#linkAZZJF').on('shown.bs.tab', function () {
     gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected, '111111');
 });
 
-let TZJNR_sideResizeEles = {};
-TZJNR_sideResizeEles.id = 'linkTZJNR';
-TZJNR_sideResizeEles.resize = $('#TZJNRResize');
-TZJNR_sideResizeEles.nearElement = $('#jobDiv');
-TZJNR_sideResizeEles.nearSpread = $('#jobSpread');
-TZJNR_sideResizeEles.farElement = $('#itemDiv');
-TZJNR_sideResizeEles.farSpread = $('#itemSpread');
-TZJNR_sideResizeEles.nav = null;
-slideResize(TZJNR_sideResizeEles, {min: 100, max: $('#tabCon').width() - 30,no_proportion:true}, 'width', function(rePercent){
-    if(rePercent) subObj.TZJNRrePercent = rePercent;
-    adaptiveTzjnrWidth();
+$('.gljSubTab ul li a').bind('click',function () {
+    if($(this).hasClass("active")){//点击展开了后又点击了自身,这时要隐藏tab和修改本身class
+        subObj.showGljSubTab = false;
+        closeTab(this);
+        subSpread.focus();//要加上这个,不然右边侧栏的选中状态的border线不会消换
+    }else {
+        subObj.showGljSubTab = true;
+    }
+    subObj.initGljSubTab();
     refreshSubSpread();
-});
+});
+
+$('.gljSubTab ul li a').on('shown.bs.tab', function () {
+    if(this.hash == "#rnc-xm"){
+        MaterialController.showItemCharacterText();
+    }else if(this.hash == "#rnc-zm"){
+        zmhs_obj.initCoeSpread();
+        zmhs_obj.refresh();
+        zmhs_obj.showCoeData();
+    }else if(this.hash == "#rnc-fz"){
+        zmhs_obj.initAssSpread();
+        zmhs_obj.refresh();
+        zmhs_obj.showAssData();
+    }
+});
+
+function closeTab(elem) {
+    setTimeout(function () {
+        $(elem).removeClass("show");
+        $(elem).removeClass("active");
+        $(elem).attr("aria-selected",false);
+        $(elem.hash).removeClass("show");
+        $(elem.hash).removeClass("active");
+    },50);
+
+}
+
+

+ 153 - 40
web/building_saas/main/js/views/zmhs_view.js

@@ -3,6 +3,7 @@
  */
 
 let zmhs_obj = {
+    module: 'subZmhs',
     coeSpread:null,
     coeSheet:null,
     coeSheetData:[],
@@ -10,12 +11,22 @@ let zmhs_obj = {
         header: [
             {headerName: "调整", headerWidth: 35, dataCode: "isAdjust", dataType: "String", cellType: "checkBox"},
             {headerName: "条件", headerWidth: 250, dataCode: "name", dataType: "String", cellType: "button"},
-            {headerName: "内容", headerWidth: 160, dataCode: "content", dataType: "String", hAlign: "left"}
+            {headerName: "内容", headerWidth: 160, dataCode: "content", dataType: "String", hAlign: "left",getText:'forContent'}
         ],
         view: {
             lockColumns:[0,1,2],
             rowHeaderWidth:25
         },
+        getText:{
+            forContent:function (item) {
+               if(gljUtil.isDef(item.select_code)&&item.select_code!=""){
+                   return item.select_code;
+               }else {
+                   return item.content;
+               }
+
+            }
+        },
         autoFit:true,
         fitRow:['name']
     },
@@ -34,27 +45,35 @@ let zmhs_obj = {
         }
     },
     initSpread:function () {
-        this.coeSpread = SheetDataHelper.createNewSpread($("#coeSpread")[0]);
-        sheetCommonObj.spreadDefaultStyle(this.coeSpread);
-        this.assSpread = SheetDataHelper.createNewSpread($("#assSpread")[0]);
-        sheetCommonObj.spreadDefaultStyle(this.assSpread);
-
-        this.coeSheet = this.coeSpread.getSheet(0);
-        sheetCommonObj.initSheet(this.coeSheet, this.coeSetting, 30);
-        this.coeSheet.name('ration_coe');
-        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;
-        });
-        this.assSheet = this.assSpread.getSheet(0);
-        sheetCommonObj.initSheet(this.assSheet, this.assSetting, 30);
-        this.assSheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onAssEditEnded);
-        this.assSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onAssRangeChanged);
-        this.assSheet.name('ration_ass');
-        SheetDataHelper.protectdSheet(this.coeSheet);
-        if(projectReadOnly){
-            disableSpread(zmhs_obj.coeSpread);
+        this.initCoeSpread();
+        this.initAssSpread();
+    },
+    initCoeSpread:function () {
+        if(zmhs_obj.coeSpread == null){
+            this.coeSpread = SheetDataHelper.createNewSpread($("#coeSpread")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.coeSpread);
+            this.coeSheet = this.coeSpread.getSheet(0);
+            sheetCommonObj.initSheet(this.coeSheet, this.coeSetting, 30);
+            this.coeSheet.name('ration_coe');
+            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.ValueChanged,this.onCoeValueChange);
+            this.coeSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e,args) {
+                args.sheet.repaint();
+            });
+            SheetDataHelper.protectdSheet(this.coeSheet);
+        }
+    },
+    initAssSpread:function () {
+        if(zmhs_obj.assSheet == null){
+            this.assSpread = SheetDataHelper.createNewSpread($("#assSpread")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.assSpread);
+            this.assSheet = this.assSpread.getSheet(0);
+            sheetCommonObj.initSheet(this.assSheet, this.assSetting, 30);
+            this.assSheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onAssEditEnded);
+            this.assSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onAssRangeChanged);
+            this.assSheet.name('ration_ass');
+            SheetDataHelper.protectdSheet(this.assSheet);
         }
     },
     showCoeData:function (node) {
@@ -67,17 +86,35 @@ let zmhs_obj = {
         }
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
         if (coeList.length > 0) {
-            var cus_index = _.findIndex(coeList, function (item) {
-                return item.coeID == -1;
-            })
-            if (cus_index != -1) {
-                this.coeSheet.getCell(cus_index, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                this.coeSheet.setCellType(cus_index, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
+            this.coeSheet.suspendPaint();
+            this.coeSheet.suspendEvent();
+            for(let i =0;i<coeList.length;i++ ){
+                if(gljUtil.isDef(coeList[i].option_codes)&&coeList[i].option_codes!=""){
+                    this.getComboBoxForCodes(coeList[i],i);//设置可选类型的下拉框
+                    //  sheet.setValue(row, col, val, ch);
+                } else if(coeList[i].coeID == -1){ //自定义系数列
+                    this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                    this.coeSheet.setCellType(i, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
+                }
             }
+            this.coeSheet.resumeEvent();
+            this.coeSheet.resumePaint();
         }
         this.coeSheetData = coeList;
+        if(projectReadOnly){
+            disableSpread(zmhs_obj.coeSpread);
+        }
+    },
+    getComboBoxForCodes:function (coe,i) {
+        this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+        let options = coe.option_codes.split("|");
+        let combo = sheetCommonObj.getDynamicCombo(true);
+        combo.itemHeight(options.length).items(options);
+        this.coeSheet.setCellType(i, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
+        this.coeSheet.setValue(i, 2, coe.select_code);
 
     },
+
     showAssData:function (node) {
         this.assSheet.suspendPaint();
         this.assSheet.suspendEvent();
@@ -89,8 +126,65 @@ let zmhs_obj = {
         this.assSheet.getRange(assList.length,-1,this.assSheet.getRowCount()-assList.length, -1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
         this.assSheet.resumePaint();
         this.assSheet.resumeEvent();
+        if(projectReadOnly){
+            disableSpread(this.assSpread);
+        }
+    },
+    refreshAfterUpdate:function(result,reload){
+        let ration_glj = projectObj.project.ration_glj;
+        let calcInstall = false;//是否记录安装增加费
+        let nodes = projectObj.project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
+        if(result.add && result.add.length > 0){//需添加定额工料机的情况
+            ration_glj.datas = ration_glj.datas.concat(result.add);
+            gljOprObj.sheetData = gljOprObj.sheetData.concat(result.add);
+        }
+        if(result.delete && result.delete.length > 0 && this.deleteGLJs(result.delete)) calcInstall = true; //这样保证delete返回值是true的时候才改变变量类型
+        if(result.replace && result.replace.length > 0){ //替换工料机的情况
+            for(let r of result.replace){//替换缓存内容
+                ration_glj.datas.splice(_.findIndex(ration_glj.datas,{'ID': r.ID}),1,r);
+                gljOprObj.sheetData.splice(_.findIndex(gljOprObj.sheetData,{'ID': r.ID}),1,r);
+                let node = ration_glj.updateGLJNodeAfterReplace(r);
+                if(node)  nodes.push(node);
+            }
+        }
+        projectObj.mainController.refreshTreeNode(nodes, false);
 
+        let rationID= ration_glj.updateCacheAfterAdjust(result.ration_glj);
+        if(reload == true){//有添加、替换、工料机等需重新加载的情况
+            $.bootstrapLoading.start();
+            projectObj.project.projectGLJ.loadData(function () {
+                $.bootstrapLoading.end();
+                if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);//这个方法有再去项目工料机那里取价格,所以要在回调里调用,不像替换工料的情况
+                ration_glj.reCalcWhenGLJChange({rationID:rationID});
+                if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
+            });
+        }else {
+            ration_glj.reCalcWhenGLJChange({rationID:rationID});
+        }
+        gljOprObj.showRationGLJSheetData(true);
+    },
+
+    deleteGLJs:function (IDs) {
+        let ration_glj = projectObj.project.ration_glj;
+        let glj_list = ration_glj.datas;
+        let calcInstall = false;
+        let oldData = _.remove(glj_list, function (o) {
+            return _.includes(IDs,o.ID);
+        });
+        _.remove(gljOprObj.sheetData, function (o) {
+            return _.includes(IDs,o.ID);
+        });
+        for (let o of oldData) {
+            if (ration_glj.needShowToTree(o)) {
+                let node = ration_glj.findGLJNodeByID(o.ID);  //找到对应的树节点
+                projectObj.mainController.deleteNode(node, null);
+                calcInstall = true;
+            }
+        }
+        return calcInstall;
     },
+
+
     refresh:function () {
         this.coeSpread?this.coeSpread.refresh():'';
         this.assSpread?this.assSpread.refresh():'';
@@ -246,6 +340,14 @@ let zmhs_obj = {
             zmhs_obj.coeSheet.startEdit();
         }
     },
+    onCoeValueChange:function (e,args) {
+        let fieldID =  zmhs_obj.coeSetting.header[args.col].dataCode;
+        let recode = zmhs_obj.coeSheetData[args.row];
+        if(gljUtil.isDef(recode.option_codes)&&recode.option_codes!=""&& fieldID == 'content'){//说明是选择了下拉框
+            projectObj.project.ration_coe.adjustCoeClick(recode, 1,{'select_code':args.newValue});
+        }
+    },
+
     onAssEditEnded:function (e,args) {
         var me = zmhs_obj;
         if (args.row >= me.assSheetData.length) {
@@ -281,7 +383,7 @@ let zmhs_obj = {
         }
         if (isValidate) {
             newval = scMathUtil.roundTo(newval, -2);
-            projectObj.project.ration_ass.updateActualValue(me.assSheetData, args.row, newval)
+            projectObj.project.ration_ass.updateActualValue(me.assSheetData, args.row, newval);
         } else {
             newval = recode.actualValue;
             me.assSheet.getCell(args.row, args.col).value(newval);
@@ -312,19 +414,30 @@ let zmhs_obj = {
             }
         }
         return true;
+    },
+    getSideResize: function () {
+        let zmhs_sideResizeEles = {};
+        zmhs_sideResizeEles.eleObj = {
+            module: zmhs_obj.module,
+            resize: $('#zmhsResize'),
+            parent: $('#tabZMHS'),
+            left: $('#coeSpread'),
+            right: $('#assDiv')
+        };
+        zmhs_sideResizeEles.limit = {
+            min: 100,
+            max: `$('#tabZMHS').width()-100`
+        };
+        return zmhs_sideResizeEles;
+    },
+    loadSideResize: function () {
+        let resizeObj = this.getSideResize();
+        SlideResize.loadHorizonWidth(resizeObj.eleObj.module, [resizeObj.eleObj.resize], [resizeObj.eleObj.left, resizeObj.eleObj.right]);
     }
 };
 
-let zmhs_sideResizeEles = {};
-zmhs_sideResizeEles.id = 'tabZMHS';
-zmhs_sideResizeEles.resize = $('#zmhsResize');
-zmhs_sideResizeEles.evFixedSize = `$(window).width()-$('.main-nav').width()-5`;
-zmhs_sideResizeEles.nearElement = $('#coeSpread');
-zmhs_sideResizeEles.nearSpread = $('#coeSpread');
-zmhs_sideResizeEles.farElement = $('#assSpread');
-zmhs_sideResizeEles.farSpread = $('#assSpread');
-zmhs_sideResizeEles.nav = null;
-slideResize(zmhs_sideResizeEles, {min: 100, max: $('#tabCon').width()-100}, 'width', function(){
+/*let zmhsResize = zmhs_obj.getSideResize();
+SlideResize.horizontalSlide(zmhsResize.eleObj, zmhsResize.limit, function () {
     zmhs_obj.refresh();
-});
+});*/
 

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

@@ -22,7 +22,7 @@
         // 这里的变量供页面调用
         var userAccount = '<%- userAccount %>';
         var userID = '<%- userID %>';
-        console.log(userID);
+        let isFirst = JSON.parse('<%- isFirst %>');
     </script>
     <style type="text/css">
         .hidden-area{
@@ -680,6 +680,22 @@
         </div>
     </div>
 </div>
+<!--弹出 新用户第一次进度条-->
+<div class="modal fade" id="progress" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">欢迎使用纵横建筑计价</h5>
+            </div>
+            <div class="modal-body">
+                <h5 class="my-3">首次加载例题,请稍候……</h5>
+                <div class="progress mb-3">
+                    <div class="progress-bar progress-bar-striped progress-bar-animated" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
 <!--弹出分享-->
 <!--<div class="modal fade" id="share" data-backdrop="static">
     <div class="modal-dialog" role="document">

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

@@ -849,10 +849,9 @@ const projTreeObj = {
                         BeforeOpenProject(node.data.ID, {'fullFolder': GetFullFolder(node.parent)}, function () {
                             let mainUrl = `/main?project=${node.data.ID}`;
                             CommonAjax.get(mainUrl, [], function () {
-                                newTab.location.href = mainUrl;
+                                newTab.location.replace(mainUrl); //不能后退
                             });
                         });
-                        return;
                     }, timeoutTime);
                 }
                 if (!node || node.children.length === 0) { return; }
@@ -872,6 +871,7 @@ const projTreeObj = {
         };
         TreeNodeCellType.prototype.processMouseMove = function (hitInfo) {
             let sheet = hitInfo.sheet;
+
             let div = sheet.getParent().getHost();
             let canvasId = div.id + "vp_vp";
             let canvas = $(`#${canvasId}`)[0];
@@ -1696,17 +1696,30 @@ function getWorkBookWidth(){
     return workBookWidth = $(window).width() - $('.pm-side').width() - 90;
 }
 
-/**
- * 初始化数据
- *
- * @return {void}
- */
-function init() {
-    billValuation = billValuation.replace(/\n/g, '\\n');
-    rationValuation = rationValuation.replace(/\n/g, '\\n');
-    //init spread and pmTree
-    socketObject.connect('pm');//socket 连接;
-    $.bootstrapLoading.start();
+function prepareInitialTimer() {
+    $('#progressBar').css('width', `0%`);
+    let outer = setInterval(function () {
+        let curWidth = parseInt($('#progressBar')[0].style.width.replace('%', ''));
+        curWidth = parseInt(curWidth + 2);
+        $('#progressBar').css('width', `${curWidth}%`);
+        if (curWidth >= 80) {
+            clearInterval(outer);
+        }
+    }, 100);
+    let inner = setInterval(function () {
+        let curWidth = parseFloat($('#progressBar')[0].style.width.replace('%', ''));
+        if (curWidth >= 80) {
+            curWidth = parseFloat(curWidth + 0.1);
+            $('#progressBar').css('width', `${curWidth}%`);
+            if (curWidth >= 95) {
+                clearInterval(inner);
+            }
+        }
+    }, 500);
+    return {outer, inner};
+}
+
+function initProjects(callback) {
     GetAllProjectData(function (datas) {
         //设置工程专业
         for (let data of datas) {
@@ -1726,11 +1739,47 @@ function init() {
             //初始选择
             let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
             projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
-            $.bootstrapLoading.end();
+           // $.bootstrapLoading.end();
             autoFlashHeight();
             projTreeObj.workBook.refresh();
+            if (callback) {
+                callback();
+            }
+        }, function () {
+            $.bootstrapLoading.end();
         });
     });
+}
+
+/**
+ * 初始化数据
+ *
+ * @return {void}
+ */
+function init() {
+    billValuation = billValuation.replace(/\n/g, '\\n');
+    rationValuation = rationValuation.replace(/\n/g, '\\n');
+    //init spread and pmTree
+    socketObject.connect('pm');//socket 连接;
+    if (isFirst) {
+        $('#progress').modal('show');
+        let intervalTime = prepareInitialTimer();
+        CommonAjax.post('/pm/api/prepareInitialData', {user_id: userID}, function () {
+            initProjects(function () {
+                clearInterval(intervalTime.outer);
+                clearInterval(intervalTime.inner);
+                $('#progressBar').css('width', '100%');
+                setTimeout(function () {
+                    $('#progress').modal('hide');
+                }, 500);
+            });
+        });
+    } else {
+        $.bootstrapLoading.start();
+        initProjects(function () {
+            $.bootstrapLoading.end();
+        })
+    }
     engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
 }
 

+ 2 - 2
web/building_saas/report/html/rpt_main.html

@@ -15,7 +15,7 @@
             </div>
         </div>
         <div class="col-lg-9 p-0">
-            <div class="toolsbar">
+            <div class="toolsbar-f d-flex justify-content-between">
                 <div class="print-toolsbar">
                     <div class="panel">
                         <div class="panel-body" id="print_div">
@@ -88,7 +88,7 @@
                     </div>
                 </div>
             </div>
-            <div class="print-view poj-list">
+            <div class="print-view  form-view">
                 <div class="pageContainer">
                     <canvas id="rptCanvas" height="820" width="920"></canvas>
                 </div>

+ 3 - 3
web/users/html/login-infoinput.html

@@ -27,7 +27,7 @@
                 </div>
                 <div class="card-body">
                     <div class="form-group">
-                        <input class="form-control" placeholder="你的姓名" name="real_name" id="name">
+                        <input class="form-control" placeholder="真实姓名" name="real_name" id="name">
                     </div>
                     <div class="form-group">
                         <input class="form-control" placeholder="企业名称" name="company" id="company">
@@ -40,7 +40,7 @@
                             <% })%>
                         </select>
                     </div>
-                    <div class="form-group">
+                    <!--<div class="form-group">
                         <a class="btn btn-link" data-toggle="collapse" href="#moreinfo" aria-expanded="false"
                            aria-controls="moreinfo">更多选项</a>
                     </div>
@@ -61,7 +61,7 @@
                                 <% })%>
                             </select>
                         </div>
-                    </div>
+                    </div>-->
                     <div class="form-group">
                         <button class="btn btn-primary btn-block" type="submit">下一步</button>
                     </div>

+ 1 - 2
web/users/html/login.html

@@ -16,8 +16,7 @@
 <body>
     <div class="container">
         <form class="form-signin" method="post" onsubmit="return false">
-            <h1 class="d-flex justify-content-center">纵横建筑云计价</h1>
-            <h4 class="d-flex justify-content-center mb-2">用户登录</h4>
+            <h1 class="d-flex justify-content-center mb-5">纵横建筑云计价</h1>
             <div class="form-group">
                 <input id="inputEmail" class="form-control " name="inputEmail" placeholder="通行账号 邮箱/手机" autofocus="" />
             </div>

+ 2 - 2
web/users/html/user-info.html

@@ -58,7 +58,7 @@
                                 <% })%>
                             </select>
                         </div>
-                        <div class="form-group">
+                    <!--    <div class="form-group">
                             <label class="form-control-label">企业类型</label>
                             <select class="form-control" name="company_type">
                                 <option value="">请选择企业类型</option>
@@ -75,7 +75,7 @@
                                 <option value="<%= index %>" <% if(index === userData.company_scale) {%>selected="selected"<% } %>><%= companyScale %></option>
                                 <% })%>
                             </select>
-                        </div>
+                        </div>-->
                         <div class="form-group mt-3">
                             <button class="btn btn-primary" type="submit">确认</button>
                         </div>