Browse Source

首页和规范列表排序

laiguoran 5 years ago
parent
commit
5c438762e5
2 changed files with 26 additions and 16 deletions
  1. 25 15
      app/service/valuation.js
  2. 1 1
      app/view/dashboard/index.ejs

+ 25 - 15
app/service/valuation.js

@@ -41,24 +41,34 @@ module.exports = app => {
             const valuation = await this.getDataById(id);
             const billsId = this._.map(valuation.bill_id.split(','), this._.toInteger);
             const chaptersId = this._.map(valuation.chapter_id.split(','), this._.toInteger);
-            const billsList = await this.db.select('zh_std_gcl_list', {
-                where: {id: billsId},
-                columns: ['id', 'name'],
-            });
-            billsList.sort(function (a, b) {
-                return billsId.indexOf(a.id) - billsList.indexOf(b.id);
-            });
-            const chapterList = await this.db.select('zh_std_xmj_list', {
-                where: {id: chaptersId},
-                columns: ['id', 'name'],
-            });
-            chapterList.sort(function (a, b) {
-                return chaptersId.indexOf(a.id) - chapterList.indexOf(b.id);
-            });
+            // const billsList = await this.db.select('zh_std_gcl_list', {
+            //     where: {id: billsId},
+            //     columns: ['id', 'name'],
+            // });
+            // billsList.sort(function (a, b) {
+            //     return billsId.indexOf(a.id) - billsList.indexOf(b.id);
+            // });
+            const sql = 'SELECT `id`, `name`' +
+                '  From ?? ' +
+                '  WHERE `id` in ( ? ) ORDER BY FIELD(`id`, ?)';
+            const sqlParam = ['zh_std_gcl_list', billsId, billsId];
+            const billsList = await this.db.query(sql, sqlParam);
+            // const chapterList = await this.db.select('zh_std_xmj_list', {
+            //     where: {id: chaptersId},
+            //     columns: ['id', 'name'],
+            // });
+            // chapterList.sort(function (a, b) {
+            //     return chaptersId.indexOf(a.id) - chapterList.indexOf(b.id);
+            // });
+            const sql2 = 'SELECT `id`, `name`' +
+                '  From ?? ' +
+                '  WHERE `id` in ( ? ) ORDER BY FIELD(`id`, ?)';
+            const sqlParam2 = ['zh_std_xmj_list', chaptersId, chaptersId];
+            const chapterList = await this.db.query(sql2, sqlParam2);
             return [billsList, chapterList];
         }
 
     }
 
     return Valuation;
-};
+};

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

@@ -24,7 +24,7 @@
                     <div class="media-body">
                         <span class="pull-right text-muted"><%- t.end_time.toLocaleString() %></span>
                         <h5 class="mt-0"><%- ctx.session.sessionUser.name %><small class="ml-3 text-muted"><%- role %></small></h5>
-                        <p><a href="/tender/<%- t.id %>"><%- t.name %></a> 台帐 需要您 <a href="/tender/<%- t.id %>/ledger/explode">重新上报</a>。</p>
+                        <p><a href="/tender/<%- t.id %>"><%- t.name %></a> 台帐 需要您 <a href="/tender/<%- t.id %>/ledger">重新上报</a>。</p>
                     </div>
                 </li>
                 <% } %>