Просмотр исходного кода

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

TonyKang 6 лет назад
Родитель
Сommit
b22a22b9b2
62 измененных файлов с 2043 добавлено и 989 удалено
  1. 3 0
      config/gulpConfig.js
  2. 2 0
      modules/all_models/compleRation_coe.js
  3. 7 0
      modules/all_models/compleRation_ration.js
  4. 2 0
      modules/all_models/ration.js
  5. 3 0
      modules/all_models/ration_coe.js
  6. 26 0
      modules/all_models/ration_template.js
  7. 2 0
      modules/all_models/stdRation_coe.js
  8. 9 2
      modules/all_models/stdRation_ration.js
  9. 2 6
      modules/main/controllers/bills_controller.js
  10. 4 1
      modules/main/facade/bill_facade.js
  11. 49 5
      modules/main/facade/ration_facade.js
  12. 21 0
      modules/main/facade/ration_template_facade.js
  13. 2 1
      modules/main/models/project.js
  14. 1 0
      modules/main/models/project_consts.js
  15. 12 5
      modules/pm/controllers/pm_controller.js
  16. 44 1
      modules/pm/facade/pm_facade.js
  17. 5 3
      modules/ration_glj/facade/ration_glj_facade.js
  18. 11 0
      modules/std_billsGuidance_lib/controllers/libController.js
  19. 15 0
      modules/std_billsGuidance_lib/facade/facades.js
  20. 1 0
      modules/std_billsGuidance_lib/routes/routes.js
  21. 7 3
      public/web/sheet/sheet_common.js
  22. 3 0
      public/web/slideResize.js
  23. 2 3
      public/web/tree_sheet/tree_sheet_helper.js
  24. BIN
      web/building_saas/css/animated_favicon1.gif
  25. 5 2
      web/building_saas/css/custom.css
  26. BIN
      web/building_saas/css/favicon.ico
  27. BIN
      web/building_saas/css/logo.png
  28. 1 1
      web/building_saas/js/global.js
  29. 118 49
      web/building_saas/main/html/main.html
  30. 19 4
      web/building_saas/main/js/controllers/block_controller.js
  31. 47 2
      web/building_saas/main/js/controllers/material_controller.js
  32. 11 6
      web/building_saas/main/js/main.js
  33. 1 7
      web/building_saas/main/js/models/bills.js
  34. 8 8
      web/building_saas/main/js/models/calc_base.js
  35. 1 1
      web/building_saas/main/js/models/calc_program.js
  36. 1 0
      web/building_saas/main/js/models/main_consts.js
  37. 1 0
      web/building_saas/main/js/models/project.js
  38. 1 1
      web/building_saas/main/js/models/quantity_detail.js
  39. 16 15
      web/building_saas/main/js/models/ration.js
  40. 38 0
      web/building_saas/main/js/models/ration_template.js
  41. 768 0
      web/building_saas/main/js/views/billsElf.js
  42. 209 36
      web/building_saas/main/js/views/block_lib.js
  43. 3 3
      web/building_saas/main/js/views/character_content_view.js
  44. 3 3
      web/building_saas/main/js/views/glj_col.js
  45. 13 3
      web/building_saas/main/js/views/glj_view.js
  46. 3 2
      web/building_saas/main/js/views/importBills.js
  47. 118 19
      web/building_saas/main/js/views/locate_view.js
  48. 2 2
      web/building_saas/main/js/views/main_tree_col.js
  49. 69 0
      web/building_saas/main/js/views/mbzm_view.js
  50. 18 0
      web/building_saas/main/js/views/project_glj_view.js
  51. 2 2
      web/building_saas/main/js/views/project_info.js
  52. 37 16
      web/building_saas/main/js/views/project_view.js
  53. 6 1
      web/building_saas/main/js/views/quantity_edit_view.js
  54. 25 26
      web/building_saas/main/js/views/side_tools.js
  55. 1 588
      web/building_saas/main/js/views/std_billsGuidance_lib.js
  56. 82 12
      web/building_saas/main/js/views/sub_view.js
  57. 2 2
      web/building_saas/main/js/views/zmhs_view.js
  58. 56 5
      web/building_saas/pm/html/project-management.html
  59. 68 128
      web/building_saas/pm/js/pm_newMain.js
  60. 57 15
      web/building_saas/pm/js/pm_share.js
  61. BIN
      web/dest/css/img/share.png
  62. BIN
      web/dest/css/logo.png

+ 3 - 0
config/gulpConfig.js

@@ -97,6 +97,7 @@ module.exports = {
         'web/building_saas/main/js/models/ration_coe.js',
         'web/building_saas/main/js/models/ration_coe.js',
         'web/building_saas/main/js/models/ration_ass.js',
         'web/building_saas/main/js/models/ration_ass.js',
         'web/building_saas/main/js/models/ration_installation.js',
         'web/building_saas/main/js/models/ration_installation.js',
+        'web/building_saas/main/js/models/ration_template.js',
         // 'web/building_saas/main/js/models/volume_price.js',
         // 'web/building_saas/main/js/models/volume_price.js',
         'web/building_saas/main/js/models/labour_coe.js',
         'web/building_saas/main/js/models/labour_coe.js',
         'web/building_saas/main/js/models/installation_fee.js',
         'web/building_saas/main/js/models/installation_fee.js',
@@ -150,7 +151,9 @@ module.exports = {
         'web/building_saas/main/js/views/character_content_view.js',
         'web/building_saas/main/js/views/character_content_view.js',
         'web/building_saas/main/js/views/glj_view.js',
         'web/building_saas/main/js/views/glj_view.js',
         'web/building_saas/main/js/views/zmhs_view.js',
         'web/building_saas/main/js/views/zmhs_view.js',
+        'web/building_saas/main/js/views/mbzm_view.js',
         'web/building_saas/main/js/views/tender_price_view.js',
         'web/building_saas/main/js/views/tender_price_view.js',
+        'web/building_saas/main/js/views/billsElf.js',
         'web/building_saas/main/js/views/sub_view.js',
         'web/building_saas/main/js/views/sub_view.js',
         'web/building_saas/main/js/views/fee_rate_view.js',
         'web/building_saas/main/js/views/fee_rate_view.js',
         'web/building_saas/main/js/views/quantity_edit_view.js',
         'web/building_saas/main/js/views/quantity_edit_view.js',

+ 2 - 0
modules/all_models/compleRation_coe.js

@@ -22,6 +22,8 @@ const coeSchema = new Schema({
     gljName: String,
     gljName: String,
     operator: String,               // 运算符(*、+、-、=)
     operator: String,               // 运算符(*、+、-、=)
     amount: String,                 // 调整的量
     amount: String,                 // 调整的量
+    replaceCode:String,
+    replaceName:String,
     _id: false
     _id: false
 });
 });
 
 

+ 7 - 0
modules/all_models/compleRation_ration.js

@@ -55,6 +55,13 @@ const compleRationSchema = new Schema({
     rationCoeList: Array,
     rationCoeList: Array,
     rationAssList: [compleRationAssItemSchema],
     rationAssList: [compleRationAssItemSchema],
     rationInstList: [rationInstSchema],
     rationInstList: [rationInstSchema],
+    rationTemplateList : [new Schema({
+        type: String,
+        code: String,
+        name: String,
+        billsLocation: String,
+        unit:String
+    }, { _id: false })],
     deleteInfo: deleteSchema
     deleteInfo: deleteSchema
 }, {versionKey: false});
 }, {versionKey: false});
 
 

+ 2 - 0
modules/all_models/ration.js

@@ -52,6 +52,7 @@ let rationSchema = new Schema({
     isSubcontract: Boolean,                     // 是否分包
     isSubcontract: Boolean,                     // 是否分包
     installationKey:String,                   //用来记录安装增加费的关联字段
     installationKey:String,                   //用来记录安装增加费的关联字段
     // 定额特有属性:
     // 定额特有属性:
+    stdID: Number,                            //来自的标准定额ID
     libID: Number,
     libID: Number,
     maskName: String,
     maskName: String,
     caption: String,
     caption: String,
@@ -66,6 +67,7 @@ let rationSchema = new Schema({
     annotation: String,                         //附注
     annotation: String,                         //附注
     ruleText: String,                            // 计算规则
     ruleText: String,                            // 计算规则
     prefix: {type: String, default: ''},                              //定额是补充、借用时用  补 借
     prefix: {type: String, default: ''},                              //定额是补充、借用时用  补 借
+    referenceRationID:String,//如果是通过模板关联子目生成的定额,这里记录对应的主定额ID
 
 
     //工料机特有属性
     //工料机特有属性
     projectGLJID:Number,  //项目工料机ID
     projectGLJID:Number,  //项目工料机ID

+ 3 - 0
modules/all_models/ration_coe.js

@@ -7,8 +7,11 @@ var mongoose = require('mongoose'),
 var coeSchema = mongoose.Schema({
 var coeSchema = mongoose.Schema({
     coeType: String,                // 系数类型,指作用范围:// 单个(如:111量0.001)、人工类、材料类、机械类、全部(如:定额×0.925)。
     coeType: String,                // 系数类型,指作用范围:// 单个(如:111量0.001)、人工类、材料类、机械类、全部(如:定额×0.925)。
     gljCode: String,                  // 要调整的工料机ID(当coeType=0时有效)
     gljCode: String,                  // 要调整的工料机ID(当coeType=0时有效)
+    gljName: String,
     operator: String,               // 运算符(*、+、-、=)
     operator: String,               // 运算符(*、+、-、=)
     amount: Number,                 // 调整的量
     amount: Number,                 // 调整的量
+    replaceCode:String,
+    replaceName:String,
     _id: false
     _id: false
 });
 });
 
 

+ 26 - 0
modules/all_models/ration_template.js

@@ -0,0 +1,26 @@
+/**
+ * Created by zhang on 2018/11/26.
+ */
+
+var mongoose = require('mongoose'),
+    Schema = mongoose.Schema;
+
+let ration_template =  new Schema({
+    ID:String,
+    projectID: Number,
+    rationID:String,
+    createLocation:Number,//提取位置
+    templateList:[new Schema({
+        code:String,
+        name:String,
+        type:String,
+        billsLocation:String,//这个是清单编号
+        fxID:String,//这个是分项对应的ID
+        unit:String,
+        quantity:String,
+        coe:String,
+        billID:String//记取位置对应的清单ID
+    },{ _id: false })]
+},{versionKey:false});
+
+mongoose.model('ration_template', ration_template);

+ 2 - 0
modules/all_models/stdRation_coe.js

@@ -12,6 +12,8 @@ const coeSchema = new Schema({
     amount: String,                 // 调整的量
     amount: String,                 // 调整的量
     gljCode: String,
     gljCode: String,
     gljName: String,
     gljName: String,
+    replaceCode:String,
+    replaceName:String,
     _id: false
     _id: false
 });
 });
 
 

+ 9 - 2
modules/all_models/stdRation_ration.js

@@ -46,7 +46,14 @@ const rationItemSchema = new Schema({
     rationGljList: [rationGljItemSchema],
     rationGljList: [rationGljItemSchema],
     rationCoeList: Array,
     rationCoeList: Array,
     rationAssList: [rationAssItemSchema],
     rationAssList: [rationAssItemSchema],
-    rationInstList: [rationInstSchema]
-});
+    rationInstList: [rationInstSchema],
+    rationTemplateList : [new Schema({
+        type: String,
+        code: String,
+        name: String,
+        billsLocation: String,
+        unit:String
+    }, { _id: false })]
 
 
+});
 mongoose.model('std_ration_lib_ration_items', rationItemSchema, 'std_ration_lib_ration_items');
 mongoose.model('std_ration_lib_ration_items', rationItemSchema, 'std_ration_lib_ration_items');

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

@@ -8,9 +8,7 @@ let ProjectsData = require('../../pm/models/project_model').project;
 let logger = require("../../../logs/log_helper").logger;
 let logger = require("../../../logs/log_helper").logger;
 let quantity_detail = require("../facade/quantity_detail_facade");
 let quantity_detail = require("../facade/quantity_detail_facade");
 let bill_facade = require("../facade/bill_facade");
 let bill_facade = require("../facade/bill_facade");
-let ration_glj = mongoose.model('ration_glj');
-let ration_coe = mongoose.model('ration_coe');
-let rationInstallationModel = mongoose.model('ration_installation');
+let raiton_facade = require("../facade/ration_facade");
 let stdBillsModel = mongoose.model('std_bills_lib_bills');
 let stdBillsModel = mongoose.model('std_bills_lib_bills');
 let stdBillJobsModel = mongoose.model('std_bills_lib_jobContent');
 let stdBillJobsModel = mongoose.model('std_bills_lib_jobContent');
 let stdBillCharacterModel = mongoose.model('std_bills_lib_itemCharacter');
 let stdBillCharacterModel = mongoose.model('std_bills_lib_itemCharacter');
@@ -425,9 +423,7 @@ async function doBillsOrRationsDelete(data) {
         await quantity_detail.deleteByQuery(qd_query) ;
         await quantity_detail.deleteByQuery(qd_query) ;
     }
     }
     if(sub_query!=null){
     if(sub_query!=null){
-        await ration_coe.deleteMany(sub_query);//删除附注条件
-        await ration_glj.deleteMany(sub_query);//删除定额工料机
-        await rationInstallationModel.deleteMany(sub_query);//删除安装增加费
+        await raiton_facade.deleteSubListByQuery(sub_query);
     }
     }
     if(rationTask.length>0){
     if(rationTask.length>0){
         await ration_model.model.bulkWrite(rationTask);//删除定额
         await ration_model.model.bulkWrite(rationTask);//删除定额

+ 4 - 1
modules/main/facade/bill_facade.js

@@ -14,6 +14,7 @@ let ration_Model = mongoose.model('ration');
 let ration_glj_Model = mongoose.model('ration_glj');
 let ration_glj_Model = mongoose.model('ration_glj');
 let ration_coe_Model = mongoose.model('ration_coe');
 let ration_coe_Model = mongoose.model('ration_coe');
 let ration_installation_Model = mongoose.model('ration_installation');
 let ration_installation_Model = mongoose.model('ration_installation');
+let ration_template_Model = mongoose.model('ration_template');
 let bill_Model = require('../models/bills').model;
 let bill_Model = require('../models/bills').model;
 import GLJController from "../../glj/controllers/glj_controller";
 import GLJController from "../../glj/controllers/glj_controller";
 
 
@@ -89,6 +90,7 @@ async function pasteOtherData(data) {
     let quantity_details = data.quantity_details;
     let quantity_details = data.quantity_details;
     let ration_coes = data.ration_coes;
     let ration_coes = data.ration_coes;
     let ration_installations = data.ration_installations;
     let ration_installations = data.ration_installations;
+    let ration_templates = data.ration_templates;
     let updateData = data.updateData;
     let updateData = data.updateData;
     let uModel = null;
     let uModel = null;
     let tasks = [];
     let tasks = [];
@@ -113,9 +115,10 @@ async function pasteOtherData(data) {
     quantity_details.length > 0 ? await insertMany(quantity_details,quantity_detail_model):'';
     quantity_details.length > 0 ? await insertMany(quantity_details,quantity_detail_model):'';
     ration_coes.length > 0 ? await insertMany(ration_coes,ration_coe_Model):'';
     ration_coes.length > 0 ? await insertMany(ration_coes,ration_coe_Model):'';
     ration_installations.length > 0 ? await insertMany(ration_installations,ration_installation_Model):'';
     ration_installations.length > 0 ? await insertMany(ration_installations,ration_installation_Model):'';
+    ration_templates.length > 0? await insertMany(ration_templates,ration_template_Model):'';
     tasks.length>0?await uModel.bulkWrite(tasks):'';
     tasks.length>0?await uModel.bulkWrite(tasks):'';
 
 
-    return {bills:bills,quantity_details:quantity_details,ration_coes:ration_coes,ration_installations:ration_installations,updateData:updateData}
+    return {bills:bills,quantity_details:quantity_details,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:ration_templates,updateData:updateData}
 }
 }
 
 
 async function pasteRationsAndRationGLJ (rations,ration_gljs) {
 async function pasteRationsAndRationGLJ (rations,ration_gljs) {

+ 49 - 5
modules/main/facade/ration_facade.js

@@ -13,6 +13,7 @@ let bill_model = require('../models/bills');
 let decimal_facade = require('./decimal_facade');
 let decimal_facade = require('./decimal_facade');
 let installationFeeModel = mongoose.model("installation_fee");
 let installationFeeModel = mongoose.model("installation_fee");
 let rationInstallationModel = mongoose.model('ration_installation');
 let rationInstallationModel = mongoose.model('ration_installation');
+let rationTemplateModel = mongoose.model('ration_template');
 const uuidV1 = require('uuid/v1');
 const uuidV1 = require('uuid/v1');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let complementary_glj_model =  mongoose.model('complementary_glj_lib');
 let complementary_glj_model =  mongoose.model('complementary_glj_lib');
@@ -32,7 +33,8 @@ module.exports = {
     addMultiRation: addMultiRation,
     addMultiRation: addMultiRation,
     getSameSectionRations:getSameSectionRations,
     getSameSectionRations:getSameSectionRations,
     getExtendData:getExtendData,
     getExtendData:getExtendData,
-    getDefaultProgramID:getDefaultProgramID
+    getDefaultProgramID:getDefaultProgramID,
+    deleteSubListByQuery:deleteSubListByQuery
 };
 };
 async function addNewRation(data,compilation) {
 async function addNewRation(data,compilation) {
     let query = data.itemQuery;
     let query = data.itemQuery;
@@ -120,6 +122,7 @@ async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入
         newData.caption = std.caption;
         newData.caption = std.caption;
         newData.unit = std.unit;
         newData.unit = std.unit;
         newData.libID = std.rationRepId;
         newData.libID = std.rationRepId;
+        newData.stdID = std.ID;
         newData.content = std.jobContent;
         newData.content = std.jobContent;
         newData.annotation = std.annotation;
         newData.annotation = std.annotation;
         if (std.chapter) {
         if (std.chapter) {
@@ -201,13 +204,15 @@ async function addRationSubList(stdRation,newRation,needInstall,compilation) {
     let ration_coes = await addRationCoe(stdRation,newRation,compilation);
     let ration_coes = await addRationCoe(stdRation,newRation,compilation);
     let addRationCoeTime = +new Date();
     let addRationCoeTime = +new Date();
     console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
     console.log("添加定额coe时间-----"+(addRationCoeTime - addRationGLJTime));
-    let ration_installs = [];
+    let ration_installations = [];
     if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
     if(needInstall && stdRation.type == 'std'){//只有标准的定额才有安装增加费,补充的定额没有安装增加费
-        ration_installs =  await addRationInstallFee(stdRation,newRation);
+        ration_installations =  await addRationInstallFee(stdRation,newRation);
     }
     }
     let addRationInstallFeeTime = +new Date();
     let addRationInstallFeeTime = +new Date();
     console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
     console.log("添加定额install时间-----"+(addRationInstallFeeTime - addRationCoeTime));
-    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installs:ration_installs};
+    //添加定额模板子目
+    let ration_template = await addRationTemplate(stdRation,newRation);
+    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installations:ration_installations,ration_templates:[ration_template]};
 }
 }
 
 
 async function addRationInstallFee(std,newRation) {
 async function addRationInstallFee(std,newRation) {
@@ -249,6 +254,38 @@ async function addRationInstallFee(std,newRation) {
     return install_fee_list;
     return install_fee_list;
 }
 }
 
 
+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:'',
+                coe:""
+            }
+            template.code = tem.code;
+            template.name = tem.name;
+            template.type = tem.type;
+            template.unit = tem.unit &&_.isString(tem.unit) ?tem.unit.replace(/^\d+/,""):"";
+            template.billsLocation = template.billsLocation
+            templateList.push(tem)
+        }
+    }
+    if(templateList.length > 0){
+        let ration_template = {};
+        ration_template.ID = uuidV1();
+        ration_template.projectID = newRation.projectID;
+        ration_template.rationID = newRation.ID;
+        ration_template.createLocation = 1; //默认模板子目分别放在措施项目下
+        ration_template.templateList = templateList;
+        await  rationTemplateModel.create(ration_template);
+        return ration_template;
+    }
+    return null;
+}
+
+
 async function addRationCoe(std,newRation,compilation) {
 async function addRationCoe(std,newRation,compilation) {
     let ration_coe_list = [];
     let ration_coe_list = [];
     let seq = 0;
     let seq = 0;
@@ -423,12 +460,18 @@ async function addRationGLJ(std,newRation,compilation) {
 async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下的数据,如工程量明细,定额工料机等
 async function deleRationSubRecode(projectID,rationID) {//删除挂在定额下的数据,如工程量明细,定额工料机等
     let delete_query={projectID: projectID, rationID: rationID};
     let delete_query={projectID: projectID, rationID: rationID};
     //删除工程量明细
     //删除工程量明细
-    await quantity_detail.deleteByQuery(delete_query) ;
+    await deleteSubListByQuery(delete_query) ;
+}
+
+async function deleteSubListByQuery(delete_query) {
+    await quantity_detail.deleteByQuery(delete_query) ;//删除工程量明细
     await ration_coe.deleteMany(delete_query);//删除附注条件
     await ration_coe.deleteMany(delete_query);//删除附注条件
     await ration_glj.deleteMany(delete_query);//删除定额工料机
     await ration_glj.deleteMany(delete_query);//删除定额工料机
     await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
     await rationInstallationModel.deleteMany(delete_query);//删除安装增加费
+    await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
 }
 }
 
 
+
 async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
 async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
     // insertNewRation
     // insertNewRation
     let ration ={};
     let ration ={};
@@ -438,6 +481,7 @@ async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,cal
     ration.unit = std.unit;
     ration.unit = std.unit;
     if (std.type === 'std') {
     if (std.type === 'std') {
         ration.libID = std.rationRepId;
         ration.libID = std.rationRepId;
+        ration.stdID = std.ID;
     }
     }
     ration.content = std.jobContent;
     ration.content = std.jobContent;
     ration.adjustState = '';
     ration.adjustState = '';

+ 21 - 0
modules/main/facade/ration_template_facade.js

@@ -0,0 +1,21 @@
+/**
+ * Created by zhang on 2018/11/26.
+ */
+
+let mongoose = require('mongoose');
+let rationTemplateModel = mongoose.model('ration_template');
+let consts = require('../models/project_consts');
+
+module.exports={
+    getData:getData,
+};
+
+function getData(projectID, callback) {
+    rationTemplateModel.find({'projectID': projectID}, (err, datas) => {
+        if (err) {
+            callback(1, '', null);
+        } else {
+            callback(0, consts.projectConst.RATION_TEMPLATE, datas);
+        }
+    })
+}

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

@@ -7,6 +7,7 @@ var ration_glj_data = require('../../ration_glj/facade/ration_glj_facade');
 var ration_coe_data = require('../../ration_glj/facade/ration_coe_facade');
 var ration_coe_data = require('../../ration_glj/facade/ration_coe_facade');
 var ration_ass_data = require('../../ration_glj/facade/ration_ass_facade');
 var ration_ass_data = require('../../ration_glj/facade/ration_ass_facade');
 let ration_installation = require('../facade/ration_installation_facade');
 let ration_installation = require('../facade/ration_installation_facade');
+let ration_template = require('../facade/ration_template_facade');
 var quantity_detail_data = require('../facade/quantity_detail_facade');
 var quantity_detail_data = require('../facade/quantity_detail_facade');
 var fee_rate_data = require('../../fee_rates/facade/fee_rates_facade');
 var fee_rate_data = require('../../fee_rates/facade/fee_rates_facade');
 let projCounter = require('./proj_counter_model');
 let projCounter = require('./proj_counter_model');
@@ -41,7 +42,7 @@ moduleMap[projectConsts.LABOUR_COE] = labour_coe_facade;
 moduleMap[projectConsts.CALC_PROGRAM] = calc_program_facade;
 moduleMap[projectConsts.CALC_PROGRAM] = calc_program_facade;
 moduleMap[projectConsts.PROJECTGLJ] = new GLJController();
 moduleMap[projectConsts.PROJECTGLJ] = new GLJController();
 moduleMap[projectConsts.INSTALLATION_FEE] = installation_facade;
 moduleMap[projectConsts.INSTALLATION_FEE] = installation_facade;
-
+moduleMap[projectConsts.RATION_TEMPLATE] = ration_template;
 
 
 var Project = function (){};
 var Project = function (){};
 
 

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

@@ -10,6 +10,7 @@ let projectConst = {
     RATION_COE:'ration_coe',
     RATION_COE:'ration_coe',
     RATION_ASS:'ration_ass',
     RATION_ASS:'ration_ass',
     RATION_INSTALLATION:'ration_installation',
     RATION_INSTALLATION:'ration_installation',
+    RATION_TEMPLATE:'ration_template',
     QUANTITY_DETAIL:'quantity_detail',
     QUANTITY_DETAIL:'quantity_detail',
     PROJECTGLJ: 'projectGLJ',
     PROJECTGLJ: 'projectGLJ',
     GLJLIST: 'GLJList',
     GLJLIST: 'GLJList',

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

@@ -566,23 +566,29 @@ module.exports = {
                 }
                 }
                 let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}});
                 let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}});
                 //建设项目
                 //建设项目
-                let consProjIDs = [];
+                let consProjIDs = [],
+                    ungroupedTenders = [];
                 for(let proj of receiveProjects){
                 for(let proj of receiveProjects){
+                    if (proj.projType === projType.project) {
+                        consProjIDs.push(proj.ID);
+                    }
                     //获取分享项目子项
                     //获取分享项目子项
                     if (proj.projType !== projType.tender) {
                     if (proj.projType !== projType.tender) {
                         proj._doc.children = await pm_facade.getPosterityProjects([proj.ID]);
                         proj._doc.children = await pm_facade.getPosterityProjects([proj.ID]);
-                        if (proj.projType === projType.project) {
-                            consProjIDs.push(proj.ID);
-                        }
                         for (let projC of proj._doc.children) {
                         for (let projC of proj._doc.children) {
                             if (projC.projType === projType.project) {
                             if (projC.projType === projType.project) {
                                 consProjIDs.push(projC.ID);
                                 consProjIDs.push(projC.ID);
                             } else if (projC.projType === projType.tender) {
                             } else if (projC.projType === projType.tender) {
                                 //设置工程专业
                                 //设置工程专业
                                 projC._doc.feeStandardName = projC.property.feeStandardName || '';
                                 projC._doc.feeStandardName = projC.property.feeStandardName || '';
+                                if (proj.projType === projType.engineering) {
+                                    ungroupedTenders.push(projC._doc);
+                                }
                             }
                             }
                             delete projC._doc.property;
                             delete projC._doc.property;
                         }
                         }
+                    } else {//未分类的单位工程不进行汇总,只取价格信息
+                        ungroupedTenders.push(proj._doc);
                     }
                     }
                     //设置分组,单位工程及单项工程分到未分组那
                     //设置分组,单位工程及单项工程分到未分组那
                     if (proj.projType === projType.tender || proj.projType === projType.engineering) {
                     if (proj.projType === projType.tender || proj.projType === projType.engineering) {
@@ -601,7 +607,8 @@ module.exports = {
                 }
                 }
                 consProjIDs = Array.from(new Set(consProjIDs));
                 consProjIDs = Array.from(new Set(consProjIDs));
                 let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
                 let summaryInfo = await pm_facade.getSummaryInfo(consProjIDs);
-                rst.summaryInfo = summaryInfo;
+                let tendersFeeInfo = await pm_facade.getTendersFeeInfo(ungroupedTenders);
+                rst.summaryInfo = {grouped: summaryInfo, ungrouped: tendersFeeInfo};
             }
             }
             callback(req, res, 0, 'success', rst);
             callback(req, res, 0, 'success', rst);
         }
         }

+ 44 - 1
modules/pm/facade/pm_facade.js

@@ -45,6 +45,7 @@ module.exports={
     copyExample: copyExample,
     copyExample: copyExample,
     getSummaryInfo: getSummaryInfo,
     getSummaryInfo: getSummaryInfo,
     getSummaryInfoByTender: getSummaryInfoByTender,
     getSummaryInfoByTender: getSummaryInfoByTender,
+    getTendersFeeInfo: getTendersFeeInfo,
     getConstructionProject: getConstructionProject,
     getConstructionProject: getConstructionProject,
     getFullPath: getFullPath,
     getFullPath: getFullPath,
     getProjectFeature:getProjectFeature,
     getProjectFeature:getProjectFeature,
@@ -630,7 +631,7 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
             if(summaryInfo[t.ID]){
             if(summaryInfo[t.ID]){
                 summaryInfo[t.ID]['name'] = t.name ? t.name : '';
                 summaryInfo[t.ID]['name'] = t.name ? t.name : '';
                 summaryList.push(summaryInfo[t.ID]);
                 summaryList.push(summaryInfo[t.ID]);
-            }
+            }k
         }
         }
     }
     }
     else {
     else {
@@ -646,6 +647,48 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
     return {parent: {name: parentName}, subList: summaryList};
     return {parent: {name: parentName}, subList: summaryList};
 }
 }
 
 
