Browse Source

调差清单添加单位数量提示功能

laiguoran 5 years ago
parent
commit
d30b56577a
3 changed files with 47 additions and 4 deletions
  1. 46 2
      app/public/js/material_list.js
  2. 0 1
      app/service/change_audit.js
  3. 1 1
      app/view/material/list.ejs

+ 46 - 2
app/public/js/material_list.js

@@ -49,6 +49,44 @@ function calcOneBQJC(xmj) {
 }
 
 $(document).ready(() => {
+    function TipCellType()
+    {
+    }
+    TipCellType.prototype = new GC.Spread.Sheets.CellTypes.ColumnHeader();
+    TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+        var hitInfo = { x: x, y: y, row: context.row, col: context.col, cellRect: cellRect, sheetArea: context.sheetArea, sheet: context.sheet };
+        return hitInfo;
+    };
+    TipCellType.prototype.processMouseEnter = function (hitInfo){
+        console.log(hitInfo);
+        if (!this._toolTipElement) {
+            var div = document.createElement("div");
+            $(div).css("position", "absolute")
+                .css("border", "1px #C0C0C0 solid")
+                .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
+                .css("font", "9pt Arial")
+                .css("background", "#fff")
+                // .css("color", "#fff")
+                .css("z-index", "1000")
+                .css("padding", 5);
+            this._toolTipElement = div;
+        }
+        $(this._toolTipElement).text("单位数量:每一单位清单下所需工料消耗量。")
+            .css("top", hitInfo.y + 15)
+            .css("left", hitInfo.x - 15);
+        $(this._toolTipElement).hide();
+        // document.body.insertBefore(this._toolTipElement, null);
+        $('#material-spread-div').append(this._toolTipElement, null);
+        $(this._toolTipElement).show("fast");
+    };
+    TipCellType.prototype.processMouseLeave = function (hitInfo) {
+        if (this._toolTipElement) {
+            // document.body.removeChild(this._toolTipElement);
+            // $('#material-spread-div').removeChild(this._toolTipElement);
+            this._toolTipElement.remove();
+            this._toolTipElement = null;
+        }
+    };
     autoFlashHeight();
     // 清单table
     const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
@@ -86,7 +124,7 @@ $(document).ready(() => {
             // console.log(gcl.leafXmjs);
             SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gcl.leafXmjs);
             // 对清单调差工料table的单位数量进行改变
-            materialSpreadSetting.cols[materialSpreadSetting.cols.length - 1].title = '|' + gcl.unit + '数量';
+            materialSpreadSetting.cols[materialSpreadSetting.cols.length - 1].title = '|' + gcl.unit + '数量';
             SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
         } else {
             SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, []);
@@ -146,7 +184,7 @@ $(document).ready(() => {
             {title: '清单调差工料|编号', colSpan: '4|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '|名称', colSpan: '|1', rowSpan: '|1', field: 'name', hAlign: 0, width: 100, formatter: '@', readOnly: true},
             {title: '|单位', colSpan: '|1', rowSpan: '|1', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
-            {title: '|数量', colSpan: '1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
+            {title: '|数量', colSpan: '1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number', readOnly: 'readOnly.isEdit'},
         ],
         emptyRows: 0,
         headRows: 2,
@@ -407,6 +445,12 @@ $(document).ready(() => {
             }
         };
         materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
+        const sheet = materialSpread.getActiveSheet();
+        sheet.suspendPaint();
+        // const basic_range = sheet.getRange(1, 3);
+        sheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
+        // console.log(basic_range);
+        sheet.resumePaint();
         // 应用调差工料至其他清单明细
         $('#user_all_material').click(function () {
             const sheet = materialSpread.getActiveSheet();

+ 0 - 1
app/service/change_audit.js

@@ -306,7 +306,6 @@ module.exports = app => {
                         '  ORDER By ca.`sin_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`id`' +
                         '  ORDER BY new_t.`cu_time`';
             const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.change.tableName, this.tableName, pid, time];
-            console.log(sql, sqlParam);
             return await this.db.query(sql, sqlParam);
         }
     }

+ 1 - 1
app/view/material/list.ejs

@@ -49,7 +49,7 @@
                                     <div class="sp-wrap" id="leaf-xmj-spread">
                                     </div>
                                 </div>
-                                <div class="col-4">
+                                <div class="col-4" id="material-spread-div" style="position: relative">
                                     <div class="sp-wrap" id="material-spread">
                                     </div>
                                 </div>