Browse Source

变更令展示页功能和bug修复

laiguoran 6 years ago
parent
commit
d861cd8ab1

+ 11 - 6
app/const/audit.js

@@ -14,6 +14,7 @@ const status = {
     checked: 3,     // 审批完成
     checkNo: 4,     // 审批终止
     back: 5,        // 重新上报
+    backnew: 6,     // 退回
 };
 const statusButton = [];
 statusButton[status.uncheck] = '上报';
@@ -21,6 +22,7 @@ statusButton[status.checking] = '审批';
 statusButton[status.checked] = '';
 statusButton[status.checkNo] = '';
 statusButton[status.back] = '重新上报';
+statusButton[status.backnew] = '审批';
 
 const statusButtonClass = [];
 statusButtonClass[status.uncheck] = 'btn-primary';
@@ -28,20 +30,23 @@ statusButtonClass[status.checking] = 'btn-success';
 statusButtonClass[status.checked] = '';
 statusButtonClass[status.checkNo] = '';
 statusButtonClass[status.back] = 'btn-warning';
+statusButtonClass[status.backnew] = 'btn-success';
 
 const statusString = [];
 statusString[status.uncheck] = '';
 statusString[status.checking] = '审批中';
 statusString[status.checked] = '完成';
 statusString[status.checkNo] = '终止';
-statusString[status.back] = '退回';
+statusString[status.back] = '';
+statusString[status.backnew] = '退回';
 
 const statusClass = [];
 statusClass[status.uncheck] = '';
 statusClass[status.checking] = 'text-warning';
 statusClass[status.checked] = 'text-success';
 statusClass[status.checkNo] = 'text-danger';
-statusClass[status.back] = 'text-warning';
+statusClass[status.back] = '';
+statusClass[status.backnew] = 'text-warning';
 
 /* ------------------------------------------------------- */
 
@@ -76,10 +81,10 @@ auditStatusClass[auditStatus.backnew] = 'text-warning';
 const filter = {
     status: {
         pending: 1,
-        uncheck: 2,
-        checking: 3,
-        checked: 4,
-        checkNo: 5,
+        uncheck: 5,
+        checking: 2,
+        checked: 3,
+        checkNo: 4,
     },
     statusString: [],
 };

+ 81 - 4
app/controller/change_controller.js

@@ -45,8 +45,36 @@ module.exports = app => {
                 let i = 0;
                 for (const c of changes) {
                     const status = c.status === audit.flow.status.uncheck ? 0 : 1;
-                    const changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
+                    // 根据审批人对当前变更令的状态取不同的展示方式。
+                    let changeAudit = '';
+                    let auditStatus = 0;
+                    switch (c.status) {
+                        case 1:
+                            auditStatus = 1;
+                            break;
+                        case 2:
+                            changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
+                            auditStatus = changeAudit.uid === ctx.session.sessionUser.accountId ? 1 : 0;
+                            break;
+                        case 3:
+                        case 4:
+                            auditStatus = 0;
+                            changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
+                            break;
+                        case 5:
+                            changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times - 1, status);
+                            auditStatus = 1;
+                            break;
+                        case 6:
+                            changeAudit = await ctx.service.changeAudit.getLastBackUser(c.cid, c.times);
+                            const checkingAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times, status);
+                            auditStatus = checkingAudit.uid === ctx.session.sessionUser.accountId ? 1 : 0;
+                            break;
+                        default:
+                            break;
+                    }
                     changes[i].changeAudit = changeAudit;
+                    changes[i].auditStatus = auditStatus;
                     i++;
                 }
             }
@@ -233,8 +261,7 @@ module.exports = app => {
                 const attList = await ctx.service.changeAtt.getAllDataByCondition({ where: { cid: ctx.params.cid } });
 
                 // 根据auditStatus获取审批人列表
-                // const auditList = await ctx.service.changeAudit.getListByStatus(change, auditStatus);
-                const auditList = [];
+                const auditList = await ctx.service.changeAudit.getListByStatus(change, auditStatus);
 
                 // 获取已选清单
                 const changeList = await ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: ctx.params.cid } });
