Browse Source

fix: 审核自动下拉高度增加容错判断

lanjianrong 4 years ago
parent
commit
a6e98c0858
3 changed files with 22 additions and 10 deletions
  1. 3 4
      app/service/material_audit.js
  2. 18 4
      app/view/material/audit_modal.ejs
  3. 1 2
      app/view/stage/audit_modal.ejs

+ 3 - 4
app/service/material_audit.js

@@ -195,7 +195,9 @@ module.exports = app => {
                 await transaction.update(this.ctx.service.material.tableName, {
                     id: materialId, status: auditConst.status.checking,
                 });
-
+                // 添加记录至推送表
+                await transaction.insert('zh_notice', { type: 'material', uid: audit.aid, status: auditConst.status.checking, is_read: 0, content: '待审核' });
+                console.log('1111');
                 // 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
                 const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
                 if (materialBillsData.length === 0) {
@@ -410,7 +412,6 @@ module.exports = app => {
             const time = new Date();
             // 整理当前流程审核人状态更新
             const audit = await this.getDataByCondition({ mid: materialId, times, status: auditConst.status.checking });
-            console.log('audit', audit);
             if (!audit || audit.order <= 1) {
                 throw '审核数据错误';
             }
@@ -459,8 +460,6 @@ module.exports = app => {
             if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) {
                 throw '提交数据错误';
             }
-            console.log('checkData:', checkData);
-            console.log('times', times);
             switch (checkData.checkType) {
                 case auditConst.status.checked:
                     await this._checked(materialId, checkData, times);

+ 18 - 4
app/view/material/audit_modal.ejs

@@ -868,11 +868,25 @@
 
 <script>
     $('.modal').on('shown.bs.modal', function () {
-        const height = $(this)[0].scrollHeight
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]')
+        const height = $(this)[0].scrollHeight;
+        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
-        if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
-            scrollBox.scrollTop(height);
+        // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        //     scrollBox.scrollTop(height);
+        // }
+        scrollBox.scrollTop(0);
+        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+        const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : null;
+        if (hdiv && scrollBox.length &&  scrollBox[0].scrollHeight > 450 && hdheight - bdiv > 450) {
+            scrollBox.scrollTop(hdheight - bdiv);
         }
     });
+    function divSearch(div) {
+        if (div.length > 0) {
+            return true;
+        }
+        return false;
+    }
 </script>

+ 1 - 2
app/view/stage/audit_modal.ejs

@@ -1598,7 +1598,7 @@
     $('.modal').on('shown.bs.modal', function () {
         const height = $(this)[0].scrollHeight;
         const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
-        const bdiv = scrollBox.offset().top;
+        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
 
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
         // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
@@ -1607,7 +1607,6 @@
         scrollBox.scrollTop(0);
         const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
         const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : null;
-        console.log(hdheight);
         if (hdiv && scrollBox.length &&  scrollBox[0].scrollHeight > 450 && hdheight - bdiv > 450) {
             scrollBox.scrollTop(hdheight - bdiv);
         }