+//获取单位工程的各标段费用信息(不进行汇总)
+async function getTendersFeeInfo(tenders) {
+    let IDMapping = {};
+    //固定清单类别与汇总金额字段映射
+    let flagFieldMapping = {};
+    flagFieldMapping[billsFlags.ENGINEERINGCOST] = 'engineeringCost';
+    flagFieldMapping[billsFlags.SUB_ENGINERRING] = 'subEngineering';
+    flagFieldMapping[billsFlags.MEASURE] = 'measure';
+    flagFieldMapping[billsFlags.SAFETY_CONSTRUCTION] = 'safetyConstruction';
+    flagFieldMapping[billsFlags.OTHER] = 'other';
+    flagFieldMapping[billsFlags.CHARGE] = 'charge';
+    flagFieldMapping[billsFlags.TAX] = 'tax';
+    let tenderIDs = [];
+    if(tenders.length > 0){
+        for(let tender of tenders){
+            tenderIDs.push(tender.ID);
+            IDMapping[tender.ID] = {engineeringCost: 0, subEngineering: 0, measure: 0, safetyConstruction: 0, other: 0, charge: 0, tax: 0, rate: 0, buildingArea: '', perCost: ''};
+            IDMapping[tender.ID]['buildingArea'] = '';
+        }
+        //需要获取的清单固定类别综合合价:工程造价、分部分项、措施项目、安全文明施工专项、规费、其他项目、税金
+        let needFlags = [billsFlags.ENGINEERINGCOST, billsFlags.SUB_ENGINERRING, billsFlags.MEASURE,
+            billsFlags.SAFETY_CONSTRUCTION, billsFlags.CHARGE, billsFlags.OTHER, billsFlags.TAX];
+        //获取单位工程汇总金额需要用到的所有清单
+        let allBills = await billsModel.find({projectID: {$in: tenderIDs}, 'flags.flag': {$in: needFlags}, $or: notDeleted},
+            '-_id projectID fees flags');
+        //进行单位工程级别的汇总
+        for(let bills of allBills){
+            let billsFlag = bills.flags[0]['flag'];
+            let costField = flagFieldMapping[billsFlag];
+            IDMapping[bills.projectID][costField] = getCommonTotalFee(bills);
+        }
+        //占造价比例、单方造价
+        for(let tender of tenders){
+            let tenderInfo = IDMapping[tender.ID];
+            tenderInfo.rate = '';
+            //单方造价
+            tenderInfo.perCost = '';
+        }
+    }
+    return IDMapping;
+}
+
 async function getSummaryInfo(projectIDs){
 async function getSummaryInfo(projectIDs){
     //ID与汇总信息映射
     //ID与汇总信息映射
     let IDMapping = {};
     let IDMapping = {};

+ 5 - 3
modules/ration_glj/facade/ration_glj_facade.js

@@ -316,13 +316,15 @@ async function doCustomQuantityUpdate(datas) {
 
 
 function delete_ration_glj(user_id, datas) {
 function delete_ration_glj(user_id, datas) {
     return function (callback) {
     return function (callback) {
-        if (datas.deleteType == "RATION") {
+        callback(new Error("删除子数据失败!"),null)
+        //这个方法已经不用,先注释,稳定后再删除
+       /* if (datas.deleteType == "RATION") {
             deleteByRation(datas, callback);
             deleteByRation(datas, callback);
         } else if (datas.deleteType == "BILL") {
         } else if (datas.deleteType == "BILL") {
             deleteByBill(user_id, datas, callback);
             deleteByBill(user_id, datas, callback);
         } else {
         } else {
             deleteByID(datas, callback);
             deleteByID(datas, callback);
-        }
+        }*/
     }
     }
 }
 }
 
 
@@ -602,7 +604,7 @@ async function prepareExtData(projectID,compilation) {
 async function addGLJ(rgList,compilation) {
 async function addGLJ(rgList,compilation) {
     let newRecodes = [];
     let newRecodes = [];
     if (rgList.length <= 0) return {};
     if (rgList.length <= 0) return {};
-    let [unitFileId,ext] = await  prepareExtData(rgList[0].projectGLJID,compilation);
+    let [unitFileId,ext] = await  prepareExtData(rgList[0].projectID,compilation);
     for (let g of rgList) {
     for (let g of rgList) {
         let projectGljModel = new GLJListModel();
         let projectGljModel = new GLJListModel();
         let result = await projectGljModel.addList(getGLJSearchInfo(g),unitFileId,ext);
         let result = await projectGljModel.addList(getGLJSearchInfo(g),unitFileId,ext);

+ 11 - 0
modules/std_billsGuidance_lib/controllers/libController.js

@@ -37,6 +37,17 @@ class BillsGuideLibController extends BaseController{
             callback(req, res, 1, err, null);
             callback(req, res, 1, err, null);
         }
         }
     }
     }
+    //根据清单编号获取项目指引
+    async getItemsByCode(req, res){
+        try{
+            let data = JSON.parse(req.body.data);
+            let items = await billsGuidanceFacade.getItemsByCode(data.guidanceLibID, data.code);
+            callback(req, res, 0, '', items);
+        }
+        catch(err){
+            callback(req, res, 1, err, null);
+        }
+    }
 
 
     async updateItems(req, res){
     async updateItems(req, res){
         try{
         try{

+ 15 - 0
modules/std_billsGuidance_lib/facade/facades.js

@@ -23,6 +23,7 @@ const _ = require('lodash');
 module.exports = {
 module.exports = {
     getLibWithBills,
     getLibWithBills,
     getItemsBybills,
     getItemsBybills,
+    getItemsByCode,
 };
 };
 
 
 async function getBillsGuideLibs(findData) {
 async function getBillsGuideLibs(findData) {
@@ -133,4 +134,18 @@ async function getItemsBybills(guidanceLibID, billsID){
         await billsGuideItemsModel.bulkWrite(bulkArr);
         await billsGuideItemsModel.bulkWrite(bulkArr);
     }
     }
     return items;
     return items;
+}
+
+async function getItemsByCode(guidanceLibID, code){
+    let rst = [];
+    let guidanceLib = await billsGuideLibModel.findOne({ID: guidanceLibID});
+    if (!guidanceLib) {
+        return rst;
+    }
+    let stdBills = await stdBillsModel.findOne({code: code, billsLibId: guidanceLib.billsLibId});
+    if (!stdBills) {
+        return rst;
+    }
+    let items = await getItemsBybills(guidanceLibID, stdBills.ID);
+    return items;
 }
 }

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

@@ -15,6 +15,7 @@ const billsGuideLibController = new BillsGuideLibController();
 module.exports = function (app) {
 module.exports = function (app) {
   router.post('/getLibWithBills', billsGuideLibController.getLibWithBills);
   router.post('/getLibWithBills', billsGuideLibController.getLibWithBills);
   router.post('/getItemsByBills', billsGuideLibController.getItemsByBills);
   router.post('/getItemsByBills', billsGuideLibController.getItemsByBills);
+  router.post('/getItemsByCode', billsGuideLibController.getItemsByCode);
 
 
   app.use('/billsGuidance/api', router);
   app.use('/billsGuidance/api', router);
 };
 };

+ 7 - 3
public/web/sheet/sheet_common.js

@@ -138,8 +138,8 @@ var sheetCommonObj = {
                 sheet.setValue(0, col, setting.header[col].headerName, header);
                 sheet.setValue(0, col, setting.header[col].headerName, header);
                 sheet.setColumnWidth(col, setting.header[col].headerWidth?setting.header[col].headerWidth:100);
                 sheet.setColumnWidth(col, setting.header[col].headerWidth?setting.header[col].headerWidth:100);
             }
             }
-            if(setting.header[col].visible === false){
-                sheet.setColumnVisible(col,false);
+            if(setting.header[col].visible!==null&&setting.header[col].visible!==undefined){
+                sheet.setColumnVisible(col,setting.header[col].visible);
             }
             }
             sheet.getCell(0, col, GC.Spread.Sheets.SheetArea.colHeader).wordWrap(true);
             sheet.getCell(0, col, GC.Spread.Sheets.SheetArea.colHeader).wordWrap(true);
         }
         }
@@ -262,7 +262,11 @@ var sheetCommonObj = {
             sheet.options.isProtected = true;
             sheet.options.isProtected = true;
             sheet.getRange(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport).locked(false);
             sheet.getRange(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport).locked(false);
             for (var i = 0; i < setting.view.lockColumns.length; i++) {
             for (var i = 0; i < setting.view.lockColumns.length; i++) {
-                sheet.getRange(-1,setting.view.lockColumns[i], -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
+                let col = setting.view.lockColumns[i];
+                if(_.isString(col)){//如果是dataCode 进行转换
+                    col = _.findIndex(setting.header,{dataCode:col})
+                }
+                sheet.getRange(-1,col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
             }
             }
         }
         }
     },
     },

+ 3 - 0
public/web/slideResize.js

@@ -79,5 +79,8 @@ const SlideResize = (function() {
         }
         }
     }
     }
 
 
+
+
+
     return {horizontalSlide, loadHorizonWidth}
     return {horizontalSlide, loadHorizonWidth}
 })();
 })();

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

@@ -510,7 +510,7 @@ var TREE_SHEET_HELPER = {
         };
         };
         TreeNodeCellType.prototype.processMouseMove = function(hitinfo){//造价书主界面,当鼠标移动到单元格最右往左50个像素内时才显示悬浮提示内容
         TreeNodeCellType.prototype.processMouseMove = function(hitinfo){//造价书主界面,当鼠标移动到单元格最右往左50个像素内时才显示悬浮提示内容
             if (hitinfo.sheet.name()!=="mainSheet") return;//只有在造价书主界面才显示
             if (hitinfo.sheet.name()!=="mainSheet") return;//只有在造价书主界面才显示
-            let offset = 20;//从右向左显示的像素范围
+            let offset = hitinfo.cellRect.width//20;从右向左显示的像素范围   2018-11-22 这里需求又改成不悬停在编码单元格右边一部分才弹出,整个单元格都弹出,所以offset先改成单元格的宽度,防止以后又改回来
             let leftX = hitinfo.cellRect.x + hitinfo.cellRect.width;//最右边的坐标
             let leftX = hitinfo.cellRect.x + hitinfo.cellRect.width;//最右边的坐标
             if(leftX - hitinfo.x <= offset){//如果鼠标移动到的位置是在显示的范围内显示悬浮提示
             if(leftX - hitinfo.x <= offset){//如果鼠标移动到的位置是在显示的范围内显示悬浮提示
                 TREE_SHEET_HELPER.delayShowTips(hitinfo,setting);
                 TREE_SHEET_HELPER.delayShowTips(hitinfo,setting);
@@ -659,8 +659,7 @@ var TREE_SHEET_HELPER = {
                     //显示在下方,三角形指
                     //显示在下方,三角形指
                     let top = setting.pos.y  +hitinfo.cellRect.y+ hitinfo.cellRect.height+10;
                     let top = setting.pos.y  +hitinfo.cellRect.y+ hitinfo.cellRect.height+10;
                     let left =  setting.pos.x + hitinfo.cellRect.x;
                     let left =  setting.pos.x + hitinfo.cellRect.x;
-                    $(this._toolTipElement).css("top", top).css("left", left);
-
+                    $(this._toolTipElement).css("top", top).css("left", left).css("max-width","500px");
                 }
                 }
                 $(this._toolTipElement).show("fast");
                 $(this._toolTipElement).show("fast");
                 TREE_SHEET_HELPER.tipDiv = 'show';//做个标记
                 TREE_SHEET_HELPER.tipDiv = 'show';//做个标记

BIN
web/building_saas/css/animated_favicon1.gif


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

@@ -254,15 +254,18 @@ legend.legend{
     color: black;
     color: black;
 }
 }
 .ration_glj_spread{
 .ration_glj_spread{
-    width: 70%;
+    width: 83%;
     float: left;
     float: left;
 }
 }
 
 
 .item_spread{
 .item_spread{
     width: 29.8%;
     width: 29.8%;
     float: left;
     float: left;
-    background: #F1F1F1
+    margin-top: -5px;
+    background: #F1F1F1;
+    word-wrap:break-word
 }
 }
+
 input.text-right{
 input.text-right{
     text-align: right;
     text-align: right;
 }
 }

BIN
web/building_saas/css/favicon.ico


BIN
web/building_saas/css/logo.png


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

@@ -12,7 +12,7 @@ function autoFlashHeight(){
     $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-$('#qd').find('.bottom-content').find('.p-0').height()-5);
     $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-$('#qd').find('.bottom-content').find('.p-0').height()-5);
     //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
     //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
     $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
     $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
-    $(".main-data-side-zb").height(($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightZ) - $('#billsGuidance_items').height() - $('#zyTools').height() - 12);
+    $(".main-data-side-zb").height(($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightZ));
     /*$(".main-data-side-zi").height($(window).height()-headerHeight-toolsbarHeight- toolsBarHeightZ - $(".main-data-side-zb").height());*/
     /*$(".main-data-side-zi").height($(window).height()-headerHeight-toolsbarHeight- toolsBarHeightZ - $(".main-data-side-zb").height());*/
     $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
     $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);
     $('#glj_tree_div .modal-content').width($(window).width() < 1020 + 20 ? $(window).width() - 20 : 1020);
     $('#glj_tree_div .modal-content').width($(window).width() < 1020 + 20 ? $(window).width() - 20 : 1020);

+ 118 - 49
web/building_saas/main/html/main.html

@@ -82,11 +82,13 @@
                     <!--<a href="javascript:void(0)" class="btn btn-sm" title="复制" ><i class="fa fa-files-o" aria-hidden="true"></i></a>
                     <!--<a href="javascript:void(0)" class="btn btn-sm" title="复制" ><i class="fa fa-files-o" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-sm" title="剪切"><i class="fa fa-scissors" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-sm" title="剪切"><i class="fa fa-scissors" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-sm" title="粘贴"><i class="fa fa-clipboard" aria-hidden="true"></i></a>-->
                     <a href="javascript:void(0)" class="btn btn-sm" title="粘贴"><i class="fa fa-clipboard" aria-hidden="true"></i></a>-->
-                    <a class="btn btn-light btn-sm" href="javascript:void(0);" aria-expanded="false" data-toggle="modal" data-target="#poj-set"><i class="fa fa-cog" data-toggle="tooltip" data-original-title="项目属性" data-placement="bottom"></i></a>
-                    <span class="btn btn-light btn-sm" id="importSpan">
-                        <a class="dropdown-toggle" href="#" data-toggle="dropdown"><i class="fa fa-cloud-upload" data-toggle="tooltip" data-original-title="导入" data-placement="bottom"></i></a>
+                      <span class="btn btn-light btn-sm" data-toggle="tooltip" data-original-title="项目属性" data-placement="bottom">
+                        <a href="javascript:void(0);" data-target="#poj-set" data-toggle="modal"><i class="fa fa-cog"></i></a>
+                    </span>
+                    <span class="btn btn-light btn-sm" id="importSpan" data-toggle="tooltip" data-original-title="导入" data-placement="bottom">
+                        <a class="dropdown-toggle" href="#" data-toggle="dropdown"><i class="fa fa-cloud-upload"></i></a>
                         <div class="dropdown-menu">
                         <div class="dropdown-menu">
-                            <a id="uploadLj" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入09表Excel清单</a>
+                            <a id="uploadLj" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入表Excel清单</a>
                             <a id="uploadGld" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入广联达算量Excel清单</a>
                             <a id="uploadGld" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入广联达算量Excel清单</a>
                         </div>
                         </div>
                     </span>
                     </span>
@@ -96,7 +98,30 @@
                     <a href="javascript:void(0)"  class="btn btn-light btn-sm" id="downLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)"  class="btn btn-light btn-sm" id="downLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
                       <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upMove" data-toggle="tooltip" data-placement="bottom" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                       <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upMove" data-toggle="tooltip" data-placement="bottom" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                       <a href="javascript:void(0)" class="btn btn-light btn-sm" id="downMove" data-toggle="tooltip" data-placement="bottom" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                       <a href="javascript:void(0)" class="btn btn-light btn-sm" id="downMove" data-toggle="tooltip" data-placement="bottom" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                    <span class="btn btn-light btn-sm">
+                      <div class="btn-group ml-2">
+                          <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">更多</a>
+                          <div class="dropdown-menu dropright">
+                              <a href="" data-toggle="dropdown" class="dropdown-item dropdown-toggle"><i class="fa fa-list-ol"></i> 显示至...</a>
+                              <div class="dropdown-menu dropdown-menu-left" style="min-width: 6.5rem">
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);" id="displayDXFY">大项费用</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);"  id="displayFB1">一级分部</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);" id="displayFB2">二级分部</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);" id="displayFB3">三级分部</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);"  id="displayFB4">四级分部</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);"  id="displayFX">分项</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);" id="displayZM">子目</a>
+                                  <a class="dropdown-item btn-sm" href="javascript:void(0);"  id="displayZD">最底层</a>
+                              </div>
+                              <a href="javascript:void(0);" id="ZLFB_btn" class="dropdown-item" data-placement="bottom"><i class="fa fa-retweet" aria-hidden="true"></i> 整理分部</a>
+                              <% if (projectData.property.lockBills == true) { %>
+                              <a href="javascript:void(0)"  class="dropdown-item" name="lockBills"> <i class="fa fa-unlock-alt" aria-hidden="true"></i> 解锁清单</a>
+                              <% } else { %>
+                              <a href="javascript:void(0)"  class="dropdown-item" name="lockBills"> <i class="fa fa-lock" aria-hidden="true"></i> 锁定清单</a>
+                              <% } %>
+                              <a id="switchTznr" href="javascript:void(0);"  class="dropdown-item"><i class="fa fa-eye" aria-hidden="true"></i> 显示特征</a>
+                          </div>
+                      </div>
+                 <!--   <span class="btn btn-light btn-sm">
                       <a href="" data-toggle="dropdown"><span data-placement="bottom"><i class="fa fa-list-ol"></i></span> 显示至...</a>
                       <a href="" data-toggle="dropdown"><span data-placement="bottom"><i class="fa fa-list-ol"></i></span> 显示至...</a>
                       <div class="dropdown-menu dropdown-menu-left" style="min-width: 6.5rem">
                       <div class="dropdown-menu dropdown-menu-left" style="min-width: 6.5rem">
                       <a class="dropdown-item" href="javascript:void(0);" id="displayDXFY">大项费用</a>
                       <a class="dropdown-item" href="javascript:void(0);" id="displayDXFY">大项费用</a>
@@ -115,26 +140,34 @@
                       <% } else { %>
                       <% } else { %>
                       <a href="javascript:void(0)"  class="btn btn-light btn-sm" name="lockBills"> <i class="fa fa-lock" aria-hidden="true"></i> 锁定清单</a>
                       <a href="javascript:void(0)"  class="btn btn-light btn-sm" name="lockBills"> <i class="fa fa-lock" aria-hidden="true"></i> 锁定清单</a>
                       <% } %>
                       <% } %>
-                      <a id="switchTznr" href="javascript:void(0);"  class="btn btn-light btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> 显示特征</a>
+                      <a id="switchTznr" href="javascript:void(0);"  class="btn btn-light btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> 显示特征</a>-->
                   </div>
                   </div>
                   <div class="side-tabs">
                   <div class="side-tabs">
                       <ul class="nav nav-tabs" role="tablist">
                       <ul class="nav nav-tabs" role="tablist">
+                          <!--<li class="nav-item">
+                              <a class="nav-link px-3 right-nav-link"  href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>
+                          </li>-->
                           <li class="nav-item">
                           <li class="nav-item">
-                              <a class="nav-link px-3" href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>
-                          </li>
-                          <li class="nav-item">
-                              <a class="nav-link px-3" href="javascript:void(0)" id = 'stdBillsGuidanceTab' relaPanel="#zy">清单指引</a>
+                              <a class="nav-link px-1 right-nav-link" href="javascript:void(0)" id = 'stdBillsGuidanceTab' relaPanel="#zy">清单规则</a>
                           </li>
                           </li>
                          <!-- <li class="nav-item">
                          <!-- <li class="nav-item">
                               <a class="nav-link px-3" href="javascript:void(0)" id = 'stdBillsTab' relaPanel="#qd">清单规则</a>
                               <a class="nav-link px-3" href="javascript:void(0)" id = 'stdBillsTab' relaPanel="#qd">清单规则</a>
                           </li>-->
                           </li>-->
                           <li class="nav-item" id = "li_stdRationTab">
                           <li class="nav-item" id = "li_stdRationTab">
-                              <a class="nav-link px-3" href="javascript:void(0)" id="stdRationTab" relaPanel="#de">定额库</a>
+                              <a class="nav-link px-1 right-nav-link" href="javascript:void(0)" id="stdRationTab" relaPanel="#de">定额库</a>
+                          </li>
+                          <li class="nav-item dropdown">
+                              <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">更多</a>
+                              <div class="dropdown-menu">
+                                  <a class="dropdown-item  right-nav-link"  href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>
+                                 <!-- <a class="dropdown-item" data-toggle="tab" href="#sqpz" role="tab">书签批注</a>-->
+                              </div>
                           </li>
                           </li>
                           <script>
                           <script>
+                              //2018-11-23  zhang 模板库移动到更多下拉框
                               if (G_SHOW_BLOCK_LIB){
                               if (G_SHOW_BLOCK_LIB){
-                                  $("#li_stdRationTab").after('<li class="nav-item"> <a class="nav-link px-3" href="javascript:void(0)" ' +
-                                      'id="blockLibTab" relaPanel="#kmbk">块模板库</a></li>');
+                                  $("#locateTab").after('<a class="dropdown-item right-nav-link" href="javascript:void(0)" ' +
+                                      'id="blockLibTab" relaPanel="#kmbk">块模板库</a>');
                               }
                               }
                           </script>
                           </script>
                       </ul>
                       </ul>
@@ -144,12 +177,15 @@
                   <div class="row">
                   <div class="row">
                       <!--col-lg-12 p-0-->
                       <!--col-lg-12 p-0-->
                       <div class="main-content" style="width: 100%; display: inline-block" id="main">
                       <div class="main-content" style="width: 100%; display: inline-block" id="main">
-                          <div class="top-content">
+                          <div class="top-content" id="top_div" style="overflow:hidden;">
                               <div class="main-data-top" id="billsSpread"></div>
                               <div class="main-data-top" id="billsSpread"></div>
                           </div>
                           </div>
                           <div class="resize"></div>
                           <div class="resize"></div>
-                          <div class="bottom-content">
+                          <div class="bottom-content" id="bottom_div">
                               <ul class="nav nav-tabs" role="tablist">
                               <ul class="nav nav-tabs" role="tablist">
+                                  <li class="nav-item" id="QDJL_div">
+                                      <a class="nav-link sub-item" id="linkQDJL" data-toggle="tab" href="#subSpread" role="tab">清单精灵</a>
+                                  </li>
                                   <li class="nav-item" id="GLJ_div">
                                   <li class="nav-item" id="GLJ_div">
                                       <a class="nav-link sub-item active" id="linkGLJ" data-toggle="tab" href="#subSpread" role="tab">人材机</a>
                                       <a class="nav-link sub-item active" id="linkGLJ" data-toggle="tab" href="#subSpread" role="tab">人材机</a>
                                   </li>
                                   </li>
@@ -177,18 +213,51 @@
                                   <li class="nav-item" id = "TZJNR_div">
                                   <li class="nav-item" id = "TZJNR_div">
                                       <a class="nav-link sub-item" id="linkTZJNR" data-toggle="tab" href="#subSpread" role="tab">特征及内容</a>
                                       <a class="nav-link sub-item" id="linkTZJNR" data-toggle="tab" href="#subSpread" role="tab">特征及内容</a>
                                   </li>
                                   </li>
+                                 <!-- <li class="nav-item" id="MBZM_div">
+                                      <a class="nav-link sub-item" id="linkMBZM" data-toggle="tab" href="#subSpread" role="tab">模板子目</a>
+                                  </li>-->
                               </ul>
                               </ul>
                               <!-- Tab panes -->
                               <!-- Tab panes -->
                               <div class="tab-content" id="tabCon">
                               <div class="tab-content" id="tabCon">
                                   <div class="tab-pane active" id="subItems" role="tabpanel">
                                   <div class="tab-pane active" id="subItems" role="tabpanel">
                                       <div class="main-data-bottom ovf-hidden" id="subSpread" style="display: none" tabindex="0"></div>
                                       <div class="main-data-bottom ovf-hidden" id="subSpread" style="display: none" tabindex="0"></div>
-                                      <div class="main-data-bottom ovf-hidden" id="rgResize" style="width: 0.2%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
-                                      <div class="main-data-bottom ovf-hidden item_spread" id="replaceM" style="display: none" ></div>
+                                      <div class="main-data-bottom ovf-hidden" id="rgResize" style="width: 0.2%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1;display: none"></div>
+                                      <div class="item_spread main-data-bottom ovf-hidden " id="replaceM" style="display: none" >
+                                          <div class="p-0" id="openItemText" style="height:100%;width: 40px">
+                                              <div class="tn-nav d-flex align-items-start flex-column" data-toggle="tooltip" data-placement="left" title="" data-original-title="打开项目特征">
+                                                  <span class="mt-3 ml-2 text-primary">项目特征</span>
+                                                  <i class="fa fa-arrow-left mt-auto mb-3 text-primary ml-2"></i>
+                                              </div>
+                                          </div>
+                                          <a id="closeItemText" style="float: right;width: auto;display: none"  data-toggle="tooltip" data-placement="bottom" data-original-title="关闭项目特征" class="col-7 col-form-label" href="javascript:void(0);"><i class="fa fa-arrow-right"></i></a>
+                                          <div id="replaceText" style="display: none;padding-bottom: 10px"></div>
+                                      </div>
                                       <div class="main-data-bottom ovf-hidden" id="tabZMHS" style="display: none">
                                       <div class="main-data-bottom ovf-hidden" id="tabZMHS" style="display: none">
                                           <div class=" main-data-bottom ovf-hidden" style="width: 60%; float: left; margin: 0; padding:0;" id="coeSpread"></div>
                                           <div class=" main-data-bottom ovf-hidden" style="width: 60%; float: left; margin: 0; padding:0;" id="coeSpread"></div>
                                           <div  id="zmhsResize" style="width: 0.2%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
                                           <div  id="zmhsResize" style="width: 0.2%; height: 100%; resize:horizontal; cursor: w-resize; float: left; background: #F1F1F1"></div>
                                           <div class=" main-data-bottom ovf-hidden" style="width: 39.8%; float: left; margin: 0; padding:0;" id="assSpread"></div>
                                           <div class=" main-data-bottom ovf-hidden" style="width: 39.8%; float: left; margin: 0; padding:0;" id="assSpread"></div>
                                       </div>
                                       </div>
+                                      <div class="main-data-bottom ovf-hidden" id="tabMBZM" style="display: none;">
+                                              <div class="col-12" style="background: #F1F1F1;">
+                                                  <div class="row" style="border-bottom:1px solid #ccc">
+                                                      <label class="col-auto col-form-label col-form-label-sm">提取位置</label>
+                                                      <div class="col-2">
+                                                          <select class="form-control  form-control-sm" id="createLocation">
+                                                              <option value="1">模板子目分别放在措施项目下</option>
+                                                              <option value="2">模板子目分别放在分部分项下</option>
+                                                              <option value="3">模板子目分别放在对应混凝土子目下</option>
+                                                          </select>
+                                                      </div>
+                                                      <div class="col-1">
+                                                          <button class=" btn btn-primary btn-sm form-control" type="button" id="apply_mbzm">应用</button>
+                                                      </div>
+                                                      <div class="col-1">
+                                                          <button class=" btn btn-primary btn-sm form-control" type="button" id="next_mbzm">下一条</button>
+                                                      </div>
+                                                  </div>
+                                              </div>
+                                              <div class=" ovf-hidden" style="" id="mbzmSpread"></div>
+                                      </div>
                                       <div class="main-data-bottom ovf-hidden" style="display: none" id="comments">
                                       <div class="main-data-bottom ovf-hidden" style="display: none" id="comments">
                                           <textarea style="font-size: 0.9rem" class="form-control" rows="8" readonly=""></textarea>
                                           <textarea style="font-size: 0.9rem" class="form-control" rows="8" readonly=""></textarea>
                                       </div>
                                       </div>
@@ -206,6 +275,7 @@
                                                       <a href="javascript:void(0);" id="jobUp" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                                       <a href="javascript:void(0);" id="jobUp" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                                   </div>
                                                   </div>
                                               </div>
                                               </div>
+                                              <div class="p-0" id="TZJNRResize" style="position:relative; width: 0.2%; resize:horizontal; cursor: w-resize; background: #F1F1F1"></div>
                                               <div class="p-0" id="itemDiv" style="position:relative">
                                               <div class="p-0" id="itemDiv" style="position:relative">
                                                   <div class="main-data-bottom ovf-hidden"  id="itemSpread">
                                                   <div class="main-data-bottom ovf-hidden"  id="itemSpread">
                                                   </div>
                                                   </div>
@@ -308,6 +378,18 @@
                                               </div>
                                               </div>
                                           </div>
                                           </div>
                                       </div>
                                       </div>
