瀏覽代碼

变更令列表展示状态筛选及状态列

ellisran 1 年之前
父節點
當前提交
ccc766a75b
共有 4 個文件被更改,包括 80 次插入33 次删除
  1. 15 2
      app/controller/change_controller.js
  2. 28 13
      app/public/js/change.js
  3. 16 14
      app/service/change.js
  4. 21 4
      app/view/change/index.ejs

+ 15 - 2
app/controller/change_controller.js

@@ -52,8 +52,9 @@ module.exports = app => {
             const pageSize = ctx.pageSize;
             const sorts = ctx.query.sort ? ctx.query.sort : 0;
             const orders = ctx.query.order ? ctx.query.order : 0;
-            const changes = await ctx.service.change.getListByStatus(tender.id, status, 1, sorts, orders);
-            const total = await ctx.service.change.getCountByStatus(tender.id, status);
+            const state = ctx.session.sessionProject.page_show.openChangeState && ctx.query.state ? parseInt(ctx.query.state) : 0;
+            const changes = await ctx.service.change.getListByStatus(tender.id, status, 1, sorts, orders, state);
+            const total = await ctx.service.change.getCountByStatus(tender.id, status, state);
             let page_total = 0;
             const tp = await ctx.service.change.getTp(tender.id, status);
             if (changes !== null) {
@@ -167,6 +168,7 @@ module.exports = app => {
                 dealCode: ctx.tender.info.deal_info.dealCode,
                 auditConst: audit.flow,
                 changeConst,
+                state,
                 ruleType: codeRuleConst.ruleType.change,
                 ruleConst: codeRuleConst.measure,
                 tenderMenu: this.menu.tenderMenu,
@@ -175,6 +177,17 @@ module.exports = app => {
                 changePlanList,
                 apLists,
             };
+
+            if (ctx.session.sessionProject.page_show.openChangeState) {
+                // 工程变更类别读取
+                const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
+                const fun_set = await ctx.service.project.getFunSet(projectData.fun_set);
+                const changeState = fun_set.change_state;
+                for (const cs of changeState) {
+                    cs.count = await ctx.service.change.getCountByStatus(tender.id, status, cs.order);
+                }
+                renderData.changeState = changeState;
+            }
             await this.layout('change/index.ejs', renderData, 'change/modal.ejs');
         }
 

+ 28 - 13
app/public/js/change.js

@@ -289,19 +289,34 @@ $(document).ready(() => {
 
     //状态切换
     $('#status_select a').on('click', function () {
-       const status = $(this).data('val');
-       let url = '/tender/'+ $('#tenderId').val() +'/change';
-       if (status !== 0) {
-           url += '/status/'+ status;
-       }
-       const filterString = setChangeFilterData('change-'+ $('#tenderId').val() +'-list-order');
-       if (filterString) url = url + filterString;
-        // let orderSetting = getLocalCache('change-'+ $('#tenderId').val() +'-list-order');
-       // if (orderSetting) {
-       //     const orders = orderSetting.split('|');
-       //     url += '?sort=' + orders[0] + '&order=' + orders[1];
-       // }
-       window.location.href = url;
+        const status = parseInt($(this).data('val'));
+        let url = '/tender/'+ $('#tenderId').val() +'/change';
+        if (status !== 0) {
+            url += '/status/'+ status;
+        }
+        const state = parseInt($('#state_zhankai').attr('data-value')) || 0;
+        const filterString = setChangeFilterData('change-'+ $('#tenderId').val() +'-list-order');
+        url = filterString ? url + filterString : url;
+        if (state) {
+            url = filterString ? url + '&state=' + state : url + '?state=' + state;
+        }
+        window.location.href = url;
+    });
+
+    //变更令状态切换
+    $('#state_select a').on('click', function () {
+        const state = parseInt($(this).data('val'));
+        let url = '/tender/'+ $('#tenderId').val() +'/change';
+        const status = parseInt($('#zhankai').attr('data-value'));
+        if (status !== 0) {
+            url += '/status/'+ status;
+        }
+        const filterString = setChangeFilterData('change-'+ $('#tenderId').val() +'-list-order');
+        url = filterString ? url + filterString : url;
+        if (state) {
+            url = filterString ? url + '&state=' + state : url + '?state=' + state;
+        }
+        window.location.href = url;
     });
     // 不再显示首次使用
     $('#changeFirst').click(function () {

+ 16 - 14
app/service/change.js

@@ -255,18 +255,19 @@ module.exports = app => {
          * @param {int} hadlimit - 分页
          * @return {object} list - 列表
          */
-        async getListByStatus(tenderId, status = 0, hadlimit = 1, sortBy = '', orderBy = '') {
+        async getListByStatus(tenderId, status = 0, hadlimit = 1, sortBy = '', orderBy = '', state = 0) {
             let sql = '';
             let sqlParam = '';
+            const stateSql = state ? ' AND a.state = ' + state : '';
             if (this.ctx.tender.isTourist && status === 0) {
-                sql = 'SELECT a.* FROM ?? As a WHERE a.tid = ?';
+                sql = 'SELECT a.* FROM ?? As a WHERE a.tid = ?' + stateSql;
                 sqlParam = [this.tableName, tenderId];
             } else {
                 switch (status) {
                     case 0: // 包含你的所有变更令
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND ' +
-                            '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid)) OR a.status = ? )';
+                            '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid)) OR a.status = ? )' + stateSql;
                         sqlParam = [
                             this.tableName,
                             tenderId,
@@ -278,14 +279,14 @@ module.exports = app => {
                         ];
                         break;
                     case 1: // 待处理(你的)
-                        sql = 'SELECT a.* FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)';
+                        sql = 'SELECT a.* FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)' + stateSql;
                         sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
                         break;
                     case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
                             'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND ' +
-                            '(a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?';
+                            '(a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql;
                         sqlParam = [
                             this.tableName,
                             this.ctx.service.changeAudit.tableName,
@@ -301,11 +302,11 @@ module.exports = app => {
                         sql =
                             'SELECT a.* FROM ?? AS a WHERE ' +
                             'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) AND ' +
-                            'a.status = ? AND a.tid = ?';
+                            'a.status = ? AND a.tid = ?' + stateSql;
                         sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId, status, tenderId];
                         break;
                     case 3: // 已完成(所有的)
-                        sql = 'SELECT a.* FROM ?? AS a WHERE a.status = ? AND a.tid = ?';
+                        sql = 'SELECT a.* FROM ?? AS a WHERE a.status = ? AND a.tid = ?' + stateSql;
                         sqlParam = [this.tableName, status, tenderId];
                         break;
                     default:
@@ -337,9 +338,10 @@ module.exports = app => {
          * @param {int} status - 状态
          * @return {void}
          */
-        async getCountByStatus(tenderId, status) {
+        async getCountByStatus(tenderId, status, state = 0) {
+            const stateSql = state ? ' AND a.state = ' + state : '';
             if (this.ctx.tender.isTourist && status === 0) {
-                const sql5 = 'SELECT count(*) AS count FROM ?? WHERE tid = ? ORDER BY in_time DESC';
+                const sql5 = 'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ?' + stateSql + ' ORDER BY a.in_time DESC';
                 const sqlParam5 = [this.tableName, tenderId];
                 const result5 = await this.db.query(sql5, sqlParam5);
                 return result5[0].count;
@@ -348,7 +350,7 @@ module.exports = app => {
                 case 0: // 包含你的所有变更令
                     const sql =
                         'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ? AND ' +
-                        '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid)) OR a.status = ? )';
+                        '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid)) OR a.status = ? )' + stateSql;
                     const sqlParam = [
                         this.tableName,
                         tenderId,
@@ -366,7 +368,7 @@ module.exports = app => {
                     //     uid: this.ctx.session.sessionUser.accountId,
                     //     status: 2,
                     // });
-                    const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)';
+                    const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)' + stateSql;
                     const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
                     const result6 = await this.db.query(sql6, sqlParam6);
                     return result6[0].count;
@@ -374,7 +376,7 @@ module.exports = app => {
                     const sql2 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
                         'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) ' +
-                        'AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?';
+                        'AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql;
                     const sqlParam2 = [
                         this.tableName,
                         this.ctx.service.changeAudit.tableName,
@@ -390,12 +392,12 @@ module.exports = app => {
                 case 4: // 终止(所有的)
                     const sql3 =
                         'SELECT count(*) AS count FROM ?? AS a WHERE ' +
-                        'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) AND a.status = ? AND a.tid = ?';
+                        'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) AND a.status = ? AND a.tid = ?' + stateSql;
                     const sqlParam3 = [this.tableName, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId, status, tenderId];
                     const result3 = await this.db.query(sql3, sqlParam3);
                     return result3[0].count;
                 case 3: // 已完成(所有的)
-                    const sql4 = 'SELECT count(*) AS count FROM ?? WHERE status = ? AND tid = ?';
+                    const sql4 = 'SELECT count(*) AS count FROM ?? AS a WHERE a.status = ? AND a.tid = ?' + stateSql;
                     const sqlParam4 = [this.tableName, status, tenderId];
                     const result4 = await this.db.query(sql4, sqlParam4);
                     return result4[0].count;

+ 21 - 4
app/view/change/index.ejs

@@ -41,7 +41,7 @@
                 </div>
                 <div class="d-inline-block">
                     <div class="btn-group">
-                        <button type="button" class="btn btn-sm btn-light text-primary dropdown-toggle" data-toggle="dropdown" id="zhankai"><% if (status !== 0) { %><%- filter.statusString[status] %>(<%- filter.count[status] %>)<% } else { %>全部<% } %></button>
+                        <button type="button" class="btn btn-sm btn-light text-primary dropdown-toggle" data-toggle="dropdown" id="zhankai" data-value="<%- status %>"><% if (status !== 0) { %><%- filter.statusString[status] %>(<%- filter.count[status] %>)<% } else { %>全部<% } %></button>
                         <div class="dropdown-menu" aria-labelledby="zhankai" id="status_select">
                             <% if (status !== 0) { %><a class="dropdown-item" data-val="0" href="javascript:void(0);">全部</a><% } %>
                             <% for (const fs in filter.status) { %>
@@ -51,6 +51,19 @@
                         </div>
                     </div>
                 </div>
+                <% if (ctx.session.sessionProject.page_show.openChangeState) { %>
+                <div class="d-inline-block">
+                    <div class="btn-group">
+                        <button type="button" class="btn btn-sm btn-light text-primary dropdown-toggle" data-toggle="dropdown" id="state_zhankai" data-value="<%- state %>">变更令状态:<% if (state !== 0) { %><%- ctx.helper._.find(changeState, { order: state }).name %>(<%- ctx.helper._.find(changeState, { order: state }).count %>)<% } else { %>全部<% } %></button>
+                        <div class="dropdown-menu" aria-labelledby="state_zhankai" id="state_select">
+                            <% if (state !== 0) { %><a class="dropdown-item" data-val="0" href="javascript:void(0);">全部</a><% } %>
+                            <% for (const cs of changeState) { %>
+                                <% if (cs.order !== state) { %><a class="dropdown-item" data-val="<%- cs.order %>" href="javascript:void(0);"><%- cs.name %>(<%- cs.count %>)</a><% } %>
+                            <% } %>
+                        </div>
+                    </div>
+                </div>
+                <% } %>
                 <div class="d-inline-block">
                     <span class="ml-3">本页小计:<%- page_total %>元</span><span class="ml-3">合计:<%- tp %>元</span>
                 </div>
@@ -73,9 +86,10 @@
                     <thead>
                     <tr>
                         <th width="18%" id="sort_change">申请编号/变更令号</th><th width="24%">变更工程名称</th>
-                        <th width="8%">变更性质</th><th width="8%">变更金额</th>
-                        <th width="8%">正变更金额</th><th width="8%">负变更金额</th>
-                        <th width="10%">审批状态</th><th width="12%">审批进度</th><th width="4%"></th>
+                        <th width="8%">变更性质</th><% if (ctx.session.sessionProject.page_show.openChangeState) { %><th width="8%">变更令状态</th><% } %>
+                        <th width="8%">变更金额</th><th width="8%">正变更金额</th>
+                        <th width="8%">负变更金额</th><th width="10%">审批状态</th>
+                        <th width="12%">审批进度</th><th width="4%"></th>
                     </tr>
                     </thead>
                     <tbody id="changeList">
@@ -89,6 +103,9 @@
                         <td><a href="/tender/<%- tender.id %>/change/<%- c.cid %>/information"><% if (c.status !== auditConst.status.checked) { %><%- c.code %><% } else { %><%- c.p_code %><% } %></a></td>
                         <td><%- c.name %></td>
                         <td><%- qualityArray[c.quality] %><% c.quality %></td>
+                        <% if (ctx.session.sessionProject.page_show.openChangeState) { %>
+                        <td><%- ctx.helper._.find(changeState, { order: c.state }).name %></td>
+                        <% } %>
                         <td style="text-align: right"><%= ctx.helper.roundNum(c.total_price, tpUnit) %></td>
                         <td style="text-align: right"><%= ctx.helper.roundNum(c.positive_tp, tpUnit) %></td>
                         <td style="text-align: right"><%= ctx.helper.roundNum(c.negative_tp, tpUnit) %></td>