瀏覽代碼

1. 合同支付,移除解锁按钮
2. spreadjs相关,添加自动提示全部内容的单元格
3. 可调用变更令,根据添加时间排序

MaiXinRong 6 年之前
父節點
當前提交
292beaf3d4
共有 4 個文件被更改,包括 117 次插入17 次删除
  1. 8 8
      app/const/spread.js
  2. 107 5
      app/public/js/spreadjs_rela/spreadjs_zh.js
  3. 2 1
      app/service/change.js
  4. 0 3
      app/view/stage/pay.ejs

+ 8 - 8
app/const/spread.js

@@ -34,7 +34,7 @@ const withCl = {
             {title: '小计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'},
-            {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@'}
+            {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@', cellType: 'autoTip'}
         ],
         emptyRows: 3,
         headRows: 2,
@@ -72,7 +72,7 @@ const withoutCl = {
             {title: '施工图复核|数量', colSpan: '2|1', rowSpan: '1|1', field: 'sgfh_qty', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.quantity'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sgfh_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'},
-            {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@'}
+            {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@', cellType: 'autoTip'}
         ],
         emptyRows: 3,
         headRows: 2,
@@ -119,7 +119,7 @@ const stageTz = {
             {title: '变更|设计数量1',  colSpan: '2|1', rowSpan: '1|1', field: 'c_dgn_qty1', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|数量2',  colSpan: '|1', rowSpan: '|1', field: 'c_dgn_qty2', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '经济指标',  colSpan: '1', rowSpan: '2', field: 'final_dgn_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@', cellType: 'autoTip'},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '累计完成率(%)', colSpan: '1', rowSpan: '2', field: 'percent', hAlign: 0, width: 100, readOnly: true, type: 'Number'},
         ],
@@ -138,7 +138,7 @@ const stageTz = {
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@', cellType: 'autoTip'},
             {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
         ],
         emptyRows: 3,
@@ -176,7 +176,7 @@ const stageCl = {
             {title: '变更|设计数量1',  colSpan: '2|1', rowSpan: '1|1', field: 'c_dgn_qty1', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|数量2',  colSpan: '|1', rowSpan: '|1', field: 'c_dgn_qty2', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '经济指标',  colSpan: '1', rowSpan: '2', field: 'final_dgn_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@', cellType: 'autoTip'},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '累计完成率(%)', colSpan: '1', rowSpan: '2', field: 'percent', hAlign: 0, width: 100, readOnly: true, type: 'Number'},
         ],
@@ -198,7 +198,7 @@ const stageCl = {
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@', cellType: 'autoTip'},
             {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage', hAlign:1, width: 80, readOnly: true},
         ],
@@ -237,7 +237,7 @@ const stageNoCl = {
             {title: '变更|设计数量1',  colSpan: '2|1', rowSpan: '1|1', field: 'c_dgn_qty1', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|数量2',  colSpan: '|1', rowSpan: '|1', field: 'c_dgn_qty2', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '经济指标',  colSpan: '1', rowSpan: '2', field: 'final_dgn_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@', cellType: 'autoTip'},
             {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '累计完成率(%)', colSpan: '1', rowSpan: '2', field: 'percent', hAlign: 0, width: 100, readOnly: true, type: 'Number'},
         ],
@@ -256,7 +256,7 @@ const stageNoCl = {
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@'},
+            {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@', cellType: 'autoTip'},
             {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
             {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage', hAlign:1, width: 80, readOnly: true},
         ],

+ 107 - 5
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -123,6 +123,7 @@ const SpreadJsObj = {
      * @returns {{x: number, y: number}}
      */
     getObjPos: function (obj) {
+        if (!obj) return null;
         let target = obj;
         let pos = {x: obj.offsetLeft, y: obj.offsetTop};
 
@@ -293,6 +294,7 @@ const SpreadJsObj = {
      */
     initSheet: function (sheet, setting) {
         this.beginMassOperation(sheet);
+        setting.pos = sheet.getParent().pos;
         sheet.zh_setting = setting;
         this._initSheetDeafult(sheet);
         this._initSheetHeader(sheet);
@@ -373,6 +375,12 @@ const SpreadJsObj = {
             }
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.tip);
         }
+        if (colSetting.cellType === 'autoTip') {
+            if (!sheet.extendCellType.autoTip) {
+                sheet.extendCellType.autoTip = this.CellType.getAutoTipCellType();
+            }
+            sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.autoTip);
+        }
         if (colSetting.cellType === 'checkbox') {
             if (!sheet.extendCellType.checkbox) {
                 sheet.extendCellType.checkbox = new spreadNS.CellTypes.CheckBox();
@@ -994,7 +1002,16 @@ const SpreadJsObj = {
             // 继承 SpreadJs定义的 普通的TextCellType
             TipCellType.prototype = new spreadNS.CellTypes.Text();
             const proto = TipCellType.prototype;
+            const getTextDisplayWidth = function(hitinfo, str) {
+                const xs = hitinfo.sheet.getParent().xs;
+                const ctx = xs.childNodes[0].getContext("2d");
+                ctx.font = hitinfo.cellStyle.font;
+                return ctx.measureText(str).width;
+            };
 
+            const showTip = function (hitinfo, text) {
+                return text && text !== '';
+            };
             /**
              * 获取点击信息
              * @param {Number} x
@@ -1013,7 +1030,91 @@ const SpreadJsObj = {
                     cellStyle: cellStyle,
                     cellRect: cellRect,
                     sheet: context.sheet,
-                    sheetArea: context.sheetArea
+                    sheetArea: context.sheetArea,
+                    ctx: context.sheet.getParent().xs,
+                };
+            };
+            /**
+             * 鼠标进入单元格事件 - 显示悬浮提示
+             * @param {Object} hitinfo - 见getHitInfo返回值
+             */
+            proto.processMouseEnter = function (hitinfo) {
+                let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+                const col = hitinfo.sheet.zh_setting.cols[hitinfo.col];
+                if (col.getTip && Object.prototype.toString.apply(col.getTip) === "[object Function]") {
+                    const sortData = SpreadJsObj.getSortData(hitinfo.sheet);
+                    text = col.getTip(sortData[hitinfo.row]);
+                }
+                const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
+                if (pos && showTip(hitinfo, text)) {
+                    if (!this._toolTipElement) {
+                        let div = $('#autoTip')[0];
+                        if (!div) {
+                            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", "white")
+                                .css("padding", 5).css("z-index", 99).css("word-wrap", "break-word")
+                                .attr("id", 'autoTip');
+                            //$(div).hide();
+                            document.body.insertBefore(div, null);
+                        }
+                        this._toolTipElement = div;
+                        $(this._toolTipElement).text(text).css("top", pos.y + hitinfo.y + 15).css("left", pos.x + hitinfo.x + 15)
+                            .css("width", $(window).width() - (pos.x + hitinfo.x + 15) - 10);
+                        $(this._toolTipElement).show("fast");
+                    }
+                }
+            };
+            /**
+             * 鼠标移出单元格事件 - 隐藏悬浮提示
+             * @param {Object} hitinfo - 见getHitInfo返回值
+             */
+            proto.processMouseLeave = function (hitinfo) {
+                if (this._toolTipElement) {
+                    $(this._toolTipElement).hide();
+                    this._toolTipElement = null;
+                }
+            };
+
+            return new TipCellType();
+        },
+        getAutoTipCellType: function () {
+            const TipCellType = function () {};
+            // 继承 SpreadJs定义的 普通的TextCellType
+            TipCellType.prototype = new spreadNS.CellTypes.Text();
+            const proto = TipCellType.prototype;
+            const getTextDisplayWidth = function(hitinfo, str) {
+                const xs = hitinfo.sheet.getParent().xs;
+                const ctx = xs.childNodes[0].getContext("2d");
+                ctx.font = hitinfo.cellStyle.font;
+                return ctx.measureText(str).width;
+            };
+            const showTip = function (hitinfo, text) {
+                return text && text !== '' && getTextDisplayWidth(hitinfo, text) > hitinfo.cellRect.width;
+            };
+            /**
+             * 获取点击信息
+             * @param {Number} x
+             * @param {Number} y
+             * @param {Object} cellStyle
+             * @param {Object} cellRect
+             * @param {Object} context
+             * @returns {{x: *, y: *, row: *, col: *|boolean|*[]|number|{}|UE.dom.dtd.col, cellStyle: *, cellRect: *, sheet: *|StyleSheet, sheetArea: *}}
+             */
+            proto.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+                return {
+                    x: x,
+                    y: y,
+                    row: context.row,
+                    col: context.col,
+                    cellStyle: cellStyle,
+                    cellRect: cellRect,
+                    sheet: context.sheet,
+                    sheetArea: context.sheetArea,
+                    ctx: context.sheet.getParent().xs,
                 };
             };
             /**
@@ -1027,8 +1128,8 @@ const SpreadJsObj = {
                     const sortData = SpreadJsObj.getSortData(hitinfo.sheet);
                     text = col.getTip(sortData[hitinfo.row]);
                 }
-                const setting = hitinfo.sheet.zh_setting;
-                if (setting.pos && text && text !== '') {
+                const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
+                if (pos && showTip(hitinfo, text)) {
                     if (!this._toolTipElement) {
                         let div = $('#autoTip')[0];
                         if (!div) {
@@ -1038,13 +1139,14 @@ const SpreadJsObj = {
                                 .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
                                 .css("font", "9pt Arial")
                                 .css("background", "white")
-                                .css("padding", 5)
+                                .css("padding", 5).css("z-index", 99).css("word-wrap", "break-word")
                                 .attr("id", 'autoTip');
                             //$(div).hide();
                             document.body.insertBefore(div, null);
                         }
                         this._toolTipElement = div;
-                        $(this._toolTipElement).text(text).css("top", setting.pos.y + hitinfo.y + 15).css("left", setting.pos.x + hitinfo.x + 15);
+                        $(this._toolTipElement).text(text).css("top", pos.y + hitinfo.y + 15).css("left", pos.x + hitinfo.x + 15)
+                            .css("width", $(window).width() - (pos.x + hitinfo.x + 15) - 10);
                         $(this._toolTipElement).show("fast");
                     }
                 }

+ 2 - 1
app/service/change.js

@@ -700,7 +700,8 @@ module.exports = app => {
                         '      ON sc.stimes = MF.stimes And sc.sorder = MF.sorder And sc.cbid = MF.cbid' +
                         '    GROUP BY sc.cbid' +
                         '  ) As scb ON cb.id = scb.cbid' +
-                        '  WHERE c.tid = ? And c.status = ? And ' + filter;
+                        '  WHERE c.tid = ? And c.status = ? And ' + filter +
+                        '  ORDER BY c.in_time';
             const sqlParam = [tid, tid, audit.flow.status.checked];
             const changes = await this.db.query(sql, sqlParam);
             for (const c of changes) {

+ 0 - 3
app/view/stage/pay.ejs

@@ -8,9 +8,6 @@
                     <a href="javascript: void(0);" id="del" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
                     <a href="javascript: void(0);" id="down-move" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                     <a href="javascript: void(0);" id="up-move" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
-                    <% if (ctx.session.sessionUser.accountId === ctx.stage.user_id && !stage.readOnly) { %>
-                    <a href="javascript: void(0);" id="unlock" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="解锁"><i class="fa fa-unlock" aria-hidden="true"></i> 解锁</a>
-                    <% } %>
                 </div>
                 <div class="d-inline-block">
                     <div class="input-group input-group-sm ml-2 mt-1">