+                                      <div class="container-fluid" id="qdjl" role="tabpanel">
+                                          <div class="row p-0" style="background: #efefef">
+                                              <div class="col-10 p-0">
+                                                  <div class="main-data-bottom ovf-hidden" id="elfItems">
+                                                  </div>
+                                              </div>
+                                              <div class="col-2 p-1">
+                                                  <p class="mt-3"><a id="elfInsertRation" href="javascript:void(0);" class="btn btn-sm btn-primary">插入定额</a></p>
+                                                  <p><a id="elfInsertSingle" href="javascript:void(0)" class="btn btn-sm btn-primary">插入单条</a></p>
+                                              </div>
+                                          </div>
+                                      </div>
                                   </div>
                                   </div>
                               </div>
                               </div>
                           </div>
                           </div>
@@ -317,25 +399,25 @@
                           <div class="tab-content" style="width: 99%; height: 100%; float: left">
                           <div class="tab-content" style="width: 99%; height: 100%; float: left">
                               <!--查找定位-->
                               <!--查找定位-->
                               <div class="tab-pane" id="locate">
                               <div class="tab-pane" id="locate">
-                                  <div class="sidebar-tools-bar container-fluid tools-bar-height-y">
+                                  <div class="sidebar-tools-bar container-fluid tools-bar-height-y" id="searchPanel">
                                       <div class="p-1 row">
                                       <div class="p-1 row">
                                           <div class="input-group input-group-sm col-12">
                                           <div class="input-group input-group-sm col-12">
                                               <input type="text" class="form-control form-control-sm" placeholder="查找内容" value="">
                                               <input type="text" class="form-control form-control-sm" placeholder="查找内容" value="">
                                               <div class="input-group-append">
                                               <div class="input-group-append">
-                                                  <button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
+                                                  <button class="btn btn-secondary btn-sm" type="button" id="locate_btn"><i class="fa fa-search" aria-hidden="true"></i></button>
                                               </div>
                                               </div>
                                           </div>
                                           </div>
                                           <div class="form-group col-12 mb-1">
                                           <div class="form-group col-12 mb-1">
                                               <div class="form-check form-check-inline">
                                               <div class="form-check form-check-inline">
-                                                  <input class="form-check-input" type="radio" name="content_type" id="bills" value="option1">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="bills" value="bills" checked = "true">
                                                   <label class="form-check-label" for="bills">分项/清单</label>
                                                   <label class="form-check-label" for="bills">分项/清单</label>
                                               </div>
                                               </div>
                                               <div class="form-check form-check-inline">
                                               <div class="form-check form-check-inline">
-                                                  <input class="form-check-input" type="radio" name="content_type" id="ration" value="option2">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="ration" value="ration">
                                                   <label class="form-check-label" for="ration">定额</label>
                                                   <label class="form-check-label" for="ration">定额</label>
                                               </div>
                                               </div>
                                               <div class="form-check form-check-inline">
                                               <div class="form-check form-check-inline">
-                                                  <input class="form-check-input" type="radio" name="content_type" id="raion_glj" value="option3">
+                                                  <input class="form-check-input" type="radio" name="content_type" id="raion_glj" value="ration_glj">
                                                   <label class="form-check-label" for="raion_glj">人材机</label>
                                                   <label class="form-check-label" for="raion_glj">人材机</label>
                                               </div>
                                               </div>
                                               <!--<div class="form-check form-check-inline">
                                               <!--<div class="form-check form-check-inline">
@@ -413,7 +495,7 @@
                                       <div class="main-data-side-zb" id="billsGuidance_bills">
                                       <div class="main-data-side-zb" id="billsGuidance_bills">
                                       </div>
                                       </div>
                                   </div>
                                   </div>
-                                  <div class="resize" id="zyResize" style="background: #F1F1F1"></div>
+                             <!--     <div class="resize" id="zyResize" style="background: #F1F1F1"></div>
                                   <div class="p-0 row" id="zyTools" style="background: #F1F1F1">
                                   <div class="p-0 row" id="zyTools" style="background: #F1F1F1">
                                       <div class="col">
                                       <div class="col">
                                           <button id="guidanceInsertBills" class="btn btn-primary btn-sm" style="height: 25px; line-height: 1px;" type="button">插入清单</button>
                                           <button id="guidanceInsertBills" class="btn btn-primary btn-sm" style="height: 25px; line-height: 1px;" type="button">插入清单</button>
@@ -423,12 +505,6 @@
                                   </div>
                                   </div>
                                   <div class="bottom-content">
                                   <div class="bottom-content">
                                       <div class="main-data-side-zi" id="billsGuidance_items"></div>
                                       <div class="main-data-side-zi" id="billsGuidance_items"></div>
-                                  </div>
-                                  <!--<div class="row" style="margin-left: 1px;">
-                                      <div id="billsGuidance_bills" class="main-data-side-zb" style="width: 53%; float: left; margin: 0; padding: 0;">
-                                      </div>
-                                      <div id="billsGuidance_items" class="main-data-side-zi" style="width: 46%; float: left; margin: 0; padding: 0;">
-                                      </div>
                                   </div>-->
                                   </div>-->
                               </div>
                               </div>
                               <!--清单规则-->
                               <!--清单规则-->
@@ -514,8 +590,7 @@
                                       </div>
                                       </div>
                                   </div>
                                   </div>
                                   <div class="top-content" style="overflow: hidden">
                                   <div class="top-content" style="overflow: hidden">
-                                      <div class="main-data-side-d" id="stdRationChapter">
-                                  </div>
+                                      <div class="main-data-side-d" id="stdRationChapter"></div>
                                   </div>
                                   </div>
                                   <div class="resize" id="deResize" style="background: #F1F1F1"></div>
                                   <div class="resize" id="deResize" style="background: #F1F1F1"></div>
                                   <div class="bottom-content">
                                   <div class="bottom-content">
@@ -523,8 +598,8 @@
                                   </div>
                                   </div>
                               </div>
                               </div>
                               <!--块模板库-->
                               <!--块模板库-->
-                              <div class="tab-pane" id="kmbk" role="tabpanel">
-                                  <div class="sidebar-tools-bar container-fluid tools-bar-height-z">
+                              <div class="tab-pane" id="kmbk">
+                                  <div class="tools-bar-height-d container-fluid">
                                       <div class="p-1 row">
                                       <div class="p-1 row">
                                           <select class="form-control form-control-sm col-6" id="exampleSelect1">
                                           <select class="form-control form-control-sm col-6" id="exampleSelect1">
                                               <option>我的模板库</option>
                                               <option>我的模板库</option>
@@ -569,22 +644,13 @@
                                           </div>
                                           </div>
                                       </div>
                                       </div>
                                   </div>
                                   </div>
-                                  <div class="main-data-side-m">
-                                          <div id="div_block_tree" style="height:400px;"></div>
-                                  </div>
-                                  <div class="resize" id="kmbkResize" style="background: #F1F1F1"></div>
-                                  <div class="sidebar-middle container-fluid">
-                                      <table class="table table-sm table-bordered">
-                                          <tr><th>项目编码</th><th>项目名称</th><th>单位</th><th>综合单价</th><th>项目特征</th></tr>
-                                          <tr><td>010202002</td><td>咬合灌注桩</td><td>m2</td><td>18732.38</td><td></td></tr>
-                                      </table>
+                                  <div class="top-content" style="overflow: hidden">
+                                      <div class="main-data-side-d" id="div_block_tree"></div>
                                   </div>
                                   </div>
-                                  <div class="sidebar-bottom container-fluid">
-                                      <table class="table table-sm table-bordered">
-                                          <tr><th>编码</th><th>名称</th><th>单位</th><th>含量</th><th>取费专业</th><th>综合单价</th><th>子目换算状态</th></tr>
-                                          <tr><td>AA0043</td><td>人工沟槽 软</td><td>1000</td><td>0.01</td><td>人工土石</td><td></td><td></td></tr>
-                                          <tr><td>AA0046</td><td>人工沟槽 硬</td><td>1000</td><td>0.21</td><td>人工土石</td><td></td><td></td></tr>
-                                      </table>
+                                  <div class="resize" id="kmbkResize" style="background-color:#dfdcdc;"></div>
+                                  <div class="bottom-content">
+                                      <div id="div_block_bill" style="height:90px"></div>
+                                      <div id="div_block_ration" style="height:100%"></div>
                                   </div>
                                   </div>
                               </div>
                               </div>
                           </div>
                           </div>
@@ -1704,7 +1770,7 @@
             </div>
             </div>
             <div class="modal-footer">
             <div class="modal-footer">
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
-                <a href="" class="btn btn-primary" id="btn_block_createBlocks">确定生成</a>
+                <button type="button" class="btn btn-primary" data-dismiss="modal" id="btn_block_createBlocks">确定生成</button>
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
@@ -1784,6 +1850,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_coe.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_coe.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_ass.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_ass.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_installation.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/ration_installation.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/models/ration_template.js"></script>
     <!--<script type="text/javascript" src="/web/building_saas/main/js/models/volume_price.js"></script>-->
     <!--<script type="text/javascript" src="/web/building_saas/main/js/models/volume_price.js"></script>-->
     <script type="text/javascript" src="/web/building_saas/main/js/models/labour_coe.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/labour_coe.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
@@ -1843,7 +1910,9 @@
     <script type="text/javascript" src="/web/building_saas/main/js/views/character_content_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/character_content_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/zmhs_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/zmhs_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/mbzm_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/tender_price_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/tender_price_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/billsElf.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/sub_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/sub_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/fee_rate_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/fee_rate_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/quantity_edit_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/quantity_edit_view.js"></script>

+ 19 - 4
web/building_saas/main/js/controllers/block_controller.js

