Browse Source

col setting

MaiXinRong 7 years ago
parent
commit
d93aa70c0b

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

@@ -81,6 +81,7 @@ var SheetDataHelper = {
                     iRow += col.head.spanRows[i];
                 };
                 sheet.setColumnWidth(index, col.width);
+                sheet.setColumnVisible(index, col.visible);
             });
         }
     },
@@ -196,6 +197,11 @@ var SheetDataHelper = {
         sheet.resumeEvent();
         sheet.resumePaint();
     },
+    refreshColumnVisible: function (setting, sheet) {
+        setting.cols.forEach(function (col, index) {
+            sheet.setColumnVisible(index, col.visible);
+        });
+    },
     bindSheetData: function (setting, sheet, datas) {     
         var getBindColInfo = function (setting) {
             var colInfo = {};

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

@@ -68,6 +68,7 @@ var TREE_SHEET_HELPER = {
                 iRow += col.head.spanRows[i];
             };
             sheet.setColumnWidth(index, col.width);
+            sheet.setColumnVisible(index, col.visible && true);
         });
     },
     protectdSheet: function (sheet) {

+ 21 - 0
web/building_saas/main/html/main.html

@@ -112,6 +112,9 @@
                     <a href="javascript:void(0)" class="btn btn-sm" id="downMove"><i class="fa fa-arrow-down" aria-hidden="true"></i> 下移</a>
                     <a href="javascript:void(0)" class="btn btn-sm" id="upMove"><i class="fa fa-arrow-up" aria-hidden="true"></i> 上移</a>
                   </div>
+                  <div>
+                      <a href="javacript:void(0);" data-toggle="modal" data-target="#column" class="btn btn-sm"><i class="fa fa-table" aria-hidden="true"></i> 列设置</a>
+                  </div>
                   <div class="side-tabs">
                       <ul class="nav nav-tabs" role="tablist">
                           <li class="nav-item">
@@ -406,6 +409,24 @@
 
         </div>
     </div>
+    <!--弹出列设置-->
+    <div class="modal fade" id="column" data-backdrop="static">
+        <div class="modal-dialog modal-lg" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title"><i class="fa fa-table"></i> 列设置</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body modal-auto-height" id="col_setting_spread" style="height: 130px; overflow: hidden;">
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                </div>
+            </div>
+        </div>
+    </div>
     <!-- JS. -->
     <script type="text/javascript">
         autoFlashHeight();

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

@@ -38,6 +38,7 @@ var PROJECT = {
                     counter = item.data;
                 } else if (item.moduleName === me.projSetting) {
                     me._project.projSetting = item.data;
+                    me._project.projSetting.moduleName = me.projSetting;
                 }
             });
             for (module in counter) {
@@ -277,7 +278,7 @@ var PROJECT = {
                 this.push(moduleName, data);
             }
             this.endUpdate();
-        }
+        };
 
         project.prototype.registerModule = function(moduleName, obj){
             if (!tools.modules.hasOwnProperty(moduleName)){

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

@@ -86,3 +86,54 @@ let MainTreeCol = {
         }
     }
 };
+
+let colSettingObj = {
+    settingSpread: null,
+    checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
+    loadSetting: function (sheet, setting) {
+        sheet.setColumnCount(setting.cols.length);
+        sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
+        sheet.setRowCount(1);
+        sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+
+        setting.headRowHeight.forEach(function (rowHeight, index) {
+            sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
+        });
+        setting.cols.forEach(function (col, index) {
+            let i, iRow = 0, cell;
+            for (i = 0; i < col.head.spanCols.length; i++) {
+                if (col.head.spanCols[i] !== 0) {
+                    cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
+                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
+                }
+                if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
+                    sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
+                }
+                iRow += col.head.spanRows[i];
+            };
+            sheet.setColumnWidth(index, col.width);
+            cell = sheet.getCell(0, index).value(col.visible);
+        });
+    },
+    initSettingSpread: function () {
+        this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
+        this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
+        this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
+    }
+};
+
+$('#column').on('shown.bs.modal', function () {
+    if (!colSettingObj.settingSpread) {
+        colSettingObj.initSettingSpread();
+    }
+});
+
+$('#column').on('hide.bs.modal', function () {
+    let sheet = colSettingObj.settingSpread.getActiveSheet();
+    for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
+        projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
+        projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
+    }
+    SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
+    projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
+})

+ 3 - 1
web/building_saas/main/js/views/project_view.js

@@ -91,7 +91,8 @@ var projectObj = {
         this.project = PROJECT.createNew(scUrlUtil.GetQueryString('project'), userID);
         this.project.loadDatas(function (err) {
             if (!err) {
-                that.project.projSetting.mainGridSetting = that.project.projSetting.main_tree_col;
+                let str = JSON.stringify(that.project.projSetting.main_tree_col);
+                that.project.projSetting.mainGridSetting = JSON.parse(str);
                 TREE_SHEET_HELPER.initSetting($('#billsSpread')[0], that.project.projSetting.mainGridSetting);
                 that.project.projSetting.mainGridSetting.cols.forEach(function (col) {
                     col.data.splitFields = col.data.field.split('.');
@@ -404,3 +405,4 @@ $('#downMove').click(function () {
         controller.downMove();
     }
 });
+