浏览代码

待办页计量期待上报展示调整

ellisran 6 月之前
父节点
当前提交
ca6e442aab
共有 2 个文件被更改,包括 27 次插入5 次删除
  1. 26 4
      app/service/stage_audit.js
  2. 1 1
      app/view/dashboard/index.ejs

+ 26 - 4
app/service/stage_audit.js

@@ -1570,8 +1570,7 @@ module.exports = app => {
                 '  FROM ?? AS sa ' +
                 '    Left Join ?? AS s On sa.`sid` = s.`id` ' +
                 '    Left Join ?? As t ON sa.`tid` = t.`id`' +
-                '  WHERE ((sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1))' +
-                '  OR (s.`user_id` = ? and s.`status` = ? and sa.`times` = s.`times`))' +
+                '  WHERE (sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1))' +
                 '  ORDER BY sa.`begin_time` DESC';
             const sqlParam = [
                 this.tableName,
@@ -1582,19 +1581,42 @@ module.exports = app => {
                 auditorId,
                 auditConst.status.checkNo,
                 auditConst.status.checkNo,
-                auditorId,
-                auditConst.status.uncheck,
             ];
             const result = await this.db.query(sql, sqlParam);
             // 过滤result中存在重复sid的值, 保留最新的一条
+            const sql1 = 'SELECT s.`order` As `sorder`, s.`status` AS `sstatus`, s.`in_time` AS `begin_time`,' +
+                ' t.`name`, t.`project_id`, t.`type`, t.`user_id`' +
+                ' FROM ?? AS s' +
+                ' Left Join ?? As t ON s.`tid` = t.`id`' +
+                ' WHERE s.`user_id` = ? and s.`status` != ?' +
+                ' ORDER BY s.`in_time` ASC';
+            const sqlParam1 = [this.ctx.service.stage.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checked];
+            const result1 = await this.db.query(sql1, sqlParam1);
+            const filterResult1 = [];
+            const tidArr = [];
+            for (const res of result1) {
+                if (tidArr.indexOf(res.tid) === -1) {
+                    tidArr.push(res.tid);
+                    if (res.sstatus === auditConst.status.uncheck) {
+                        filterResult1.push(res);
+                    }
+                }
+            }
             const filterResult = [];
             const sidArr = [];
             for (const r of result) {
                 if (sidArr.indexOf(r.sid) === -1) {
                     filterResult.push(r);
                     sidArr.push(r.sid);
+                    if (tidArr.indexOf(r.tid) !== -1) {
+                        const index = filterResult1.findIndex(item => item.tid === r.tid);
+                        if (index !== -1) filterResult1.splice(index, 1);
+                    }
                 }
             }
+            // 合并并按begin_time排序
+            filterResult.push(...filterResult1);
+            filterResult.sort((a, b) => b.begin_time - a.begin_time);
             return filterResult;
         }
 

+ 1 - 1
app/view/dashboard/index.ejs

@@ -141,7 +141,7 @@
                                                     <td><span class="bg-new-stage text-new-stage badge text-width">计量审批</span></td>
                                                     <td><a href="/tender/<%- audit.tid %>"><%- audit.name %></a> <a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>">第<%- audit.sorder %>期</a></td>
                                                     <td>第<%- audit.sorder %>期</td>
-                                                    <td><%- ctx.moment(audit.in_time).format('YYYY/MM/DD HH:mm') %></td>
+                                                    <td><%- ctx.moment(audit.begin_time).format('YYYY/MM/DD HH:mm') %></td>
                                                     <td><a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>" class="btn btn-outline-primary btn-sm btn-table" role="button">上报</a></td>
                                                 </tr>
                                             <% } else { %>