@@ -250,6 +277,7 @@ module.exports = app => {
                     whiteList,
                     auditList,
                     changeList,
+                    tpUnit: ctx.tender.info.decimal.tp,
                 };
                 // 根据auditStatus状态获取的不同的数据
                 if (auditStatus === 1 || auditStatus === 2) {
@@ -257,7 +285,6 @@ module.exports = app => {
                     const dealBillList = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: tenderid } });
                     renderData.dealBillList = dealBillList;
                     renderData.changeUnits = ctx.tender.info.precision;
-                    renderData.tpUnit = ctx.tender.info.decimal.tp;
                     // 根据清单获取提交数据和计算总金额
                     const changeListData = [];
                     const changeWhiteListData = [];
@@ -290,6 +317,56 @@ module.exports = app => {
                     // 获取公司列表
                     const companyList = await ctx.service.changeCompany.getAllDataByCondition({ where: { tid: tenderid } });
                     renderData.companyList = companyList;
+                } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) {
+                    // 展示页左侧审批流程列表和清单审批列表数据
+                    const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(change.cid, change.times);
+                    // renderData.auditList2 = auditList2;
+
+                    // 展示页右侧审批流程列表
+                    const auditList3 = [];
+                    for (let time = 1; time <= change.times; time++) {
+                        const auditTimeList = [];
+                        for (const al of auditList) {
+                            if (al.times === time) {
+                                auditTimeList.push(al);
+                            }
+                        }
+                        auditList3.push(auditTimeList);
+                    }
+                    renderData.auditList3 = auditList3;
+
+                    renderData.changeList = changeList.sort();
+                    let ototalCost = 0;
+                    let ctotalCost = 0;
+                    let stotalCost = 0;
+                    const auditTotalCost = [];
+                    for (const cl of changeList) {
+                        ototalCost += parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
+                        ctotalCost += parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
+                        stotalCost += cl.samount !== '' ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
+                        const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
+                        auditTotalCost.push(audit_amount);
+                    }
+                    console.log(auditTotalCost);
+                    renderData.ototalCost = ototalCost;
+                    renderData.ctotalCost = ctotalCost;
+                    renderData.stotalCost = stotalCost;
+
+                    // 清单表页赋值
+                    for (const [index, au] of auditList2.entries()) {
+                        if (au.usite !== 0) {
+                            au.list_amount = [];
+                            au.totalCost = 0;
+                            for (const [auindex, at] of auditTotalCost.entries()) {
+                                au.list_amount.push(at[index - 1]);
+                                au.totalCost += at[index - 1] !== undefined ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
+                            }
+                        }
+                    }
+                    console.log(auditList2);
+                    renderData.auditList2 = auditList2;
+                } else if (auditStatus === 6) {
+                    console.log('ok');
                 }
 
                 await this.layout('change/info.ejs', renderData, 'change/info_modal.ejs');

+ 1 - 12
app/public/js/change_detail.js

@@ -38,18 +38,7 @@ $(document).ready(() => {
         $('.show_title').hide();
         $('#'+ tab +'_title').show();
         if (tab === 'bills' && $('#bills').hasClass('first-bill-pane')) {
-            table = $('#tablelist').removeAttr('width').DataTable({
-                columnDefs: [
-                    { className: 'allwidth1', width: 100, targets: 0 },
-                    { className: 'allwidth2', width: 150, targets: [1,2] },
-                    { className: 'allwidth4', width: 40, targets: 9 },
-                    { className: 'allwidth5', width: 60, targets: 3 },
-                    { className: 'allwidth3',width: 80, targets: '_all' }
-                ],
-                fixedColumns: {
-                    leftColumns: 5
-                }
-            });
+            table = $('.table-list').removeAttr('width').DataTable(billsTable);
             $('#bills').removeClass('first-bill-pane');
         }
     });

+ 32 - 0
app/public/js/change_show.js

@@ -0,0 +1,32 @@
+'use strict';
+
+/**
+ * 变更令-展示页js
+ *
+ * @author EllisRan.
+ * @date 2018/11/22
+ * @version
+ */
+
+$(document).ready(() => {
+    $('#show-table-detail').click(function (e) {
+        if($(e.target).is('label')){
+            return;
+        }
+        table.destroy();
+        if ($(this).prop('checked')) {
+            $('#tablelist2').show();
+            $('#tablelist').hide();
+            table = $('#tablelist2').removeAttr('width').DataTable(billsTable);
+        } else {
+            $('#tablelist').show();
+            $('#tablelist2').hide();
+            table = $('#tablelist').removeAttr('width').DataTable(billsTable);
+        }
+        // 判断是否显示变更详情
+        if (!$('.change-detail-checkbox').is(':checked')) {
+            const column = table.column(2);
+            column.visible(!column.visible());
+        }
+    })
+});

