Browse Source

修复变更审批人审批中页面流程bug

laiguoran 5 years ago
parent
commit
fe9e85da34
3 changed files with 30 additions and 21 deletions
  1. 4 3
      app/controller/change_controller.js
  2. 15 7
      app/service/change_audit.js
  3. 11 11
      app/view/change/info_modal.ejs

+ 4 - 3
app/controller/change_controller.js

@@ -414,10 +414,11 @@ module.exports = app => {
                     // 展示页左侧审批流程列表和清单审批列表数据
                     const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, change.times);
                     renderData.auditList2 = auditList2;
-                    for (const i in auditList) {
-                        auditList[i].max_sort = auditList2.length - 1;
+                    const auditList3 = await ctx.service.changeAudit.getListOrderByTimes(change.cid, change.times);
+                    for (const i in auditList3) {
+                        auditList3[i].max_sort = auditList2.length - 1;
                     }
-                    renderData.auditList = auditList;
+                    renderData.auditList3 = auditList3;
                     renderData.changeList = changeList.sort();
                     let ototalCost = 0;
                     let ctotalCost = 0;

+ 15 - 7
app/service/change_audit.js

@@ -157,13 +157,13 @@ module.exports = app => {
                     sqlParam = [this.tableName, change.cid];
                     break;
                 case 6: // 审批中
-                    // sql = 'SELECT * FROM (SELECT MAX(usort) as ust FROM ?? ' +
-                    //     'WHERE cid = ? and times = ? GROUP BY usite ) as b ' +
-                    //     'JOIN ?? as a ON a.usort = b.ust WHERE cid = ? and times = ? ORDER BY usite';
-                    // sqlParam = [this.tableName, change.cid, change.times, this.tableName, change.cid, change.times];
-                    sql = 'SELECT * FROM ?? WHERE ' +
-                        'cid = ? AND times = ? ORDER BY usort';
-                    sqlParam = [this.tableName, change.cid, change.times];
+                    sql = 'SELECT * FROM (SELECT MAX(usort) as ust FROM ?? ' +
+                        'WHERE cid = ? and times = ? GROUP BY usite ) as b ' +
+                        'JOIN ?? as a ON a.usort = b.ust WHERE cid = ? and times = ? ORDER BY usite';
+                    sqlParam = [this.tableName, change.cid, change.times, this.tableName, change.cid, change.times];
+                    // sql = 'SELECT * FROM ?? WHERE ' +
+                    //     'cid = ? AND times = ? ORDER BY usort';
+                    // sqlParam = [this.tableName, change.cid, change.times];
                     break;
                 default:// 无权限查看此变更令
                     break;
@@ -213,6 +213,14 @@ module.exports = app => {
             return list;
         }
 
+        async getListOrderByTimes(cid, times) {
+            const sql = 'SELECT * FROM ?? WHERE ' +
+                'cid = ? AND times = ? ORDER BY usort';
+            const sqlParam = [this.tableName, cid, times];
+            const list = await this.db.query(sql, sqlParam);
+            return list;
+        }
+
         /**
          * 获取比sort大的审批人列表
          * @param {Object} cid - 变更令id

+ 11 - 11
app/view/change/info_modal.ejs

@@ -456,9 +456,9 @@
                                             </li>
                                         <% } else { %>
                                             <li class="list-group-item">
-                                                <% if (index+1 !== auditList.length) { %>
+                                                <% if (index+1 !== auditList2.length) { %>
                                                     <i class="fa fa-chevron-circle-down"></i>
-                                                <% } else if (index+1 === auditList.length) { %>
+                                                <% } else if (index+1 === auditList2.length) { %>
                                                     <i class="fa fa-stop-circle"></i>
                                                 <% } %>
                                                 <%= a.name %> <small class="text-muted"><%= a.jobs %></small><span class="pull-right"><%= index+1 === auditList2.length ? '终' : ctx.helper.transFormToChinese(index) %>审</span>
@@ -471,7 +471,7 @@
                         <div class="col-8 modal-height-500" style="overflow: auto">
                             <div class="card mt-3">
                                 <ul class="list-group list-group-flush">
-                                    <% for (const [index,a] of auditList.entries()) { %>
+                                    <% for (const [index,a] of auditList3.entries()) { %>
                                         <li class="list-group-item">
                                         <% if (a.usite === 0 ) { %>
                                             <h5 class="card-title">
@@ -483,7 +483,7 @@
                                             </div>
                                         <% } else { %>
                                             <h5 class="card-title">
-                                                <i class="fa <% if (index+1 !== auditList.length) { %>fa-chevron-circle-down <% } else { %>fa-stop-circle <% } %><% if (a.status === 3) { %>text-success<% } else if (a.status === 4) { %>text-danger<% } else if (a.status === 6 || a.status === 7) { %>text-warning<% } %>"></i>
+                                                <i class="fa <% if (index+1 !== auditList3.length) { %>fa-chevron-circle-down <% } else { %>fa-stop-circle <% } %><% if (a.status === 3) { %>text-success<% } else if (a.status === 4) { %>text-danger<% } else if (a.status === 6 || a.status === 7) { %>text-warning<% } %>"></i>
                                                 <%= a.name %>&nbsp;<small class="text-muted"><%= a.jobs%></small><span class="pull-right"><%= a.max_sort === a.usite ? '终' : ctx.helper.transFormToChinese(a.usite) %>审</span>
                                             </h5>
                                             <div class="ml-3">
@@ -503,14 +503,14 @@
                                                     <label>审批意见<b class="text-danger">*</b></label>
                                                     <textarea class="form-control form-control-sm" name="sdesc">同意</textarea>
                                                     <input type="hidden" name="audit_id" value="<%= a.id %>">
-                                                    <% if (a.usort !== 0 && index+1 === auditList.length) { %>
+                                                    <% if (a.usort !== 0 && index+1 === auditList3.length) { %>
                                                         <!--终审填写批复编号-->
                                                         <div class="form-group mt-3">
                                                             <label><b class="text-danger">*&nbsp;</b>变更令号(批复编号)</label>
                                                             <input class="form-control form-control-sm" value="<%= change.code %>" name="p_code" type="text">
                                                         </div>
                                                     <% } else { %>
-                                                        <input type="hidden" name="audit_next_id" value="<%= auditList[index+1].id %>">
+                                                        <input type="hidden" name="audit_next_id" value="<%= auditList3[index+1].id %>">
                                                     <% } %>
                                                 </div>
                                             <% } %>
@@ -553,9 +553,9 @@
                                             </li>
                                         <% } else { %>
                                             <li class="list-group-item">
-                                                <% if (index+1 !== auditList.length) { %>
+                                                <% if (index+1 !== auditList2.length) { %>
                                                     <i class="fa fa-chevron-circle-down"></i>
-                                                <% } else if (index+1 === auditList.length) { %>
+                                                <% } else if (index+1 === auditList2.length) { %>
                                                     <i class="fa fa-stop-circle"></i>
                                                 <% } %>
                                                 <%= a.name %> <small class="text-muted"><%= a.jobs %></small><span class="pull-right"><%= index+1 === auditList2.length ? '终' : ctx.helper.transFormToChinese(index) %>审</span>
@@ -568,7 +568,7 @@
                         <div class="col-8 modal-height-500" style="overflow: auto">
                             <div class="card mt-3">
                                 <ul class="list-group list-group-flush">
-                                    <% for (const [index,a] of auditList.entries()) { %>
+                                    <% for (const [index,a] of auditList3.entries()) { %>
                                         <li class="list-group-item">
                                             <% if (a.usite === 0 ) { %>
                                                 <h5 class="card-title">
@@ -580,7 +580,7 @@
                                                 </div>
                                             <% } else { %>
                                                 <h5 class="card-title">
-                                                    <i class="fa <% if (index+1 !== auditList.length) { %>fa-chevron-circle-down <% } else { %>fa-stop-circle <% } %><% if (a.status === 3) { %>text-success<% } else if (a.status === 4) { %>text-danger<% } else if (a.status === 6 || a.status === 7) { %>text-warning<% } %>"></i>
+                                                    <i class="fa <% if (index+1 !== auditList3.length) { %>fa-chevron-circle-down <% } else { %>fa-stop-circle <% } %><% if (a.status === 3) { %>text-success<% } else if (a.status === 4) { %>text-danger<% } else if (a.status === 6 || a.status === 7) { %>text-warning<% } %>"></i>
                                                     <%= a.name %>&nbsp;<small class="text-muted"><%= a.jobs%></small><span class="pull-right"><%= a.max_sort === a.usite ? '终' : ctx.helper.transFormToChinese(a.usite) %>审</span>
                                                 </h5>
                                                 <div class="ml-3">
@@ -604,7 +604,7 @@
                                                     <div class="alert alert-warning">
                                                         <div class="form-check form-check-inline">
                                                             <input class="form-check-input" type="radio" name="status" id="change-back" value="5" <% if (index === 1) { %>checked<% } %>>
-                                                            <label class="form-check-label" for="change-back">退回上报 <%= auditList[0].name %></label>
+                                                            <label class="form-check-label" for="change-back">退回上报 <%= auditList3[0].name %></label>
                                                         </div>
                                                         <% if (index !== 1) { %>
                                                             <div class="form-check form-check-inline">