Browse Source

项目属性重载分离,清单定额库状态保存,mainTab状态保存

zhongzewei 7 years ago
parent
commit
d25e727082

+ 24 - 0
public/web/id_tree.js

@@ -689,6 +689,30 @@ var idTree = {
             }
         };
 
+        Tree.prototype.getExpState = function (nodes) {
+            let sessionExpanded = [];
+            function getStat(items){
+                for(let item of items){
+                    sessionExpanded.push(item.expanded ? 1 : 0);
+                }
+            }
+            getStat(nodes);
+            let expState = sessionExpanded.join('');
+            return expState;
+        };
+
+        //节点根据展开收起列表'010101'展开收起
+        Tree.prototype.setExpandedByState = function (nodes, expState) {
+            let expStateArr = expState.split('');
+            for(let i = 0; i < nodes.length; i++){
+                let expanded = expStateArr[i] == 1 ? true : false;
+                if(nodes[i].expanded === expanded){
+                    continue;
+                }
+                nodes[i].setExpanded(expanded);
+            }
+        };
+
         /*Tree.prototype.editedData = function (field, id, newText) {
             var node = this.findNode(id), result = {allow: false, nodes: []};
             if (this.event[this.eventType.editedData]) {

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

@@ -319,7 +319,16 @@ var TREE_SHEET_HELPER = {
             let centerX = hitinfo.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
             let centerY = (hitinfo.cellRect.y + offset + (hitinfo.cellRect.y + offset + hitinfo.cellRect.height)) / 2;
             if (hitinfo.x > centerX - halfBoxLength && hitinfo.x < centerX + halfBoxLength && hitinfo.y > centerY - halfBoxLength && hitinfo.y < centerY + halfBoxLength) {
+                console.log(`hitinfo.sheet.name()`);
+                console.log(hitinfo.sheet.name());
                 node.setExpanded(!node.expanded);
+                let sheetName = hitinfo.sheet.name();
+                if(sheetName === 'stdBillsLib_bills'){
+                    sessionStorage.setItem('stdBillsLibExpState', billsLibObj.stdBillsTree.getExpState(billsLibObj.stdBillsTree.items));
+                }
+                else if(sheetName === 'stdRationLib_chapter'){
+                    sessionStorage.setItem('stdRationLibExpState', rationLibObj.tree.getExpState(rationLibObj.tree.items));
+                }
                 TREE_SHEET_HELPER.massOperationSheet(hitinfo.sheet, function () {
                     let iCount = node.posterityCount(), i, child;
                     for (i = 0; i < iCount; i++) {

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

@@ -1066,7 +1066,7 @@
                 <div class="modal-body">
                     <div class="custom-file">
                         <input type="file" class="custom-file-input" id="customFile" lang="zh" accept=".xls,.xlsx">
-                        <label class="custom-file-label" for="customFile">请选择上传文件</label>
+                        <label class="custom-file-label" for="customFile" style="white-space: nowrap; overflow: hidden;">请选择上传文件</label>
                     </div>
                     <div class="alert alert-success mt-3" id="uploadAlert" role="alert" style="display: none;">
                         广东XXXX项目清单.xlsx 准备导入上传

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

@@ -27,6 +27,8 @@ $(function () {
     });
 
     $('#tab_zaojiashu').on('shown.bs.tab', function (e) {
+        //设置sessionStorage,重载时用
+        sessionStorage.setItem('mainTab', '#tab_zaojiashu');
         $(e.relatedTarget.hash).removeClass('active');
         $("#subItems").addClass('active');
         $(gljOprObj.activeTab).addClass('active');
@@ -34,19 +36,23 @@ $(function () {
         projectObj.refreshMainSpread();
     });
 
+    $('#tab_report').on('shown.bs.tab', function(e){
+        sessionStorage.setItem('mainTab', '#tab_report');
+    });
+
     slideResize(mainResizeEles, {min: 170, max: 700}, 'height', function() {
         projectObj.mainSpread.refresh();
         refreshSubSpread();
     });
 
-    const projectId = scUrlUtil.GetQueryString('project');
+    /*const projectId = scUrlUtil.GetQueryString('project');
     // 绑定点击事件
     projectObj.mainSpread.bind(GC.Spread.Sheets.Events.CellClick, function(sender, info) {
         if (info.row !== undefined && projectId !== undefined) {
             setLocalCache('lastRow:' + projectId, info.row);
             setLocalCache('lastCol:' + projectId, info.col);
         }
-    });
+    });*/
 });
 
 /**

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

@@ -431,6 +431,7 @@ let calcProgramManage = {
 
 $(document).ready(function(){
     $('#tab_calc_program_manage').on('shown.bs.tab', function (e) {
+        sessionStorage.setItem('mainTab', '#tab_calc_program_manage');
         $(e.relatedTarget.hash).removeClass('active');
         calcProgramManage.buildSheet();
     });

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

@@ -790,6 +790,7 @@ $(function(){
     );
 
     $('#tab_fee_rate').on('shown.bs.tab', function (e) {
+        sessionStorage.setItem('mainTab', '#tab_fee_rate');
         let me = feeRateObject;
         $(e.relatedTarget.hash).removeClass('active');
         if(me.mainFeeRateSpread == null){

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

@@ -551,6 +551,7 @@ $(function () {
         projectGljObject.mixRatioSpread?projectGljObject.mixRatioSpread.refresh():'';
     });
     $('#tab_project_glj').on('shown.bs.tab', function (e) {
+        sessionStorage.setItem('mainTab', '#tab_project_glj');
         let me = projectGljObject;
         $(e.relatedTarget.hash).removeClass('active');
         if(me.projectGljSpread==null){
@@ -558,6 +559,7 @@ $(function () {
         }
         me.unitPriceFileInit();
         //projectObj.project.projectGLJ.calcQuantity(); 在工程量有更新的地方调用
+
         me.showProjectGljData();
         loadSize(pojGljResizeEles, 'height', function () {
             me.projectGljSpread.refresh();

+ 51 - 9
web/building_saas/main/js/views/project_view.js

@@ -483,6 +483,7 @@ var projectObj = {
     },
     //repaint 动态下拉框
     mainSpreadEnterCell: function (sender, info) {
+        console.log('enterCell');
         let colSetting = projectObj.mainController.setting.cols[info.col];
         if(colSetting.data.field === 'unit' || (projectObj.lastCol&&projectObj.lastCol.data.field === 'unit')||colSetting.data.field ==='subType'
             || (projectObj.lastCol&&projectObj.lastCol.data.field === 'subType') || colSetting.data.field === 'programID' ||(projectObj.lastCol&&projectObj.lastCol.data.field === 'programID')){
@@ -681,6 +682,9 @@ var projectObj = {
                 installationFeeObj.engineeringTypeChecking();//检查是否安装工程
                 autoFlashHeight();
                 projectObj.refreshMainSpread();
+                //定位到会话中的选项
+                let mainTabFocus = sessionStorage.getItem('mainTab') ? sessionStorage.getItem('mainTab') : '#tab_zaojiashu';
+                $(`${mainTabFocus}`).click();
                 $.bootstrapLoading.end();
             }
             else {
@@ -1573,13 +1577,37 @@ $('#property_ok').click(function () {
             mixDatas.labourCoes.updateData || mixDatas.rations.length > 0 || mixDatas.bills.length > 0;
     }
 
+    function needToReload(mixDatas){
+        if(Object.keys(mixDatas.labourCoes).length > 0){
+            return true;
+        }
+        if(Object.keys(mixDatas.properties).length > 0){
+            if(mixDatas.properties.hasOwnProperty('property.billsCalcMode') ||
+                mixDatas.properties.hasOwnProperty('property.zanguCalcMode') ||
+                mixDatas.properties.hasOwnProperty('property.calcOptions')||
+                mixDatas.properties.hasOwnProperty('property.billsQuantityDecimal')||
+                mixDatas.properties.hasOwnProperty('property.decimal')||
+                mixDatas.properties.hasOwnProperty('property.displaySetting')){
+                return true;
+            }
+        }
+        return false;
+    }
+
     if(hasMixData()){
         CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
-/*            if (changedNodes.length > 0) {
-                for (let node of changedNodes){delete node.changed};
-            };
-            if (mixDatas.labourCoes.updateData) labourCoeView.refresh();*/
-            window.location.href = '/main?project=' + projectID;
+            //需要重载页面
+            if(needToReload(mixDatas)){
+                window.location.href = '/main?project=' + projectID;
+            }
+            else{
+                if(mixDatas.properties.hasOwnProperty('property.basicInformation')){
+                    basicInfoView.orgDatas = basicInfoView.toViewDatas(mixDatas.properties['property.basicInformation']);
+                }
+                if(mixDatas.properties.hasOwnProperty('property.projectFeature')){
+                    projFeatureView.orgDatas = projFeatureView.toViewDatas(mixDatas.properties['property.projectFeature']);
+                }
+            }
         });
     }
 });
