瀏覽代碼

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

chenshilong 6 年之前
父節點
當前提交
0c4813226e

+ 1 - 1
gulpfile.js

@@ -276,7 +276,7 @@ gulp.task('main_css',function () {
     return css(mainOptions);
 })
 
-gulp.task('main_inject',['main_minify','main_css'],function () {
+gulp.task('main_inject',['main_minify'],function () {//,'main_css'
     return inject(mainOptions);
 })
 

+ 3 - 0
modules/glj/controllers/glj_controller.js

@@ -277,6 +277,9 @@ class GLJController extends BaseController {
      * @return {void}
      */
     async getProjectInfo(request, response) {
+        if(typeof request.body.data == "string"){
+            request.body = JSON.parse(request.body.data)
+        }
         let projectId = request.body.project_id;
         let rootProjectID = request.body.rootProjectID;
         projectId = parseInt(projectId);

+ 1 - 1
modules/main/facade/ration_facade.js

@@ -347,7 +347,7 @@ async function getCustomerCoe(projectID,rationID,seq,compilation){//取自定义
         coeID:-1,
         name : '自定义系数',
         content:'人工×1,材料×1,机械×1,主材×1,设备×1',
-        isAdjust:0,
+        isAdjust:1,
         seq:seq,
         rationID : rationID,
         projectID : projectID

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

@@ -872,7 +872,7 @@ async function getPosterityProjects(projectIDs) {
     return rst;
 }
 
-//打开的单位工程是否是被分享的
+//打开的单位工程是否是被分享的.
 async function isShare(userId, project){
     //判断是否是打开分享的项目,属于分享文件的子项也算
     while (project) {

+ 1 - 1
public/web/common_ajax.js

@@ -173,7 +173,7 @@ async function ajaxPost(url, data) {
             cache: false,
             timeout: 50000,
             success: function(result){
-                if (result.error === 0) {
+                if (result.error === 0 || result.err ===0) {
                     resolve(result.data);
                 } else {
                     alert('error: ' + result.message);

+ 18 - 0
public/web/sheet/sheet_common.js

@@ -217,6 +217,24 @@ var sheetCommonObj = {
             sheet.autoFitRow(row);
         }
     },
+    checkData : function(col,setting, value) {
+        let result = true;
+        let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
+        if (validator === null) {
+            return result;
+        }
+        switch (validator) {
+            case 'number':
+                let regular = /^\d+(\.\d+)?$/;
+                result = regular.test(value);
+                break;
+            case 'boolean':
+                let booleanValue = [true, false];
+                result = booleanValue.indexOf(value) >= 0;
+                break;
+        }
+        return result;
+    },
     //todo
     analyzePasteData: function(setting, pastedInfo) {
         var rst = [], propId = pastedInfo.cellRange.col, preStrIdx = 0, itemObj = {};//propId = 0 to proId = pastedInfo.cellRange.col, update by zhong

+ 2 - 0
public/web/slideResize.js

@@ -156,6 +156,8 @@ const SlideResize = (function() {
                 eleObj.topSpread.height(topChange - limit.notTopSpread);
                 //设置下部分div高度
                 eleObj.bottom.height(bottomChange);
+                console.log(eleObj.bottom);
+                console.log(bottomChange);
                 //设置下部分div内spread高度
                 eleObj.bottomSpread.height(bottomChange - limit.notBottomSpread);
                 mouseMoveCount += Math.abs(moveSize);

+ 2 - 1
web/building_saas/complementary_ration_lib/js/coe.js

@@ -31,6 +31,7 @@ $(document).ready(function () {
     leftElesObj.right = $('#mainContent');
     let maxEval = `$('#zmhsContent').is(':visible') ? $('#dataRow').width() - $('#zmhsContent').width() - 300 : $('#dataRow').width()  - 300`;
     SlideResize.horizontalSlide(leftElesObj, {min: 300, max: maxEval}, function () {
+        sectionTreeObj.loadRateWidth();
         refreshALlWorkBook();
     });
     SlideResize.loadHorizonWidth(moduleName, [$('#slideResizeLeft')], [$('#leftContent'), $('#mainContent')], function () {
@@ -40,7 +41,6 @@ $(document).ready(function () {
         let surplus = 100 - leftContentWidth - mainContentWidth;
         $('#leftContent').css('width', `${leftContentWidth + surplus / 2}%`);
         $('#mainContent').css('width', `${mainContentWidth + surplus / 2}%`);
-
         refreshALlWorkBook();
     });
     //定额表与子目换算表
@@ -105,6 +105,7 @@ $(document).ready(function () {
         for (let resize of resizes) {
             setResizeWidth(resize);
         }
+        sectionTreeObj.loadRateWidth();
     }
     $('#zmhs').click(function () {
         if(!$(this).hasClass('active')){

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

@@ -27,6 +27,7 @@ function autoFlashHeight(){
     $('#ruleTextShow').height($(window).height()-headerHeight-toolsBar-100);
     typeof loadRationSubSize !== 'undefined' ? loadRationSubSize() : '';
     typeof loadZmhsAdjSize !== 'undefined' ? loadZmhsAdjSize() : '';
+    typeof sectionTreeObj !== 'undefined' ? sectionTreeObj.loadRateWidth() : '';
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/

+ 6 - 28
web/building_saas/complementary_ration_lib/js/section_tree.js

@@ -44,33 +44,6 @@ let pageOprObj = {
     getRationLibInfo: function (rationLibId, callback) {
         CommonAjax.post('api/getRationLib', {rationRepId: rationLibId}, callback);
     },
-    //获取定额库列表
-    /*getRationLibs: function () {
-        let scFunc = function (rstData) {
-            $("#comple_ration_table").empty();
-            for(let i = 0; i < rstData.length; i++){
-                storageUtil.setSessionCache("RationGrp","repositoryID_" + rstData[i].ID, rstData[i].dispName);
-                if(rstData[i].gljLib !== undefined && rstData[i].gljLib && rstData[i].gljLib != -1){
-                    storageUtil.setSessionCache("gljLib","repositoryID_" + rstData[i].ID, rstData[i].gljLib);
-                    let id = rstData[i].ID;
-                    let libName = rstData[i].dispName;
-                    $("#comple_ration_table").append(
-                        "<tr id='tempId'>" +
-                        "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td></tr>"
-                    );
-                    var newHref = "/complementaryRation/ration?repository="+id;
-                    $("#tempId td:first a").attr("href", newHref);
-                    $("#tempId").attr("id", id);
-                }
-            }
-        };
-        let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
-        let ids = [];
-        for(lib of ration_lib){
-            ids.push(parseInt(lib.id));
-        }
-        CommonAjax.post('/complementaryRation/api/getRationLibs', {user_id: userID, ids: ids}, scFunc);
-    }*/
 };
 
 let sectionTreeObj = {
@@ -245,7 +218,11 @@ let sectionTreeObj = {
             });
         }
     },
-
+    loadRateWidth: function () {
+        if (this.workBook) {
+            sheetCommonObj.setColumnWidthByRate($('#sectionSpread').width() - 65, this.workBook, [{rateWidth: 1}]);//65: 列头宽度和垂直滚动条宽度和
+        }
+    },
     getSectionTree: function () {
         let me = sectionTreeObj;
         let url = 'api/getRationTree';
@@ -265,6 +242,7 @@ let sectionTreeObj = {
             me.setColor(me.cache);
             me.sheet.setFormatter(-1, 0, '@');
             me.initSelection(me.tree.selected);
+            me.loadRateWidth();
             //explanatoryOprObj.bindEvents($('#explanationShow'), $('#ruleTextShow'));
         };
         let errFunc = function () {

+ 4 - 0
web/building_saas/css/custom.css

@@ -295,4 +295,8 @@ input.text-right{
     bottom:30px;
     left:0px;
     z-index: 999
+}
+
+.zmhs-link{
+    padding:0.4em 0.4em !important;
 }

+ 33 - 16
web/building_saas/main/html/main.html

@@ -7,7 +7,7 @@
     <meta http-equiv="x-ua-compatible" content="ie=edge">
     <title><%= projectData.name !== undefined ? projectData.name : '造价书' %>-纵横建筑云计价</title>
 
-    <!-- inject:css -->
+
     <link rel="stylesheet" href="/lib/jquery-ui/jquery-ui.css" type="text/css">
     <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
@@ -24,7 +24,7 @@
     <link rel="stylesheet" href="/lib/spreadjs/views/gc.spread.views.dataview.10.0.0.css">
     <!-- jquery.contextmenu -->
    <!-- <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">-->
-    <!-- endinject -->
+   
     <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico">
     <link rel="icon" type="image/gif" href="/web/building_saas/css/animated_favicon1.gif">
     <style type="text/css">
@@ -228,7 +228,7 @@
                                           <div class="resize-x main-data-bottom ovf-hidden" id="rgResize" style="display: none"></div>
                                           <div class="item_spread main-data-bottom ovf-hidden " id="gljSubDiv" style="width: 99%;">
                                               <div class="tab-content">
-                                                  <div class="tab-pane" id="rnc-xm">
+                                                  <div class="tab-pane" id="rnc-xm" >
                                                       <div class="main-data-bottom ovf-hidden" id="itemCharacterText">
                                                           项目特征 内容
                                                       </div>
@@ -237,6 +237,10 @@
                                                       <div class="main-data-bottom ovf-hidden" id = "coeSpread">
                                                       </div>
                                                   </div>
+                                                  <div class="tab-pane" id="rnc-cus">
+                                                      <div class="main-data-bottom ovf-hidden" id = "cusSpread">
+                                                      </div>
+                                                  </div>
                                                   <div class="tab-pane" id="rnc-fz">
                                                       <div class="main-data-bottom ovf-hidden" id="assSpread"></div>
                                                   </div>
@@ -252,16 +256,28 @@
                                           </div>
                                           <div class=" main-data-bottom ovf-hidden col-auto p-0" id="gljItemTab" style="width: 30px">
                                               <div class="rn-nav d-flex align-items-start flex-column gljSubTab">
-                                                  <ul class="nav nav-tabs">
-                                                      <li class="nav-item" data-toggle="tooltip" data-placement="left" title="项目特征">
-                                                          <a data-toggle="tab" href="#rnc-xm" role="tab" class="nav-link "><i class="fa fa-info-circle"></i><span>项目特征</span></a>
-                                                      </li>
-                                                      <li class="nav-item" data-toggle="tooltip" data-placement="left" title="子目换算"><a data-toggle="tab" href="#rnc-zm" role="tab"class="nav-link"><i class="fa fa-exchange"></i><span>子目换算</span></a></li>
-                                                      <li class="nav-item" data-toggle="tooltip" data-placement="left" title="辅助定额"><a data-toggle="tab" href="#rnc-fz" role="tab"class="nav-link"><i class="fa fa-wrench"></i><span>辅助定额</span></a></li>
-                                                    <!--  <li class="nav-item"><a data-toggle="tab" href="#rnc-xm" role="tab"  class="nav-link">项目特征</a></li>
-                                                      <li class="nav-item"><a data-toggle="tab" href="#rnc-zm" role="tab" class="nav-link">子目换算</a></li>
-                                                      <li class="nav-item"><a data-toggle="tab" href="#rnc-fz" role="tab" class="nav-link">辅助定额</a></li>-->
-                                                  </ul>
+                                                  <div id="zmhs_toogle">
+                                                      <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>
+                                                      </div>
+                                                  </div>
+                                                  <!--<a  role="tab" class="zmhs-link nav-link">子目换算</a>-->
+                                                  <div id="zmhs_nav" style="display: none">
+                                                      <ul class="nav nav-tabs">
+                                                          <li class="nav-item" data-toggle="tooltip" data-placement="left" title="收起">
+                                                              <a data-toggle="tab" href="#rnc-close" role="tab" class="zmhs-link nav-link"><i class="fa fa-arrow-right"></i></a>
+                                                          </li>
+                                                          <li class="nav-item" data-toggle="tooltip" data-placement="left" title="项目特征">
+                                                              <a data-toggle="tab" id="xm-nav" href="#rnc-xm" role="tab" class="zmhs-link nav-link"><i class="fa fa-info-circle"></i></a>
+                                                          </li>
+                                                          <li class="nav-item" data-toggle="tooltip" data-placement="left" title="附注条件"><a data-toggle="tab" href="#rnc-zm" role="tab"class="zmhs-link nav-link"><i class="fa fa-check-circle-o"></i></a></li>
+                                                          <li class="nav-item" data-toggle="tooltip" data-placement="left" title="自定义系数"><a data-toggle="tab" href="#rnc-cus" role="tab"class="zmhs-link nav-link"><i class="fa fa-wrench"></i></a></li>
+                                                          <li class="nav-item" data-toggle="tooltip" data-placement="left" title="增减换算"><a data-toggle="tab" href="#rnc-fz" role="tab"class="zmhs-link nav-link "><i class="fa fa-plus"></i></a></li>
+                                                        <!--  <li class="nav-item"><a data-toggle="tab" href="#rnc-xm" role="tab"  class="nav-link">项目特征</a></li>
+                                                          <li class="nav-item"><a data-toggle="tab" href="#rnc-zm" role="tab" class="nav-link">子目换算</a></li>
+                                                          <li class="nav-item"><a data-toggle="tab" href="#rnc-fz" role="tab" class="nav-link">辅助定额</a></li>-->
+                                                      </ul>
+                                                  </div>
                                               </div>
                                           </div>
                                       </div>
@@ -419,11 +435,11 @@
                                       </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="col-6 p-0">
                                                   <div class="main-data-bottom ovf-hidden" id="elfItems">
                                                   </div>
                                               </div>
-                                              <div class="col-2 p-1">
+                                              <div class="col-6 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>
@@ -525,7 +541,8 @@
                                       <div class="side-search-box col-12 p-2" id="billsGuidanceSearchResult" style="display: none;">
                                           <div class="d-flex justify-content-between">
                                               <span id = 'billsGuidanceSearchResultCount'>搜索结果:5</span>
-                                              <a class="btn btn-secondary btn-sm" href="javascript:void(0);" id="nextBillsGuidance">查找下一条</a>
+                                              <a class="btn btn-secondary btn-sm" href="javascript:void(0);" id="preBillsGuidance">上一条</a>
+                                              <a class="btn btn-secondary btn-sm" href="javascript:void(0);" id="nextBillsGuidance">下一条</a>
                                               <a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0);" id="closeSearchBillsGuidance"><i class="fa fa-remove" aria-hidden="true"></i></a>
                                           </div>
                                       </div>

+ 5 - 2
web/building_saas/main/js/main.js

@@ -59,14 +59,17 @@ function getMainResizeEles() {
         bottomSpread: $('#bottom_div').children().find('.main-data-bottom'),
     };
     mainResizeEles.limit = {
-        min: 150,
-        max: `$(window).height()-$('.header').height()-$('#headerToolsBar').height()-150-10`,
+        min: 180,
+        max: `$(window).height()-$('.header').height()-$('#headerToolsBar').height()-180-10`,
         notTopSpread: 0,
         notBottomSpread: $('#bottom_div ul').height(),
         totalHeight: `$(window).height()-$('.header').height()-$('#headerToolsBar').height()-10`
     };
     return mainResizeEles;
 }
+function getMaxLim(ele) {
+    $(window).height()-$('.header').height()-$('#headerToolsBar').height()-150-10
+}
 
 function loadMainSize() {//加载造价书页面各高度
     // 读取本地存储的高度(必须放在载入spread之前)

+ 4 - 3
web/building_saas/main/js/models/ration_coe.js

@@ -38,7 +38,7 @@ var ration_coe = {
         };
         ration_coe.prototype.refreshAfterSave=function(data){
             projectObj.project.ration_coe.addDatasToList(data);
-            zmhs_obj.showCoeData();
+            zmhs_obj.showDatas();
         };
 
         ration_coe.prototype.addDatasToList = function (datas) {
@@ -63,13 +63,14 @@ var ration_coe = {
             _.forEach(data.doc, function(n, key) {
                 coe_list[coe_index][key] = n;
             });
-            zmhs_obj.showCoeData();
+            $('#coeSpread').is(':visible'),
+            zmhs_obj.showDatas();
         };
         ration_coe.prototype.refreshAfterDelete=function(data){
             var glj_list = projectObj.project.ration_coe.datas;
             _.remove(glj_list,data.query);
             _.remove(gljOprObj.sheetData,data.query);
-            zmhs_obj.showCoeData();
+            zmhs_obj.showDatas();
         };
 
         ration_coe.prototype.getRationCoedata=function(newRation,data){

+ 3 - 31
web/building_saas/main/js/views/billsElf.js

@@ -72,8 +72,8 @@ const BillsElf = (function() {
             ]
         },
         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: '@'},
+            {name: '施工工序', dataCode: 'name', width: 180, rateWidth: 0.5, vAlign: 'center', hAlign: 'center', formatter: '@'},
+            {name: '选项', dataCode: 'options', width: 180, rateWidth: 0.5,  vAlign: 'center', hAlign: 'left', formatter: '@'},
         ],
         rowHeaderWidth:25,
         events: {
@@ -205,7 +205,7 @@ const BillsElf = (function() {
             }
             setOptions(elfItem.workBook, options);
             buildHeader(elfItem.workBook.getActiveSheet(), elfItem.headers);
-            setColumnWidthByRate(elfItem.workBook, $('#elfItems').width(), elfItem.headers);
+            //setColumnWidthByRate(elfItem.workBook, $('#elfItems').width(), elfItem.headers);
             bindEvent(elfItem.workBook, elfItem.events);
         }
     }
@@ -247,7 +247,6 @@ const BillsElf = (function() {
                 billsNode.elf.tree.selected = node;
             }
         }
-        refreshInsertSingle();
     }
     //清单焦点变换-清单精灵操作,获取清单前九位编码的标准清单清单精灵选项
     //@param {String}code @return {void}
@@ -255,8 +254,6 @@ const BillsElf = (function() {
         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);
@@ -311,7 +308,6 @@ const BillsElf = (function() {
                     setOptionsCellType(node.elf.tree.items);
                     //项目指引初始焦点
                     elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
-                    refreshInsertRation();
                 });
             });
         }
@@ -321,7 +317,6 @@ const BillsElf = (function() {
                 setOptionsCellType(node.elf.tree.items);
                 //项目指引初始焦点
                 elfItemInitSel(elfSheet.getActiveRowIndex() ? elfSheet.getActiveRowIndex() : 0);
-                refreshInsertRation();
             });
         }
     }
@@ -530,8 +525,6 @@ const BillsElf = (function() {
             }
             TREE_SHEET_HELPER.refreshTreeNodeData(elfItem.treeSetting, elfSheet, node.tree.items, false);
             setOptionsCellType(node.tree.items);
-            refreshInsertRation();
-            refreshInsertSingle();
         }
         //获取删除节点
         function getDeleteNodes(node, optionChecked) {
@@ -723,31 +716,10 @@ const BillsElf = (function() {
     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(){

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

@@ -947,7 +947,8 @@ projectGljObject={
         return supply_quantity
     },
     checkData : function(col,setting, value) {
-        let result = true;
+        return sheetCommonObj.checkData(col,setting, value);
+     /*   let result = true;
         let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
         if (validator === null) {
             return result;
@@ -962,7 +963,7 @@ projectGljObject={
                 result = booleanValue.indexOf(value) >= 0;
                 break;
         }
-        return result;
+        return result;*/
     },
     getProjectGLJSelected:function () {
         let me = projectGljObject;

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

@@ -7,7 +7,7 @@ $(window).resize(function() {
     billsGuidance.setColumnWidthByRate(billsGuidance.elfItem.workBook, $('#zy').width(), billsGuidance.elfItem.headers);
     billsGuidance.refreshWorkBook();
     rationLibObj.refreshSpread();
-    BillsElf.setColumnWidthByRate();
+    //BillsElf.setColumnWidthByRate();
     loadSideToolsHeight();
     //刷新主界面与各库中间的拖动条宽度:始终保持为一个宽度(在小窗口打开一个库,再放大窗口后,该拖动条宽度会变大)
     SlideResize.setResizeWidth($('#sideResize'));
@@ -32,7 +32,7 @@ SlideResize.horizontalSlide(sideResizeEles.eleObj, sideResizeEles.limit, functio
    // MaterialController.showReplaceDiv();
     subObj.initGljSubTab();
     pageCCOprObj.resizeWidth();
-    BillsElf.setColumnWidthByRate();
+    //BillsElf.setColumnWidthByRate();
     projectObj.refreshMainSpread();
     refreshSubSpread();
     if (sideResizeEles.eleObj.module === 'stdBillsGuidanceTab') {//清单精灵(规则)
@@ -199,7 +199,7 @@ var sideToolsObj = {
         pageCCOprObj.resizeWidth();
         billsGuidance.refreshWorkBook();
         billsLibObj.refreshBillsSpread();
-        BillsElf.setColumnWidthByRate();
+        //BillsElf.setColumnWidthByRate();
         refreshSubSpread();
         billsLibObj.refreshBillsRelaSpread();
         rationLibObj.refreshSpread();//subSpread、jobSpread、itemSpread显示问题

+ 24 - 3
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -719,8 +719,10 @@ const billsGuidance = (function () {
         let billsSheet = bills.workBook.getActiveSheet();
         renderSheetFunc(billsSheet, function () {
             function expParentNode(node){
-                if(node.parent && !node.parent.expanded){
-                    node.parent.setExpanded(true);
+                if(node.parent){
+                    if (!node.parent.expanded) {
+                        node.parent.setExpanded(true);
+                    }
                     expParentNode(node.parent);
                 }
             }
@@ -788,7 +790,7 @@ const billsGuidance = (function () {
                 });
                 //搜索初始定位
                 billsSheet.showRow(result[0].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
-
+                //查找下一条
                 $('#nextBillsGuidance').show();
                 $('#nextBillsGuidance').unbind('click');
                 $('#nextBillsGuidance').bind('click', function () {
@@ -803,12 +805,30 @@ const billsGuidance = (function () {
                         billsSheet.showRow(result[resultIndex + 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
                     }
                 });
+                //查找上一条
+                $('#preBillsGuidance').show();
+                $('#preBillsGuidance').unbind('click');
+                $('#preBillsGuidance').bind('click', function () {
+                    let cur = bills.tree.selected, resultIndex = result.indexOf(cur), sel = billsSheet.getSelections();
+                    if (resultIndex === 0) {
+                        bills.controller.setTreeSelected(result[result.length - 1]);
+                        billsSheet.setSelection(result[result.length - 1].serialNo(), sel[0].col, 1, 1);
+                        billsSheet.showRow(result[result.length - 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
+                    } else {
+                        bills.controller.setTreeSelected(result[resultIndex - 1]);
+                        billsSheet.setSelection(result[resultIndex - 1].serialNo(), sel[0].col, 1, 1);
+                        billsSheet.showRow(result[resultIndex - 1].serialNo(), GC.Spread.Sheets.VerticalPosition.bottom);
+                    }
+                });
             } else {
                 billsLibObj.clearHighLight(bills.workBook);
                 $('#nextBillsGuidance').hide();
+                $('#preBillsGuidance').hide();
             }
             $('#billsGuidanceSearchResultCount').text('搜索结果:' + result.length);
             $('#billsGuidanceSearchResult').show();
+            autoFlashHeight();
+            refreshWorkBook();
         });
         //搜索框回车
         $('#stdBillsGuidanceSearch>input').bind('keypress', function (event) {
@@ -821,6 +841,7 @@ const billsGuidance = (function () {
         $('#closeSearchBillsGuidance').click(function () {
             $('#billsGuidanceSearchResult').hide();
             billsLibObj.clearHighLight(bills.workBook);
+            autoFlashHeight();
             refreshWorkBook();
         });
     }

+ 1 - 1
web/building_saas/main/js/views/std_ration_lib.js

@@ -723,7 +723,7 @@ function seachRation(){
             resultObj.hide();
             $(".main-data-side-search", resultObj).height(0);
             autoFlashHeight();
-            rationLibObj.refreshSpread();
+            loadSideToolsHeight();
         });
         resultObj.show();
         $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);

+ 25 - 10
web/building_saas/main/js/views/sub_view.js

@@ -135,8 +135,7 @@ let subObj = {
     },
     showGljSubTabData:function () {
         this.initGljSubTab();
-        if($('#rnc-zm').is(':visible')) zmhs_obj.showCoeData();
-        if($('#rnc-fz').is(':visible')) zmhs_obj.showAssData();
+        zmhs_obj.showDatas();
         refreshSubSpread();
     }
 };
@@ -716,16 +715,32 @@ $('#linkAZZJF').on('shown.bs.tab', function () {
     gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected, '111111');
 });
 
+$('#zmhs_toogle').bind('click',function (){
+   $("#zmhs_nav").show();
+   if(subObj.showGljSubTab == false){
+       subObj.activeTab?$(subObj.activeTab).click():$("#xm-nav").click();
+   }
+    $("#zmhs_toogle").hide();
+});
+
 $('.gljSubTab ul li a').bind('click',function () {
-    if($(this).hasClass("active")){//点击展开了后又点击了自身,这时要隐藏tab和修改本身class
-        subObj.showGljSubTab = false;
+    if(this.hash =="#rnc-close"){
+        $("#zmhs_nav").hide();
+        $("#zmhs_toogle").show();
         closeTab(this);
-        subSpread.focus();//要加上这个,不然右边侧栏的选中状态的border线不会消换
-    }else {
+        subObj.showGljSubTab = false;
+    } else {
         subObj.showGljSubTab = true;
+        subObj.activeTab =this;
     }
+
     subObj.initGljSubTab();
     refreshSubSpread();
+    /* if($(this).hasClass("active")){//点击展开了后又点击了自身,这时要隐藏tab和修改本身class
+     subObj.showGljSubTab = false;
+     closeTab(this);
+     subSpread.focus();//要加上这个,不然右边侧栏的选中状态的border线不会消换
+     }*/
 });
 
 $('.gljSubTab ul li a').on('shown.bs.tab', function () {
@@ -733,13 +748,13 @@ $('.gljSubTab ul li a').on('shown.bs.tab', function () {
         MaterialController.showItemCharacterText();
     }else if(this.hash == "#rnc-zm"){
         zmhs_obj.initCoeSpread();
-        zmhs_obj.refresh();
-        zmhs_obj.showCoeData();
     }else if(this.hash == "#rnc-fz"){
         zmhs_obj.initAssSpread();
-        zmhs_obj.refresh();
-        zmhs_obj.showAssData();
+    }else if(this.hash == "#rnc-cus"){
+        zmhs_obj.initCusSpread();
     }
+    zmhs_obj.refresh();
+    zmhs_obj.showDatas();
 });
 
 function closeTab(elem) {

+ 101 - 4
web/building_saas/main/js/views/zmhs_view.js

@@ -30,6 +30,19 @@ let zmhs_obj = {
         autoFit:true,
         fitRow:['name']
     },
+    cusSpread:null,
+    cusSheet:null,
+    cusSheetData:null,
+    cusSetting:{
+        header: [
+            {headerName: "类型", headerWidth: 250, dataCode: "coeType", dataType: "String",hAlign: "left"},
+            {headerName: "系数", headerWidth: 160, dataCode: "amount", dataType: "String", hAlign: "right",validator:"number"}
+        ],
+        view: {
+            lockColumns:["coeType"],
+            rowHeaderWidth:25
+        }
+    },
     assSpread:null,
     assSheet:null,
     assSheetData: [],
@@ -64,6 +77,18 @@ let zmhs_obj = {
             SheetDataHelper.protectdSheet(this.coeSheet);
         }
     },
+    initCusSpread:function () {
+        if(zmhs_obj.cusSpread == null){
+            this.cusSpread = SheetDataHelper.createNewSpread($("#cusSpread")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.cusSpread);
+            this.cusSheet = this.cusSpread.getSheet(0);
+            sheetCommonObj.initSheet(this.cusSheet, this.cusSetting, 30);
+            this.cusSheet.name('ration_cus');
+            this.cusSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onCusValueChange);
+            this.cusSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onCusRangeChanged);
+            SheetDataHelper.protectdSheet(this.cusSheet);
+        }
+    },
     initAssSpread:function () {
         if(zmhs_obj.assSheet == null){
             this.assSpread = SheetDataHelper.createNewSpread($("#assSpread")[0]);
@@ -83,7 +108,9 @@ let zmhs_obj = {
         if(selected&&selected.sourceType == "ration"){
             let ration = selected.data;
             coeList = ration_coe.getCoeByRationID(ration.ID);
+            _.remove(coeList,{"coeID":-1})//2018-12-24 新需求,把自定义乘系数分离出来,这里排除自定义乘系数行
         }
+        this.coeSheet.setRowCount(0);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
         if (coeList.length > 0) {
             this.coeSheet.suspendPaint();
@@ -105,16 +132,32 @@ let zmhs_obj = {
             disableSpread(zmhs_obj.coeSpread);
         }
     },
+    showCusData:function (node) {
+        let selected = node?node:projectObj.project.mainTree.selected;
+        let ration_coe = projectObj.project.ration_coe;
+        let cusList = [];
+        if(selected&&selected.sourceType == "ration"){
+            let ration = selected.data;
+            let coeList = ration_coe.getCoeByRationID(ration.ID);
+            this.cusSheetData = _.find(coeList,{"coeID":-1});
+            if(this.cusSheetData) cusList = this.cusSheetData.coes;
+        }
+        sheetCommonObj.showData(this.cusSheet, this.cusSetting,cusList);
+        this.cusSheet.getRange(cusList.length,-1,this.cusSheet.getRowCount()-cusList.length, -1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
+        if(projectReadOnly){
+            disableSpread(zmhs_obj.cusSpread);
+        }
+    },
+
     getComboBoxForCodes:function (coe,i) {
         this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
         let options = coe.option_codes.split("|");
         let combo = sheetCommonObj.getDynamicCombo(true);
-        combo.itemHeight(options.length).items(options);
+        combo.items(options);//itemHeight(options.length).
         this.coeSheet.setCellType(i, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
         this.coeSheet.setValue(i, 2, coe.select_code);
 
     },
-
     showAssData:function (node) {
         this.assSheet.suspendPaint();
         this.assSheet.suspendEvent();
@@ -186,8 +229,14 @@ let zmhs_obj = {
 
 
     refresh:function () {
-        this.coeSpread?this.coeSpread.refresh():'';
-        this.assSpread?this.assSpread.refresh():'';
+        $('#coeSpread').is(':visible')&&this.coeSpread?this.coeSpread.refresh():'';
+        $('#cusSpread').is(':visible')&&this.cusSpread?this.cusSpread.refresh():'';
+        $('#assSpread').is(':visible')&&this.assSpread?this.assSpread.refresh():'';
+    },
+    showDatas:function () {
+        if($('#coeSpread').is(':visible')) this.showCoeData();
+        if($('#cusSpread').is(':visible')) this.showCusData();
+        if($('#assSpread').is(':visible')) this.showAssData();
     },
     showZMHSData:function (node) {
         if(this.coeSpread&& this.assSpread && $('#linkZMHS').hasClass('active')){
@@ -347,7 +396,47 @@ let zmhs_obj = {
             projectObj.project.ration_coe.adjustCoeClick(recode, 1,{'select_code':args.newValue});
         }
     },
+    onCusValueChange:function (e,args) {
+      zmhs_obj.changeCusValue([{row:args.row,col:args.col,value:args.newValue}]);
+    },
+    changeCusValue:function (datas) {//[{row:,col,value}]
+        if(this.cusSheetData){
+            let tem_coes = _.cloneDeep(this.cusSheetData.coes);
+            for(let d of datas){
+                if(d.value&&!sheetCommonObj.checkData(d.col,this.cusSetting,d.value)){
+                    this.showDatas();
+                    alert('输入的数据类型不对,请重新输入!');
+                    return;
+                }
+                if(gljUtil.isDef(d.value)&&d.value !=""){
+                    if(tem_coes[d.row].coeType=="定额"){
+                        for(let t of tem_coes){
+                            t.amount = d.value;
+                        }
+                    }else {
+                        tem_coes[d.row].amount = d.value;
+                    }
+                }
+            }
+            let doc = {'coes':tem_coes,'content':this.generationContent(tem_coes)};
+            projectObj.project.ration_coe.adjustCoeClick(this.cusSheetData, 1,doc);
+        }
+    },
+    generationContent:function (coes) {
+        let rationAmount = coes[0].amount;
+        let string ='';
+        if(_.every(coes,'amount',rationAmount)){
+            string = coes[0].coeType + 'x'+rationAmount;
+        }else {
+            let context_arr =[];
+            for(let i =1;i<coes.length;i++){
+                context_arr.push( coes[i].coeType + 'x'+coes[i].amount);
+            }
+            string = context_arr.join(',');
 
+        }
+        return string;
+    },
     onAssEditEnded:function (e,args) {
         var me = zmhs_obj;
         if (args.row >= me.assSheetData.length) {
@@ -358,6 +447,14 @@ let zmhs_obj = {
             me.updateRationAss(args);
         }
     },
+    onCusRangeChanged:function (e,args) {
+        let datas = [];
+        for(let c of args.changedCells){
+            let value=  args.sheet.getCell(c.row, c.col).text();
+            datas.push({row:c.row,col:c.col,value:value})
+        }
+        zmhs_obj.changeCusValue(datas);
+    },
     onAssRangeChanged:function (e,args) {
         let me = zmhs_obj;
         if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {

+ 70 - 0
web/building_saas/pm/html/project-management.html

@@ -614,6 +614,76 @@
         </div>
     </div>
 </div>
+
+<!--弹出 批量替换单价文件-->
+<div class="modal fade" id="m_replace_file" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="mr_title">批量替换单价文件</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <input type="hidden" id="mr_from">
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-6">
+                        <h5>选择项目</h5>
+                        <div class="modal-auto-height">
+                            <div id="replaceSpread" style="height: 100%"></div>
+                        </div>
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="customCheck1">
+                            <label class="custom-control-label" for="customCheck1">自动勾选同专业工程</label>
+                        </div>
+                    </div>
+                    <div class="col-6">
+                        <h5>更换为</h5>
+                        <div class="form-group">
+                            <div class="custom-control custom-radio custom-control-inline">
+                                <input type="radio" id="customRadioInline33" name="select_from" value="0" class="custom-control-input" checked>
+                                <label class="custom-control-label" for="customRadioInline33">从本建设项目中选择</label>
+                            </div>
+                            <div class="custom-control custom-radio custom-control-inline">
+                                <input type="radio" id="customRadioInline44" name="select_from" value="1" class="custom-control-input">
+                                <label class="custom-control-label" for="customRadioInline44">从其他建设项目中复制</label>
+                            </div>
+                        </div>
+                        <!--从本建设项目中选择-->
+                        <label id="project_name">9.21<!--本建设项目名称--></label>
+                        <div class="form-group" id = "fromProject">
+                            <select class="form-control" id="currentOptions">
+                                <option>测试5单价文件</option><!--单价文件-->
+                            </select>
+                        </div>
+                        <!--从其他建设项目中复制-->
+                        <div id = "fromOther">
+                            <div class="form-group" >
+                                <label>选择建设项目</label>
+                                <select class="form-control" id="otherProject" >
+                                    <option>10.9建筑例题内测</option><!--建设项目-->
+                                </select>
+                            </div>
+                            <div class="form-group">
+                                <select class="form-control" id="otherFileOptions">
+                                    <option>10.9建筑例题内测单价文件</option><!--建设项目下单价文件-->
+                                </select>
+                                <span class="form-text text-muted">你选择的单价文件将复制一份至新项目,不会影响原建设项目的单价文件。</span>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                <a href="" class="btn btn-primary mr-3">确定</a>
+            </div>
+        </div>
+    </div>
+</div>
+
 <!--弹出删除 单价/费率 文件-->
 <div class="modal fade" id="del-wj" data-backdrop="static">
     <div class="modal-dialog" role="document">

+ 204 - 81
web/building_saas/pm/js/pm_newMain.js

@@ -55,8 +55,10 @@ const projTreeObj = {
     tree: null,
     workBook: null,
     copyToWorkBook:null,
+    replaceWorkBook:null,
     copySelected:null,
     preSelection: null,
+    changeInfo:null,
     setting: {
         tree: {
             id: 'ID',
@@ -116,7 +118,28 @@ const projTreeObj = {
             allowUserDragFill: false,
             scrollbarMaxAlign : true,
             showDragDropTip:false
-        }},
+        }
+    },
+    replaceSetting:{
+        header: [
+            {name: '工程列表', dataCode: 'name', width: 250, vAlign: 'center', hAlign: 'left'},
+            {name: '选择', dataCode: 'selected', width: 50, vAlign: 'center', cellType:'checkBox'}
+        ],
+        //选中行颜色
+        style: {
+            defalutBackColor: 'White',
+            selectedColor: '#BBFFFF'
+        },
+        options: {
+            tabStripVisible:  false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true,
+            showDragDropTip:false
+        }
+    },
     renderSheetFuc: function (sheet, fuc) {
         sheet.suspendPaint();
         sheet.suspendEvent();
@@ -137,6 +160,7 @@ const projTreeObj = {
         sheet.bind(_events.EditStarting, this.onCellEditing);
         sheet.bind(_events.ClipboardPasting,this.onCellEditing);
         workBook.bind(_events.DragDropBlock, this.onDragDropBlock);
+        workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, this.changeFileClick)
     },
     buildHeader: function (sheet, headers) {
         let me = this;
@@ -472,6 +496,14 @@ const projTreeObj = {
         let me = projTreeObj;
         me.initSelection(args.newSelections[0], args.oldSelections[0],args.sheet);
     },
+    changeFileClick:async function (sender,args) {
+        if(args.sheet.name() == "projectSheet"){
+            await projTreeObj.initFileChangePage(projTreeObj.setting.header[args.col].dataCode);
+            $("#mr_from").val(projTreeObj.setting.header[args.col].dataCode);
+            $("#project_name").text(projTreeObj.tree.selected.data.name);
+            $('#m_replace_file').modal('show');
+        }
+    },
     onDragDropBlock : function (sender,args) {//拖动移动项目位置
         let selected = projTreeObj.tree.selected;
         let targetNode = projTreeObj.tree.items[args.toRow];
@@ -837,7 +869,7 @@ const projTreeObj = {
             function withingClickArea(){
                 return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
             }
-            if(hitinfo.sheet.name() != "copyToSheet"){//如果是复制到sheet,不用执行
+            if(hitinfo.sheet.name() === "projectSheet"){//只有项目管理界面才执行
                 //单项文件,进入造价书界面
                  if(node.data.projType === projectType.tender && withingClickArea()){
                     let timeoutTime = 200;
@@ -909,10 +941,11 @@ const projTreeObj = {
         }
         return new TreeNodeCellType();
     },
-    setCellValue: function (cell, node,sheet) {
+    setCellValue: function (cell, node,sheet,setting) {
         //const sheet = this.workBook.getActiveSheet();
+        if(!setting) setting = this.setting;
         const {row, col} = cell;
-        let dataCode = this.setting.header[col]['dataCode'];
+        let dataCode = setting.header[col]['dataCode'];
         let value = '';
         if(dataCode === 'unitPriceFile'){
             if(node.data.projType === projectType.tender){
@@ -932,9 +965,10 @@ const projTreeObj = {
         }
         sheet.setValue(row, col, value);
     },
-    showTreeData: function (nodes, headers,sheet) {
+    showTreeData: function (nodes, setting,sheet) {
+        let headers = setting.header;
         let me = this;
-        let tree = sheet.name() == "copyToSheet"?me.copyTree:me.tree;
+        let tree = nodes.length>0?nodes[0].tree:me.tree;//sheet.name() == "copyToSheet"?me.copyTree:me.tree;
         let fuc = function(){
             sheet.setRowCount(0);
             sheet.setRowCount(nodes.length);
@@ -944,8 +978,16 @@ const projTreeObj = {
                 for(let j = 0; j < headers.length; j++){
                     sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
                     sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
-                    me.setCellValue({row: i, col: j}, nodes[i],sheet);
+                    if(headers[j].cellType == "checkBox"){
+                        sheet.setCellType(i, j,new GC.Spread.Sheets.CellTypes.CheckBox(),GC.Spread.Sheets.SheetArea.viewport);
+                        sheet.getCell(i, j).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+                    }
+                    me.setCellValue({row: i, col: j}, nodes[i],sheet,setting);
                     let dataCode = headers[j].dataCode;
+                    if(nodes[i].data.projType == "Tender" && (dataCode=="feeRateFile" || dataCode == "unitPriceFile")) {
+                        sheet.setCellType(i, j,sheetCommonObj.getSelectButton(headers[j].width),GC.Spread.Sheets.SheetArea.viewport);
+                        sheet.getCell(i, j,GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                    }
                     //sheet.setValue(i, j, nodes[i]['data'][dataCode]);
                 }
                 sheet.getCell(i, 1,GC.Spread.Sheets.SheetArea.viewport).locked(true);
@@ -1018,6 +1060,95 @@ const projTreeObj = {
         }
 
     },
+    initFileChangePage:async function (from) {
+        let title = from == "unitPriceFile" ?"批量替换单价文件":"批量替换费率文件";
+        $("#mr_title").text(title);
+        this.initHtmlByFromRadio();
+        let result = from == "unitPriceFile"?await this.setUnitFileChangeFileData():await this.setFeeRateChangeFileData();
+        console.log(result);
+        this.changeInfo = result;
+        this.loadFileOptions(this.changeInfo,from);
+
+    },
+    setFeeRateChangeFileData:async function(){
+        //userID
+        let node = projTreeObj.tree.selected;
+        let data={"user_id":userID, "projectID":node.data.ID, "rootProjectID":node.data.property.rootProjectID};
+        let result = await ajaxPost("/feeRates/getChangeInfo",data);
+        this.getFileListWithPath(result.others);
+        return result;
+
+    },
+    setUnitFileChangeFileData:async function(){
+        let node = projTreeObj.tree.selected;
+        let data ={"project_id":node.data.ID,"rootProjectID":node.data.property.rootProjectID};
+        let result = await ajaxPost("/glj/get-project-info",data);
+        this.getFileListWithPath(result.other);
+        console.log(result);
+        //数据结构不一样,这里做一下转换
+        let t_result = {
+            currentProject:{
+                ID:node.data.ID,
+                currentOptions:result.self,
+            },
+            others:result.other
+        }
+        return t_result;
+
+
+    },
+
+
+
+    getFileListWithPath:function (list) {
+        for(let n of list){
+            let node = projTreeObj.tree.findNode(n.ID);
+            if(node) n.name = getPathName(node);
+        }
+
+        function getPathName(node) {
+            if(node.parent && node.parent.data){
+                return getPathName(node.parent)+"\\"+node.data.name
+            }else {
+                return node.data?node.data.name:"";
+            }
+        }
+
+    },
+    loadFileOptions:function (data,from) {
+        let idField = "ID",optionField ="optionList";
+        if(from == "unitPriceFile"){
+            idField = 'id';
+            optionField = 'unitPriceList'
+        }
+        $('#currentOptions').empty();
+        for(let c of data.currentProject.currentOptions){
+            var option =  $("<option>").val(c[idField]).text(c.name);
+            $('#currentOptions').append(option);
+        }
+        $('#otherProject').empty();
+        for(let p of data.others){
+            var option =  $("<option>").val(p.ID).text(p.name);
+            $('#otherProject').append(option);
+        }
+        $('#otherFileOptions').empty();
+        if(data.others.length>0){
+            for(let f of data.others[0][optionField]){
+                var option =  $("<option>").val(f[idField]).text(f.name);
+                $('#otherFileOptions').append(option);
+            }
+        }
+    },
+    initHtmlByFromRadio:function () {
+        var radioV= $("input[name='select_from']:checked").val();
+        if(radioV == "0"){
+            $("#fromProject").show();
+            $("#fromOther").hide();
+        } else {
+            $("#fromProject").hide();
+            $("#fromOther").show();
+        }
+    },
     initCopyToSpread:function () {
         let me = this;
         me.copyToWorkBook =  projTreeObj.buildSheet(me.copyToWorkBook,'copyToSpread',me.copyToSetting);
@@ -1029,11 +1160,27 @@ const projTreeObj = {
             datas.push(i.data);
         }
         me.copyTree  = pmTree.createNew(projTreeObj.setting, datas);
-        me.showTreeData(me.copyTree.items, me.copyToSetting.header, sheet);
+        me.showTreeData(me.copyTree.items, me.copyToSetting, sheet);
         me.copySelected = null;
         let initSel = sheet.getSelections()[0] ? sheet.getSelections()[0] : {row: 0, rowCount: 1};
         projTreeObj.initSelection(initSel,null,sheet);
     },
+    initReplaceSpread:function () {
+        let me = this;
+        me.replaceWorkBook =  projTreeObj.buildSheet(me.replaceWorkBook,'replaceSpread',me.replaceSetting);
+        let sheet = me.replaceWorkBook.getActiveSheet();
+        sheet.options.isProtected = true;
+        sheet.name('replaceSheet');
+        let datas = [];
+        for(let i of me.tree.items){
+            datas.push(i.data);
+        }
+        me.replaceTree  = pmTree.createNew(projTreeObj.setting, datas);
+        me.showTreeData(me.replaceTree.items, me.replaceSetting, sheet);
+
+    },
+
+
     insert: function (data, parent, next) {
         let preNode = this.tree.items[this.preSelection.row];
         let node = this.tree.addNodeData(data, parent, next);
@@ -1547,11 +1694,19 @@ $(document).ready(function() {
     });*/
 
     $('#copy-to-dialog').on('shown.bs.modal', function () {
-        console.log('shown copy to ');
         projTreeObj.initCopyToSpread();
        // copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
     });
 
+    $('#m_replace_file').on('shown.bs.modal', function () {
+        // projTreeObj.tree.selected
+        projTreeObj.initReplaceSpread();
+    });
+    $("input[name='select_from']").each(function(){
+        $(this).click(function(){
+            projTreeObj.initHtmlByFromRadio();
+        });
+    });
     // 复制到操作
     $("#copy-to-confirm").click(function() {
         let originalNode = projTreeObj.tree.selected;
@@ -1654,7 +1809,6 @@ $(document).ready(function() {
         }else {
             $('#taxType_div').show();
         }
-        console.log(taxTypeArray);
     }
 
     function getStdCalcProgramFiles(){
@@ -1733,9 +1887,10 @@ function initProjects(callback) {
             projTreeObj.tree.selected = projTreeObj.tree.items[0];
             projTreeObj.workBook = projTreeObj.buildSheet(projTreeObj.workBook,'projSpread',projTreeObj.setting);
             projTreeObj.workBook.getSheet(0).frozenColumnCount(2);
+            projTreeObj.workBook.getSheet(0).name('projectSheet');
             sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
             projTreeObj.sumEngineeringCost();
-            projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header, projTreeObj.workBook.getActiveSheet());
+            projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting, projTreeObj.workBook.getActiveSheet());
             //初始选择
             let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
             projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
@@ -3131,14 +3286,14 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
         });
     }
     //重命名
+    let fileObjs = getFileObj(targetBody, type),
+        fileDiv = $(jqS + ' div:eq(0)'),
+        renameDiv = $(jqS + ' div:eq(1)'),
+        hintText = $(jqS).find('span'),
+        postFix = '';
     $(jqS + ' p a:eq(1)').on('click', function () {
-        let fileObjs = getFileObj(targetBody, type);
         let orgDispName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
-        let postFix = '';
         let orgName = orgDispName;
-        let hintText = $(jqS).find('span');
-        let fileDiv = $(jqS + ' div:eq(0)');
-        let renameDiv = $(jqS + ' div:eq(1)');
         $(jqS + ' input').val(orgName);
         fileDiv.hide();
         renameDiv.show();
@@ -3148,62 +3303,17 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
             renameDiv.hide();
             hintText.hide();
         });
-        //确认重命名
-        //回车键
-        $(jqS).find('input:eq(0)').keypress(function (e) {
-            if(e.keyCode === 13){
-                let attrId = $(jqS).attr('id');
-                let id = attrId.slice(5, attrId.length);
-                let newName = $(jqS + ' input').val().trim();
-                if(newName !== orgName){
-                    if(hasThisFileName(fileObjs, newName)){
-                        hintText.show();
-                        //$(jqS + ' input').val(orgName);
-                        return;
-                    }
-                    if(newName.trim().length === 0){
-                        alert('文件名不可为空!');
-                        $(jqS + ' input').val(orgName);
-                        return;
-                    }
-                    //ajax
-                    let updateObj = Object.create(null);
-                    updateObj.fileType = type;
-                    updateObj.updateType = 'update';
-                    updateObj.updateData = Object.create(null);
-                    if(type === fileType.unitPriceFile){
-                        updateObj.updateData.id = parseInt(id);
-                        //updateObj.updateData.id = id;
-                    }
-                    else if(type === fileType.feeRateFile){
-                        updateObj.updateData.ID = id;
-                    }
-                    updateObj.updateData.name = newName;
-                    a_updateFiles([updateObj], function () {
-                        let newDispName = newName + postFix;
-                        fileDiv[0].childNodes[0].textContent = newDispName;
-                        fileDiv.show();
-                        renameDiv.hide();
-                        //refresh tender
-                        refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
-                    });
-                }
-                let newDispName = newName + postFix;
-                fileDiv[0].childNodes[0].textContent = newDispName;
-                fileDiv.show();
-                renameDiv.hide();
-                hintText.hide();
-            }
-        });
-
-        /*$(jqS + ' .btn-success').on('click', function () {
+    });
+    //回车键确认重命名
+    $(jqS).find('input:eq(0)').keypress(function (e) {
+        if(e.keyCode === 13){
+            let orgName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
             let attrId = $(jqS).attr('id');
             let id = attrId.slice(5, attrId.length);
             let newName = $(jqS + ' input').val().trim();
             if(newName !== orgName){
                 if(hasThisFileName(fileObjs, newName)){
-                    $(jqS).find('span:eq(2)').show();
-                    //$(jqS + ' input').val(orgName);
+                    hintText.show();
                     return;
                 }
                 if(newName.trim().length === 0){
@@ -3218,7 +3328,6 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
                 updateObj.updateData = Object.create(null);
                 if(type === fileType.unitPriceFile){
                     updateObj.updateData.id = parseInt(id);
-                    //updateObj.updateData.id = id;
                 }
                 else if(type === fileType.feeRateFile){
                     updateObj.updateData.ID = id;
@@ -3226,24 +3335,19 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
                 updateObj.updateData.name = newName;
                 a_updateFiles([updateObj], function () {
                     let newDispName = newName + postFix;
-                    $(jqS + ' div:eq(0)')[0].childNodes[0].textContent = newDispName;
-                    $(jqS + ' div:eq(0)').show();
-                    $(jqS + ' div:eq(1)').hide();
+                    fileDiv[0].childNodes[0].textContent = newDispName;
+                    fileDiv.show();
+                    renameDiv.hide();
                     //refresh tender
                     refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
                 });
             }
             let newDispName = newName + postFix;
-            $(jqS + ' div:eq(0)')[0].childNodes[0].textContent = newDispName;
-            $(jqS + ' div:eq(0)').show();
-            $(jqS + ' div:eq(1)').hide();
-        });
-        //取消重命名
-        $(jqS + ' .btn-secondary').on('click', function () {
-            $(jqS + ' div:eq(0)').show();
-            $(jqS + ' div:eq(1)').hide();
-            $(jqS).find('span:eq(2)').hide();
-        });*/
+            fileDiv[0].childNodes[0].textContent = newDispName;
+            fileDiv.show();
+            renameDiv.hide();
+            hintText.hide();
+        }
     });
     //悬浮框显示使用该文件的单位工程
     $($(jqS)[0].nextSibling).popover({
@@ -3483,6 +3587,25 @@ $('#allowCopy').change(function () {
     }
 });
 
+//批量替换文件,切换建设项目
+$('#otherProject').change(function(){
+    let optionList = [],idField = 'ID';
+    var newVal = $(this).val();
+    var projects = projTreeObj.changeInfo.others;
+    var selected = _.find(projects,{ID:parseInt(newVal)});
+    if($("#mr_from").val() =="unitPriceFile"){
+        idField = 'id';
+        optionList = selected.unitPriceList;
+    }else {
+        optionList =  selected.optionList;
+    }
+    $('#otherFileOptions').empty();
+    for(let f of optionList){
+        let option =  $("<option>").val(f[idField]).text(f.name);
+        $('#otherFileOptions').append(option);
+    }
+});
+
 //分享给...界面确认
 $('#shareToConfirm').click(function () {
     let selected = projTreeObj.tree.selected;