Browse Source

feat: 清单精灵,清单选中行标蓝

vian 3 years ago
parent
commit
4fa7d05f6d
1 changed files with 24 additions and 11 deletions
  1. 24 11
      web/maintain/billsGuidance_lib/js/billsGuidance.js

+ 24 - 11
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -111,10 +111,12 @@ const billsGuidance = (function () {
         ],
         events: {
             SelectionChanged: function (sender, info) {
-                billsInitSel(info.newSelections[0].row);
+                billsInitSel(info.newSelections[0].row, info.oldSelections[0]);
             }
         }
     };
+    const bgColor = '#DFE8F9';
+
     //项目指引类型
     const itemType = {
         job: 0,
@@ -403,11 +405,17 @@ const billsGuidance = (function () {
             }
         });
     }
+
     //清单表焦点控制
     //@param {Number}row @return {void}
-    function billsInitSel(row){
+    function billsInitSel(row, oldSel){
         let guideSheet = guideItem.workBook.getActiveSheet();
         cleanData(guideSheet, guideItem.headers, -1);
+        const billSheet = bills.workBook.getActiveSheet();
+        setBgColor(billSheet, row, bgColor);
+        if (oldSel) {
+            setBgColor(billSheet, oldSel.row, 'white');
+        }
         let node = bills.tree.items[row];
         if(!node){
             return;
@@ -489,20 +497,25 @@ const billsGuidance = (function () {
             }
         }
     }
+    // 设置行底色
+    function setBgColor(sheet, row, color) {
+        const style = new GC.Spread.Sheets.Style();
+        style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+        style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+        style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+        style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+        style.backColor = color;
+        sheet.setStyle(row, -1, style);
+        
+    }
     //根据奇偶层级设置节点底色,奇数层为蓝色(树节点深度为偶数)
     //@param {Object}sheet {Array}nodes @return {void}
     function setNodesColor(sheet, nodes) {
-        const color = '#DFE8F9';
         renderSheetFunc(sheet, function () {
             for(let node of nodes){
-                let style = new GC.Spread.Sheets.Style();
-                style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
-                style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
-                style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
-                style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
-                let nDepth = node.depth();
-                style.backColor = nDepth % 2 == 0 && _isDef(node.data.type) && node.data.type === itemType.job ? color : 'White';
-                sheet.setStyle(node.serialNo(), -1, style);
+                const nDepth = node.depth();
+                const color = nDepth % 2 == 0 && _isDef(node.data.type) && node.data.type === itemType.job ? bgColor : 'White';
+                setBgColor(sheet, node.serialNo(), color);
             }
         });
     }