浏览代码

预付款、材差: 期显示顺序 + 审核信息(前期准备)

Tony Kang 1 年之前
父节点
当前提交
ddb290670d
共有 4 个文件被更改,包括 97 次插入5 次删除
  1. 39 0
      app/controller/report_controller.js
  2. 12 0
      app/service/advance_audit.js
  3. 12 0
      app/service/material_audit.js
  4. 34 5
      app/view/report/index.ejs

+ 39 - 0
app/controller/report_controller.js

@@ -147,6 +147,7 @@ module.exports = app => {
                 // const advanceType = typeConsts.typeCol.find(item => item.key === 'start');
                 // const advanceList = await ctx.service.advance.getAdvanceListDirectly(tender.id, advanceType.type);
                 const advanceList = await ctx.service.advance.getAdvanceListDirectly(tender.id);
+                const advanceAuditList = await ctx.service.advanceAudit.getAuditAdvanceByTender(tender.id);
                 // const materialList = await ctx.service.advance.getValidMaterials(tender.id);
                 const isAdmin = ctx.session.sessionUser.is_admin;
                 // console.log('this.ctx.session.sessionUser.accountId: ' + this.ctx.session.sessionUser.accountId);
@@ -268,6 +269,7 @@ module.exports = app => {
                     reportConst.rptDataType[JV.NODE_CUS_MATERIAL_SELECT]);
 
                 const materialList = await ctx.service.material.getValidMaterials(ctx.tender.id);
+                const materialAdjAuditList = await ctx.service.materialAudit.getAuditorsByTender(tender.id);
 
 
                 if (stage !== null && stage !== undefined) {
@@ -329,7 +331,9 @@ module.exports = app => {
                     customSelects,
                     rptCustomType: reportConst.rptCustomType,
                     advanceList: JSON.stringify(advanceList),
+                    advanceAuditList: JSON.stringify(advanceAuditList),
                     materialAdjList: JSON.stringify(materialList),
+                    materialAdjAuditList: JSON.stringify(materialAdjAuditList),
                     materialList,
                     stages: stageList,
                     dataSelects,
@@ -488,7 +492,9 @@ module.exports = app => {
                     customSelects,
                     rptCustomType: reportConst.rptCustomType,
                     advanceList: JSON.stringify([]),
+                    advanceAuditList: JSON.stringify([]),
                     materialAdjList: JSON.stringify(materialList),
+                    materialAdjAuditList: JSON.stringify([]),
                     materialList,
                     stages: stageList,
                     dataSelects,
@@ -636,7 +642,9 @@ module.exports = app => {
                     customSelects,
                     rptCustomType: reportConst.rptCustomType,
                     advanceList: JSON.stringify([]),
+                    advanceAuditList: JSON.stringify([]),
                     materialAdjList: JSON.stringify(materialList),
+                    materialAdjAuditList: JSON.stringify([]),
                     materialList,
                     stages: stageList,
                     dataSelects,
@@ -824,7 +832,9 @@ module.exports = app => {
                     customSelects,
                     rptCustomType: reportConst.rptCustomType,
                     advanceList: JSON.stringify([]),
+                    advanceAuditList: JSON.stringify([]),
                     materialAdjList: JSON.stringify(materialList),
+                    materialAdjAuditList: JSON.stringify([]),
                     materialList,
                     stages: stageList,
                     dataSelects,
@@ -974,6 +984,35 @@ module.exports = app => {
                         stgAudit.push({ aid: audit.aid, status: audit.status, opinion: audit.opinion, end_time: audit.end_time, times: audit.times, order: audit.order });
                     });
                     break;
+                case -400: // 预付款
+                    const advanceList = await ctx.service.advance.getAdvanceListDirectly(params.tender_id);
+                    for (const advance of advanceList) {
+                        if (advance.id === params.advance_id) {
+                            stgAudit.push({ aid: advance.uid, status: advance.status, opinion: '同意', end_time: advance.end_time, order: 0 }); // 加上原报
+                            break;
+                        }
+                    }
+                    const advanceAuditList = await ctx.service.advanceAudit.getAuditAdvanceByTender(params.tender_id);
+                    advanceAuditList.forEach(advAudit => {
+                        if (advAudit.vid === params.advance_id) {
+                            stgAudit.push({ aid: advAudit.autdit_id, status: advAudit.status, opinion: advAudit.opinion, end_time: advAudit.end_time, times: advAudit.times, order: advAudit.order });
+                        }
+                    });
+                    break;
+                case -500: // 材差
+                    const materialList = await ctx.service.material.getValidMaterials(params.tender_id);
+                    for (const material of materialList) {
+                        if (material.id === params.material_id) {
+                            stgAudit.push({ aid: material.user_id, status: material.status, opinion: '同意', end_time: material.in_time, order: 0 }); // 加上原报
+                        }
+                    }
+                    const materialAdjAuditList = await ctx.service.materialAudit.getAuditorsByTender(params.tender_id);
+                    materialAdjAuditList.forEach(material => {
+                        if (material.id === params.material_id) {
+                            stgAudit.push({ aid: material.aid, status: material.status, opinion: material.opinion, end_time: material.end_time, order: material.order }); // 加上原报
+                        }
+                    });
+                    break;
                 default:
                     break;
             }

+ 12 - 0
app/service/advance_audit.js

@@ -687,6 +687,18 @@ module.exports = app => {
         }
 
         /**
+         * 获取tender下所有的审核列表(报表用)
+         * @param {Number} tenderId
+         */
+        async getAuditAdvanceByTender(tenderId) {
+            const sql = 'SELECT ma.`tid`, ma.`vid`, ma.`type`, ma.`times`, ma.`order`, ma.`audit_id`, ma.`status`, ma.`create_time`, ma.`end_time`, ma.`opinion`' +
+                        '  FROM ?? AS ma ' +
+                        '  WHERE ma.`tid` = ?';
+            const sqlParam = [this.tableName, tenderId];
+            return await this.db.query(sql, sqlParam);
+        }
+
+        /**
          * 获取审核人审核的次数
          *
          * @param auditorId

+ 12 - 0
app/service/material_audit.js

@@ -895,6 +895,18 @@ module.exports = app => {
         }
 
         /**
+         * 获取tender下所有的审核列表(报表用)
+         * @param {Number} tenderId
+         */
+        async getAuditorsByTender(tenderId) {
+            const sql = 'SELECT la.`tid`, la.`mid`, la.`aid`, la.`order`, la.`times`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`' +
+                '  FROM ?? AS la ' +
+                '  WHERE la.`tid` = ?';
+            const sqlParam = [this.tableName, tenderId];
+            return await this.db.query(sql, sqlParam);
+        }
+
+        /**
          * 复制上一期的审批人列表给最新一期
          *
          * @param transaction - 新增一期的事务

+ 34 - 5
app/view/report/index.ejs

@@ -524,13 +524,35 @@
     const ALL_CHANGES = <%- changes %>;
     const BGL_OBJ = <%- bglObj %>;
     const ADVANCE_LIST = <%- advanceList %>;
+    const ADVANCE_AUDIT_LISt = <%- advanceAuditList %>;
     ADVANCE_LIST.sort(function(a1, a2) {
         return a1.order - a2.order;
     });
+    ADVANCE_AUDIT_LISt.sort(function(aa1, aa2) {
+        let rst = aa1.vid - aa2.vid;
+        if (rst === 0) {
+            rst = aa1.order - aa2.order;
+            if (rst === 0) {
+                rst = aa2.times - aa1.times; // 这个排序是为了后续判断方便,只需要找第一个符合advance_id即可,无需再循环
+            }
+        }
+        return rst;
+    });
     const MATERIAL_LIST = <%- materialAdjList %>;
     MATERIAL_LIST.sort(function(m1, m2) {
         return m1.order - m2.order;
     });
+    const MATERIAL_AUDIT_LIST = <%- materialAdjAuditList %>;
+    MATERIAL_AUDIT_LIST.sort(function(ma1, ma2) {
+        let rst = ma1.mid - ma2.mid;
+        if (rst === 0) {
+            rst = ma1.order - ma2.order;
+            if (rst === 0) {
+                rst = ma2.times - ma1.times; // 这个排序是为了后续判断方便,只需要找第一个符合advance_id即可,无需再循环
+            }
+        }
+        return rst;
+    });
     const CHANGE_ID = BGL_OBJ?.change?.cid || '-1';
     const CHANGE_TIMES = BGL_OBJ?.change?.times || 1;
     let BUSINESS_ID = BGL_OBJ?.BUSINESS_ID || '-1';
@@ -829,7 +851,9 @@
             }
         }
         const maxIdx = (adList.length - 1) || 0;
-        adList.forEach((advance, adIndex) => {
+        for (let adIndex = adList.length - 1; adIndex >= 0; adIndex--) {
+            const advance = adList[adIndex];
+        // adList.forEach((advance, adIndex) => {
             let dispStr = '';
             current_advance_order = adIndex + 1;
             if (!hasMatch && adIndex === maxIdx || current_advance_id === advance.id) {
@@ -840,7 +864,8 @@
             }
             const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentAdvance(this)" advance_id = "${advance.id}" advance_order="${current_advance_order}">第${current_advance_order}期</a>`;
             $("#optionSelectableAdvancePays").append(str);
-        });
+        // });
+        }
         if (current_advance_id > 0) {
             getReportArchive();
         }
@@ -850,7 +875,9 @@
         $("#optionSelectableMaterials").empty();
         $("#btnCurrentMaterial")[0].innerText = '';
         const maxIdx = (MATERIAL_LIST.length - 1) || 0;
-        MATERIAL_LIST.forEach((materialAdj, maIndex) => {
+        for (let maIndex = MATERIAL_LIST.length - 1; maIndex >= 0; maIndex--) {
+            const materialAdj = MATERIAL_LIST[maIndex];
+        // MATERIAL_LIST.forEach((materialAdj, maIndex) => {
             let dispStr = '';
             current_material_order = maIndex + 1;
             if (current_material_id === -1 && maIndex === maxIdx || current_material_id === materialAdj.id) {
@@ -859,9 +886,10 @@
                 $("#btnCurrentMaterial")[0].innerText = `第${current_material_order}期`;
                 dispStr = ';display:none';
             }
-            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentMaterial(this)" material_id = "${materialAdj.id}">第${current_material_order}期</a>`;
+            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentMaterial(this)" material_id = "${materialAdj.id}" material_order="${current_material_order}">第${current_material_order}期</a>`;
             $("#optionSelectableMaterials").append(str);
-        });
+        // });
+        }
         if (current_material_id > 0) {
             getReportArchive();
         }
@@ -887,6 +915,7 @@
         $('#optionSelectableMaterials a').show();
         $(ele).hide();
         current_material_id = +ele.attributes[3].value;
+        current_material_order = +ele.attributes[4].value;
         BUSINESS_ID = current_material_id;
         $('#optionSelectableMaterials').siblings('button').text($(ele).text());
         // 刷新报表模板