Kaynağa Gözat

1. 导入Excel调整
2. 升级spreadjs至v11后,acitveCombo显示问题

MaiXinRong 5 yıl önce
ebeveyn
işleme
858faa40f9

+ 1 - 0
app/lib/analysis_excel.js

@@ -324,6 +324,7 @@ class AnalysisExcelTree {
         const pos = {};
         pos.name = this.ctx.helper.replaceReturn(row[this.colsDef.name]);
         pos.quantity = aeUtils.toNumber(row[this.colsDef.quantity]);
+        pos.sgfh_qty = pos.quantity;
         pos.drawing_code = this.ctx.helper.replaceReturn(row[this.colsDef.drawing_code]);
         return this.cacheTree.addPos(pos);
     }

+ 38 - 32
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -385,6 +385,33 @@ const SpreadJsObj = {
         });
 
     },
+    _addActivePaintEvents: function (sheet, cellType) {
+        if (!sheet.ActiveType) {
+            sheet.ActiveType = [];
+        }
+        sheet.ActiveType.push(cellType);
+
+        if (!sheet.AcitveRefresh) {
+            sheet.bind(spreadNS.Events.LeaveCell, function (e, info) {
+                const cellType = info.sheet.getCell(info.row, info.col).cellType();
+                if (sheet.ActiveType.indexOf(cellType) >= 0) {
+                    info.sheet.leaveCell = {row: info.row, col: info.col};
+                } else {
+                    delete info.sheet.leaveCell;
+                }
+            });
+            sheet.bind(spreadNS.Events.EnterCell, function (e, info) {
+                const cellType = info.sheet.getCell(info.row, info.col).cellType();
+                if (sheet.ActiveType.indexOf(cellType) >= 0) {
+                    info.sheet.repaint(info.sheet.getCellRect(info.row, info.col));
+                }
+                if (info.sheet.leaveCell) {
+                    info.sheet.repaint(info.sheet.getCellRect(info.sheet.leaveCell.row, info.sheet.leaveCell.col));
+                }
+            });
+            sheet.AcitveRefresh = true;
+        }
+    },
     _defineColCellType: function (sheet, col, colSetting) {
         sheet.AcitveComboRefresh = false;
         if(colSetting.cellType === 'ellipsis') {
@@ -450,22 +477,7 @@ const SpreadJsObj = {
         if (colSetting.cellType === 'unit') {
             if (!sheet.extendCellType.unit) {
                 sheet.extendCellType.unit = this.CellType.getUnitCellType();
-                if (!sheet.AcitveComboRefresh) {
-                    sheet.bind(spreadNS.Events.LeaveCell, function (e, info) {
-                        const cellType = info.sheet.getCell(info.row, info.col).cellType();
-                        if (cellType === sheet.extendCellType.unit) {
-                            info.sheet.leaveCell = {row: info.row, col: info.col};
-                        } else {
-                            delete info.sheet.leaveCell;
-                        }
-                    });
-                    sheet.bind(spreadNS.Events.EnterCell, function (e, info) {
-                        if (info.sheet.leaveCell) {
-                            info.sheet.repaint(info.sheet.getCellRect(info.sheet.leaveCell.row, info.sheet.leaveCell.col));
-                        }
-                    });
-                    sheet.AcitveComboRefresh = true;
-                }
+                SpreadJsObj._addActivePaintEvents(sheet, sheet.extendCellType.unit);
             }
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.unit);
         }
@@ -473,22 +485,7 @@ const SpreadJsObj = {
             const cellKey = colSetting.cellTypeKey ? 'customizeCombo-' + colSetting.cellTypeKey : 'customizeCombo';
             if (!sheet.extendCellType[cellKey]) {
                 sheet.extendCellType[cellKey] = this.CellType.getCustomizeComboCellType(colSetting.comboItems);
-                if (!sheet.AcitveComboRefresh) {
-                    sheet.bind(spreadNS.Events.LeaveCell, function (e, info) {
-                        const cellType = info.sheet.getCell(info.row, info.col).cellType();
-                        if (cellType === sheet.extendCellType[cellKey]) {
-                            info.sheet.leaveCell = {row: info.row, col: info.col};
-                        } else {
-                            delete info.sheet.leaveCell;
-                        }
-                    });
-                    sheet.bind(spreadNS.Events.EnterCell, function (e, info) {
-                        if (info.sheet.leaveCell) {
-                            info.sheet.repaint(info.sheet.getCellRect(info.sheet.leaveCell.row, info.sheet.leaveCell.col));
-                        }
-                    });
-                    sheet.AcitveComboRefresh = true;
-                }
+                SpreadJsObj._addActivePaintEvents(sheet, sheet.extendCellType[cellKey]);
             }
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType[cellKey]);
         }
@@ -1809,14 +1806,23 @@ const SpreadJsObj = {
             const proto = ActiveComboCellType.prototype;
             proto.paintValue = function (ctx, value, x, y, w, h, style, options) {
                 const sheet = options.sheet;
+                console.log('paint');
+                console.log('row: ' + options.row + ' ' + sheet.getActiveRowIndex());
+                console.log('col: ' + options.col + ' ' + sheet.getActiveColumnIndex());
                 if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()
                     && !sheet.getCell(options.row, options.col).locked()) {
+                    console.log('comboBox');
                     spreadNS.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
                 } else {
+                    console.log('base');
                     spreadNS.CellTypes.Base.prototype.paintValue.apply(this, arguments);
                 }
             };
+            proto.processMouseEnter = function (hitinfo) {
+                hitinfo.sheet.repaint(hitinfo.cellRect);
+            };
             proto.getHitInfo = function (x, y, cellStyle, cellRect, options) {
+                console.log('getHitInfo');
                 const sheet = options.sheet;
                 if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()
                     && !sheet.getCell(options.row, options.col).locked()) {