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

定额库章节树名称宽度自适应

zhongzewei 7 лет назад
Родитель
Сommit
7979f8e26f

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

@@ -440,4 +440,24 @@ var sheetCommonObj = {
         console.log(colMapping);
         obj.colMapping = colMapping
     },
+    //动态根据工作簿宽度和各列宽度比例设置宽度
+    setColumnWidthByRate: function (workBookWidth, workBook, headers){
+        if(workBook){
+            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'] !== ''){
+                    sheet.setColumnWidth(col, workBookWidth * headers[col]['rateWidth'], 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();
+        }
+    },
 }

+ 2 - 0
web/maintain/ration_repository/js/coe.js

@@ -31,6 +31,7 @@ $(document).ready(function () {
     let maxEval = `$('#zmhsContent').is(':visible') ? $('#dataRow').width() - $('#zmhsContent').width() - 300 : $('#dataRow').width()  - 300`;
     SlideResize.horizontalSlide(leftElesObj, {min: 300, max: maxEval}, function () {
         refreshALlWorkBook();
+        sectionTreeObj.loadRateWidth();
     });
     SlideResize.loadHorizonWidth(moduleName, [$('#slideResizeLeft')], [$('#leftContent'), $('#mainContent')], function () {
         //refreshAfterZmhs(false);
@@ -104,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/maintain/ration_repository/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);
 /*全局自适应高度结束*/

+ 10 - 1
web/maintain/ration_repository/js/section_tree.js

@@ -234,7 +234,15 @@ let sectionTreeObj = {
             });
         }
     },
-
+    loadRateWidth: function () {
+        if (this.workBook) {
+            //ID列固定40宽度
+            let spreadWidth = $('#sectionSpread').width() - 65; //65: 列头宽度和垂直滚动条宽度和
+            let IDRate = 40 / spreadWidth,
+                nameRate = 1 - IDRate;
+            sheetCommonObj.setColumnWidthByRate($('#sectionSpread').width() - 65, this.workBook, [{rateWidth: IDRate}, {rateWidth: nameRate}]);
+        }
+    },
     getSectionTree: function (repId) {
         let me = sectionTreeObj;
         let url = 'api/getRationTree';
@@ -253,6 +261,7 @@ let sectionTreeObj = {
             me.sheet.setFormatter(-1, 0, '@');
             me.initSelection(me.tree.selected);
             explanatoryOprObj.bindEvents(exEditor, calcEditor);
+            me.loadRateWidth();
         };
         let errFunc = function () {