@@ -127,6 +127,7 @@ let BlockController = {
             data.ration_coes = projectObj.project.ration_coe.getCoeByRationID(data.ID);
             data.ration_coes = projectObj.project.ration_coe.getCoeByRationID(data.ID);
             data.ration_installations =  projectObj.project.ration_installation.getInstallationByRationID(data.ID);
             data.ration_installations =  projectObj.project.ration_installation.getInstallationByRationID(data.ID);
             data.quantity_details = projectObj.project.quantity_detail.getDetailByRationID(data.ID);
             data.quantity_details = projectObj.project.quantity_detail.getDetailByRationID(data.ID);
+            data.ration_template = projectObj.project.ration_template.getTemplateByRationID(data.ID);
         }else if(node.children.length>0){
         }else if(node.children.length>0){
             let children = [];
             let children = [];
             for(let c of node.children){
             for(let c of node.children){
@@ -290,10 +291,11 @@ let BlockController = {
         let mainTree = project.mainTree;
         let mainTree = project.mainTree;
         Bills.addDatasToList(result.bills);
         Bills.addDatasToList(result.bills);
         Ration.addDatasToList(result.rations);
         Ration.addDatasToList(result.rations);
-        project.quantity_detail.addDatasToList(result.quantity_details);
+        Ration.addSubListOfRation(result);//这里是新插入定额时
+      /*  project.quantity_detail.addDatasToList(result.quantity_details);
         project.ration_glj.addDatasToList(result.ration_gljs);
         project.ration_glj.addDatasToList(result.ration_gljs);
         project.ration_coe.addDatasToList(result.ration_coes);
         project.ration_coe.addDatasToList(result.ration_coes);
-        project.ration_installation.addDatasToList(result.ration_installations);
+        project.ration_installation.addDatasToList(result.ration_installations);*/
         for(let u of  result.updateData){
         for(let u of  result.updateData){
             let unode = mainTree.findNode(u.query.ID);
             let unode = mainTree.findNode(u.query.ID);
             if(unode){
             if(unode){
@@ -390,7 +392,7 @@ let BlockController = {
     preparePasteData : function (datas,billsIDMap,firstParentID,lastNextID) {
     preparePasteData : function (datas,billsIDMap,firstParentID,lastNextID) {
         let me = this;
         let me = this;
         me.datas = _.cloneDeep(projectObj.project.Bills.datas);
         me.datas = _.cloneDeep(projectObj.project.Bills.datas);
-        let bills = [],rations=[],ration_gljs = [],ration_coes = [],quantity_details = [],ration_installations = [];
+        let bills = [],rations=[],ration_gljs = [],ration_coes = [],quantity_details = [],ration_installations = [],ration_templates=[];
         let firstBillIDs = [],lastBillID = null;//记录第一层清单的ID,和第一层的最后一个清单ID
         let firstBillIDs = [],lastBillID = null;//记录第一层清单的ID,和第一层的最后一个清单ID
         let firstIDMap = {};
         let firstIDMap = {};
         for(let i = 0 ;i< datas.length ;i++){
         for(let i = 0 ;i< datas.length ;i++){
@@ -420,7 +422,7 @@ let BlockController = {
         }
         }
 
 
 
 
-        return {bills:bills,rations:rations,ration_gljs:ration_gljs,ration_coes:ration_coes,quantity_details:quantity_details,ration_installations:ration_installations};
+        return {bills:bills,rations:rations,ration_gljs:ration_gljs,ration_coes:ration_coes,quantity_details:quantity_details,ration_installations:ration_installations,ration_templates:ration_templates};
 
 
         function eachData(data) {
         function eachData(data) {
             if(data.sourceType == 'bills'){
             if(data.sourceType == 'bills'){
@@ -453,10 +455,22 @@ let BlockController = {
                 for(let ri of data.ration_installations){
                 for(let ri of data.ration_installations){
                     ration_installations.push(createSubList(ri,tem_r));
                     ration_installations.push(createSubList(ri,tem_r));
                 }
                 }
+                if(data.ration_template){
+                    ration_templates.push(createRationTemplate(data.ration_template,tem_r))
+                }
             }
             }
 
 
         }
         }
 
 
+        function createRationTemplate(oldTem,rationData) {
+            let template = _.cloneDeep(oldTem);
+            delete template._id;
+            template.ID = uuid.v1();
+            template.projectID = projectObj.project.ID();
+            template.rationID = rationData.ID;
+            return template;
+        }
+        
         function createSubList(subData,rationData) {
         function createSubList(subData,rationData) {
             let tem_sub = _.cloneDeep(subData);
             let tem_sub = _.cloneDeep(subData);
             delete tem_sub._id;
             delete tem_sub._id;
@@ -490,6 +504,7 @@ let BlockController = {
             delete tem_ration.ration_coes;
             delete tem_ration.ration_coes;
             delete tem_ration.ration_installations;
             delete tem_ration.ration_installations;
             delete tem_ration.quantity_details;
             delete tem_ration.quantity_details;
+            delete tem_ration.referenceRationID;//删除关联的主定额信息
             delete tem_ration.__v;
             delete tem_ration.__v;
             delete tem_ration.sourceType;
             delete tem_ration.sourceType;
 
 

+ 47 - 2
web/building_saas/main/js/controllers/material_controller.js

@@ -3,6 +3,7 @@
  */
  */
 let MaterialController = {
 let MaterialController = {
     subSpreadDivWidth:"",
     subSpreadDivWidth:"",
+    showItemText:false,
     //规则相关映射
     //规则相关映射
     rule1: function (node) {
     rule1: function (node) {
         let itemText = node.data.itemCharacterText;
         let itemText = node.data.itemCharacterText;
@@ -163,6 +164,9 @@ let MaterialController = {
     sheet:null,
     sheet:null,
     datas:[],
     datas:[],
     showReplaceDiv:function (node) {
     showReplaceDiv:function (node) {
+        if(!($('#linkGLJ').hasClass('active'))){
+            return;
+        }
         $("#subSpread").addClass("ration_glj_spread");
         $("#subSpread").addClass("ration_glj_spread");
         $("#replaceM").show();
         $("#replaceM").show();
         $("#rgResize").show();// 拖动调整大小功能添加
         $("#rgResize").show();// 拖动调整大小功能添加
@@ -178,6 +182,7 @@ let MaterialController = {
         refreshSubSpread();
         refreshSubSpread();
     },
     },
     showReplaceSpread:function(node){
     showReplaceSpread:function(node){
+        $("#replaceM").addClass("ovf-hidden");
         this.initSpread();
         this.initSpread();
         this.showData(node);
         this.showData(node);
     },
     },
@@ -219,8 +224,32 @@ let MaterialController = {
             $('#subSpread').css('width','');
             $('#subSpread').css('width','');
             return;
             return;
         }
         }
-        $('#subSpread').css('width',MaterialController.subSpreadDivWidth);
-        $("#replaceM").html(text);
+        $('#replaceM').css('margin-top',0);
+        this.toggleItemInit();
+        $("#replaceText").html(text);
+    },
+    toggleItemInit:function () {
+        if(this.showItemText == true){
+            $("#replaceM").removeClass("ovf-hidden");
+            $("#openItemText").hide();
+            $("#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);
+        }else {
+            $("#replaceM").addClass("ovf-hidden");
+            $("#openItemText").show();
+            $("#replaceText").hide();
+            $("#closeItemText").hide();
+            $("#rgResize").hide();
+            $('#replaceM').css('width',30);
+            $('#subSpread').css('width',$("#bottom_div").width()-30);
+
+
+        }
     },
     },
     getItems:function(characterText){
     getItems:function(characterText){
         if(!characterText) return;
         if(!characterText) return;
@@ -271,3 +300,19 @@ slideResize(rg_sideResizeEles, {min: 100, max: $('#tabCon').width()-100}, 'width
     MaterialController.subSpreadDivWidth = $('#subSpread').css('width');
     MaterialController.subSpreadDivWidth = $('#subSpread').css('width');
     refreshSubSpread();
     refreshSubSpread();
 });
 });
+
+
+$(function (){
+    $("#openItemText").click(function () {
+        MaterialController.showItemText = true;
+        MaterialController.toggleItemInit();
+        refreshSubSpread();
+    });
+
+    $("#closeItemText").click(function () {
+        MaterialController.showItemText = false;
+        MaterialController.toggleItemInit();
+        refreshSubSpread();
+    });
+
+})

+ 11 - 6
web/building_saas/main/js/main.js

@@ -126,12 +126,17 @@ function slideResize(eles, limit, type, callback) {
             fEleChangeSize = fEleSize - moveSize;
             fEleChangeSize = fEleSize - moveSize;
             fEleChangeSize = fEleChangeSize < limit.min ? limit.min : fEleChangeSize;
             fEleChangeSize = fEleChangeSize < limit.min ? limit.min : fEleChangeSize;
             fEleChangeSize = fEleChangeSize > limit.max ? limit.max + 9 : fEleChangeSize;
             fEleChangeSize = fEleChangeSize > limit.max ? limit.max + 9 : fEleChangeSize;
-
+            let rePercent = {};
             if(type === 'width'){
             if(type === 'width'){
-                let rePercent = getResizeWidthPercent(nEleChangeSize, fEleChangeSize);
-                console.log(rePercent);
-                eles.nearElement.css(type, rePercent.nearPercent);
-                eles.farElement.css(type, rePercent.farPercent);
+                 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{
             else{
                 eles.nearSpread[type](nEleChangeSize);
                 eles.nearSpread[type](nEleChangeSize);
@@ -141,7 +146,7 @@ function slideResize(eles, limit, type, callback) {
             //实时刷新页面
             //实时刷新页面
             mouseMoveCount+=Math.abs(moveSize);//取移动的决对值
             mouseMoveCount+=Math.abs(moveSize);//取移动的决对值
             if(mouseMoveCount >=5){//当累计移动超过5个像素时,才刷新,减少刷新次数
             if(mouseMoveCount >=5){//当累计移动超过5个像素时,才刷新,减少刷新次数
-                if(callback) callback();
+                if(callback) callback(rePercent);
                 mouseMoveCount = 0;
                 mouseMoveCount = 0;
             }
             }
         }
         }

+ 1 - 7
web/building_saas/main/js/models/bills.js

@@ -756,9 +756,6 @@ var Bills = {
             CommonAjax.post("/bills/multiDelete", updateData, function () {
             CommonAjax.post("/bills/multiDelete", updateData, function () {
                 let quantity_detail_datas = project.quantity_detail.datas;
                 let quantity_detail_datas = project.quantity_detail.datas;
                 let ration_datas = project.Ration.datas;
                 let ration_datas = project.Ration.datas;
-                let ration_glj_datas = project.ration_glj.datas;
-                let ration_coe_datas = project.ration_coe.datas;
-                let ration_install_datas = project.ration_installation.datas;
                 let nodes = controller.tree.nodes;
                 let nodes = controller.tree.nodes;
                 let prefix = controller.tree.prefix;
                 let prefix = controller.tree.prefix;
                 //更新缓存
                 //更新缓存
@@ -777,10 +774,7 @@ var Bills = {
                 if(updateData['ration']){
                 if(updateData['ration']){
                     for(let r_key in updateData['ration']){//定额只有删除,没有更新
                     for(let r_key in updateData['ration']){//定额只有删除,没有更新
                         _.remove(ration_datas,{'ID':r_key});
                         _.remove(ration_datas,{'ID':r_key});
-                        _.remove(quantity_detail_datas,{'rationID':r_key});
-                        _.remove(ration_glj_datas,{'rationID':r_key});
-                        _.remove(ration_coe_datas,{'rationID':r_key});
-                        _.remove(ration_install_datas,{'rationID':r_key});
+                        project.Ration.deleteSubListOfRation({ID:r_key});
                     }
                     }
                 }
                 }
                 controller.m_delete(mainNodes);//删除树节点
                 controller.m_delete(mainNodes);//删除树节点

+ 8 - 8
web/building_saas/main/js/models/calc_base.js

@@ -916,7 +916,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(glj.type === gljType.LABOUR){
             if(glj.type === gljType.LABOUR){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -926,7 +926,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -936,7 +936,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -946,7 +946,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(glj.type === gljType.LABOUR){
             if(glj.type === gljType.LABOUR){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -956,7 +956,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
             if(baseMaterialTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -966,7 +966,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
             if(baseMachineTypes.includes(glj.type) && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -976,7 +976,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(glj.type === gljType.MAIN_MATERIAL && glj.ratio_data.length === 0){
             if(glj.type === gljType.MAIN_MATERIAL && glj.ratio_data.length === 0){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.base_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;
@@ -986,7 +986,7 @@ let baseFigureTemplate = {
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         for(let glj of projGljs){
         for(let glj of projGljs){
             if(glj.type === gljType.EQUIPMENT){
             if(glj.type === gljType.EQUIPMENT){
-                rst = (rst + parseFloat(glj.supply_quantity * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
+                rst = (rst + parseFloat(projectGljObject.getSupplyQuantityByGlj(glj) * glj.unit_price.market_price).toDecimal(decimalObj.bills.totalPrice)).toDecimal(decimalObj.bills.totalPrice);
             }
             }
         }
         }
         return rst;
         return rst;

+ 1 - 1
web/building_saas/main/js/models/calc_program.js

@@ -761,7 +761,7 @@ let calcTools = {
         // 定额大类
         // 定额大类
         if (me.isRationCategory(treeNode)) {
         if (me.isRationCategory(treeNode)) {
             data.isSubcontract = treeNode.data.isSubcontract;
             data.isSubcontract = treeNode.data.isSubcontract;
-
+            data.evaluationProject = treeNode.data.evaluationProject;
             //定额类型的工料机做特殊处理
             //定额类型的工料机做特殊处理
             if(me.isGljRation(treeNode)){
             if(me.isGljRation(treeNode)){
                 data.code = treeNode.data.code;
                 data.code = treeNode.data.code;

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

@@ -12,6 +12,7 @@ const ModuleNames = {
     ration_coe:'ration_coe',
     ration_coe:'ration_coe',
     ration_ass:'ration_ass',
     ration_ass:'ration_ass',
     ration_installation:'ration_installation',
     ration_installation:'ration_installation',
+    ration_template:'ration_template',
     quantity_detail:'quantity_detail',
     quantity_detail:'quantity_detail',
     labour_coe: 'labour_coe',
     labour_coe: 'labour_coe',
     calc_program: 'calc_program',
     calc_program: 'calc_program',

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

@@ -80,6 +80,7 @@ var PROJECT = {
             this.ration_coe = ration_coe.createNew(this);
             this.ration_coe = ration_coe.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
             this.ration_installation = ration_installation.createNew(this);
             this.ration_installation = ration_installation.createNew(this);
+            this.ration_template = ration_template.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
             this.installation_fee = installation_fee.createNew(this);
             this.installation_fee = installation_fee.createNew(this);
             this.FeeRate = FeeRate.createNew(this);
             this.FeeRate = FeeRate.createNew(this);

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

@@ -384,7 +384,7 @@ var quantity_detail = {
                     query.billID = recode.billID;
                     query.billID = recode.billID;
                     doc.billID=recode.billID;
                     doc.billID=recode.billID;
                 }
                 }
-                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){
+                if(gljUtil.isDef(args.editingText)&&this.checkAndCalcResult(args.editingText,args.row,doc) === false){
                     gljOprObj.showQuantityDetailData();
                     gljOprObj.showQuantityDetailData();
                     return;
                     return;
                 }
                 }

+ 16 - 15
web/building_saas/main/js/models/ration.js

@@ -269,11 +269,7 @@ var Ration = {
         ration.prototype.delete = function (ration) {
         ration.prototype.delete = function (ration) {
             var ration_glj =projectObj.project.ration_glj;
             var ration_glj =projectObj.project.ration_glj;
             this.project.pushNow('deleteRation', [this.getSourceType(),ration_glj.getSourceType()], [this.getDeleteData(ration),ration_glj.getDeleteDataByRation(ration)]);
             this.project.pushNow('deleteRation', [this.getSourceType(),ration_glj.getSourceType()], [this.getDeleteData(ration),ration_glj.getDeleteDataByRation(ration)]);
-
-            project.ration_glj.deleteByRation(ration);
-            project.ration_coe.deleteByRation(ration);
-            project.quantity_detail.deleteByRation(ration);
-            project.ration_installation.deleteByRation(ration);
+            this.deleteSubListOfRation(ration);
             this.datas.splice(this.datas.indexOf(ration), 1);
             this.datas.splice(this.datas.indexOf(ration), 1);
         };
         };
         ration.prototype.removeByID = function(ID){
         ration.prototype.removeByID = function(ID){
@@ -420,9 +416,8 @@ var Ration = {
                        project.ration_glj.removeNodeByRation(recode.ration,projectObj.mainController);
                        project.ration_glj.removeNodeByRation(recode.ration,projectObj.mainController);
                        project.Ration.deleteSubListOfRation(recode.ration);//删除旧定额下的相关记录
                        project.Ration.deleteSubListOfRation(recode.ration);//删除旧定额下的相关记录
                        //添加新的记录
                        //添加新的记录
-                       project.ration_glj.addDatasToList(recode.ration_gljs);
-                       project.ration_coe.addDatasToList(recode.ration_coes);
-                       project.ration_installation.addDatasToList(recode.ration_installs);
+                       project.Ration.addSubListOfRation(recode);
+
 
 
                        project.ration_glj.addToMainTree(recode.ration_gljs);
                        project.ration_glj.addToMainTree(recode.ration_gljs);
                    }
                    }
@@ -507,10 +502,7 @@ var Ration = {
                     //更新缓存
                     //更新缓存
                     for(let data of rstData){
                     for(let data of rstData){
                         me.datas.push(data.ration);
                         me.datas.push(data.ration);
-                        project.ration_glj.addDatasToList(data.ration_gljs);
-                        project.ration_coe.addDatasToList(data.ration_coes);
-                        project.ration_installation.addDatasToList(data.ration_installs);
-
+                        me.addSubListOfRation(data);
                         //插入树节点
                         //插入树节点
                         newSource = data.ration;
                         newSource = data.ration;
                         newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
                         newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
@@ -605,9 +597,8 @@ var Ration = {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                     //更新缓存
                     //更新缓存
                     me.datas.push(data.ration);
                     me.datas.push(data.ration);
-                    project.ration_glj.addDatasToList(data.ration_gljs);
-                    project.ration_coe.addDatasToList(data.ration_coes);
-                    project.ration_installation.addDatasToList(data.ration_installs);
+
+                    me.addSubListOfRation(data);
 
 
                     //插入树节点
                     //插入树节点
                     newSource = data.ration;
                     newSource = data.ration;
@@ -686,6 +677,7 @@ var Ration = {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:null,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:brUpdate,needInstall:false},function (data) {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:null,newData:newData,defaultLibID: rationLibObj.getDefaultStdRationLibID(),calQuantity:false,brUpdate:brUpdate,needInstall:false},function (data) {
                     //更新缓存
                     //更新缓存
                     me.datas.push(data.ration);
                     me.datas.push(data.ration);
+                    me.addSubListOfRation(data);
                     //插入树节点
                     //插入树节点
                     newSource = data.ration;
                     newSource = data.ration;
                     newNode.source = newSource;
                     newNode.source = newSource;
@@ -705,7 +697,16 @@ var Ration = {
             projectObj.project.ration_coe.deleteByRation(ration);
             projectObj.project.ration_coe.deleteByRation(ration);
             projectObj.project.quantity_detail.deleteByRation(ration);
             projectObj.project.quantity_detail.deleteByRation(ration);
             projectObj.project.ration_installation.deleteByRation(ration);
             projectObj.project.ration_installation.deleteByRation(ration);
+            projectObj.project.ration_template.deleteByRation(ration);
+        };
+        ration.prototype.addSubListOfRation = function (data) {
+             project.ration_glj.addDatasToList(data.ration_gljs);
+             project.ration_coe.addDatasToList(data.ration_coes);
+             project.ration_installation.addDatasToList(data.ration_installations);
+             project.ration_template.addDatasToList(data.ration_templates);
+             project.quantity_detail.addDatasToList(data.quantity_details);
         };
         };
+
         ration.prototype.replaceRation = function (ration, std) {
         ration.prototype.replaceRation = function (ration, std) {
             this.project.beginUpdate('replaceRation');
             this.project.beginUpdate('replaceRation');
             
             

+ 38 - 0
web/building_saas/main/js/models/ration_template.js

@@ -0,0 +1,38 @@
+/**
+ * Created by zhang on 2018/11/26.
+ */
+let ration_template = {
+    createNew: function (project) {
+        let ration_template = function (proj){
+            this.datas = [];
+
+            var sourceType = ModuleNames.ration_template;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.ration_template, this);
+
+        };
+        // prototype用于定义public方法
+        ration_template.prototype.loadData = function (datas) {
+            this.datas = datas;
+        };
+        ration_template.prototype.addDatasToList = function (datas) {
+            let  me = this;
+            if(datas&&datas.length>0){
+                if (me.datas && Array.isArray(me.datas)) {
+                    me.datas = me.datas.concat(datas);
+                } else {
+                    me.datas = datas;
+                }
+            }
+        };
+        ration_template.prototype.getTemplateByRationID = function (rationID) {
+            return _.find(this.datas, {'rationID': rationID});
+        };
+        ration_template.prototype.deleteByRation = function(ration){
+            _.remove(this.datas,{'rationID':ration.ID});
+        };
+        return new ration_template(project);
+    }
+}

+ 768 - 0
web/building_saas/main/js/views/billsElf.js

@@ -0,0 +1,768 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/11/25
+ * @version
+ */
+
+/*
+* 造价书下方清单精灵
+* */
+//选项单选多选状态(按住alt为多选) 单选:0 多选:1
+let billsGuidanceSelMode = 0;
+
+const BillsElf = (function() {
+    //清单精灵树挂载的地方,selected:当前选中的清单,mapping:以前九位清单编码为索引, 'xxx' : {elf: {datas, tree, controller}}
+    let bills = {selected: null, mapping: {}};
+    const itemType = {
+        job: 0,
+        ration: 1
+    };
+    const elfItem = {
+        dom: $('#elfItems'),
+        workBook: null,
+        tree: null,
+        controller: null,
+        treeSetting: {
+            treeCol: 0,
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [40],
+            defaultRowHeight: 21,
+            cols: [
+                {
+                    width: 250,
+                    readOnly: true,
+                    head: {
+                        titleNames: ["施工工序"],
+                        spanCols: [1],
+                        spanRows: [1],
+                        vAlign: [1],
+                        hAlign: [1],
+                        font: ["Arial"]
+                    },
+                    data: {
+                        field: "name",
+                        vAlign: 1,
+                        hAlign: 0,
+                        font: "Arial"
+                    }
+                },
+                {
+                    width: 250,
+                    readOnly: false,
+                    head: {
+                        titleNames: ["选项"],
+                        spanCols: [1],
+                        spanRows: [1],
+                        vAlign: [1],
+                        hAlign: [1],
+                        font: ["Arial"]
+                    },
+                    data: {
+                        field: "options",
+                        vAlign: 1,
+                        hAlign: 0,
+                        font: "Arial"
+                    }
+                }
+            ]
+        },
+        headers: [
+            {name: '施工工序', dataCode: 'name', width: 250, rateWidth: 0.5, vAlign: 'center', hAlign: 'center', formatter: '@'},
+            {name: '选项', dataCode: 'options', width: 250, rateWidth: 0.5,  vAlign: 'center', hAlign: 'left', formatter: '@'},
+        ],
+        rowHeaderWidth:25,
+        events: {
+            SelectionChanging: function (sender, info) {
+                elfItemInitSel(info.newSelections[0].row);
+            },
+            CellClick: function (sender, args) {
+                if(elfItem.headers[args.col]['dataCode'] === 'options' && args.sheetArea === 3){
+                    if(!args.sheet.getCell(args.row, args.col).locked() && !args.sheet.isEditing()){
+                        args.sheet.startEdit();
+                    }
+                }
+            },
+            ClipboardPasting: function (sender, info) {
+                info.cancel = true;
+            }
+        }
+    };
+    const options = {
+        workBook: {
+            tabStripVisible:  false,
+            allowContextMenu: false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true
+        },
+        sheet: {
+            protectionOptions: {allowResizeRows: true, allowResizeColumns: true},
+            clipBoardOptions: GC.Spread.Sheets.ClipboardPasteOptions.values
+        }
+    };
+    //渲染时方法,停止渲染
+    //@param {Object}sheet {Function}func @return {void}
+    function renderSheetFunc(sheet, func){
+        sheet.suspendEvent();
+        sheet.suspendPaint();
+        if(func){
+            func();
+        }
+        sheet.resumeEvent();
+        sheet.resumePaint();
+    }
+    //设置表选项
+    //@param {Object}workBook {Object}opts @return {void}
+    function setOptions(workBook, opts) {
+        for(let opt in opts.workBook){
+            workBook.options[opt] = opts.workBook[opt];
+        }
+        for(let opt in opts.sheet){
+            workBook.getActiveSheet().options[opt] = opts.sheet[opt];
+        }
+    }
+    //建表头
+    //@param {Object}sheet {Array}headers @return {void}
+    function buildHeader(sheet, headers) {
+        let fuc = function () {
+            sheet.setColumnCount(headers.length);
+            sheet.setRowHeight(0, 30, GC.Spread.Sheets.SheetArea.colHeader);
+            sheet.setColumnWidth(0, sheet.getParent() === bills.workBook ? 15 : 25, GC.Spread.Sheets.SheetArea.rowHeader);
+            if(sheet.getParent() === elfItem.workBook || sheet.getParent() === guideItem.workBook){
+                sheet.setRowHeight(0, 20, GC.Spread.Sheets.SheetArea.colHeader);
+            }
+            for(let i = 0, len = headers.length; i < len; i++){
+                sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
+                sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
+                if(headers[i].formatter){
+                    sheet.setFormatter(-1, i, headers[i].formatter);
+                }
+                sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
+                sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
+            }
+        };
+        renderSheetFunc(sheet, fuc);
+    }
+    //表监听事件
+    //@param {Object}workBook @return {void}
+    function bindEvent(workBook, events) {
+        if(Object.keys(events).length === 0){
+            return;
+        }
+        const Events = GC.Spread.Sheets.Events;
+        for(let event in events){
+            workBook.bind(Events[event], events[event]);
+        }
+    }
+    //根据宽度比例设置列宽
+    //@param {Object}workBook {Number}workBookWidth {Array}headers @return {void}
+    function setColumnWidthByRate() {
+        let workBook = elfItem.workBook,
+            workBookWidth = ($(window).width() - $('.main').find('.main-nav').width() - $('.main-side').width()) * 5 / 6,
+            headers = elfItem.headers;
+        if(workBook){
+            workBookWidth -= 60;
+            const sheet = workBook.getActiveSheet();
+            sheet.suspendEvent();
+            sheet.suspendPaint();
+            for(let col = 0; col < headers.length; col++){
+                if(headers[col]['rateWidth'] !== undefined && headers[col]['rateWidth'] !== null && headers[col]['rateWidth'] !== ''){
+                    let width = workBookWidth * headers[col]['rateWidth'];
+                    if(headers[col]['dataCode'] === 'options'){
+                        width = width;
+                    }
+                    sheet.setColumnWidth(col, width, GC.Spread.Sheets.SheetArea.colHeader)
+                }
+                else {
+                    if(headers[col]['headerWidth'] !== undefined && headers[col]['headerWidth'] !== null && headers[col]['headerWidth'] !== ''){
+                        sheet.setColumnWidth(col, headers[col]['headerWidth'], GC.Spread.Sheets.SheetArea.colHeader)
+                    }
+                }
+            }
+            sheet.resumeEvent();
+            sheet.resumePaint();
+        }
+    }
+    //建表
+    //@param {Object}module @return {void}
+    function buildSheet() {
+        if(!elfItem.workBook){
+            elfItem.workBook = new GC.Spread.Sheets.Workbook(elfItem.dom[0], {sheetCount: 1});
+            sheetCommonObj.spreadDefaultStyle(elfItem.workBook);
+            let sheet = elfItem.workBook.getActiveSheet();
+            sheet.options.isProtected = true;
+            sheet.getRange(-1, 0, -1, 1).locked(true);
+            sheet.getRange(-1, 1, -1, 1).locked(false);
+            if(elfItem.rowHeaderWidth) {
+                sheet.setColumnWidth(0, elfItem.rowHeaderWidth, GC.Spread.Sheets.SheetArea.rowHeader);
+            }
+            setOptions(elfItem.workBook, options);
+            buildHeader(elfItem.workBook.getActiveSheet(), elfItem.headers);
+            setColumnWidthByRate(elfItem.workBook, $('#elfItems').width(), elfItem.headers);
+            bindEvent(elfItem.workBook, elfItem.events);
+        }
+    }
+    //刷新表
+    //@return {void}
+    function refreshWorkBook(){
+        if (elfItem.workBook) {
+            elfItem.workBook.refresh();
+        }
+    }
+    //清空表数据
+    //@param {Object}sheet {Array}headers {Number}rowCount @return {void}
+    function cleanData(sheet, headers, rowCount){
+        renderSheetFunc(sheet, function () {
+            sheet.clear(-1, 0, -1, headers.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
+            if (rowCount > 0) {
+                sheet.setRowCount(rowCount);
+            } else {
+                sheet.setRowCount(0);
+            }
+        });
+    }
+    //初始化并输出树
+    //@param {Object}module {Object}sheet {Object}treeSetting {Array}datas
+    function initTree(module, sheet, treeSetting, datas){
+        module.tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
+        module.controller = TREE_SHEET_CONTROLLER.createNew(module.tree, sheet, treeSetting, false);
+        module.tree.loadDatas(datas);
+        module.controller.showTreeData();
+    }
+    //清单精灵表焦点控制
+    //@param {Number}row @return {void}
+    function elfItemInitSel(row){
+        let billsNode = bills.selected;
+        let node = null;
+        if(billsNode && billsNode.elf.tree){
+            node = billsNode.elf.tree.items[row];
+            if(node){
+                billsNode.elf.tree.selected = node;
+            }
+        }
+        refreshInsertSingle();
+    }
+    //清单焦点变换-清单精灵操作,获取清单前九位编码的标准清单清单精灵选项
+    //@param {String}code @return {void}
+    function billsSelElf(code) {
+        let elfSheet = elfItem.workBook.getActiveSheet();
+        cleanData(elfSheet, elfItem.headers, -1);
+        if (!code || code === '') {
+            $('#elfInsertRation').addClass('disabled');
+            $('#elfInsertSingle').addClass('disabled');
+            return;
+        }
+        let nineCode = code.substr(0, 9);
+        //查看此清单映射是否存在此编码映射数据,不存在,则新建映射
+        if (!bills.mapping[nineCode]) {
+            bills.mapping[nineCode] = {elf: {datas: [], tree: null, controller: null}};
+        }
+        let node = bills.mapping[nineCode];
+        bills.selected = node;
+        if(!node.elf.tree){
+            let guidanceLibID;
+            if (projectInfoObj.projectInfo.engineeringInfo && projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib) {
+                guidanceLibID = projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib[0] ? projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib[0].id : null;
+            }
+            CommonAjax.post('/billsGuidance/api/getItemsByCode', {guidanceLibID: guidanceLibID, code: nineCode}, function (rstData) {
+                //定额数据删除编号信息
+                for(let rData of rstData){
+                    if(rData.type === itemType.ration){
+                        let nameArr = rData.name.split(' ');
+                        if(nameArr.length > 0){
+                            nameArr.splice(0, 1);
+                            rData.name = nameArr.join(' ');
+                        }
+                    }
+                }
+                node.elf.datas = rstData;
+                //第一层节点数据
+                let firstLevelDatas = _.filter(rstData, function (data) {
+                    return data.ParentID == -1;
+                });
+                //第一层初始数据的选项显示
+                for(let fData of firstLevelDatas){
+                    let options = getOptions(fData, rstData);
+                    fData.options = options.length > 0 ? options[0].name : '';
+                    //下挂的选项
+                    fData.optionsData = options && options.length > 0 ? _.cloneDeep(options) : [];
+                    fData.optionChecked = options && options.length > 0 ? [_.cloneDeep(options[0])] : [];
+                }
+                renderSheetFunc(elfSheet, function () {
+                    initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
+                    //初始选择选项
+                    let initOptsOpr = [];
+                    for(let elfNode of node.elf.tree.items){
+                        if(elfNode.data.optionsData.length > 0){
+                            initOptsOpr.push({node: elfNode, data: elfNode.data.optionsData[0]});
+                        }
+                    }
+                    for(let opr of initOptsOpr){
+                        insertNodeByData(opr.node, opr.data);
+                    }
+                    TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.elf.tree.items, false);
+                    setOptionsCellType(node.elf.tree.items);
+                    //项目指引初始焦点
+                    elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
+                    refreshInsertRation();
+                });
+            });
+        }
+        else{
+            renderSheetFunc(elfSheet, function () {
+                node.elf.controller.showTreeData();
+                setOptionsCellType(node.elf.tree.items);
+                //项目指引初始焦点
+                elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
+                refreshInsertRation();
+            });
+        }
+    }
+    //获取选项的深度
+    //@param {Object}opt {Array}options(当前清单所有选项) @return {Array}
+    function getOptionDepth(opt, options) {
+        let parent = _.find(options, {ID: opt.ParentID});
+        let depth = 0;
+        while (parent){
+            depth++;
+            parent = _.find(options, {ID: parent.ParentID});
+        }
+        return depth;
+    }
+    //获取施工工序含有的选项(即当前施工工序的子项),获取的顺序按照NextSiblingID排序
+    //@param {Object}process {Array}datas @return {Array}
+    function getOptions(process, datas) {
+        let rst = [];
+        if(!process || !process.ID){
+            return [];
+        }
+        let options = _.filter(datas, function (data) {
+            return data.ParentID == process.ID;
+        });
+        if(options.length === 0){
+            return [];
+        }
+        //根据NextSiblingID排序
+        let IDMapping = {};
+        for(let opt of options){
+            IDMapping[opt.ID] = {self: opt, next: null, pre: null};
+        }
+        for(let opt of options){
+            let next = IDMapping[opt.NextSiblingID] ? IDMapping[opt.NextSiblingID] : null;
+            if(next){
+                next.pre = IDMapping[opt.ID];
+                IDMapping[opt.ID]['next'] = next;
+            }
+        }
+        let first = null,
+            rank = 0;
+        for(let ID in IDMapping){
+            let obj = IDMapping[ID];
+            if(!obj.pre){
+                first = obj;
+            }
+        }
+        while(first){
+            rank++;
+            first.self.rank = rank;
+            rst.push(first.self);
+            first = first.next;
+        }
+
+        return rst;
+    }
+    //设置清单精灵选项单元格
+    //@param {Array}nodes @return {void}
+    function setOptionsCellType(nodes) {
+        let elfSheet = elfItem.workBook.getActiveSheet();
+        for(let node of nodes){
+            if(node.data.optionsData && node.data.optionsData.length > 0){
+                elfSheet.getCell(node.serialNo(), 1).locked(false).cellType(getOptionsCellType());
+            }
+            else {
+                elfSheet.getCell(node.serialNo(), 1).locked(true).cellType(new GC.Spread.Sheets.CellTypes.Base());
+            }
+        }
+    }
+    //递归插入节点:原始项目指引数据奇数层为需要插入的节点,偶数层为下拉选项
+    //@param {Object}node(当前操作的节点) {Object}data(选项) @return {void}
+    function insertNodeByData(node, data) {
+        let elfSheet = elfItem.workBook.getActiveSheet();
+        let sameDepthNodes = node.children;
+        let insertNextSiblingID = -1,
+            insertParentID = node.data.ID;
+        //当前操作节点的选项
+        let nodeOpts = getOptions(node.data, bills.selected.elf.datas);
+        let subOpts = getOptions(data, bills.selected.elf.datas);
+        let dataDepth = getOptionDepth(data, bills.selected.elf.datas);
+        if(subOpts.length >0 && subOpts[0].type !== itemType.ration){
+            if((dataDepth + 1) % 2 === 0){
+                //排序后的数据
+                let dataWithRank = _.find(nodeOpts, {ID: data.ID});
+                //确定插入位置
+                for(let subOpt of subOpts){
+                    for(let subNode of sameDepthNodes){
+                        //同层节点原本选项数据
+                        let subNodeOptData = _.find(bills.selected.elf.datas, {ID: subNode.data.ID});
+                        //同层节点原本父选项数据
+                        let subNodeOptParent = _.find(bills.selected.elf.datas, {ID: subNodeOptData.ParentID});
+                        let subNodeOptParentWithRank = _.find(nodeOpts, {ID: subNodeOptParent.ID});
+                        //父项顺序决定插入位置
+                        if(dataWithRank.rank < subNodeOptParentWithRank.rank){
+                            insertNextSiblingID = subNode.data.ID;
+                            break;
+                        }
+                        //父项顺序相同,根据子项顺序决定插入位置
+                        else if(dataWithRank.rank = subNodeOptParentWithRank.rank){
+                            if(subOpt.rank < subNode.data.rank){
+                                insertNextSiblingID = subNode.data.ID;
+                                break;
+                            }
+                        }
+                    }
+                    let sub2Opts = getOptions(subOpt, bills.selected.elf.datas);
+                    subOpt.options = sub2Opts.length > 0 ? sub2Opts[0].name : '';
+                    let cloneOpt = _.cloneDeep(subOpt);//不改变原本的数据,比如ParentID
+                    cloneOpt.optionChecked = sub2Opts.length > 0 ? [_.cloneDeep(sub2Opts[0])] : [];
+                    cloneOpt.optionsData = sub2Opts.length > 0 ? _.cloneDeep(sub2Opts) : [];
+                    let newNode = node.tree.insertByData(cloneOpt, insertParentID, insertNextSiblingID);
+                    elfSheet.addRows(newNode.serialNo(), 1);
+                    node.tree.selected = newNode;
+                    elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
+                    if(sub2Opts.length > 0 && sub2Opts[0].type !== itemType.ration){
+                        insertNodeByData(newNode, sub2Opts[0]);
+                    }
+                }
+            }
+            else {
+                insertNodeByData(node, subOpts[0]);
+            }
+        }
+    }
+    //获取选项下拉多选单元格
+    //@param {void} @return {void}
+    function getOptionsCellType() {
+        let me = this;
+        let elfSheet= elfItem.workBook.getActiveSheet();
+        function OptionsCellType() {
+            this.isEscKey=false;
+            this.displayText='';
+        }
+        function setOptionsDiv($editor, node, cellRect, cellStyle, top) {
+            if(!node){
+                return '';
+            }
+            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;
+            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>`);
+            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' : ''}>`);
+                $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 {//多选
+
+                    }
+                });
+            }
+            $editor.append($editInput);
+            $editor.append($optDiv);
+        }
+        //选择后处理
+        function doAfterSel(node) {
+            let checkedSels = $('.elf-options').find('input:checked');
+            let checkedNameArr = [],
+                optionChecked= [];
+            for(let checkSel of checkedSels){
+                let opt = _.cloneDeep(_.find(bills.selected.elf.datas, {ID: $(checkSel).val()}));
+                opt.rank = $(checkSel).attr('rank');
+                checkedNameArr.push(opt.name);
+                optionChecked.push(opt);
+            }
+            this.displayText = checkedNameArr.length > 0 ? checkedNameArr.join(';') : '';
+            node.data.options = this.displayText;
+            node.data.optionChecked = optionChecked;
+            //删除节点
+            let deleteNodes = getDeleteNodes(node, optionChecked);
+            for(let dNode of deleteNodes){
+                elfSheet.deleteRows(dNode.serialNo(), dNode.posterityCount() + 1);
+                node.tree.delete(dNode);
+            }
+            //插入节点
+            for(let perCheked of optionChecked){
+                let exist = false;
+                let subOpts = getOptions(perCheked, bills.selected.elf.datas);
+                for(let subNode of node.children){
+                    for(let subOpt of subOpts){
+                        if(subNode.data.ID === subOpt.ID){
+                            exist = true;
+                            break;
+                        }
+                    }
+                }
+                //不重复且不为定额时插入
+                if(!exist && perCheked.type !== itemType.ration){
+                    insertNodeByData(node, perCheked);//这里递归,默认第一个
+                }
+            }
+            TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.tree.items, false);
+            setOptionsCellType(node.tree.items);
+            refreshInsertRation();
+            refreshInsertSingle();
+        }
+        //获取删除节点
+        function getDeleteNodes(node, optionChecked) {
+            let rst = [];
+            for(let subNode of node.children){
+                let exist = false;
+                for(let perChecked of optionChecked){
+                    let subOpts = getOptions(perChecked, bills.selected.elf.datas);
+                    for(let subOpt of subOpts){
+                        if(subNode.data.ID === subOpt.ID){
+                            exist = true;
+                            break;
+                        }
+                    }
+                }
+                if(!exist){
+                    rst.push(subNode);
+                }
+            }
+            return rst;
+        }
+        OptionsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
+
+        OptionsCellType.prototype.createEditorElement = function (context) {
+            let element = document.createElement("div");//这里创建的,会自动销毁
+            return element
+        };
+        OptionsCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
+            if (editorContext) {
+                let $editor = $(editorContext);
+                $editor.css("position", "fixed");
+                $editor.css("background", "white");
+                $editor.css("width", cellRect.width);
+                $editor.attr("gcUIElement", "gcEditingInput");
+                let top = $('.header').height() + $('#zaojiashu').find('.toolsbar').height() + $('#top_div').height();
+                let activeCellTop = $editor.parent().parent().css('top');
+                activeCellTop = parseFloat(activeCellTop.replace('px', ''));
+                let node = bills.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
+                setOptionsDiv($editor, node, cellRect, cellStyle, top + activeCellTop);
+                this.isEscKey = false;
+            }
+        }
+        OptionsCellType.prototype.deactivateEditor = function (editorContext, context) {
+
+        };
+        OptionsCellType.prototype.setEditorValue = function (editor, value, context) {
+            this.displayText = value;
+        };
+        OptionsCellType.prototype.getEditorValue = function (editor, context) {
+            let me = this;
+            let node = bills.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
+            if(this.isEscKey !=true){
+                renderSheetFunc(elfSheet, function () {
+                    doAfterSel.call(me, node);
+                });
+            }
+            this.isEscKey = false;
+            return this.displayText;
+        };
+        OptionsCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
+
+        };
+        OptionsCellType.prototype.isReservedKey = function (e, context) {
+            //cell type handle tab key by itself
+            this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
+            return false;
+        };
+        /* OptionsCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+         if(style.backColor){
+         ctx.fillStyle = style.backColor;
+         ctx.fillRect(x, y, w, h);
+         ctx.save();
+         }
+         //边长
+         const l = 7;
+         let leftPointX = x + w - 15,
+         rightPointX = leftPointX + l,
+         middlePointX = (leftPointX + rightPointX)/2;
+         const cos30 = Math.cos(2*Math.PI * 30 / 360);
+         let hL = l * cos30;
+         let beginY = y + h/2 - hL;
+         ctx.beginPath();
+         ctx.moveTo(leftPointX, beginY);
+         ctx.lineTo(rightPointX, beginY);
+         ctx.lineTo(middlePointX, beginY + hL);
+         ctx.fillStyle = 'black';
+         ctx.fill();
+         ctx.save();
+         };*/
+        // override getHitInfo to allow cell type get mouse messages
+        OptionsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheetArea: context.sheetArea
+            };
+        };
+        return new OptionsCellType();
+    }
+    //获取清单精灵生成的定额数据(跳过重复,不允许重复插入)
+    //@return {Array}
+    function getInsertElfRationData(){
+        let rst = [];
+        if(!bills.selected || !bills.selected.elf){
+            return rst;
+        }
+        let tree = bills.selected.elf.tree;
+        if(!tree){
+            return rst;
+        }
+        let mainSelected = projectObj.project.mainTree.selected;
+        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
+            return c.data && c.data.type === rationType.ration;
+        });
+        //原本清单存在此定额
+        function existTheRation(rationID) {
+            let r = _.find(mainSelRationNodes, function (node) {
+                return node.data && node.data.stdID && node.data.stdID == rationID;
+            });
+            return r;
+        }
+        //造价书当前选中清单下的定额
+        for(let node of tree.items){
+            for(let perChecked of node.data.optionChecked){
+                //选项直接是定额
+                if(perChecked.type === itemType.ration && !existTheRation(perChecked.rationID)){
+                    rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
+                }
+                //选项下子选项是定额
+                else {
+                    let rationOpts = getOptions(perChecked, bills.selected.elf.datas);
+                    for(let ration of rationOpts){
+                        if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
+                            rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
+                        }
+                    }
+                }
+            }
+        }
+        return rst;
+    }
+    //获取清单精灵插入单条定额的数据
+    //@return {Array}
+    function getInsertElfSingleRation() {
+        let rst = [];
+        if (!bills.selected || !bills.selected.elf) {
+            return rst;
+        }
+        let tree = bills.selected.elf.tree;
+        if (!tree) {
+            return rst;
+        }
+        let elfSelected = tree.selected;
+        if (!elfSelected || !elfSelected.data.optionChecked || !elfSelected.data.optionChecked[0]) {
+            return rst;
+        }
+        let mainSelected = projectObj.project.mainTree.selected;
+        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
+            return c.data && c.data.type === rationType.ration;
+        });
+        //原本清单存在此定额
+        function existTheRation(rationID) {
+            let r = _.find(mainSelRationNodes, function (node) {
+                return node.data && node.data.stdID && node.data.stdID == rationID;
+            });
+            return r;
+        }
+        //选中的节点第一个选项时定额选项或第一个选项下的子选项时定额选项
+        let firstOptionChecked = elfSelected.data.optionChecked[0];
+        if (firstOptionChecked.type === itemType.ration && !existTheRation(firstOptionChecked.rationID)) {
+            rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
+        } else {
+            let rationOpts = getOptions(firstOptionChecked, bills.selected.elf.datas);
+            for(let ration of rationOpts){
+                if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
+                    rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
+                    break;
+                }
+            }
+        }
+        return rst;
+    }
+    //插入定额
+    //@return {void}
+    function insertRations(addRationDatas){
+        if(addRationDatas.length > 0){
+            projectObj.project.Ration.addMultiRation(addRationDatas, function () {
+                refreshInsertRation();
+                projectObj.setActiveCell('quantity', true);
+            });
+        }
+    }
+    //更新插入定额按钮有效性
+    function refreshInsertRation(){
+        if (!projectReadOnly) {
+            if (getInsertElfRationData().length > 0) {
+                $('#elfInsertRation').removeClass('disabled');
+            } else {
+                $('#elfInsertRation').addClass('disabled');
+            }
+        }
+    }
+    //更新插入单条按钮有效性
+    function refreshInsertSingle() {
+        if (!projectReadOnly) {
+            if (getInsertElfSingleRation().length > 0) {
+                $('#elfInsertSingle').removeClass('disabled');
+            } else {
+                $('#elfInsertSingle').addClass('disabled');
+            }
+        }
+    }
+    //各监听事件
+    //@return {void}
+    function bindListener(){
+        //插入定额
+        $('#elfInsertRation').click(function () {
+            let addRationDatas =  getInsertElfRationData();
+            insertRations(addRationDatas);
+        });
+        //插入单条
+        $('#elfInsertSingle').click(function () {
+            let addRationDatas = getInsertElfSingleRation();
+            insertRations(addRationDatas);
+        })
+    }
+    return {buildSheet, refreshWorkBook, billsSelElf, setColumnWidthByRate, bindListener};
+})();
+
+$(document).ready(function () {
+    BillsElf.bindListener();
+});

+ 209 - 36
web/building_saas/main/js/views/block_lib.js

@@ -1,4 +1,5 @@
 /**
 /**
+ * 块模板库管理。
  * Created by CSL on 2018-09-19.
  * Created by CSL on 2018-09-19.
  */
  */
 var blockLibObj = {
 var blockLibObj = {
@@ -34,29 +35,73 @@ var blockLibObj = {
         }]
         }]
     },
     },
     mainDatas: [],
     mainDatas: [],
+    billSpread: null,
+    billSheet: null,
+    billSetting: {
+        header: [
+            {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: 160, dataCode: "itemCharacterText", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1, 2, 3, 4]
+        }
+    },
+    rationSpread: null,
+    rationSheet: null,
+    rationSetting: {
+        header: [
+            {headerName: "编码", headerWidth: 45, dataCode: "code", dataType: "String", hAlign: "center"},
+            {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: 90, dataCode: "adjustState", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1, 2, 3, 4, 5, 6]
+        }
+    },
+
     buildSheet: function () {
     buildSheet: function () {
         $.bootstrapLoading.start();
         $.bootstrapLoading.start();
         let me = this;
         let me = this;
         me.mainDatas = [
         me.mainDatas = [
+            {ID: 1, ParentID: -1, NextSiblingID: 2, name: '分类1', type: 1},
             {ID: 2, ParentID: -1, NextSiblingID: 3, name: '分类2', type: 1},
             {ID: 2, ParentID: -1, NextSiblingID: 3, name: '分类2', type: 1},
-            {ID: 3, ParentID: -1, NextSiblingID: -1, name: '分类3', type: 1},
-            {ID: 6, ParentID: 2, NextSiblingID: 7, name: '块1', type: 2},
-            {ID: 7, ParentID: 2, NextSiblingID: -1, name: '块2', type: 2},
-            {ID: 52, ParentID: -1, NextSiblingID: 53, name: '分类52', type: 1},
-            {ID: 55, ParentID: -1, NextSiblingID: -1, name: '分类55', type: 1},
-            {ID: 88, ParentID: 52, NextSiblingID: -1, name: '块88', type: 2}
+            {ID: 3, ParentID: -1, NextSiblingID: 4, name: '分类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}
         ];
         ];
 
 
         if (me.mainSpread) {
         if (me.mainSpread) {
             me.mainSpread.destroy();
             me.mainSpread.destroy();
             me.mainSpread = null;
             me.mainSpread = null;
         };
         };
+
+        if (me.billSpread) {
+            me.billSpread.destroy();
+            me.billSpread = null;
+        };
+
+        if (me.rationSpread) {
+            me.rationSpread.destroy();
+            me.rationSpread = null;
+        };
+
         me.mainSpread = SheetDataHelper.createNewSpread($('#div_block_tree')[0]);
         me.mainSpread = SheetDataHelper.createNewSpread($('#div_block_tree')[0]);
         // me.mainSpread = TREE_SHEET_HELPER.createNewSpread($('#div_block_tree')[0]);
         // me.mainSpread = TREE_SHEET_HELPER.createNewSpread($('#div_block_tree')[0]);
         me.mainSheet = me.mainSpread.getSheet(0);
         me.mainSheet = me.mainSpread.getSheet(0);
         me.mainSheet.name('blockLibSheet');
         me.mainSheet.name('blockLibSheet');
         sheetCommonObj.spreadDefaultStyle(me.mainSpread);
         sheetCommonObj.spreadDefaultStyle(me.mainSpread);
         // me.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onCellDoubleClick);
         // me.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onCellDoubleClick);
+        me.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
 
 
         var showblockTree = function (datas) {
         var showblockTree = function (datas) {
             me.mainTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
             me.mainTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
@@ -65,14 +110,9 @@ var blockLibObj = {
             me.mainTreeController.showTreeData();
             me.mainTreeController.showTreeData();
             me.mainSheet.getRange(-1, 0, -1, 1).cellType(me.getTreeCell(me.mainTree));
             me.mainSheet.getRange(-1, 0, -1, 1).cellType(me.getTreeCell(me.mainTree));
             me.mainTree.selected = me.mainTree.items[0];
             me.mainTree.selected = me.mainTree.items[0];
-/*            me.mainTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
-                rationLibObj.loadSectionRations(node && node.children.length === 0 ? node.getID() : null);
+            me.mainTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
+                blockLibObj.loadDetailDatas(node);
             });
             });
-            if (me.mainTree.firstNode() && me.mainTree.firstNode().length === 0) {
-                rationLibObj.loadSectionRations(me.mainTree.firstNode().getID());
-            } else {
-                rationLibObj.loadSectionRations();
-            };*/
         };
         };
 
 
 /*        CommonAjax.post('/complementaryRation/api/getRationTree', {userId: userID, rationRepId: rationLibID}, function (datas) {
 /*        CommonAjax.post('/complementaryRation/api/getRationTree', {userId: userID, rationRepId: rationLibID}, function (datas) {
@@ -84,8 +124,42 @@ var blockLibObj = {
         });*/
         });*/
 
 
         showblockTree(me.mainDatas);
         showblockTree(me.mainDatas);
+
+        me.billSpread = sheetCommonObj.buildSheet($('#div_block_bill')[0], me.billSetting, 1);
+        me.billSheet = me.billSpread.getSheet(0);
+        sheetCommonObj.spreadDefaultStyle(me.billSpread);
+        me.billSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
+
+        me.rationSpread = sheetCommonObj.buildSheet($('#div_block_ration')[0], me.rationSetting, 1);
+        me.rationSheet = me.rationSpread.getSheet(0);
+        sheetCommonObj.spreadDefaultStyle(me.rationSpread);
+        me.rationSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
+
+        me.loadTreeContextMenu();
+
         $.bootstrapLoading.end();
         $.bootstrapLoading.end();
     },
     },
+    loadDetailDatas: function (node){
+        let me = this;
+        if (node.data.type == 2){
+            let sourceNode = node.data.sourceNode;
+            let rations = sourceNode.children;
+            let rationDatas = [];
+            for (let r of rations){
+                rationDatas.push(r.data);
+            };
+            sheetCommonObj.showData(me.billSheet, me.billSetting, [sourceNode.data]);
+            me.changeBillText(sourceNode.data);
+            let rCount = (rationDatas.length > 0) ? rationDatas.length : 1;
+            me.rationSheet.setRowCount(rCount, GC.Spread.Sheets.SheetArea.viewport);
+            sheetCommonObj.showData(me.rationSheet, me.rationSetting, rationDatas);
+            me.changeRationText(rationDatas);
+        }
+        else{
+            sheetCommonObj.cleanSheet(me.billSheet, me.billSetting, 1);
+            sheetCommonObj.cleanSheet(me.rationSheet, me.rationSetting, 1);
+        }
+    },
     getTreeCell: function (tree) {
     getTreeCell: function (tree) {
         let me = this;
         let me = this;
         let indent = 20, levelIndent = -5, halfBoxLength = 5, halfExpandLength = 3, imgWidth = 14, imgHeight = 14;
         let indent = 20, levelIndent = -5, halfBoxLength = 5, halfExpandLength = 3, imgWidth = 14, imgHeight = 14;
@@ -285,11 +359,10 @@ var blockLibObj = {
         };
         };
         return new TreeCell();
         return new TreeCell();
     },
     },
-    newNode: function (nodeType, nodeName, categoryID){     // 1 分类  2 块文件
+    newNode: function (nodeType, nodeName, categoryID, sourceNode){     // 1 分类(只用前两个参数)  2 块文件
         let tree = blockLibObj.mainTree;
         let tree = blockLibObj.mainTree;
         let pID = -1, nID = -1;
         let pID = -1, nID = -1;
         let select = tree.selected;
         let select = tree.selected;
-        let newNode = null;
         if (nodeType == 1){
         if (nodeType == 1){
             if (!select) {
             if (!select) {
                 nID = -1;
                 nID = -1;
@@ -302,24 +375,15 @@ var blockLibObj = {
             };
             };
         }
         }
         else if (nodeType == 2) {
         else if (nodeType == 2) {
-/*            if (!select) {
-                pID = tree.items[0].getID();
-            }
-            else if (select.data.type == 1){
-                pID = select.getID();
-            }
-            else if (select.data.type == 2){
-                pID = select.getParentID();
-                nID = select.getNextSiblingID();
-            };*/
-
             pID = categoryID;
             pID = categoryID;
             nID = -1;
             nID = -1;
         }
         }
 
 
-        newNode = tree.insert(pID, nID);
+        let newNode = tree.insert(pID, nID);
         newNode.data.type = nodeType;
         newNode.data.type = nodeType;
         newNode.data.name = nodeName;
         newNode.data.name = nodeName;
+        if (nodeType == 2)
+            newNode.data.sourceNode = sourceNode;
         tree.selected = newNode;
         tree.selected = newNode;
 
 
         let sheet = blockLibObj.mainSheet;
         let sheet = blockLibObj.mainSheet;
@@ -337,14 +401,7 @@ var blockLibObj = {
     },
     },
     reName: function (node, newName){
     reName: function (node, newName){
         node.data.name = newName;
         node.data.name = newName;
-        let nodes = blockLibObj.mainTree.items;
-        let idx = -1;
-        for (let i = 0; i < nodes.length; i++) {
-            if (node == nodes[i]){
-                idx = i;
-                break;
-            }
-        }
+        let idx = blockLibObj.mainTree.items.indexOf(node);
         blockLibObj.mainSheet.setValue(idx, 0, newName);
         blockLibObj.mainSheet.setValue(idx, 0, newName);
     },
     },
     getCategories: function () {
     getCategories: function () {
@@ -355,6 +412,123 @@ var blockLibObj = {
             nodes.push(node);
             nodes.push(node);
         };
         };
         return nodes;
         return nodes;
+    },
+    curIsBlock: function () {
+        return this.mainTree.selected.data.type == 2;
+    },
+    curIsCategory: function () {
+        return this.mainTree.selected.data.type == 1;
+    },
+    refreshSpread: function (){
+        if (this.mainSpread)
+            this.mainSpread.refresh();
+        if (this.billSpread)
+            this.billSpread.refresh();
+        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({
+            selector: '#div_block_tree',
+            build: function ($trigger, e) {
+                SheetDataHelper.safeRightClickSelection($trigger, e, me.mainSpread);
+                me.onEnterCell();
+            },
+            items: {
+                "oneToOneClone": {
+                    name: '一对一克隆',
+                    icon: "fa-battery-empty",
+                    disabled: function () {
+
+                    },
+                    visible: function(key, opt){
+                        return me.curIsBlock();
+                    },
+                    callback: function (key, opt) {
+
+                    }
+                },
+                "oneToMoreClone": {
+                    name: '一对多克隆',
+                    icon: "fa-battery-half",
+                    disabled: function () {
+
+                    },
+                    visible: function(key, opt){
+                        return me.curIsBlock();
+                    },
+                    callback: function (key, opt) {
+
+                    }
+                },
+                "moreToMoreClone": {
+                    name: '多对多克隆',
+                    icon: "fa-battery-full",
+                    disabled: function () {
+
+                    },
+                    visible: function(key, opt){
+                        return me.curIsCategory();
+                    },
+                    callback: function (key, opt) {
+
+                    }
+                },
+                "delete": {
+                    name: '删除',
+                    icon: "delete",
+                    disabled: function () {
+
+                    },
+                    visible: function(key, opt){
+                        return true;
+                    },
+                    callback: function (key, opt) {
+
+                    }
+                },
+                "moveBlock": {
+                    name: '移动模板',
+                    icon: "cut",
+                    disabled: function () {
+
+                    },
+                    visible: function(key, opt){
+                        return me.curIsBlock();
+                    },
+                    callback: function (key, opt) {
+
+                    }
+                }
+            }
+        });
+    },
+    onEnterCell: function (sender, args) {
+        let me = blockLibObj;
+        me.mainTree.selected = me.mainTree.items[me.mainSheet.getActiveRowIndex()];
     }
     }
 };
 };
 
 
@@ -377,7 +551,6 @@ $(document).ready(function(){
 
 
     $('#btn_block_reName').on('click', function (){
     $('#btn_block_reName').on('click', function (){
         let select = blockLibObj.mainTree.selected;
         let select = blockLibObj.mainTree.selected;
-        // $('#lbl_block_reName').text(select.data.name);
         $('#input_block_reName').val(select.data.name);
         $('#input_block_reName').val(select.data.name);
     });
     });
 
 

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

@@ -7,7 +7,7 @@ let contentOprObj = {
     currentCache: [],//按照serialNo排序
     currentCache: [],//按照serialNo排序
     setting: {
     setting: {
         header: [
         header: [
-            {headerName:"工作内容", headerWidth: 360, rateWidth:0.93, dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"工作内容", headerWidth: 360, rateWidth:0.93, dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center", formatter: '@'},
             {headerName:"输出", headerWidth: 40, rateWidth: null, dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}
             {headerName:"输出", headerWidth: 40, rateWidth: null, dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}
         ]
         ]
     },
     },
@@ -409,8 +409,8 @@ let characterOprObj = {
     currentCache: [],
     currentCache: [],
     setting: {
     setting: {
         header: [
         header: [
-            {headerName:"项目特征",headerWidth:120, rateWidth:0.9, dataCode:"character", dataType: "String", hAlign: "left", vAlign: "center"},
-            {headerName:"特征值",headerWidth:160,dataCode:"eigenvalue", dataType: "String", cellType: "comboBox", hAlign: "left", vAlign: "center"},
+            {headerName:"项目特征",headerWidth:120, rateWidth:0.9, dataCode:"character", dataType: "String", hAlign: "left", vAlign: "center", formatter: '@'},
+            {headerName:"特征值",headerWidth:160,dataCode:"eigenvalue", dataType: "String", cellType: "comboBox", hAlign: "left", vAlign: "center", formatter: '@'},
             {headerName:"输出",headerWidth:40,dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}
             {headerName:"输出",headerWidth:40,dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}
         ]
         ]
     },
     },

+ 3 - 3
web/building_saas/main/js/views/glj_col.js

@@ -6,7 +6,7 @@ let gljCol = {
         header: [
         header: [
             {headerName: "编码", headerWidth: 130, dataCode: "code", dataType: "String", formatter: "@"},
             {headerName: "编码", headerWidth: 130, dataCode: "code", dataType: "String", formatter: "@"},
             {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
             {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
-            {headerName: "规格型号", headerWidth: 160, dataCode: "specs", dataType: "String", hAlign: "left",cellType:'tipsCell'},
+            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", dataType: "String", hAlign: "left",cellType:'tipsCell'},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center"},
             {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"
             {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"
             {headerName: "调整价", headerWidth: 65, dataCode: "adjustPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"1
             {headerName: "调整价", headerWidth: 65, dataCode: "adjustPrice", dataType: "Number", hAlign: "right"},//, decimalField: "glj.unitPrice"1
@@ -22,7 +22,7 @@ let gljCol = {
             rowHeaderWidth:25
             rowHeaderWidth:25
         },
         },
         getStyle:function (data) {
         getStyle:function (data) {
-            if(data.type == gljType.MAIN_MATERIAL){//是主材的话字体蓝色显示
+            if(data&&data.type == gljType.MAIN_MATERIAL){//是主材的话字体蓝色显示
                 return {foreColor:"#4D7BFF"};
                 return {foreColor:"#4D7BFF"};
             }
             }
             return null;
             return null;
@@ -35,7 +35,7 @@ let gljCol = {
         header: [
         header: [
             {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
             {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
             {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
             {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
-            {headerName: "规格型号", headerWidth: 160, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
+            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
             {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
             {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
             {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
             {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
             {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"

+ 13 - 3
web/building_saas/main/js/views/glj_view.js

@@ -17,6 +17,8 @@ var gljOprObj = {
     selectedGLJClass: null,
     selectedGLJClass: null,
     parentNodeIds: {},
     parentNodeIds: {},
     activeTab: '#linkGLJ',
     activeTab: '#linkGLJ',
+    rationTab:'#linkGLJ',
+    billsTab:'#linkJSCX',
     setting: {},
     setting: {},
     detailSetting: {
     detailSetting: {
         header: [
         header: [
@@ -155,7 +157,7 @@ var gljOprObj = {
         function enterKeyAction(spd,sheeName) {
         function enterKeyAction(spd,sheeName) {
             let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
             let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
             let fieldID = me.setting.header[orgCol].dataCode;
             let fieldID = me.setting.header[orgCol].dataCode;
-            if(me.setting.navigationRightCol.indexOf(fieldID) != -1){
+            if(sheeName=="ration_glj" && me.setting.navigationRightCol.indexOf(fieldID) != -1){
                 if(sheet.isEditing()) sheet.endEdit();
                 if(sheet.isEditing()) sheet.endEdit();
                 GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
                 GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
             }else {
             }else {
@@ -518,6 +520,7 @@ var gljOprObj = {
                         MaterialController.showReplaceDiv(node);
                         MaterialController.showReplaceDiv(node);
                     }
                     }
                     if($('#linkAZZJF').hasClass('active')) installationFeeObj.showRationInstallationData(node);
                     if($('#linkAZZJF').hasClass('active')) installationFeeObj.showRationInstallationData(node);
+                    if($('#linkMBZM').hasClass('active')) mbzm_obj.showMBZMData(node);
                 }
                 }
                 isShow = true;
                 isShow = true;
             }
             }
@@ -608,8 +611,6 @@ var gljOprObj = {
         let ration_glj = this.sheetData[selected.row];
         let ration_glj = this.sheetData[selected.row];
         return ration_glj;
         return ration_glj;
     },
     },
-
-
     getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
     getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
         let codeMap = {};
         let codeMap = {};
         let priceMap = projectObj.project.projectGLJ.datas.unitPriceMap;
         let priceMap = projectObj.project.projectGLJ.datas.unitPriceMap;
@@ -758,6 +759,7 @@ var gljOprObj = {
         return data;
         return data;
 
 
     },
     },
+
     getBasePrice:function (treeNode) {//造价书中的工料机修改的节点要用到
     getBasePrice:function (treeNode) {//造价书中的工料机修改的节点要用到
         let proGLJ =  projectObj.project.projectGLJ;
         let proGLJ =  projectObj.project.projectGLJ;
         let glj =_.find(proGLJ.datas.gljList, {'id': treeNode.data.projectGLJID});
         let glj =_.find(proGLJ.datas.gljList, {'id': treeNode.data.projectGLJID});
@@ -1397,6 +1399,14 @@ var gljOprObj = {
     },
     },
     isExtraType:function (type) {
     isExtraType:function (type) {
         return _.includes(gljUtil.extraType,type)
         return _.includes(gljUtil.extraType,type)
+    },
+    setNodeShowTab:function () {
+        let node = projectObj.project.mainTree.selected;
+        if(node && node.sourceType==ModuleNames.ration){
+            gljOprObj.rationTab = gljOprObj.activeTab;
+        }else {
+            gljOprObj.billsTab = gljOprObj.activeTab;
+        }
     }
     }
 }
 }
 
 

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

@@ -32,7 +32,7 @@ const importBills = (function(){
         serialNo: ['序号'],
         serialNo: ['序号'],
         code: ['编码', '项目编码'],
         code: ['编码', '项目编码'],
         name: ['名称', '项目名称'],
         name: ['名称', '项目名称'],
-        itemCharacterText: ['特征', '项目特征'],
+        itemCharacterText: ['特征', '项目特征', '项目特征描述'],
         unit: ['单位', '计量单位'],
         unit: ['单位', '计量单位'],
         quantity: ['工程量', '项目工程量'],
         quantity: ['工程量', '项目工程量'],
         money: ['金额'],
         money: ['金额'],
@@ -166,7 +166,8 @@ const importBills = (function(){
                 colMapping.name = colIdx;
                 colMapping.name = colIdx;
             }
             }
             //项目特征
             //项目特征
-            else if(colMapping.itemCharacterText === undefined && (_deESC(cellData) === colText.itemCharacterText[0] || _deESC(cellData) === colText.itemCharacterText[1])){
+            else if(colMapping.itemCharacterText === undefined && (_deESC(cellData) === colText.itemCharacterText[0] || _deESC(cellData) === colText.itemCharacterText[1]
+                ||  _deESC(cellData) === colText.itemCharacterText[2])){
                 colMapping.itemCharacterText = colIdx;
                 colMapping.itemCharacterText = colIdx;
             }
             }
             //单位
             //单位

+ 118 - 19
web/building_saas/main/js/views/locate_view.js

@@ -2,37 +2,136 @@
  * Created by zhang on 2018/11/16.
  * Created by zhang on 2018/11/16.
  */
  */
 let locateObject={
 let locateObject={
+    bills_setting:{
+        header:[
+            {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
+            {headerName: "项目名称", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right"},
+            {headerName: "综合单价", headerWidth: 65, dataCode: "unitPrice", dataType: "Number", hAlign: "right"},
+            {headerName: "综合合价", headerWidth: 65, dataCode: "totalPrice", dataType: "Number", hAlign: "right"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3,4,5],
+            colHeaderHeight:30
+        }
+    },
+    ration_setting:{
+        header:[
+            {headerName: "定额编码", headerWidth: 100, dataCode: "code", dataType: "String"},
+            {headerName: "定额名称", headerWidth: 180, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number", hAlign: "right",decimalField: "ration.quantity"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3],
+            colHeaderHeight:30
+        }
+    },
+    ration_glj_setting:{
+        header:[
+            {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
+            {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3,4],
+            colHeaderHeight:30
+        }
+    },
+    initMainSpread:function(){
+        if(!this.mainSpread){
+            this.mainSpread = SheetDataHelper.createNewSpread($("#locate_result")[0],3);
+            sheetCommonObj.spreadDefaultStyle(this.mainSpread);
+            this.initMainSheet();
+        }else {
+            this.mainSpread.refresh();
+        }
+    },
+    initMainSheet:function () {
+       // this.mainSheet = this.mainSpread .getSheet(0);
+        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
+       //初始化清单表格
+        sheetCommonObj.initSheet(this.mainSpread .getSheet(0),this.bills_setting);
+        this.mainSpread .getSheet(0).setRowCount(0);
+        //初始化定额表格
+        sheetCommonObj.initSheet(this.mainSpread .getSheet(1),this.ration_setting);
+        this.mainSpread .getSheet(1).setRowCount(0);
 
 
-
+        //初始化人材机表格
+        sheetCommonObj.initSheet(this.mainSpread.getSheet(2),this.ration_glj_setting);
+        this.mainSpread .getSheet(2).setRowCount(0);
+    },
+    initSubSpread:function () {
+        if(!this.subSpread){
+            this.subSpread = SheetDataHelper.createNewSpread($("#locate_sub")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.subSpread);
+            this.initSubSheet();
+        }else {
+            this.subSpread.refresh();
+        }
+    },
+    initSubSheet:function () {
+        this.subSheet = this.subSpread .getSheet(0);
+        sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
+        this.subSheet.setRowCount(0);
+        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
+        this.subSheet.name('locate_sub');
+    },
+    showMainData:function () {
+        let datas = [];
+        //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
+        this.mainSpread.getActiveSheet().setRowCount(datas.length);
+    },
     init:function () {
     init:function () {
-        let tab_content = $('#locate').parent();
-        $('#locate_result').height(tab_content.height()*0.6);
-        $('#locate_sub').height(tab_content.height()*0.4);
-
+        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.initMainSpread();
+            me.initSubSpread();
+            me.showMainData();
+        };
+        options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
 
 
     },
     },
+    findRecodes:function () {
 
 
+    },
     onshow:function () {
     onshow:function () {
-
         locateObject.init();
         locateObject.init();
-        console.log('#locate is now visible');
-        console.log($("#locate").is(':visible'))
     }
     }
-
 }
 }
 
 
 
 
+$("#locate_btn").click(function () {
+    locateObject.findRecodes();
+});
 
 
-
-/*
-$("input[name='install_setting_radios']").each(function(){
+$("input[name='content_type']").each(function(){
     $(this).click(function(){
     $(this).click(function(){
-        var settingVal = $(this).val();
-        let installSetting = projectInfoObj.projectInfo.property.installSetting;
-        if(installSetting==settingVal){
-            return;
+        let optins = $(this).val();
+        switch (optins){
+            case "bills":
+                locateObject.mainSpread.setActiveSheetIndex(0);
+                break;
+            case "ration":
+                locateObject.mainSpread.setActiveSheetIndex(1);
+                break;
+            case "ration_glj":
+                locateObject.mainSpread.setActiveSheetIndex(2);
+                break;
         }
         }
-        projectObj.project.installation_fee.updateInstallSetting(settingVal);
-        installationFeeObj.cleanPositionIfNeed(settingVal);
+        locateObject.init();
     });
     });
-});*/
+});

+ 2 - 2
web/building_saas/main/js/views/main_tree_col.js

@@ -434,14 +434,14 @@ let MainTreeCol = {
                     return '0.######';
                     return '0.######';
                 default:
                 default:
                     return '0';
                     return '0';
-            }
-            ;
+            };
         }
         }
     },
     },
     getRationUnitTips:function (node) {
     getRationUnitTips:function (node) {
         let tips="";
         let tips="";
         let ration_glj = projectObj.project.ration_glj;
         let ration_glj = projectObj.project.ration_glj;
         let gljList = gljOprObj.filterGljByRation(node.data, ration_glj.datas);
         let gljList = gljOprObj.filterGljByRation(node.data, ration_glj.datas);
+        gljList = sortRationGLJ(gljList);
         for(let glj of gljList){
         for(let glj of gljList){
             tips += `${glj.code} ${glj.name}${glj.specs ? '&nbsp;&nbsp;&nbsp;' + glj.specs : ''}&nbsp;&nbsp&nbsp;${glj.unit}&nbsp;&nbsp;&nbsp;${glj.quantity}<br>`;
             tips += `${glj.code} ${glj.name}${glj.specs ? '&nbsp;&nbsp;&nbsp;' + glj.specs : ''}&nbsp;&nbsp&nbsp;${glj.unit}&nbsp;&nbsp;&nbsp;${glj.quantity}<br>`;
         }
         }

+ 69 - 0
web/building_saas/main/js/views/mbzm_view.js

@@ -0,0 +1,69 @@
+/**
+ * Created by zhang on 2018/11/26.
+ */
+
+let mbzm_obj={
+    spread:null,
+    datas:[],
+    setting:{
+        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"},
+            {headerName: "单位", headerWidth: 45, dataCode: "unit", dataType: "String", hAlign: "center"},
+            {headerName: "工程量", headerWidth: 65, dataCode: "quantity", dataType: "Number",decimalField: "ration.quantity"},
+            {headerName: "关联类别", headerWidth: 100, dataCode: "type", dataType: "String"},
+            {headerName: "清单位置", headerWidth: 200, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton',getText:'forPosition'},
+        ],
+        view: {
+            lockColumns:["code","name","unit","type","fxID"],
+            rowHeaderWidth:25
+        },
+        getText:{
+            forPosition:function (item) {
+                return ""
+            }
+        }
+    },
+    //当点击应用的时候才保存数据
+    initSpread:function () {
+        this.spread = SheetDataHelper.createNewSpread($("#mbzmSpread")[0]);
+        sheetCommonObj.spreadDefaultStyle(this.spread);
+        this.sheet = this.spread.getSheet(0);
+        sheetCommonObj.initSheet(this.sheet, this.setting);
+    },
+    refresh:function () {
+        let total = $('#mbzmSpread').parent().height();
+        let b_height = $('#mbzmSpread').prev('.col-12').height();
+        $('#mbzmSpread').css('height',total- b_height);
+        this.spread?this.spread.refresh():this.initSpread();
+    },
+    showMBZMData:function(node){
+        let selected = node?node:projectObj.project.mainTree.selected;
+        let datas = [];
+        $("#createLocation").val(1);//初始化
+        if(selected&&selected.sourceType == "ration"){
+            let ration = selected.data;
+            let  template = projectObj.project.ration_template.getTemplateByRationID(ration.ID);
+            if(template) {
+                $("#createLocation").val(template.createLocation);
+                let pcol = _.findIndex(this.setting.header,{dataCode:"position"});
+                this.setting.header[pcol].visible = template.createLocation == 3?false:true;
+                datas = _.cloneDeep(template.templateList);
+            }
+        }
+        this.datas = datas;
+        sheetCommonObj.showData(this.sheet, this.setting,this.datas);
+        this.sheet.setRowCount(this.datas.length);
+    }
+};
+
+$('#createLocation').change(function(){
+    let me = mbzm_obj;
+    let pcol = _.findIndex(me.setting.header,{dataCode:"position"});
+    me.setting.header[pcol].visible = template.createLocation == 3?false:true;
+
+    $(this).val();
+
+    mbzm_obj.showMBZMData();
+});

+ 18 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -928,6 +928,24 @@ projectGljObject={
         supplyQuantity = parseFloat(supplyQuantity);
         supplyQuantity = parseFloat(supplyQuantity);
         return supplyQuantity;
         return supplyQuantity;
     },
     },
+    getSupplyQuantityByGlj:function (glj) {
+        //{"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
+        let supply_quantity = glj.supply_quantity;
+        switch (glj.supply){
+            case 0:
+                supply_quantity = 0;
+                break;
+            case 1:
+                break;
+            case 2:
+                supply_quantity = glj.quantity;
+                break;
+            case 3:
+                supply_quantity = 0;
+                break;
+        }
+        return supply_quantity
+    },
     checkData : function(col,setting, value) {
     checkData : function(col,setting, value) {
         let result = true;
         let result = true;
         let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
         let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;

+ 2 - 2
web/building_saas/main/js/views/project_info.js

@@ -32,9 +32,9 @@ var projectInfoObj = {
                 if(!data.engineeringInfo.billsGuidance_lib || data.engineeringInfo.billsGuidance_lib.length === 0){
                 if(!data.engineeringInfo.billsGuidance_lib || data.engineeringInfo.billsGuidance_lib.length === 0){
                     $('#stdBillsGuidanceTab').addClass('disabled');
                     $('#stdBillsGuidanceTab').addClass('disabled');
                 }
                 }
-                else {
+              /*  else {
                     $('#stdBillsGuidanceTab').text(data.engineeringInfo.billsGuidance_lib[0].type === 1 ? '清单指引' : '清单精灵');
                     $('#stdBillsGuidanceTab').text(data.engineeringInfo.billsGuidance_lib[0].type === 1 ? '清单指引' : '清单精灵');
-                }
+                }*/
 
 
                 //init decimal
                 //init decimal
                 setDecimal(decimalObj, data.property.decimal);
                 setDecimal(decimalObj, data.property.decimal);

+ 37 - 16
web/building_saas/main/js/views/project_view.js

@@ -183,6 +183,7 @@ var projectObj = {
     },
     },
     checkFormulaValidField: function (editingText, colSetting) {
     checkFormulaValidField: function (editingText, colSetting) {
         let value = Number(editingText);
         let value = Number(editingText);
+        if(isNaN(value)) return value;
         if (!value) {
         if (!value) {
             try {
             try {
                 let exp = new Expression('');
                 let exp = new Expression('');
@@ -976,7 +977,6 @@ var projectObj = {
                 if(!projectReadOnly){
                 if(!projectReadOnly){
                     that.loadMainSpreadContextMenu();
                     that.loadMainSpreadContextMenu();
                 }
                 }
-                that.loadFocusLocation();
                 socketObject.connect();//连接socket服务器
                 socketObject.connect();//连接socket服务器
                 let endTime = +new Date();
                 let endTime = +new Date();
                 console.log(`其它时间——${endTime - endShowTime}`);
                 console.log(`其它时间——${endTime - endShowTime}`);
@@ -984,6 +984,7 @@ var projectObj = {
                 console.log(`时间——${endTime - startTime}`);
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
                 autoFlashHeight();
                 autoFlashHeight();
+                that.loadFocusLocation();
                 projectObj.refreshMainSpread();
                 projectObj.refreshMainSpread();
                 //定位到会话中的选项
                 //定位到会话中的选项
                 let mainTabFocus = sessionStorage.getItem('mainTab') ? sessionStorage.getItem('mainTab') : '#tab_zaojiashu';
                 let mainTabFocus = sessionStorage.getItem('mainTab') ? sessionStorage.getItem('mainTab') : '#tab_zaojiashu';
@@ -1507,18 +1508,11 @@ var projectObj = {
                         return selected.sourceType != ModuleNames.bills;
                         return selected.sourceType != ModuleNames.bills;
                     },
                     },
                     callback:function(){
                     callback:function(){
-                        let selected = project.mainTree.selected;
-                        if (selected.data.name == undefined || selected.data.name == ''){
-                            hintBox.infoBox('系统提示','清单名称为空,无法生成块模板文件!', 1);
-                            return false;
-                        }
-                        else{
-                            if (!$("#kmbk").is(":visible")){
-                                $('#blockLibTab').click()
-                            };
+                        if (!$("#kmbk").is(":visible")){
+                            $('#blockLibTab').click()
+                        };
 
 
-                            $("#zujiamb").modal({show: true});
-                        }
+                        $("#zujiamb").modal({show: true});
                     },
                     },
                     visible: function(key, opt){
                     visible: function(key, opt){
                         return G_SHOW_BLOCK_LIB;
                         return G_SHOW_BLOCK_LIB;
@@ -2897,11 +2891,35 @@ $(function () {
 
 
     $("#btn_block_createBlocks").click(function () {
     $("#btn_block_createBlocks").click(function () {
         if ($("#select_block_category")[0].options.length < 1) return;
         if ($("#select_block_category")[0].options.length < 1) return;
-        let selected = projectObj.project.mainTree.selected;
-        let name = selected.data.code + ' ' + selected.data.name + ' ' + selected.data.unit;
-        name = name.replace(/^\s+|\s+$/g, "");    // 只去两头空格
         let cID = $("#select_block_category").val();
         let cID = $("#select_block_category").val();
-        blockLibObj.newNode(2, name, cID);
+        let selected = projectObj.project.mainTree.selected;
+
+        function createBlocks(aNode, categoryID){
+            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, "");    // 只去两头空格
+                blockLibObj.newNode(2, name, categoryID, node);
+            };
+
+            function createRecursion(node){
+                if (!node) return;
+
+                if (calcTools.isLeafBill(node)) createBlock(node);
+
+                if (node.firstChild()) createRecursion(node.firstChild());
+                if (node.nextSibling) createRecursion(node.nextSibling);
+            };
+
+            if (calcTools.isLeafBill(aNode))
+                createBlock(aNode)
+            else
+                createRecursion(aNode.firstChild());
+        };
+
+        createBlocks(selected, cID);
+        blockLibObj.loadDetailDatas(blockLibObj.mainTree.selected);
+        $("#zujiamb").modal("hide");
     });
     });
 
 
 
 
@@ -2945,6 +2963,9 @@ function disableTools(){
     $('#property_default').addClass('disabled');
     $('#property_default').addClass('disabled');
     //项目属性确定
     //项目属性确定
     $('#property_ok').addClass('disabled');
     $('#property_ok').addClass('disabled');
+    //清单精灵
+    $('#elfInsertRation').addClass('disabled');
+    $('#elfInsertSingle').addClass('disabled');
     //特征及内容
     //特征及内容
     $('#add-rule').find('select').prop('disabled', 'disabled');
     $('#add-rule').find('select').prop('disabled', 'disabled');
     $('#use-to-current').addClass('disabled');
     $('#use-to-current').addClass('disabled');

+ 6 - 1
web/building_saas/main/js/views/quantity_edit_view.js

@@ -220,7 +220,12 @@ let quantityEditObj = {
             evalString = replaceAll("QDL","("+bQuantity+")",evalString);
             evalString = replaceAll("QDL","("+bQuantity+")",evalString);
         }
         }
         try {
         try {
-            let value = eval(evalString);
+            let value = undefined;
+            if(evalString&&evalString!=""){
+                let exp = new Expression('');
+                exp.Expression(evalString);
+                value = Number(exp.Evaluate());
+            }
             return value;
             return value;
         }catch (error){
         }catch (error){
             alert("输入的表达式有误,请重新输入!");
             alert("输入的表达式有误,请重新输入!");

+ 25 - 26
web/building_saas/main/js/views/side_tools.js

@@ -6,6 +6,7 @@ $(window).resize(function() {
     billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
     billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
     billsGuidance.refreshWorkBook();
     billsGuidance.refreshWorkBook();
     rationLibObj.refreshSpread();
     rationLibObj.refreshSpread();
+    BillsElf.setColumnWidthByRate();
 });
 });
 //造价书与清单定额库左右拖动
 //造价书与清单定额库左右拖动
 let sideResizeEles = {};
 let sideResizeEles = {};
@@ -19,7 +20,9 @@ sideResizeEles.farSpread = $('.main-side');
 sideResizeEles.nav = null;
 sideResizeEles.nav = null;
 slideResize(sideResizeEles, {min: 250, max: $('#zaojiashu').width()-260}, 'width', function(){
 slideResize(sideResizeEles, {min: 250, max: $('#zaojiashu').width()-260}, 'width', function(){
     adaptiveTzjnrWidth();
     adaptiveTzjnrWidth();
+    MaterialController.showReplaceDiv();
     pageCCOprObj.resizeWidth();
     pageCCOprObj.resizeWidth();
+    BillsElf.setColumnWidthByRate();
     projectObj.refreshMainSpread();
     projectObj.refreshMainSpread();
     refreshSubSpread();
     refreshSubSpread();
     if(sideResizeEles.id === 'stdBillsGuidanceTab'){
     if(sideResizeEles.id === 'stdBillsGuidanceTab'){
@@ -30,13 +33,16 @@ slideResize(sideResizeEles, {min: 250, max: $('#zaojiashu').width()-260}, 'width
         sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 40, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
         sheetCommonObj.setColumnWidthByRate($('#stdRationChapter').width() - 40, rationLibObj.rationChapterSpread, rationLibObj.rationChapterTreeSetting.cols);
         rationLibObj.refreshSpread();
         rationLibObj.refreshSpread();
     }
     }
+    else if(sideResizeEles.id === 'blockLibTab'){
+        blockLibObj.refreshSpread();
+    }
     else{
     else{
         billsLibObj.refreshBillsSpread();
         billsLibObj.refreshBillsSpread();
         billsLibObj.refreshBillsRelaSpread();
         billsLibObj.refreshBillsRelaSpread();
     }
     }
 });
 });
 
 
-//清单指引上下拖动
+/*//清单指引上下拖动
 let billsGuidanceLibResizeEles = {};
 let billsGuidanceLibResizeEles = {};
 billsGuidanceLibResizeEles.id = '#zy';
 billsGuidanceLibResizeEles.id = '#zy';
 billsGuidanceLibResizeEles.resize = $('#zyResize');
 billsGuidanceLibResizeEles.resize = $('#zyResize');
@@ -47,7 +53,7 @@ billsGuidanceLibResizeEles.farSpread = $('#billsGuidance_items');
 billsGuidanceLibResizeEles.nav = null;
 billsGuidanceLibResizeEles.nav = null;
 slideResize(billsGuidanceLibResizeEles, {min: 147, max: 680}, 'height', function() {
 slideResize(billsGuidanceLibResizeEles, {min: 147, max: 680}, 'height', function() {
     billsGuidance.refreshWorkBook();
     billsGuidance.refreshWorkBook();
-});
+});*/
 
 
 //定额库上下拖动
 //定额库上下拖动
 let rationLibResizeEles = {};
 let rationLibResizeEles = {};
@@ -76,6 +82,7 @@ slideResize(billsLibResizeEles, {min: 147, max: 680}, 'height', function() {
     billsLibObj.refreshBillsRelaSpread();
     billsLibObj.refreshBillsRelaSpread();
 });
 });
 
 
+// 块模板库上下拖动
 let blockLibResizeEles = {};
 let blockLibResizeEles = {};
 blockLibResizeEles.id = '#kmbk';
 blockLibResizeEles.id = '#kmbk';
 blockLibResizeEles.resize = $('#kmbkResize');
 blockLibResizeEles.resize = $('#kmbkResize');
@@ -85,7 +92,7 @@ blockLibResizeEles.farElement = $('#kmbk').find('.bottom-content');
 blockLibResizeEles.farSpread = $('#div_block_detail');
 blockLibResizeEles.farSpread = $('#div_block_detail');
 blockLibResizeEles.nav = null;
 blockLibResizeEles.nav = null;
 slideResize(blockLibResizeEles, {min: 147, max: 680}, 'height', function() {
 slideResize(blockLibResizeEles, {min: 147, max: 680}, 'height', function() {
-    billsGuidance.refreshWorkBook();
+    blockLibObj.refreshSpread();
 });
 });
 
 
 
 
@@ -93,27 +100,16 @@ var sideToolsObj = {
     showSideTools: function (tabPanel, show, id) {
     showSideTools: function (tabPanel, show, id) {
         sideResizeEles.id = id;
         sideResizeEles.id = id;
         if (show) {
         if (show) {
-            if(id === 'stdBillsGuidanceTab'){
-                //billsGuidance.refreshInsertRation();
-                sideResizeEles.nearElement.css('width', '66.666667%');
-                sideResizeEles.farElement.css('width', '33.333333%');
-            }
-            else {
-                sideResizeEles.nearElement.css('width', '66.666667%');
-                sideResizeEles.farElement.css('width', '33.333333%');
-            }
+            sideResizeEles.nearElement.css('width', '66.666667%');
+            sideResizeEles.farElement.css('width', '33.333333%');
             $('.main-side .tab-pane').hide();
             $('.main-side .tab-pane').hide();
             id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
             id === 'locateTab'?tabPanel.show(locateObject.onshow):tabPanel.show();//locateTab要等div显示后才执行刷新操作
             loadSize(sideResizeEles, 'width', function(){
             loadSize(sideResizeEles, 'width', function(){
-                if(id === 'stdBillsGuidanceTab'){//清单指引
-                    loadSize(billsGuidanceLibResizeEles, 'height', function(){
-                    });
-                }
-                else if(id === 'stdRationTab'){//定额库
+                if(id === 'stdRationTab'){//定额库
                     loadSize(rationLibResizeEles, 'height', function(){
                     loadSize(rationLibResizeEles, 'height', function(){
                     });
                     });
                 }
                 }
-                else if(id === 'blockLibTab'){//定额
+                else if(id === 'blockLibTab'){//块模板库
                     loadSize(blockLibResizeEles, 'height', function(){
                     loadSize(blockLibResizeEles, 'height', function(){
                     });
                     });
                 }else if(id == "locateTab"){
                 }else if(id == "locateTab"){
@@ -124,7 +120,6 @@ var sideToolsObj = {
                     });
                     });
                 }
                 }
             });
             });
-
         } else {
         } else {
             sideResizeEles.nearElement.css('width', '100%');
             sideResizeEles.nearElement.css('width', '100%');
             sideResizeEles.farElement.css('width', '0%');
             sideResizeEles.farElement.css('width', '0%');
@@ -132,27 +127,31 @@ var sideToolsObj = {
         }
         }
         adaptiveTzjnrWidth();
         adaptiveTzjnrWidth();
         autoFlashHeight();
         autoFlashHeight();
+        MaterialController.showReplaceDiv();
         pageCCOprObj.resizeWidth();
         pageCCOprObj.resizeWidth();
         billsGuidance.refreshWorkBook();
         billsGuidance.refreshWorkBook();
         billsLibObj.refreshBillsSpread();
         billsLibObj.refreshBillsSpread();
+        BillsElf.setColumnWidthByRate();
         refreshSubSpread();
         refreshSubSpread();
         billsLibObj.refreshBillsRelaSpread();
         billsLibObj.refreshBillsRelaSpread();
-        rationLibObj.refreshSpread();;//subSpread、jobSpread、itemSpread显示问题
+        rationLibObj.refreshSpread();//subSpread、jobSpread、itemSpread显示问题
     }
     }
 };
 };
 
 
-$('.side-tabs ul li a').bind('click', function () {
+
+$('.right-nav-link').bind('click', function () {//$('.side-tabs ul li a').bind   2018-11-23  使用更多标签,所以不能这样绑定事件了
     var tab = $(this), tabPanel = $(tab.attr('relaPanel'));
     var tab = $(this), tabPanel = $(tab.attr('relaPanel'));
     if(tab.hasClass('disabled')){
     if(tab.hasClass('disabled')){
         return;
         return;
     }
     }
-    if (!tab.hasClass('active')) {
+    let setActiveTab = tab.hasClass("dropdown-item")?tab.parent().prev('.nav-link'):tab;//如果是点击了更多下拉菜单的子项,则需设置成active 的tab是“更多”
+    if (!(setActiveTab.hasClass('active')&&tabPanel.is(":visible"))) {
         $('.side-tabs ul li a').removeClass('active');
         $('.side-tabs ul li a').removeClass('active');
-        tab.addClass('active');
-        sideToolsObj.showSideTools(tabPanel, tab.hasClass('active'), tab.attr('id'));
+        setActiveTab.addClass('active');
+        sideToolsObj.showSideTools(tabPanel, true, tab.attr('id'));
     } else {
     } else {
-        tab.removeClass('active');
-        sideToolsObj.showSideTools(tabPanel, tab.hasClass('active'), tab.attr('id'));
+        setActiveTab.removeClass('active');
+        sideToolsObj.showSideTools(tabPanel, false, tab.attr('id'));
     }
     }
     projectObj.refreshMainSpread();
     projectObj.refreshMainSpread();
 });
 });

+ 1 - 588
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -10,14 +10,11 @@
 
 
 //清单指引/精灵获取完清单数据后的回调函数
 //清单指引/精灵获取完清单数据后的回调函数
 let doAfterLoadGuidance = null;
 let doAfterLoadGuidance = null;
-//选项单选多选状态(按住alt为多选) 单选:0 多选:1
-let billsGuidanceSelMode = 0;
 
 
 const billsGuidance = (function () {
 const billsGuidance = (function () {
     let currentLib = null;
     let currentLib = null;
     //库类型
     //库类型
     const libType = {'guidance': 1, 'elf': 2}; //清单指引、清单精灵
     const libType = {'guidance': 1, 'elf': 2}; //清单指引、清单精灵
-    const libTypeText = {1: '清单指引', 2: '清单精灵'};
     const libSel = $('#stdBillsGuidanceLibSelect');
     const libSel = $('#stdBillsGuidanceLibSelect');
     //工作内容
     //工作内容
     let stdBillsJobData = [];
     let stdBillsJobData = [];
@@ -100,9 +97,6 @@ const billsGuidance = (function () {
         ],
         ],
         rowHeaderWidth:25,
         rowHeaderWidth:25,
         events: {
         events: {
-            SelectionChanging: function (sender, info) {
-                billsInitSel(info.newSelections[0].row);
-            },
             CellDoubleClick: function (sender, args) {
             CellDoubleClick: function (sender, args) {
                 if(!bills.tree){
                 if(!bills.tree){
                     return;
                     return;
@@ -536,418 +530,6 @@ const billsGuidance = (function () {
             }
             }
         });
         });
     }
     }
-    //清单表焦点控制
-    //@param {Number}row @return {void}
-    function billsInitSel(row){
-        if(currentLib.type && currentLib.type === libType.elf){
-            billsSelElf(row);
-        }else {
-            billsSelGuidance(row);
-        }
-    }
-    //清单焦点变换-清单指引操作
-    //@param {Number}row @return {void}
-    function billsSelGuidance(row){
-        let guideSheet = guideItem.workBook.getActiveSheet();
-        cleanData(guideSheet, guideItem.headers, -1);
-        if(!bills.tree){
-            return;
-        }
-        let node = bills.tree.items[row];
-        if(!node){
-            return;
-        }
-        bills.tree.selected = node;
-        refreshInsertRation();
-        if(!node.guidance.tree){
-            CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
-                initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
-                setItemCellType(node.guidance.tree.items);
-                //项目指引初始焦点
-                guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
-            });
-        }
-        else{
-            node.guidance.controller.showTreeData();
-            setItemCellType(node.guidance.tree.items);
-            //项目指引初始焦点
-            guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
-        }
-    }
-    //清单焦点变换-清单精灵操作
-    //@param {Number}row @return {void}
-    function billsSelElf(row) {
-        let elfSheet = elfItem.workBook.getActiveSheet();
-        cleanData(elfSheet, elfItem.headers, -1);
-        if(!bills.tree){
-            return;
-        }
-        let node = bills.tree.items[row];
-        if(!node){
-            return;
-        }
-        bills.tree.selected = node;
-        if(!node.elf.tree){
-            CommonAjax.post('/billsGuidance/api/getItemsByBills', {guidanceLibID: libSel.val(), billsID: node.getID()}, function (rstData) {
-                //定额数据删除编号信息
-                for(let rData of rstData){
-                    if(rData.type === itemType.ration){
-                        let nameArr = rData.name.split(' ');
-                        if(nameArr.length > 0){
-                            nameArr.splice(0, 1);
-                            rData.name = nameArr.join(' ');
-                        }
-                    }
-                }
-                node.elf.datas = rstData;
-                //第一层节点数据
-                let firstLevelDatas = _.filter(rstData, function (data) {
-                    return data.ParentID == -1;
-                });
-                //第一层初始数据的选项显示
-                for(let fData of firstLevelDatas){
-                    let options = getOptions(fData, rstData);
-                    fData.options = options.length > 0 ? options[0].name : '';
-                    //下挂的选项
-                    fData.optionsData = options && options.length > 0 ? _.cloneDeep(options) : [];
-                    fData.optionChecked = options && options.length > 0 ? [_.cloneDeep(options[0])] : [];
-                }
-                renderSheetFunc(elfSheet, function () {
-                    initTree(node.elf, elfSheet, elfItem.treeSetting, firstLevelDatas);
-                    //初始选择选项
-                    let initOptsOpr = [];
-                    for(let elfNode of node.elf.tree.items){
-                        if(elfNode.data.optionsData.length > 0){
-                            initOptsOpr.push({node: elfNode, data: elfNode.data.optionsData[0]});
-                        }
-                    }
-                    for(let opr of initOptsOpr){
-                        insertNodeByData(opr.node, opr.data);
-                    }
-                    TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.elf.tree.items, false);
-                    setOptionsCellType(node.elf.tree.items);
-                    //项目指引初始焦点
-                    elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
-                    refreshInsertRation();
-                });
-            });
-        }
-        else{
-            renderSheetFunc(elfSheet, function () {
-                node.elf.controller.showTreeData();
-                setOptionsCellType(node.elf.tree.items);
-                //项目指引初始焦点
-                elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
-                refreshInsertRation();
-            });
-        }
-    }
-    //获取选项的深度
-    //@param {Object}opt {Array}options(当前清单所有选项) @return {Array}
-    function getOptionDepth(opt, options) {
-        let parent = _.find(options, {ID: opt.ParentID});
-        let depth = 0;
-        while (parent){
-            depth++;
-            parent = _.find(options, {ID: parent.ParentID});
-        }
-        return depth;
-    }
-    //获取施工工序含有的选项(即当前施工工序的子项),获取的顺序按照NextSiblingID排序
-    //@param {Object}process {Array}datas @return {Array}
-    function getOptions(process, datas) {
-        let rst = [];
-        if(!process || !process.ID){
-            return [];
-        }
-        let options = _.filter(datas, function (data) {
-            return data.ParentID == process.ID;
-        });
-        if(options.length === 0){
-            return [];
-        }
-        //根据NextSiblingID排序
-        let IDMapping = {};
-        for(let opt of options){
-            IDMapping[opt.ID] = {self: opt, next: null, pre: null};
-        }
-        for(let opt of options){
-            let next = IDMapping[opt.NextSiblingID] ? IDMapping[opt.NextSiblingID] : null;
-            if(next){
-                next.pre = IDMapping[opt.ID];
-                IDMapping[opt.ID]['next'] = next;
-            }
-        }
-        let first = null,
-            rank = 0;
-        for(let ID in IDMapping){
-            let obj = IDMapping[ID];
-            if(!obj.pre){
-                first = obj;
-            }
-        }
-        while(first){
-            rank++;
-            first.self.rank = rank;
-            rst.push(first.self);
-            first = first.next;
-        }
-
-        return rst;
-    }
-    //设置清单精灵选项单元格
-    //@param {Array}nodes @return {void}
-    function setOptionsCellType(nodes) {
-        let elfSheet = elfItem.workBook.getActiveSheet();
-        for(let node of nodes){
-            if(node.data.optionsData && node.data.optionsData.length > 0){
-                elfSheet.getCell(node.serialNo(), 1).locked(false).cellType(getOptionsCellType());
-            }
-            else {
-                elfSheet.getCell(node.serialNo(), 1).locked(true).cellType(new GC.Spread.Sheets.CellTypes.Base());
-            }
-        }
-    }
-    //递归插入节点:原始项目指引数据奇数层为需要插入的节点,偶数层为下拉选项
-    //@param {Object}node(当前操作的节点) {Object}data(选项) @return {void}
-    function insertNodeByData(node, data) {
-        let elfSheet = elfItem.workBook.getActiveSheet();
-        let sameDepthNodes = node.children;
-        let insertNextSiblingID = -1,
-            insertParentID = node.data.ID;
-        //当前操作节点的选项
-        let nodeOpts = getOptions(node.data, bills.tree.selected.elf.datas);
-        let subOpts = getOptions(data, bills.tree.selected.elf.datas);
-        let dataDepth = getOptionDepth(data, bills.tree.selected.elf.datas);
-        if(subOpts.length >0 && subOpts[0].type !== itemType.ration){
-            if((dataDepth + 1) % 2 === 0){
-                //排序后的数据
-                let dataWithRank = _.find(nodeOpts, {ID: data.ID});
-                //确定插入位置
-                for(let subOpt of subOpts){
-                    for(let subNode of sameDepthNodes){
-                        //同层节点原本选项数据
-                        let subNodeOptData = _.find(bills.tree.selected.elf.datas, {ID: subNode.data.ID});
-                        //同层节点原本父选项数据
-                        let subNodeOptParent = _.find(bills.tree.selected.elf.datas, {ID: subNodeOptData.ParentID});
-                        let subNodeOptParentWithRank = _.find(nodeOpts, {ID: subNodeOptParent.ID});
-                        //父项顺序决定插入位置
-                        if(dataWithRank.rank < subNodeOptParentWithRank.rank){
-                            insertNextSiblingID = subNode.data.ID;
-                            break;
-                        }
-                        //父项顺序相同,根据子项顺序决定插入位置
-                        else if(dataWithRank.rank = subNodeOptParentWithRank.rank){
-                            if(subOpt.rank < subNode.data.rank){
-                                insertNextSiblingID = subNode.data.ID;
-                                break;
-                            }
-                        }
-                    }
-                    let sub2Opts = getOptions(subOpt, bills.tree.selected.elf.datas);
-                    subOpt.options = sub2Opts.length > 0 ? sub2Opts[0].name : '';
-                    let cloneOpt = _.cloneDeep(subOpt);//不改变原本的数据,比如ParentID
-                    cloneOpt.optionChecked = sub2Opts.length > 0 ? [_.cloneDeep(sub2Opts[0])] : [];
-                    cloneOpt.optionsData = sub2Opts.length > 0 ? _.cloneDeep(sub2Opts) : [];
-                    let newNode = node.tree.insertByData(cloneOpt, insertParentID, insertNextSiblingID);
-                    elfSheet.addRows(newNode.serialNo(), 1);
-                    node.tree.selected = newNode;
-                    elfSheet.setSelection(newNode.serialNo(), elfSheet.getSelections()[0].col, 1, 1);
-                    if(sub2Opts.length > 0 && sub2Opts[0].type !== itemType.ration){
-                        insertNodeByData(newNode, sub2Opts[0]);
-                    }
-                }
-            }
-            else {
-                insertNodeByData(node, subOpts[0]);
-            }
-        }
-    }
-    //获取选项下拉多选单元格
-    //@param {void} @return {void}
-    function getOptionsCellType() {
-        let me = this;
-        let elfSheet= elfItem.workBook.getActiveSheet();
-        function OptionsCellType() {
-            this.isEscKey=false;
-            this.displayText='';
-        }
-        function setOptionsDiv($editor, node, cellRect, cellStyle, top) {
-            if(!node){
-                return '';
-            }
-            let height = cellRect.height;
-            top = top.replace('px', '');
-            let options = getOptions(node.data, bills.tree.selected.elf.datas);
-            top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height - 5;
-            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>`);
-            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' : ''}>`);
-                $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 {//多选
-
-                    }
-                });
-            }
-            $editor.append($editInput);
-            $editor.append($optDiv);
-        }
-        //选择后处理
-        function doAfterSel(node) {
-            let checkedSels = $('.elf-options').find('input:checked');
-            let checkedNameArr = [],
-                optionChecked= [];
-            for(let checkSel of checkedSels){
-                let opt = _.cloneDeep(_.find(bills.tree.selected.elf.datas, {ID: $(checkSel).val()}));
-                opt.rank = $(checkSel).attr('rank');
-                checkedNameArr.push(opt.name);
-                optionChecked.push(opt);
-            }
-            this.displayText = checkedNameArr.length > 0 ? checkedNameArr.join(';') : '';
-            node.data.options = this.displayText;
-            node.data.optionChecked = optionChecked;
-            //删除节点
-            let deleteNodes = getDeleteNodes(node, optionChecked);
-            for(let dNode of deleteNodes){
-                elfSheet.deleteRows(dNode.serialNo(), dNode.posterityCount() + 1);
-                node.tree.delete(dNode);
-            }
-            //插入节点
-            for(let perCheked of optionChecked){
-                let exist = false;
-                let subOpts = getOptions(perCheked, bills.tree.selected.elf.datas);
-                for(let subNode of node.children){
-                    for(let subOpt of subOpts){
-                        if(subNode.data.ID === subOpt.ID){
-                            exist = true;
-                            break;
-                        }
-                    }
-                }
-                //不重复且不为定额时插入
-                if(!exist && perCheked.type !== itemType.ration){
-                    insertNodeByData(node, perCheked);//这里递归,默认第一个
-                }
-            }
-            TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.tree.items, false);
-            setOptionsCellType(node.tree.items);
-            refreshInsertRation();
-        }
-        //获取删除节点
-        function getDeleteNodes(node, optionChecked) {
-            let rst = [];
-            for(let subNode of node.children){
-                let exist = false;
-                for(let perChecked of optionChecked){
-                    let subOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
-                    for(let subOpt of subOpts){
-                        if(subNode.data.ID === subOpt.ID){
-                            exist = true;
-                            break;
-                        }
-                    }
-                }
-                if(!exist){
-                    rst.push(subNode);
-                }
-            }
-            return rst;
-        }
-        OptionsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
-
-        OptionsCellType.prototype.createEditorElement = function (context) {
-            let element = document.createElement("div");//这里创建的,会自动销毁
-            return element
-        };
-        OptionsCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
-            if (editorContext) {
-                let $editor = $(editorContext);
-                $editor.css("position", "fixed");
-                $editor.css("background", "white");
-                $editor.css("width", cellRect.width);
-                $editor.attr("gcUIElement", "gcEditingInput");
-                let activeCellTop = $editor.parent().parent().css('top');
-                let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
-                setOptionsDiv($editor, node, cellRect, cellStyle, activeCellTop);
-                this.isEscKey = false;
-            }
-        }
-        OptionsCellType.prototype.deactivateEditor = function (editorContext, context) {
-
-        };
-        OptionsCellType.prototype.setEditorValue = function (editor, value, context) {
-            this.displayText = value;
-        };
-        OptionsCellType.prototype.getEditorValue = function (editor, context) {
-            let me = this;
-            let node = bills.tree.selected.elf.tree.items[elfSheet.getActiveRowIndex()];
-            if(this.isEscKey !=true){
-                renderSheetFunc(elfSheet, function () {
-                    doAfterSel.call(me, node);
-                });
-            }
-            this.isEscKey = false;
-            return this.displayText;
-        };
-        OptionsCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
-
-        };
-        OptionsCellType.prototype.isReservedKey = function (e, context) {
-            //cell type handle tab key by itself
-            this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
-            return false;
-        };
-       /* OptionsCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-            if(style.backColor){
-                ctx.fillStyle = style.backColor;
-                ctx.fillRect(x, y, w, h);
-                ctx.save();
-            }
-            //边长
-            const l = 7;
-            let leftPointX = x + w - 15,
-                rightPointX = leftPointX + l,
-                middlePointX = (leftPointX + rightPointX)/2;
-            const cos30 = Math.cos(2*Math.PI * 30 / 360);
-            let hL = l * cos30;
-            let beginY = y + h/2 - hL;
-            ctx.beginPath();
-            ctx.moveTo(leftPointX, beginY);
-            ctx.lineTo(rightPointX, beginY);
-            ctx.lineTo(middlePointX, beginY + hL);
-            ctx.fillStyle = 'black';
-            ctx.fill();
-            ctx.save();
-        };*/
-        // override getHitInfo to allow cell type get mouse messages
-        OptionsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
-            return {
-                x: x,
-                y: y,
-                row: context.row,
-                col: context.col,
-                cellStyle: cellStyle,
-                cellRect: cellRect,
-                sheetArea: context.sheetArea
-            };
-        };
-        return new OptionsCellType();
-    }
     //初始化清单的工作内容和项目特征
     //初始化清单的工作内容和项目特征
     //@param {Number}billsLibId {Function}callback @return {void}
     //@param {Number}billsLibId {Function}callback @return {void}
     function initJobAndCharacter(billsLibId, callback){
     function initJobAndCharacter(billsLibId, callback){
@@ -998,7 +580,6 @@ const billsGuidance = (function () {
         let sheet = bills.workBook.getActiveSheet();
         let sheet = bills.workBook.getActiveSheet();
         let locateRow = locateBills ? locateBills.serialNo() : 0;
         let locateRow = locateBills ? locateBills.serialNo() : 0;
         sheet.setActiveCell(locateRow, 0);
         sheet.setActiveCell(locateRow, 0);
-        billsInitSel(locateRow);
         sheet.showRow(locateRow, GC.Spread.Sheets.VerticalPosition.center);
         sheet.showRow(locateRow, GC.Spread.Sheets.VerticalPosition.center);
     }
     }
     //清单设置悬浮提示信息
     //清单设置悬浮提示信息
@@ -1084,25 +665,6 @@ const billsGuidance = (function () {
             initViews();
             initViews();
             let callback = function () {
             let callback = function () {
                 initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
                 initTree(bills, bills.workBook.getActiveSheet(), bills.treeSetting, rstData.bills);
-                //清单精灵
-                if(rstData.guidanceLib.type && rstData.guidanceLib.type == libType.elf){
-                    $('#stdBillsGuidanceTab').text('清单精灵');
-                    //每一个清单节点下挂载一棵清单精灵树
-                    for(let node of bills.tree.items){
-                        node.elf = {tree: null, controller: null, datas: []}; //挂载全部数据,数据不一定全成为树节点
-                    }
-                }
-                //清单指引
-                else {
-                    $('#stdBillsGuidanceTab').text('清单指引');
-                    //每一棵项目指引树挂在清单节点上
-                    for(let node of bills.tree.items){
-                        node.guidance = {tree: null, controller: null};
-                    }
-                }
-                //setTagForHint(bills.tree.items);
-                //默认初始节点
-                billsInitSel(0);
                 if(doAfterLoadGuidance){
                 if(doAfterLoadGuidance){
                     doAfterLoadGuidance();
                     doAfterLoadGuidance();
                 }
                 }
@@ -1151,105 +713,6 @@ const billsGuidance = (function () {
         initWorkBooks(modules);
         initWorkBooks(modules);
 
 
     }
     }
-    //获取选中的行
-    //@return {Array}
-    function getCheckedRows(){
-        let rst = [];
-        let itemSheet = guideItem.workBook.getActiveSheet();
-        for(let row = 0; row < itemSheet.getRowCount(); row++){
-            let rowV = itemSheet.getValue(row, 0);
-            if(rowV){
-                rst.push(row);
-            }
-        }
-        return rst;
-    }
-    //获取清单精灵生成的定额数据
-    //@return {Array}
-    function getInsertElfRationData(){
-        let rst = [];
-        if(!bills.tree.selected){
-            return [];
-        }
-        if(!bills.tree.selected.elf){
-            return [];
-    }
-        let tree = bills.tree.selected.elf.tree;
-        if(!tree){
-            return [];
-        }
-        for(let node of tree.items){
-            for(let perChecked of node.data.optionChecked){
-                //选项直接是定额
-                if(perChecked.type === itemType.ration){
-                    rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
-                }
-                //选项下子选项是定额
-                else {
-                    let rationOpts = getOptions(perChecked, bills.tree.selected.elf.datas);
-                    for(let ration of rationOpts){
-                        if(ration.type === itemType.ration){
-                            rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
-                        }
-                    }
-                }
-            }
-        }
-        return rst;
-    }
-    //获取选中的定额数据
-    //@param {Array}rows @return {Array}
-    function getInsertRationData(rows){
-        let rst = [];
-        for(let row of rows){
-            let node = bills.tree.selected.guidance.tree.items[row];
-            if(node && node.data.type === itemType.ration){
-                rst.push({itemQuery: {userID: userID, ID: node.data.rationID}, rationType: rationType.ration});
-            }
-        }
-        return rst;
-    }
-    //插入定额
-    //@return {void}
-    function insertRations(addRationDatas){
-        if(addRationDatas.length > 0){
-            projectObj.project.Ration.addMultiRation(addRationDatas, function () {
-                //恢复
-                if(!currentLib.type || currentLib.type === libType.guidance){
-                    let sheet = guideItem.workBook.getActiveSheet();
-                    renderSheetFunc(sheet, function () {
-                        for(let row = 0; row < sheet.getRowCount(); row++){
-                            if(sheet.getValue(row, 0)){
-                                sheet.setValue(row, 0, false);
-                            }
-                        }
-                    });
-                }
-                refreshInsertRation();
-                projectObj.setActiveCell('quantity', true);
-            });
-        }
-    }
-    //更新插入定额按钮有效性
-    function refreshInsertRation(){
-        if(currentLib.type && currentLib.type === libType.elf){
-            if(getInsertElfRationData().length > 0){
-                $('#guidanceInsertRation').removeClass('disabled');
-            }
-            else {
-                $('#guidanceInsertRation').addClass('disabled');
-            }
-        }
-        else {
-            //勾选了定额,插入定额按钮才有效
-            if(getCheckedRows().length > 0){
-                $('#guidanceInsertRation').removeClass('disabled');
-            }
-            else {
-                $('#guidanceInsertRation').addClass('disabled');
-            }
-        }
-    }
     //展开至搜索出来点的节点
     //展开至搜索出来点的节点
     //@param {Array}nodes @return {void}
     //@param {Array}nodes @return {void}
     function expandSearchNodes(nodes){
     function expandSearchNodes(nodes){
@@ -1289,41 +752,6 @@ const billsGuidance = (function () {
             //清除展开收起状态sessionStorage
             //清除展开收起状态sessionStorage
             sessionStorage.removeItem('stdBillsGuidanceExpState');
             sessionStorage.removeItem('stdBillsGuidanceExpState');
         });
         });
-        //插入定额
-        $('#guidanceInsertRation').click(function () {
-            let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
-            insertRations(addRationDatas);
-        });
-        //插入清单
-        $('#guidanceInsertBills').click(function () {
-            //插入清单
-            if(!bills.tree || !bills.tree.selected){
-                return;
-            }
-            if(bills.tree.selected.children.length === 0){
-                let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
-                /*if(insert){
-                    //插入选中的定额
-                    let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
-                    insertRations(addRationDatas);
-                }*/
-            }
-        });
-        //插入清单和定额
-        $('#guidanceInsertBillsAndRation').click(function () {
-            //插入清单
-            if(!bills.tree || !bills.tree.selected){
-                return;
-            }
-            if(bills.tree.selected.children.length === 0){
-                let insert = billsLibObj.insertBills(stdBillsJobData, stdBillsFeatureData, bills.tree.selected);
-                if(insert){
-                    //插入选中的定额
-                    let addRationDatas = currentLib.type && currentLib.type === libType.elf ? getInsertElfRationData() : getInsertRationData(getCheckedRows());
-                    insertRations(addRationDatas);
-                }
-            }
-        });
         //搜索
         //搜索
         $('#stdBillsGuidanceSearch>div>button').click(function () {
         $('#stdBillsGuidanceSearch>div>button').click(function () {
             if(!bills.tree){
             if(!bills.tree){
@@ -1355,8 +783,6 @@ const billsGuidance = (function () {
                 renderSheetFunc(billsSheet, function () {
                 renderSheetFunc(billsSheet, function () {
                     bills.controller.setTreeSelected(result[0]);
                     bills.controller.setTreeSelected(result[0]);
                     billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
                     billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
-                    billsInitSel(result[0].serialNo());
-
                     for (let node of result) {
                     for (let node of result) {
                         billsSheet.getRange(node.serialNo(), -1, 1, -1).backColor('lemonChiffon');
                         billsSheet.getRange(node.serialNo(), -1, 1, -1).backColor('lemonChiffon');
                     }
                     }
@@ -1371,12 +797,10 @@ const billsGuidance = (function () {
                     if (resultIndex === result.length - 1) {
                     if (resultIndex === result.length - 1) {
                         bills.controller.setTreeSelected(result[0]);
                         bills.controller.setTreeSelected(result[0]);
                         billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
                         billsSheet.setSelection(result[0].serialNo(), sel[0].col, 1, 1);
-                        billsInitSel(result[0].serialNo());
                         billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
                         billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
                     } else {
                     } else {
                         bills.controller.setTreeSelected(result[resultIndex + 1]);
                         bills.controller.setTreeSelected(result[resultIndex + 1]);
                         billsSheet.setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
                         billsSheet.setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
-                        billsInitSel(result[resultIndex + 1].serialNo());
                         billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
                         billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
                     }
                     }
                 });
                 });
@@ -1400,17 +824,6 @@ const billsGuidance = (function () {
             billsLibObj.clearHighLight(bills.workBook);
             billsLibObj.clearHighLight(bills.workBook);
             refreshWorkBook();
             refreshWorkBook();
         });
         });
-        //监听alt建,确定选项单选多选状态
-       /* $('#billsGuidance_items').keydown(function(e){
-            if(e.keyCode === 18){
-                billsGuidanceSelMode = 1;
-            }
-        });
-        $('#billsGuidance_items').keyup(function(e){
-            if(e.keyCode === 18){
-                billsGuidanceSelMode = 0;
-            }
-        });*/
     }
     }
     //刷新表
     //刷新表
     //@return {void}
     //@return {void}
@@ -1426,7 +839,7 @@ const billsGuidance = (function () {
         }
         }
     }
     }
 
 
-    return {initViews, bindBtn, refreshWorkBook, refreshInsertRation, setColumnWidthByRate, locateAtBills, bills, elfItem};
+    return {initViews, bindBtn, refreshWorkBook, setColumnWidthByRate, locateAtBills, bills, elfItem};
 })();
 })();
 
 
 $(document).ready(function(){
 $(document).ready(function(){

+ 82 - 12
web/building_saas/main/js/views/sub_view.js

@@ -9,7 +9,10 @@
 
 
 let subSpread = null;
 let subSpread = null;
 let subObj = {
 let subObj = {
+    TZJNRrePercent:null,
     initSubSpread:function () {
     initSubSpread:function () {
+        //清单精灵
+        BillsElf.buildSheet();
         contentOprObj.buildSheet($("#jobSpread")[0]);
         contentOprObj.buildSheet($("#jobSpread")[0]);
         //sheetCommonObj.bindEscKey(contentOprObj.workBook, [{sheet: contentOprObj.workBook.getSheet(0), editStarting: contentOprObj.onEditStart, editEnded: contentOprObj.onEditEnded}]);
         //sheetCommonObj.bindEscKey(contentOprObj.workBook, [{sheet: contentOprObj.workBook.getSheet(0), editStarting: contentOprObj.onEditStart, editEnded: contentOprObj.onEditEnded}]);
         sheetCommonObj.spreadDefaultStyle(contentOprObj.workBook);
         sheetCommonObj.spreadDefaultStyle(contentOprObj.workBook);
@@ -60,7 +63,7 @@ let subObj = {
     },
     },
     initNavItem:function (node) {
     initNavItem:function (node) {
      /*   1、造价书选中行类别是“大项费用”、“分部”、“分项”、“清单”时,显示按钮“工程量明细”、“计算程序”、“特征及内容”,默认打开“计算程序”。
      /*   1、造价书选中行类别是“大项费用”、“分部”、“分项”、“清单”时,显示按钮“工程量明细”、“计算程序”、“特征及内容”,默认打开“计算程序”。
-          2、选中行类别是“定额”、“量价”、“人材机”时,显示按钮“人材机”、“子目换算”、“工程量明细”、“计算程序”、“安装增加费”,默认打开“人材机”。
+          2、选中行类别是“定额”、“量价”、“人材机”时,显示按钮“人材机”、“子目换算”、“工程量明细”、“计算程序”、“安装增加费”、"模板子目",默认打开“人材机”。
      */
      */
         if (!node) {
         if (!node) {
             return;
             return;
@@ -70,17 +73,20 @@ let subObj = {
             //GLJ_div //ZMHS_div
             //GLJ_div //ZMHS_div
             $("#GLJ_div").show();
             $("#GLJ_div").show();
             $("#ZMHS_div").show();
             $("#ZMHS_div").show();
+            $("#MBZM_div").show();
             installationFeeObj.engineeringTypeChecking();//检查是否安装工程
             installationFeeObj.engineeringTypeChecking();//检查是否安装工程
             $("#TZJNR_div").hide();
             $("#TZJNR_div").hide();
-            $("#linkGLJ").addClass();
-            $("#linkGLJ").click();
+  			$('#QDJL_div').hide();
+            $("#linkGLJ").addClass();            $(gljOprObj.rationTab).click();
 
 
         }else {
         }else {
             $("#GLJ_div").hide();
             $("#GLJ_div").hide();
             $("#ZMHS_div").hide();
             $("#ZMHS_div").hide();
+            $("#MBZM_div").hide();
             $("#AZZJF_div").hide();
             $("#AZZJF_div").hide();
             $("#TZJNR_div").show();
             $("#TZJNR_div").show();
-            $("#linkJSCX").click();
+            $('#QDJL_div').show();
+            $(gljOprObj.billsTab).click();
         }
         }
         projectObj.mainSpread.focus();
         projectObj.mainSpread.focus();
     }
     }
@@ -98,12 +104,10 @@ $("#linkGLJ").click(function(){
     refreshSubSpread();
     refreshSubSpread();
     subSpread.setActiveSheetIndex(0);
     subSpread.setActiveSheetIndex(0);
     gljOprObj.activeTab='#linkGLJ';
     gljOprObj.activeTab='#linkGLJ';
+    gljOprObj.setNodeShowTab();
 });
 });
 
 
 
 
-
-
-
 $("#linkAZZJF").click(function(){
 $("#linkAZZJF").click(function(){
     $("#subItems").children().hide();
     $("#subItems").children().hide();
     MaterialController.hideReplaceDiv();
     MaterialController.hideReplaceDiv();
@@ -112,6 +116,7 @@ $("#linkAZZJF").click(function(){
     refreshSubSpread();
     refreshSubSpread();
     subSpread.setActiveSheetIndex(3);
     subSpread.setActiveSheetIndex(3);
     gljOprObj.activeTab='#linkAZZJF';
     gljOprObj.activeTab='#linkAZZJF';
+    gljOprObj.setNodeShowTab();
 });
 });
 
 
 $("#linkGCLMX").click(function(){
 $("#linkGCLMX").click(function(){
@@ -123,6 +128,7 @@ $("#linkGCLMX").click(function(){
     refreshSubSpread();
     refreshSubSpread();
     subSpread.setActiveSheetIndex(1);
     subSpread.setActiveSheetIndex(1);
     gljOprObj.activeTab='#linkGCLMX';
     gljOprObj.activeTab='#linkGCLMX';
+    gljOprObj.setNodeShowTab();
 });
 });
 
 
 $("#linkJSCX").click(function(){        // 计算程序
 $("#linkJSCX").click(function(){        // 计算程序
@@ -139,6 +145,7 @@ $("#linkJSCX").click(function(){        // 计算程序
     let sel = projectObj.mainController.tree.selected;
     let sel = projectObj.mainController.tree.selected;
     calcProgramObj.refreshCalcProgram(sel, 3);
     calcProgramObj.refreshCalcProgram(sel, 3);
     gljOprObj.activeTab='#linkJSCX';
     gljOprObj.activeTab='#linkJSCX';
+    gljOprObj.setNodeShowTab();
 });
 });
 
 
 
 
@@ -150,28 +157,67 @@ $("#linkZMHS").click(function(){        // 子目换算
     refreshSubSpread();
     refreshSubSpread();
 
 
     gljOprObj.activeTab='#linkZMHS';
     gljOprObj.activeTab='#linkZMHS';
+    gljOprObj.setNodeShowTab();
+});
+$("#linkMBZM").click(function(){        // 模板子目
+    $("#subItems").children().hide();
+    $("#tabMBZM").show();
+    pageCCOprObj.active = false;
+    refreshSubSpread();
+    gljOprObj.activeTab='#linkMBZM';
+    gljOprObj.setNodeShowTab();
 });
 });
+
+
 //特征及内容各模块宽度自适应
 //特征及内容各模块宽度自适应
 function adaptiveTzjnrWidth() {
 function adaptiveTzjnrWidth() {
     if(gljOprObj.activeTab !== '#linkTZJNR'){
     if(gljOprObj.activeTab !== '#linkTZJNR'){
         return;
         return;
     }
     }
+    let job_proportion = 0.25;
+    let item_proportion = 0.75;
+    if(subObj.TZJNRrePercent){
+        job_proportion = parseFloat(subObj.TZJNRrePercent.nearPercent)/100;
+        item_proportion = 1- job_proportion;
+    }
+
     //排版规则工具条宽度
     //排版规则工具条宽度
     const typeSettingWidth = 30;
     const typeSettingWidth = 30;
-    let tzjnrWidth = $('#tzjnrCon').width() + 30;
+    let tzjnrWidth = $('#tabCon').width();
+    console.log("set jobDiv");
+    console.log(subObj.TZJNRrePercent);
     //let tzjnrWidth = $(window).width() - $('.main-nav').width() - $('.main-side').width();
     //let tzjnrWidth = $(window).width() - $('.main-nav').width() - $('.main-side').width();
-    if($('#add-rule').is(':visible')){
-        $('#jobDiv').css('width', tzjnrWidth / 3);
-        $('#itemDiv').css('width', tzjnrWidth / 3);
+    //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);
         $('#add-rule').css('width', tzjnrWidth / 3);
     } else{
     } else{
         $('#jobDiv').css('width', tzjnrWidth / 2);
         $('#jobDiv').css('width', tzjnrWidth / 2);
         $('#itemDiv').css('width', tzjnrWidth / 2 - typeSettingWidth);
         $('#itemDiv').css('width', tzjnrWidth / 2 - typeSettingWidth);
         $('#openTypeSetting').css('width', typeSettingWidth);
         $('#openTypeSetting').css('width', typeSettingWidth);
-    }
+    }*/
     pageCCOprObj.resizeWidth();
     pageCCOprObj.resizeWidth();
     refreshSubSpread();
     refreshSubSpread();
 }
 }
+//清单精灵
+$('#linkQDJL').click(function () {
+    gljOprObj.activeTab='#linkQDJL';
+    $("#subItems").children().hide();
+    $('#qdjl').show();
+    let selectedNode = projectObj.mainController.tree.selected;
+    BillsElf.billsSelElf(selectedNode.data.code);
+    refreshSubSpread();
+    gljOprObj.setNodeShowTab();
+    BillsElf.refreshWorkBook();
+
+});
 //特征及内容
 //特征及内容
 $("#linkTZJNR").click(function () {
 $("#linkTZJNR").click(function () {
     gljOprObj.activeTab='#linkTZJNR';
     gljOprObj.activeTab='#linkTZJNR';
@@ -190,6 +236,7 @@ $("#linkTZJNR").click(function () {
     }
     }
     pageCCOprObj.mainActiveCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
     pageCCOprObj.mainActiveCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
     pageCCOprObj.setCacheAndShow(selectedNode);
     pageCCOprObj.setCacheAndShow(selectedNode);
+    gljOprObj.setNodeShowTab();
 });
 });
 //打开排版规则
 //打开排版规则
 $('#openTypeSetting').click(function () {
 $('#openTypeSetting').click(function () {
@@ -502,8 +549,10 @@ function refreshSubSpread(){
     } else{
     } else{
         if(subSpread) subSpread.refresh();
         if(subSpread) subSpread.refresh();
         if(MaterialController.spread) MaterialController.spread.refresh();
         if(MaterialController.spread) MaterialController.spread.refresh();
+        BillsElf.refreshWorkBook();
     }
     }
     if($('#linkZMHS').hasClass('active')) zmhs_obj.refresh();
     if($('#linkZMHS').hasClass('active')) zmhs_obj.refresh();
+    if($('#linkMBZM').hasClass('active')) mbzm_obj.refresh();
 }
 }
 
 
 let subViewObj = {
 let subViewObj = {
@@ -567,6 +616,13 @@ $('#linkZMHS').on('shown.bs.tab', function (e) {
     zmhs_obj.showZMHSData();
     zmhs_obj.showZMHSData();
 });
 });
 
 
+
+$('#linkMBZM').on('shown.bs.tab', function (e) {
+    mbzm_obj.refresh();
+    mbzm_obj.showMBZMData();
+});
+
+
 $('#linkComments').on('shown.bs.tab', function () {
 $('#linkComments').on('shown.bs.tab', function () {
     subViewObj.loadComments(projectObj.project.mainTree.selected);
     subViewObj.loadComments(projectObj.project.mainTree.selected);
 });
 });
@@ -578,3 +634,17 @@ $('#linkGCLMX').on('shown.bs.tab', function () {
 $('#linkAZZJF').on('shown.bs.tab', function () {
 $('#linkAZZJF').on('shown.bs.tab', function () {
     gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected, '111111');
     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();
+    refreshSubSpread();
+});

+ 2 - 2
web/building_saas/main/js/views/zmhs_view.js

@@ -219,12 +219,12 @@ let zmhs_obj = {
         let me = zmhs_obj;
         let me = zmhs_obj;
         let height = cellRect.height;
         let height = cellRect.height;
         let offect = 0;
         let offect = 0;
-        let newString = "<form style='margin-top:1px' ><table  width='100%'  cellpadding='0'  border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;'>";
+        let newString = "<form style='margin-top:1px' ><table  width='100%'  cellpadding='0'  border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;'>";
         let cus_coe =  me.coeSheetData[context.row];
         let cus_coe =  me.coeSheetData[context.row];
         if(cus_coe){
         if(cus_coe){
             for(let i =0;i< cus_coe.coes.length;i++){
             for(let i =0;i< cus_coe.coes.length;i++){
                 newString += me.getOneRow(cus_coe.coes[i].coeType, i, cus_coe.coes[i].coeType,height);
                 newString += me.getOneRow(cus_coe.coes[i].coeType, i, cus_coe.coes[i].coeType,height);
-                offect += height +1
+                offect += height +3
             }
             }
         }
         }
         newString += "</table></form><div style='height:"+ height+"px'><div onclick='zmhs_obj.coeSheet.endEdit()' style='margin:-1px 1px 0px'>自定义系数</div></div>";
         newString += "</table></form><div style='height:"+ height+"px'><div onclick='zmhs_obj.coeSheet.endEdit()' style='margin:-1px 1px 0px'>自定义系数</div></div>";

+ 56 - 5
web/building_saas/pm/html/project-management.html

@@ -31,6 +31,12 @@
         #summary-engineering,#summary-project{
         #summary-engineering,#summary-project{
             display: none;
             display: none;
         }
         }
+        #shareToInfo {
+            display:block;
+            height:200px;
+            overflow-y:auto;
+            -webkit-overflow-scrolling: touch;
+        }
     </style>
     </style>
 </head>
 </head>
 
 
@@ -631,6 +637,51 @@
 </div>
 </div>
 <!--弹出分享-->
 <!--弹出分享-->
 <div class="modal fade" id="share" data-backdrop="static">
 <div class="modal fade" id="share" data-backdrop="static">
+    <div class="modal-dialog modal-lg" 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">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <!--添加分享-->
+                <div class="form-group">
+                    <div class="input-group input-group-sm">
+                        <input id="sharePhone" type="text" class="form-control" placeholder="输入 手机号 添加分享">
+                       <!-- <div class="input-group-append">
+                            <button class="btn btn-primary" type="button" id="button-addon2">添加分享</button>
+                        </div>-->
+                    </div>
+                </div>
+                <table class="table table-sm" id="shareFindDiv">
+                    <tbody style="display: block">
+                    <tr><th style="width: 112px;">姓名</th><th style="width: 165px;">公司</th><th style="width: 136px;">手机</th><th style="width: 160px;">邮箱</th><th style="width: 90px;">允许拷贝</th><th style="width: 90px;">添加分享</th></tr>
+                    <tr><td id="user_name">张三</td><td id="user_company">XX公司</td><td id="user_mobile">12345678900</td><td id="user_email"></td><td><input id="allowCopy" type="checkbox"></td><td><a id="share-confirm" href="javascript:void(0)" class="btn btn-sm btn-primary">添加分享</a></td></tr>
+                    </tbody>
+                </table>
+                <p id="share-info" class="text-danger">不存在手机号 15812777651 的用户</p>
+                <!--已分享数据-->
+                <legend>已分享</legend>
+                <table class="table table-sm">
+                    <tbody id="shareToInfo">
+                    <tr><th>姓名</th><th>公司</th><th>手机</th><th>邮箱</th><th width="90">允许拷贝</th><th width="90">取消分享</th></tr>
+                    <tr><td>张三</td><td>XX公司</td><td>12345678900</td><td></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
+                    <tr><td>王五</td><td>XX公司</td><td>12345678900</td><td></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>
+                    </tbody>
+                </table>
+            </div>
+            <div class="modal-footer">
+                <!--分享人可以取消-->
+                <button id="shareToConfirm" type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--弹出分享-->
+<!--<div class="modal fade" id="share" data-backdrop="static">
     <div class="modal-dialog" role="document">
     <div class="modal-dialog" role="document">
         <div class="modal-content">
         <div class="modal-content">
             <div class="modal-header">
             <div class="modal-header">
@@ -660,7 +711,7 @@
                             <div class="form-check mb-2">
                             <div class="form-check mb-2">
                                 <input type="checkbox" class="form-check-input" id="allowCopy">
                                 <input type="checkbox" class="form-check-input" id="allowCopy">
                                 <label class="form-check-label" for="allowCopy">允许该用户拷贝该工程</label>
                                 <label class="form-check-label" for="allowCopy">允许该用户拷贝该工程</label>
-                                <!--打勾后出现提示-->
+                                &lt;!&ndash;打勾后出现提示&ndash;&gt;
                                 <div id="allowCopyHint" class="form-text text-danger"><i class="fa fa-exclamation-triangle"></i> 该用户可以把你的项目拷贝成为他的数据,请谨慎勾选。 </div>
                                 <div id="allowCopyHint" class="form-text text-danger"><i class="fa fa-exclamation-triangle"></i> 该用户可以把你的项目拷贝成为他的数据,请谨慎勾选。 </div>
                             </div>
                             </div>
                             <a id="addShareUser" class="btn btn-sm btn-primary" href="javascript:void(0);"><i class="fa fa-plus"></i> 添加</a>
                             <a id="addShareUser" class="btn btn-sm btn-primary" href="javascript:void(0);"><i class="fa fa-plus"></i> 添加</a>
@@ -679,9 +730,9 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
-</div>
+</div>-->
 <!--弹出分享给交互-->
 <!--弹出分享给交互-->
-<div class="modal fade" id="shareTo" data-backdrop="static">
+<!--<div class="modal fade" id="shareTo" data-backdrop="static">
     <div class="modal-dialog" role="document">
     <div class="modal-dialog" role="document">
         <div class="modal-content" style="width: 750px;">
         <div class="modal-content" style="width: 750px;">
             <div class="modal-header">
             <div class="modal-header">
@@ -691,7 +742,7 @@
                 </button>
                 </button>
             </div>
             </div>
             <div class="modal-body modal-fixed-height">
             <div class="modal-body modal-fixed-height">
-                <!--     <p>勾选需要恢复的文件,点“确定”按钮,确认从回收站中恢复。</p>-->
+                &lt;!&ndash;     <p>勾选需要恢复的文件,点“确定”按钮,确认从回收站中恢复。</p>&ndash;&gt;
                 <table class="table table-hover table-sm mb-5">
                 <table class="table table-hover table-sm mb-5">
                     <thead>
                     <thead>
                     <tr style="display: block;">
                     <tr style="display: block;">
@@ -721,7 +772,7 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
-</div>
+</div>-->
 <!-- JS. -->
 <!-- JS. -->
 <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
 <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
 <script>GC.Spread.Sheets.LicenseKey = '<%- LicenseKey %>';</script>
 <script>GC.Spread.Sheets.LicenseKey = '<%- LicenseKey %>';</script>

+ 68 - 128
web/building_saas/pm/js/pm_newMain.js

@@ -35,9 +35,6 @@ let taxTypeMap = {
 * */
 * */
 let regions = [];
 let regions = [];
 
 
-//分享用户列表
-let shareUsers = [];
-
 function isDef(v) {
 function isDef(v) {
     return typeof v !== 'undefined' && v !== null;
     return typeof v !== 'undefined' && v !== null;
 }
 }
@@ -308,9 +305,11 @@ const projTreeObj = {
                         //return !(selectedItem && selectedItem.data.projType === projectType.tender);
                         //return !(selectedItem && selectedItem.data.projType === projectType.tender);
                     },
                     },
                     callback: function (key, opt) {
                     callback: function (key, opt) {
+                        let selected = projTreeObj.tree.selected;
                         $('#sharePhone').val('');
                         $('#sharePhone').val('');
                         $('#share-info').hide();
                         $('#share-info').hide();
-                        $('#share').find('.card').hide();
+                        $('#shareFindDiv').hide();
+                        setShareToModal(selected);
                         $('#share').modal('show');
                         $('#share').modal('show');
                         //默认允许拷贝
                         //默认允许拷贝
                         $('#allowCopy').prop('checked', true);
                         $('#allowCopy').prop('checked', true);
@@ -320,7 +319,7 @@ const projTreeObj = {
                         }, 200);
                         }, 200);
                     }
                     }
                 },
                 },
-                'cancelShare': {
+               /* 'cancelShare': {
                     name: '取消分享',
                     name: '取消分享',
                     icon: 'fa-ban',
                     icon: 'fa-ban',
                     disabled: function () {
                     disabled: function () {
@@ -332,7 +331,7 @@ const projTreeObj = {
                         setShareToModal(selected);
                         setShareToModal(selected);
                         $('#shareTo').modal('show');
                         $('#shareTo').modal('show');
                     }
                     }
-                },
+                },*/
                 "spr3": '--------',
                 "spr3": '--------',
                 "manageFiles": {
                 "manageFiles": {
                     name: "管理相关文件",
                     name: "管理相关文件",
@@ -672,8 +671,8 @@ const projTreeObj = {
         let imgWidth = 18;
         let imgWidth = 18;
         let imgHeight = 14;
         let imgHeight = 14;
         let shareImg = document.getElementById('share_pic'),
         let shareImg = document.getElementById('share_pic'),
-            shareImgWidth = 18,
-            shareImgHeight = 18;
+            shareImgWidth = 13,
+            shareImgHeight = 13;
         let TreeNodeCellType = function () {
         let TreeNodeCellType = function () {
         };
         };
         TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
@@ -793,16 +792,21 @@ const projTreeObj = {
                     parentCenterX -= (indent + levelIndent);
                     parentCenterX -= (indent + levelIndent);
                 }
                 }
             };
             };
+            //分享标记在开头
+            if (node.data.shareInfo && node.data.shareInfo.length > 0) {
+                let nowY = Math.floor((y + (y + h)) / 2);
+                ctx.drawImage(shareImg, x + 3, nowY - 7, shareImgWidth,shareImgHeight);
+            }
             // Draw Text
             // Draw Text
             //x = x + (node.depth() + 1) * indent +  node.depth() * levelIndent;
             //x = x + (node.depth() + 1) * indent +  node.depth() * levelIndent;
             x = x + (node.depth() + 1) * indent +  node.depth() * levelIndent + imgWidth + 3;
             x = x + (node.depth() + 1) * indent +  node.depth() * levelIndent + imgWidth + 3;
             w = w - (node.depth() + 1) * indent - node.depth() * levelIndent - imgWidth - 3;
             w = w - (node.depth() + 1) * indent - node.depth() * levelIndent - imgWidth - 3;
             GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
             GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-            if (node.data.shareInfo && node.data.shareInfo.length > 0) {
+          /*  if (node.data.shareInfo && node.data.shareInfo.length > 0) {//分享标记在文本后
                 let nowX = Math.floor(x) + w - 20;
                 let nowX = Math.floor(x) + w - 20;
                 let nowY = Math.floor((y + (y + h)) / 2);
                 let nowY = Math.floor((y + (y + h)) / 2);
                 ctx.drawImage(shareImg, nowX + 3, nowY - 7, shareImgWidth,shareImgHeight);
                 ctx.drawImage(shareImg, nowX + 3, nowY - 7, shareImgWidth,shareImgHeight);
-            }
+            }*/
         };
         };
         TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
         TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
             let info = {x: x, y: y, row: context.row, col: context.col, cellStyle: cellStyle, cellRect: cellRect, sheetArea: context.sheetArea};
             let info = {x: x, y: y, row: context.row, col: context.col, cellStyle: cellStyle, cellRect: cellRect, sheetArea: context.sheetArea};
@@ -1897,7 +1901,7 @@ function AddTenderItems(selected, projName, engName, tenderName, property, callb
             let updateProjs = GetUpdateData(pre, parent, next, projName, null, projID, {updateType: 'new', projectType: projectType.project});
             let updateProjs = GetUpdateData(pre, parent, next, projName, null, projID, {updateType: 'new', projectType: projectType.project});
             let updateEng = {updateType: 'new', updateData: {ID: engID, ParentID: projID, NextSiblingID: -1, name: engName, projType: projectType.engineering}};
             let updateEng = {updateType: 'new', updateData: {ID: engID, ParentID: projID, NextSiblingID: -1, name: engName, projType: projectType.engineering}};
             property.rootProjectID = projID;
             property.rootProjectID = projID;
-            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: engID, NextSiblingID: -1, name: tenderName, projType: projectType.tender, property: property}};
+            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: engID, NextSiblingID: -1, shareInfo: [], name: tenderName, projType: projectType.tender, property: property}};
             updateDatas = updateDatas.concat(updateProjs);
             updateDatas = updateDatas.concat(updateProjs);
             updateDatas.push(updateEng);
             updateDatas.push(updateEng);
             updateDatas.push(updateTender);
             updateDatas.push(updateTender);
@@ -1932,7 +1936,7 @@ function AddTenderItems(selected, projName, engName, tenderName, property, callb
             let next = null;
             let next = null;
             let updateEng = {updateType: 'new', updateData: {ID: engID, ParentID: tempProj.data.ID, NextSiblingID: -1, name: engName, projType: projectType.engineering}};
             let updateEng = {updateType: 'new', updateData: {ID: engID, ParentID: tempProj.data.ID, NextSiblingID: -1, name: engName, projType: projectType.engineering}};
             property.rootProjectID = tempProj.data.ID;
             property.rootProjectID = tempProj.data.ID;
-            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: engID, NextSiblingID: -1, name: tenderName, projType: projectType.tender, property: property}};
+            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: engID, NextSiblingID: -1,  shareInfo: [], name: tenderName, projType: projectType.tender, property: property}};
             if(selected && selected.data.projType === projectType.engineering && selected.parent === tempProj){
             if(selected && selected.data.projType === projectType.engineering && selected.parent === tempProj){
                 pre = selected;
                 pre = selected;
                 next = selected.nextSibling;
                 next = selected.nextSibling;
@@ -1968,7 +1972,7 @@ function AddTenderItems(selected, projName, engName, tenderName, property, callb
             let tenderID = IDs.lowID;
             let tenderID = IDs.lowID;
             let pre = tempEng.lastChild();
             let pre = tempEng.lastChild();
             property.rootProjectID = tempProj.data.ID;
             property.rootProjectID = tempProj.data.ID;
-            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: tempEng.id(), NextSiblingID: -1, name: tenderName, projType: projectType.tender, property: property}};
+            let updateTender = {updateType: 'new', updateData: {ID: tenderID, ParentID: tempEng.id(), NextSiblingID: -1,  shareInfo: [], name: tenderName, projType: projectType.tender, property: property}};
             updateDatas.push(updateTender);
             updateDatas.push(updateTender);
             if(pre){
             if(pre){
                 updateDatas.push({updateType: 'update', updateData: {ID: pre.id(), NextSiblingID: tenderID}});
                 updateDatas.push({updateType: 'update', updateData: {ID: pre.id(), NextSiblingID: tenderID}});
@@ -3316,9 +3320,11 @@ function shareTender(){
     canShare = false;
     canShare = false;
     let phone = $('#sharePhone').val();
     let phone = $('#sharePhone').val();
     const hintInfo = $('#share-info');
     const hintInfo = $('#share-info');
-    const userInfo = $('#share').find('.card');
+    const userInfo = $('#shareFindDiv');
     const addUser = $('#addShareUser');
     const addUser = $('#addShareUser');
     const copyInput = $('#allowCopy');
     const copyInput = $('#allowCopy');
+    const shareConfirm = $('#share-confirm');
+    shareConfirm.addClass('disabled');
     //可分享才可添加用户
     //可分享才可添加用户
     addUser.addClass('disabled');
     addUser.addClass('disabled');
     if (hintInfo.is(':visible')) {
     if (hintInfo.is(':visible')) {
@@ -3349,10 +3355,8 @@ function shareTender(){
             setDangerInfo(hintInfo, '', false);
             setDangerInfo(hintInfo, '', false);
             $('#user_name').text(userData.real_name ? userData.real_name : '');
             $('#user_name').text(userData.real_name ? userData.real_name : '');
             $('#user_company').text(userData.company ? userData.company : '');
             $('#user_company').text(userData.company ? userData.company : '');
-            let mobileHtml = `<i class="fa fa-tablet"> ${userData.mobile ? userData.mobile : ''}</i>`;
-            $('#user_mobile').html(mobileHtml);
-            let emailHtml = `<i class="fa fa-envelope-o"> ${userData.email ? userData.email : ''}</i>`;
-            $('#user_email').html(emailHtml);
+            $('#user_mobile').text(userData.mobile ? userData.mobile : '');
+            $('#user_email').text(userData.email ? userData.email : '');
             //默认可拷贝
             //默认可拷贝
             copyInput.prop('checked', true);
             copyInput.prop('checked', true);
             userInfo.show();
             userInfo.show();
@@ -3365,6 +3369,7 @@ function shareTender(){
                     }
                     }
                 }
                 }
                 addUser.removeClass('disabled');
                 addUser.removeClass('disabled');
+                shareConfirm.removeClass('disabled');
                 canShare = true;
                 canShare = true;
             });
             });
         }
         }
@@ -3376,127 +3381,46 @@ $('#sharePhone').on('keyup',function () {
     });
     });
 });
 });
 
 
-//设置确认分享用户列表
-//@param {String}name {String}phone @return {void}
-function setUsersShareDiv(projName, users) {
-    //每行的数据
-    const perLineCount = 2;
-    let $users = $('#shareUsers');
-    //三行后限制死高度
-    if (Math.ceil(users.length / perLineCount) > 2) {
-        $users.height(180);
-    } else {
-        $users.height('');
-    }
-    $users.empty();
-    let $projInfo = $(`<p>确认分享 <b>${projName}</b> 给</p>`);
-    $users.append($projInfo);
-    let $preP = null,
-        $preH4 = null;
-    for (let i = 0; i < users.length; i++) {
-        let user = users[i];
-        let $span = $(`<span class="badge badge-light mr-3" style="padding: 0">${user.name}(${user.phone})</span>`),
-            $a = $(`<a href="javascript:void(0);" userID="${user.userID}" class="text-danger" title="移除分享"></a>`),
-            $i = $('<i class="fa fa-remove"></i>');
-        bindRemoveShare($a);
-        $a.append($i);
-        $span.append($a);
-        //另起一行
-        if (i % 2 === 0) {
-           $preP = $('<p>');
-           $preH4 = $('<h4>');
-           $preH4.append($span);
-           $preP.append($preH4);
-           $users.append($preP);
-        } else {//行内新增元素
-            $preH4.append($span);
-            $preP.append($preH4);
-        }
-    }
-    if (users.length > 0) {
-        $users.show();
-    }
-    //移除分享列表
-    function bindRemoveShare(a){
-        a.click(function () {
-            let theUserID = a.attr('userID');
-            //清除shareUsers数组相关数据
-            _.remove(shareUsers, {userID: theUserID});
-            a.parent().remove();
-            //如果行内只剩一个数据,则删除数据及行
-            if (a.parent().parent().children().length === 0) {
-                a.parent().parent().remove();
-            }
-            //如果所用用户数据只剩这一条,删除用户数据则隐藏分享用户列表容器
-            if (shareUsers.length === 0) {
-                $('#shareUsers').hide();
-            }
-        });
-    }
-
-}
-//添加分享用户
-$('#addShareUser').click(function () {
-    //输入有效手机号的用户
-    if (shareUserID) {
-        const hintInfo = $('#share-info');
-        if (_.find(shareUsers, {userID: shareUserID})) {
-            setDangerInfo(hintInfo, '已添加此用户');
-            return;
-        }
-        let allowCopy = $('#allowCopy').prop('checked'),
-            name = $('#user_name').text(),
-            phone = $('#user_mobile').text();
-        shareUsers.push({userID: shareUserID, name: name, phone: phone, allowCopy: allowCopy});
-        let selected = projTreeObj.tree.selected;
-        setUsersShareDiv(selected.data.name, shareUsers);
-        if (hintInfo.is(':visible')) {
-            hintInfo.hide();
-        }
-        //搜索的用户信息
-        $('#share').find('.card').hide();
-        $('#sharePhone').val('');
-        $('#sharePhone').focus();
-        shareUserID = null;
-    }
-});
-$('#share').on('hidden.bs.modal', function () {
-    $('#shareUsers').hide();
-    shareUsers = []
-});
 //确认分享
 //确认分享
 $('#share-confirm').click(function(){
 $('#share-confirm').click(function(){
     const hintInfo = $('#share-info');
     const hintInfo = $('#share-info');
-    if (shareUsers.length === 0) {
-        setDangerInfo(hintInfo, '请添加分享');
-        return;
-    }
-    $('#shareUsers').hide();
-    $('#share-confirm').addClass('disabled');
     $.bootstrapLoading.start();
     $.bootstrapLoading.start();
-    let allowCopy = $('#allowCopy').prop('checked');
-    let shareData = [];
-    for (let userData of shareUsers) {
-        shareData.push({userID: userData.userID, allowCopy: userData.allowCopy});
-    }
+    const perHeight = 30;
+    let allowCopy = $('#allowCopy').prop('checked'),
+        userName = $('#user_name').text() || '',
+        userCompany = $('#user_company').text() || '',
+        userMobile = $('#user_mobile').text() || '',
+        userEmail = $('#user_email').text() || '';
+    let shareData = [{userID: shareUserID, allowCopy: allowCopy}];
     //分享
     //分享
     CommonAjax.post('/pm/api/share', {user_id: userID, type: shareType.create,  projectID: shareSeleted.data.ID, shareData: shareData}, function (rstData) {
     CommonAjax.post('/pm/api/share', {user_id: userID, type: shareType.create,  projectID: shareSeleted.data.ID, shareData: shareData}, function (rstData) {
+        //更新已分享table
+        let $tr = $(`<tr>
+                        <td style="width: 112px">${userName}</td>
+                        <td style="width: 165px">${userCompany}</td>
+                        <td style="width: 136px">${userMobile}</td>
+                        <td style="width: 136px">${userEmail}</td>
+                        <td style="width: 90px;"><input value="allowCopy" ${allowCopy ? 'checked' : ''} type="checkbox"></td>
+                        <td style="width: 90px;"><input value="cancelShare" type="checkbox"></td>
+                     </tr>`);
+        let tbodyTotalHeight = $('#shareToInfo').height() + perHeight > 200 ? 200 : $('#shareToInfo').height() + perHeight;
+        $('#shareToInfo').height(tbodyTotalHeight);
+        $('#shareToInfo').append($tr);
         //更新缓存
         //更新缓存
-        if (shareSeleted.data.shareInfo.length === 0) {
+       // if (shareSeleted.data.shareInfo.length === 0) {
             shareSeleted.data.shareInfo = shareSeleted.data.shareInfo.concat(shareData);
             shareSeleted.data.shareInfo = shareSeleted.data.shareInfo.concat(shareData);
             let sheet = projTreeObj.workBook.getSheet(0);
             let sheet = projTreeObj.workBook.getSheet(0);
             projTreeObj.renderSheetFuc(sheet, function () {
             projTreeObj.renderSheetFuc(sheet, function () {
                 sheet.invalidateLayout();
                 sheet.invalidateLayout();
                 sheet.repaint();
                 sheet.repaint();
             });
             });
-        }
+       // }
         $.bootstrapLoading.end();
         $.bootstrapLoading.end();
-        $('#share-confirm').removeClass('disabled');
-        $('#share').modal('hide');
+        $('#shareFindDiv').hide();
+        $('#share-confirm').addClass('disabled');
     }, function () {
     }, function () {
         $.bootstrapLoading.end();
         $.bootstrapLoading.end();
         $('#share-confirm').removeClass('disabled');
         $('#share-confirm').removeClass('disabled');
-        $('#share').modal('hide');
     });
     });
 });
 });
 //允许拷贝
 //允许拷贝
@@ -3522,6 +3446,7 @@ $('#shareToConfirm').click(function () {
 //设置分享给界面数据
 //设置分享给界面数据
 //@param {Object}selected @return {void}
 //@param {Object}selected @return {void}
 function setShareToModal(selected){
 function setShareToModal(selected){
+    const perHeight = 30; //每条分享给数据的高度
     $('#shareToInfo').empty();
     $('#shareToInfo').empty();
     if(!selected){
     if(!selected){
         return;
         return;
@@ -3542,17 +3467,29 @@ function setShareToModal(selected){
             }
             }
         }
         }
         let infoArr = [];
         let infoArr = [];
+        //居中style="width: 90px;text-align: center"
+        let theadHtml = `<tr>
+                                          <th style="width: 112px;">姓名</th>
+                                          <th style="width: 165px;">公司</th>
+                                          <th style="width: 136px;">手机</th>
+                                          <th style="width: 136px;">邮箱</th>
+                                          <th style="width: 90px;">允许拷贝</th>
+                                          <th style="width: 90px;">取消分享</th>
+                               </tr>`;
+        infoArr.push(theadHtml);
         for(let user of selected.data.shareInfo){
         for(let user of selected.data.shareInfo){
             let infoHtml = `<tr>
             let infoHtml = `<tr>
-                                          <td style="width: 106px;">${user.name}</td>
-                                          <td style="width: 146px;">${user.company}</td>
-                                          <td style="width: 146px;">${user.mobile}</td>
-                                          <td style="width: 156px;">${user.email}</td>
-                                          <td style="width: 70px;text-align: center"><input value="allowCopy" ${user.allowCopy ? 'checked' : ''} type="checkbox"></td>
-                                          <td style="width: 70px;text-align: center"><input value="cancelShare" type="checkbox"></td>
+                                          <td style="width: 112px;">${user.name}</td>
+                                          <td style="width: 165px;">${user.company}</td>
+                                          <td style="width: 136px;">${user.mobile}</td>
+                                          <td style="width: 160px;">${user.email}</td>
+                                          <td style="width: 90px;"><input value="allowCopy" ${user.allowCopy ? 'checked' : ''} type="checkbox"></td>
+                                          <td style="width: 90px;"><input value="cancelShare" type="checkbox"></td>
                                </tr>`;
                                </tr>`;
             infoArr.push(infoHtml);
             infoArr.push(infoHtml);
         }
         }
+        let tbodyTotalHeight = infoArr.length * perHeight + 5 > 200 ? 200 : infoArr.length * perHeight + 5;
+        $('#shareToInfo').height(tbodyTotalHeight);
         let infoHtml = infoArr.join('');
         let infoHtml = infoArr.join('');
         $('#shareToInfo').html(infoHtml);
         $('#shareToInfo').html(infoHtml);
     });
     });
@@ -3564,6 +3501,9 @@ function updateShareInfo(selected){
         return;
         return;
     }
     }
     let usersTr = $('#shareToInfo').find('tr');
     let usersTr = $('#shareToInfo').find('tr');
+    if (usersTr && usersTr.length > 0) {
+        usersTr = usersTr.slice(1);
+    }
     let newShareInfo = [];
     let newShareInfo = [];
     for(let i = 0; i < usersTr.length; i++){
     for(let i = 0; i < usersTr.length; i++){
         let userTr = usersTr[i];
         let userTr = usersTr[i];

+ 57 - 15
web/building_saas/pm/js/pm_share.js

@@ -11,6 +11,7 @@
 const pmShare = (function () {
 const pmShare = (function () {
     const spreadDom = $('#shareSpread');
     const spreadDom = $('#shareSpread');
     let spreadObj = {workBook: null, sheet: null};
     let spreadObj = {workBook: null, sheet: null};
+    let preSelection = null;
     //项目分享类型,由别人分享给自己的,和自己分享给别人的
     //项目分享类型,由别人分享给自己的,和自己分享给别人的
     const shareType = {receive: 'receive', shareTo: 'shareTo'};
     const shareType = {receive: 'receive', shareTo: 'shareTo'};
     //操作类型
     //操作类型
@@ -28,9 +29,9 @@ const pmShare = (function () {
     };
     };
     const headers = [
     const headers = [
         {name: '工程列表', dataCode: 'name', width: 300, rateWidth: 0.55, vAlign: 'center', hAlign: 'left'},
         {name: '工程列表', dataCode: 'name', width: 300, rateWidth: 0.55, vAlign: 'center', hAlign: 'left'},
-        {name: '由...分享', dataCode: 'from', width: 100, rateWidth: 0.15, vAlign: 'center', hAlign: 'left'},
-        {name: '拷贝工程', dataCode: 'copy', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
-        {name: '清除', dataCode: 'cancel', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
+        {name: '由...分享', dataCode: 'from', width: 120, rateWidth: 0.15, vAlign: 'center', hAlign: 'left'},
+     /*   {name: '拷贝工程', dataCode: 'copy', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},
+        {name: '清除', dataCode: 'cancel', width: 100, rateWidth: 0.075, vAlign: 'center', hAlign: 'left'},*/
         {name: '工程造价', dataCode: 'engineeringCost', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
         {name: '工程造价', dataCode: 'engineeringCost', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
         {name: '分部分项合计', dataCode: 'subEngineering', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
         {name: '分部分项合计', dataCode: 'subEngineering', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
         {name: '措施项目合计', dataCode: 'measure', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
         {name: '措施项目合计', dataCode: 'measure', width: 100, vAlign: 'center', hAlign: 'right', formatter: '0.00'},
@@ -89,6 +90,7 @@ const pmShare = (function () {
         if(newSel){
         if(newSel){
             setSelStyle(newSel, projTreeObj.setting.style.selectedColor, spreadObj.sheet);
             setSelStyle(newSel, projTreeObj.setting.style.selectedColor, spreadObj.sheet);
         }
         }
+        preSelection = newSel;
     }
     }
     //渲染时方法,停止渲染
     //渲染时方法,停止渲染
     //@param {Object}sheet {Function}func @return {void}
     //@param {Object}sheet {Function}func @return {void}
@@ -123,15 +125,12 @@ const pmShare = (function () {
                 if(headers[i].formatter){
                 if(headers[i].formatter){
                     sheet.setFormatter(-1, i, headers[i].formatter);
                     sheet.setFormatter(-1, i, headers[i].formatter);
                 }
                 }
-                if(headers[i].dataCode === oprType.copy){
+              /*  if(headers[i].dataCode === oprType.copy){
                     //合并列
                     //合并列
                     sheet.addSpan(0, i, 1, 2, GC.Spread.Sheets.SheetArea.colHeader);
                     sheet.addSpan(0, i, 1, 2, GC.Spread.Sheets.SheetArea.colHeader);
                     sheet.setValue(0, i, '操作', GC.Spread.Sheets.SheetArea.colHeader);
                     sheet.setValue(0, i, '操作', GC.Spread.Sheets.SheetArea.colHeader);
                     continue;
                     continue;
-                }
-                if(headers[i].dataCode === '' || headers[i].dataCode === 'feeRateFile_delete'){
-                    continue;
-                }
+                }*/
                 sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
                 sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
                 sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
                 sheet.getRange(-1, i, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[i]['hAlign']]);
                 sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
                 sheet.getRange(-1, i, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[i]['vAlign']]);
@@ -151,7 +150,7 @@ const pmShare = (function () {
         }
         }
     }
     }
     //建表
     //建表
-    //
+    //@return {void}
     function buildSheet(){
     function buildSheet(){
         spreadObj.workBook = new GC.Spread.Sheets.Workbook(spreadDom[0], {sheetCount: 1});
         spreadObj.workBook = new GC.Spread.Sheets.Workbook(spreadDom[0], {sheetCount: 1});
         sheetCommonObj.spreadDefaultStyle(spreadObj.workBook);
         sheetCommonObj.spreadDefaultStyle(spreadObj.workBook);
@@ -173,8 +172,8 @@ const pmShare = (function () {
         }
         }
         return false;
         return false;
     }
     }
-    //
-    //
+    //获取树节点
+    //@param {Object}tree @return {Object}
     function getTreeNodeCell(tree){
     function getTreeNodeCell(tree){
         let indent = 20;
         let indent = 20;
         let levelIndent = -5;
         let levelIndent = -5;
@@ -639,7 +638,7 @@ const pmShare = (function () {
             if (data.userInfo) {
             if (data.userInfo) {
                 data.from = `由 ${data.userInfo.name} 分享`;
                 data.from = `由 ${data.userInfo.name} 分享`;
                 data.to = '分享给 我';
                 data.to = '分享给 我';
-                data.cancel = '清除'
+                data.cancel = '清除';
 
 
                 //拷贝操作只允许到单位工程级
                 //拷贝操作只允许到单位工程级
                 let tendersCanCopy = isAllowCopy(userID, data);
                 let tendersCanCopy = isAllowCopy(userID, data);
@@ -653,6 +652,9 @@ const pmShare = (function () {
     //给项目设置汇总信息
     //给项目设置汇总信息
     //@param {Array}projs {Object}summaryInfo
     //@param {Array}projs {Object}summaryInfo
     function setSummaryInfo(grouped, summaryInfo) {
     function setSummaryInfo(grouped, summaryInfo) {
+        if (!summaryInfo) {
+            return;
+        }
         let allDatas = [];
         let allDatas = [];
         for (let data of grouped) {
         for (let data of grouped) {
             allDatas.push(data);
             allDatas.push(data);
@@ -743,11 +745,12 @@ const pmShare = (function () {
             sortByDate(rstData.grouped);
             sortByDate(rstData.grouped);
             sortByDate(rstData.ungrouped);
             sortByDate(rstData.ungrouped);
             //设置汇总信息
             //设置汇总信息
-            setSummaryInfo(rstData.grouped, rstData.summaryInfo);
+            if (rstData.summaryInfo) {
+                setSummaryInfo(rstData.grouped, rstData.summaryInfo.grouped);
+                setSummaryInfo(rstData.ungrouped, rstData.summaryInfo.ungrouped);
+            }
             let treeDatas = getTreeDatas(rstData.grouped, rstData.ungrouped);
             let treeDatas = getTreeDatas(rstData.grouped, rstData.ungrouped);
-            console.log(treeDatas);
             tree = pmTree.createNew(treeSetting, treeDatas);
             tree = pmTree.createNew(treeSetting, treeDatas);
-            console.log(tree);
             tree.selected = tree.items[0];
             tree.selected = tree.items[0];
             showTreeData(tree.items, headers);
             showTreeData(tree.items, headers);
             //初始选择
             //初始选择
@@ -759,6 +762,44 @@ const pmShare = (function () {
             $.bootstrapLoading.end();
             $.bootstrapLoading.end();
         });
         });
     }
     }
+    //初始化右键菜单
+    function initContextMenu() {
+        $.contextMenu({
+            selector: '#shareSpread',
+            build: function ($trigger, e) {
+                let target = SheetDataHelper.safeRightClickSelection($trigger, e, spreadObj.workBook);
+                initSelection({row: target.row, rowCount: 1}, preSelection ? preSelection : null, spreadObj.sheet);
+                return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
+            },
+            items: {
+                "copy": {
+                    name: "拷贝工程",
+                    icon: 'fa-copy',
+                    disabled: function () {
+                        let selected = tree.selected;
+                        return !(selected && selected.data.copy && selected.data.copy === '拷贝工程');
+                    },
+                    callback: function (key, opt) {
+                        $('#copyShare').modal('show');
+                    }
+                },
+                "cancel": {
+                    name: "清除",
+                    icon: 'fa-remove',
+                    disabled: function () {
+                        let selected = tree.selected;
+                        return !(selected && selected.data.cancel && selected.data.cancel === '清除');
+                    },
+                    callback: function (key, opt) {
+                        let $p = $('<p>').text(`点“确定”按钮,确认清除分享文件 “${tree.selected.data.name}”。`);
+                        $('#cancelShare').find('.modal-body').empty();
+                        $('#cancelShare').find('.modal-body').append($p);
+                        $('#cancelShare').modal('show');
+                    }
+                }
+            }
+        });
+    }
     //初始化视图
     //初始化视图
     //@return void
     //@return void
     function initView(){
     function initView(){
@@ -769,6 +810,7 @@ const pmShare = (function () {
             spreadObj.workBook.destroy();
             spreadObj.workBook.destroy();
             spreadObj.workBook = null;
             spreadObj.workBook = null;
         }
         }
+        initContextMenu();
         buildSheet();
         buildSheet();
         initShareTree();
         initShareTree();
     }
     }

BIN
web/dest/css/img/share.png


BIN
web/dest/css/logo.png