@@ -1752,11 +1780,11 @@ function ifCanDelete() {
 $('#customFile').change(function () {
     let file = $(this)[0];
     if(file.files.length > 0){
-        $('#uploadAlert').text(`${file.files[0].name} 准备导入上传`);
-        $('#uploadAlert').show();
+        $('.custom-file-label').text(`${file.files[0].name} 准备导入上传`);
+        $('#uploadAlert').hide();
     }
     else{
-        $('#uploadAlert').hide();
+        $('.custom-file-label').text(`请选择上传文件`);
     }
 });
 //从excel导入清单
@@ -1813,10 +1841,23 @@ $('#uploadConfirm').click(function () {
         });
     }
     catch (err){
-        alert(err);
+        //alert(err);
+        showUploadAlert(false, err);
         $(me).removeClass('disabled');
     }
 });
+function showUploadAlert(success, msg){
+    if(!success){
+        $('#uploadAlert').removeClass('alert-success');
+        $('#uploadAlert').addClass('alert-danger');
+    }
+    else{
+        $('#uploadAlert').removeClass('alert-danger');
+        $('#uploadAlert').addClass('alert-success');
+    }
+    $('#uploadAlert').text(msg);
+    $('#uploadAlert').show();
+}
 //导入后更新操作
 function doAfterImport(resData){
     if(resData){
@@ -1907,6 +1948,7 @@ $(function () {
     $('#import').on('show.bs.modal', function(){
         $('#customFile').val('');
         $('#uploadAlert').hide();
+        $('.custom-file-label').text(`请选择上传文件`);
     });
 
     $("#billsSpread").mouseover(function(){

+ 36 - 14
web/building_saas/main/js/views/std_bills_lib.js

@@ -4,6 +4,7 @@
  */
 
 var billsLibObj = {
+    stdBillsTree: null,
     stdBillsSpread: null,
     stdBillsJobSpread: null,
     stdBillsFeatureSpread: null,
@@ -13,6 +14,7 @@ var billsLibObj = {
     checkBillsSpread: function () {
         if (!this.stdBillsSpread) {
             this.stdBillsSpread = SheetDataHelper.createNewSpread($('#stdBillsSpread')[0]);
+            this.stdBillsSpread.getSheet(0).name('stdBillsLib_bills');
             // 刷新setting中记录的spread的位置
             this.refreshSettingForHint();
         }
@@ -64,8 +66,12 @@ var billsLibObj = {
         select.empty();
 
         let bills_lib = projectInfoObj.projectInfo.engineeringInfo.bill_lib;
+        let selectedBillsLib = sessionStorage.getItem('stdBillsLib');
         bills_lib.forEach(function (data) {
             var option = $('<option>').val(data.id).text(data.name);
+            if(selectedBillsLib && data.id == selectedBillsLib){
+                option.attr('selected', 'selected');
+            }
             select.append(option);
         });
         if (select.children.length !== 0) {
@@ -75,8 +81,11 @@ var billsLibObj = {
     loadStdBills: function (stdBillsLibID) {
         var that = this;
         var stdBillsJobData, stdBillsFeatureData, stdBills;
-        var stdBillsTree  = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
-        var stdBillsTreeController = TREE_SHEET_CONTROLLER.createNew(stdBillsTree, billsLibObj.stdBillsSpread.getActiveSheet(), billsLibObj.stdBillsTreeSetting);
+        if(that.stdBillsTree){
+            that.stdBillsTree = null;
+        }
+        that.stdBillsTree  = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
+        var stdBillsTreeController = TREE_SHEET_CONTROLLER.createNew(that.stdBillsTree, billsLibObj.stdBillsSpread.getActiveSheet(), billsLibObj.stdBillsTreeSetting);
         var findData = function (value, field, Array) {
             var i = 0;
             for (i = 0; i < Array.length; i++) {
@@ -164,25 +173,31 @@ var billsLibObj = {
         });
         CommonAjax.post('/stdBillsEditor/getBills', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
             stdBills = datas;
-            stdBillsTree.loadDatas(stdBills);
+            that.stdBillsTree.loadDatas(stdBills);
+            //读取展开收起状态
+            let currentExpState = sessionStorage.getItem('stdBillsLibExpState');
+            if(currentExpState){
+                that.stdBillsTree.setExpandedByState(that.stdBillsTree.items, currentExpState);
+            }
             //非叶子节点默认收起
-            stdBillsTree.setRootExpanded(stdBillsTree.roots, false);
-
+            else{
+                that.stdBillsTree.setRootExpanded(that.stdBillsTree.roots, false);
+            }
             stdBillsTreeController.showTreeData();
             billsLibObj.setTagForHint(datas);
-            showBillsRela(stdBillsTree.firstNode());
+            showBillsRela(that.stdBillsTree.firstNode());
 
             stdBillsTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, showBillsRela);
             that.stdBillsSpread.unbind(GC.Spread.Sheets.Events.CellDoubleClick);
             that.stdBillsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (sender, args) {
-                let selectNode = stdBillsTree.items[args.row];
+                let selectNode = that.stdBillsTree.items[args.row];
                 let name = selectNode.data.name;
-                if (stdBillsTree.items[args.row].children.length === 0) {
+                if (that.stdBillsTree.items[args.row].children.length === 0) {
                     if(projectInfoObj.projectInfo.property.lockBills == true){
                         return;
                     }
                     //特征及内容转化
-                    pageCCOprObj.setItemContentNode(stdBillsTree.items[args.row], getBillsJobs(stdBillsTree.items[args.row]), getBillsFeatures(stdBillsTree.items[args.row]), name);
+                    pageCCOprObj.setItemContentNode(that.stdBillsTree.items[args.row], getBillsJobs(that.stdBillsTree.items[args.row]), getBillsFeatures(that.stdBillsTree.items[args.row]), name);
                     if (/\//.test(selectNode.data.unit)) {
                         let existB = projectObj.project.Bills.sameStdCodeBillsData(selectNode.data.code);
                         if (existB) {
@@ -200,14 +215,16 @@ var billsLibObj = {
                 }
                 else{
                     let me = billsLibObj;
-                    let node = stdBillsTree.items[args.row];
+                    let node = that.stdBillsTree.items[args.row];
                     if (!node || node.children.length === 0)
                         return;
                     node.setExpanded(!node.expanded);
+                    //设置展开收起状态
+                    sessionStorage.setItem('stdBillsLibExpState', that.stdBillsTree.getExpState(that.stdBillsTree.items));
                     TREE_SHEET_HELPER.massOperationSheet(args.sheet, function () {
                         let iCount = node.posterityCount(), i, child;
                         for (i = 0; i < iCount; i++) {
-                            child = stdBillsTree.items[args.row + i + 1];
+                            child = that.stdBillsTree.items[args.row + i + 1];
                             args.sheet.setRowVisible(args.row + i + 1, child.visible, args.sheetArea);
                         }
                         args.sheet.invalidateLayout();
@@ -224,7 +241,7 @@ var billsLibObj = {
 
             if (!keyword || keyword === '') {return}
 
-            var result = stdBillsTree.items.filter(function (item) {
+            var result = that.stdBillsTree.items.filter(function (item) {
                 var codeIs = item.data.code ? item.data.code.indexOf(keyword) !== -1 : false;
                 var nameIs = item.data.name ? item.data.name.indexOf(keyword) !== -1 : false;
                 return codeIs || nameIs;
@@ -243,7 +260,7 @@ var billsLibObj = {
 
                 $('#nextStdBills').show();
                 $('#nextStdBills').click(function () {
-                    var cur = stdBillsTree.selected, resultIndex = result.indexOf(cur), sel = billsLibObj.stdBillsSpread.getActiveSheet().getSelections();
+                    var cur = that.stdBillsTree.selected, resultIndex = result.indexOf(cur), sel = billsLibObj.stdBillsSpread.getActiveSheet().getSelections();
                     if (resultIndex === result.length - 1) {
                         stdBillsTreeController.setTreeSelected(result[0]);
                         billsLibObj.stdBillsSpread.getActiveSheet().setSelection(result[0].serialNo(), sel[0].col, 1, 1);
@@ -423,7 +440,12 @@ $('#stdBillsLibSelect').change(function () {
 
     var select = $(this);
     if (this.children.length !== 0) {
-        billsLibObj.loadStdBills(select.val());
+        //设置sessionStorage
+        let billsLibId  = select.val();
+        sessionStorage.setItem('stdBillsLib', billsLibId);
+        //清除展开收起状态sessionStorage
+        sessionStorage.removeItem('stdBillsLibExpState');
+        billsLibObj.loadStdBills(billsLibId);
     }
 });
 

+ 22 - 4
web/building_saas/main/js/views/std_ration_lib.js

@@ -14,6 +14,7 @@ var rationLibObj = {
     checkSpread: function () {
         if (!this.rationChapterSpread) {
             this.rationChapterSpread = SheetDataHelper.createNewSpread($('#stdRationChapter')[0]);
+            this.rationChapterSpread.getSheet(0).name('stdRationLib_chapter');
             this.rationChapterSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onChapterSpreadCellDoubleClick);
         }
         if (!this.sectionRationsSpread) {
@@ -36,8 +37,14 @@ var rationLibObj = {
         select.empty();
 
         let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
+        let selectedRationLib = sessionStorage.getItem('stdRationLib');
         ration_lib.forEach(function (data) {
-            select.append($('<option>').val(data.id).text(data.name));
+            let option = $('<option>').val(data.id).text(data.name);
+            //select.append($('<option>').val(data.id).text(data.name));
+            if(selectedRationLib && data.id == selectedRationLib){
+                option.attr('selected', 'selected');
+            }
+            select.append(option);
         });
         if (select[0].options.length !== 0) {
             rationLibObj.loadStdRation(select.val());
@@ -50,8 +57,15 @@ var rationLibObj = {
             that.tree = rationChapterTree;
             var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
             rationChapterTree.loadDatas(datas);
-            //非叶子节点默认收起
-            that.tree.setRootExpanded(that.tree.roots, false);
+            //读取展开收起状态
+            let currentExpState = sessionStorage.getItem('stdRationLibExpState');
+            if(currentExpState){
+                that.tree.setExpandedByState(that.tree.items, currentExpState);
+            }
+            else {
+                //非叶子节点默认收起
+                that.tree.setRootExpanded(that.tree.roots, false);
+            }
             rationChapterTreeController.showTreeData();
 
             rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
@@ -78,6 +92,7 @@ var rationLibObj = {
         if (!node || node.children.length === 0)
             return;
         node.setExpanded(!node.expanded);
+        sessionStorage.setItem('stdRationLibExpState', me.tree.getExpState(me.tree.items));
         TREE_SHEET_HELPER.massOperationSheet(args.sheet, function () {
             let iCount = node.posterityCount(), i, child;
             for (i = 0; i < iCount; i++) {
@@ -309,7 +324,10 @@ $('#stdRationTab').bind('click', function () {
 $('#stdRationLibSelect').change(function () {
     var select = $(this);
     if (this.children.length !== 0) {
-        rationLibObj.loadStdRation(select.val());
+        let rationLibId = select.val();
+        sessionStorage.setItem('stdRationLib', rationLibId);
+        sessionStorage.removeItem('stdRationLibExpState');
+        rationLibObj.loadStdRation(rationLibId);
     }
 });
 $('#rationSearch').click(function () {