+ 1 - 0
app/public/upload/changes/page.html

@@ -0,0 +1 @@
+当前页存变更令附件

+ 37 - 24
app/service/change.js

@@ -194,19 +194,19 @@ module.exports = app => {
                         this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
                     break;
                 case 1:// 待处理(你的)
-                    sql = 'SELECT * FROM ?? WHERE tid = ? AND uid = ? AND status = ? ORDER BY in_time DESC';
-                    sqlParam = [this.tableName, tenderId, this.ctx.session.sessionUser.accountId, status];
+                    sql = 'SELECT a.* FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?) ORDER BY in_time DESC';
+                    sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, 2];
                     break;
-                case 2:// 待上报(所有的)PS:取未上报和退回的变更令
+                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 = 1 OR a.status = 5) AND a.tid = ? ORDER BY a.in_time DESC';
                     sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName,
                         this.ctx.session.sessionUser.accountId, tenderId];
                     break;
-                case 3:// 进行中(所有的)
-                case 4:// 已完成(所有的)
-                case 5:// 终止(所有的)
+                case 2:// 进行中(所有的)
+                case 3:// 已完成(所有的)
+                case 4:// 终止(所有的)
                     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 = ? AND a.tid = ? ORDER BY a.in_time DESC';
@@ -241,21 +241,26 @@ module.exports = app => {
                     const result = await this.db.query(sql, sqlParam);
                     return result[0].count;
                 case 1:// 待处理(你的)
-                    return await this.count({
+                    return await this.ctx.service.changeAudit.count({
                         tid: tenderId,
                         uid: this.ctx.session.sessionUser.accountId,
-                        status,
+                        status: 2,
                     });
-                case 2:// 待上报(所有的)PS:取未上报和退回的变更令
-                    const sql2 = 'SELECT count(*) AS count FROM ?? AS a WHERE a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND (a.status = 1 OR a.status = 5) AND a.tid = ?';
-                    const sqlParam2 = [this.tableName, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId, tenderId];
+                case 5:// 待上报(所有的)PS:取未上报和退回的变更令
+                    const sql2 = 'SELECT count(*) AS count FROM ?? AS a WHERE ' +
+                        'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) ' +
+                        'AND (a.status = 1 OR a.status = 5) AND a.tid = ?';
+                    const sqlParam2 = [this.tableName, this.ctx.service.changeAudit.tableName,
+                        this.ctx.session.sessionUser.accountId, tenderId];
                     const result2 = await this.db.query(sql2, sqlParam2);
                     return result2[0].count;
-                case 3:// 进行中(所有的)
-                case 4:// 已完成(所有的)
-                case 5:// 终止(所有的)
-                    const sql3 = 'SELECT count(*) AS count FROM ?? AS a WHERE a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND a.status = ? AND a.tid = ?';
-                    const sqlParam3 = [this.tableName, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId, status, tenderId];
+                case 2:// 进行中(所有的)
+                case 3:// 已完成(所有的)
+                case 4:// 终止(所有的)
+                    const sql3 = 'SELECT count(*) AS count FROM ?? AS a WHERE ' +
+                        'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND a.status = ? AND a.tid = ?';
+                    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;
                 default:
@@ -274,19 +279,30 @@ module.exports = app => {
             this.transaction = await this.db.beginTransaction();
             let result = false;
             try {
+                // 变更令信息
                 const changeInfo = await this.getDataByCondition({ cid: postData.cid });
+                // 该变更令原报人信息
+                const lastUser = await this.ctx.service.changeAudit.getLastUser(changeInfo.cid, changeInfo.times, 0);
                 // 先删除本次原有的变更审批人和清单
                 await this.ctx.service.changeAudit.deleteAuditData(this.transaction, changeInfo.cid, changeInfo.times);
                 await this.transaction.delete(this.ctx.service.changeAuditList.tableName, { cid: changeInfo.cid });
+                let change_status = false;
+                // 获取变更令提交状态
+                if (postData.changestatus !== undefined && parseInt(postData.changestatus) === 1) {
+                    change_status = true;
+                    // 更新原报人审批状态
+                    await this.transaction.update(this.ctx.service.changeAudit.tableName, { id: lastUser.id, status: 3 });
+                }
                 // 再插入postData里的变更审批人和清单
                 if (postData.changeaudit !== undefined && postData.changeaudit !== '') {
-                    const lastUser = await this.ctx.service.changeAudit.getLastUser(changeInfo.cid, changeInfo.times, 0);
                     const changeAudit = postData.changeaudit.split(',');
                     const insertCA = [];
                     let uSite = 1;
                     let uSort = parseInt(lastUser.usort) + 1;
-                    for (const ca of changeAudit) {
+                    for (const [index, ca] of changeAudit.entries()) {
                         const auditInfo = ca.split('/%/');
+                        const uStatus = change_status && index === 0 ? 2 : 1;
+                        const sin_time = change_status && index === 0 ? new Date() : null;
                         const caArray = {
                             tid: tenderId,
                             cid: changeInfo.cid,
@@ -297,9 +313,8 @@ module.exports = app => {
                             times: changeInfo.times,
                             usite: uSite,
                             usort: uSort,
-                            status: 2,
-                            sdesc: '',
-                            sin_time: new Date(),
+                            status: uStatus,
+                            sin_time,
                         };
                         uSite++;
                         uSort++;
@@ -362,9 +377,7 @@ module.exports = app => {
                         cid: changeInfo.cid,
                     },
                 };
-
-                // 根据上报状态修改变更令状态和审批状态
-                if (postData.changestatus !== undefined && parseInt(postData.changestatus) === 1) {
+                if (change_status) {
                     cArray.status = 2;
                     cArray.cin_time = Date.parse(new Date()) / 1000;
                 }

+ 48 - 8
app/service/change_audit.js

@@ -50,7 +50,36 @@ module.exports = app => {
                     operate: '=',
                 });
             }
-            this.sqlBuilder.orderBy = [['usort', 'DESC']];
+            const u_sort = [['usort', 'DESC']];
+            this.sqlBuilder.orderBy = u_sort;
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
+            const data = await this.db.queryOne(sql, sqlParam);
+
+            return data;
+        }
+
+        /**
+         * 获取最后一位退回的审批人
+         * @param {int} cid - 变更令id
+         * @param {int} times - 次数
+         * @return {void}
+         */
+        async getLastBackUser(cid, times) {
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('cid', {
+                value: this.db.escape(cid),
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('times', {
+                value: times,
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('status', {
+                value: 6,
+                operate: '=',
+            });
+            const u_sort = [['usort', 'DESC']];
+            this.sqlBuilder.orderBy = u_sort;
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
             const data = await this.db.queryOne(sql, sqlParam);
 
@@ -119,14 +148,11 @@ module.exports = app => {
                 case 3: // 被退回但你不是原报人
                 case 4:// 已完成
                 case 5:// 已终止
-                    // 获取完整的审批顺序
-                    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 = ? AND a.tid = ?';
-                    sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName,
-                        this.ctx.session.sessionUser.accountId, status, ''];
-                    break;
                 case 7:// 审批中但你未到你审批或你已审批
+                    // 获取完整的审批顺序
+                    sql = 'SELECT * FROM ?? WHERE ' +
+                        'cid = ? ORDER BY usort';
+                    sqlParam = [this.tableName, change.cid];
                     break;
                 case 6:// 待你审批
                 default:// 无权限查看此变更令
@@ -162,6 +188,20 @@ module.exports = app => {
 
             return result;
         }
+
+        /**
+         * 获取不重复列表
+         * @param {Object} cid - 变更令id
+         * @param {int} times - 次数
+         * @return {object} 返回结果
+         */
+        async getListGroupByTimes(cid, times) {
+            const sql = 'SELECT * FROM ?? WHERE ' +
+                'cid = ? AND times = ? GROUP BY usite';
+            const sqlParam = [this.tableName, cid, times];
+            const list = await this.db.query(sql, sqlParam);
+            return list;
+        }
     }
 
     return ChangeAudit;

+ 9 - 16
app/view/change/index.ejs

@@ -39,33 +39,26 @@
                 <% } %>
                 <% for (const c of changes) { %>
                 <tr>
-                    <td><a href="change/<%- c.cid %>/info"><%- c.code %></a></td>
+                    <td><a href="/tender/<%- tender.id %>/change/<%- c.cid %>/info"><%- c.code %></a></td>
                     <td><%- c.name %></td>
                     <td><%- classArray[c.class] %><% c.class %></td>
                     <td><%- c.total_price %></td>
-                    <% if (uid === c.changeAudit.uid && c.status === auditConst.status.uncheck) { %>
+                    <% if (c.auditStatus) { %>
                     <td>
-                        <a href="change/<%- c.cid %>/info" class="btn <%- auditConst.statusButtonClass[c.status] %> btn-sm">
+                        <a href="/tender/<%- tender.id %>/change/<%- c.cid %>/info" class="btn <%- auditConst.statusButtonClass[c.status] %> btn-sm">
                             <%- auditConst.statusButton[c.status] %>
                         </a>
                     </td>
+                    <% } else {  %>
                     <td>
-                        待上报
-                    </td>
-                    <% } else if (uid === c.changeAudit.uid) { %>
-                    <td>
-                        <a href="change/<%- c.cid %>/info" class="btn <%- auditConst.statusButtonClass[c.status] %> btn-sm">
-                            <%- auditConst.statusButton[c.status] %>
-                        </a>
-                    </td>
-                    <td>
-                        <%- c.changeAudit.name %>-<%- c.changeAudit.jobs %>
-                        <span class="<%- auditConst.auditStatusClass[c.changeAudit.status] %>"><%- auditConst.auditStatusString[c.changeAudit.status] %></span>
+                        <span class="<%- auditConst.statusClass[c.status] %>"><%- auditConst.statusString[c.status] %></span>
                     </td>
-                    <% } else if (uid !== c.changeAudit.uid) { %>
+                    <% } %>
+                    <% if (c.status === auditConst.status.uncheck) { %>
                     <td>
-                        <span class="<%- auditConst.statusClass[c.status] %>"><%- auditConst.statusString[c.status] %></span>
+                        待上报
                     </td>
+                    <% } else { %>
                     <td>
                         <%- c.changeAudit.name %>-<%- c.changeAudit.jobs %>
                         <span class="<%- auditConst.auditStatusClass[c.changeAudit.status] %>"><%- auditConst.auditStatusString[c.changeAudit.status] %></span>

+ 167 - 21
app/view/change/info.ejs

@@ -58,6 +58,13 @@
     .bg-con-warp:nth-child(2) th{
         text-align: center !important;
     }
+    .change-title {
+        font-size: 16px;
+        margin: 0;
+        height: 50px;
+        line-height: 50px;
+        display: block;
+    }
 </style>
 <div class="panel-sidebar">
     <div class="panel-title">
@@ -85,39 +92,31 @@
         <div class="title-main d-flex justify-content-between">
             <h2 id="info_title" class="show_title">变更信息</h2>
             <div id="bills_title" class="show_title" style="display: none">
-                <% if (auditStatus === 1 || auditStatus === 2) { %>
                 <div>
+                    <% if (auditStatus === 1 || auditStatus === 2) { %>
                     <div class="d-inline-block">
                         <a href="#addlist" data-toggle="modal" class="btn btn-sm" id="open-list-modal" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="添加清单"><i class="fa fa-plus" aria-hidden="true"></i> 添加清单</a>
                     </div>
-                        <div class="d-inline-block ml-3">
-                        <div class="custom-control custom-checkbox" style="line-height: normal;">
-                            <input type="checkbox" class="custom-control-input change-detail-checkbox" id="customCheck1" checked>
-                            <label class="custom-control-label" for="customCheck1">变更详情</label>
-                        </div>
-                    </div>
-                </div>
-                <% } else { %>
-                <div>
+                    <% } else { %>
                     <div class="d-inline-block">
-                        <h2>变更清单</h2>
+                        <h2 class="change-title">变更清单</h2>
                     </div>
+                    <% } %>
                     <div class="d-inline-block ml-3">
                         <div class="custom-control custom-checkbox" style="line-height: normal;">
-                            <input type="checkbox" class="custom-control-input change-detail-checkbox" id="customCheck1">
+                            <input type="checkbox" class="custom-control-input change-detail-checkbox" id="customCheck1" checked>
                             <label class="custom-control-label" for="customCheck1">变更详情</label>
                         </div>
                     </div>
-                    <% if (auditStatus !== 6 ) { %>
+                    <% if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
                     <div class="d-inline-block ml-3">
                         <div class="custom-control custom-checkbox" style="line-height: normal;">
-                            <input type="checkbox" class="custom-control-input" id="customCheck1">
-                            <label class="custom-control-label" for="customCheck1">审批过程</label>
+                            <input type="checkbox" class="custom-control-input" id="show-table-detail">
+                            <label class="custom-control-label" for="show-table-detail">审批过程</label>
                         </div>
                     </div>
                     <% } %>
                 </div>
-                <% } %>
             </div>
             <div id="files_title" class="show_title" style="display: none">
                 <% if (auditStatus === 1 || auditStatus === 2 || auditStatus === 6) { %>
@@ -125,7 +124,7 @@
                     <i class="fa fa-cloud-upload" aria-hidden="true"></i> 上传附件
                 </a>
                 <% } else { %>
-                <h2>附件</h2>
+                <h2 class="change-title">附件</h2>
                 <% } %>
             </div>
             <input id="tenderId" value="<%= tender.id %>" type="hidden">
@@ -397,7 +396,7 @@
                         </div>
                         <div class="form-group">
                             <label><b class="text-danger">*&nbsp;</b>批复文号</label>
-                            <input class="form-control" id="w_code" placeholder="" type="text" value="<%- change.w_code %>" <% if (auditStatus === 6) { %>readonly<% } %>>
+                            <input class="form-control" id="w_code" placeholder="" type="text" value="<%- change.w_code %>" <% if (auditStatus !== 6) { %>readonly<% } %>>
                         </div>
                     </form>
                 </div>
@@ -408,7 +407,7 @@
         <div class="c-body tab-pane first-bill-pane" role="tabpanel" id="bills">
             <!--变更清单-->
             <% if (auditStatus === 1 || auditStatus === 2) { %>
-            <table class="table table-striped table-bordered nowrap qd-table" id="tablelist" cellspacing="0" style="width:100%">
+            <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist" cellspacing="0" style="width:100%">
                 <thead>
                 <tr>
                     <th rowspan="2" class="text-center">清单编号</th>
@@ -481,7 +480,121 @@
                 </tfoot>
             </table>
             <% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
+                <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist" cellspacing="0" style="width:100%">
+                    <thead>
+                    <tr>
+                        <th rowspan="2" class="text-center">清单编号</th>
+                        <th rowspan="2" class="text-center">名称</th>
+                        <th rowspan="2" class="text-center">变更详情</th>
+                        <th rowspan="2" class="text-center">单位</th>
+                        <th rowspan="2" class="text-center">单价</th>
+                        <th colspan="2" class="text-center">原设计</th>
+                        <th colspan="2" class="text-center">申报变更</th>
+                        <th colspan="2" class="text-center">审批后变更</th>
+                    </tr>
+                    <tr>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                    </tr>
+                    </thead>
+                    <tbody id="list">
+                    <% for (const cl of changeList.sort()) { %>
+                        <tr>
+                            <td><%= cl.code %></td>
+                            <td><%= cl.name %></td>
+                            <td><%= cl.detail %></td>
+                            <td><%= cl.unit %></td>
+                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
+                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
+                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                            <td><%= cl.samount !== '' ? ctx.helper.roundNum(cl.samount, ctx.helper.findDecimal(cl.unit)) : '' %></td>
+                            <td><%= cl.samount !== '' ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), tpUnit) : '' %></td>
+                            </td>
+                        </tr>
+                    <% } %>
+                    </tbody>
+                    <tfoot>
+                    <tr class="info">
+                        <td>合计</td><td></td><td></td><td></td><td></td><td></td>
+                        <td><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
+                        <td><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td><td></td>
+                        <td><%= stotalCost !== 0 ? ctx.helper.roundNum(stotalCost, tpUnit) : '' %></td>
+                    </tr>
+                    </tfoot>
+                </table>
 
+                <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist2" cellspacing="0" style="width:100%;display: none;">
+                    <thead>
+                    <tr>
+                        <th rowspan="2" class="text-center">清单编号</th>
+                        <th rowspan="2" class="text-center">名称</th>
+                        <th rowspan="2" class="text-center">变更详情</th>
+                        <th rowspan="2" class="text-center">单位</th>
+                        <th rowspan="2" class="text-center">单价</th>
+                        <th colspan="2" class="text-center">原设计</th>
+                        <th colspan="2" class="text-center">申报变更</th>
+                        <% for (const audit of auditList2) { %>
+                        <% if (audit.usite !== 0) { %>
+                        <th colspan="2" class="text-center"><%= audit.name %> 审批</th>
+                        <% } %>
+                        <% } %>
+                    </tr>
+                    <tr>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                        <% for (const audit of auditList2) { %>
+                            <% if (audit.usite !== 0) { %>
+                        <th class="text-center">数量</th>
+                        <th class="text-center">金额</th>
+                            <% } %>
+                        <% } %>
+                    </tr>
+                    </thead>
+                    <tbody id="list">
+                    <% const audittotalCost = []; %>
+                    <% for (const [cindex,cl] of changeList.sort().entries()) { %>
+                        <tr>
+                            <td><%= cl.code %></td>
+                            <td><%= cl.name %></td>
+                            <td><%= cl.detail %></td>
+                            <td><%= cl.unit %></td>
+                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
+                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                            <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
+                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                            <% for (const audit of auditList2) { %>
+                                <% if (audit.usite !== 0) { %>
+                                <% %>
+                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %></td>
+                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, audit.list_amount[cindex]), tpUnit) : '' %></td>
+                                <% } %>
+                            <% } %>
+                            </td>
+                        </tr>
+                    <% } %>
+                    </tbody>
+                    <tfoot>
+                    <tr class="info">
+                        <td>合计</td><td></td><td></td><td></td><td></td><td></td>
+                        <td><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
+                        <td><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td>
+                        <% for (const audit of auditList2) { %>
+                            <% if (audit.usite !== 0) { %>
+                        <td></td><td><%=audit.totalCost !== 0 ? ctx.helper.roundNum(audit.totalCost, tpUnit) : '' %></td>
+                            <% } %>
+                        <% } %>
+                    </tr>
+                    </tfoot>
+                </table>
             <% } else if (auditStatus === 6) { %>
 
             <% } %>
@@ -490,7 +603,13 @@
         <div class="c-body tab-pane" role="tabpanel" id="files">
             <table class="table table-bordered">
                 <thead>
-                <tr><th width="50">序号</th><th>名称</th><th width="90">大小</th><th width="100">上传时间</th><th width="100">操作</th></tr>
+                <tr>
+                    <th width="50">序号</th>
+                    <th>名称</th>
+                    <th width="90">大小</th>
+                    <th width="100">上传时间</th>
+                    <th width="100">操作</th>
+                </tr>
                 </thead>
                 <tbody id="attList">
                 <% if (attList !== undefined && attList !== '') { %>
@@ -542,12 +661,39 @@
 <script src="/public/js/datatable/dataTables.fixedColumns.min.js"></script>
 <script src="/public/js/datatable/jlzf-change-table.js"></script>
 <script src="/public/js/change_calculation.js"></script>
-<script src="/public/js/change_detail.js"></script>
 <% if (auditStatus === 1 || auditStatus === 2) { %>
 <script>
     const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
     const changeUnits = JSON.parse('<%- JSON.stringify(changeUnits) %>');
     const totalPriceUnit = '<%- tpUnit %>';
+    const billsTable = {
+        columnDefs: [
+            { className: 'allwidth1', width: 100, targets: 0 },
+            { className: 'allwidth2', width: 150, targets: [1,2] },
+            { className: 'allwidth4', width: 40, targets: 9 },
+            { className: 'allwidth5', width: 60, targets: 3 },
+            { className: 'allwidth3',width: 80, targets: '_all' }
+        ],
+        fixedColumns: {
+            leftColumns: 5
+        }
+    }
 </script>
 <script src="/public/js/change_set.js"></script>
+<% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
+<script>
+    const billsTable = {
+        columnDefs: [
+            { className: 'allwidth1', width: 100, targets: 0 },
+            { className: 'allwidth2', width: 150, targets: [1,2] },
+            { className: 'allwidth5', width: 60, targets: 3 },
+            { className: 'allwidth3',width: 80, targets: '_all' }
+        ],
+        fixedColumns: {
+            leftColumns: 5
+        }
+    }
+</script>
+<script src="/public/js/change_show.js"></script>
 <% } %>
+<script src="/public/js/change_detail.js"></script>

+ 78 - 0
app/view/change/info_modal.ejs

@@ -156,6 +156,84 @@
 </div>
 <% } %>
 
+<% if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
+<!--审批流程/结果-->
+<div class="modal fade" id="sp-list" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">审批流程</h5>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-4">
+                        <div class="card mt-3">
+                            <ul class="list-group list-group-flush">
+                                <% for (const [index,a] of auditList2.entries()) { %>
+                                    <li class="list-group-item">
+                                        <% if (a.usite === 0 ) { %>
+                                            <i class="fa fa-play-circle fa-rotate-90"></i>
+                                        <% } else if (index+1 !== auditList2.length) { %>
+                                            <i class="fa fa-chevron-circle-down"></i>
+                                        <% } else if (index+1 === auditList2.length) { %>
+                                            <i class="fa fa-stop-circle"></i>
+                                        <% } %>
+                                        <%= a.name %>  <small class="text-muted"><%= a.jobs %></small>
+                                    </li>
+                                <% } %>
+                            </ul>
+                        </div>
+                    </div>
+                    <div class="col-8 modal-height-500" style="overflow: auto">
+                        <% for (const time in auditList3) { %>
+                        <div class="card mt-3">
+                            <ul class="list-group list-group-flush">
+                                <% for (const [aindex,al] of auditList3[time].entries()) { %>
+                                <li class="list-group-item">
+                                    <% if (al.usite === 0 && al.status === 3) { %>
+                                    <span class="text-success pull-right">上报</span>
+                                    <% } else if (al.usite !== 0 && al.status === 2) { %>
+                                    <span class="pull-right">审批中</span>
+                                    <% } else if (al.usite !== 0 && al.status === 3) { %>
+                                    <span class="text-success pull-right">审批通过</span>
+                                    <% } else if (al.usite !== 0 && al.status === 4) { %>
+                                    <span class="text-danger pull-right">审批终止</span>
+                                    <% } else if (al.usite !== 0 && (al.status === 5 || al.status === 6)) { %>
+                                    <span class="text-warning pull-right">审批退回 </span>
+                                    <% } %>
+                                    <h5 class="card-title">
+                                        <% if (al.usite === 0 ) { %>
+                                        <i class="fa fa-play-circle fa-rotate-90 text-success"></i>
+                                        <% } else if (al.status === 1 || al.status === 2) { %>
+                                        <i class="fa <% if (aindex+1 === auditList3[time].length) { %>fa-stop-circle<% } else { %>fa-chevron-circle-down<% } %> "></i>
+                                        <% } else if (al.status === 3) { %>
+                                        <i class="fa <% if (aindex+1 === auditList3[time].length) { %>fa-stop-circle<% } else { %>fa-chevron-circle-down<% } %> text-success"></i>
+                                        <% } else if (al.status === 4) { %>
+                                        <i class="fa <% if (aindex+1 === auditList3[time].length) { %>fa-stop-circle<% } else { %>fa-chevron-circle-down<% } %> text-danger"></i>
+                                        <% } else if (al.status === 5 || al.status === 6) { %>
+                                        <i class="fa <% if (aindex+1 === auditList3[time].length) { %>fa-stop-circle<% } else { %>fa-chevron-circle-down<% } %> text-warning"></i>
+                                        <% } %>
+                                        <%= al.name %>&nbsp;<small class="text-muted"><%= al.jobs %></small>
+                                    </h5>
+                                    <% if (al.sin_time !== null || (al.sdesc !== '' && al.sdesc !== null)) { %>
+                                        <p class="card-text"><%= al.sdesc %>&nbsp;<%= moment(al.sin_time).format('YYYY-MM-DD') %></p>
+                                    <% } %>
+                                </li>
+                                <% } %>
+                            </ul>
+                        </div>
+                        <% } %>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>
+<% } %>
+
 <!--添加附件-->
 <div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" id="addfujian">
     <div class="modal-dialog" role="document">