浏览代码

根据单元格文本长度判断是否提示悬浮

zhongzewei 7 年之前
父节点
当前提交
2b4bc32316
共有 2 个文件被更改,包括 14 次插入1 次删除
  1. 11 1
      public/web/tree_sheet/tree_sheet_helper.js
  2. 3 0
      web/building_saas/main/js/views/project_view.js

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

@@ -334,8 +334,18 @@ var TREE_SHEET_HELPER = {
         };
         TipCellType.prototype.processMouseEnter = function (hitinfo) {
             let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+            let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
             let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
-            if(setting.cols[hitinfo.col].data.field=="quantity"){
+            let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
+                zoom = hitinfo.sheet.zoom();
+            let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, {sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport});
+            let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
+            let dataField = setting.cols[hitinfo.col].data.field;
+            if(dataField === 'name' || dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'){
+                if(hitinfo.sheet.getParent() === projectObj.mainSpread && textLength <= cellWidth)
+                 return;
+            }
+            if(dataField=="quantity"){
                 text = tag;
             }else if(tag !== undefined && tag) {
                 text = tag;

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

@@ -581,6 +581,9 @@ var projectObj = {
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
                 installationFeeObj.engineeringTypeChecking();//检查是否安装工程
+                //初始需要触发一次点击表格事件,sheet.getAutoFitWidth值(获取单元格文本长度)才正确
+                that.mainSpread.getActiveSheet().startEdit();
+                that.mainSpread.getActiveSheet().endEdit();
             }
             else {